summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraywu <raywu@aaeon.com.tw>2018-09-13 16:11:56 +0800
committerraywu <raywu@aaeon.com.tw>2018-09-13 16:11:56 +0800
commit31bb486c913795c8b67d1c4dbaae2bdec4943fc9 (patch)
treef0e04ad6fe983d8aa11f0f8a808518e39ab408f1
parent465bdc2f8b32bb4cc1ac2c420086ec79ccbd5f78 (diff)
downloadzprj-31bb486c913795c8b67d1c4dbaae2bdec4943fc9.tar.xz
SLP1.0 / SLP2.0 / Default Password / Logo / Fix Boot Order
-rw-r--r--BIOS_CUSTOM/OA20Marker.binbin0 -> 182 bytes
-rw-r--r--BIOS_CUSTOM/OA20PKSign.binbin0 -> 284 bytes
-rw-r--r--BIOS_CUSTOM/OA20PubKey.binbin0 -> 156 bytes
-rw-r--r--BIOS_CUSTOM/logo.jpgbin0 -> 16126 bytes
-rw-r--r--Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.c164
-rw-r--r--Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.cif10
-rw-r--r--Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.mak59
-rw-r--r--Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.sdl55
-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
-rw-r--r--Board/EM/Setup/Setup.unibin24798 -> 24798 bytes
-rw-r--r--CRB/CSP.sdl123
-rw-r--r--Core/EM/SLP20/Marker.bin1
-rw-r--r--Core/EM/SLP20/PubKey.bin1
-rw-r--r--Core/EM/SLP20/SlpSupport.c407
-rw-r--r--Core/EM/SLP20/SlpSupport.chmbin0 -> 41243 bytes
-rw-r--r--Core/EM/SLP20/SlpSupport.cif15
-rw-r--r--Core/EM/SLP20/SlpSupport.dxs73
-rw-r--r--Core/EM/SLP20/SlpSupport.h207
-rw-r--r--Core/EM/SLP20/SlpSupport.mak118
-rw-r--r--Core/EM/SLP20/SlpSupport.sdl52
-rw-r--r--Core/EM/Slp10/OemTable.asm67
-rw-r--r--Core/EM/Slp10/Slp10.c125
-rw-r--r--Core/EM/Slp10/Slp10.chmbin0 -> 24774 bytes
-rw-r--r--Core/EM/Slp10/Slp10.cif14
-rw-r--r--Core/EM/Slp10/Slp10.dxs18
-rw-r--r--Core/EM/Slp10/Slp10.h104
-rw-r--r--Core/EM/Slp10/Slp10.mak83
-rw-r--r--Core/EM/Slp10/Slp10.sdl43
-rw-r--r--EDK/MiniSetup/AMITSE.chmbin0 -> 754045 bytes
-rw-r--r--EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c103
-rw-r--r--EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h104
-rw-r--r--EDK/MiniSetup/BootOnly/EDKhelper.c1737
-rw-r--r--EDK/MiniSetup/BootOnly/EDKhelper.h419
-rw-r--r--EDK/MiniSetup/BootOnly/HookAnchor.c676
-rw-r--r--EDK/MiniSetup/BootOnly/MiniSetup.cif47
-rw-r--r--EDK/MiniSetup/BootOnly/MiniSetup.mak138
-rw-r--r--EDK/MiniSetup/BootOnly/MiniSetup.sdl83
-rw-r--r--EDK/MiniSetup/BootOnly/Resources.c231
-rw-r--r--EDK/MiniSetup/BootOnly/Timer.h91
-rw-r--r--EDK/MiniSetup/BootOnly/amiver.h143
-rw-r--r--EDK/MiniSetup/BootOnly/bbs.c1552
-rw-r--r--EDK/MiniSetup/BootOnly/bbs.h146
-rw-r--r--EDK/MiniSetup/BootOnly/boot.c3034
-rw-r--r--EDK/MiniSetup/BootOnly/box.c241
-rw-r--r--EDK/MiniSetup/BootOnly/box.h95
-rw-r--r--EDK/MiniSetup/BootOnly/buffer.c501
-rw-r--r--EDK/MiniSetup/BootOnly/buffer.h95
-rw-r--r--EDK/MiniSetup/BootOnly/dobmpmgr.c301
-rw-r--r--EDK/MiniSetup/BootOnly/globals.c212
-rw-r--r--EDK/MiniSetup/BootOnly/hiistring.c251
-rw-r--r--EDK/MiniSetup/BootOnly/hiistring.h153
-rw-r--r--EDK/MiniSetup/BootOnly/logo.c1163
-rw-r--r--EDK/MiniSetup/BootOnly/mem.c255
-rw-r--r--EDK/MiniSetup/BootOnly/minisetup.c551
-rw-r--r--EDK/MiniSetup/BootOnly/minisetup.h1519
-rw-r--r--EDK/MiniSetup/BootOnly/minisetupext.c927
-rw-r--r--EDK/MiniSetup/BootOnly/notify.c1271
-rw-r--r--EDK/MiniSetup/BootOnly/password.c253
-rw-r--r--EDK/MiniSetup/BootOnly/password.h111
-rw-r--r--EDK/MiniSetup/BootOnly/postmgmt.c897
-rw-r--r--EDK/MiniSetup/BootOnly/postmgmtext.c964
-rw-r--r--EDK/MiniSetup/BootOnly/print.c476
-rw-r--r--EDK/MiniSetup/BootOnly/protocol.c1870
-rw-r--r--EDK/MiniSetup/BootOnly/protocol.h198
-rw-r--r--EDK/MiniSetup/BootOnly/screen.c346
-rw-r--r--EDK/MiniSetup/BootOnly/screen.h96
-rw-r--r--EDK/MiniSetup/BootOnly/string.c1488
-rw-r--r--EDK/MiniSetup/BootOnly/string.h158
-rw-r--r--EDK/MiniSetup/BootOnly/timer.c154
-rw-r--r--EDK/MiniSetup/BootOnly/variable.c204
-rw-r--r--EDK/MiniSetup/Ezport/Ezport.cif14
-rw-r--r--EDK/MiniSetup/Ezport/Ezport.mak123
-rw-r--r--EDK/MiniSetup/Ezport/Ezport.sdl1057
-rw-r--r--EDK/MiniSetup/Ezport/ezport.c731
-rw-r--r--EDK/MiniSetup/Ezport/ezport.h134
-rw-r--r--EDK/MiniSetup/Ezport/style.c546
-rw-r--r--EDK/MiniSetup/Ezport/style.h247
-rw-r--r--EDK/MiniSetup/Ezport/stylecommon.c1440
-rw-r--r--EDK/MiniSetup/EzportPlus/EzportPlus.cif14
-rw-r--r--EDK/MiniSetup/EzportPlus/EzportPlus.mak130
-rw-r--r--EDK/MiniSetup/EzportPlus/EzportPlus.sdl1073
-rw-r--r--EDK/MiniSetup/EzportPlus/ezportplus.c1251
-rw-r--r--EDK/MiniSetup/EzportPlus/ezportplus.h141
-rw-r--r--EDK/MiniSetup/EzportPlus/style.c625
-rw-r--r--EDK/MiniSetup/EzportPlus/style.h255
-rw-r--r--EDK/MiniSetup/EzportPlus/stylecommon.c1437
-rw-r--r--EDK/MiniSetup/Legacy/Legacy.cif14
-rw-r--r--EDK/MiniSetup/Legacy/Legacy.mak131
-rw-r--r--EDK/MiniSetup/Legacy/Legacy.sdl445
-rw-r--r--EDK/MiniSetup/Legacy/legacy.c1622
-rw-r--r--EDK/MiniSetup/Legacy/legacy.h160
-rw-r--r--EDK/MiniSetup/Legacy/style.c725
-rw-r--r--EDK/MiniSetup/Legacy/style.h259
-rw-r--r--EDK/MiniSetup/Legacy/stylecommon.c1362
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c101
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif10
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak145
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl34
-rw-r--r--EDK/MiniSetup/TSESources.Sdl20
-rw-r--r--EDK/MiniSetup/TSESources.cif20
-rw-r--r--EDK/MiniSetup/TseAdvanced/Bbs.c946
-rw-r--r--EDK/MiniSetup/TseAdvanced/Jpeg6.h123
-rw-r--r--EDK/MiniSetup/TseAdvanced/Logo.c282
-rw-r--r--EDK/MiniSetup/TseAdvanced/MyDefs.h103
-rw-r--r--EDK/MiniSetup/TseAdvanced/TseAdvanced.c3962
-rw-r--r--EDK/MiniSetup/TseAdvanced/TseAdvanced.cif28
-rw-r--r--EDK/MiniSetup/TseAdvanced/TseAdvanced.mak160
-rw-r--r--EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl42
-rw-r--r--EDK/MiniSetup/TseAdvanced/bootflowLib.c199
-rw-r--r--EDK/MiniSetup/TseAdvanced/dogif.c1197
-rw-r--r--EDK/MiniSetup/TseAdvanced/dogifmgr.c486
-rw-r--r--EDK/MiniSetup/TseAdvanced/iJpeg.c253
-rw-r--r--EDK/MiniSetup/TseAdvanced/ipcx.c188
-rw-r--r--EDK/MiniSetup/TseAdvanced/jpeg.h106
-rw-r--r--EDK/MiniSetup/TseAdvanced/jpeg6.c1320
-rw-r--r--EDK/MiniSetup/TseAdvanced/pcx.h138
-rw-r--r--EDK/MiniSetup/TseAdvanced/pcxc.c321
-rw-r--r--EDK/MiniSetup/TseAdvanced/png.c1353
-rw-r--r--EDK/MiniSetup/TseAdvanced/png.h136
-rw-r--r--EDK/MiniSetup/TseAdvanced/pnguncmp.c879
-rw-r--r--EDK/MiniSetup/TseAdvanced/special.c1898
-rw-r--r--EDK/MiniSetup/TseAdvanced/special.h196
-rw-r--r--EDK/MiniSetup/TseLite/Action.c365
-rw-r--r--EDK/MiniSetup/TseLite/AddBootOption.c2548
-rw-r--r--EDK/MiniSetup/TseLite/Date.c1397
-rw-r--r--EDK/MiniSetup/TseLite/Date.h181
-rw-r--r--EDK/MiniSetup/TseLite/Label.c523
-rw-r--r--EDK/MiniSetup/TseLite/Label.h160
-rw-r--r--EDK/MiniSetup/TseLite/ListBox.c1436
-rw-r--r--EDK/MiniSetup/TseLite/ListBox.h186
-rw-r--r--EDK/MiniSetup/TseLite/Memo.c764
-rw-r--r--EDK/MiniSetup/TseLite/Memo.h195
-rw-r--r--EDK/MiniSetup/TseLite/Menu.c1069
-rw-r--r--EDK/MiniSetup/TseLite/Menu.h179
-rw-r--r--EDK/MiniSetup/TseLite/MessageBox.c1192
-rw-r--r--EDK/MiniSetup/TseLite/MessageBox.h207
-rw-r--r--EDK/MiniSetup/TseLite/PopupEdit.c890
-rw-r--r--EDK/MiniSetup/TseLite/PopupEdit.h192
-rw-r--r--EDK/MiniSetup/TseLite/PopupPassword.c1377
-rw-r--r--EDK/MiniSetup/TseLite/PopupPassword.h178
-rw-r--r--EDK/MiniSetup/TseLite/PopupSel.c1646
-rw-r--r--EDK/MiniSetup/TseLite/PopupSel.h229
-rw-r--r--EDK/MiniSetup/TseLite/PopupString.c1283
-rw-r--r--EDK/MiniSetup/TseLite/PopupString.h200
-rw-r--r--EDK/MiniSetup/TseLite/ResetButton.c297
-rw-r--r--EDK/MiniSetup/TseLite/ResetButton.h106
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif49
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/StyleHook.h147
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak114
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl24
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook1.c99
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook10.c97
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook11.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook12.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook13.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook14.c99
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook15.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook16.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook17.c99
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook18.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook19.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook2.c102
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook20.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook21.c100
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook22.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook23.c95
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook24.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook25.c94
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook26.c94
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook27.c95
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook28.c94
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook29.c94
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook3.c101
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook30.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook31.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook32.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook33.c97
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook34.c97
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook35.c93
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook36.c97
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook37.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook38.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook39.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook4.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook5.c99
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook6.c96
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook7.c98
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook8.c97
-rw-r--r--EDK/MiniSetup/TseLite/StyleHook/styleHook9.c96
-rw-r--r--EDK/MiniSetup/TseLite/SubMenu.c876
-rw-r--r--EDK/MiniSetup/TseLite/SubMenu.h197
-rw-r--r--EDK/MiniSetup/TseLite/Text.c587
-rw-r--r--EDK/MiniSetup/TseLite/Text.h154
-rw-r--r--EDK/MiniSetup/TseLite/Time.h180
-rw-r--r--EDK/MiniSetup/TseLite/TseLite.cif73
-rw-r--r--EDK/MiniSetup/TseLite/TseLite.mak124
-rw-r--r--EDK/MiniSetup/TseLite/TseLite.sdl40
-rw-r--r--EDK/MiniSetup/TseLite/TseLiteCommon.c433
-rw-r--r--EDK/MiniSetup/TseLite/TseLitehelper.c1310
-rw-r--r--EDK/MiniSetup/TseLite/UefiAction.c498
-rw-r--r--EDK/MiniSetup/TseLite/UefiAction.h119
-rw-r--r--EDK/MiniSetup/TseLite/action.h163
-rw-r--r--EDK/MiniSetup/TseLite/application.c436
-rw-r--r--EDK/MiniSetup/TseLite/application.h180
-rw-r--r--EDK/MiniSetup/TseLite/callback.c1341
-rw-r--r--EDK/MiniSetup/TseLite/callback.h189
-rw-r--r--EDK/MiniSetup/TseLite/control.c337
-rw-r--r--EDK/MiniSetup/TseLite/control.h171
-rw-r--r--EDK/MiniSetup/TseLite/edit.c636
-rw-r--r--EDK/MiniSetup/TseLite/edit.h166
-rw-r--r--EDK/MiniSetup/TseLite/frame.c2563
-rw-r--r--EDK/MiniSetup/TseLite/frame.h221
-rw-r--r--EDK/MiniSetup/TseLite/hotclick.c230
-rw-r--r--EDK/MiniSetup/TseLite/hotclick.h120
-rw-r--r--EDK/MiniSetup/TseLite/hotkey.c237
-rw-r--r--EDK/MiniSetup/TseLite/hotkey.h157
-rw-r--r--EDK/MiniSetup/TseLite/minisetupext.c2378
-rw-r--r--EDK/MiniSetup/TseLite/minisetupext.h537
-rw-r--r--EDK/MiniSetup/TseLite/numeric.c1430
-rw-r--r--EDK/MiniSetup/TseLite/numeric.h224
-rw-r--r--EDK/MiniSetup/TseLite/object.c211
-rw-r--r--EDK/MiniSetup/TseLite/object.h144
-rw-r--r--EDK/MiniSetup/TseLite/ordlistbox.c1080
-rw-r--r--EDK/MiniSetup/TseLite/ordlistbox.h202
-rw-r--r--EDK/MiniSetup/TseLite/page.c1079
-rw-r--r--EDK/MiniSetup/TseLite/page.h185
-rw-r--r--EDK/MiniSetup/TseLite/popup.c613
-rw-r--r--EDK/MiniSetup/TseLite/popup.h161
-rw-r--r--EDK/MiniSetup/TseLite/time.c1121
-rw-r--r--EDK/MiniSetup/TseLite/variable.c1488
-rw-r--r--EDK/MiniSetup/changelog.log1458
-rw-r--r--EDK/MiniSetup/uefi2.0/FormBrowser.c591
-rw-r--r--EDK/MiniSetup/uefi2.0/Hiicallback.c429
-rw-r--r--EDK/MiniSetup/uefi2.0/Uefi20.cif16
-rw-r--r--EDK/MiniSetup/uefi2.0/ctrlcond.c840
-rw-r--r--EDK/MiniSetup/uefi2.0/ctrlcond.h113
-rw-r--r--EDK/MiniSetup/uefi2.0/hii.c3273
-rw-r--r--EDK/MiniSetup/uefi2.0/hii.h328
-rw-r--r--EDK/MiniSetup/uefi2.0/uefi20.mak128
-rw-r--r--EDK/MiniSetup/uefi2.0/uefi20.sdl53
-rw-r--r--EDK/MiniSetup/uefi2.0/uefi20Wapper.c2428
-rw-r--r--EDK/MiniSetup/uefi2.1/CtrlCond.c806
-rw-r--r--EDK/MiniSetup/uefi2.1/CtrlCond.h146
-rw-r--r--EDK/MiniSetup/uefi2.1/Expression.c2861
-rw-r--r--EDK/MiniSetup/uefi2.1/FormBrowser2.c1175
-rw-r--r--EDK/MiniSetup/uefi2.1/FormBrowser2.h156
-rw-r--r--EDK/MiniSetup/uefi2.1/Hii.c3557
-rw-r--r--EDK/MiniSetup/uefi2.1/HiiCallback.c1073
-rw-r--r--EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c740
-rw-r--r--EDK/MiniSetup/uefi2.1/Parse.c4700
-rw-r--r--EDK/MiniSetup/uefi2.1/TseUefiHii.h951
-rw-r--r--EDK/MiniSetup/uefi2.1/Uefi21.cif21
-rw-r--r--EDK/MiniSetup/uefi2.1/Uefi21.mak134
-rw-r--r--EDK/MiniSetup/uefi2.1/Uefi21.sdl71
-rw-r--r--EDK/MiniSetup/uefi2.1/Uefi21Wapper.c8266
-rw-r--r--EDK/MiniSetup/uefi2.1/UefiTianoHii.h241
-rw-r--r--FixedBootOrder.cif19
-rw-r--r--RomImage/FitcBuild.bat2
-rw-r--r--SharkBayDT.veb16
277 files changed, 142397 insertions, 1 deletions
diff --git a/BIOS_CUSTOM/OA20Marker.bin b/BIOS_CUSTOM/OA20Marker.bin
new file mode 100644
index 0000000..9e65faa
--- /dev/null
+++ b/BIOS_CUSTOM/OA20Marker.bin
Binary files differ
diff --git a/BIOS_CUSTOM/OA20PKSign.bin b/BIOS_CUSTOM/OA20PKSign.bin
new file mode 100644
index 0000000..cf8aeac
--- /dev/null
+++ b/BIOS_CUSTOM/OA20PKSign.bin
Binary files differ
diff --git a/BIOS_CUSTOM/OA20PubKey.bin b/BIOS_CUSTOM/OA20PubKey.bin
new file mode 100644
index 0000000..4982ea8
--- /dev/null
+++ b/BIOS_CUSTOM/OA20PubKey.bin
Binary files differ
diff --git a/BIOS_CUSTOM/logo.jpg b/BIOS_CUSTOM/logo.jpg
new file mode 100644
index 0000000..110f161
--- /dev/null
+++ b/BIOS_CUSTOM/logo.jpg
Binary files differ
diff --git a/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.c b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.c
new file mode 100644
index 0000000..7211a96
--- /dev/null
+++ b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.c
@@ -0,0 +1,164 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2008, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: $
+//
+// $Revision: $
+//
+// $Date: $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: $
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: <This File Name>
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "token.h"
+#include <EFI.h>
+#include <AMIVfr.h>
+#include <Protocol/SimpleTextIn.h>
+#include <Protocol/EfiOEMBadging.h>
+
+#if EFI_SPECIFICATION_VERSION>0x20000
+#include <UefiHii.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/HiiString.h>
+#else
+#include <Protocol/Hii.h>
+#endif //EFI_SPECIFICATION_VERSION>0x20000
+
+#include "commonoem.h"
+
+extern VOID PasswordEncodeHook( CHAR16 *Password, UINTN MaxSize);
+extern VOID *VarGetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size );
+extern EFI_STATUS VarSetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size );
+extern VOID *VarGetNvram( UINT32 variable, UINTN *size );
+extern EFI_STATUS VarSetNvram( UINT32 variable, VOID *buffer, UINTN size );
+extern VOID *EfiLibAllocateZeroPool ( IN UINTN AllocationSize);
+extern VOID MemFreePointer( VOID **ptr );
+extern VOID
+ EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ );
+extern VOID MemCopy( VOID *dest, VOID *src, UINTN size );
+extern VOID MemSet( VOID *buffer, UINTN size, UINT8 value );
+
+extern EFI_RUNTIME_SERVICES *gRT;
+
+
+#define VARIABLE_ID_AMITSESETUP 5
+#define ___INTERNAL_CONVERT_TO_WSTRING___(a) L#a
+#define CONVERT_TO_WSTRING(a) ___INTERNAL_CONVERT_TO_WSTRING___(a)
+
+VOID OemSetDefaultPasswordHook(VOID)
+{
+ EFI_STATUS Status;
+ //CHAR16 *AdminPassword, *UserPassword;
+ CHAR16 *AdminPassword;
+ #if defined(USER_PASSWORD_SUPPORT) && (USER_PASSWORD_SUPPORT == 1)
+ CHAR16 *UserPassword;
+ #endif
+ CHAR16 *EncPass=NULL;
+ const UINTN TsePasswordLength = SETUP_PASSWORD_LENGTH;
+
+ EFI_GUID AmiTseSetupGuid = AMITSESETUP_GUID;
+ AMITSESETUP AmiTseSetup;
+ UINT32 Attrib=0;
+ UINTN Size=0;
+
+ UINT16 Buffer;
+ EFI_GUID EfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID;
+
+ Size = sizeof(UINT16);
+
+ // Check first boot
+ Status = gRT->GetVariable(L"OemFirstBoot", &EfiGlobalVariableGuid, NULL, &Size, &Buffer);
+ if (EFI_ERROR(Status))
+ {
+ Buffer = 1;
+ Status = gRT->SetVariable(L"OemFirstBoot",
+ &EfiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ Size,
+ &Buffer);
+ }
+ else
+ return;
+
+ // Initial
+ AdminPassword = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16));
+ #if defined(USER_PASSWORD_SUPPORT) && (USER_PASSWORD_SUPPORT == 1)
+ UserPassword = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16));
+ #endif
+ EncPass = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16));
+
+ AdminPassword = CONVERT_TO_WSTRING(DEFAULT_ADMIN_PASSWORD);
+ #if defined(USER_PASSWORD_SUPPORT) && (USER_PASSWORD_SUPPORT == 1)
+ UserPassword = CONVERT_TO_WSTRING(DEFAULT_USER_PASSWORD);
+ #endif
+
+ // Get Setting
+ Size = sizeof(AMITSESETUP);
+ Status = gRT->GetVariable(L"AMITSESetup", &AmiTseSetupGuid, &Attrib, &Size, &AmiTseSetup);
+
+ // Set Admin password
+ EfiStrCpy( EncPass, AdminPassword );
+ PasswordEncodeHook( EncPass, TsePasswordLength*sizeof(CHAR16));
+ MemCopy(&AmiTseSetup.AdminPassword, EncPass, TsePasswordLength*sizeof(CHAR16));
+
+ // Clear EncPass buffer
+ MemSet(EncPass, (TsePasswordLength + 1)*sizeof(CHAR16), 0);
+
+ #if defined(USER_PASSWORD_SUPPORT) && (USER_PASSWORD_SUPPORT == 1)
+ // Set user password
+ EfiStrCpy( EncPass, UserPassword);
+ PasswordEncodeHook( EncPass, TsePasswordLength*sizeof(CHAR16));
+ MemCopy(&AmiTseSetup.UserPassword, EncPass, TsePasswordLength*sizeof(CHAR16));
+ #endif
+
+ Status = gRT->SetVariable(L"AMITSESetup", &AmiTseSetupGuid, Attrib, Size, &AmiTseSetup);
+
+ // Free all pool
+ MemFreePointer((VOID**) &EncPass);
+ MemFreePointer((VOID**) &AdminPassword);
+ #if defined(USER_PASSWORD_SUPPORT) && (USER_PASSWORD_SUPPORT == 1)
+ MemFreePointer((VOID**) &UserPassword);
+ #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/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.cif b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.cif
new file mode 100644
index 0000000..5b5491e
--- /dev/null
+++ b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.cif
@@ -0,0 +1,10 @@
+<component>
+ name = "OemDefualtPwdHook - Set Default Password"
+ category = ModulePart
+ LocalRoot = "Board\AAEON\OEMFeatures\OEMDefaultPwdHook\"
+ RefName = "OEMDefaultPwdHook"
+[files]
+"OEMDefaultPwdHook.c"
+"OEMDefaultPwdHook.sdl"
+"OEMDefaultPwdHook.mak"
+<endComponent>
diff --git a/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.mak b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.mak
new file mode 100644
index 0000000..8390c40
--- /dev/null
+++ b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.mak
@@ -0,0 +1,59 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2007, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: $
+#
+# $Revision: $
+#
+# $Date: $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: $
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: OemTseHook.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+AMITSEBin : $(BUILD_DIR)\OEMDefaultPwdHook.obj
+
+OEMDefaultPwdHook_CFLAGS=$(CFLAGS) \
+ -I $(TSESRC_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(TSEBIN_DIR)
+
+$(BUILD_DIR)\OEMDefaultPwdHook.obj : $(OemDefaultPwdHook_DIR)\OEMDefaultPwdHook.obj
+ $(CC) $(OEMDefaultPwdHook_CFLAGS) /Fo$(BUILD_DIR)\OEMDefaultPwdHook.obj $(OemDefaultPwdHook_DIR)\OEMDefaultPwdHook.c
+
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2007, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 6145-F Northbelt Pkwy, Norcross, GA 30071 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.sdl b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.sdl
new file mode 100644
index 0000000..b15a940
--- /dev/null
+++ b/Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.sdl
@@ -0,0 +1,55 @@
+TOKEN
+ Name = "OEMDefultPwdHook_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable OEMTSEHook support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "OemDefaultPwdHook_DIR"
+End
+
+MODULE
+ Help = "Includes OemDefaultPwdHook.mak to Project"
+ File = "OemDefaultPwdHook.mak"
+End
+
+TOKEN
+ Name = "DEFAULT_ADMIN_PASSWORD"
+ Value = "Grg90#@B"
+ Help = "Set default admin password"
+ TokenType = Expression
+ TargetH = Yes
+End
+TOKEN
+ Name = "USER_PASSWORD_SUPPORT"
+ Value = "0"
+ TokenType = Boolean
+ TargetH = Yes
+ ##TargetEQU = Yes
+ ##TargetMAK = Yes
+End
+TOKEN
+ Name = "DEFAULT_USER_PASSWORD"
+ Value = ""
+ Help = "Set default user password"
+ TokenType = Expression
+ TargetH = Yes
+ Token = "USER_PASSWORD_SUPPORT" "=" "1"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\OEMDefaultPwdHook.obj"
+ Parent = "AMITSE_Objects"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "OemSetDefaultPasswordHook,"
+ Parent = "MinisetupDriverEntryHookHook,"
+ InvokeOrder = AfterParent
+End
+
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 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Board/EM/Setup/Setup.uni b/Board/EM/Setup/Setup.uni
index c3d893c..d6d5d35 100644
--- a/Board/EM/Setup/Setup.uni
+++ b/Board/EM/Setup/Setup.uni
Binary files differ
diff --git a/CRB/CSP.sdl b/CRB/CSP.sdl
index 2dc50a6..c9fb820 100644
--- a/CRB/CSP.sdl
+++ b/CRB/CSP.sdl
@@ -1510,3 +1510,126 @@ ELINK
# Token = "BEEP_ENABLE" "=" "1"
InvokeOrder = AfterParent
End
+
+TOKEN
+ Name = "PASSWORD_MIN_SIZE"
+ Value = "8"
+ TokenType = Integer
+ TargetH = Yes
+End
+TOKEN
+ Name = "SETUP_PASSWORD_LENGTH"
+ Value = "12"
+ Help = "Default maximum password length. TSE Source needed to change the length"
+ TokenType = Integer
+ TargetH = Yes
+End
+TOKEN
+ Name = "SETUP_ENTRY_SCAN"
+ Value = "EFI_SCAN_F11"
+ Help = "Set to one of the defined constants from EFI_SIMPLE_TEXT_INPUT protocol. Remember to check STR_DEL_ENTER_SETUP string in MiniSetupStr.uni."
+ TokenType = Expression
+ TargetH = Yes
+End
+TOKEN
+ Name = "POPUP_MENU_ENTRY_SCAN"
+ Value = "EFI_SCAN_F10"
+ Help = "Set to one of the defined constants from EFI_SIMPLE_TEXT_INPUT protocol"
+ TokenType = Expression
+ TargetH = Yes
+ Token = "SETUP_BBS_POPUP_ENABLE" "!=" "0"
+End
+TOKEN
+ Name = "TSE_DEFAULT_SETUP_PASSWORD_SUPPORT"
+ Value = "1"
+ Help = "0 is default.set 1=> to Enable default setup password"
+ TokenType = Expression
+ TargetH = Yes
+ TargetMAK = Yes
+End
+TOKEN
+ Name = "DEFAULT_SETUP_PWD_AT_FIRSTBOOT_ONLY"
+ Value = "0"
+ Help = "1 is default. 1 => Sets the TSE_ADMIN_PASSWORD and TSE_USER_PASSWORD at first boot only. 0 => Sets TSE_ADMIN_PASSWORD and TSE_USER_PASSWORD in TSE defaults, on load defaults these data will be loaded"
+ TokenType = Expression
+ TargetH = Yes
+ TargetMAK = Yes
+ Token = "TSE_DEFAULT_SETUP_PASSWORD_SUPPORT" "=" "1"
+End
+TOKEN
+ Name = "TSE_ADMIN_PASSWORD"
+ Value = "Grg90#@B"
+ Help = "Defaultly no password is given. Need TSE source to change this. Provide data to set as default admin password. Maximum string can be provide is based on SETUP_PASSWORD_LENGTH token. String should be atleat minimum length mentioned in vfr. If no password is given it will not set any default password. Note: specify EMPTY_DATA in value if default admin password is not required"
+ TokenType = Expression
+ TargetH = Yes
+ TargetMAK = Yes
+ Token = "TSE_DEFAULT_SETUP_PASSWORD_SUPPORT" "=" "1"
+End
+TOKEN
+ Name = "TSE_DONOT_LOAD_PASSWORD_ON_DEFAULTS"
+ Value = "1"
+ Help = "1 => Will not load defaults for password when we press F3. 0 => Load default passowrd."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_SUPPORT_NATIVE_RESOLUTION"
+ Value = "0"
+ Help = "Sets the graphics mode for quiet boot from EDID. 1 - Defaultly enable make 0 to disable the feature"
+ TokenType = Boolean
+ TargetH = Yes
+End
+TOKEN
+ Name = "GC_MODE0"
+ Value = "{ 0, 80, 25, 640, 480 }"
+ Help = "Parameters of the graphica console text mode 0.\NOTE: Text resolution of the mode 0 must be 80 by 25\Format: {ModeNumber, TextColomns,TextRows, HorizontalPixels,VerticalPixels}"
+ TokenType = Expression
+ TargetH = Yes
+# Token = "WIN8_FEATURE_SUPPORT" "=" "1"
+End
+TOKEN
+ Name = "SETUP_JPEG_LOGO_SUPPORT"
+ Value = "1"
+ Help = "JPEG Logo support in Setup."
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+End
+TOKEN
+ Name = "SETUP_BMP_LOGO_SUPPORT"
+ Value = "0"
+ Help = "BMP Logo support in Setup"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+TOKEN
+ Name = "LOGO_FILE_NAME"
+ Value = "BIOS_CUSTOM\logo.jpg"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "SLP_MARKER_ROM_FILENAME"
+ Value = "BIOS_CUSTOM\OA20Marker.bin"
+ Help = "SLP2.0 Marker key rom file"
+ TokenType = File
+ TargetMAK = Yes
+End
+TOKEN
+ Name = "SLP_PUBKEY_ROM_FILENAME"
+ Value = "BIOS_CUSTOM\OA20PubKey.bin"
+ Help = "SLP2.0 Public key rom file"
+ TokenType = File
+ TargetMAK = Yes
+End
+TOKEN
+ Name = "SLP_STRING"
+ Value = "GRGBankingIPC1"
+ Help = "SLP string."
+ TokenType = Expression
+ TargetEQU = Yes
+End
diff --git a/Core/EM/SLP20/Marker.bin b/Core/EM/SLP20/Marker.bin
new file mode 100644
index 0000000..8b3aeed
--- /dev/null
+++ b/Core/EM/SLP20/Marker.bin
@@ -0,0 +1 @@
+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ \ No newline at end of file
diff --git a/Core/EM/SLP20/PubKey.bin b/Core/EM/SLP20/PubKey.bin
new file mode 100644
index 0000000..2910e3c
--- /dev/null
+++ b/Core/EM/SLP20/PubKey.bin
@@ -0,0 +1 @@
+ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ \ No newline at end of file
diff --git a/Core/EM/SLP20/SlpSupport.c b/Core/EM/SLP20/SlpSupport.c
new file mode 100644
index 0000000..0159473
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.c
@@ -0,0 +1,407 @@
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
+
+//****************************************************************************
+// $Header: /Alaska/BIN/Modules/SLP/SlpSupport.c 12 8/03/11 2:45p Vyacheslava $
+//
+// $Revision: 12 $
+//
+// $Date: 8/03/11 2:45p $
+//****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/SLP/SlpSupport.c $
+//
+// 12 8/03/11 2:45p Vyacheslava
+//
+// 11 8/01/11 3:25p Vyacheslava
+// [TAG] EIP64110
+// [Category] Spec Update
+// [Severity] Normal
+// [Description] This file has been updated to be compliant with PI 1.2,
+// and UEFI 2.3.1 specifications.
+//
+// 10 7/12/11 4:44p Vyacheslava
+//
+// 9 7/12/11 3:56p Vyacheslava
+//
+// 8 7/01/11 12:19p Vyacheslava
+// [TAG] EIP63678
+// [Category] Improvement
+// [Description] Added checking for dummy binaries.
+//
+// 7 7/01/11 12:00p Vyacheslava
+// [TAG] EIP63678
+// [Category] New Feature
+// [Description] Preserve the OEM Activation SLIC during the BIOS
+// recovery path.
+// [Files] SlpSupport.sdl
+// SlpSupport.mak
+// SlpSupport.c
+// SlpSupport.dxs
+// SlpSupport.h
+// SlpSupport.cif
+//
+// 6 8/25/10 11:44a Vyacheslava
+// Added comments.
+//
+// 5 5/18/10 4:15p Vyacheslava
+// Update for OEM ID and OEM Table ID from the Marker binary. (EIP#38438)
+//
+// 4 8/19/09 10:47a Vyacheslava
+// Added support for ACPI 3.0 (EIP#25335 )
+//
+// 3 6/01/09 4:53p Vyacheslava
+// EIP#22212: Synopsis: (1) SimpleBootFlag, (2) SLP, (3) CSPLibrary
+// Description: Aptio Enhancement Guidelines for Engineers
+//
+// 2 10/09/07 3:55p Vyacheslava
+// Fixed issue with token conversion. Added function CopyToken.
+//
+// 1 3/30/07 3:39p Felixp
+//
+//****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SlpSupport.c
+//
+// Description:
+// Updated the XSDT with the SLIC OEM Activation ACPI Table.
+//
+//<AMI_FHDR_END>
+//****************************************************************************
+
+
+//---------------------------------------------------------------------------
+
+#include <AmiDxeLib.h>
+#include <Protocol/AcpiTable.h>
+#include <AmiHobs.h>
+#include "SlpSupport.h"
+
+//---------------------------------------------------------------------------
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: LocateAndLoadRawData
+//
+// Description: This fills the PubKey and Marker structures of SLIC table.
+//
+// Input:
+// *FfsGuid - Pointer to GUID of the FFS file to read
+// *Address - Address of the buffer to read data into
+// Size - Size of the buffer
+//
+// Output:
+// EFI_STATUS - Sucessful
+// EFI_NOT_FOUND - Couldn't find the binaries
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS LocateAndLoadRawData(
+ IN EFI_GUID *FfsGuid,
+ IN VOID *Address,
+ IN UINTN Size )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer = NULL;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ UINT32 Authentication;
+
+#if PI_SPECIFICATION_VERSION >= 0x0001000A
+ EFI_GUID EfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVolumeProtocol = NULL;
+#else
+ EFI_GUID EfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *FwVolumeProtocol = NULL;
+#endif
+
+ // Locate the Firmware volume protocol
+ Status = pBS->LocateHandleBuffer(
+ ByProtocol,
+ &EfiFirmwareVolumeProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // Find and read raw data
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+
+ Status = pBS->HandleProtocol(
+ HandleBuffer[Index],
+ &EfiFirmwareVolumeProtocolGuid,
+ &FwVolumeProtocol
+ );
+ if (EFI_ERROR(Status))
+ continue;
+
+ Status = FwVolumeProtocol->ReadSection(
+ FwVolumeProtocol,
+ FfsGuid,
+ EFI_SECTION_RAW,
+ 0x0,
+ &Address,
+ &Size,
+ &Authentication
+ );
+ if (Status == EFI_SUCCESS)
+ break;
+ }
+
+ pBS->FreePool(HandleBuffer);
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: PreserveSlicBinaries
+//
+// Description: This function preserves the the Marker and PubKey binaries.
+//
+// Input: VOID
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PreserveSlicBinaries(VOID)
+{
+ EFI_STATUS Status = EFI_NOT_FOUND;
+ RECOVERY_IMAGE_HOB *RecoveryHob;
+ EFI_GUID HobListGuid = HOB_LIST_GUID;
+ EFI_GUID RecoveryHobGuid = AMI_RECOVERY_IMAGE_HOB_GUID;
+ EFI_GUID PubKeyGuid = OEM_SLP_PUBLIC_KEY_GUID;
+ EFI_GUID MarkerGuid = OEM_SLP_MARKER_GUID;
+ EFI_CONFIGURATION_TABLE *Table = pST->ConfigurationTable;
+ EFI_PHYSICAL_ADDRESS Addr;
+ UINTN i;
+ UINT8 *FwPubKeyPtr = NULL;
+ UINT8 *FwMarkerPtr = NULL;
+ UINT8 *RecPubKeyPtr = NULL;
+ UINT8 *RecMarkerPtr = NULL;
+
+ // Find the Product Key place in the recovery HOB
+ for( i = 0; i < pST->NumberOfTableEntries; i++, Table++ ) {
+
+ if ( !MemCmp(&Table->VendorGuid, &HobListGuid, sizeof(EFI_GUID)) ) {
+
+ RecoveryHob = Table->VendorTable;
+ Status = FindNextHobByGuid(&RecoveryHobGuid, &RecoveryHob);
+ if (!EFI_ERROR(Status)) {
+
+ // Find Public Key and Marker binaries in the Recovery image
+ Status = EFI_NOT_FOUND;
+ for ( Addr = RecoveryHob->Address; Addr < RecoveryHob->Address + FLASH_SIZE; Addr++ ) {
+
+ // Find the Public Key binary GUID
+ if ( !MemCmp((UINT8*)Addr, &PubKeyGuid, sizeof(EFI_GUID)) )
+ RecPubKeyPtr = (UINT8*)Addr;
+
+ // Find the Marker binary GUID
+ else if ( !MemCmp((UINT8*)Addr, &MarkerGuid, sizeof(EFI_GUID)) )
+ RecMarkerPtr = (UINT8*)Addr;
+
+ // if all binaries are found then find original places in the Firmware
+ if ( RecPubKeyPtr != NULL && RecMarkerPtr != NULL ) {
+
+ // Find Public Key and Marker binaries in the BIOS firmware
+ for ( Addr = FLASH_DEVICE_BASE_ADDRESS; Addr < FLASH_UPPER_ADDRESS; Addr++ ) {
+
+ // Find the Public Key binary GUID
+ if ( !MemCmp((UINT8*)Addr, &PubKeyGuid, sizeof(EFI_GUID)) )
+ FwPubKeyPtr = (UINT8*)Addr;
+
+ // Find the Marker binary GUID
+ else if ( !MemCmp((UINT8*)Addr, &MarkerGuid, sizeof(EFI_GUID)) )
+ FwMarkerPtr = (UINT8*)Addr;
+
+ // Preserve the SLIC binaries
+ if ( FwPubKeyPtr != NULL && FwMarkerPtr != NULL ) {
+
+ MemCpy(
+ RecPubKeyPtr,
+ FwPubKeyPtr,
+ sizeof(OEM_PUBLIC_KEY_STRUCTURE) + sizeof(EFI_FFS_FILE_HEADER) + sizeof(UINT16)
+ );
+
+ MemCpy(
+ RecMarkerPtr,
+ FwMarkerPtr,
+ sizeof(WINDOWS_MARKER_STRUCTURE) + sizeof(EFI_FFS_FILE_HEADER) + sizeof(UINT16)
+ );
+
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ TRACE((TRACE_ALWAYS,"PreserveSlicBinaries: Status = %r\n",Status));
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: PublishSlicTable
+//
+// Description: This function publish SLIC table in the ACPI.
+//
+// Input: VOID
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PublishSlicTable(VOID)
+{
+ EFI_STATUS Status;
+ EFI_GUID PubKeyGuid = OEM_SLP_PUBLIC_KEY_GUID;
+ EFI_GUID MarkerGuid = OEM_SLP_MARKER_GUID;
+ EFI_ACPI_SLP SlpTable = {
+ {SLIC_SIG, sizeof(EFI_ACPI_SLP), 0x01, 0x00, {0}, {0}, ACPI_OEM_REV, CREATOR_ID_AMI, CREATOR_REV_MS},
+ {0},
+ {0}
+ };
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol = NULL;
+ UINTN TableKey = 0;
+
+ // Locate SLP Public Key binary
+ Status = LocateAndLoadRawData(
+ &PubKeyGuid,
+ &SlpTable.PubKey,
+ sizeof(SlpTable.PubKey)
+ );
+ if (EFI_ERROR(Status)) {
+ TRACE((TRACE_ALWAYS, "Slp Public Key Binaries Not Found!\n"));
+ return Status;
+ }
+
+ // Locate SLP Marker binary
+ Status = LocateAndLoadRawData(
+ &MarkerGuid,
+ &SlpTable.WinMarker,
+ sizeof(SlpTable.WinMarker)
+ );
+ if (EFI_ERROR(Status)) {
+ TRACE((TRACE_ALWAYS, "Slp Marker Binaries Not Found!\n"));
+ return Status;
+ }
+
+ // The dummy SLIC will be not published
+ if ( SlpTable.WinMarker.StructType == 0xFFFFFFFF && SlpTable.PubKey.StructType == 0xFFFFFFFF ) {
+ TRACE((TRACE_ALWAYS, "SlpSupport: Found dummy binaries. The SLIC will be not published!\n"));
+ return EFI_ABORTED;
+ }
+
+ // Copy OEM ID and OEM Table ID from Marker's binary to SLIC header
+ MemCpy(
+ (UINT8*)&SlpTable.Header.OemId,
+ (UINT8*)&SlpTable.WinMarker.sOEMID,
+ sizeof(SlpTable.WinMarker.sOEMID)
+ );
+ MemCpy(
+ (UINT8*)&SlpTable.Header.OemTblId,
+ (UINT8*)&SlpTable.WinMarker.sOEMTABLEID,
+ sizeof(SlpTable.WinMarker.sOEMTABLEID)
+ );
+
+ // Locate the ACPI table protocol
+ Status = pBS->LocateProtocol(
+ &gEfiAcpiTableProtocolGuid,
+ NULL,
+ &AcpiTableProtocol
+ );
+ if (EFI_ERROR(Status)) {
+ TRACE((TRACE_ALWAYS, "Unable to locate AcpiTableProtocol!\n"));
+ return Status;
+ }
+
+ // Publish SLIC to ACPI table
+ Status = AcpiTableProtocol->InstallAcpiTable(
+ AcpiTableProtocol,
+ &SlpTable,
+ sizeof(EFI_ACPI_SLP),
+ &TableKey
+ );
+ if (!EFI_ERROR(Status))
+ TRACE((TRACE_ALWAYS, "SLIC table has been published.\n"));
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SlpSupport_EntryPoint
+//
+// Description: This function is the entry point of the eModule.
+//
+// Input:
+// ImageHandle - Image handle
+// *SystemTable - Pointer to the system table
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS EFIAPI SlpSupport_EntryPoint(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ InitAmiLib(ImageHandle, SystemTable);
+
+ // Check if it's a Recovery Mode then preserve the Marker and PubKey binaries
+ if (GetBootMode() == BOOT_IN_RECOVERY_MODE)
+ Status = PreserveSlicBinaries();
+ if (!EFI_ERROR(Status))
+ Status = PublishSlicTable();
+
+ return Status;
+}
+
+
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
diff --git a/Core/EM/SLP20/SlpSupport.chm b/Core/EM/SLP20/SlpSupport.chm
new file mode 100644
index 0000000..2178c61
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.chm
Binary files differ
diff --git a/Core/EM/SLP20/SlpSupport.cif b/Core/EM/SLP20/SlpSupport.cif
new file mode 100644
index 0000000..10d9d5b
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.cif
@@ -0,0 +1,15 @@
+<component>
+ name = "SlpSupport"
+ category = eModule
+ LocalRoot = "Core\EM\SLP20"
+ RefName = "SlpSupport"
+[files]
+"SlpSupport.sdl"
+"SlpSupport.mak"
+"SlpSupport.c"
+"SlpSupport.dxs" = "dxs"
+"Marker.bin"
+"PubKey.bin"
+"SlpSupport.chm"
+"SlpSupport.h"
+<endComponent>
diff --git a/Core/EM/SLP20/SlpSupport.dxs b/Core/EM/SLP20/SlpSupport.dxs
new file mode 100644
index 0000000..d45ab61
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.dxs
@@ -0,0 +1,73 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//*****************************************************************************
+// $Header: /Alaska/BIN/Modules/SLP/SlpSupport.dxs 3 8/01/11 5:07p Vyacheslava $
+//
+// $Revision: 3 $
+//
+// $Date: 8/01/11 5:07p $
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/SLP/SlpSupport.dxs $
+//
+// 3 8/01/11 5:07p Vyacheslava
+//
+// 2 7/01/11 12:00p Vyacheslava
+// [TAG] EIP63678
+// [Category] New Feature
+// [Description] Preserve the OEM Activation SLIC during the BIOS
+// recovery path.
+// [Files] SlpSupport.sdl
+// SlpSupport.mak
+// SlpSupport.c
+// SlpSupport.dxs
+// SlpSupport.h
+// SlpSupport.cif
+//
+//
+//*****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SlpSupport.dxs
+//
+// Description: This file is the dependency file for SlpSupport eModule.
+//
+//<AMI_FHDR_END>
+//*****************************************************************************
+
+//----------------------------------------------------------------------------
+// Header files for GUID definitions
+//----------------------------------------------------------------------------
+
+#include <Protocol/AcpiTable.h>
+
+DEPENDENCY_START
+ EFI_ACPI_TABLE_PROTOCOL_GUID
+DEPENDENCY_END
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/SLP20/SlpSupport.h b/Core/EM/SLP20/SlpSupport.h
new file mode 100644
index 0000000..fd44e5d
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.h
@@ -0,0 +1,207 @@
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
+
+//****************************************************************************
+// $Header: /Alaska/BIN/Modules/SLP/SlpSupport.h 4 8/01/11 3:26p Vyacheslava $
+//
+// $Revision: 4 $
+//
+// $Date: 8/01/11 3:26p $
+//****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/SLP/SlpSupport.h $
+//
+// 4 8/01/11 3:26p Vyacheslava
+// [TAG] EIP64110
+// [Category] Spec Update
+// [Severity] Normal
+// [Description] This file has been updated to be compliant with PI 1.2,
+// and UEFI 2.3.1 specifications.
+//
+// 3 7/01/11 12:00p Vyacheslava
+// [TAG] EIP63678
+// [Category] New Feature
+// [Description] Preserve the OEM Activation SLIC during the BIOS
+// recovery path.
+// [Files] SlpSupport.sdl
+// SlpSupport.mak
+// SlpSupport.c
+// SlpSupport.dxs
+// SlpSupport.h
+// SlpSupport.cif
+//
+// 2 8/25/10 11:45a Vyacheslava
+// Changed comments for better representation in the CHM file.
+//
+// 1 5/18/10 4:11p Vyacheslava
+//
+//
+//****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SlpSupport.h
+//
+// Description: SlpSupport Header file.
+//
+//<AMI_FHDR_END>
+//****************************************************************************
+
+#ifndef __SLP_SUPPORT__H__
+#define __SLP_SUPPORT__H__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//------------------------------------------------------------------------
+
+#include <EFI.h>
+#include <Token.h>
+#include <Acpi.h>
+
+//------------------------------------------------------------------------
+
+#define SLIC_SIG 0x43494c53 //"SLIC" Microsoft System Locked Preinstallation Table
+
+#define OEM_SLP_PUBLIC_KEY_GUID \
+ { 0x996aa1e0, 0x1e8c, 0x4f36, 0xb5, 0x19, 0xa1, 0x70, 0xa2, 0x06, 0xfc, 0x14 }
+
+#define OEM_SLP_MARKER_GUID \
+ { 0x69009842, 0x63f2, 0x43db, 0x96, 0x4b, 0xef, 0xad, 0x1c, 0x39, 0xec, 0x85 }
+
+#define FLASH_UPPER_ADDRESS 0xFFFFFFFF
+#define FLASH_DEVICE_BASE_ADDRESS (FLASH_UPPER_ADDRESS-FLASH_SIZE+1)
+
+//------------------------------------------------------------------------
+
+#pragma pack (1)
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: OEM_PUBLIC_KEY_STRUCTURE
+//
+// Description: This structure comes out of the document:
+// OEM Activation version 2.0 for M$ Windows Vista (tm) Operating System.
+//
+// Fields:
+// Name Type Description
+// ------------------------------------------------------------------
+// StructType UINT32 0x00000000 = PubKey Structure.
+// LicensingData UINT32 Length, in bytes, of OEM pub key struct (156).
+// bType UINT8 Public Key Type [PUBLICKEYBLOB (6)].
+// bVersion UINT8 Version, currently 2 (7/27/2006).
+// Reserved UINT16 Zero.
+// aiKeyAlg UINT32 Key Algorithm. [CALG_RSA_SIGN (0x00002400)].
+// Magic UINT32 bytes: 'RSA1'.
+// BitLen UINT32 1024 converted to hex.
+// Pubexp UINT32 Exponent of Public Key, usually 257 converted to hex.
+// Modulus UINT8 Array. Modulus, modulues of the public key 128 bytes.
+//
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+
+typedef struct {
+ UINT32 StructType;
+ UINT32 LicensingData;
+ UINT8 bType;
+ UINT8 bVersion;
+ UINT16 Reserved;
+ UINT32 aiKeyAlg;
+ UINT32 Magic;
+ UINT32 Bitlen;
+ UINT32 Pubexp;
+ UINT8 Modulus[128];
+} OEM_PUBLIC_KEY_STRUCTURE;
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: WINDOWS_MARKER_STRUCTURE
+//
+// Description: This structure comes out of the document:
+// OEM Activation version 2.0 for M$ Windows Vista (tm) Operating System.
+//
+// Fields:
+// Name Type Description
+// ------------------------------------------------------------------
+// StructType UINT32 0x00000001 = Windows marker structure
+// LicensingData UINT32 Length, in bytes of Windows Marker (182)
+// dwVersion UINT32 Version of the Windows Marker (0x0002000)
+// sOEMID UINT8 The OEMID value from XSDT and RSDT (must match). (6 bytes)
+// sOEMTABLEID UINT8 the OEMTABLEID from XSDT and RSDT (must match). (8 bytes)
+// sWindowsFlag UINT8 'WINDOWS ' (notice trailing space, not null terminated). (8 bytes)
+// Reserved UINT8 Reserved for future use. (20 bytes)
+// Signature UINT8 SHA256 Signature from the Windows Marker. (128 bytes)
+//
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+
+typedef struct {
+ UINT32 StructType;
+ UINT32 LicensingData;
+ UINT32 dwVersion;
+ UINT8 sOEMID[6];
+ UINT8 sOEMTABLEID[8];
+ UINT8 sWindowsFlag[8];
+ UINT8 Reserved[20];
+ UINT8 Signature[128];
+} WINDOWS_MARKER_STRUCTURE;
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: EFI_ACPI_SLP
+//
+// Description: This structure comes out of the document:
+// OEM Activation version 2.0 for M$ Windows Vista (tm) Operating System.
+//
+// Fields:
+// Name Type Description
+// ------------------------------------------------------------------
+// Header EFI_ACPI_DESCRIPTION_HEADER Common ACPI table header
+// PubKey OEM_PUBLIC_KEY_STRUCTURE See above for description
+// WinMarker WINDOWS_MARKER_STRUCTURE See above for description
+//
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+
+typedef struct {
+ ACPI_HDR Header;
+ OEM_PUBLIC_KEY_STRUCTURE PubKey;
+ WINDOWS_MARKER_STRUCTURE WinMarker;
+} EFI_ACPI_SLP;
+
+#pragma pack()
+
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
diff --git a/Core/EM/SLP20/SlpSupport.mak b/Core/EM/SLP20/SlpSupport.mak
new file mode 100644
index 0000000..80a41a0
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.mak
@@ -0,0 +1,118 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/BIN/Modules/SLP/SlpSupport.mak 8 8/09/11 10:18a Vyacheslava $
+# $Revision: 8 $
+# $Date: 8/09/11 10:18a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Modules/SLP/SlpSupport.mak $
+#
+# 8 8/09/11 10:18a Vyacheslava
+# [TAG] EIP63678
+# [Description] The modules GUID has been changed.
+#
+# 7 7/01/11 12:00p Vyacheslava
+# [TAG] EIP63678
+# [Category] New Feature
+# [Description] Preserve the OEM Activation SLIC during the BIOS
+# recovery path.
+# [Files] SlpSupport.sdl
+# SlpSupport.mak
+# SlpSupport.c
+# SlpSupport.dxs
+# SlpSupport.h
+# SlpSupport.cif
+#
+# 6 5/18/10 4:14p Vyacheslava
+# Updated copiright header.
+#
+# 5 8/19/09 11:49a Vyacheslava
+# Removed token USE_SOURCE_BINARIES (EIP#25334).
+#
+# 4 6/12/09 11:02a Vyacheslava
+# EIP#23109: Synopsis: Tokens for SlpSupport eModule.
+# Description: SlpSupport eModule needs to have tokens
+# SLP_MARKER_ROM_FILENAME SLP_PUBKEY_ROM_FILENAME to make more flexible
+# in changing Marker and Public Key files.
+#
+# 3 2/11/08 12:01p Felixp
+# Make file bug fix.
+#
+# 2 5/30/07 6:24p Aaronp
+# Changed mak file to allow for SDL token to include or exclude
+# the Public Key binary and the Marker binary. This is necssary
+# for supporting the AMISLP tool from the utilites group.
+#
+# 1 3/30/07 3:39p Felixp
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: SlpSupport.mak
+#
+# Description: Make file for SlpSupport eModule.
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+all : SLP
+
+SLP20MARKER_GUID = 69009842-63F2-43db-964B-EFAD1C39EC85
+SLP20PUBKEY_GUID = 996AA1E0-1E8C-4f36-B519-A170A206FC14
+
+SLP_BINARIES : $(BUILD_DIR)\SLP20Marker.ffs $(BUILD_DIR)\SLP20PubKey.ffs
+SLP : $(BUILD_DIR)\SlpSupport.mak SlpSupportBin SLP_BINARIES
+
+$(BUILD_DIR)\SlpSupport.mak : $(SLP_SUPPORT_DIR)\SlpSupport.cif
+ $(CIF2MAK) $(SLP_SUPPORT_DIR)\SlpSupport.cif $(CIF2MAK_DEFAULTS)
+
+SlpSupportBin: $(AMIDXELIB)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\SlpSupport.mak all\
+ GUID=952821AA-EACD-465b-B478-5429DFC9A747\
+ ENTRY_POINT=SlpSupport_EntryPoint\
+ TYPE=BS_DRIVER\
+ "EXT_HEADERS=$(BUILD_DIR)\Token.h"\
+ COMPRESS=1
+
+$(BUILD_DIR)\SLP20Marker.ffs : $(SLP_MARKER_ROM_FILENAME)
+ $(MAKE) /f Core\FFS.mak \
+ BUILD_DIR=$(BUILD_DIR) \
+ GUID=$(SLP20MARKER_GUID) \
+ TYPE=EFI_FV_FILETYPE_FREEFORM \
+ BINFILE=$** FFSFILE=$@ COMPRESS=0 NAME=$(**B)
+
+$(BUILD_DIR)\SLP20PubKey.ffs : $(SLP_PUBKEY_ROM_FILENAME)
+ $(MAKE) /f Core\FFS.mak \
+ BUILD_DIR=$(BUILD_DIR) \
+ GUID=$(SLP20PUBKEY_GUID) \
+ TYPE=EFI_FV_FILETYPE_FREEFORM \
+ BINFILE=$** FFSFILE=$@ COMPRESS=0 NAME=$(**B)
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/Core/EM/SLP20/SlpSupport.sdl b/Core/EM/SLP20/SlpSupport.sdl
new file mode 100644
index 0000000..780efb5
--- /dev/null
+++ b/Core/EM/SLP20/SlpSupport.sdl
@@ -0,0 +1,52 @@
+TOKEN
+ Name = "SlpSupport_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable SlpSupport support in Project"
+ TokenType = Boolean
+ TargetMAK = Yes
+ Master = Yes
+ Token = "ACPI_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "SLP_SUPPORT_DIR"
+End
+
+MODULE
+ Help = "Includes SlpSupport.mak to Project"
+ File = "SlpSupport.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\SlpSupport.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\Slp20Marker.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\Slp20PubKey.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
+TOKEN
+ Name = "SLP_MARKER_ROM_FILENAME"
+ Value = "$(SLP_SUPPORT_DIR)\Marker.bin"
+ Help = "SLP2.0 Marker key rom file"
+ TokenType = File
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "SLP_PUBKEY_ROM_FILENAME"
+ Value = "$(SLP_SUPPORT_DIR)\PubKey.bin"
+ Help = "SLP2.0 Public key rom file"
+ TokenType = File
+ TargetMAK = Yes
+End
diff --git a/Core/EM/Slp10/OemTable.asm b/Core/EM/Slp10/OemTable.asm
new file mode 100644
index 0000000..0eb3902
--- /dev/null
+++ b/Core/EM/Slp10/OemTable.asm
@@ -0,0 +1,67 @@
+;*************************************************************************
+;*************************************************************************
+;** **
+;** (C)Copyright 1985-2009, American Megatrends, Inc. **
+;** **
+;** All Rights Reserved. **
+;** **
+;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+;** **
+;** Phone: (770)-246-8600 **
+;** **
+;*************************************************************************
+;*************************************************************************
+
+;*****************************************************************************
+; $Header: /Alaska/SOURCE/Modules/Slp10/OemTable.asm 1 6/18/09 5:31p Vyacheslava $
+;
+; $Revision: 1 $
+;
+; $Date: 6/18/09 5:31p $
+;*****************************************************************************
+; Revision History
+; ----------------
+; $Log: /Alaska/SOURCE/Modules/Slp10/OemTable.asm $
+;
+; 1 6/18/09 5:31p Vyacheslava
+; Initial Creation
+;
+;*****************************************************************************
+;<AMI_FHDR_START>
+;
+; Name: OemTable.asm
+;
+; Description: This is OEM table binary for Aptio Firmware Volume.
+;
+;<AMI_FHDR_END>
+;*****************************************************************************
+
+ INCLUDE token.equ
+
+.686p
+.model flat
+.data
+
+slp_string_size SIZESTR MKF_SLP_STRING
+
+ DB '$ODB$', 0
+ DW 001h
+ DW MKF_OEM_DATA_SPACE_SIZE
+ DB @CATSTR(<!'>,%MKF_SLP_STRING,<!'>)
+ DB [MKF_OEM_DATA_SPACE_SIZE - slp_string_size] DUP (0)
+
+end
+
+;*************************************************************************
+;*************************************************************************
+;** **
+;** (C)Copyright 1985-2009, American Megatrends, Inc. **
+;** **
+;** All Rights Reserved. **
+;** **
+;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+;** **
+;** Phone: (770)-246-8600 **
+;** **
+;*************************************************************************
+;*************************************************************************
diff --git a/Core/EM/Slp10/Slp10.c b/Core/EM/Slp10/Slp10.c
new file mode 100644
index 0000000..b83edd5
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.c
@@ -0,0 +1,125 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//*****************************************************************************
+// $Header: /Alaska/SOURCE/Modules/Slp10/Slp10.c 1 6/18/09 5:31p Vyacheslava $
+//
+// $Revision: 1 $
+//
+// $Date: 6/18/09 5:31p $
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Slp10/Slp10.c $
+//
+// 1 6/18/09 5:31p Vyacheslava
+// Initial Creation
+//
+//
+//*****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Slp10.c
+//
+// Description: Implementation of the SLP 1.0 eModule.
+//
+//<AMI_FHDR_END>
+//*****************************************************************************
+
+//----------------------------------------------------------------------------
+
+#include <AmiDxeLib.h>
+#include <Token.h>
+#include <Protocol/LegacyBiosExt.h>
+#include "Slp10.h"
+
+//----------------------------------------------------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: Slp10_EntryPoint
+//
+// Description: This function is the entry point of the Slp10 eModule.
+//
+// Parameter:
+// ImageHandle - Image handle for this driver image.
+// SystemTable - Pointer to the EFI system table.
+//
+// Return value: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS Slp10_EntryPoint(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable )
+{
+ EFI_STATUS Status;
+ EFI_GUID EfiLegacyBiosExtProtocolGuid = EFI_LEGACY_BIOS_EXT_PROTOCOL_GUID;
+ EFI_GUID BiosFeaturesSectionGuid = BIOS_FEATURES_SECTION_GUID;
+ EFI_LEGACY_BIOS_EXT_PROTOCOL *LegacyBiosExtProtocol = NULL;
+ UINT8 *DataPtr = NULL;
+ UINTN Size = 0;
+ UINTN Address;
+
+ InitAmiLib( ImageHandle, SystemTable );
+
+ // Get OEM data from Aptio FV
+ Status = ReadImageResource(
+ ImageHandle,
+ &BiosFeaturesSectionGuid,
+ &DataPtr,
+ &Size
+ );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // Locate the Aptio extended Legacy Protocol
+ Status = pBS->LocateProtocol(
+ &EfiLegacyBiosExtProtocolGuid,
+ NULL,
+ &LegacyBiosExtProtocol
+ );
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // Copy OEM Data to Legacy Table
+ Address = LegacyBiosExtProtocol->CopyLegacyTable(
+ ((BIOS_OEM_DATA*)DataPtr)->Data, // Pointer to SLP data
+ OEM_DATA_SPACE_SIZE, // Size of the data
+ 1, // Alignment
+ OEM_DATA_LOCATION_BIT // Location Attribute
+ );
+ ASSERT_EFI_ERROR(Address);
+
+ Status = pBS->FreePool(DataPtr);
+ ASSERT_EFI_ERROR(Status);
+ return Status;
+}
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/Slp10/Slp10.chm b/Core/EM/Slp10/Slp10.chm
new file mode 100644
index 0000000..f58c4ab
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.chm
Binary files differ
diff --git a/Core/EM/Slp10/Slp10.cif b/Core/EM/Slp10/Slp10.cif
new file mode 100644
index 0000000..8d7ed77
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "Slp10"
+ category = eModule
+ LocalRoot = "Core\EM\Slp10\"
+ RefName = "Slp10"
+[files]
+"Slp10.sdl"
+"Slp10.mak"
+"Slp10.c"
+"Slp10.dxs"
+"OemTable.asm"
+"Slp10.h"
+"Slp10.chm"
+<endComponent>
diff --git a/Core/EM/Slp10/Slp10.dxs b/Core/EM/Slp10/Slp10.dxs
new file mode 100644
index 0000000..4ce0411
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.dxs
@@ -0,0 +1,18 @@
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+// Name: Slp10.dxs
+//
+// Description: This file is the dependency file for Slp10 driver
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+//----------------------------------------------------------------------------
+// Header files for GUID definitions
+//----------------------------------------------------------------------------
+
+#include <Protocol\LegacyBios.h>
+
+DEPENDENCY_START
+ EFI_LEGACY_BIOS_PROTOCOL_GUID
+DEPENDENCY_END
diff --git a/Core/EM/Slp10/Slp10.h b/Core/EM/Slp10/Slp10.h
new file mode 100644
index 0000000..8a6ed2b
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.h
@@ -0,0 +1,104 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//*****************************************************************************
+// $Header: /Alaska/SOURCE/Modules/Slp10/Slp10.h 1 6/18/09 5:31p Vyacheslava $
+//
+// $Revision: 1 $
+//
+// $Date: 6/18/09 5:31p $
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/Slp10/Slp10.h $
+//
+// 1 6/18/09 5:31p Vyacheslava
+// Initial Creation
+//
+//
+//*****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Slp10.h
+//
+// Description: Internal header file of the Slp10 eModule.
+//
+//<AMI_FHDR_END>
+//*****************************************************************************
+
+#ifndef _AMI_SLP10_MODULE_H
+#define _AMI_SLP10_MODULE_H
+
+#include <EFI.h>
+#include <Token.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// {2EBE0275-6458-4af9-91ED-D3F4EDB100AA}
+#define BIOS_FEATURES_SECTION_GUID \
+ {0x2ebe0275, 0x6458, 0x4af9, 0x91, 0xed, 0xd3, 0xf4, 0xed, 0xb1, 0x0, 0xaa}
+
+#define OEM_DATA_LOCATION_BIT 0x80
+
+#pragma pack(1)
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: BIOS_OEM_DATA
+//
+// Description: This structure comes out of the AMI Utility Specification.
+//
+// Fields:
+// Name Type Description
+// ---------------------------------------------------------------------------
+// Guid EFI_GUID Firmware Section GUID
+// Identifier CHAR8 Identifier String "$ODB$"
+// Flag UINT16 Data Flag
+// Size UINT16 Data Size
+// Data UINT8 Data Buffer (SLP String)
+//
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+
+typedef struct _BIOS_OEM_DATA {
+ EFI_GUID Guid;
+ CHAR8 Identifier[6];
+ UINT16 Flag;
+ UINT16 Size;
+ UINT8 Data[OEM_DATA_SPACE_SIZE];
+} BIOS_OEM_DATA;
+
+#pragma pack()
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
diff --git a/Core/EM/Slp10/Slp10.mak b/Core/EM/Slp10/Slp10.mak
new file mode 100644
index 0000000..13dbef2
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.mak
@@ -0,0 +1,83 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
+
+#*****************************************************************************
+# $Header: /Alaska/SOURCE/Modules/Slp10/Slp10.mak 2 7/14/09 12:26p Vyacheslava $
+#
+# $Revision: 2 $
+#
+# $Date: 7/14/09 12:26p $
+#*****************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/Slp10/Slp10.mak $
+#
+# 2 7/14/09 12:26p Vyacheslava
+# EIP#17468: Synopsis: customers are requesting support for SLP1.0.
+# Description: Mandal, We have support for SLP2.0 but not SLP1.0. Core8
+# has support for both and customers ar requesting SLP1.0 support. Please
+# let us know your plans for this.
+# - Removed $(BUILD_DIR)\AmiHpLibrary.lib.
+#
+# 1 6/18/09 5:31p Vyacheslava
+# Initial Creation
+#
+#*****************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: Slp10.mak
+#
+# Description: Make file for Slp10 eModule.
+#
+#<AMI_FHDR_END>
+#*****************************************************************************
+
+all : Slp10
+
+Slp10 : $(BUILD_DIR)\Slp10.mak $(BUILD_DIR)\OemTable.bin Slp10Bin
+
+SLP10_OBJECTS = $(BUILD_DIR)\$(Slp10_DIR)\Slp10.obj
+
+$(BUILD_DIR)\Slp10.mak : $(Slp10_DIR)\$(@B).cif $(Slp10_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(Slp10_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+$(BUILD_DIR)\OemTable.bin : $(Slp10_DIR)\OemTable.asm
+ $(ASM) /c /Fo$(BUILD_DIR)\ $(Slp10_DIR)\OemTable.asm
+ $(ASMLINK) $(BUILD_DIR)\OemTable.obj, $*.exe, $*.map,,,
+ exe2bin $*.exe $@
+
+Slp10Bin : $(AMIDXELIB)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\Slp10.mak all\
+ GUID=8E477676-55FD-48cf-9210-15A99B27D740\
+ OBJECTS="$(SLP10_OBJECTS)" \
+ ENTRY_POINT=Slp10_EntryPoint\
+ RESOURCE=$(BUILD_DIR)\OemTable.bin\
+ SECTION_GUID=2EBE0275-6458-4af9-91ED-D3F4EDB100AA\
+ TYPE=BS_DRIVER\
+ COMPRESS=1
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/Core/EM/Slp10/Slp10.sdl b/Core/EM/Slp10/Slp10.sdl
new file mode 100644
index 0000000..136d9b7
--- /dev/null
+++ b/Core/EM/Slp10/Slp10.sdl
@@ -0,0 +1,43 @@
+TOKEN
+ Name = Slp10_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable Slp10 support in Project"
+End
+
+TOKEN
+ Name = "OEM_DATA_SPACE_SIZE"
+ Value = "0x3E"
+ Help = "Maximum OEM data space size."
+ TokenType = Integer
+ TargetEQU = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SLP_STRING"
+ Value = "Copyright American Megatrends Inc. 1985-2009"
+ Help = "SLP string."
+ TokenType = Expression
+ TargetEQU = Yes
+End
+
+PATH
+ Name = Slp10_DIR
+ Help = "Path to Slp10 Module in Project"
+End
+
+MODULE
+ Help = "Includes Slp10.mak to Project"
+ File = "Slp10.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\Slp10.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End
+
diff --git a/EDK/MiniSetup/AMITSE.chm b/EDK/MiniSetup/AMITSE.chm
new file mode 100644
index 0000000..cc36dbc
--- /dev/null
+++ b/EDK/MiniSetup/AMITSE.chm
Binary files differ
diff --git a/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c
new file mode 100644
index 0000000..c85be31
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c
@@ -0,0 +1,103 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 7 $
+//
+// $Date: 8/28/14 5:29a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.c $
+//
+// 7 8/28/14 5:29a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 6 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 2/26/10 8:53p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 5 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 8/17/09 12:22p Presannar
+// Removed References to Tiano.h
+//
+// 2 6/23/09 6:55p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: AMILogo.c
+//
+// Description: This file contains code to handle logo.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifdef TSE_FOR_APTIO_4_50
+#include "Token.h"
+#else
+#include "tokens.h"
+#endif
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "AMILogo.h"
+
+EFI_GUID gAMIEfiLogoGuid = AMI_EFI_LOGO_GUID;
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h
new file mode 100644
index 0000000..14a1ccb
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h
@@ -0,0 +1,104 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/AMILogo/AMILogo.h $
+//
+// 6 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 1/31/12 1:22p Premkumara
+// [TAG] EIP75136
+// [Category] New Feature
+// [Description] Generic support for logos in RomHoles
+// [Files] CommomHelper.c, AMITSE.sdl, AMITSE.mak, LogoLib.h,
+// Postmgmt.c, AMILogo.h
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:55p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: AMILogo.h
+//
+// Description: header file to define logo related stuff.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _AMI_LOGO_FV_
+#define _AMI_LOGO_FV_
+
+#define FOUR_GB_LIMIT 0x100000000
+//{63819805-67BB-46ef-AA8D-1524A19A01E4}
+#define AMI_EFI_LOGO_GUID \
+ { 0x63819805, 0x67BB, 0x46ef, 0xAA, 0x8D, 0x15, 0x24, 0xA1, 0x9A, 0x01, 0xE4}
+
+extern EFI_GUID gAMIEfiLogoGuid;
+#endif //_AMI_LOGO_FV_
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/EDKhelper.c b/EDK/MiniSetup/BootOnly/EDKhelper.c
new file mode 100644
index 0000000..b0aabd9
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/EDKhelper.c
@@ -0,0 +1,1737 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 11 $
+//
+// $Date: 2/11/14 8:14p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.c $
+//
+// 11 2/11/14 8:14p Arunsb
+// [TAG] EIP125719
+// [Category] Improvement
+// [Description] The EfiCreateEventReadyToBoot is conflicted under
+// UefiLib.h and EDKhelper.h.
+// [Files] boot.c, EDKhelper.c and EDKHelper.h
+//
+// 10 5/22/13 10:26a Arunsb
+// [TAG] EIP122907
+// [Category] Improvement
+// [Description] Functions added for name value support
+//
+// 9 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 5/29/12 3:58a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 7 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 6 4/23/10 6:22p Madhans
+// To resolve Build issues with EDK support on.
+//
+// 5 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 1/09/10 5:49a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 7/31/09 6:27p Presannar
+// Removed Redefinition of gEfiOEMBadgingProtocolGuid, EfiCopyMem
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 3 5/06/09 8:09p Mallikarjunanv
+// updated for if no edk lib support
+//
+// 2 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 3/31/09 3:33p Madhans
+// To build with/without EDK libs.
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: EdkHelper.c
+//
+// Description: This file contains code from EDK library.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ xxxxxx.c
+
+Abstract:
+
+ xxxxxxxxxxxx
+
+--*/
+
+#include "minisetup.h"
+
+#if !TSE_USE_EDK_LIBRARY
+
+extern EFI_SYSTEM_TABLE *pST;
+extern EFI_BOOT_SERVICES *pBS;
+extern EFI_RUNTIME_SERVICES *pRS;
+
+#if !TSE_APTIO_5_SUPPORT
+EFI_SYSTEM_TABLE *gST=NULL;
+EFI_BOOT_SERVICES *gBS=NULL;
+EFI_RUNTIME_SERVICES *gRT=NULL;
+EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID;
+EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT;
+#endif
+
+#define EFI_SHELL_FILE_GUID \
+ { 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 }
+EFI_GUID gEfiShellFileGuid = EFI_SHELL_FILE_GUID;
+
+/*
+#define EFI_GLOBAL_VARIABLE_GUID \
+ { \
+ 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C \
+ }
+*/
+
+#define EFI_PRINT_PROTOCOL_GUID \
+ { 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 }
+
+EFI_GUID gEfiPrintProtocolGuid = EFI_PRINT_PROTOCOL_GUID;
+
+#ifndef EFI_OEM_BADGING_PROTOCOL_GUID
+#define EFI_OEM_BADGING_PROTOCOL_GUID \
+ { 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc }
+#endif
+//EFI_GUID gEfiOEMBadgingProtocolGuid = EFI_OEM_BADGING_PROTOCOL_GUID;
+extern EFI_GUID gEfiOEMBadgingProtocolGuid;
+
+/*
+#define EFI_EVENT_GROUP_READY_TO_BOOT \
+ { 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } }
+*/
+VOID InitAmiLib(
+ IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable
+);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiInitializeDriverLib
+//
+// Description: To avoid including EDK libs.
+//
+// Input: ImageHandle and Systemtable
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EfiInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ InitAmiLib(ImageHandle,SystemTable);
+ gST = pST;
+ gBS = pBS;
+ gRT = pRS;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiLibAllocateZeroPool
+//
+// Description: To avoid including EDK libs.
+//
+// Input: size
+//
+// Output: pointer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void* MallocZ(UINTN Size);
+VOID *
+EfiLibAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return MallocZ(AllocationSize);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiLibAllocatePool
+//
+// Description: To avoid including EDK libs.
+//
+// Input: size
+//
+// Output: pointer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void* Malloc(UINTN Size);
+VOID *
+EfiLibAllocatePool (
+ IN UINTN AllocationSize
+ )
+{
+ return Malloc(AllocationSize);
+}
+
+//<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)));
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiCompareMem
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN VOID *MemOne, IN VOID *MemTwo,
+//
+// Output: INTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INTN
+EfiCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Length
+ )
+{
+ return MemCmp(MemOne,MemTwo,Length);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Wcslen
+//
+// Description: To avoid including EDK libs.
+//
+// Input: CHAR16 *string
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN Wcslen(CHAR16 *string);
+UINTN
+EfiStrLen (
+ IN CHAR16 *String
+ )
+{
+ return Wcslen(String);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Wcscpy
+//
+// Description: To avoid including EDK libs.
+//
+// Input: CHAR16 *string1, CHAR16* string2
+//
+// Output: CHAR16*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16* Wcscpy(CHAR16 *string1, CHAR16* string2);
+VOID
+EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+{
+ Wcscpy(Destination,Source);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Wcscmp
+//
+// Description: To avoid including EDK libs.
+//
+// Input: CHAR16 *string1, CHAR16 *string2
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+int Wcscmp( CHAR16 *string1, CHAR16 *string2 );
+INTN
+EfiStrCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2
+ )
+{
+ return Wcscmp( String, String2 );
+}
+
+int Strcmp( char *string1, char *string2 );
+INTN
+EfiAsciiStrCmp (
+ IN CHAR8 *String,
+ IN CHAR8 *String2
+ )
+{
+ return Strcmp( String, String2 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DPAdd
+//
+// Description: To avoid including EDK libs.
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* DPAdd(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2);
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+{
+ return (EFI_DEVICE_PATH_PROTOCOL *)DPAdd(Src1,Src2);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DPAddNode
+//
+// Description: To avoid including EDK libs.
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* DPAddNode(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2);
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+{
+ return (EFI_DEVICE_PATH_PROTOCOL *)DPAddNode(Src1, Src2);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiDevicePathFromHandle
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_HANDLE Handle
+//
+// Output: EFI_DEVICE_PATH_PROTOCOL *
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Get the device path protocol interface installed on a specified handle.
+
+Arguments:
+
+ Handle - a specified handle
+
+Returns:
+
+ The device path protocol interface installed on that handle.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ DevicePath = NULL;
+ gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *) &DevicePath
+ );
+ return DevicePath;
+}
+
+VOID
+EfiStrCat (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiStrCpy (Destination + EfiStrLen (Destination), Source);
+}
+
+INTN
+EfiStrnCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ This function compares the Unicode string String to the Unicode
+ string String2 for len characters. If the first len characters
+ of String is identical to the first len characters of String2,
+ then 0 is returned. If substring of String sorts lexicographically
+ after String2, the function returns a number greater than 0. If
+ substring of String sorts lexicographically before String2, the
+ function returns a number less than 0.
+
+Arguments:
+ String - Compare to String2
+ String2 - Compare to String
+ Length - Number of Unicode characters to compare
+
+Returns:
+ 0 - The substring of String and String2 is identical.
+ > 0 - The substring of String sorts lexicographically after String2
+ < 0 - The substring of String sorts lexicographically before String2
+
+--*/
+{
+ while (*String && Length != 0) {
+ if (*String != *String2) {
+ break;
+ }
+ String += 1;
+ String2 += 1;
+ Length -= 1;
+ }
+ return Length > 0 ? *String - *String2 : 0;
+}
+
+
+UINTN
+EfiStrSize (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number bytes in the Unicode String. This is not the same as
+ the length of the string in characters. The string size includes the NULL
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of bytes in String
+
+--*/
+{
+ return ((EfiStrLen (String) + 1) * sizeof (CHAR16));
+}
+
+
+#define AMI_SIZE_OF_FILEPATH_DEVICE_PATH STRUCT_OFFSET(FILEPATH_DEVICE_PATH,PathName)
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiFileDevicePath
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_HANDLE Device OPTIONAL, IN CHAR16 *FileName
+//
+// Output: EFI_DEVICE_PATH_PROTOCOL *
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_DEVICE_PATH_PROTOCOL *
+EfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ )
+/*++
+
+Routine Description:
+
+ This function allocates a device path for a file and appends it to an existiong
+ device path.
+
+Arguments:
+ Device - A pointer to a device handle.
+
+ FileName - A pointer to a Null-terminated Unicodestring.
+
+Returns:
+ A device path contain the file name.
+
+--*/
+{
+ UINTN Size;
+ FILEPATH_DEVICE_PATH *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *Eop;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ for (Size = 0; FileName[Size] != 0; Size++)
+ ;
+ Size = (Size + 1) * 2;
+
+ FilePath = EfiLibAllocateZeroPool (Size + AMI_SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));
+
+ DevicePath = NULL;
+
+ if (FilePath != NULL) {
+
+ //
+ // Build a file path
+ //
+ FilePath->Header.Type = MEDIA_DEVICE_PATH;
+ FilePath->Header.SubType = MEDIA_FILEPATH_DP;
+ SetDevicePathNodeLength (&FilePath->Header, Size + AMI_SIZE_OF_FILEPATH_DEVICE_PATH);
+ EfiCopyMem (FilePath->PathName, FileName, Size);
+ Eop = NextDevicePathNode (&FilePath->Header);
+ SetDevicePathEndNode (Eop);
+
+ //
+ // Append file path to device's device path
+ //
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;
+ if (Device != NULL) {
+ DevicePath = EfiAppendDevicePath (
+ EfiDevicePathFromHandle (Device),
+ DevicePath
+ );
+
+ gBS->FreePool (FilePath);
+ }
+ }
+
+ return DevicePath;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiInitializeFwVolDevicepathNode
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+// IN EFI_GUID *NameGuid
+//
+// Output: VOID EFIAPI
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+EFIAPI
+EfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+/*++
+
+Routine Description:
+
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for PIWG extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+Returns:
+
+ None
+
+--*/
+{
+//*** AMI PORTING BEGIN ***//
+//NEW PIWG Specific Device Path defined here is not in compliance with PI DXE CIS 1.0
+//Let's disable it
+//See also corresponding change in TianoSpecDevicePath.h
+#if 1
+//*** AMI PORTING END *****//
+ //
+ // Use old Device Path that conflicts with UEFI
+ //
+ FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+#else
+ //
+ // Use the new Device path that does not conflict with the UEFI
+ //
+ FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+ //
+ // Add the GUID for generic PIWG device paths
+ //
+ EfiCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID));
+
+ //
+ // Add in the FW Vol File Path PIWG defined inforation
+ //
+ FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;
+
+#endif
+ EfiCopyMem (&((AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)FvDevicePathNode)->FvFileName, NameGuid, sizeof(EFI_GUID));
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiLibNamedEventSignal
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_GUID *Name
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EfiLibNamedEventSignal (
+ IN EFI_GUID *Name
+ )
+/*++
+
+Routine Description:
+ Signals a named event. All registered listeners will run.
+ The listeners should register using EfiLibNamedEventListen() function.
+
+ NOTE: For now, the named listening/signalling is implemented
+ on a protocol interface being installed and uninstalled.
+ In the future, this maybe implemented based on a dedicated mechanism.
+
+Arguments:
+ Name - Name to perform the signaling on. The name is a GUID.
+
+Returns:
+ EFI_SUCCESS if successfull.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ Name,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->UninstallProtocolInterface (
+ Handle,
+ Name,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LibReportStatusCode
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value,
+// IN UINT32 Instance, IN EFI_GUID *CallerId OPTIONAL,
+// IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LibReportStatusCode(
+ IN EFI_STATUS_CODE_TYPE Type, IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance, IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+);
+
+EFI_STATUS
+EfiLibReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ return LibReportStatusCode(Type,Value,Instance,CallerId,Data);
+}
+
+
+VOID
+EFIAPI
+EventNotifySignalAllNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // This null event is a size efficent way to enusre that
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
+ // CreateEventEx() and this function is used to make the
+ // old error checking in CreateEvent() for Tiano extensions
+ // function.
+ //
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseEfiCreateEventReadyToBoot
+//
+// Description: To avoid including EDK libs.
+//
+// Input: IN EFI_TPL NotifyTpl,
+// IN EFI_EVENT_NOTIFY NotifyFunction,
+// IN VOID *NotifyContext,
+// OUT EFI_EVENT *ReadyToBootEvent
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EFIAPI
+TseEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ ReadyToBootEvent
+ );
+#else
+
+ EventType = EFI_EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = EventNotifySignalAllNullEvent;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventReadyToBootGuid,
+ ReadyToBootEvent
+ );
+#endif
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsHexDigit
+//
+// Description: To avoid including EDK libs.
+//
+// Input:
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN
+IsHexDigit (
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
+ )
+/*++
+
+ Routine Description:
+ Determines if a Unicode character is a hexadecimal digit.
+ The test is case insensitive.
+
+ Arguments:
+ Digit - Pointer to byte that receives the value of the hex character.
+ Char - Unicode character to test.
+
+ Returns:
+ TRUE - If the character is a hexadecimal digit.
+ FALSE - Otherwise.
+
+--*/
+{
+ if ((Char >= L'0') && (Char <= L'9')) {
+ *Digit = (UINT8) (Char - L'0');
+ return TRUE;
+ }
+
+ if ((Char >= L'A') && (Char <= L'F')) {
+ *Digit = (UINT8) (Char - L'A' + 0x0A);
+ return TRUE;
+ }
+
+ if ((Char >= L'a') && (Char <= L'f')) {
+ *Digit = (UINT8) (Char - L'a' + 0x0A);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HexStringToBuf
+//
+// Description: To avoid including EDK libs.
+//
+// Input:
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+HexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Converts Unicode string to binary buffer.
+ The conversion may be partial.
+ The first character in the string that is not hex digit stops the conversion.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Buf - Pointer to buffer that receives the data.
+ Len - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+ ConvertedStrLen - Length of the Hex String consumed.
+
+ Returns:
+ EFI_SUCCESS: Routine Success.
+ EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
+ EFI_
+
+--*/
+{
+ UINTN HexCnt;
+ UINTN Idx;
+ UINTN BufferLength;
+ UINT8 Digit;
+ UINT8 Byte;
+
+ //
+ // Find out how many hex characters the string has.
+ //
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
+
+ if (HexCnt == 0) {
+ *Len = 0;
+ return EFI_SUCCESS;
+ }
+ //
+ // Two Unicode characters make up 1 buffer byte. Round up.
+ //
+ BufferLength = (HexCnt + 1) / 2;
+
+ //
+ // Test if buffer is passed enough.
+ //
+ if (BufferLength > (*Len)) {
+ *Len = BufferLength;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *Len = BufferLength;
+
+ for (Idx = 0; Idx < HexCnt; Idx++) {
+
+ IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
+
+ //
+ // For odd charaters, write the lower nibble for each buffer byte,
+ // and for even characters, the upper nibble.
+ //
+ if ((Idx & 1) == 0) {
+ Byte = Digit;
+ } else {
+ Byte = Buf[Idx / 2];
+ Byte &= 0x0F;
+ Byte |= Digit << 4;
+ }
+
+ Buf[Idx / 2] = Byte;
+ }
+
+ if (ConvertedStrLen != NULL) {
+ *ConvertedStrLen = HexCnt;
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------------------------------------------------------------------
+// Procedure: NameValueHexStringToBuf
+//
+// Description: Converts name value string to buffer
+//
+// Input: : Buf - Pointer to buffer that receives the data.
+// Len - Length in bytes of the buffer to hold converted data.
+// If routine return with EFI_SUCCESS, containing length of converted data.
+// If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+// Str - String to be converted from.
+// ConvertedStrLen - Length of the Hex String consumed.
+//
+// Output: EFI_SUCCESS: Routine Success.
+// EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
+//
+//-----------------------------------------------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 HexToNibbleChar (IN UINT8 Nibble);
+EFI_STATUS NameValueHexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ )
+{
+ UINTN HexCnt;
+ UINTN Idx, ByteIndex = 0;
+ UINTN BufferLength;
+ UINT8 Digit;
+ UINT8 Byte;
+ UINT64 Ext8byte = 0;
+ UINT32 Ext4byte = 0;
+ UINT16 Word;
+
+ //
+ // Find out how many hex characters the string has.
+ //
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
+
+ if (HexCnt == 0) {
+ *Len = 0;
+ return EFI_SUCCESS;
+ }
+ //
+ // Two Unicode characters make up 1 buffer byte. Round up.
+ //
+ BufferLength = (HexCnt + 1) / 2;
+
+ //
+ // Test if buffer is passed enough.
+ //
+ if (BufferLength > (*Len)) {
+ *Len = BufferLength;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *Len = BufferLength;
+
+ for (Idx = 0; Idx < HexCnt; Idx += 4)
+ {
+ //00 31 00 36 00 30 00 00
+ Ext4byte = *((UINT32 *)&Str[Idx+2]); //00 31 00 36
+
+ Word = ((UINT16)(Ext4byte & 0x0000FFFF)); //00 36
+ Byte = ((UINT8)(Word & 0x00FF)); //36
+ Buf [ByteIndex] = HexToNibbleChar (Byte); //6
+ Buf [ByteIndex] <<= 0x4; //60
+
+ Word = ((UINT16)(Ext4byte >> 16)); //00 31
+ Byte = ((UINT8)(Word & 0x00FF)); //31
+ Buf [ByteIndex] |= HexToNibbleChar (Byte); //1
+
+ ByteIndex ++;
+
+ Ext4byte = *((UINT32 *)&Str[Idx]); //00 30 00 30
+ Word = ((UINT16)(Ext4byte & 0x0000FFFF)); //00 30
+ Byte = ((UINT8)(Word & 0x00FF)); //30
+ Buf [ByteIndex] = HexToNibbleChar (Byte); //0
+ Buf [ByteIndex] <<= 0x4; //60
+
+ Word = ((UINT16)(Ext4byte >> 16)); //00 30
+ Byte = ((UINT8)(Word & 0x00FF)); //30
+ Buf [ByteIndex] |= HexToNibbleChar (Byte); //0
+
+ ByteIndex ++;
+ }
+
+ if (ConvertedStrLen != NULL) {
+ *ConvertedStrLen = HexCnt;
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Mul64
+//
+// Description: To avoid including EDK libs.
+//
+// Input:
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 Mul64(
+ IN UINT64 Value64,
+ IN UINTN Value32
+ );
+#if !TSE_APTIO_5_SUPPORT
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+{
+ return Mul64(Multiplicand,Multiplier);
+}
+#endif
+UINTN DPLength(EFI_DEVICE_PATH_PROTOCOL *pDp);
+
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ return DPLength(DevicePath);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NibbleToHexChar
+//
+// Description: Converts the low nibble of a byte to hex unicode character.
+//
+// Input: Nibble - lower nibble of a byte.
+//
+// Output: Hex unicode character.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16
+NibbleToHexChar (
+ IN UINT8 Nibble
+ )
+{
+ Nibble &= 0x0F;
+ if (Nibble <= 0x9) {
+ return (CHAR16)(Nibble + L'0');
+ }
+
+ return (CHAR16)(Nibble - 0xA + L'A');
+}
+
+
+//<AMI_PHDR_START>
+//------------------------------------------------------------------------------------
+// Procedure: HexToNibbleChar
+//
+// Description: Converts the hex value to character.
+//
+// Input: Nibble - lower nibble of a byte.
+//
+// Output: Hex unicode character.
+//
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8
+HexToNibbleChar (
+ IN UINT8 Nibble
+ )
+{
+ if (Nibble - L'0' <= 0x9) {
+ return (CHAR16)(Nibble - L'0');
+ }
+
+ return (CHAR16)(Nibble + 0xA - L'A');
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BufToHexString
+//
+// Description: Converts binary buffer to Unicode string.
+// At a minimum, any blob of data could be represented as a hex string.
+//
+// Input: Str - Pointer to the string.
+// HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+// If routine return with EFI_SUCCESS, containing length of hex string buffer.
+// If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+// Buf - Buffer to be converted from.
+// Len - Length in bytes of the buffer to be converted.
+//
+// Output: EFI_SUCCESS: Routine success.
+// EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+BufToHexString (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ )
+{
+ UINTN Idx;
+ UINT8 Byte;
+ UINTN StrLen;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+ StrLen = Len * 2;
+ if (StrLen > ((*HexStringBufferLength) - 1)) {
+ *HexStringBufferLength = StrLen + 1;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *HexStringBufferLength = StrLen + 1;
+ //
+ // Ends the string.
+ //
+ Str[StrLen] = L'\0';
+
+ for (Idx = 0; Idx < Len; Idx++) {
+
+ Byte = Buf[Idx];
+ Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
+ Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NameValueBufToHexString
+//
+// Description: Converts binary buffer to Unicode string.
+// At a minimum, any blob of data could be represented as a hex string.
+// Used only for name value implementaion
+//
+// Input: Str - Pointer to the string.
+// HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+// If routine return with EFI_SUCCESS, containing length of hex string buffer.
+// If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+// Buf - Buffer to be converted from.
+// Len - Length in bytes of the buffer to be converted.
+//
+// Output: EFI_SUCCESS: Routine success.
+// EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+NameValueBufToHexString (
+ IN OUT CHAR16 **Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ )
+{
+ UINT8 Byte;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+
+ if (Len <= sizeof (UINT64)) //For upto 8 bytes we have to take care of endian allignment
+ {
+ UINTN Idx;
+ UINTN StrLen;
+ CHAR16 *tempStr = (CHAR16 *)NULL;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+ StrLen = Len * 2;
+ *Str = EfiLibAllocateZeroPool ((StrLen + 1) * sizeof (UINT16) );
+ if (NULL == *Str)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ *HexStringBufferLength = (StrLen + 1) * sizeof (UINT16); //UefiVarSetNvram needs full size
+ //
+ // Ends the string.
+ //
+ tempStr = *Str;
+ tempStr[StrLen] = L'\0';
+
+ for (Idx = 0; Idx < Len; Idx++)
+ {
+ Byte = Buf[Idx];
+ tempStr[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
+ tempStr[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ }
+ }
+ else
+ {
+ CHAR16 *tempBuf = (CHAR16 *)NULL, *tempStr = (CHAR16 *)NULL;
+ UINT32 iIndex = 0, StringHexLength = 0;
+ CHAR16 Word;
+
+ tempBuf = EfiLibAllocateZeroPool (Len + sizeof (CHAR16)); //If full string is given then NULL wont be there so crashing so added one NULL
+ if (NULL == tempBuf) //character at end
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ MemCpy (tempBuf, Buf, Len);
+ //Finding length to allocate
+ while (tempBuf [iIndex])
+ {
+ StringHexLength ++;
+ iIndex ++;
+ }
+ iIndex = 0;
+ *Str = EfiLibAllocateZeroPool ((StringHexLength * sizeof (CHAR16) * 4) + sizeof (CHAR16));
+ if (NULL == *Str )
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ tempStr = *Str;
+ while (tempBuf [iIndex])
+ {
+ Word = tempBuf [iIndex];
+ Byte = ((UINT8)(Word >> 8));
+ tempStr [iIndex * 4] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ tempStr [iIndex * 4 + 1] = NibbleToHexChar (Byte);
+ Byte = Word & 0x00FF;
+ tempStr [iIndex * 4 + 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ tempStr [iIndex * 4 + 3] = NibbleToHexChar (Byte);
+ iIndex ++;
+ }
+ *HexStringBufferLength = (StringHexLength * sizeof (CHAR16) * 4) + sizeof (CHAR16);
+ tempStr [StringHexLength * 4] = L'\0';
+ MemFreePointer ((VOID **)&tempBuf);
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ToLower
+//
+// Description: Converts the unicode character of the string from uppercase to lowercase.
+//
+// Input: Str - String to be converted
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+ToLower (
+ IN OUT CHAR16 *Str
+ )
+{
+ CHAR16 *Ptr;
+
+ for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
+ if (*Ptr >= L'A' && *Ptr <= L'Z') {
+ *Ptr = (CHAR16) (*Ptr - L'A' + L'a');
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SwapBuffer
+//
+// Description: Swap bytes in the buffer.
+//
+// Input: Buffer - Binary buffer.
+// BufferSize - Size of the buffer in bytes.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+SwapBuffer (
+ IN OUT UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+{
+ UINTN Index;
+ UINT8 Temp;
+ UINTN SwapCount;
+
+ SwapCount = BufferSize / 2;
+ for (Index = 0; Index < SwapCount; Index++) {
+ Temp = Buffer[Index];
+ Buffer[Index] = Buffer[BufferSize - 1 - Index];
+ Buffer[BufferSize - 1 - Index] = Temp;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UnicodeToConfigString
+//
+// Description: Convert Unicode string to binary representation Config string, e.g.
+// "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
+// "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+//
+// Input: ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+// StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+// Includes tailing '\0' character.
+// On output:
+// If return EFI_SUCCESS, containing length of Unicode string buffer.
+// If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+// UnicodeString - Original Unicode string.
+//
+// Output: EFI_SUCCESS - Routine success.
+// EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+UnicodeToConfigString (
+ IN OUT CHAR16 *ConfigString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *UnicodeString
+ )
+{
+ UINTN Index;
+ UINTN Len;
+ UINTN BufferSize;
+ CHAR16 *String;
+
+ Len = EfiStrLen (UnicodeString);
+ BufferSize = (Len * 4 + 1) * sizeof (CHAR16);
+
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+ String = ConfigString;
+
+ for (Index = 0; Index < Len; Index++) {
+ BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);
+
+ ConfigString += 4;
+ UnicodeString += 1;
+ }
+
+ //
+ // Add tailing '\0' character
+ //
+ *ConfigString = L'\0';
+
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (String);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiLibAllocateCopyPool
+//
+// Description: Allocate BootServicesData pool and use a buffer provided by
+// caller to fill it.
+//
+// Input: AllocationSize - The size to allocate
+// Buffer - Buffer that will be filled into the buffer allocated
+//
+// Output: Pointer of the buffer allocated.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *
+EfiLibAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ if (Memory != NULL) {
+ gBS->CopyMem (Memory, Buffer, AllocationSize);
+ }
+
+ return Memory;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BufferToHexString
+//
+// Description: Converts binary buffer to Unicode string in reversed byte order from BufToHexString().
+//
+// Input: Str - String for output
+// Buffer - Binary buffer.
+// BufferSize - Size of the buffer in bytes.
+//
+// Output: EFI_SUCCESS - The function completed successfully.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+BufferToHexString (
+ IN OUT CHAR16 *Str,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+{
+ EFI_STATUS Status;
+ UINT8 *NewBuffer;
+ UINTN StrBufferLen;
+
+ NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer);
+ SwapBuffer (NewBuffer, BufferSize);
+
+ StrBufferLen = BufferSize * 2 + 1;
+ Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
+
+ gBS->FreePool (NewBuffer);
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (Str);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiStrStr
+//
+// Description: Find a substring.
+//
+// Input: String - Null-terminated string to search.
+// StrCharSet - Null-terminated string to search for.
+//
+// Output: The address of the first occurrence of the matching substring if successful,
+// or NULL otherwise.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16*
+ EfiStrStr (
+ IN CHAR16 *String,
+ IN CHAR16 *StrCharSet
+ )
+ {
+ CHAR16 *Src;
+ CHAR16 *Sub;
+
+ Src = String;
+ Sub = StrCharSet;
+
+ while ((*String != L'\0') && (*StrCharSet != L'\0')) {
+ if (*String++ != *StrCharSet++) {
+ String = ++Src;
+ StrCharSet = Sub;
+ }
+ }
+ if (*StrCharSet == L'\0') {
+ return Src;
+ } else {
+ return NULL;
+ }
+ }
+
+UINT64 Shr64(
+ IN UINT64 Value,
+ IN UINT8 Shift
+ );
+
+UINT64 Shl64(
+ IN UINT64 Value,
+ IN UINT8 Shift
+ );
+#if !TSE_APTIO_5_SUPPORT
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ UINT8 Shift;
+
+ while(Count)
+ {
+ Shift = (UINT8)((Count>256)?256:Count);
+ Operand = Shl64(Operand,Shift);
+ Count -= Shift;
+ }
+
+ return Operand;
+}
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ UINT8 Shift;
+
+ while(Count)
+ {
+ Shift = (UINT8)((Count>256)?256:Count);
+ Operand = Shr64(Operand,Shift);
+ Count -= Shift;
+ }
+
+ return Operand;
+}
+#endif
+UINT64 Div64 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor, //Can only be 31 bits.
+ OUT UINTN *Remainder OPTIONAL
+ );
+
+UINT64
+AmiTseDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+{
+ return Div64(Dividend,Divisor,Remainder);
+}
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+{
+}
+
+VOID
+EfiDebugPrint (
+IN UINTN ErrorLevel,
+IN CHAR8 *Format,
+...
+)
+{
+}
+
+#define EFI_FORM_BROWSER_PROTOCOL_GUID \
+ { \
+ 0xe5a1333e, 0xe1b4, 0x4d55, 0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 \
+ }
+EFI_GUID gEfiFormBrowserProtocolGuid = EFI_FORM_BROWSER_PROTOCOL_GUID;
+
+#else //!TSE_USE_EDK_LIBRARY
+
+// To support building when TSE_USE_EDK_LIBRARY = 1
+#ifdef TSE_FOR_APTIO_4_50
+const UINTN FlashEmpty = (UINTN)(-FLASH_ERASE_POLARITY);
+const UINT32 FlashEmptyNext = (FLASH_ERASE_POLARITY ? 0xffffff : 0);
+
+VOID MemCpy(VOID* pDestination, VOID* pSource, UINTN Count)
+{
+ gBS->CopyMem (pDestination, pSource, Count);
+}
+#endif
+
+#endif //#if !TSE_USE_EDK_LIBRARY
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/EDKhelper.h b/EDK/MiniSetup/BootOnly/EDKhelper.h
new file mode 100644
index 0000000..067a8c5
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/EDKhelper.h
@@ -0,0 +1,419 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 2/11/14 8:19p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/EDKhelper.h $
+//
+// 6 2/11/14 8:19p Arunsb
+// [TAG] EIP125719
+// [Category] Improvement
+// [Description] The EfiCreateEventReadyToBoot is conflicted under
+// UefiLib.h and EDKhelper.h.
+// [Files] boot.c, EDKhelper.c and EDKHelper.h
+//
+// 5 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 6 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 5/29/12 4:02a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 3 12/28/10 6:12p Mallikarjunanv
+// [TAG] EIP41615
+// [Category] New Feature
+// [Description] Added the file browser support for the Add boot option
+// reated controls
+// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c,
+// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c,
+// AddBootOption.c
+//
+// 2 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 2 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 1 7/31/09 5:03p Presannar
+// Initial Draft - EDKHelper header
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: edkhelper.h
+//
+// Description: Edk helper header file.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _EDK_HELPER_H_
+#define _EDK_HELPER_H_
+
+//AMI <--> EDK mapping
+#define EFI_LOADED_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION
+typedef DXE_SERVICES EFI_DXE_SERVICES;
+#define EFI_TPL_APPLICATION TPL_APPLICATION
+#define EFI_TPL_CALLBACK TPL_CALLBACK
+#define EFI_TPL_NOTIFY TPL_NOTIFY
+#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL
+
+#ifndef END_DEVICE_PATH_TYPE
+#define END_DEVICE_PATH_TYPE 0x7F
+#endif
+
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xFF
+#define EFI_EVENT_EFI_SIGNAL_MASK 0x000000FF
+#define EFI_EVENT_EFI_SIGNAL_MAX 4
+#define EFI_TPL_DRIVER 6
+#define EFI_DXE_SERVICES_SIGNATURE DXE_SERVICES_SIGNATURE
+#define EFI_DXE_SERVICES_REVISION DXE_SERVICES_REVISION
+#define EFI_DXE_ENTRY_POINT(EntryPoint)
+#ifndef EFI_DEADLOOP
+#define EFI_DEADLOOP() { volatile UINTN __DeadLoopVar__ = 1; while (__DeadLoopVar__); }
+#endif
+#define EFI_BREAKPOINT() EFI_DEADLOOP()
+#define EFI_BAD_POINTER 0xAFAFAFAF
+//This is defined in FirmwareValume.h but has nothing to do with the protocol.
+//It should be in DxeMain internal header
+//#define FV_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '_')
+//#define EFI_FVH_SIGNATURE FV_SIGNATURE
+//#define EFI_FV_BLOCK_MAP_ENTRY FvBlockMapEntry
+//This is define in TianoType.h, however, this is not in DXECIS
+//
+// attributes for reserved memory before it is promoted to system memory
+//
+#define EFI_MEMORY_PRESENT 0x0100000000000000
+#define EFI_MEMORY_INITIALIZED 0x0200000000000000
+#define EFI_MEMORY_TESTED 0x0400000000000000
+
+//
+// range for memory mapped port I/O on IPF
+//
+#define EFI_MEMORY_PORT_IO 0x4000000000000000
+//
+// A pointer to a function in IPF points to a plabel.
+//
+typedef struct {
+ UINT64 EntryPoint;
+ UINT64 GP;
+} EFI_PLABEL;
+////////////////////////////////////////////////
+//defined for every CPU architecture
+// Maximum legal IA-32 address
+#define EFI_MAX_ADDRESS 0xFFFFFFFF
+////////////////////////////////////////////////
+
+// Protocols
+#define EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL
+#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID FW_VOLUME_BLOCK_PROTOCOL_GUID
+#define EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
+#define EFI_SIMPLE_TEXT_OUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
+#define EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
+#define EFI_SIMPLE_TEXT_IN_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+#define LOAD_FILE_PROTOCOL_GUID EFI_LOAD_FILE_PROTOCOL_GUID
+#define EFI_EBC_INTERPRETER_PROTOCOL_GUID EFI_EBC_PROTOCOL_GUID
+
+//from EfiStdArg.h
+#define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))
+
+//
+// Also support coding convention rules for var arg macros
+//
+#ifndef VA_START
+
+typedef CHAR8 *VA_LIST;
+#define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))
+#define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))
+#define VA_END(ap) (ap = (VA_LIST) 0)
+
+#endif
+
+//from EfiDevicePath.h
+#define EFI_DP_TYPE_MASK 0x7F
+#define EFI_DP_TYPE_UNPACKED 0x80
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01
+
+#define DP_IS_END_TYPE(a)
+#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
+
+#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK )
+#define DevicePathSubType(a) ( (a)->SubType )
+#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) )
+
+#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE )
+#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
+#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )
+#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))
+
+#define SetDevicePathNodeLength(a,l) { \
+ (a)->Length[0] = (UINT8) (l); \
+ (a)->Length[1] = (UINT8) ((l) >> 8); \
+ }
+
+#define SetDevicePathEndNode(a) { \
+ (a)->Type = END_DEVICE_PATH_TYPE; \
+ (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
+ (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
+ (a)->Length[1] = 0; \
+ }
+
+
+
+EFI_STATUS
+EfiInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+VOID *
+EfiLibAllocateZeroPool (
+ IN UINTN AllocationSize
+ );
+
+VOID *
+EfiLibAllocatePool (
+ IN UINTN AllocationSize
+ );
+
+BOOLEAN
+EfiCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ );
+
+INTN
+EfiCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Length
+ );
+
+UINTN
+EfiStrLen (
+ IN CHAR16 *String
+ );
+
+VOID
+EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ );
+
+INTN
+EfiStrCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2
+ );
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ );
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ );
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ );
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ );
+
+VOID
+EFIAPI
+EfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ );
+
+
+EFI_STATUS
+EfiLibNamedEventSignal (
+ IN EFI_GUID *Name
+ );
+
+EFI_STATUS
+EfiLibReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+
+//STATIC
+VOID
+EFIAPI
+EventNotifySignalAllNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+EFI_STATUS
+EFIAPI
+TseEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ );
+
+BOOLEAN
+IsHexDigit (
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
+ );
+
+
+EFI_STATUS
+HexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ );
+
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ );
+
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ );
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ );
+
+// EDKHelper.c
+#define CONST const
+#define STATIC static
+#define VOLATILE volatile
+
+#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length))
+#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0)
+//
+// Length of temp string buffer to store value string.
+//
+#define CHARACTER_NUMBER_FOR_VALUE 30
+
+UINTN
+EfiStrSize (
+ IN CHAR16 *String
+ );
+
+VOID
+EfiStrCat (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ );
+
+CHAR16*
+ EfiStrStr (
+ IN CHAR16 *String,
+ IN CHAR16 *StrCharSet
+ );
+
+UINT64
+AmiTseDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ );
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+EFI_STATUS
+BufToHexString (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ );
+// EIP-41615: updated related to file browser support in add boot option
+VOID *
+EfiLibAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ );
+
+#endif /* _EDK_HELPER_H_ */
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/BootOnly/HookAnchor.c b/EDK/MiniSetup/BootOnly/HookAnchor.c
new file mode 100644
index 0000000..8cdcc37
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/HookAnchor.c
@@ -0,0 +1,676 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/HookAnchor.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 11 $
+//
+// $Date: 3/06/13 12:26a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/HookAnchor.c $
+//
+// 11 3/06/13 12:26a Premkumara
+// [TAG] EIP111415
+// [Category] Improvement
+// [Description] Elink function for SETUP_TOGGLE_KEY_UNICODE function
+// [Files] HookAnchor.h, AMITSE.sdl, commonoem.c, Commonoem.h,
+// HookList.c, HookAnchor.c
+//
+// 10 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 11/20/11 7:05a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 8 3/28/11 9:23p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 9 8/18/10 6:16p Mallikarjunanv
+// EIP-38089: Hook after pressing F2 key and before showing setup menu.
+//
+// 8 6/08/10 5:08p Blaines
+// Added new AMITSE hook (hook33), called when TSE determines that console
+// out is available.
+//
+// 7 4/13/10 6:01p Madhans
+// Eip: 33100 To create new hook for BootNowLaunching. (From bbsPopoup and
+// Boot override menu).
+//
+// 6 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/04/10 11:09p Madhans
+// MapControlActionMouse Hook added
+//
+// 4 10/28/09 5:36p Madhans
+//
+// 3 9/15/09 9:28a Sudhirv
+// Added hook functions for LoadSetupDefaults and PreSystemReset
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: HOOKANCHOR.C
+//
+// Description: file to handle the hook functions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SearchLastHook
+//
+// Description: Returns the lasthookfn number
+//
+// Input: firsthookfn
+//
+// Output: lastHookfn
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN SearchLastHook(UINTN firsthookfn)
+{
+ UINTN ii;
+
+ for ( ii = firsthookfn; (UINTN)AMITSE_HookList[ii] ; ii++ )
+ if( HOOKID0 == ((UINTN)AMITSE_HookList[ii]& HOOKID0) ) // Check till next HOOK
+ return (UINTN)ii-1;
+ return (UINTN)ii-1; // Last HOOKID may not be followed by another HOOKID but only by end of table
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SearchHook
+//
+// Description: Finds the Firsthookfn and Lasthookfn of HookNum
+//
+// Input: HookNum
+//
+// Output: firsthookfn , lastHookfn
+// returns zero if hook not found. Non Zero on success.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN SearchHook(UINTN HookNum,UINTN *firsthookfn,UINTN *lasthookfn)
+{
+ int ii;
+
+ *firsthookfn = 0;
+ for ( ii = 0; (UINTN)AMITSE_HookList[ii] ; ii++ )
+ {
+ if ( HookNum == (UINTN)AMITSE_HookList[ii] )
+ {
+ *firsthookfn = (UINTN)ii+2; // Skip the HOOKx and funHook
+ *lasthookfn = SearchLastHook(*firsthookfn);
+ return *firsthookfn;
+ }
+
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHook
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+//Input: HookNum , default function.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GenericHook( UINTN HookNum, TSE_HOOK * defaultfn )
+{
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ AMITSE_HookList[ii]();
+ }
+ else
+ defaultfn();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType1
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function.
+//
+// Output: Boolean
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN GenericHookType1( UINTN HookNum, TSE_HOOK * defaultfn)
+{
+ BOOLEAN ret = FALSE;
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ret |= ((TSE_HOOK_T1 *)AMITSE_HookList[ii])();
+ }
+ else
+ ret = ((TSE_HOOK_T1 *)defaultfn)();
+ return ret;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType2
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function and Key.
+//
+// Output: CONTROL_ACTION
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CONTROL_ACTION GenericHookType2( UINTN HookNum, TSE_HOOK * defaultfn, AMI_EFI_KEY_DATA key)
+{
+ CONTROL_ACTION ret = 0;
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ret = ((TSE_HOOK_T2 *)AMITSE_HookList[ii])(key);
+ }
+ else
+ ret = ((TSE_HOOK_T2 *)defaultfn)(key);
+ return ret;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType3
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function, Event and Context.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GenericHookType3( UINTN HookNum, TSE_HOOK * defaultfn, EFI_EVENT Event, VOID *Context)
+{
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ((TSE_HOOK_T3 *)AMITSE_HookList[ii])(Event, Context);
+ }
+ else
+ ((TSE_HOOK_T3 *)defaultfn)(Event, Context);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType4
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function, Event and Context.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GenericHookType4( UINTN HookNum, TSE_HOOK * defaultfn, BOOT_FLOW *bootFlowPtr)
+{
+ EFI_STATUS ret = EFI_SUCCESS;
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ret = ((TSE_HOOK_T4 *)AMITSE_HookList[ii])(bootFlowPtr);
+ }
+ else
+ ret = ((TSE_HOOK_T4 *)defaultfn)(bootFlowPtr);
+ return ret;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType5
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function, Password and MaxSize.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GenericHookType5( UINTN HookNum, TSE_HOOK * defaultfn, CHAR16 *Password, UINTN MaxSize)
+{
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ((TSE_HOOK_T5 *)AMITSE_HookList[ii])(Password, MaxSize);
+ }
+ else
+ ((TSE_HOOK_T5 *)defaultfn)(Password, MaxSize);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType6
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function and Variable pointers to hold colors.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GenericHookType6( UINTN HookNum, TSE_HOOK * defaultfn,
+ UINT8 *BGColor, UINT8 *FGColor, UINT8 *SecBGColor, UINT8 *SecFGColor,
+ UINT8 *SelBGColor, UINT8 *SelFGColor, UINT8 *NSelBGColor, UINT8 *NSelFGColor,
+ UINT8 *LabelBGColor, UINT8 *LabelFGColor,UINT8 *NSelLabelFGColor,
+ UINT8 *EditBGColor, UINT8 *EditFGColor, UINT8 *PopupFGColor, UINT8 *PopupBGColor)
+{
+ EFI_STATUS ret = EFI_SUCCESS;
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ret = ((TSE_HOOK_T6 *)AMITSE_HookList[ii])(BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor,
+ SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor,
+ LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor,
+ PopupFGColor, PopupBGColor);
+ }
+ else
+ ret = ((TSE_HOOK_T6 *)defaultfn)(BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor,
+ SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor,
+ LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor,
+ PopupFGColor, PopupBGColor);
+
+ return ret;
+}
+
+//#pragma optimize ("",off)
+
+//Hook #1
+VOID DrawQuietBootLogoHook(VOID)
+{
+ GenericHook( HOOKID1, DrawQuietBootLogo );
+}
+
+//Hook #2
+BOOLEAN ProcessConInAvailabilityHook(VOID)
+{
+ return GenericHookType1( HOOKID2, (TSE_HOOK *)ProcessConInAvailability);
+}
+
+//Hook #3
+VOID ProcessEnterSetupHook(VOID)
+{
+ GenericHook( HOOKID3, ProcessEnterSetup );
+}
+
+//Hook #4
+VOID ProcessProceedToBootHook(VOID)
+{
+ GenericHook( HOOKID4, ProcessProceedToBoot );
+}
+
+//Hook #5
+VOID MinisetupDriverEntryHookHook(VOID)
+{
+ GenericHook( HOOKID5, MinisetupDriverEntryHook );
+}
+
+//Hook #6
+VOID PostManagerHandShakeHookHook(VOID)
+{
+ GenericHook( HOOKID6, PostManagerHandShakeHook );
+}
+
+//Hook #7
+CONTROL_ACTION MapControlKeysHook(AMI_EFI_KEY_DATA key)
+{
+ return GenericHookType2( HOOKID7, (TSE_HOOK *) MapControlKeys, key);
+}
+
+//Hook #8
+VOID CheckForKeyHook( EFI_EVENT Event, VOID *Context )
+{
+ GenericHookType3( HOOKID8, (TSE_HOOK *) CheckForKey, Event, Context);
+}
+
+//Hook #9
+VOID BeforeLegacyBootLaunchHook(VOID)
+{
+ GenericHook( HOOKID9, BeforeLegacyBootLaunch );
+}
+
+//Hook #10
+VOID AfterLegacyBootLaunchHook(VOID)
+{
+ GenericHook( HOOKID10, AfterLegacyBootLaunch );
+}
+
+//Hook #11
+VOID BeforeEfiBootLaunchHook(VOID)
+{
+ GenericHook( HOOKID11, BeforeEfiBootLaunch );
+}
+
+//Hook #12
+VOID AfterEfiBootLaunchHook(VOID)
+{
+ GenericHook( HOOKID12, AfterEfiBootLaunch );
+}
+
+//Hook #13
+VOID SavedConfigChangesHook(VOID)
+{
+ GenericHook( HOOKID13, SavedConfigChanges );
+}
+
+//Hook #14
+VOID LoadedConfigDefaultsHook(VOID)
+{
+ GenericHook( HOOKID14, LoadedConfigDefaults );
+}
+
+//Hook #15
+VOID TimeOutLoopHookHook(VOID)
+{
+ GenericHook( HOOKID15, TimeOutLoopHook );
+}
+
+//Hook #16
+EFI_STATUS OemKey1HookHook ( BOOT_FLOW *bootFlowPtr )
+{
+ return GenericHookType4( HOOKID16, (TSE_HOOK *) OemKey1Hook, bootFlowPtr);
+}
+
+//Hook #17
+EFI_STATUS OemKey2HookHook ( BOOT_FLOW *bootFlowPtr )
+{
+ return GenericHookType4( HOOKID17, (TSE_HOOK *) OemKey2Hook, bootFlowPtr);
+}
+
+//Hook #18
+EFI_STATUS OemKey3HookHook ( BOOT_FLOW *bootFlowPtr )
+{
+ return GenericHookType4( HOOKID18, (TSE_HOOK *) OemKey3Hook, bootFlowPtr);
+}
+
+//Hook #19
+EFI_STATUS OemKey4HookHook ( BOOT_FLOW *bootFlowPtr )
+{
+ return GenericHookType4( HOOKID19, (TSE_HOOK *) OemKey4Hook, bootFlowPtr);
+}
+
+//Hook #20
+VOID PasswordEncodeHook( CHAR16 *Password, UINTN MaxSize)
+{
+ GenericHookType5( HOOKID20, (TSE_HOOK *)PasswordEncode, Password, MaxSize );
+}
+
+//Hook #21
+EFI_STATUS SetControlColorsHook(UINT8 *BGColor, UINT8 *FGColor, UINT8 *SecBGColor, UINT8 *SecFGColor,
+ UINT8 *SelBGColor, UINT8 *SelFGColor, UINT8 *NSelBGColor, UINT8 *NSelFGColor,
+ UINT8 *LabelBGColor, UINT8 *LabelFGColor,UINT8 *NSelLabelFGColor, UINT8 *EditBGColor, UINT8 *EditFGColor,
+ UINT8 *PopupFGColor, UINT8 *PopupBGColor)
+{
+ return GenericHookType6( HOOKID21, (TSE_HOOK *)SetControlColors,
+ BGColor, FGColor, SecBGColor, SecFGColor, SelBGColor,
+ SelFGColor, NSelBGColor, NSelFGColor, LabelBGColor,
+ LabelFGColor, NSelLabelFGColor, EditBGColor, EditFGColor,
+ PopupFGColor, PopupBGColor );
+}
+
+
+//Hook #22
+VOID InvalidActionHookHook(VOID)
+{
+ GenericHook( HOOKID22, InvalidActionHook );
+}
+
+//Hook #23
+VOID LoadedUserDefaultsHook(VOID)
+{
+ GenericHook( HOOKID23, LoadedUserDefaults );
+}
+
+//Hook #24
+VOID LoadedBuildDefaultsHook(VOID)
+{
+ GenericHook( HOOKID24, LoadedBuildDefaults );
+}
+
+//Hook #25
+VOID LoadedPreviousValuesHook(VOID)
+{
+ GenericHook( HOOKID25, LoadedPreviousValues );
+}
+
+//Hook #26
+VOID SetupConfigModifiedHook(VOID)
+{
+ GenericHook( HOOKID26, SetupConfigModified);
+}
+
+VOID DrawPopupMenuHook()
+{
+ GenericHook( HOOKID27, DrawBootOnlyBbsPopupMenu );
+}
+
+VOID BbsBootHook()
+{
+ GenericHook( HOOKID28, BbsBoot );
+}
+
+///Hook for Load deafaults fucntions.
+VOID LoadSetupDefaultsHook( NVRAM_VARIABLE *defaults, UINTN data )
+{
+ GenericHookType5( HOOKID29, (TSE_HOOK *)LoadSetupDefaults, (CHAR16*)defaults, data );
+}
+
+/// EIP:26409 - Hook function to update before resetting the system
+VOID PreSystemResetHookHook(VOID)
+{
+ GenericHook( HOOKID30, PreSystemResetHook );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GenericHookType7
+//
+// Description: Locates the hook based on hooknum and calls them
+// If hook not found it calls the default function.
+//
+// Input: HookNum , default function and Key.
+//
+// Output: CONTROL_ACTION
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CONTROL_ACTION GenericHookType7( UINTN HookNum, TSE_HOOK * defaultfn, VOID * pMouseInfo)
+{
+ CONTROL_ACTION ret = 0;
+ UINTN ii;
+ UINTN firsthookfn = 0;
+ UINTN lasthookfn = 0;
+
+ if ( SearchHook(HookNum,&firsthookfn, &lasthookfn ) )
+ {
+ for ( ii = firsthookfn; ii <= lasthookfn; ii++ )
+ ret = ((TSE_HOOK_T7 *)AMITSE_HookList[ii])(pMouseInfo);
+ }
+ else
+ ret = ((TSE_HOOK_T7 *)defaultfn)(pMouseInfo);
+ return ret;
+}
+
+//Hook #31
+CONTROL_ACTION MapControlMouseActionHook(VOID *pMouseInfo)
+{
+ return GenericHookType7( HOOKID31, (TSE_HOOK *) MapControlMouseAction, pMouseInfo);
+}
+
+//Hook #32
+VOID ProcessProceedToBootNowHook(VOID)
+{
+ GenericHook( HOOKID32, ProcessProceedToBootNow );
+}
+
+//Hook #33
+VOID ProcessConOutAvailableHook(VOID)
+{
+ GenericHook( HOOKID33, ProcessConOutAvailable );
+}
+
+VOID ProcessUIInitHookHook(VOID)
+{
+ GenericHook( HOOKID34, ProcessUIInitHook );
+}
+
+VOID AfterInitPostScreenHook(VOID)
+{
+ GenericHook( HOOKID35, AfterInitPostScreen );
+}
+
+//Hook #36
+VOID CheckForClickHook( EFI_EVENT Event, VOID *Context )
+{
+ GenericHookType3( HOOKID36, (TSE_HOOK *) CheckForClick, Event, Context);
+}
+//HOOK #37 EIP-111415
+VOID SwitchToPostScreenHook(VOID)
+{
+ GenericHook( HOOKID37, SwitchToPostScreen );
+}
+
+//Last Hook
+VOID LastTSEHook(VOID)
+{
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.cif b/EDK/MiniSetup/BootOnly/MiniSetup.cif
new file mode 100644
index 0000000..6f0d624
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/MiniSetup.cif
@@ -0,0 +1,47 @@
+<component>
+ name = "TSE Sources - BootOnly"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\BootOnly"
+ RefName = "Minisetup"
+[files]
+"MiniSetup.sdl"
+"MiniSetup.mak"
+"AMILogo\AMILogo.c"
+"AMILogo\AMILogo.h"
+"amiver.h"
+"bbs.c"
+"bbs.h"
+"boot.c"
+"box.c"
+"box.h"
+"buffer.c"
+"buffer.h"
+"dobmpmgr.c"
+"globals.c"
+"hiistring.c"
+"hiistring.h"
+"logo.c"
+"mem.c"
+"minisetup.c"
+"minisetup.h"
+"minisetupext.c"
+"notify.c"
+"postmgmt.c"
+"print.c"
+"protocol.c"
+"protocol.h"
+"screen.c"
+"screen.h"
+"string.c"
+"string.h"
+"timer.c"
+"Timer.h"
+"variable.c"
+"Resources.c"
+"HookAnchor.c"
+"EDKhelper.c"
+"EDKhelper.h"
+"password.c"
+"password.h"
+"postmgmtext.c"
+<endComponent>
diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.mak b/EDK/MiniSetup/BootOnly/MiniSetup.mak
new file mode 100644
index 0000000..d07745a
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/MiniSetup.mak
@@ -0,0 +1,138 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2004, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/MiniSetup.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 9 $
+##
+## $Date: 10/18/12 5:58a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/MiniSetup.mak $
+#
+# 9 10/18/12 5:58a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 12 10/10/12 12:36p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 8 4/02/10 6:13p Madhans
+# EIP 37036 : To make TSE 2.01 Binary module to work with older Cores
+#
+# 7 2/26/10 8:53p Madhans
+# For TSE 2.01.1024. refer changelog.log for file checkin history .
+##
+## 8 2/26/10 1:29p Madhans
+## Bootonly source module need AMITSEStrTokens.h
+##
+## 7 2/19/10 8:14a Mallikarjunanv
+## updated year in copyright message
+##
+## 6 2/17/10 1:02p Madhans
+## minisetupstr.uni removed and Strings token are refered from
+## AMITSEStrTokens.h
+##
+## 5 10/28/09 5:37p Madhans
+##
+## 4 8/17/09 12:22p Presannar
+## Removed include directory Core
+##
+## 3 6/24/09 6:09p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 7:41p Presannar
+## Initial implementation of coding standards
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:12p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 5 4/28/09 9:39p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 4 3/31/09 3:58p Madhans
+##
+## 3 2/05/09 10:15a Madhans
+## Style Module created.
+##
+## 2 1/30/09 6:06p Madhans
+## Function headers added.
+##
+## 1 12/18/08 7:58p Madhans
+## Intial version of TSE Lite sources
+##*****************************************************************##
+
+# MAK file for the eModule:MiniSetup
+
+MINISETUP_INCLUDES = \
+ -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 $(BUILD_DIR) \
+
+!if "$(TseLite_SUPPORT)" == "1"
+MINISETUP_INCLUDES = -I $(UEFISRC_DIR) $(MINISETUP_INCLUDES) -I $(TSELITESRC_DIR) -I $(TSE_STYLE_DIR)
+!endif
+
+
+$(BUILD_DIR)\MiniSetupLocal.lib : MiniSetupLib
+
+MiniSetupLib : $(BUILD_DIR)\MiniSetup.mak MiniSetupLibBin
+
+$(BUILD_DIR)\MiniSetup.mak : $(TSESRC_DIR)\$(@B).cif $(TSESRC_DIR)\$(@B).mak $(BUILD_RULES) $(BUILD_DIR)\AMITSEStrTokens.h
+ $(CIF2MAK) $(TSESRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+MiniSetupLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\MiniSetup.mak all\
+ "MY_INCLUDES=$(MINISETUP_INCLUDES)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\MiniSetupLocal.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/BootOnly/MiniSetup.sdl b/EDK/MiniSetup/BootOnly/MiniSetup.sdl
new file mode 100644
index 0000000..a96d9b4
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/MiniSetup.sdl
@@ -0,0 +1,83 @@
+TOKEN
+ Name = "MiniSetup_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable MiniSetup support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL"
+ Value = "1"
+ Help = "1 => Uses Graphics output protocol. 0 => Uses UgaDraw protocol."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_USE_EDK_LIBRARY"
+ Value = "0"
+ Help = "Turn on to Depend on the EDK Libraries, OFF makes use of Aptio Libaray"
+ TokenType = Boolean
+ TargetH = Yes
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "SETUP_OEM_SPECIAL_CONTROL_SUPPORT"
+ Value = "0"
+ Help = "Turn on to have OEM Special Control Support."
+ TokenType = Boolean
+ TargetH = Yes
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "SETUP_USE_GUIDED_SECTION"
+ Value = "0"
+ Help = "Enable to have BCP compatibility in Aptio 3.x"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_MAX_DRIVE_NAME"
+ Value = "51"
+ Help = "Set the value to dispaly number of characters for Drive name"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_BEST_HORIZONTAL_RESOLUTION"
+ Value = "800"
+ Help = "800 is Standard horizontal resolution for TSE."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_BEST_VERTICAL_RESOLUTION"
+ Value = "600"
+ Help = "600 is Standard vertical resolution for TSE."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+PATH
+ Name = "TSESRC_DIR"
+End
+
+MODULE
+ Help = "Includes MiniSetup.mak to Project"
+ File = "MiniSetup.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\MiniSetupLocal.lib"
+ Parent = "$(TSESRC_DIR)\MiniSetupLocal$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
diff --git a/EDK/MiniSetup/BootOnly/Resources.c b/EDK/MiniSetup/BootOnly/Resources.c
new file mode 100644
index 0000000..4b6c52a
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/Resources.c
@@ -0,0 +1,231 @@
+//**********************************************************************
+//**********************************************************************
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Resources.c 7 10/18/12 5:59a Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 5:59a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Resources.c $
+//
+// 7 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 5/02/11 3:31p Arunsb
+// Changed for EDK library build. PI 1.1 support added.
+//
+// 5 12/02/10 2:33p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 4 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 6 9/16/10 3:00p Madhans
+// To Avoid build issues with TSE_USE_EDK_LIBRARY Building.
+//
+// 5 7/12/10 4:49p Madhans
+// EIP 39113: Sign ON Message Support.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:00p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Resources.c
+//
+// Description: Library routines to load image resources.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include <minisetup.h>
+
+#if TSE_USE_EDK_LIBRARY
+
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+//#include EFI_PROTOCOL_DEFINITION (HII)
+#if PI_SPECIFICATION_VERSION<0x00010000
+ EFI_GUID guidFV = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; //For EDK Library usage tse have to set the fv guids correctly
+#else
+ EFI_GUID guidFV = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID;
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReadImageResource
+//
+// Description: Function to read all the resources of a image.
+//
+// Input: EFI_HANDLE ImageHandle, EFI_GUID *pGuid,
+// VOID **ppData, UINTN *pDataSize
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ReadImageResource(
+ EFI_HANDLE ImageHandle, EFI_GUID *pGuid,
+ VOID **ppData, UINTN *pDataSize
+)
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *pImage;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *pFV;
+ UINTN i=0, DataSize;
+ EFI_GUID *pSectionGuid;
+ UINT32 Authentication;
+
+ Status=gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, &pImage);
+ if (EFI_ERROR(Status)) return Status;
+ Status=gBS->HandleProtocol(pImage->DeviceHandle, &guidFV, &pFV);
+ if (EFI_ERROR(Status)) return Status;
+ do{
+ pSectionGuid=NULL;
+ DataSize=0;
+ Status=pFV->ReadSection (
+ pFV,&((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)(pImage->FilePath))->NameGuid,
+ EFI_SECTION_FREEFORM_SUBTYPE_GUID,i++, &pSectionGuid, &DataSize,
+ &Authentication
+ );
+ if (!EFI_ERROR(Status)&&EfiCompareGuid(pSectionGuid,pGuid)) break;
+ gBS->FreePool(pSectionGuid);
+ }while(!EFI_ERROR(Status));
+ if (EFI_ERROR(Status)) return Status;
+ *ppData = pSectionGuid;
+ if (pDataSize) *pDataSize = DataSize;
+ return EFI_SUCCESS;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FvReadResources
+//
+// Description: Function to read all the section from of specified image.
+//
+// Input: IN EFI_GUID *NameGuid,IN EFI_GUID *pGuid,IN OUT VOID **Buffer,IN OUT UINTN *BufferSize
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FvReadResources (
+ IN EFI_GUID *NameGuid,
+ IN EFI_GUID *pGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize
+ )
+{
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+ UINT32 AuthenticationStatus;
+
+ EFI_STATUS Status;
+ UINTN NumHandles;
+ EFI_HANDLE *HandleBuffer;
+ UINTN i,j=0;
+ UINTN DataSize=0;
+ EFI_GUID *pSectionGuid=NULL;
+
+ Status = gBS->LocateHandleBuffer(ByProtocol,&guidFV,NULL,&NumHandles,&HandleBuffer);
+ if (EFI_ERROR(Status)) return Status;
+
+ for (i = 0; i< NumHandles; ++i)
+ {
+ j=0;
+ gBS->HandleProtocol(HandleBuffer[i],&guidFV,&Fv);
+ do{
+ pSectionGuid=NULL;
+ DataSize=0;
+ Status = Fv->ReadSection(
+ Fv,NameGuid,
+ EFI_SECTION_FREEFORM_SUBTYPE_GUID,j++,
+ &pSectionGuid, &DataSize,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR(Status)&&EfiCompareGuid(pSectionGuid,pGuid)) break;
+ gBS->FreePool(pSectionGuid);
+ }while(!EFI_ERROR(Status));
+
+ if (!EFI_ERROR(Status))
+ {
+ // Section found
+ break;
+ }
+ }
+
+ if (!EFI_ERROR(Status))
+ {
+ *Buffer = pSectionGuid;
+ if (BufferSize) *BufferSize = DataSize;
+ }
+
+ gBS->FreePool(HandleBuffer);
+ return Status;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/EDK/MiniSetup/BootOnly/Timer.h b/EDK/MiniSetup/BootOnly/Timer.h
new file mode 100644
index 0000000..38352c1
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/Timer.h
@@ -0,0 +1,91 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Timer.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/Timer.h $
+//
+// 4 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: timer.h
+//
+// Description: Header file for code to handle the timer.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _TIMER_H_
+#define _TIMER_H_
+
+EFI_STATUS TimerCreateTimer( EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback,
+ VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger, EFI_TPL CallBackTPL );
+EFI_STATUS TimerStopTimer( EFI_EVENT *Event );
+
+#endif /* _TIMER_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/amiver.h b/EDK/MiniSetup/BootOnly/amiver.h
new file mode 100644
index 0000000..4d5bd91
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/amiver.h
@@ -0,0 +1,143 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/amiver.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/amiver.h $
+//
+// 4 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: amiver.h
+//
+// Description: This file contains version macros.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _AMIVER_H_
+#define _AMIVER_H_
+
+#define AMI_VERSION_SIGNATURE {'$','A','P','V'}
+
+#pragma pack(1)
+typedef struct
+{
+ CHAR8 signature[4];
+ UINT8 major;
+ UINT8 minor;
+ UINT16 build;
+ CHAR8 name[4];
+ UINT8 reserved[4];
+}
+AMI_VERSION;
+#pragma pack()
+
+#ifdef __cplusplus
+extern "C"
+{
+#define AMI_SET_VERSION(major,minor,build,sign) \
+AMI_VERSION gVersion_##sign = { \
+ AMI_VERSION_SIGNATURE, \
+ major, \
+ minor, \
+ build, \
+ ##sign, \
+ { 0, 0, 0, 0 } \
+}
+
+}
+#else
+
+#define AMI_SET_VERSION(major,minor,build,sign) \
+AMI_VERSION gVersion_##sign = { \
+ AMI_VERSION_SIGNATURE, \
+ major, \
+ minor, \
+ build, \
+ #sign, \
+ { 0, 0, 0, 0 } \
+}
+
+
+#endif //__cplusplus
+
+#define AMI_GET_VERSION_MAJOR(ver) ((ver).major)
+#define AMI_GET_VERSION_MINOR(ver) ((ver).minor)
+#define AMI_GET_VERSION_BUILD(ver) ((ver).build)
+#define AMI_GET_VERSION_NAME(ver) ((ver).name)
+
+#define AMI_VERSION_STRUCT(sign) (gVersion_##sign)
+
+#define AMI_CHECK_VERSION(ver) \
+ ( ((ver).major != 0) || ((ver).minor != 0) )
+
+#endif /* _AMIVER_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/bbs.c b/EDK/MiniSetup/BootOnly/bbs.c
new file mode 100644
index 0000000..4cfc7c7
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/bbs.c
@@ -0,0 +1,1552 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 32 $
+//
+// $Date: 7/11/14 1:31p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.c $
+//
+// 32 7/11/14 1:31p Premkumara
+// [TAG] EIP175119
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Can not boot to PXE with boot override menu if
+// GROUP_BOOT_OPTIONS_BY_TAG is 0
+// [RootCause] With GROUP_BOOT_OPTIONS_BY_TAG = 0, the Index
+//
+// of the BBS Network Device was 0xFFFF Since CSM does not
+//
+// publish any handle for BBS Network Boot Device.
+//
+// that's why it was not booting.
+// [Solution] Added Condition to check whether the Boot option type is
+//
+// Network or not.if Network Type then,Directly assigning the
+//
+// Orig Index so that it will Boot.
+// [Files] bbs.c
+//
+// 31 7/11/14 1:23p Premkumara
+// [TAG] EIP166385
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] If the HDD boot option is selected to Disabled in Boot
+// Priority, this HDD will be disappeared under DOS
+// [RootCause] TSE was setting Boot priority to BBS_UNPRIORITIZED_ENTRY
+//
+// insted of setting BBS_DO_NOT_BOOT_FROM for the disabled devices
+// [Solution] modified the code to assign the Boot priority to
+// BBS_DO_NOT_BOOT_FROM
+//
+// instead of BBS_UNPRIORITIZED_ENTRY for the disabled devices
+//
+// so that they will be visible under DOS
+// [Files] bbs.c
+//
+// 30 5/14/14 11:56a Arunsb
+// [TAG] EIP168723
+// [Description] Removed RT attribute for LegacyDevOrder variable.
+// [Files] bbs.c and callback.c
+//
+// 29 5/02/14 10:39a Premkumara
+// [TAG] EIP151484
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When token MATCH_BOOT_OPTION_BY_LOCATION = 0 and
+// GROUP_BOOT_OPTIONS_BY_TAG = 0, the device path info is not proper so
+// device is not displaying.
+// [RootCause] When MATCH_BOOT_OPTION_BY_LOCATION = 1 the BBS devicepath
+// and bootdata DevicePath length are getting matched but when
+// MATCH_BOOT_OPTION_BY_LOCATION = 0, then BBS devicepath and bootdata
+// DevicePath length will be different.
+// [Solution] To resolve this, when MATCH_BOOT_OPTION_BY_LOCATION = 1
+// i'm checking for valid DevicePath length and when
+// MATCH_BOOT_OPTION_BY_LOCATION = 0 i'm checking for valid for BBS device
+// type
+// [Files] BootOnly\BBs.c
+//
+// 28 12/03/13 2:09p Premkumara
+// [TAG] EIP130420
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] String is getting truncated
+// [RootCause] The string for messagebox, Popup controls is getting
+// truncated
+// [Solution] Used temp variable to store original string and modify the
+// string temp and used to avoid changing org string.
+// [Files] String.c
+//
+// 27 7/02/13 10:06a Premkumara
+// [TAG] EIP120011
+// [Category] Improvement
+// [Description] Variable BootOrder and LegacyDevOrder need
+// fool-proofing function when TSE load variabled
+// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c
+//
+// 26 2/06/13 9:03a Arunsb
+// Checked in properly
+//
+// 26 1/31/13 12:51p Arunsb
+// [TAG] EIP109382
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Boot Device name incorrect when load default
+// [RootCause] Legacy offset in gbootdata corrupted so names displayed
+// improperly.
+// [Solution] Legacy offsets re-calculated properly
+// [Files] CommonHelper.c, BootOnly\bbs.c and callback.c
+//
+// 25 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 20 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 24 9/24/12 9:04a Premkumara
+// [TAG] EIP 93797
+// [Description] Add support to check for enabled device in BBS priority
+// order before launching legacy boot.
+// [Files] bbs.c, Boot.c, Protocol.c
+//
+// 23 5/29/12 3:49a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 22 4/27/12 7:21a Premkumara
+// [TAG] EIP81402
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDD Port Number is not properly updated after adding
+// "TseDefaultBootOrder"
+// [RootCause] when GROUP_BOOT_OPTIONS_BY_TAG=0 BBSList->Name is not
+// returned properly
+// [Solution] Returned BBSList->Name properly
+// [Files] bbs.c, variable.c
+//
+// 21 1/11/12 7:11a Arunsb
+// [TAG] EIP64700
+// [Category] Improvement
+// [Description] Request for _BBSSetDevicePriorities to check current
+// BootPriority before assigning a new BootPriority
+// [Files] bbs.c
+//
+// 20 12/16/11 5:41a Arunsb
+// Reverted 64700 change. Bcoz legacy boot not happening properly.
+//
+// 19 11/30/11 1:24p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 18 10/31/11 9:49a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 17 9/29/11 1:15p Premkumara
+// [TAG] EIP64700
+// Category] Function Request
+// [Description] Checking current BootPriority before assigning a new
+// BootPriority.
+// Not assigning priority if it also BBS_DO_NOT_BOOT_FROM
+// [Files] bbs.c
+//
+// 16 6/20/11 11:43a Rajashakerg
+// [TAG] EIP59417
+// [Category] New Feature
+// [Description] Spport LOAD_OPTION_HIDDEN option in TSE
+// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
+// minisetup.h, special.c, callback.c
+//
+// 15 3/07/11 4:49p Arunsb
+// [TAG] EIP53106
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Invalid string appears in the boot order for Network
+// related devices
+// [RootCause] Handle not obtained for network related devices
+// [Solution] Disabled option is checked only if
+// GROUP_BOOT_OPTIONS_BY_TAG token is enabled
+// [Files] bbs.c and commonhelper.c
+//
+// 14 2/04/11 4:42p Mallikarjunanv
+// udpated the BBSGetDeviceList() function to update the
+// LegacyDevVariables properly in case of TSE Lite.
+//
+// 13 12/21/10 11:32a Mallikarjunanv
+//
+// 13 10/06/10 5:48p Madhans
+// [TAG] - EIP 45620
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- TSE with TSE_CONTINUE_BOOT_NOW_ON_FAIL ON Not allows to boot
+// to USB group of devices with customized BDS.
+// [RootCause] - BBSTable does not contain the DeviceType called USB. Only
+// in EFI Logical group is created in EFI variables.
+// TSE was checking the DeviceType to set the priorities.
+// [Solution]- TSE is changed to not check for DeviceType in BBSTable. But
+// set the priorities based on LegacyDevOrder.
+// [Files] - bbs.c commonhelper.c minisetup.h
+//
+// 12 10/05/10 5:08p Madhans
+// [TAG] - EIP 45299
+// [Category]- Enhancment
+// [Severity]- Minor
+// [Symptom]- TSE by default saves the Disbaled BBS devices device path in
+// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on
+// this variable to consider the device as disabled inaddtion to
+// LegacyDevOrder.
+// Some BDS customized projects don't want this.
+// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to
+// control this option. Bydefault It is Enabled.
+// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl
+//
+// 11 9/21/10 11:26a Madhans
+// EIP44542 changes
+//
+// 8 9/20/10 6:47p Madhans
+// [TAG] EIP44542
+// [Category] BUILD ISSUE FIX
+// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
+// when IdeSecurity and FastBoot modules added to the project
+// [RootCause] -
+// [Solution] Build issues resolved
+// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
+// bbs.c, special.c, Bds.c TseLitehelp
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 10 9/16/10 3:01p Madhans
+// To Avoid build issues with TSE_USE_EDK_LIBRARY Building.
+//
+// 9 8/27/10 4:59a Mallikarjunanv
+// EIP-39334: support to build TSE without the CSM module support
+//
+// 8 7/28/10 4:46a Mallikarjunanv
+// EIP-29951: TSE Device Path Name support updated
+//
+// 7 3/23/10 5:07p Blaines
+// Preseve the order of disabled BBS boot devices.
+//
+// 6 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 5:10a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 9/24/09 9:41a Sudhirv
+// EIP-24971: moved the dependency for TSE_CONTINUE_BOOT_NOW_ON_FAIL to
+// Tse Binary
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: bbs.c
+//
+// Description: takecare of bbs/legacy boot management.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "minisetup.h"
+
+EFI_GUID gLegacyDevGuid = LEGACY_DEV_ORDER_GUID;
+BOOT_DATA *gCurrLegacyBootData;
+static EFI_LEGACY_BIOS_PROTOCOL *gLegacyBios = NULL;
+extern EFI_GUID gEfiLegacyBiosProtocolGuid;
+
+//Internal functions
+EFI_STATUS _BBSInitProtocol( VOID );
+VOID _BBSSetDevicePriorities( BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData );
+VOID _CreateDriveString ( CHAR16 *String, UINT16 *IdentifyDriveData );
+VOID BBSBuildName( CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo );
+BOOLEAN _BBSCheckDisabled( BBS_TABLE *BBSEntry );
+UINT8 IsBootOptionsGroupingEnabled (void);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BBSInitProtocol
+//
+// Description: function to initialize the bbs protocol.
+//
+// Input: void
+//
+// Output: device path
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _BBSInitProtocol( VOID )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( gLegacyBios != NULL )
+ return Status;
+
+ Status = gBS->LocateProtocol( &gEfiLegacyBiosProtocolGuid, NULL, &gLegacyBios );
+ if ( EFI_ERROR( Status ) )
+ gLegacyBios = NULL;
+
+ return Status;
+}
+
+
+INTN CompareDevicePath(EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2){
+ UINTN len;
+//---------------------
+ if(!pDp1 && !pDp2) return 0; //if both is NULL than Dp1==Dp2
+ if(!pDp1 || !pDp2) return -1; // if one is NULL than Dp1!=Dp2
+ len=EfiDevicePathSize(pDp1);
+ if(EfiDevicePathSize(pDp2)!=len) return -1;
+ return MemCmp(pDp1,pDp2, len);
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MatchDevicePath
+//
+// Description: Matches the Device path from the BootOption to BBS Device path to locate the
+// right Device
+//
+// Input: pBootData - Boot Data of Boot Option
+// LegacyOrder - LegacyDevOrder Entry for Boot Option
+// DevHandle - BBS device Handle
+//
+// Output: BOOLEAN - TRUE - Device path matched betweend LegacyOrder and pBootData.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN MatchDevicePath(BOOT_DATA *pBootData, BBS_ORDER_TABLE* LegacyOrder, EFI_HANDLE DevHandle)
+{
+ CHAR16 *varName = L"BootXXXX";
+ BOOT_OPTION *pOption;
+ UINTN OptionSize;
+ EFI_DEVICE_PATH_PROTOCOL *Path;
+ EFI_DEVICE_PATH_PROTOCOL *BBSDevDP;
+ EFI_STATUS Status;
+ BOOLEAN bRet=FALSE;
+
+ OptionSize = 0; pOption = NULL;
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1),gBootFormarSpecifier, pBootData->Option );
+ pOption = (BOOT_OPTION *)VarGetNvramName( varName, &gEfiGlobalVariableGuid, NULL, &OptionSize );
+
+ if(EfiDevicePathSize(pBootData->DevicePath) == pOption->PathLength)
+ { // Device path Length Matches
+ // Not Flex Boot
+ bRet=TRUE;
+ goto DONE;
+ }
+
+ //For Flex Boot try to match Device path of BBS Device
+
+ // Skip the BBS Devicepath
+ Path = (EFI_DEVICE_PATH_PROTOCOL*)(((UINTN)pBootData->DevicePath) + EfiDevicePathSize(pBootData->DevicePath));
+
+ Status = gBS->HandleProtocol( DevHandle, &gEfiDevicePathProtocolGuid, &BBSDevDP );
+
+ // Not able to locate just matched the Device type
+ if ( EFI_ERROR( Status ) )
+ {
+ bRet=TRUE;
+ goto DONE;
+ }
+
+ //Comparing device path length if MATCH_BOOT_OPTION_BY_LOCATION = 1 devicepath(BBSDevDP) and DevicePath length are equal
+ if(CompareDevicePath(Path, BBSDevDP) == 0)
+ {
+ bRet=TRUE;
+ }
+
+ //EIP-151484 If MATCH_BOOT_OPTION_BY_LOCATION = 0 then devicepath(BBSDevDP) and Device Pathlength will be different so matching with DeviceType
+ else if( ( ((BBS_ORDER_TABLE*)LegacyOrder)->Type == BBSDevDP->Type ) ||
+ ( ((BBS_BBS_DEVICE_PATH*)pBootData->DevicePath)->DeviceType == BBSDevDP->Type )
+ )
+ {
+ bRet = TRUE;
+ }
+
+DONE:
+ MemFreePointer((VOID **)&pOption);
+
+ return bRet;
+}
+
+//EIP109382 Starts
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------
+// Procedure: RearrangeBBSOrder
+//
+// Description: Rearranges the bootdata legacy entries with legacydevorder defaults
+//
+// Input: VOID * - Cache Buffer
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+//UINT8 IsBootOptionsGroupingEnabled (VOID);
+EFI_STATUS _BBSInitProtocol (VOID);
+BOOLEAN MatchDevicePath(BOOT_DATA *pBootData, BBS_ORDER_TABLE* LegacyOrder, EFI_HANDLE DevHandle);
+VOID RearrangeBBSOrder (NVRAM_VARIABLE *nvPtr, NVRAM_VARIABLE *DefaultBuffer)
+{
+ EFI_STATUS Status;
+ UINT16 HDDCount = 0, BBSCount = 0;
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+ UINT16 *BootOrder;
+ UINTN BootOrderSize,p;
+ BOOT_DATA *pBootData;
+ UINT16 count = 0;
+ UINTN CurrSize = 0, iIndex = 0;
+ EFI_GUID AmitseBootOrderChangeGuid = AMITSE_BOOT_ORDER_CHANGE_GUID;
+ BBS_ORDER_TABLE *DevEntry = NULL, *CurrOrder = NULL, *NewLegacyOrder = NULL, *NewDevEntry = NULL;
+ BBS_BBS_DEVICE_PATH *DevPath = NULL;
+
+ Status = _BBSInitProtocol ();
+ if (EFI_ERROR (Status))
+ return;
+
+ Status = gLegacyBios->GetBbsInfo (
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+ if (EFI_ERROR (Status))
+ {
+ return;
+ }
+ BootOrderSize = 0;
+ BootOrder = VarGetNvramName (L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
+
+ if ((NULL == BootOrder) || (0 == BootOrderSize))
+ return; //continue;
+
+ NewLegacyOrder = EfiLibAllocateZeroPool (DefaultBuffer->Size);
+ if (NULL == NewLegacyOrder)
+ {
+ MemFreePointer((VOID **) &BootOrder);
+ return;
+ }
+
+ //NOTE: Taking advantage of the fact that
+ //VARIABLE_ID_BBS_ORDER is after
+ //VARIABLE_ID_BOOT_ORDER
+ NewDevEntry = NewLegacyOrder;
+ for (p=0; p<(BootOrderSize/sizeof(UINT16)); p++)
+ {
+ pBootData = BootGetBootData (BootOrder[p]);
+ //EIP:59417 - Error Handling in case of pBootData is NULL. If its NULL the setupgets a CRASH
+ if (pBootData == NULL)
+ goto DONE;
+
+ if (BBSValidDevicePath (pBootData->DevicePath))
+ {
+ DevPath = (BBS_BBS_DEVICE_PATH *)pBootData->DevicePath;
+ DevEntry = (BBS_ORDER_TABLE *)DefaultBuffer->Buffer;
+ for (iIndex = 0; iIndex < DefaultBuffer->Size; )
+ {
+ if ( (DevEntry->Length >= DefaultBuffer->Size) || (0 == DevEntry->Length) ) //EIP-120011
+ {
+ return;
+ }
+
+ count = DevEntry->Length / sizeof(UINT16) - 1;
+
+ if (count)
+ {
+ if (DevPath->DeviceType == DevEntry->Type)
+ {
+ if (MatchDevicePath (pBootData, DevEntry, (EFI_HANDLE)*(UINTN*)&BBSInfo[(UINT8)DevEntry->Data[0]].IBV1) )
+ //Found a valid dev entry group.
+ break;
+ }
+ }
+ count = sizeof (UINT32) + DevEntry->Length;
+ DevEntry = (BBS_ORDER_TABLE *)((UINTN)DevEntry + count);
+ iIndex += count;
+ }
+ if (iIndex < DefaultBuffer->Size)
+ {
+ MemCopy (NewDevEntry, DevEntry, sizeof(UINT32) + DevEntry->Length);
+ }
+ pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder;
+ //create boot data order list
+ NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + sizeof (UINT32) + DevEntry->Length);
+ }
+ }
+ MemFreePointer ((VOID **)&nvPtr->Buffer);
+ nvPtr->Buffer = (UINT8 *)NewLegacyOrder;
+DONE:
+ //Update the nv buffer with the re ordered list
+
+ //Signal TPM if BBS order has changed
+ CurrOrder = VarGetNvramName (L"LegacyDevOrder", &gLegacyDevGuid, NULL, &CurrSize);
+ if (NULL == CurrOrder)
+ {
+ MemFreePointer((VOID **) &BootOrder);
+ return;
+ }
+ if (CurrOrder)
+ {
+ if (MemCmp ((UINT8 *)CurrOrder, (UINT8 *)NewLegacyOrder, CurrSize))
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+
+ MemFreePointer((VOID **) &CurrOrder);
+ }
+ MemFreePointer((VOID **) &BootOrder);
+}
+//EIP109382 Ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSGetDeviceList
+//
+// Description: function to get the list of all the devices
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSGetDeviceList( VOID )
+{
+ EFI_STATUS Status;
+
+ UINT16 HDDCount = 0, BBSCount = 0;
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+
+ BBS_ORDER_TABLE *LegacyOrder = NULL, *NewLegacyOrder = NULL, *DevEntry, *NewDevEntry;
+ UINTN NewLegacyOrderSize, LegacyOrderSize=0, j, l;
+ UINT16 count = 0,u16Tmp;
+ UINT16 *BootOrder = NULL, *NewBootOrder = NULL;
+ UINTN NewBootOrderSize, BootOrderSize=0, i, k;
+ BOOT_DATA *pBootData;
+ BBS_BBS_DEVICE_PATH * DevPath;
+ UINT16 NoOfLegacyGroups = 0;
+ UINT32 LegDevOrderAttribute = 7;
+
+ Status = _BBSInitProtocol();
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ Status = gLegacyBios->GetBbsInfo(
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+
+ LegacyOrderSize = 0;
+
+ LegacyOrder = VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, &LegDevOrderAttribute, &LegacyOrderSize );
+ if ( LegacyOrder == NULL )
+ goto DONE;
+
+ BootOrderSize = 0;
+ BootOrder = VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize );
+ if(NULL == BootOrder)
+ goto DONE;
+
+ //Check if the Master boot order and Legacy dev order match.
+ //Create corrected new orders if not.
+ NewLegacyOrder = EfiLibAllocateZeroPool(LegacyOrderSize);
+ NewBootOrder = EfiLibAllocateZeroPool(BootOrderSize);
+
+ //NOTE: Device count will not be initialised here. It will be
+ //initialised with the number of devices in a group when the user
+ //switches to a page specific to that group.
+ NoOfLegacyGroups = 0;
+ k = 0;
+ NewDevEntry = NewLegacyOrder;
+ for(i=0; i<(BootOrderSize/sizeof(UINT16)); i++)
+ {
+ pBootData = BootGetBootData(BootOrder[i]);
+ if(pBootData)
+ {
+ if(BBSValidDevicePath(pBootData->DevicePath))
+ {
+ //BBS boot order entry
+ DevPath = (BBS_BBS_DEVICE_PATH *)pBootData->DevicePath;
+
+ DevEntry = LegacyOrder;
+ for(j=0; j<LegacyOrderSize; )
+ {
+ if ( (DevEntry->Length >= LegacyOrderSize) || (0 == DevEntry->Length) ) //EIP-120011
+ {
+ return;
+ }
+ count = DevEntry->Length / sizeof(UINT16) - 1;
+
+ if (count)
+ {
+ if(DevPath->DeviceType == DevEntry->Type)
+ {
+ if(MatchDevicePath(pBootData, DevEntry,(EFI_HANDLE)*(UINTN*)&BBSInfo[(UINT8)DevEntry->Data[0]].IBV1 ))
+ //Found a valid dev entry group.
+ break;
+ }
+ }
+
+ //Go to next entry
+ count = sizeof(UINT32) + DevEntry->Length;
+ DevEntry = (BBS_ORDER_TABLE *)((UINTN)DevEntry + count);
+ j += count;
+ }
+
+ if(j<LegacyOrderSize)
+ {
+ //Found a valid BBS entry. Take dev entry and boot option.
+ NewBootOrder[k] = BootOrder[i];
+ k++;
+
+ MemCopy(NewDevEntry, DevEntry, sizeof(UINT32) + DevEntry->Length);
+ NoOfLegacyGroups++;
+
+ pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder;
+ pBootData->LegacyDevCount = count;
+
+
+ if(gIsSaveDisabledBBSDevicePath)
+ {
+ //Make sure the right devices are disabled
+ for(j=0;j<count;j++)//Caution: destroying contents of j
+ {
+ if(BBS_ORDER_DISABLE_MASK == (NewDevEntry->Data[j] & BBS_ORDER_DISABLE_MASK))
+ {
+ //BBS Type Network Device doesnot publish any Handle hence, directly assigning the actual Index
+ if(BBS_TYPE_EMBEDDED_NETWORK == NewDevEntry->Type)//EIP-175119
+ NewDevEntry->Data[j] = (UINT8)(NewDevEntry->Data[j]);
+ //Make sure we have the device path in NVRAM for this legacy option
+ else if( !_BBSCheckDisabled( &(BBSInfo[(UINT8)(NewDevEntry->Data[j])]) ) )
+ {
+ NewDevEntry->Data[j] = (UINT8)(NewDevEntry->Data[j]);
+ }
+ }
+ }
+ }
+
+ if(!IsPreservedDisabledBootOptionOrder())
+ {
+ //Correct LegacyDevOrder variable if necessary. Move
+ //disabled devices to end.
+ for ( j = 0; j < count; j++ )
+ {
+ if(BBS_ORDER_DISABLE_MASK == (NewDevEntry->Data[j] & BBS_ORDER_DISABLE_MASK))
+ {
+ for(l=j+1; l<count; l++)
+ {
+ if(BBS_ORDER_DISABLE_MASK != (NewDevEntry->Data[l] & BBS_ORDER_DISABLE_MASK))
+ {
+ u16Tmp = NewDevEntry->Data[l];
+ NewDevEntry->Data[l] = NewDevEntry->Data[j];
+ NewDevEntry->Data[j] = u16Tmp;
+ break;
+ }
+ }
+ if(l>=count)
+ break;
+ }
+ }
+ }
+
+ //create boot data order list
+ pBootData->OrderList = EfiLibAllocateZeroPool( count * sizeof(BBS_ORDER_LIST) );
+ for ( j = 0; j < count; j++ )
+ {
+ pBootData->OrderList[j].Index = NewDevEntry->Data[j] & (~BBS_ORDER_DISABLE_MASK);
+ BBSBuildName(
+ pBootData->OrderList[j].Name,
+ &BBSInfo[pBootData->OrderList[j].Index],
+ pBootData->OrderList[j].Index,
+ HDDInfo
+ );
+ }
+
+ //Move pointer to the unused portion
+ count = sizeof(UINT32) + NewDevEntry->Length;
+ NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + count);
+
+ //Mark it used in DevEntry by assigning device type
+ //to BBS_TYPE_UNKNOWN
+ DevEntry->Type = BBS_TYPE_UNKNOWN;
+ }
+ }
+ else
+ {
+ //A valid non bbs boot order entry
+ NewBootOrder[k] = BootOrder[i];
+ k++;
+ }
+ }
+ }
+
+ //Set corrected variables
+ NewLegacyOrderSize = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder;
+ VarSetNvramName(L"LegacyDevOrder",
+ &gLegacyDevGuid,
+ LegDevOrderAttribute,
+ NewLegacyOrder,
+ NewLegacyOrderSize);
+
+ NewBootOrderSize = k*sizeof(UINT16);
+ VarSetNvramName(L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NewBootOrder,
+ NewBootOrderSize);
+
+ MemFreePointer( (VOID **)&BootOrder );
+ MemFreePointer( (VOID **)&NewBootOrder );
+ MemFreePointer( (VOID **)&LegacyOrder );
+ MemFreePointer( (VOID **)&NewLegacyOrder );
+
+DONE:
+ //Set LegacyDev variable with number of groups
+ UpdateLegacyDevVariable(NoOfLegacyGroups);
+
+ //Set the LegacyGroup variable to zero for now
+ NoOfLegacyGroups = 0;
+ VarSetNvramName( L"LegacyGroup", &gLegacyDevGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &NoOfLegacyGroups, sizeof(NoOfLegacyGroups) );
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSSetBootPriorities_BootOrder
+//
+// Description: Assign priority as per boot order other than 0 priority devices
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSSetBootPriorities_BootOrder(UINT16 Priority)
+{
+ EFI_STATUS Status;
+ UINT16 *pBootOrder=NULL;
+ UINT16 BootOrderCount = 0;
+ UINT16 DevType=0;
+ UINTN size=0;
+ UINT16 HDDCount = 0;
+ UINT16 BBSCount = 0;
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+ BOOT_DATA *pBootData;
+ UINT16 i,index,index1;
+ UINT16 j;
+ UINT8 *pDevOrder;
+ BBS_ORDER_TABLE *pDevEntry;
+
+ Status = _BBSInitProtocol();
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ Status = gLegacyBios->GetBbsInfo(
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ size =0 ;
+ pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ BootOrderCount=(UINT16)(size/sizeof(UINT16));
+
+ if (pBootOrder==NULL)
+ return;
+
+ size = 0;
+ pDevOrder = (UINT8 *)VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size );
+
+ if (pDevOrder==NULL)
+ {
+ MemFreePointer((VOID **) &pBootOrder);
+ return;
+ }
+
+ for(j=0;j<BootOrderCount;j++)
+ {
+ pBootData = BootGetBootData(pBootOrder[j]);
+ if(!pBootData)
+ continue;
+
+ if ( BBSValidDevicePath( pBootData->DevicePath ) )
+ {
+ pDevEntry = (BBS_ORDER_TABLE *)(pDevOrder + pBootData->LegacyEntryOffset);
+
+ if ( (pDevEntry->Length >= size) || (0 == pDevEntry->Length) ) //EIP-120011
+ {
+ return;
+ }
+ //search for boot options which are disabled and change their priority to BBS_DO_NOT_BOOT_FROM
+ for(index=0;index<pBootData->LegacyDevCount;index++)//EIP-166385
+ {
+ for(index1=0;index1<pBootData->LegacyDevCount;index1++)
+ {
+ if(((pBootData->OrderList[index])).Index == pDevEntry->Data[index1])
+ break;
+ }
+ if(index1 == pBootData->LegacyDevCount)
+ BBSInfo[((pBootData->OrderList[index])).Index].BootPriority = BBS_DO_NOT_BOOT_FROM;
+ }
+ for(i=0;i<pBootData->LegacyDevCount;i++)
+ {
+ if(!(pDevEntry->Data[i] & BBS_ORDER_DISABLE_MASK))
+ {
+ if(BBSInfo[pDevEntry->Data[i]].BootPriority == BBS_UNPRIORITIZED_ENTRY)
+ {
+ BBSInfo[pDevEntry->Data[i]].BootPriority = Priority;
+ Priority++;
+ }
+ }
+ }
+ }
+ }
+
+ MemFreePointer((VOID **) &pDevOrder);
+ MemFreePointer((VOID **) &pBootOrder);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSSetBootPriorities
+//
+// Description: function to set boot priorities
+//
+// Input: BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount)
+{
+ EFI_STATUS Status;
+ UINT16 HDDCount = 0, BBSCount = 0;
+ UINT16 i, Priority = 0;
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+ UINT16 *pBootOrder=NULL;
+ UINT16 BootOrderCount = 0;
+ UINTN size=0;
+
+ Status = _BBSInitProtocol();
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ Status = gLegacyBios->GetBbsInfo(
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+
+ if ( EFI_ERROR( Status ) )
+ return;
+ pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ BootOrderCount=(UINT16)(size/sizeof(UINT16));
+ for ( i = 0; i < BBSCount; i++ )
+ {
+ switch ( BBSInfo[i].BootPriority )
+ {
+ case BBS_IGNORE_ENTRY:
+ case BBS_LOWEST_PRIORITY:
+ case BBS_DO_NOT_BOOT_FROM: //EIP 64700
+ continue;
+ default:
+ BBSInfo[i].BootPriority = BBS_UNPRIORITIZED_ENTRY;
+ break;
+ }
+ }
+
+ if(pOrder)
+ {
+ for ( i = 0; i < BootOrderCount; i++ )
+ {
+ pBootData = BootGetBootData(pOrder[i]);
+
+ if(!pBootData)
+ continue;
+
+ if ( BBSValidDevicePath( pBootData->DevicePath ) )
+ _BBSSetDevicePriorities( BBSInfo, &Priority, pBootData);
+ }
+ }
+ else
+ {
+ if ( BBSValidDevicePath( pBootData->DevicePath ) )
+ _BBSSetDevicePriorities( BBSInfo, &Priority, pBootData );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BBSSetDevicePriorities
+//
+// Description: function to set boot device priorities
+//
+// Input: BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _BBSSetDevicePriorities( BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData )
+{
+ UINT8 *pDevOrder;
+ UINTN size;
+ UINT16 i,index,index1;
+ BBS_ORDER_TABLE *pDevEntry;
+
+ size = 0;
+ pDevOrder = (UINT8 *)VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == pDevOrder)
+ return;
+
+ pDevEntry = (BBS_ORDER_TABLE *)(pDevOrder + BootData->LegacyEntryOffset);
+
+ if ( (pDevEntry->Length >= size) || (0 == pDevEntry->Length) ) //EIP-120011
+ return;
+ //search for boot options which are disabled and change their priority to BBS_DO_NOT_BOOT_FROM
+ for(index=0;index<BootData->LegacyDevCount;index++)//EIP-166385
+ {
+ for(index1=0;index1<BootData->LegacyDevCount;index1++)
+ {
+ if(((BootData->OrderList[index])).Index == pDevEntry->Data[index1])
+ break;
+ }
+ if(index1 == BootData->LegacyDevCount)
+ BBSInfo[((BootData->OrderList[index])).Index].BootPriority = BBS_DO_NOT_BOOT_FROM;
+ }
+
+ for ( i = 0; i < BootData->LegacyDevCount; i++ )
+ {
+ if(!(pDevEntry->Data[i] & BBS_ORDER_DISABLE_MASK))
+ {
+ // don't set the BootPriority if it already the first one.
+ //EIP: 64700 Checking current BootPriority before assigning a new BootPriority
+ if ( (BBSInfo[pDevEntry->Data[i]].BootPriority != 0) && (BBSInfo[pDevEntry->Data[i]].BootPriority != BBS_DO_NOT_BOOT_FROM) ) //EIP 64700
+ {
+ BBSInfo[pDevEntry->Data[i]].BootPriority = *Priority;
+ (*Priority)++;
+ }
+ }
+ }
+
+ MemFreePointer((VOID **) &pDevOrder);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSSetBootNowPriority
+//
+// Description: Sets BBS priority for the BootNow devices.
+//
+// Input: BootData - Boot data
+// uiPrefferedDevice - prefered Device type valid in ShowAllBBSDev case
+// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 count = 0, offset = 0;
+ UINT8 *pDevOrder = NULL;
+ UINTN size = 0;
+ UINT16 HDDCount = 0, BBSCount = 0;
+ UINT16 i;
+ UINT16 Priority = 0;
+
+ BBS_ORDER_TABLE *pDev = NULL;
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+ BBS_ORDER_LIST *BBSList = NULL;
+
+ Status = _BBSInitProtocol();
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = gLegacyBios->GetBbsInfo(
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ for ( i = 0; i < BBSCount; i++ )
+ {
+ switch ( BBSInfo[i].BootPriority )
+ {
+ case BBS_IGNORE_ENTRY:
+ case BBS_LOWEST_PRIORITY:
+ case BBS_DO_NOT_BOOT_FROM: //EIP 64700
+ continue;
+ default:
+ BBSInfo[i].BootPriority = BBS_UNPRIORITIZED_ENTRY;
+ break;
+ }
+ }
+ if(!ShowAllBbsDev)
+ {
+ count = BootData->LegacyDevCount;
+ offset = (UINT16)BootData->LegacyEntryOffset;
+
+ size = 0;
+ pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == pDevOrder)
+ return EFI_NOT_FOUND;
+
+ pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset);
+
+ if ( (pDev->Length >= size) ||(0 == pDev->Length) ) //EIP-120011
+ return EFI_NOT_FOUND;
+
+ for ( i = 0; i < count; i++ )
+ {
+ if(DISABLED_BOOT_OPTION != pDev->Data[i])
+ {
+ BBSInfo[pDev->Data[i]].BootPriority = Priority;
+ Priority++;
+ }
+ }
+ }
+ else
+ {
+ BBSList = BootData->OrderList;
+ BBSInfo[BBSList[uiPrefferedDevice].Index].BootPriority = Priority;
+ Priority++;
+ }
+
+
+ TseBBSSetBootPriorities_BootOrder(Priority);
+
+ if (0 == Priority ) //EIP-93797
+ return EFI_UNSUPPORTED;
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CreateDriveString
+//
+// Description: function to create the device string
+//
+// Input: CHAR16 *String, UINT16 *IdentifyDriveData
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _CreateDriveString ( CHAR16 *String, UINT16 *IdentifyDriveData )
+{
+ UINT8 i, data8;
+ UINT16 data16;
+ UINT8 s[MAX_DRIVE_NAME] = "APAT :"; // "PATA: "
+
+ //Check if identify drive data is available
+ if(NULL == IdentifyDriveData)
+ return;
+
+ // Check Word76 for BIT1 and BIT2; set for SATA drives
+ data16 = IdentifyDriveData[76];
+ if ((data16 != 0xFFFF) && (data16 & 6)) {
+ s[1] = 'S';
+ }
+
+ // Get the drive name out of IdentifyDrive data word 27..46 (upto 40 chars)
+ MemCopy(&s[6], IdentifyDriveData+27, MAX_DRIVE_NAME-5);
+
+ // Swap the bytes
+ for (i=0; i<MAX_DRIVE_NAME; i+=2)
+ {
+ data8=s[i];
+ s[i]=s[i+1];
+ s[i+1]=data8;
+ }
+
+ s[MAX_DRIVE_NAME-1] = 0; // terminate with zero
+
+ //Put drive name in CHAR 16 array
+ for (i=0; i<(MAX_DRIVE_NAME-1); i++)
+ {
+ String[i] = s[i];
+ }
+ String[MAX_DRIVE_NAME-1] = 0; // terminate with 0
+}
+
+EFI_STATUS GetAdvanceDeviceName( CHAR16 *String, VOID *info, UINTN index, VOID *HDDInfo );
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSBuildDefaultName
+//
+// Description: function to build the default boot device name
+//
+// Input: CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSBuildDefaultName( CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 i, *StringDesc;
+
+ // If current BBS entry has its description then use it.
+ StringDesc = (UINT8*)(UINTN)((info->DescStringSegment << 4) + info->DescStringOffset);
+ if ( StringDesc != NULL )
+ {
+ for ( i = 0; (i < (MAX_DRIVE_NAME - 1)) && (StringDesc[i] != L'\0'); i++ )
+ String[i] = (CHAR16)StringDesc[i];
+
+ String[i] = L'\0';
+ }
+ else
+ {
+ Status = GetAdvanceDeviceName(String, info, index, HDDInfo);
+ if ( Status != EFI_SUCCESS ) {
+ switch ( info->DeviceType )
+ {
+ case BBS_TYPE_FLOPPY:
+ EfiStrCpy(String, L"Floppy");
+ break;
+
+ case BBS_TYPE_HARDDRIVE:
+ EfiStrCpy(String, L"Hard Drive");
+
+ case BBS_TYPE_CDROM:
+ if(BBS_TYPE_CDROM == info->DeviceType)
+ EfiStrCpy(String, L"CDROM");
+
+ if((index < 17) && (index > 0)) {
+ _CreateDriveString(String, HDDInfo[(index-1)/2].IdentifyDrive[(index-1)%2].Raw);
+ }
+ break;
+
+ case BBS_TYPE_EMBEDDED_NETWORK:
+ EfiStrCpy(String, L"Network");
+ break;
+
+ case BBS_TYPE_DEV:
+ EfiStrCpy(String, L"BEV Device");
+ break;
+
+ case BBS_TYPE_UNKNOWN:
+ default:
+ EfiStrCpy(String, L"Unknown");
+ break;
+ }
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSLaunchDevicePath
+//
+// Description: function to launch the device path
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath )
+{
+ EFI_STATUS Status;
+
+ Status = _BBSInitProtocol();
+
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ // Performance measurement Pause
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ Status = gLegacyBios->LegacyBoot( gLegacyBios, (BBS_BBS_DEVICE_PATH *)DevicePath, 0, NULL );
+
+ // Performance measurement continue
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSUpdateBootData
+//
+// Description: function to update boot related data
+//
+// Input: UINT16 GroupNo
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSUpdateBootData(UINT16 GroupNo)
+{
+ UINTN i,j;
+ BOOT_DATA *bootData;
+
+ for( j=0,i=0; i<gBootOptionCount; i++ )
+ {
+ bootData = &(gBootData[i]);
+ //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+ if(gLoadOptionHidden && (bootData->Active & LOAD_OPTION_HIDDEN))
+ continue;
+
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ if(GroupNo == j)
+ {
+ gCurrLegacyBootData = bootData;
+ break;
+ }
+ j++;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSGetOptionName
+//
+// Description: function to get the name of the option
+//
+// Input: UINT16 *Option, UINT16 Pos
+//
+// Output: string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *BBSGetOptionName( UINT16 *Option, UINT16 Pos )
+{
+ UINT16 count;
+ BBS_ORDER_LIST *BBSList;
+
+ BBSList = gCurrLegacyBootData->OrderList;
+ count = gCurrLegacyBootData->LegacyDevCount;
+
+ if(count <= Pos)
+ return( L"");
+
+ if( Option != NULL )
+ *Option=(BBSList+Pos)->Index;
+
+ if ( BBSList != NULL )
+ return (BBSList+Pos)->Name;
+
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BBSCheckDisabled
+//
+// Description: function to check whether a perticular entry is disabled.
+//
+// Input: UINT16 *Option, UINT16 Pos
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _BBSCheckDisabled( BBS_TABLE *BbsEntry )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ UINTN i,size = 0;
+ EFI_GUID BootManGuid = BOOT_MANAGER_GUID;
+ EFI_DEVICE_PATH_PROTOCOL *dpp = NULL, *NvramDP = NULL, *TmpNvramDP;
+
+ Handle = *(VOID**)(&BbsEntry->IBV1);
+
+ if (Handle == 0)
+ return TRUE;
+
+ Status = gBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &dpp);
+
+ if(EFI_ERROR(Status))
+ return TRUE;
+
+ TmpNvramDP = NvramDP = (EFI_DEVICE_PATH_PROTOCOL *)VarGetNvramName(L"DisabledDevs", &BootManGuid, NULL, &size);
+
+ if(NULL == NvramDP)
+ return FALSE;
+
+ for(i=0;i<size;)
+ {
+ if(EfiDevicePathSize(TmpNvramDP) == EfiDevicePathSize(dpp))
+ {
+ if(!MemCmp((UINT8 *)TmpNvramDP, (UINT8 *)dpp, EfiDevicePathSize(TmpNvramDP)))
+ break;
+ }
+ i+= EfiDevicePathSize(TmpNvramDP);
+ TmpNvramDP = (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *)NvramDP) + i );
+ }
+
+ MemFreePointer((VOID **) &NvramDP);
+
+ if(i<size)
+ return TRUE;
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSSetDisabled
+//
+// Description: function to disable a perticular entry.
+//
+// Input: UINT16 Index, VOID **DisDPs, UINTN *DPSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSSetDisabled(UINT16 Index, VOID **DisDPs, UINTN *DPSize)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ UINT16 HDDCount = 0, BBSCount = 0;
+
+ HDD_INFO *HDDInfo = NULL;
+ BBS_TABLE *BBSInfo = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *dpp = NULL;
+
+ Status = _BBSInitProtocol();
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ Status = gLegacyBios->GetBbsInfo(
+ gLegacyBios,
+ &HDDCount,
+ &HDDInfo,
+ &BBSCount,
+ &BBSInfo
+ );
+
+ Handle = *(VOID**)(&(BBSInfo[Index].IBV1));
+ if (Handle)
+ {
+ Status = gBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &dpp);
+ if(!EFI_ERROR(Status))
+ {
+ *DisDPs = MemReallocateZeroPool(*DisDPs, *DPSize, *DPSize + EfiDevicePathSize(dpp));
+ MemCopy( ((UINT8 *)*DisDPs)+*DPSize, dpp, EfiDevicePathSize(dpp));
+ *DPSize += EfiDevicePathSize(dpp);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBBSBootOptionName
+//
+// Description: function to get the Boot option name.
+//
+// Input: BOOT_DATA *bootData
+//
+// Output: CHAR16* - BootOptionName
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+CHAR16 *GetBBSBootOptionName( BOOT_DATA *bootData)
+{
+ UINT16 offset = 0, count = 0, i;
+ UINT8 *pDevOrder;
+ UINTN size = 0;
+ BBS_ORDER_LIST *BBSList = NULL;
+ BBS_ORDER_TABLE *pDev;
+
+ BBSList = bootData->OrderList;
+ count = bootData->LegacyDevCount;
+ offset = (UINT16)bootData->LegacyEntryOffset;
+
+ pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == pDevOrder)
+ return NULL;
+
+ if (IsBootOptionsGroupingEnabled ())
+ {
+ pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset); //EIP-81402
+
+ if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011
+ return NULL;
+
+ if (DISABLED_BOOT_OPTION == pDev->Data[0]) //For grouping only test for disable option
+ {
+ return gBBSDisabled;
+ }
+
+ for(i=0; i<count; i++)
+ {
+ if(BBSList[i].Index == pDev->Data[0])
+ break;
+ }
+ if(i<count)
+ return BBSList[i].Name;
+ }
+ else //EIP-81402 If GROUP_BOOT_OPTIONS_BY_TAG == 0 then retrun name
+ {
+ return BBSList->Name;
+ }
+
+ return bootData->Name;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsBBSDevicePath
+//
+// Description: function to check for bbs device path support.
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsBBSDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath )
+{
+ return (BOOLEAN)(
+ ( DevicePathType( DevicePath ) == BBS_DEVICE_PATH ) &&
+ ( DevicePathSubType( DevicePath ) == BBS_BBS_DP )
+ );
+}
+
+//EIP-93797 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBBSOptionStatus
+//
+// Description: function to get for bbs option status
+//
+// Input: BOOT_DATA
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN GetBBSOptionStatus(BOOT_DATA *pBootData)
+{
+ UINT32 offset=0;
+ UINT8 *pDevOrder;
+ BBS_ORDER_TABLE *pDev;
+ UINTN size = 0;
+
+ offset = (UINT16)pBootData->LegacyEntryOffset;
+
+ pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size);
+
+ pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset);
+
+ if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011
+ return TRUE;
+
+ //if(((UINT8)pDev->Data[0] == (pBootData->OrderList->Index))&&(BBS_ORDER_DISABLE_MASK == (UINT8)((pDev->Data[0])>>8)))
+ if(pDev->Data[0] & BBS_ORDER_DISABLE_MASK)
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return TRUE;
+ }
+ else
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return FALSE;
+ }
+}
+//EIP-93797 Ends
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/bbs.h b/EDK/MiniSetup/BootOnly/bbs.h
new file mode 100644
index 0000000..1bdd3a4
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/bbs.h
@@ -0,0 +1,146 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/bbs.h $
+//
+// 6 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 12/21/10 11:46a Mallikarjunanv
+// [TAG] EIP47353
+// [Category] Improvement
+// [Description] The #define 32 is tokenized so it can be able to
+// display more than 32 characters for some boot options.
+// [Files] bbs.h, MiniSetup.sdl
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: bbs.h
+//
+// Description: Header file for bbs/legacy boot management.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _BBS_H_
+#define _BBS_H_
+
+UINT16 gBBSHardDiskOffset ;
+UINT16 gBBSCDOffset ;
+UINT16 gBBSFloppyOffset ;
+UINT16 gBBSNetworkOffset ;
+UINT16 gBBSBevOffset ;
+
+#ifndef MAX_DRIVE_NAME
+#define MAX_DRIVE_NAME TSE_MAX_DRIVE_NAME // EIP : 47353 MAX_DRIVE_NAME 32 macro value is changed to TSE_MAX_DRIVE_NAME SDL TOKEN. So maximum character of Drive name can be determined at run time
+#endif //MAX_DRIVE_NAME
+
+typedef struct
+{
+ UINT16 HardDiskCount;
+ UINT16 CDROMCount;
+ UINT16 FloppyCount;
+ UINT16 NetworkCount;
+ UINT16 BevCount;
+}
+BBS_DEVICE_COUNT;
+
+typedef struct
+{
+ UINT32 Type;
+ UINT16 Length;
+ UINT16 Data[1];
+}
+BBS_ORDER_TABLE;
+
+#define BBS_ORDER_DISABLE_MASK 0xFF00
+
+typedef struct _BBS_ORDER_LIST
+{
+ UINT16 Index;
+ CHAR16 Name[MAX_DRIVE_NAME];
+}
+BBS_ORDER_LIST;
+
+//exported variables
+extern EFI_GUID gLegacyDevGuid;
+
+//exported functions
+VOID BBSGetDeviceList( VOID );
+VOID BBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount);
+EFI_STATUS BBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev);
+BOOLEAN BBSValidDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath );
+EFI_STATUS BBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath );
+
+VOID BBSUpdateBootData(UINT16 GroupNo);
+CHAR16 *BBSGetOptionName( UINT16 *Option, UINT16 Pos );
+//VOID BBSUpdateOrder(UINT16 newOption,UINT32 *offset,UINTN *size, VOID **buffer);
+VOID BBSSetDisabled(UINT16 Index, VOID **DisDPs, UINTN *DPSize);
+
+EFI_STATUS BbsItkBoot();
+
+#endif /* _BBS_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/boot.c b/EDK/MiniSetup/BootOnly/boot.c
new file mode 100644
index 0000000..5b5036c
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/boot.c
@@ -0,0 +1,3034 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/boot.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 70 $
+//
+// $Date: 5/02/14 9:26p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/boot.c $
+//
+// 70 5/02/14 9:26p Arunsb
+// semicolon added to PERF_END
+//
+// 69 5/02/14 5:13p Premkumara
+// [TAG] EIP162197
+// [Category] Improvement
+// [Description] Password encode feature modify to encode using Hashing
+// based on token.
+// [[Files] Password.c, PasswordEncodeBin.cif, AMITSE.cif,
+// TSESource.cif, PasswordEncode.c, PasswordEncode.h, AMITSE.sdl,
+// PasswordEncodeBin.mak, PasswordEncodeBin.sdl
+// AMIVfr.h, Boot.c
+//
+// 68 5/02/14 2:24a Arunsb
+// [TAG] EIP158989
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BGRT status bit not cleared with Shell v2.0
+// [RootCause] Shell v2.0 protocol not registered
+// [Solution] Shell v2.0 protocol registered and cleared the BGRT status
+// bit
+// [Files] AMIVfr.h and boot.c
+//
+// 67 2/11/14 7:52p Arunsb
+// [TAG] EIP125719
+// [Category] Improvement
+// [Description] The EfiCreateEventReadyToBoot is conflicted under
+// UefiLib.h and EDKhelper.h.
+// [Files] boot.c
+//
+// 66 12/04/13 5:20a Premkumara
+// [TAG] EIP123535
+// [Category] Improvement
+// [Description] Moved saving quietboot resolution to DrawQuietBootLogo()
+// to avoid setting resolution of initPostScreenthis while booting.
+// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c
+//
+// 65 11/06/13 12:16p Arunsb
+// [TAG] EIP136592, 141863
+// [Category] Improvement
+// [Description] Resolution restored before signalling
+// AMITSE_EVENT_BEFORE_BOOT_GUID
+// [Files] boot.c
+//
+// 64 9/13/13 1:55p Premkumara
+// Uploaded back EIP-126807 after TSEBootOnly1240 release.
+//
+// 63 9/13/13 8:33a Premkumara
+// Reverted EIP-126807 for TSEBootOnly1240 release.
+//
+// 61 7/02/13 10:06a Premkumara
+// [TAG] EIP120011
+// [Category] Improvement
+// [Description] Variable BootOrder and LegacyDevOrder need
+// fool-proofing function when TSE load variabled
+// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c
+//
+// 60 6/10/13 1:17p Arunsb
+// BS->CalculateCrc32 used to calculate CRC
+//
+// 59 5/21/13 5:52a Rajashakerg
+// [TAG] EIP121881
+// [Category] Improvement
+// [Description] Change resolution before boot in FastBoot path
+// [Files] boot.c
+//
+// 58 4/18/13 2:18a Arunsb
+// [TAG] EIP113266
+// [Category] Improvement
+// [Description] gBrowserCallbackEnabled variable moved to boot only
+// module
+// [Files] boot.c and FormBrowser2.c
+//
+// 57 3/18/13 12:23a Arunsb
+// [TAG] EIP117338
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] TSE BootGetBBSOptionStatus asserts
+// [RootCause] Pointer incremented from allocated initial memory and
+// freed so asserts
+// [Solution] Freed the initial allocated memory
+// [Files] boot.c
+//
+// 56 3/14/13 10:50a Premkumara
+// [TAG] EIP112796
+// [Category] New Feature
+// [Description] AMITSE not signalling AMITSE_EVENT_BEFORE_BOOT_GUID in
+// fast boot path and legacy boot path.
+// [Files] Boot.c
+//
+// 55 2/19/13 4:18a Premkumara
+// [TAG] EIP103540
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Currently _BootBuildFVDevicePath function using FV
+// protocol alone not FV2 protocol. So applications loading from ffs are
+// not loading properly.
+// [RootCause] _BootBuildFVDevicePath() function used
+// gEfiFirmwareVolumeProtocolGuid only not gEfiFirmwareVolume2ProtocolGuid
+// [Solution] Used gEfiFirmwareVolume2ProtocolGuid based on
+// PISpecVersion
+// [Files] CommonHelper.c, Boot.c
+//
+// 54 12/05/12 5:30a Arunsb
+// [TAG] EIP105864
+// [Category] Improvement
+// [Description] Screen not cleared properly for successive boots
+// [Files] boot.c
+//
+// 53 10/18/12 11:20a Arunsb
+// [TAG] EIP102710
+// [Category] Improvement
+// [Description] Include function "_RegisterShellGuid()" in fast boot
+// path
+// [Files] boot.c
+//
+// 52 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 19 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 50 9/24/12 9:13a Premkumara
+// [TAG] EIP 93797
+// [Category] Improvement
+// [Description] Add support to check for enabled device in BBS
+// priority order before launching legacy boot.
+// [Files] bbs.c, Boot.c, Protocol.c
+//
+// 49 9/21/12 9:38a Premkumara
+// [TAG] EIP 97704
+// [Category] Improvement
+// [Description] Support BootFFFF variable
+// [Files] Boot.h, Boot.c, Special.c
+//
+// 48 9/18/12 12:50a Rajashakerg
+// [TAG] EIP95518
+// [Category] Improvement
+// [Description] Validate the Gop before usage in all the possible cases
+// and also get instance of Gop through notification
+// [Files] boot.c, notify.c, logo.c
+//
+// 47 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 45 9/12/12 5:23a Rajashakerg
+// [TAG] EIP94205
+// [Category] Improvement
+// [Description] OEM needs Token to assign the display mode of SHELL
+// [Files] AMITSE.sdl, boot.c, CommonHelper.c
+//
+// 44 8/29/12 4:19p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 43 6/25/12 5:37p Arunsb
+// [TAG] EIP93524
+// [Category] Improvement
+// [Description] Invalidate the BGRT table when boot device launched
+// from BBS popup or from shell or launched as second boot device
+// [Files] boot.c and minisetup.c
+//
+// 42 5/29/12 3:53a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 41 5/28/12 6:09a Rajashakerg
+// [TAG] EIP89377
+// [Category] Improvement
+// [Description] Support to LegacyBootFailHook() in TSE.
+// [Files] AMITSE.sdl, CommonHelper.c, boot.c
+//
+// 40 5/25/12 1:38a Premkumara
+// [TAG] EIP88430
+// [Category] Improvement
+// [Description] Resolution set after logo displayed should retain when
+// boot to device.
+// [Files] boot.c, logo.c
+//
+// 39 5/08/12 2:31a Rajashakerg
+// [TAG] EIP89483
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Handle hidden boot options properly in BBS Pop up menu
+// [RootCause] Check for LOAD_OPTION_HIDDEN is not present when
+// TSE_BOOT_NOW_IN_BOOT_ORDER and POPUP_MENU_SHOW_ALL_BBS_DEVICES are
+// Disabled
+// [Solution] Provided the check for the loda option hidden.
+// [Files] boot.c
+//
+// 38 2/02/12 1:05p Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] boot.c
+//
+// 37 1/31/12 6:42a Arunsb
+// [TAG] EIP81830
+// [Category] Improvement
+// [Description] Support to uninstall the BGRT on legacy boot.
+// [Files] Commonhelper.c, postmgmt.c and boot.c
+//
+// 36 1/13/12 1:40a Arunsb
+// For shell the cursor is enabled. Default the cursor is disabled to
+// avoid cursor visibility in win8 seamless boot
+//
+// 35 1/10/12 2:36a Arunsb
+// [TAG] EIP77400
+// [Category] Improvement
+// [Description] Need to do "Clear Screen" whenever boot to EFI Shell
+// [Files] Boot.c and minisetup.h
+//
+// 34 12/29/11 12:00p Arunsb
+// [TAG] EIP74871
+// [Category] Improvement
+// [Description] When UEFI booting to windows, a cursor is displayed on
+// the lower right hand corner of the screen
+// [Files] Screen attribute changed to EFI_BACKGROUND_BLACK | EFI_WHITE
+//
+// 33 12/14/11 12:14p Premkumara
+// [TAG] EIP77400
+// [Category] Improvement
+// [Description] Need to do "Clear Screen" whenever boot to EFI Shell
+// [Files] Boot.c
+//
+// 32 12/10/11 4:43a Arunsb
+// Corrected the header
+//
+// 31 12/08/11 12:29p Arunsb
+// UpdateDriverVariables function used properly
+//
+// 30 11/30/11 1:20p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 29 11/24/11 5:26a Arunsb
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] boot.c
+//
+// 28 11/16/11 11:17a Madhans
+// [TAG] EIP75736
+// [Category] Improvement
+// [Description] To avoid flicks when booting UEFI OS for seamless boot.
+// [Files] Boot.c
+// Tseadvanced.c
+//
+// 27 11/13/11 12:30p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 26 11/02/11 10:43a Arunsb
+// [TAG] EIP69884
+// [Category] New Feature
+// [Description] Support for UEFI Load Options - USB WWID
+// [Files] boot.c
+//
+// 25 11/01/11 3:53p Rajashakerg
+// [TAG] EIP71223
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] TSE label 4.6.2_TSE_2_14_1219 has issues in Sandybridge
+// platform
+// [Solution] Fixed the issue by handling the return status when there
+// is no valid boot option to boot.
+// [Files] BootOnly\boot.c
+//
+// 24 10/31/11 9:47a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 23 9/24/11 4:41a Arunsb
+// [TAG] EIP70096
+// [Category] Improvement
+// [Description] Exposing the Handle of the image that's being launched
+// for boot.
+// This will help other elinks to do the processing. Needed for CsmOptOut
+// Feature.
+// [Files] BootOnly\boot.c
+//
+// 22 7/19/11 11:53a Arunsb
+// [TAG] EIP65320
+// [Category] Improvement
+// [Description] Board module hook for LoadImage failure
+// [Files] boot.c and commonhelper.c
+//
+// 21 7/11/11 4:50p Arunsb
+// [TAG] EIP64295
+// [Category] New Feature
+// [Description] Support for software created boot entry for USB.
+// CheckDevSupShortFormPath function added to check whether the boot
+// option supports short-form device path for USB class(Table 60) device
+// path.
+// Goto statement removed in CheckDevSupShortFormPath function.
+// [Files] boot.c
+//
+// 20 7/11/11 3:24p Arunsb
+// [TAG] EIP64295
+// [Category] New Feature
+// [Description] Support for software created boot entry for USB.
+// CheckDevSupShortFormPath function added to check whether the boot
+// option supports short-form device path for USB class(Table 60) device
+// path.
+// [Files] boot.c
+//
+// 19 6/30/11 4:13a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Boot device repair operation performed.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 18 6/29/11 6:12a Arunsb
+// [TAG] EIP 62631, 60128
+// [Category] New Feature
+// [Description] Hot key boot option in TSE as per UEFI spec. section
+// 3.1.6.
+// [Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h,
+// boot.c, hiistring20.c and hiistring21.c.
+//
+// 17 6/22/11 2:40p Arunsb
+// [TAG] EIP 62631
+// [Category] New Feature
+// [Description] Support for Hot key boot option in TSE as per UEFI
+// spec. section 3.1.6.
+// [Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h,
+// boot.c, hiistring20.c and hiistring21.c.
+//
+// 16 6/20/11 3:55p Arunsb
+// [TAG] EIP57660
+// [Category] New Feature
+// [Description] Non-removable media boot behavior as described in UEFI
+// specification v 2.3.1, p. 3.4.1.
+// [Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c,
+// boot.c and protocol.c
+//
+// 15 6/20/11 11:45a Rajashakerg
+// [TAG] EIP59417
+// [Category] New Feature
+// [Description] Spport LOAD_OPTION_HIDDEN option in TSE
+// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
+// minisetup.h, special.c, callback.c
+//
+// 14 6/10/11 2:35p Arunsb
+// [TAG] EIP57660
+// [Category] New Feature
+// [Description] Non-removable media boot behavior as described in UEFI
+// specification v 2.3.1, p. 3.4.1.2
+// [Files] boot.c, bootflow.c and bootflow.h
+//
+// 13 6/04/11 1:49p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Wrapper function added for InvalidateStatusInBgrt
+// function.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 12 5/29/11 12:04p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Quiet boot logo's only added for BGRT. BGRT status
+// field cleared if any changes happened in screen other than displaying
+// the image.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 11 3/15/11 5:15a Rajashakerg
+// [TAG] EIP51671
+// [Category] New Feature
+// [Description] Boot overide menu devices are not disable
+// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl,
+// boot.h, CommonHelper.c
+//
+// 10 2/04/11 4:36p Mallikarjunanv
+// UpdateBootVariables() function added to update boot and BBS Order
+// varaibles.
+//
+// 9 1/14/11 6:05p Madhans
+// [TAG] EIP52153
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If new device added once we boot after reboot, Booting
+// using BBS popup might Crash
+// [RootCause] The BootOrder Varaible is read when TSE entry and And it
+// is not synced with Cache value.
+// [Solution] Update the BootOrder,BBSOrder variable cache, when we
+// handle boot Variables in TSE
+// [Files] boot.c
+//
+// 8 12/02/10 2:33p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 13 9/13/10 3:10p Madhans
+// [TAG] EIP41137
+// [Category] Improvement
+// [Symptom] Boot errors status reported for TSE loaded also
+// [RootCause] Fix done in Boot.c. To report the error status only for
+// boot options.
+//
+// 12 9/08/10 6:53a Mallikarjunanv
+// EIP-42080: TSE updates with respect to Fast Boot Support
+//
+// 11 8/23/10 4:00p Blaines
+// In the function _BootSetBootManagerVariables, the assert that was
+// ensuring that all disabled boot options were forced to the end of the
+// list, was left outside of the code block (it was causing a hang after
+// inserting a new boot device, then re-booting).
+//
+// Only process the assert if the preserve disabled boot option order is
+// disabled.
+//
+// 10 7/28/10 4:46a Mallikarjunanv
+// EIP-29951: TSE Device Path Name support updated
+//
+// 9 4/13/10 6:01p Madhans
+// Eip: 33100 To create new hook for BootNowLaunching. (From bbsPopoup and
+// Boot override menu).
+//
+// 8 3/23/10 5:08p Blaines
+// Preseve the order of disabled BBS boot devices.
+//
+// 7 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/15/10 10:10p Madhans
+// To avoid Compilation issues
+//
+// 5 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 4 1/29/10 4:34p Madhans
+// To avoid compiler warnings.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/19/09 6:36p Madhans
+// updated the code getting language codes
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 6 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 3/31/09 3:33p Madhans
+// UnicodeCollection2 protocol support.
+//
+// 4 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: BOOT.C
+//
+// Description: This file contains code for Boot management
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include EFI_PROTOCOL_DEFINITION (BlockIo)
+#include EFI_PROTOCOL_DEFINITION (UsbIo)
+#include EFI_PROTOCOL_DEFINITION (DiskIo)
+#define BOOT_OPTION_ALLOC_UNIT 10
+//////////////////////////////////////
+//Extern Variables
+//////////////////////////////////////
+extern UINTN gDelOptionCount;
+extern BOOT_DATA *gDelBootData;
+extern UINT32 gBootFlow;
+extern UINTN CurrentScreenresolutionX, CurrentScreenresolutionY; //EIP-88430
+//////////////////////////////////////
+//Internal Variable Declarations
+//////////////////////////////////////
+UINTN gBootOptionCount;
+EFI_GUID gBootNowCountGuid = BOOT_NOW_COUNT_GUID;
+UINT16 *gBBSDisabled = L"Disabled in BBS Order";
+UINTN gLangCount;
+BOOT_DATA *gBootData;
+LANGUAGE_DATA *gLanguages;
+EFI_HANDLE gCurrentBootHandle = NULL;
+EFI_EVENT gShellLaunchEvent = NULL; //EIP 77400 Clearing the screen for shell boot
+EFI_EVENT gShell20LaunchEvent = NULL; //EIP158989 For shell2.0
+UINT16 DISABLED_BOOT_OPTION; //EIP-97704
+UINT16 DISABLED_DRIVER_OPTION; //EIP-97704
+UINTN gDriverOptionCount;//EIP70421 & 70422 Support for driver order
+BOOT_DATA *gDriverData;//EIP70421 & 70422 Support for driver order
+BOOLEAN gBrowserCallbackEnabled = FALSE; //EIP113266 Allow external drivers to change ASL cache only if it's TRUE; ignore browser callback otherwise
+//////////////////////////////////////
+//Internal Functions Declarations
+//////////////////////////////////////
+EFI_DEVICE_PATH_PROTOCOL *_BootBuildFVDevicePath( UINT32 *index, EFI_GUID *guidPtr );
+EFI_DEVICE_PATH_PROTOCOL *_BootBuildFileDevicePath( UINT32 *index, CHAR16 *fileName );
+EFI_DEVICE_PATH_PROTOCOL* _DiscoverPartition(EFI_DEVICE_PATH_PROTOCOL *DevicePath);
+VOID _BootSetBootManagerVariables(VOID);
+VOID _BootInstallLoadOptions( EFI_HANDLE handle, VOID *Options, UINTN OptionSize );
+EFI_STATUS _BootLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption );
+UINT16 _BootSetBootNowCount(VOID);
+CHAR16 *TseGetUefiDevPathString(EFI_DEVICE_PATH_PROTOCOL *DevPath);
+VOID InvalidateStatusInBgrtWrapper (VOID);
+VOID UninstallBgrtWrapper(VOID);//EIP81830 Support to uninstall the BGRT on legacy boot
+VOID FormHotBootKeys (CHAR16 *VarName);
+VOID RefreshBootKeysDetails (VOID);
+VOID FreeExtraKeyMemories (VOID);
+EFI_STATUS CheckForDeviceNeedRepair (EFI_DEVICE_PATH_PROTOCOL *);
+EFI_HANDLE CheckDevSupShortFormPath (EFI_DEVICE_PATH_PROTOCOL *);
+VOID LegacyBootFailHook(EFI_STATUS);
+VOID UefiBootFailHook (EFI_STATUS);
+VOID UpdateBootVariables ();
+VOID FixHiddenOptions (BOOLEAN, UINT16 **, UINTN);
+VOID _SetDriverManagerVariables (VOID);//EIP70421 & 70422 Support for driver order
+VOID UpdateDriverVariables ();//EIP70421 & 70422 Support for driver order
+UINT32 ShellTextMode (VOID);//EIP 94205 : OEM needs Token to assign the display mode of SHELL.
+UINTN PISpecVersion(VOID);//EIP-103540
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetBootOptions
+//
+// Description: This function collects all the boot options, both efi
+// and legacy boot options, that are present in the
+// system and sets various boot manager variables that
+// are used to expand boot manager questions.
+//
+// Input: VOID
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BootGetBootOptions( VOID )
+{
+ EFI_STATUS Status;
+ UINTN AllocatedCount;
+
+#ifndef STANDALONE_APPLICATION
+ CHAR16 Pattern[]=L"boot[0-9a-f][0-9a-f][0-9a-f][0-9a-f]";
+ CHAR16 KeyPattern[]=L"Key[0-9a-f][0-9a-f][0-9a-f][0-9a-f]";
+ UINTN OldVarNameSize;
+ UINTN VarNameSize;
+ CHAR16 *VarName;
+ EFI_GUID VarGuid;
+ VOID * UnicodeInterface;
+ UINTN size=0, Length = 2;
+ UINT8 *bufPtr;
+ BOOT_OPTION *buffer;
+ BOOT_DATA *dataPtr;
+ UINT32 *conditionPtr;
+ UINT16 *BootOrder;
+ CHAR16 *String=NULL;
+// UINTN KeyVarNameSize = 0;
+#endif //STANDALONE_APPLICATION
+ BOOLEAN IsFastBoot=FALSE;
+//EIP70421 & 70422 Support for driver order starts
+ UINTN DriverAllocatedCount;
+ CHAR16 DriverPattern[] = L"Driver[0-9a-f][0-9a-f][0-9a-f][0-9a-f]";
+ BOOLEAN BootOption = FALSE;
+ BOOLEAN DriverOption = FALSE;
+//EIP-97704 Starts
+ UINT16 jIndex = 0;
+ DISABLED_BOOT_OPTION = 0xFFFF;
+ DISABLED_DRIVER_OPTION = 0xFFFF;
+//EIP-97704 Ends
+ DriverAllocatedCount = gDriverOptionCount = 0;
+//EIP70421 & 70422 Support for driver order ends
+ AllocatedCount = gBootOptionCount = 0;
+#ifndef STANDALONE_APPLICATION
+ Status = InitUnicodeCollectionProtocol(&UnicodeInterface);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ RefreshBootKeysDetails ();
+ //start with a size of 80 bytes
+ VarNameSize = 80;
+ OldVarNameSize = VarNameSize;
+ VarName = EfiLibAllocateZeroPool(VarNameSize);
+ conditionPtr = VarGetNvramName( L"BootFlow", &_gBootFlowGuid, NULL, &size );
+ if ( (conditionPtr != NULL) && (BOOT_FLOW_CONDITION_FAST_BOOT == *conditionPtr) )
+ {
+ IsFastBoot = TRUE;
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ VarNameSize = ((EfiStrLen(L"BOOTXXXX")+1)*2);
+ VarName = EfiLibAllocateZeroPool(VarNameSize);
+ SPrint (VarName, VarNameSize, L"Boot%04X",BootOrder[0] );
+ MemFreePointer((VOID **) &BootOrder);
+ MemFreePointer((VOID **) &conditionPtr);
+ }
+ do
+ {
+ if (!IsFastBoot)
+ {
+ Status = gRT->GetNextVariableName (&VarNameSize,
+ VarName,
+ &VarGuid);
+ if (Status == EFI_BUFFER_TOO_SMALL)
+ {
+ //Allocate correct size
+ VarName = MemReallocateZeroPool (VarName,
+ OldVarNameSize,
+ VarNameSize);
+ OldVarNameSize = VarNameSize;
+ continue;
+ }
+ }
+// KeyVarNameSize = VarNameSize; //EIP: 62631 For hot key boot
+ if ( (VarNameSize == ((EfiStrLen (L"BOOTXXXX")+1)*2)) || (VarNameSize == ((EfiStrLen (L"DRIVERXXXX")+1)*2)) ) //Find if this variable is one of L"BOOTXXXX" or L"DRIVERXXXX"
+ {
+ if (MetaiMatch (UnicodeInterface, VarName, Pattern)) //The buffer is definatly a boot#### option
+ {
+ size = 0;
+ buffer = VarGetNvramName (VarName, &gEfiGlobalVariableGuid, NULL, &size);
+ if (buffer) //Variable exists. Store details in global array.
+ {
+ if (gBootOptionCount >= AllocatedCount) //Check if enough size has been already allocated
+ {
+ gBootData = MemReallocateZeroPool (gBootData, AllocatedCount * sizeof(BOOT_DATA), (AllocatedCount + BOOT_OPTION_ALLOC_UNIT) * sizeof(BOOT_DATA));
+ if (NULL == gBootData)
+ {
+ return EFI_UNSUPPORTED;
+ }
+ AllocatedCount += BOOT_OPTION_ALLOC_UNIT;
+ }
+ dataPtr = &(gBootData [gBootOptionCount]);
+ HexStringToBuf(
+ (UINT8 *)(&(dataPtr->Option)),
+ &Length,
+ &(VarName[4]),
+ NULL);
+ BootOption = TRUE;
+ gBootOptionCount ++;
+ }
+ }
+ else if (MetaiMatch (UnicodeInterface, VarName, DriverPattern)) //EIP70421 Support for Driver Order
+ {
+ size = 0;
+ buffer = VarGetNvramName (VarName, &gEfiGlobalVariableGuid, NULL, &size);
+ if (buffer) //Variable exists. Store details in global array.
+ {
+ if (gDriverOptionCount >= DriverAllocatedCount) //Check if enough size has been already allocated
+ {
+ gDriverData = MemReallocateZeroPool (gDriverData, DriverAllocatedCount * sizeof (BOOT_DATA), (DriverAllocatedCount + BOOT_OPTION_ALLOC_UNIT) * sizeof(BOOT_DATA));
+ if (NULL == gDriverData)
+ {
+ return EFI_UNSUPPORTED;
+ }
+ DriverAllocatedCount += BOOT_OPTION_ALLOC_UNIT;
+ }
+ dataPtr = &(gDriverData [gDriverOptionCount]);
+ HexStringToBuf(
+ (UINT8 *)(&(dataPtr->Option)),
+ &Length,
+ &(VarName[6]),
+ NULL);
+ DriverOption = TRUE;
+ gDriverOptionCount ++;
+ }
+ }
+ else
+ {
+ goto _NextVariable; //Jumping for next variable iteration
+ }
+ if (DriverOption || BootOption) //Common code for both driver and boot options
+ {
+ dataPtr->Active = buffer->Active;
+ dataPtr->Name = StrDup (buffer->Name);
+ bufPtr = (UINT8 *)((CHAR16 *)buffer->Name + EfiStrLen( buffer->Name ) + 1);
+ dataPtr->DevicePath = EfiLibAllocateZeroPool( buffer->PathLength );
+ if (NULL != dataPtr->DevicePath)
+ {
+ MemCopy (dataPtr->DevicePath, bufPtr, buffer->PathLength);
+ }
+ bufPtr += buffer->PathLength;
+ size -= (UINTN)bufPtr - (UINTN)buffer;
+ if (size != 0)
+ {
+ dataPtr->LoadOptions = EfiLibAllocatePool( size );
+ if ( dataPtr->LoadOptions != NULL )
+ {
+ dataPtr->LoadOptionSize = size;
+ MemCopy( dataPtr->LoadOptions, bufPtr, size );
+ }
+ }
+ if (BootOption)
+ {
+ //In case of DEVIE PATH support, to reset the name using device path
+ String = TseGetUefiDevPathString(dataPtr->DevicePath);
+ if (NULL != String)
+ {
+ // For UEFI boot options, Prefix the string with "UEFI: "
+ MemFreePointer( (VOID **)&(dataPtr->Name) );
+ dataPtr->Name = EfiLibAllocateZeroPool( EfiStrLen( String ) + EfiStrLen(L"UEFI: ")+ 1 );
+ EfiStrCpy(dataPtr->Name, L"UEFI: ");
+ EfiStrCat(dataPtr->Name, String);
+ }
+ }
+ MemFreePointer( (VOID **)&buffer );
+ }
+_NextVariable:
+ BootOption = DriverOption = FALSE; //Getting ready for next iteration
+ }
+ else if (VarNameSize == ((EfiStrLen(L"keyXXXX")+1)*2)) //Boot, Driver and Key are different length so handling in else if cases
+ {
+ if (MetaiMatch (UnicodeInterface, VarName, KeyPattern))
+ {
+ FormHotBootKeys (VarName);
+ }
+ }
+ // Only one Boot options is valid in FastBoot case
+ if(IsFastBoot)
+ break;
+ //reset the size of this buffer to what has been allocated for it
+ VarNameSize = OldVarNameSize;
+
+ }while(Status != EFI_NOT_FOUND);
+
+#endif //STANDALONE_APPLICATION
+
+//EIP-97704 Starts
+ //For Boot#### variable
+ for ( jIndex = 0; jIndex < gBootOptionCount; jIndex++ )
+ {
+ if ( gBootData[jIndex].Option == DISABLED_BOOT_OPTION )
+ {
+ DISABLED_BOOT_OPTION--;//Changing the value based on the available of BOOT#### variable
+ jIndex = -1;
+ continue;
+ }
+ }
+ //For Driver#### variable
+ for ( jIndex = 0; jIndex < gDriverOptionCount; jIndex++ )
+ {
+ if ( gDriverData[jIndex].Option == DISABLED_DRIVER_OPTION )
+ {
+ DISABLED_DRIVER_OPTION--;//Changing the value based on the available of DRIVER#### variable
+ jIndex = -1;
+ continue;
+ }
+ }
+//EIP-97704 Ends
+ //Free unused memory
+ if (gBootOptionCount < AllocatedCount)
+ gBootData = MemReallocateZeroPool(gBootData, AllocatedCount * sizeof (BOOT_DATA), gBootOptionCount * sizeof (BOOT_DATA));
+
+ if (gDriverOptionCount < DriverAllocatedCount)
+ gDriverData = MemReallocateZeroPool(gDriverData, DriverAllocatedCount * sizeof (BOOT_DATA), gDriverOptionCount * sizeof (BOOT_DATA));
+
+ FreeExtraKeyMemories ();
+ //Set boot manager variables
+ if(!IsFastBoot)
+ {
+ _BootSetBootManagerVariables ();
+ _SetDriverManagerVariables ();
+ }
+ Status = EFI_SUCCESS;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootLaunchBootOption
+//
+// Description: This function launches the boot option supplied
+//
+// Input: u16Option: BootOption to be launched
+// pOrder: The order in which to set BBS priorities
+// u16OrderCount: No of options in pOrder
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BootLaunchBootOption(UINT16 u16Option, UINT16 *pOrder, UINTN u16OrderCount)
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+ UINT16 u16BootCurrent;
+
+ BOOT_DATA *pBootData = NULL;
+
+ pBootData = BootGetBootData(u16Option);
+ if (pBootData)
+ {
+ //Set BootCurrent
+ u16BootCurrent = pBootData->Option;
+ VarSetNvramName(L"BootCurrent",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ &(u16BootCurrent),
+ sizeof(u16BootCurrent));
+ if( gBootFlow != BOOT_FLOW_CONDITION_FAST_BOOT) {
+ CsmBBSSetBootPriorities(pBootData, pOrder, u16OrderCount);
+ }
+ status = _BootLaunchDevicePath(pBootData->DevicePath, pBootData->LoadOptions, pBootData->LoadOptionSize,TRUE);
+
+ //clear BootCurrent
+ VarSetNvramName(L"BootCurrent",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ &(u16BootCurrent),
+ 0);
+ }
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetBootData
+//
+// Description: Finds and returns internal data structure BOOT_DATA
+// for a given boot option number.
+//
+// Input: Option: Option number for which BOOT_DATA is needed
+//
+// Output: Returns pointer to BOOT_DATA if found. Returns NULL
+// if BOOT_DATA not found.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOT_DATA *BootGetBootData( UINT16 Option )
+{
+ UINTN i;
+
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( gBootData[i].Option == Option )
+ return &gBootData[i];
+ }
+
+ return NULL;
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DriverGetDriverData
+//
+// Description: Finds and returns internal data structure BOOT_DATA
+// for a given Driver option number.
+//
+// Input: Option: Option number for which BOOT_DATA is needed
+//
+// Output: Returns pointer to BOOT_DATA if found. Returns NULL
+// if BOOT_DATA not found.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOT_DATA *DriverGetDriverData (UINT16 Option)
+{
+ UINTN i;
+
+ for ( i = 0; i < gDriverOptionCount; i++ )
+ {
+ if ( gDriverData[i].Option == Option )
+ return &gDriverData[i];
+ }
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetOptionName
+//
+// Description: Provides the unicode name for the given boot option
+// in the form of internal data structure BOOT_DATA.
+//
+// Input: bootData: BOOT_DATA struct for which unicode name is
+// needed.
+//
+// Output: Returns unicode string corresponding to the provided
+// BOOT_DATA. If the BOOT_DATA provided is for legacy
+// option then the name for the first legacy option in
+// that category is returned.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *BootGetOptionName( BOOT_DATA *bootData)
+{
+ if ( BBSValidDevicePath(bootData->DevicePath) ) {
+ return CsmBBSBootOptionName(bootData);
+ }
+ return bootData->Name;
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//------------------------------------------------------------------------------------
+// Procedure: DriverGetOptionName
+//
+// Description: Provides the unicode name for the given driver option
+// in the form of internal data structure BOOT_DATA.
+//
+// Input: DriverData: BOOT_DATA struct for which unicode name is
+// needed.
+//
+// Output: Returns unicode string corresponding to the provided BOOT_DATA
+//
+//------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *DriverGetOptionName (BOOT_DATA *DriverData)
+{
+ return DriverData->Name;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetBootNowName
+//
+// Description: Provides the unicode name for the given boot option.
+//
+// Input: value: boot option for which unicode name is needed
+//
+// Output: Returns unicode string corresponding to the provided
+// boot option.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *BootGetBootNowName( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde)
+{
+ UINT16 *BootOrder=NULL;
+ UINTN size = 0;
+ UINTN i,j,k;
+ UINTN count;
+
+ BOOT_DATA *bootData;
+
+ if((!ShowAllBBSDev) && (!TseBootNowInBootOrde))
+ if(gBootData == NULL)
+ return NULL;
+ else
+ {
+ if(gLoadOptionHidden && (gBootData[value].Active & LOAD_OPTION_HIDDEN))
+ return NULL;//EIP 89483 : Cheking for the load option hidden presence in the Boot option
+
+ return BootGetOptionName(&(gBootData[value]));
+ }
+ if(TseBootNowInBootOrde)
+ {
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == BootOrder){
+ ASSERT (0);
+ return NULL;
+ }
+
+ //Find the first disabled option
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( DISABLED_BOOT_OPTION == BootOrder[i] )
+ break;
+ }
+
+ if(i<gBootOptionCount)
+ {
+ //There are disabled options replace them with valid options
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ for(k=0;k<gBootOptionCount;k++)
+ {
+ if(BootOrder[k] == gBootData[j].Option)
+ break;
+ }
+
+ if(k >= gBootOptionCount)
+ {
+ //gBootData[j].Option is not present in BootOrder; fill it
+ BootOrder[i] = gBootData[j].Option;
+ i++;
+ }
+ }
+ }
+ }
+
+ if(ShowAllBBSDev)
+ {
+ count = 0;
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(TseBootNowInBootOrde) {
+ bootData = BootGetBootData(BootOrder[i]);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == bootData){
+ return NULL;
+ }
+ }
+ else {
+ bootData = gBootData + i;
+ }
+
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ if((value >= count) && (value < (count+bootData->LegacyDevCount)))
+ {
+ if(TseBootNowInBootOrde)
+ MemFreePointer((VOID **) &BootOrder);
+ if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0))
+ return NULL;
+
+ return bootData->OrderList[value-count].Name;
+ }
+
+ count+=bootData->LegacyDevCount;
+ }
+ else {
+ if(value == count)
+ {
+ if(TseBootNowInBootOrde)
+ MemFreePointer((VOID **) &BootOrder);
+ if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0))
+ return NULL;
+ return bootData->Name;
+ }
+ count++;
+ }
+ }
+ return NULL;
+ }
+ else {
+ bootData = BootGetBootData(BootOrder[value]);
+ MemFreePointer((VOID **) &BootOrder);
+ if (gLoadOptionHidden && ((bootData->Active & LOAD_OPTION_HIDDEN)!= 0))
+ return NULL;//EIP 89483 : Cheking for the load option hidden presence in the Boot option
+
+ return BootGetOptionName(bootData);
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetLanguages
+//
+// Description: Finds the languages that the firmware supports.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetBootLanguages( VOID )
+{
+ CHAR16 *langString;
+ CHAR8 *langCodes, *langPtr;
+ UINTN i, count, size = 0;
+
+ langCodes = VarGetNvramName( L"LangCodes", &gEfiGlobalVariableGuid, NULL, &size );
+ count = size /3;
+
+ if ( size == 0 )
+ {
+ langCodes = VarGetNvramName( L"Lang", &gEfiGlobalVariableGuid, NULL, &size );
+ if ( size != 0) {
+ count = 1;
+ }
+ else {
+ gLanguages = EfiLibAllocateZeroPool( sizeof(LANGUAGE_DATA) );
+ if ( gLanguages == NULL )
+ return;
+
+ gLanguages[0].LangCode = StrDup8("eng");
+ gLanguages[0].Unicode = StrDup(L"eng");
+ gLangCount = 1;
+ langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[0].Unicode );
+ gLanguages[0].Token = HiiAddString( gHiiHandle, langString );
+ gLanguages[0].LangString = langString;
+ return;
+ }
+ }
+
+ gLanguages = EfiLibAllocateZeroPool( count * sizeof(LANGUAGE_DATA) );
+ if ( gLanguages == NULL )
+ return;
+
+ for ( langPtr = langCodes, i = 0; i < count; i++, langPtr += 3 )
+ {
+ gLanguages[i].LangCode = EfiLibAllocateZeroPool( 4 * sizeof(CHAR8));
+ MemCopy( gLanguages[i].LangCode, langPtr, 3 * sizeof(CHAR8) );
+ gLanguages[i].Unicode = StrDup8to16(gLanguages[i].LangCode);
+ }
+
+ gLangCount = count;
+
+ for ( langPtr = langCodes, i = 0; i < count; i++, langPtr += 3 )
+ {
+ langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[i].Unicode );
+ gLanguages[i].Token = HiiAddString( gHiiHandle, langString );
+ gLanguages[i].LangString = langString;
+ }
+
+ MemFreePointer( (VOID **)&langCodes );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetLanguages
+//
+// Description: Finds the languages that the firmware supports.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetPlatformBootLanguages( VOID )
+{
+ CHAR16 *langString;
+ CHAR8 *langCodes, *langPtr;
+ UINTN i = 0, count=0, size = 0, pos = 0;
+
+ langCodes = VarGetNvramName( L"PlatformLangCodes", &gEfiGlobalVariableGuid, NULL, &size );
+ if(langCodes != NULL)
+ count = GetTokenCount(langCodes);
+
+ if ((0 == size) || (NULL == langCodes))
+ {
+ langCodes = VarGetNvramName( L"PlatformLang", &gEfiGlobalVariableGuid, NULL, &size );
+ if ( size != 0 ) {
+ count=1;
+ }
+ else {
+ gLanguages = (LANGUAGE_DATA *)EfiLibAllocateZeroPool( sizeof(LANGUAGE_DATA) );
+ if ( gLanguages == NULL )
+ return;
+
+ gLanguages[0].LangCode = StrDup8("en-US");
+ gLanguages[0].Unicode = StrDup(L"en-US");
+
+ gLangCount = 1;
+ langString = HiiGetStringLanguage( (VOID*)(UINTN)INVALID_HANDLE, 1, gLanguages[0].Unicode );
+ gLanguages[0].Token = HiiAddString( gHiiHandle, langString );
+ gLanguages[0].LangString = langString;
+ return;
+ }
+ }
+
+ gLanguages = EfiLibAllocateZeroPool( count * sizeof(LANGUAGE_DATA) );
+ if ( gLanguages == NULL )
+ return;
+
+ for ( langPtr = langCodes, i = 0; i < count; i++ )
+ {
+ gLanguages[i].LangCode = GetTokenString(langPtr, &pos);
+ gLanguages[i].Unicode = StrDup8to16(gLanguages[i].LangCode);
+ langString = HiiGetStringLanguage( INVALID_HANDLE, 1, gLanguages[i].Unicode );
+ gLanguages[i].Token = HiiAddString( gHiiHandle, langString );
+ gLanguages[i].LangString = langString;
+
+ langPtr += pos + 1;
+ }
+
+ gLangCount = count;
+ MemFreePointer( (VOID **)&langCodes );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootLaunchBootNow
+//
+// Description: Launches the boot option provided.
+//
+// Input: index: The nth option in the boot now menu.
+// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BootLaunchBootNow( UINT16 index, BOOLEAN ShowAllBbsDev )
+{
+
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+ BOOLEAN bLegacyBoot = FALSE;
+ UINT16 count = 0, BootCurrent;
+ UINT16 *BootOrder;
+ UINTN i = 0;
+
+ BOOT_DATA *bootData=NULL;
+
+ ProcessProceedToBootNowHook();
+
+ BootOrder = BootNowinBootOrderInit();
+
+ if(ShowAllBbsDev)
+ {
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ bootData = BootGetBootNowBootData(gBootData,BootOrder,i);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == bootData){
+ continue;
+ }
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ if((index >= count) && (index < (count+bootData->LegacyDevCount)))
+ {
+ bLegacyBoot = TRUE;
+ break;
+ }
+ else
+ count=count+(UINT16)(bootData->LegacyDevCount);
+ }
+ else
+ {
+ if(index == count)
+ break;
+ count++;
+ }
+ }
+ }
+ else
+ {
+ if(0 == gBootOptionCount)//EIP 71223: If there is no valid boot option present, returning EFI_NOT_FOUND.
+ return EFI_NOT_FOUND;
+ bootData = BootGetBootNowBootData(gBootData,BootOrder,index);
+ }
+
+ if(BootOrder!=NULL)
+ MemFreePointer((VOID **) &BootOrder);
+
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == bootData){
+ return EFI_NOT_FOUND;
+ }
+
+ if(ShowAllBbsDev)
+ {
+ if(i == gBootOptionCount)
+ return Status;
+
+ //Boot bootData and device index-count
+ //set bbs priorities
+ if(bLegacyBoot)
+ {
+ Status = CsmBBSSetBootNowPriority(bootData,index-count,ShowAllBbsDev);
+ if(EFI_ERROR( Status )) //EIP-93797
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ //Set BootCurrent
+ BootCurrent = bootData->Option;
+ VarSetNvramName(L"BootCurrent",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ &(BootCurrent),
+ sizeof(BootCurrent));
+ if(!ShowAllBbsDev)
+ {
+ if(BBSValidDevicePath(bootData->DevicePath))
+ {
+ Status = CsmBBSSetBootNowPriority(bootData,0,ShowAllBbsDev);
+ if(EFI_ERROR( Status )) //EIP-93797
+ return EFI_UNSUPPORTED;
+ }
+ }
+ Status = _BootLaunchDevicePath( bootData->DevicePath, bootData->LoadOptions, bootData->LoadOptionSize,TRUE );
+ //clear BootCurrent
+ VarSetNvramName(L"BootCurrent",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ &(BootCurrent),
+ 0);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootLaunchGuid
+//
+// Description: Launches the guided file from FV.
+//
+// Input: guid: Guid of the file to be launched.
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BootLaunchGuid( EFI_GUID *guid )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT32 index = 0;
+
+ EFI_DEVICE_PATH_PROTOCOL *devicePath;
+
+ do
+ {
+ devicePath = _BootBuildFVDevicePath( &index, guid );
+ if ( index != (UINT32)-1 )
+ Status = _BootLaunchDevicePath( devicePath, NULL, 0,FALSE );
+
+ MemFreePointer( (VOID **)&devicePath );
+ }
+ while ( ( EFI_ERROR( Status ) ) && ( index != (UINT32)-1 ) );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootLaunchFilename
+//
+// Description: Launches the file mentioned in file path from the
+// available FS.
+//
+// Input: fileName: Path of the file to be launched.
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS BootLaunchFilename( CHAR16 *fileName )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT32 index = 0;
+
+ EFI_DEVICE_PATH_PROTOCOL *devicePath;
+
+ do
+ {
+ devicePath = _BootBuildFileDevicePath( &index, fileName );
+ if ( index != (UINT32)-1 )
+ Status = _BootLaunchDevicePath( devicePath, NULL, 0,FALSE );
+
+ MemFreePointer( (VOID **)&devicePath );
+ }
+ while ( ( EFI_ERROR( Status ) ) && ( index != (UINT32)-1 ) );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------
+// Procedure: FixHiddenOptions
+//
+// Description: Function to move the hidden option at last of the boot order
+//
+// Input: UINT16 ** => Boot order to be reformed
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FixHiddenOptions (BOOLEAN Option, UINT16 **Order, UINTN OptionCount)
+{
+ UINTN iIndex = 0;
+ UINTN jIndex = 0;
+ UINT16 TempBootOption = 0;
+ BOOT_DATA *pBootData;
+
+ if (0 == OptionCount)
+ {
+ return;
+ }
+ for (iIndex = 0; iIndex < OptionCount-1; iIndex ++)
+ {
+ if (BOOT_ORDER_OPTION == Option)
+ {
+ pBootData = BootGetBootData ((*Order) [iIndex]);
+ }
+ else
+ {
+ pBootData = DriverGetDriverData ((*Order) [iIndex]);
+ }
+ if (pBootData)
+ {
+ if (pBootData->Active & LOAD_OPTION_HIDDEN)
+ {
+ for (jIndex = iIndex+1; jIndex < OptionCount; jIndex ++)
+ {
+ if (BOOT_ORDER_OPTION == Option)
+ {
+ pBootData = BootGetBootData ((*Order) [jIndex]);
+ }
+ else
+ {
+ pBootData = DriverGetDriverData ((*Order) [jIndex]);
+ }
+ if (!(pBootData->Active & LOAD_OPTION_HIDDEN))
+ {
+ TempBootOption = (*Order) [iIndex];
+ (*Order) [iIndex] = (*Order) [jIndex];
+ (*Order) [jIndex] = TempBootOption;
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootSetBootManagerVariables
+//
+// Description: function to set the variables for the boot manager
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _BootSetBootManagerVariables(VOID)
+{
+ UINT16 *NewBootOrder, *BootOrder, count;
+ UINTN size=0, i=0, j=0, k=0, BootOrderCount;
+
+ EFI_GUID BootManGuid = BOOT_MANAGER_GUID;
+ BOOT_DATA *pBootData;
+
+ //Correct BootOrder variable if necessary
+ NewBootOrder = NULL;
+ if(gBootOptionCount)
+ NewBootOrder = (UINT16 *)EfiLibAllocateZeroPool(gBootOptionCount * sizeof(UINT16));
+
+ BootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ BootOrderCount = size/sizeof(UINT16);
+
+ //Get all the enabled boot options in the boot order
+ for(i = 0; i < BootOrderCount; i++)
+ {
+ pBootData = BootGetBootData(BootOrder[i]);
+ if(pBootData)
+ {
+ if(IsPreservedDisabledBootOptionOrder())
+ { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+ /*if(gLoadOptionHidden && (pBootData->Active & LOAD_OPTION_HIDDEN))
+ {
+ j++;
+ continue;
+ }*/
+ NewBootOrder[j] = BootOrder[i];
+ j++;
+ }
+ else if(pBootData->Active & LOAD_OPTION_ACTIVE)
+ { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+ /*if(gLoadOptionHidden && (pBootData->Active & LOAD_OPTION_HIDDEN))
+ {
+ j++;
+ continue;
+ }*/
+ NewBootOrder[j] = BootOrder[i];
+ j++;
+ }
+ }
+ }
+
+ //Append all options that are enabled but not included in
+ //BootOrder. FCFS used.
+ for(i=0; i < gBootOptionCount; i++)
+ {
+ if(gBootData[i].Active & LOAD_OPTION_ACTIVE)
+ {
+ //Check presence in boot order
+ for(k=0;k<BootOrderCount;k++)
+ {
+ if(BootOrder[k] == gBootData[i].Option)
+ break;
+ }
+ if(k >= BootOrderCount)
+ {
+ //Not present in boot order! Add option
+ NewBootOrder[j] = gBootData[i].Option;
+ j++;
+ }
+ }
+ }
+
+ //Free Boot order
+ MemFreePointer((VOID **)&BootOrder);
+
+ if(!IsPreservedDisabledBootOptionOrder())
+ {
+ //Put disabled options at the end of NewBootOrder
+ for(i=0; i < gBootOptionCount; i++)
+ {
+ if(!(gBootData[i].Active & LOAD_OPTION_ACTIVE))
+ { //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+/* if(gLoadOptionHidden && (gBootData[i].Active & LOAD_OPTION_HIDDEN))
+ {
+ j++;
+ continue;
+ }*/
+ NewBootOrder[j] = gBootData[i].Option;
+ j++;
+ }
+ }
+ ASSERT(j==gBootOptionCount);
+ }
+
+ //Set BootOrder Variable with corrected order
+ if (gLoadOptionHidden)
+ {
+ FixHiddenOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount);
+ }
+ VarSetNvramName(L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NewBootOrder,
+ gBootOptionCount * sizeof(UINT16));
+
+ //Free NewBootOrder
+ MemFreePointer((VOID **)&NewBootOrder);
+
+ //Get BBS devices
+ CsmBBSGetDeviceList();
+
+ // Update the BootOrder,BBSOrder Cache From the NVRAM.
+ UpdateBootVariables();
+
+ //Set Boot manager variable
+ count = (UINT16)gBootOptionCount;
+ VarSetNvramName( L"BootManager", &BootManGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+
+ //Set Boot now count
+ if(gShowAllBbsDev)
+ count = _BootSetBootNowCount();
+
+ VarSetNvramName( L"BootNowCount", &gBootNowCountGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ UpdateAddDeleteBootVar ();
+}
+
+//EIP70421 & 70422 Support for driver order Starts
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------------------
+// Procedure: _SetDriverManagerVariables
+//
+// Description: Sets DriverManager variable for drivers count and sets DriverOrder
+//
+// Input: void
+//
+// Output: void
+//
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SetDriverManagerVariables (VOID)
+{
+ UINT16 *DriverOrder = NULL;
+ UINT16 *NewDriverOrder = NULL;
+ UINT16 DriverOrderCount = 0;
+ UINTN DriverOrderSize = 0;
+ UINTN iIndex = 0;
+ UINTN jIndex = 0;
+ UINT16 Count = 0;
+ BOOT_DATA *pDrvData; //BOOT_DATA using same structure for driver options too
+ EFI_GUID DrvMgrGuid = DRIVER_MANAGER_GUID;
+
+ if (gDriverOptionCount)
+ {
+ NewDriverOrder = (UINT16 *)EfiLibAllocateZeroPool (gDriverOptionCount * sizeof(UINT16));
+ if (NULL == NewDriverOrder)
+ {
+ return;
+ }
+ }
+ DriverOrder = (UINT16 *)VarGetNvramName (L"DriverOrder", &gEfiGlobalVariableGuid, NULL, &DriverOrderSize);
+ DriverOrderCount = (UINT16)(DriverOrderSize/sizeof(UINT16));
+ if ((NULL == DriverOrder) || (0 == DriverOrderSize))
+ {
+ for (iIndex = 0; iIndex < gDriverOptionCount; iIndex++) //Forming DriverOrder variable freshly
+ {
+ if (gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE)
+ {
+ NewDriverOrder [Count] = gDriverData [iIndex].Option;
+ Count ++;
+ }
+ }
+ goto _FormDisableDevices;
+ }
+ else //Forming DriverOrder variable with first active and non hidden drivers
+ {
+ for (iIndex = 0; iIndex < DriverOrderCount; iIndex ++)
+ {
+ pDrvData = DriverGetDriverData (DriverOrder [iIndex]);
+ if (pDrvData)
+ {
+ if ( (pDrvData->Active & LOAD_OPTION_ACTIVE) )
+ { //Checking for active drivers
+ NewDriverOrder [Count] = DriverOrder [iIndex];
+ Count ++;
+ }
+ }
+ }
+ }
+ //Append all options that are enabled but not included in
+ //DriverOrder. Having same logic as of boot order.
+ for(iIndex = 0; iIndex < gDriverOptionCount; iIndex ++)
+ {
+ if ( (gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE) )
+ {
+ //Check presence in DriverOrder
+ for (jIndex = 0; jIndex < DriverOrderCount; jIndex ++)
+ {
+ if (DriverOrder [jIndex] == gDriverData [iIndex].Option)
+ break;
+ }
+ if (jIndex >= DriverOrderCount)
+ {
+ //Not present in Driver order! Add option
+ NewDriverOrder [Count] = gBootData[iIndex].Option;
+ Count ++;
+ }
+ }
+ }
+_FormDisableDevices: //Forming disabled drivers last in the newly formed DriverOrder variable.
+ for (iIndex = 0; iIndex < gDriverOptionCount; iIndex ++)
+ {
+ if (!(gDriverData [iIndex].Active & LOAD_OPTION_ACTIVE))
+ {
+ NewDriverOrder [Count] = gDriverData [iIndex].Option;
+ Count ++;
+ }
+ }
+ if (gLoadOptionHidden)
+ {
+ FixHiddenOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount);
+ }
+ VarSetNvramName (
+ L"DriverOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NewDriverOrder,
+ gDriverOptionCount * sizeof(UINT16)
+ );
+ //Set Driver manager variable
+ Count = (UINT16)gDriverOptionCount;
+ VarSetNvramName (L"DriverManager", &DrvMgrGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &Count, sizeof(Count));
+ UpdateDriverVariables ();
+ if (DriverOrder)
+ {
+ MemFreePointer ((VOID **)&DriverOrder);
+ }
+ if (DriverOrder)
+ {
+ MemFreePointer ((VOID **)&NewDriverOrder);
+ }
+ UpdateAddDeleteDriverVar ();
+}
+//EIP70421 & 70422 Support for driver order Ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootSetBootNowCount
+//
+// Description: function to set boot new devices count
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _BootSetBootNowCount(VOID)
+{
+ UINT16 count = 0;
+ UINTN i;
+
+ BOOT_DATA *bootData;
+
+ for( i=0; i<gBootOptionCount; i++)
+ {
+ bootData = &(gBootData[i]);
+
+ if(BBSValidDevicePath(bootData->DevicePath))
+ {
+ count = count + bootData->LegacyDevCount;
+ }
+ else
+ count++;
+ }
+
+ return count;
+}
+
+//EIP 77400 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ShellClearScreen
+//
+// Description: Clears the screen for shell boot
+//
+// Input: EFI_EVENT , VOID *
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void ClearGrphxScreen (void);
+VOID _ShellClearScreen (EFI_EVENT Event, VOID *Context)
+{
+ UINT32 shelltextmodetype;
+ InvalidateStatusInBgrtWrapper(); //EIP93524 : When booting to shell clearing the BGRT status bit.
+ ClearGrphxScreen ();
+ gST->ConOut->ClearScreen (gST->ConOut);
+ gBS->CloseEvent (Event);
+ gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ if (Event != gShellLaunchEvent) //One event will be closed in incoming fnc argument other we have to close it
+ {
+ gBS->CloseEvent (gShellLaunchEvent);
+ }
+ if (Event != gShell20LaunchEvent) //EIP158989 For shell2.0
+ {
+ gBS->CloseEvent (gShell20LaunchEvent);
+ }
+ gShellLaunchEvent = NULL; //Make NULL otherwise we will try to close it after startimage
+ gShell20LaunchEvent = NULL;
+
+ shelltextmodetype = ShellTextMode();//EIP 94205 : OEM needs Token to assign the display mode of SHELL.
+
+ if ( 0xFF != shelltextmodetype )
+ gST->ConOut->SetMode( gST->ConOut, shelltextmodetype );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _RegisterShellGuid
+//
+// Description: Registers the shell guid
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _RegisterShellGuid (VOID)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ VOID *Registration = NULL;
+ EFI_GUID EfiShellInterfaceGuid = EFI_SHELL_PROTOCOL_GUID;
+ EFI_GUID EfiShell20InterfaceGuid = EFI_SHELL2_0_FILE_GUID;
+
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ _ShellClearScreen,
+ NULL,
+ &gShellLaunchEvent);
+ if (!EFI_ERROR (Status))
+ {
+ Status = gBS->RegisterProtocolNotify(
+ &EfiShellInterfaceGuid,
+ gShellLaunchEvent,
+ &Registration
+ );
+ }
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ _ShellClearScreen,
+ NULL,
+ &gShell20LaunchEvent);
+ if (!EFI_ERROR (Status))
+ {
+ Status = gBS->RegisterProtocolNotify(
+ &EfiShell20InterfaceGuid,
+ gShell20LaunchEvent,
+ &Registration
+ );
+ }
+}
+//EIP 77400 Ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootLaunchDevicePath
+//
+// Description: function to launch the boot operation
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _BootLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE handle;
+ BOOLEAN FreeDevicePath = FALSE;
+ EFI_EVENT ReadyToBootEvent;
+ EFI_GUID Bootguid = AMITSE_EVENT_BEFORE_BOOT_GUID;
+ EFI_GUID AfterBootGuid = AMITSE_EVENT_AFTER_BOOT_GUID; //EIP-162197
+
+ EFI_TPL CurrentTpl;
+ TSE_POST_STATUS BackupPostStatus;
+#ifndef STANDALONE_APPLICATION
+ EFI_CONSOLE_CONTROL_SCREEN_MODE ScreenMode = EfiConsoleControlScreenText;
+#endif //STANDALONE_APPLICATION
+
+ BackupPostStatus = gPostStatus; // Back it up and of boot fail restore it back
+ gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT;
+
+#if defined(EFI_EVENT_SIGNAL_READY_TO_BOOT) && EFI_SPECIFICATION_VERSION<0x20000
+ Status = gBS->CreateEvent(
+ EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,
+ EFI_TPL_CALLBACK,
+ NULL,
+ NULL,
+ &ReadyToBootEvent
+ );
+#else
+ Status = TseEfiCreateEventReadyToBoot(
+ EFI_TPL_CALLBACK,
+ NULL,
+ NULL,
+ &ReadyToBootEvent
+ );
+#endif //EFI_EVENT_SIGNAL_READY_TO_BOOT
+
+ if (EFI_ERROR(Status))
+ return Status;
+
+ gBS->SignalEvent( ReadyToBootEvent );
+ gBS->CloseEvent( ReadyToBootEvent );
+ EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_READY_TO_BOOT,0,NULL,NULL);
+
+ TSEIDEPasswordFreezeDevices();
+
+ if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT)
+ {
+ // Call the Hook and do the FastBoot
+ if ( BBSValidDevicePath( DevicePath ) )
+ {
+ BeforeLegacyBootLaunchHook();
+ UninstallBgrtWrapper(); //EIP81830 Support to uninstall the BGRT on legacy boot
+ }
+ else
+ {
+ BeforeEfiBootLaunchHook(); //Clearing the logo for shell in fast boot also EIP102710
+ if (NULL != gShellLaunchEvent)
+ {
+ gBS->CloseEvent (gShellLaunchEvent);
+ gShellLaunchEvent = NULL;
+ }
+ if (NULL != gShell20LaunchEvent) //EIP158989
+ {
+ gBS->CloseEvent (gShell20LaunchEvent);
+ gShell20LaunchEvent = NULL;
+ }
+ //EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification
+ //EIP136592, 141863, 123535
+ if ( ( NULL != gGOP ) && (CurrentScreenresolutionX && CurrentScreenresolutionY) && //If it has valid gGOP and resolution
+ ((CurrentScreenresolutionX != gGOP->Mode->Info->HorizontalResolution) || (CurrentScreenresolutionY != gGOP->Mode->Info->VerticalResolution)) //If current and quietboot resolution is different
+ )//EIP-88430
+ {
+ GOPSetScreenResolution(&CurrentScreenresolutionX, &CurrentScreenresolutionY);
+ //gGOP->SetMode (gGOP, CurrentResolutionIndex); // To maintain graphics resolution
+ }
+ EfiLibNamedEventSignal (&Bootguid);//EIP-112796 Signal AMITSE_EVENT_BEFORE_BOOT_GUID for EfiBoot during Fastboot
+ _RegisterShellGuid ();
+ }
+ // Performance measurement Pause
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+ Status = FastBootLaunch();
+
+ EfiLibNamedEventSignal (&AfterBootGuid);
+ return Status;
+ }
+#if APTIO_4_00 //EIP94702 Useful for secure boot violation message box
+ gMaxRows = MAX_ROWS;
+ gMaxCols = MAX_COLS;
+#endif
+ if ( BBSValidDevicePath( DevicePath ) ) //EIP58954 Changing the mode only for csm
+ {
+#ifndef STANDALONE_APPLICATION
+ // Fast Boot May want to boot without Console Control
+ if (gConsoleControl != NULL)
+ {
+ gConsoleControl->GetMode (gConsoleControl, &ScreenMode, NULL, NULL);
+ if (ScreenMode != EfiConsoleControlScreenText)
+ {
+ gConsoleControl->SetMode (gConsoleControl, EfiConsoleControlScreenText);
+ InvalidateStatusInBgrtWrapper (); //Since mode changed invalidating status field in BGRT table. EIP 58954
+ }
+ }
+#endif //STANDALONE_APPLICATION
+ BeforeLegacyBootLaunchHook();
+ UninstallBgrtWrapper(); //EIP81830 Support to uninstall the BGRT on legacy boot
+ Status = CsmBBSLaunchDevicePath( DevicePath );
+ if (EFI_ERROR (Status))
+ LegacyBootFailHook(Status);//EIP 89377 : Support to LegacyBootFailHook() in TSE.
+ AfterLegacyBootLaunchHook();
+ gPostStatus = BackupPostStatus;
+
+ EfiLibNamedEventSignal (&AfterBootGuid);
+ return Status;
+ }
+
+ CurrentTpl = gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL );
+ gBS->RestoreTPL( EFI_TPL_APPLICATION );
+ if (DevicePath->Type==MEDIA_DEVICE_PATH && DevicePath->SubType==MEDIA_HARDDRIVE_DP)
+ {
+ DevicePath = _DiscoverPartition(DevicePath);
+ FreeDevicePath = TRUE;
+ }
+ Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &handle);
+ if (EFI_ERROR (Status))
+ {
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath = DevicePath;
+ EFI_STATUS RepairStatus = FALSE;
+ UefiBootFailHook (Status);
+ RepairStatus = CheckForDeviceNeedRepair (TempDevicePath); //EIP 57661 support for UEFI specification v 2.3.1, p. 10.10.1 Driver health protocol
+ if (!(EFI_ERROR (RepairStatus)))
+ {
+ Status = gBS->LoadImage (TRUE, gImageHandle, DevicePath, NULL, 0, &handle);
+ if (EFI_ERROR (Status))
+ {
+ UefiBootFailHook (Status);
+ }
+ }
+ }
+ if (EFI_ERROR (Status))
+ {
+ //Try default behaviour
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath = NULL;
+ EFI_HANDLE DevHandle;
+ EFI_HANDLE UsbDevHandle = NULL;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo = NULL;
+ VOID *Buffer = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL;
+
+ // Find a Simple File System protocol on the device path.
+ TempDevicePath = DevicePath;
+
+ UsbDevHandle = CheckDevSupShortFormPath (DevicePath); ////EIP 64295 Support for section 3.1.2. booting from a short-form device path
+ if (NULL != UsbDevHandle)
+ {
+ DevHandle = UsbDevHandle;
+ }
+ else
+ {
+ Status = gBS->LocateDevicePath (
+ &gEfiSimpleFileSystemProtocolGuid,
+ &TempDevicePath,
+ &DevHandle
+ );
+ }
+ if ((!EFI_ERROR (Status) && IsDevicePathEnd (TempDevicePath)) || (NULL != UsbDevHandle))
+ {
+ // Files are specified in the device path so try to
+ // load the default removable media file name.
+
+ FilePath = EfiFileDevicePath (DevHandle, gBootFileName);
+
+ if (FilePath)
+ {
+ // Issue a dummy read to the device to check for media
+ // change. When the removable media is changed, any Block
+ // IO read/write will cause the BlockIo protocol be
+ // reinstalled and EFI_MEDIA_CHANGED is returned. After
+ // the Block IO protocol is reinstalled, subsequent Block
+ // IO read/write will success.
+ Status = gBS->HandleProtocol (
+ DevHandle,
+ &gEfiBlockIoProtocolGuid,
+ (VOID **) &BlkIo
+ );
+ if (!EFI_ERROR (Status))
+ {
+ Buffer = EfiLibAllocatePool (BlkIo->Media->BlockSize);
+ if (Buffer != NULL)
+ {
+ BlkIo->ReadBlocks (
+ BlkIo,
+ BlkIo->Media->MediaId,
+ 0,
+ BlkIo->Media->BlockSize,
+ Buffer
+ );
+ MemFreePointer((VOID **)&Buffer);
+ }
+ }
+
+ Status = gBS->LoadImage (
+ TRUE,
+ gImageHandle,
+ FilePath,
+ NULL,
+ 0,
+ &handle
+ );
+ if (EFI_ERROR (Status))
+ {
+ UefiBootFailHook (Status);
+ }
+ MemFreePointer((VOID **) &FilePath);
+ }
+ else
+ {
+ Status = EFI_NOT_FOUND;
+ }
+ }
+ else
+ {
+ Status = EFI_NOT_FOUND;
+ }
+ }
+
+
+ if(ValidBootOption==TRUE)
+ if (EFI_ERROR (Status)) // Report only if it Boot Option launch - Boot of loading Error!!!
+ EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_BOOT_OPTION_LOAD_ERROR,0,NULL,NULL);
+
+ if (FreeDevicePath) gBS->FreePool(DevicePath);
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ if (gST->ConOut != NULL)
+ {
+ gST->ConOut->EnableCursor (gST->ConOut, FALSE); //Disabling bcoz Cursor appears on the WIN8 boot
+ }
+ _BootInstallLoadOptions( handle, Options, OptionSize );
+
+ BeforeEfiBootLaunchHook();
+
+ // Performance measurement Pause
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ //EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification
+ //EIP136592, 141863
+ if ( ( NULL != gGOP ) && (CurrentScreenresolutionX && CurrentScreenresolutionY) && //If it has valid gGOP and resolution
+ ((CurrentScreenresolutionX != gGOP->Mode->Info->HorizontalResolution) || (CurrentScreenresolutionY != gGOP->Mode->Info->VerticalResolution)) //If current and quietboot resolution is different
+ )//EIP-88430
+ {
+ GOPSetScreenResolution(&CurrentScreenresolutionX, &CurrentScreenresolutionY);
+ //gGOP->SetMode (gGOP, CurrentResolutionIndex); // To maintain graphics resolution
+ }
+
+ // Signal AMITSE_EVENT_BEFORE_BOOT_GUID Event;
+ EfiLibNamedEventSignal (&Bootguid);
+ _RegisterShellGuid (); //EIP 77400 clearing the screen if its shell boot
+
+ Status = gBS->StartImage( handle, NULL, NULL );
+ if (NULL != gShellLaunchEvent) //EIP 77400 Close the event if it is not the shell boot
+ {
+ gBS->CloseEvent (gShellLaunchEvent);
+ gShellLaunchEvent = NULL;
+ }
+ if (NULL != gShell20LaunchEvent) //EIP158989
+ {
+ gBS->CloseEvent (gShell20LaunchEvent);
+ gShell20LaunchEvent = NULL;
+ }
+ // Performance measurement continue
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ AfterEfiBootLaunchHook();
+ EfiLibNamedEventSignal (&AfterBootGuid);
+/*#if APTIO_4_00
+ gMaxRows = MAX_ROWS;
+ gMaxCols = MAX_COLS;
+#endif //APTIO_4_00
+
+ SetDesiredTextMode(); //EIP94702 - StyleInit will set the desired text mode*/
+ ClearGrphxScreen ();
+ if(EFI_ERROR( Status ))
+ {
+ // Report only if it is Boot Option launch - Starting the Boot option failed.!!!!
+ if(ValidBootOption==TRUE)
+ EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_BOOT_OPTION_FAILED,0,NULL,NULL);
+
+ //Clear the flush buffer so that flush lines will actually
+ //draw the complete screen again
+ MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0);
+
+ if (gST->ConOut != NULL)
+ {
+ //Disable cursor, set desired attributes and clear screen
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, EFI_BACKGROUND_BLACK | EFI_WHITE);
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+
+ //Call flush lines to draw the whole screen again
+ FlushLines( 0, gMaxRows - 1 );
+// DoRealFlushLines(); //EIP94702
+ }
+ else
+ {
+ InvalidateStatusInBgrtWrapper (); //EIP93524 When win8 launched after successfull boot then BGRT table should be invalidated
+ }
+ }
+ gPostStatus = BackupPostStatus; /// restore the pre. Post status.
+
+ if ( CurrentTpl > EFI_TPL_APPLICATION )
+ gBS->RaiseTPL( CurrentTpl );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DiscoverPartition
+//
+// Description: function to launch the boot operation
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath
+//
+// Output: device path
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_DEVICE_PATH_PROTOCOL* _DiscoverPartition(EFI_DEVICE_PATH_PROTOCOL *DevicePath)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handle;
+ UINTN Count, i;
+
+ EFI_DEVICE_PATH_PROTOCOL *FullDevicePath=NULL;
+ HARDDRIVE_DEVICE_PATH* BootParitionDevicePath = (HARDDRIVE_DEVICE_PATH*)DevicePath;
+
+ //get list of available Block I/O devices
+ Status = gBS->LocateHandleBuffer(ByProtocol,&gEfiBlockIoProtocolGuid,NULL,&Count,&Handle);
+ if (EFI_ERROR(Status)) return NULL;
+
+ for( i=0; i<Count; i++ )
+ {
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_DEVICE_PATH_PROTOCOL *PartitionDevicePath, *TmpDevicePath;
+ HARDDRIVE_DEVICE_PATH* PartitionNode;
+
+ Status = gBS->HandleProtocol(Handle[i],&gEfiBlockIoProtocolGuid,&BlockIo);
+ if (EFI_ERROR(Status))
+ continue;
+
+ // if this is not partition, continue
+ if (!BlockIo->Media->LogicalPartition)
+ continue;
+
+ Status = gBS->HandleProtocol(Handle[i],&gEfiDevicePathProtocolGuid,&PartitionDevicePath);
+ if (EFI_ERROR(Status))
+ continue;
+
+ // Get last node of the device path. It should be partition node
+ PartitionNode = (HARDDRIVE_DEVICE_PATH*)PartitionDevicePath;
+
+ for( TmpDevicePath = PartitionDevicePath;
+ !IsDevicePathEndType(TmpDevicePath);
+ TmpDevicePath=NextDevicePathNode(TmpDevicePath) )
+ {
+ PartitionNode = (HARDDRIVE_DEVICE_PATH*)TmpDevicePath;
+ }
+
+ //Check if our partition matches Boot partition
+ if (PartitionNode->Header.Type!=MEDIA_DEVICE_PATH || PartitionNode->Header.SubType!=MEDIA_HARDDRIVE_DP)
+ continue;
+
+ if ( PartitionNode->PartitionNumber==BootParitionDevicePath->PartitionNumber &&
+ PartitionNode->SignatureType==BootParitionDevicePath->SignatureType &&
+ !MemCmp(PartitionNode->Signature,BootParitionDevicePath->Signature,16) )
+ {
+ //Match found
+ FullDevicePath = EfiAppendDevicePath(PartitionDevicePath,NextDevicePathNode(DevicePath));
+ break;
+ }
+ }
+
+ gBS->FreePool(Handle);
+ return FullDevicePath;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootInstallLoadOptions
+//
+// Description: function to install the load options
+//
+// Input: EFI_HANDLE handle, VOID *Options, UINTN OptionSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _BootInstallLoadOptions( EFI_HANDLE handle, VOID *Options, UINTN OptionSize )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+
+ Status = gBS->HandleProtocol( handle, &gEfiLoadedImageProtocolGuid, &LoadedImage );
+ if ( EFI_ERROR( Status ) )
+ return;
+
+ LoadedImage->LoadOptions = Options;
+ LoadedImage->LoadOptionsSize = (UINT32)OptionSize;
+
+ gCurrentBootHandle = handle; //EIP70096 Exposing the Handle of the image that's being launched for boot, This will help other elinks to do the processing.
+
+}
+
+#if EFI_SPECIFICATION_VERSION<0x20000
+static MEDIA_FW_VOL_FILEPATH_DEVICE_PATH gFvFile =
+{
+ { MEDIA_DEVICE_PATH, MEDIA_FV_FILEPATH_DP, { sizeof(MEDIA_FW_VOL_FILEPATH_DEVICE_PATH), 0 } },
+ MINI_SETUP_DATA_GUID
+};
+#endif //EFI_SPECIFICATION_VERSION
+
+static EFI_DEVICE_PATH_PROTOCOL gEndDevicePath =
+{
+ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootBuildFVDevicePath
+//
+// Description: function to build firmware volume device path protocol.
+//
+// Input: UINT32 *index, EFI_GUID *guidPtr
+//
+// Output: device path
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_DEVICE_PATH_PROTOCOL *_BootBuildFVDevicePath( UINT32 *index, EFI_GUID *guidPtr )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Count;
+ UINT32 i;
+ EFI_GUID tempEfiFirmwareVolumeProtocolGuid;
+
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath, *FilePath = NULL;
+#if EFI_SPECIFICATION_VERSION>=0x20000
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH gFvFile;
+#endif //EFI_SPECIFICATION_VERSION
+
+ if ( PISpecVersion() < 0x00010000 )//EIP-103540
+ tempEfiFirmwareVolumeProtocolGuid = gEfiFirmwareVolumeProtocolGuid;
+ else
+ tempEfiFirmwareVolumeProtocolGuid = gEfiFirmwareVolume2ProtocolGuid;
+
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol,
+ &tempEfiFirmwareVolumeProtocolGuid,
+ NULL,
+ &Count,
+ &HandleBuffer
+ );
+
+ if ( EFI_ERROR( Status ) )
+ {
+ *index = (UINT32)-1;
+ return FilePath;
+ }
+
+#if EFI_SPECIFICATION_VERSION<0x20000
+ MemCopy( (UINT8 *)&gFvFile + sizeof(EFI_DEVICE_PATH_PROTOCOL), guidPtr, sizeof(EFI_GUID) );
+#endif //EFI_SPECIFICATION_VERSION
+
+ for ( i = *index; i < (UINT32)Count; i++ )
+ {
+ Status = gBS->HandleProtocol( HandleBuffer[i], &gEfiDevicePathProtocolGuid, &DevicePath );
+ if ( EFI_ERROR( Status ) )
+ continue;
+
+#if EFI_SPECIFICATION_VERSION>=0x20000
+ EfiInitializeFwVolDevicepathNode (&gFvFile, guidPtr);
+#endif //EFI_SPECIFICATION_VERSION
+
+ FilePath = EfiAppendDevicePathNode( DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gFvFile );
+ if ( FilePath != NULL )
+ {
+ *index = i + 1;
+ break;
+ }
+ }
+
+ if ( i == (UINT32)Count )
+ *index = (UINT32)-1;
+
+ MemFreePointer( (VOID **)&HandleBuffer );
+
+ return FilePath;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _BootBuildFileDevicePath
+//
+// Description: function to build File device path protocol.
+//
+// Input: UINT32 *index, CHAR16 *fileName
+//
+// Output: device path
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_DEVICE_PATH_PROTOCOL *_BootBuildFileDevicePath( UINT32 *index, CHAR16 *fileName )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN Count;
+ UINT32 i;
+
+ EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL;
+
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol,
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ &Count,
+ &HandleBuffer
+ );
+
+ if ( EFI_ERROR( Status ) )
+ {
+ *index = (UINT32)-1;
+ return FilePath;
+ }
+
+ for ( i = *index; i < (UINT32)Count; i++ )
+ {
+ FilePath = EfiFileDevicePath( HandleBuffer[i], fileName );
+ if ( FilePath != NULL )
+ {
+ *index = i + 1;
+ break;
+ }
+ }
+
+ if ( i == (UINT32)Count )
+ *index = (UINT32)-1;
+
+ MemFreePointer( (VOID **)&HandleBuffer );
+ return FilePath;
+}
+
+//EIP: 51671 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsBootDeviceEnabled
+//
+// Description: Function to check the boot option status
+//
+// Input: UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsBootDeviceEnabled( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup)
+{
+
+ UINT16 *BootOrder=NULL;
+ UINTN size = 0;
+ UINTN i,j,k;
+ UINT16 count;
+
+ BOOT_DATA *bootData;
+
+ if((!ShowAllBBSDev) && (!TseBootNowInBootOrde))
+ if(gBootData == NULL)
+ return FALSE;
+ else
+ {
+ bootData = &gBootData[value];
+ if(BBSValidDevicePath(bootData->DevicePath) )
+ return BootGetBBSOptionStatus(bootData, 0, FromSetup,ShowAllBBSDev);
+ else
+ return BootGetOptionStatus(bootData, FromSetup);//EIP: 51671 Getting the Boot option status when TSE_BOOT_NOW_IN_BOOT_ORDER and SETUP_SHOW_ALL_BBS_DEVICES is OFF.
+ }
+ if(TseBootNowInBootOrde)
+ {
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ if (NULL == BootOrder) //Check for boot order else the system will hang
+ {
+ return TRUE;
+ }
+ //Find the first disabled option
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( DISABLED_BOOT_OPTION == BootOrder[i] )
+ break;
+ }
+
+ if(i<gBootOptionCount)
+ {
+ //There are disabled options replace them with valid options
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ for(k=0;k<gBootOptionCount;k++)
+ {
+ if(BootOrder[k] == gBootData[j].Option)
+ break;
+ }
+
+ if(k >= gBootOptionCount)
+ {
+ //gBootData[j].Option is not present in BootOrder; fill it
+ BootOrder[i] = gBootData[j].Option;
+ i++;
+ }
+ }
+ }
+ }
+
+ if(ShowAllBBSDev)
+ {
+ count = 0;
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(TseBootNowInBootOrde) {
+ bootData = BootGetBootData(BootOrder[i]);
+ }
+ else {
+ bootData = gBootData + i;
+ }
+
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ if((value >= count) && (value < (count+bootData->LegacyDevCount)))
+ {
+ if(TseBootNowInBootOrde)
+ MemFreePointer((VOID **) &BootOrder);
+ return BootGetBBSOptionStatus(bootData, value-count, FromSetup, ShowAllBBSDev);//EIP: 51671 Getting the Legacy Boot option status when SETUP_SHOW_ALL_BBS_DEVICES is ON.
+ }
+
+ count+=bootData->LegacyDevCount;
+ }
+ else {
+ if(value == count)
+ {
+ if(TseBootNowInBootOrde)
+ MemFreePointer((VOID **) &BootOrder);
+ return BootGetOptionStatus(bootData, FromSetup);//EIP: 51671 Getting the Boot option status when SETUP_SHOW_ALL_BBS_DEVICES is ON.
+ }
+ count++;
+ }
+ }
+ return FALSE;
+ }
+ else {
+ bootData = BootGetBootData(BootOrder[value]);
+ MemFreePointer((VOID **) &BootOrder);
+ if(BBSValidDevicePath(bootData->DevicePath) )
+ return BootGetBBSOptionStatus(bootData, 0, FromSetup,ShowAllBBSDev);
+ else
+ return BootGetOptionStatus(bootData, FromSetup);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetOptionStatus
+//
+// Description: Function to check the boot option status in Boot Order
+//
+// Input: BOOT_DATA *bootData, BOOLEAN FromSetup
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN BootGetOptionStatus(BOOT_DATA *bootData, BOOLEAN FromSetup)
+{
+ UINTN size = 0;
+ UINTN i=0;
+ UINT16 *buffer = NULL;
+
+ if(0 == FromSetup)
+ {
+ if(bootData->Active & LOAD_OPTION_ACTIVE)
+ return FALSE;
+ else
+ return TRUE;
+
+ }
+
+ buffer = EfiLibAllocateZeroPool( gBootOptionCount * sizeof(UINT16));
+ buffer = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ if (NULL == buffer)
+ {
+ return TRUE;
+ }
+
+ for(i=0 ; i<gBootOptionCount ; i++)
+ {
+ if(buffer[i] == bootData->Option)
+ break;
+ }
+ if(i == gBootOptionCount )
+ {
+ MemFreePointer((VOID **) &buffer);
+ return TRUE;
+ }
+ else
+ {
+ MemFreePointer((VOID **) &buffer);
+ return FALSE;
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootGetBBSOptionStatus
+//
+// Description: Function to check the Legacy boot option status
+//
+// Input: BOOT_DATA *bootData, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev
+//
+// Output:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN BootGetBBSOptionStatus(BOOT_DATA *bootData, UINT16 value, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev)
+{
+ UINT32 offset=0;
+ UINT32 i;
+ UINT8 *pDevOrder;
+ BBS_ORDER_TABLE *pDev;
+ UINTN size = 0;
+ UINT16 *buf = NULL, *Tempbuf = NULL;
+
+ if(0 == FromSetup)
+ {
+ if(!BootGetOptionStatus(bootData, FromSetup))
+ {
+ offset = (UINT16)bootData->LegacyEntryOffset;
+
+ pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size);
+
+ pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset);
+
+ if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011
+ return TRUE;
+
+ if(DISABLED_BOOT_OPTION == pDev->Data[value])
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return TRUE;
+ }
+ else
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return FALSE;
+ }
+ }
+ else
+ return TRUE;
+ }
+ if(!BootGetOptionStatus(bootData, FromSetup))
+ {
+
+ size=0;
+ offset = (UINT16)bootData->LegacyEntryOffset;
+ pDevOrder = HelperGetVariable(VARIABLE_ID_BBS_ORDER,L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size);
+ if (NULL == pDevOrder)
+ {
+ return TRUE;
+ }
+
+ pDev = (BBS_ORDER_TABLE *)(pDevOrder + offset);
+
+ if ( (pDev->Length >= size) || (0 == pDev->Length) ) //EIP-120011
+ return TRUE;
+
+ if(!ShowAllBBSDev)
+ {
+ if(DISABLED_BOOT_OPTION == pDev->Data[value])
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return TRUE;
+ }
+ else
+ {
+ MemFreePointer((VOID **) &pDevOrder);
+ return FALSE;
+ }
+ }
+
+ buf = EfiLibAllocateZeroPool( pDev->Length - sizeof(UINT16));
+
+ if (NULL == buf) //EIP117338
+ {
+ return FALSE;
+ }
+
+ Tempbuf = buf;
+ MemCopy( buf, &pDev->Data, pDev->Length - sizeof(UINT16) );
+
+ for(i=0; i < bootData->LegacyDevCount ;i++)
+ {
+ if(*buf == bootData->OrderList[value].Index)
+ break;
+ buf++;
+ }
+
+ MemFreePointer((VOID **) &pDevOrder); //EIP117338
+ MemFreePointer((VOID **) &Tempbuf);
+
+ if(i == bootData->LegacyDevCount)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ return TRUE;
+}
+//EIP: 51671 END
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadOptionhidden
+//
+// Description: Function to check the Boot option status if gLoadOptionhidden token is Enabled
+//
+// Input: UINT16 value
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN LoadOptionhidden (UINT16 value, BOOLEAN Option)
+{
+ if (BOOT_ORDER_OPTION == Option)
+ {
+ if (gBootData [value].Active & LOAD_OPTION_HIDDEN)
+ return TRUE;
+ }
+ else if (DRIVER_ORDER_OPTION == Option) //EIP70421 & 70422
+ {
+ if (gDriverData [value].Active & LOAD_OPTION_HIDDEN)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckHiddenforBootDriverOption
+//
+// Description: Check whether the Boot/Driver option has hidden property
+//
+// Input: UINT16, BOOLEAN
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckHiddenforBootDriverOption (UINT16 Option, BOOLEAN HiddenOption)
+{
+ UINTN i = 0;
+ if (gLoadOptionHidden)
+ {
+ if (BOOT_ORDER_OPTION == HiddenOption)
+ {
+ for (i = 0 ;i < gBootOptionCount ;i++)
+ {
+ if (gBootData [i].Option == Option)
+ {
+ if (gBootData [i].Active & LOAD_OPTION_HIDDEN)
+ {
+ return TRUE;
+ }
+ break;
+ }
+ }
+ }
+ else if (DRIVER_ORDER_OPTION == HiddenOption)
+ {
+ for (i = 0 ;i < gDriverOptionCount ;i++)
+ {
+ if (gDriverData [i].Option == Option)
+ {
+ if (gDriverData [i].Active & LOAD_OPTION_HIDDEN)
+ {
+ return TRUE;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+//EIP: 62631 Start
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------------
+// Procedure: CheckBootOptionMatch
+//
+// Description: Checks the input boot option matches with any of the boot option in the system
+//
+// Input: UINT16 = Boot option to which match to be find
+//
+// Output: UINT32 = Returns 0 if no match found
+// = 32 bit CRC value of boot option if match found
+//
+//------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 CheckBootOptionMatch (UINT16 BootOption)
+{
+ UINTN iIndex = 0;
+ CHAR16 BootOptionName [9]; //Bootxxxx + 1 NULL char
+ UINT32 *LoadOptions = NULL; //Using 32 bit ptr bcoz to find CRC32
+ UINTN LoadOptionSize = 0;
+ UINT32 CRC32 = 0;
+
+ SPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04X", BootOption);
+ LoadOptions = VarGetNvramName (BootOptionName, &gEfiGlobalVariableGuid, NULL, &LoadOptionSize); //Getting boot options
+ if ((NULL == LoadOptions) || (0 == LoadOptionSize))
+ {
+ return CRC32; //returning 0
+ }
+ gBS->CalculateCrc32 ((UINT8 *)LoadOptions, LoadOptionSize, &CRC32);
+ return CRC32;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------------------
+// Procedure: SetBootOptionSupportVariable
+//
+// Description: Function to set the BootOptionSupport variable
+//
+// Input: UINT32 = Capabilities for the BootOptionSupport variable
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetBootOptionSupportVariable (UINT32 BootManCapabilities)
+{
+ CHAR16 VariableName [] = L"BootOptionSupport";
+ UINT32 Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
+ UINTN DataSize = 0;
+ VOID *Data;
+ UINT32 SetData = 0;
+
+ Data = VarGetNvramName (VariableName, &gEfiGlobalVariableGuid, &Attributes, &DataSize); //If the variable exists use its attribute to set it
+ if (NULL != Data)
+ {
+ SetData = *((UINT32 *)Data);
+ }
+ SetData |= BootManCapabilities;
+ DataSize = sizeof (UINT32); //Sizeof BootOptionSupport variable is UINT32
+ VarSetNvramName (VariableName, &gEfiGlobalVariableGuid, Attributes, (VOID *)&SetData, DataSize);
+}
+//EIP: 62631 End
+
+//EIP 64295 Start
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------------------
+// Procedure: CheckDevSupShortFormPath
+//
+// Description: Matches the device path with USB class device path (Table 60) and returns
+// the corresponding USB's file system handle
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL * -> Device path for the boot option
+//
+// Output: EFI_HANDLE -> Handle for the file system
+//
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_HANDLE CheckDevSupShortFormPath (EFI_DEVICE_PATH_PROTOCOL *DevicePath)
+{
+ UINTN NumHandles = 0;
+ UINTN iIndex = 0;
+ CHAR16 *USBString = NULL;
+ CHAR16 *USBDevPathString = NULL;
+ UINT16 *LangIDTable;
+ UINT16 TableSize = 0;
+ EFI_STATUS Status;
+ EFI_HANDLE *UsbIoHandles = NULL;
+ EFI_USB_IO_PROTOCOL *UsbIoProtocolInstance = NULL;
+ EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
+ USB_CLASS_DEVICE_PATH *UsbClassDevPath = NULL;
+ USB_WWID_DEVICE_PATH *UsbWwidDevPath = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevPath = DevicePath;
+
+ if ((MESSAGING_DEVICE_PATH == TempDevPath->Type) && (MSG_USB_CLASS_DP == TempDevPath->SubType)) //Check for USB Device Path Class. type = 3 and subtype = 0xf
+ {
+ UsbClassDevPath = (USB_CLASS_DEVICE_PATH *)TempDevPath;
+ }
+ else if ((MESSAGING_DEVICE_PATH == TempDevPath->Type) && (MSG_USB_WWID_CLASS_DP == TempDevPath->SubType))
+ {
+ UsbWwidDevPath = (USB_WWID_DEVICE_PATH *)TempDevPath;
+ USBDevPathString = (CHAR16 *)((UINT8 *)UsbWwidDevPath + sizeof (USB_WWID_DEVICE_PATH)); //String will be present at the end of the WWID device path
+ }
+ else
+ {
+ return NULL;
+ }
+ Status = gBS->LocateHandleBuffer ( //To match with USB Device Path Class
+ ByProtocol,
+ &gEfiUsbIoProtocolGuid,
+ NULL,
+ &NumHandles,
+ &UsbIoHandles
+ );
+ if (EFI_ERROR (Status))
+ {
+ return NULL;
+ }
+ for (iIndex = 0; iIndex < NumHandles; iIndex ++)
+ {
+ Status = gBS->HandleProtocol (UsbIoHandles [iIndex], &gEfiUsbIoProtocolGuid, &UsbIoProtocolInstance);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ Status = UsbIoProtocolInstance->UsbGetDeviceDescriptor (UsbIoProtocolInstance, &DeviceDescriptor);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ if (UsbWwidDevPath)
+ {
+ Status = UsbIoProtocolInstance->UsbGetSupportedLanguages (UsbIoProtocolInstance, &LangIDTable, &TableSize);
+ if (!EFI_ERROR (Status) && TableSize)
+ {
+ Status = UsbIoProtocolInstance->UsbGetStringDescriptor (UsbIoProtocolInstance, LangIDTable [0], DeviceDescriptor.StrSerialNumber, &USBString); //LangIDTable [0], getting default as English
+ if (EFI_ERROR (Status))
+ {
+ USBString = NULL; //Explicitly making as NULL
+ }
+ }
+ if ((NULL != USBString) ^ (0 != EfiStrLen (USBDevPathString))) //If serial number string present in device path and not in descriptor then try for other device and vice versa too
+ { //If device path and descriptor not has the string then proceed
+ continue;
+ }
+ }
+ if (UsbClassDevPath?
+ ( //Check for USB Class device path
+ ((UsbClassDevPath->VendorId == DeviceDescriptor.IdVendor) || (0xFFFF == UsbClassDevPath->VendorId)) && //If values are 0xF's then dont consider that option
+ ((UsbClassDevPath->ProductId == DeviceDescriptor.IdProduct) || (0xFFFF == UsbClassDevPath->ProductId)) &&
+ ((UsbClassDevPath->DeviceClass == DeviceDescriptor.DeviceClass) || (0xFF == UsbClassDevPath->DeviceClass)) &&
+ ((UsbClassDevPath->DeviceSubClass == DeviceDescriptor.DeviceSubClass) || (0xFF == UsbClassDevPath->DeviceSubClass)) &&
+ ((UsbClassDevPath->DeviceProtocol == DeviceDescriptor.DeviceProtocol) || (0xFF == UsbClassDevPath->DeviceProtocol))
+ ):
+ ( //Check for USB WWID device path
+ (UsbWwidDevPath->VendorId == DeviceDescriptor.IdVendor) &&
+ (UsbWwidDevPath->ProductId == DeviceDescriptor.IdProduct) &&
+ (USBString ? (!(EfiStrCmp (USBDevPathString, USBString))):1) //String number of USB might not be filled in some case in such conditions will take it as TRUE
+ )
+ )
+ {
+ UINTN Count;
+ EFI_GUID **ppGuid;
+ UINTN jIndex = 0;
+ UINTN kIndex = 0;
+
+ Status = gBS->ProtocolsPerHandle (UsbIoHandles [iIndex], &ppGuid, &Count);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ for (jIndex = 0; jIndex < Count; jIndex ++)
+ {
+ if (!guidcmp (ppGuid [jIndex], &gEfiDiskIoProtocolGuid))
+ {
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *pInfo;
+ UINTN InfoCount = 0;
+ VOID *FilsSystemInstance = NULL;
+ EFI_HANDLE handle = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath = NULL;
+
+ Status = gBS->OpenProtocolInformation (UsbIoHandles [iIndex], ppGuid [jIndex], &pInfo, &InfoCount);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ for (kIndex = 0; kIndex < InfoCount; kIndex ++)
+ {
+ Status = gBS->HandleProtocol (pInfo [kIndex].ControllerHandle, &gEfiSimpleFileSystemProtocolGuid, &FilsSystemInstance);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ FilePath = EfiFileDevicePath (pInfo [kIndex].ControllerHandle, gBootFileName);
+ if (FilePath)
+ {
+ Status = gBS->LoadImage ( //Ensuring the image can load
+ TRUE,
+ gImageHandle,
+ FilePath,
+ NULL,
+ 0,
+ &handle
+ );
+ MemFreePointer((VOID **) &FilePath);
+ if (!EFI_ERROR (Status))
+ {
+ if (USBString)
+ {
+ MemFreePointer ((VOID **)&USBString);
+ }
+ MemFreePointer ((VOID **)&UsbIoHandles);
+ return pInfo [kIndex].ControllerHandle;
+ }
+
+ }
+ }
+ if (InfoCount)
+ {
+ MemFreePointer ((VOID **)&pInfo);
+ }
+ }
+ }
+ }
+ if (USBString)
+ {
+ MemFreePointer ((VOID **)&USBString);
+ }
+ }
+ MemFreePointer ((VOID **)&UsbIoHandles);
+ return NULL;
+}
+//EIP 64295 End
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/box.c b/EDK/MiniSetup/BootOnly/box.c
new file mode 100644
index 0000000..535995e
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/box.c
@@ -0,0 +1,241 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.c $
+//
+// 5 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 12/10/09 2:59p Presannar
+// Modified DrawBorder fn to check if Width or Height is zero. This is a
+// solution to address EiP - 32242
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawLineWithAttribute
+//
+// Description: function to draw the lines with attributes
+//
+// Input: UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib )
+{
+ UINTN Index;
+ CHAR16 *Line;
+
+ Line = EfiLibAllocatePool( sizeof(CHAR16) * (Length + 1) );
+ if ( Line == NULL )
+ return;
+
+ for ( Index = 0; Index < Length; Index++ )
+ Line[Index] = Type;
+
+ Line[Index] = 0;
+
+ DrawStringWithAttribute( Col, Row, Line, Attrib );
+
+ MemFreePointer( (VOID **)&Line );
+}
+
+VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type )
+{
+ DrawLineWithAttribute( Col, Row, Length, Type, 0 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBorder
+//
+// Description: function to draw the border
+//
+// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height )
+{
+ UINTN Index;
+ CHAR16 *Line;
+ UINTN Right, Bottom;
+
+ if( Width == 0 || Height == 0 )
+ return;
+
+ Line = EfiLibAllocateZeroPool( (Width + 6) * sizeof(CHAR16) );
+ if ( Line == NULL )
+ return;
+
+ Right = Left + Width - 1;
+ Bottom = Top + Height - 1;
+
+ for ( Index = 1; Index < Width - 1; Index++ )
+ Line[Index] = BOXDRAW_HORIZONTAL;
+
+ Line[0] = BOXDRAW_DOWN_RIGHT;
+ Line[Index] = BOXDRAW_DOWN_LEFT;
+ DrawString( Left, Top, Line );
+ Line[0] = BOXDRAW_UP_RIGHT;
+ Line[Index] = BOXDRAW_UP_LEFT;
+ DrawString( Left, Bottom, Line );
+
+ Line[0] = BOXDRAW_VERTICAL;
+ Line[1] = 0;
+
+ for ( Index = Top + 1; Index < Bottom; Index++ )
+ {
+ DrawString( Left, Index, Line );
+ DrawString( Right, Index, Line );
+ }
+
+ MemFreePointer( (VOID **)&Line );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawWindow
+//
+// Description: function to draw a window
+//
+// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height,
+// UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow )
+{
+ if ( Shadow )
+ DrawBox( Left + 2, Top + 1, Width, Height, 0 );
+
+ DrawBox( Left, Top, Width, Height, Attrib );
+
+ if ( Border )
+ DrawBorder( Left, Top, Width, Height );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBox
+//
+// Description: function to draw a box
+//
+// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib )
+{
+ UINTN Bottom, Right;
+ UINTN Index;
+ UINTN Offset;
+ CHAR16 WindowLine[MAX_COLS];
+ UINT8 AttribLine[MAX_COLS];
+
+ Bottom = Top + Height;
+ if ( Bottom >= gMaxRows )
+ {
+ Bottom = gMaxRows - 1;
+ Height = Bottom - Top;
+ }
+
+ Right = Left + Width;
+ if ( Right >= gMaxCols )
+ {
+ Right = gMaxCols - 1;
+ Width = Right - Left;
+ }
+
+ MemSet( AttribLine, Width, Attrib );
+ for ( Index = 0; Index < Width; Index++ )
+ WindowLine[Index] = L' ';
+
+ Offset = Top * gMaxCols + Left;
+ for ( Index = Top; Index < Bottom; Index++, Offset += gMaxCols )
+ {
+ // to resolve the wide char corruption when box is drawn
+ if((Left) && ( IsCharWide( gFlushBuffer->Chars[Offset-1]) == TRUE ))
+ gActiveBuffer->Chars[Offset-1]=L' ';
+
+ MemCopy( &gActiveBuffer->Chars[Offset], WindowLine, sizeof(CHAR16) * Width );
+ MemCopy( &gActiveBuffer->Attribs[Offset], AttribLine, Width );
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/box.h b/EDK/MiniSetup/BootOnly/box.h
new file mode 100644
index 0000000..559fb6a
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/box.h
@@ -0,0 +1,95 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/box.h $
+//
+// 4 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Box.h
+//
+// Description: Header file for box related functions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _BOX_H_
+#define _BOX_H_
+
+VOID DrawLine( UINTN Col, UINTN Rown, UINTN Length, CHAR16 Type );
+VOID DrawLineWithAttribute( UINTN Col, UINTN Rown, UINTN Length, CHAR16 Type, UINT8 Attrib );
+VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height );
+VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow );
+VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib );
+#endif /* _BOX_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/buffer.c b/EDK/MiniSetup/BootOnly/buffer.c
new file mode 100644
index 0000000..e49203a
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/buffer.c
@@ -0,0 +1,501 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 10 $
+//
+// $Date: 3/18/13 2:40a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.c $
+//
+// 10 3/18/13 2:40a Arunsb
+// [TAG] EIP116669
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse shadow can't refresh when switch Multi languages
+// under BIOS Setup.
+// [RootCause] Mouse not stopped when mouse pointer is at the top(0 row)
+// of the screen.
+// [Solution] Mouse stopped properly in all the position.
+// [Files] buffer.c
+//
+// 9 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 1/18/12 4:55a Rajashakerg
+// [TAG] EIP79962
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse pointer corruption in GTSE
+// [RootCause] For GTSE, the cordanites comparison logic went wrong for
+// stopping the mouse pointer when it is present while
+// updating the screen buffer.
+// [Solution] Corrected the logic to stop the mouse when mouse pointer
+// is present on screen we are updating.
+// [Files] buffer.c, CommonHelper.c, Mouse.c
+//
+// 7 11/30/11 11:24a Premkumara
+// [TAG] EIP67695
+// [Category] Improvement
+// [Description] No cursor visible in setup, while editing text input
+// box
+// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c
+//
+// 6 11/20/11 7:02a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 5 9/27/10 7:48a Mallikarjunanv
+// EIP 40555 : To avoid Compilation issues with Fareast Windows.
+//
+// 4 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 9 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 8 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 7 10/28/09 5:36p Madhans
+// To undo the changes.
+//
+// 6 9/29/09 5:51p Madhans
+// Added more comment.
+//
+// 5 9/15/09 9:27a Sudhirv
+// added a flag for FlushPause
+//
+// 4 8/17/09 4:31a Mallikarjunanv
+// EIP:24991 - updated the DoRealFlush lines function with the changes
+// suggested by Murase
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Buffer.c
+//
+// Description: This file contains code to manage buffers
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+VOID GetCoordinates(INT32 *x, INT32 *y, INT32 *z);
+INT32 GetactualScreentop(VOID);
+BOOLEAN IsMouseSupported(VOID);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitializeScreenBuffer
+//
+// Description: function to initialize the screen buffer
+//
+// Input: UINT8 attrib
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitializeScreenBuffer( UINT8 attrib )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ MemFreePointer( (VOID **)&gFlushBuffer );
+ gFlushBuffer = EfiLibAllocateZeroPool( sizeof(SCREEN_BUFFER) );
+ if ( gFlushBuffer == NULL )
+ return Status;
+
+ MemFreePointer( (VOID **)&gActiveBuffer );
+ gActiveBuffer = EfiLibAllocatePool( sizeof(SCREEN_BUFFER) );
+ if ( gActiveBuffer != NULL )
+ {
+ ClearScreenWithoutFlush( attrib );
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SlowFlushLines
+//
+// Description: function to slow flush lines
+//
+// Input: UINTN Top, UINTN Bottom
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SlowFlushLines( UINTN Top, UINTN Bottom )
+{
+ UINTN Index;
+ UINTN Offset = Top * gMaxCols;
+ UINTN End = (Bottom - Top + 1) * gMaxCols + Offset;
+ UINT8 LastAttrib = 0xFF;
+ CHAR16 String[2] = { 0, 0 };
+
+ gST->ConOut->SetCursorPosition( gST->ConOut, 0, Top );
+ for ( Index = Offset; Index < End; Index++ )
+ {
+ if ( gActiveBuffer->Attribs[Index] != LastAttrib )
+ {
+ LastAttrib = gActiveBuffer->Attribs[Index];
+ gST->ConOut->SetAttribute( gST->ConOut, LastAttrib );
+ }
+ *String = gActiveBuffer->Chars[Index];
+
+ gST->ConOut->OutputString( gST->ConOut, String );
+ }
+}
+
+#define INVALID_FLUSH_LINE 0xFFFF
+UINTN FlushTop=INVALID_FLUSH_LINE;
+UINTN FlushBottom=INVALID_FLUSH_LINE;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FlushLines
+//
+// Description: function to set the positions for flush lines
+//
+// Input: UINTN Top, UINTN Bottom
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FlushLines( UINTN Top, UINTN Bottom )
+{
+ if( FlushTop==INVALID_FLUSH_LINE)
+ FlushTop = Top;
+
+ if(FlushBottom==INVALID_FLUSH_LINE)
+ FlushBottom = Bottom;
+
+ if(FlushTop>Top)
+ FlushTop = Top;
+
+ if(FlushBottom < Bottom)
+ FlushBottom = Bottom;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoRealFlushLines
+//
+// Description: function to flush lines
+//
+// Input: NIL
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoRealFlushLines()
+{
+ UINTN Index;
+ UINTN ByteStart, ByteEnd;
+ UINTN Offset = 0;
+ UINTN End = 0;
+ UINT8 LastAttrib,LastSetAttrib=0;
+ CHAR16 *String;
+ UINTN X=0,Y=0,TempOffSet,PrintLen;
+ UINTN CurrentX=0;
+ BOOLEAN FlushIt;
+ UINTN Top, Bottom;
+ UINT32 MousePointerX=0,MousePointerY=0,MousePointerZ=0;//EIP 62763 : Mouse poiner declaration
+
+ if( (FlushTop==INVALID_FLUSH_LINE) || (FlushBottom==INVALID_FLUSH_LINE))
+ return;
+
+ if(gST->ConOut == NULL)
+ return;
+ Top = FlushTop;
+ Bottom = FlushBottom;
+
+ if ( Top >= gMaxRows )
+ return;
+
+ if ( Top > Bottom )
+ {
+ UINTN Swap = Bottom;
+ Bottom = Top;
+ Top = Swap;
+ }
+
+ if ( Bottom >= gMaxRows )
+ Bottom = gMaxRows - 1;
+
+ ByteStart = Top * gMaxCols;
+ ByteEnd = (Bottom - Top + 1) * gMaxCols + ByteStart;
+
+ String = EfiLibAllocateZeroPool( (gMaxCols + 1) * sizeof(CHAR16) );
+
+ if ( String == NULL )
+ {
+ SlowFlushLines( Top, Bottom );
+ return;
+ }
+
+ // Flush from Top to Bottom
+ // inside the loop 'Top' refers current line
+ for ( ; Top <= Bottom; Top++ )
+ {
+ Offset = Top * gMaxCols;
+ End = Offset + gMaxCols;
+
+ // If All the Chars and attributes are equal in current line. Go to next line.
+ if ( ( ! EfiCompareMem( &gActiveBuffer->Attribs[Offset], &gFlushBuffer->Attribs[Offset], gMaxCols ) ) &&
+ ( ! EfiCompareMem( &gActiveBuffer->Chars[Offset], &gFlushBuffer->Chars[Offset], gMaxCols * sizeof(CHAR16) ) ) )
+ continue;
+
+ // Don't Print the last char in MaxRow X MaxCol
+ // As it will scroll if we print.
+ if ( End >= gMaxRows * gMaxCols )
+ End = gMaxRows * gMaxCols - 1;
+
+ // Attribute for current print.
+ LastAttrib = gActiveBuffer->Attribs[Offset];
+
+ // To improve the flush lines code.
+ CurrentX=0;
+
+ // To support Terminal host with hight resolution.(EIP-25288)
+ gST->ConOut->EnableCursor(gST->ConOut, FALSE); //EIP:67695-Make the cursor invisible since the cursor position is changing and visible outside popup box
+ gST->ConOut->SetCursorPosition( gST->ConOut, CurrentX, Top );
+
+ PrintLen = 0;
+ FlushIt = TRUE; // decides printing
+
+ if(IsMouseSupported())
+ GetCoordinates(&MousePointerX, &MousePointerY, &MousePointerZ);
+
+ while ( Offset < End )
+ {
+ // Collect the string till the Attribute is differnt as it may need setAttribute
+ for ( Index = 0, TempOffSet = Offset; (gActiveBuffer->Attribs[Offset] == LastAttrib) && (Offset < End); Offset++, Index++ )
+ {
+ String[Index] = gActiveBuffer->Chars[Offset];
+
+ if(TRUE == IsCharWide(String[Index]))
+ Offset++;
+
+ }
+ String[Index] = 0;
+//EIP 79962 : Getting the actual Screen top from the binary for stopping the mouse
+ if(
+ (IsMouseSupported() &&
+ ((0 == Top) || (((MousePointerY/HiiGetGlyphHeight()) >= ((Top + ( GetactualScreentop()/ HiiGetGlyphHeight()))-1)) && ( (MousePointerY/HiiGetGlyphHeight()) <= ((Top + (GetactualScreentop()/ HiiGetGlyphHeight()))+1)))) )
+ ) //EIP116669
+ {
+ MouseStop();
+ }
+
+ // We are trying to print the strings with 'LastAttrib'
+ // NOW - TempOffSet refers begining of the buffer
+ // Offset refers end if the print buffer for currnet print.
+
+ // if the String and attribute are equal to flush lines and it is more then 10 then we don't need to Print.
+ // The reason for 10 is to avoid sending setposition. IF we skip less then 10 then we will end up calling setposition that takes 9 bytes
+ // for serial redirection.
+ if(((Offset-TempOffSet)>10)&&
+ ( ! EfiCompareMem( &gActiveBuffer->Attribs[TempOffSet], &gFlushBuffer->Attribs[TempOffSet], Offset-TempOffSet ) ))
+ {
+ // If all the charecters are same between active and flush buffer, let not print it
+ if ( ( ! EfiCompareMem( &gActiveBuffer->Chars[TempOffSet], &gFlushBuffer->Chars[TempOffSet], (Offset-TempOffSet) * sizeof(CHAR16) ) ) )
+ FlushIt = FALSE;
+ else
+ {
+ UINTN i,j=0;
+ UINTN FirstDiff, LastDiff;
+ FirstDiff = LastDiff = (Offset-TempOffSet); // Fail case default
+
+ // loop to find out that is the first and last different offset in the printable string.
+ for(i=0,j=0; i<(Offset-TempOffSet);i++,j++)
+ {
+ if(gActiveBuffer->Chars[TempOffSet+i] != gFlushBuffer->Chars[TempOffSet+i])
+ {
+ if(FirstDiff>i) // First Diff set
+ FirstDiff = i;
+ LastDiff = i;
+ Index = j;
+ }
+ if(TRUE == IsCharWide(String[j]))
+ i++;
+ }
+
+//EIP:24991 - START
+ // Modification to erase wide characters correctly.
+ // Issue:
+ // If we write "a" over some wide character, the right half of the wide character is sometimes not erased.
+ // e.g.)
+ // When we write "aaaa " over "aaa? ", the right half of "?" is not erased.
+ if (!IsCharWide(String[Index]) && IsCharWide(gFlushBuffer->Chars[TempOffSet + LastDiff]) && LastDiff+1<Offset-TempOffSet){
+ LastDiff++;
+ Index++;
+ }else if (IsCharWide(String[Index]) && IsCharWide(gFlushBuffer->Chars[TempOffSet + LastDiff + 1]) && LastDiff+2<Offset-TempOffSet){
+ LastDiff += 2;
+ Index++;
+ }
+//EIP:24991 - End
+ if(FirstDiff>10) // Is it worth skiping?
+ {
+ Offset = TempOffSet+FirstDiff;
+ String[Index] = 0; // No need. But lets do it anyway
+ FlushIt = FALSE;
+ }
+ else if(((Offset-TempOffSet)- LastDiff) > 10) // Only print the Different sting up to LastDiff
+ {
+//EIP:24991 - START
+ // Make the offset to point to next char to be printed for next iteration
+ Offset = TempOffSet+LastDiff+1;
+ if(TRUE == IsCharWide(String[Index]))
+ Offset++;
+//EIP:24991 - END
+ String[Index+1] = 0;
+ }
+ }
+ }
+
+ if(FlushIt)
+ {
+ // Set of it is different from previous setatribute.
+ if(LastSetAttrib!=LastAttrib)
+ {
+ gST->ConOut->SetAttribute( gST->ConOut, LastAttrib );
+ LastSetAttrib = LastAttrib;
+ }
+ //do the set position if the cursor is not at expected loc.
+ if(((X+PrintLen) != CurrentX) || (Y != Top) || ((CurrentX == 0) && (Top==0)))
+ {
+ gST->ConOut->SetCursorPosition( gST->ConOut, CurrentX, Top );
+ }
+
+ X=CurrentX;
+ Y=Top;
+
+ gST->ConOut->OutputString( gST->ConOut, String );
+ PrintLen = Offset-TempOffSet;
+
+ // if we print till end of line then increament the y and make x=0.
+ if((X+PrintLen)>=gMaxCols)
+ {
+ Y++;X=0;
+ }
+ }
+
+ CurrentX += Offset-TempOffSet;
+ FlushIt = TRUE;
+ LastAttrib = gActiveBuffer->Attribs[Offset];
+ }
+ }
+
+ MemCopy( &gFlushBuffer->Attribs[ByteStart], &gActiveBuffer->Attribs[ByteStart], ByteEnd - ByteStart );
+ MemCopy( &gFlushBuffer->Chars[ByteStart], &gActiveBuffer->Chars[ByteStart], (ByteEnd - ByteStart) * sizeof(CHAR16) );
+ FlushTop=INVALID_FLUSH_LINE;
+ FlushBottom=INVALID_FLUSH_LINE;
+ MemFreePointer( (VOID **)&String );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetDesiredTextMode
+//
+// Description: function to set the test mode
+//
+// Input: nil
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void SetDesiredTextMode()
+{
+ EFI_STATUS Status;
+
+ if(gST->ConOut==NULL)
+ return;
+ Status = gST->ConOut->Reset( gST->ConOut, FALSE );
+ Status = gST->ConOut->SetMode( gST->ConOut, StyleGetTextMode( gMaxRows, gMaxCols ) );
+
+ if ( EFI_ERROR( Status ) )
+ {
+ gMaxRows = StyleGetStdMaxRows();
+ gMaxCols = StyleGetStdMaxCols();
+ gST->ConOut->SetMode( gST->ConOut, 0 );
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/buffer.h b/EDK/MiniSetup/BootOnly/buffer.h
new file mode 100644
index 0000000..1fa054d
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/buffer.h
@@ -0,0 +1,95 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/buffer.h $
+//
+// 4 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Buffer.h
+//
+// Description: Header file for code to manage buffers
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _BUFFER_H_
+#define _BUFFER_H_
+
+VOID FlushLines( UINTN Top, UINTN Bottom );
+VOID DoRealFlushLines();
+
+#endif /* _BUFFER_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/dobmpmgr.c b/EDK/MiniSetup/BootOnly/dobmpmgr.c
new file mode 100644
index 0000000..076649b
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/dobmpmgr.c
@@ -0,0 +1,301 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/dobmpmgr.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 13 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/dobmpmgr.c $
+//
+// 13 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 11 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 9 8/29/12 12:38p Arunsb
+// [TAG] EIP93521
+// [Category] New Feature
+// [Description] Support of ESRT
+// [Files] amitse.sdl, bootflow.c, bootflow.h, commonhelper.c and
+// dobmpmgr.c
+//
+// 8 8/23/12 6:24p Arunsb
+// Reverted back 2.15.1229 for making GTSE, TSELite and BootOnly labels
+//
+// 7 8/21/12 7:57p Arunsb
+// [TAG] EIP93521, EIP92901 and EIP92900
+// [Category] New Feature
+// [Description] Support of ESRT
+// [Files] amitse.sdl, bootflow.c, bootflow.h, commonhelper.c and
+// dobmpmgr.c
+//
+// 6 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 9/02/09 7:40p Madhans
+// To Realy fix the Logo Security issue
+//
+// 5 8/13/09 12:14p Blaines
+// Move Image support to binary module
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: DoBMPmgr.c
+//
+// Description: file contains code that is taken from graphics.c
+// to eliminnate library dependancy
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+//#if SETUP_BMP_LOGO_SUPPORT
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemFreePointer
+//
+// Description: Convert a *.BMP graphics image to a UGA blt buffer.
+// If a NULL UgaBlt buffer is passed in a UgaBlt buffer will
+// be allocated by this routine. If a UgaBlt buffer is passed
+// in it will be used if it is big enough.
+//
+// Input: BmpImage - Pointer to BMP file
+// BmpImageSize - Number of bytes in BmpImage
+// UgaBlt - Buffer containing UGA version of BmpImage.
+// UgaBltSize - Size of UgaBlt in bytes.
+// PixelHeight - Height of UgaBlt/BmpImage in pixels
+// PixelWidth - Width of UgaBlt/BmpImage in pixels
+//
+// Output: EFI_SUCCESS - UgaBlt and UgaBltSize are returned.
+// EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
+// EFI_BUFFER_TOO_SMALL - The passed in UgaBlt buffer is not big enough.
+// UgaBltSize will contain the required size.
+// EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+ConvertBmpToUgaBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth
+ )
+{
+ UINT8 *Image;
+ BMP_IMAGE_HEADER *BmpHeader;
+ BMP_COLOR_MAP *BmpColorMap;
+ EFI_UGA_PIXEL *BltBuffer;
+ EFI_UGA_PIXEL *Blt;
+ UINT64 BltBufferSize;
+ UINTN Index;
+ UINTN Height;
+ UINTN Width;
+ UINTN ImageIndex;
+
+ BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
+ if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M')
+ return EFI_UNSUPPORTED;
+
+ if (BmpHeader->CompressionType != 0)
+ return EFI_UNSUPPORTED;
+
+ // Calculate Color Map offset in the image.
+ Image = BmpImage;
+ BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
+
+ // Calculate graphics image data address in the image
+ Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
+
+ // Make sure to do x64 Mul
+ BltBufferSize = MultU64x32((UINT64)BmpHeader->PixelWidth ,BmpHeader->PixelHeight);
+
+ /// Check whether the Size exceeds the limit...
+ // 4GB/PIXEL_SIZE becoz we need Resolution*PIXEL_SIZE for bltbuffer
+ if ( BltBufferSize >= (FOUR_GB_LIMIT/sizeof (EFI_UGA_PIXEL))) {
+ // The buffer size extends the limitation
+ return EFI_UNSUPPORTED;
+ }
+
+ BltBufferSize = MultU64x32( BltBufferSize ,sizeof (EFI_UGA_PIXEL));
+
+ if (*UgaBlt == NULL)
+ {
+ *UgaBltSize = (UINTN)BltBufferSize;
+ *UgaBlt = EfiLibAllocatePool (*UgaBltSize);
+ if (*UgaBlt == NULL)
+ return EFI_OUT_OF_RESOURCES;
+ }
+ else
+ {
+ if (*UgaBltSize < (UINTN)BltBufferSize)
+ {
+ *UgaBltSize = (UINTN)BltBufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ *PixelWidth = BmpHeader->PixelWidth;
+ *PixelHeight = BmpHeader->PixelHeight;
+
+ // Convert image from BMP to Blt buffer format
+
+ BltBuffer = *UgaBlt;
+ for (Height = 0; Height < BmpHeader->PixelHeight; Height++)
+ {
+ Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
+ for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++)
+ {
+ switch (BmpHeader->BitPerPixel)
+ {
+ case 1: //the bitmap is monochrome //EIP93521 and EIP92900
+ //for every bit
+ for(Index = 8; Index ; Index--)
+ {
+ if(1<<(Index-1) & *Image)
+ {
+ Blt->Red = BmpColorMap[1].Red;
+ Blt->Green = BmpColorMap[1].Green;
+ Blt->Blue = BmpColorMap[1].Blue;
+ }
+ else
+ {
+ Blt->Red = BmpColorMap[0].Red;
+ Blt->Green = BmpColorMap[0].Green;
+ Blt->Blue = BmpColorMap[0].Blue;
+ }
+ if (Width < (BmpHeader->PixelWidth))
+ {
+ Blt++;
+ Width++;
+ }
+ }
+ Blt--;
+ Width--;
+ break;
+
+ case 4: // Convert BMP Palette to 24-bit color
+ Index = (*Image) >> 4;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ if (Width < (BmpHeader->PixelWidth - 1))
+ {
+ Blt++;
+ Width++;
+ Index = (*Image) & 0x0f;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ }
+ break;
+
+ case 8: // Convert BMP Palette to 24-bit color
+ Blt->Red = BmpColorMap[*Image].Red;
+ Blt->Green = BmpColorMap[*Image].Green;
+ Blt->Blue = BmpColorMap[*Image].Blue;
+ break;
+
+ case 24:
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image;
+ break;
+ case 32: //EIP93521 and EIP92901
+ {
+ if((BmpHeader->CompressionType)==0)
+ {
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image++;
+ }
+ else
+ {
+ return EFI_UNSUPPORTED;
+ }
+ }
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ };
+ }
+ ImageIndex = (UINTN) (Image - BmpHeader->ImageOffset);
+ if ((ImageIndex % 4) != 0) // Bmp Image starts each row on a 32-bit boundary!
+ Image = Image + (4 - (ImageIndex % 4));
+ }
+ return EFI_SUCCESS;
+}
+
+//#endif //SETUP_BMP_LOGO_SUPPORT
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/globals.c b/EDK/MiniSetup/BootOnly/globals.c
new file mode 100644
index 0000000..a8b39a6
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/globals.c
@@ -0,0 +1,212 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/globals.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 2/11/14 7:54p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/globals.c $
+//
+// 9 2/11/14 7:54p Arunsb
+// [TAG] EIP132360
+// [Category] Improvement
+// [Description] Verify ESA will show a form if SendForm interface is
+// called by a driver.
+// [Files] globals.c
+// EsaBin.c
+// FormBrowser2.c
+// protocol.c
+// minisetup.h
+//
+// 8 4/18/13 1:50a Arunsb
+// [TAG] EIP81490
+// [Category] New Feature
+// [Description] Post message support for BBS popup menu
+// [Files] AMITSE.sdl, AmiTSEStr.uni, commonoem.c, FakeTokens.c and
+// globals.c
+//
+// 7 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 1/24/12 4:24a Arunsb
+// [TAG] EIP81581
+// [Category] Improvement
+// [Description] Default driver order support
+// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and
+// variable.c
+//
+// 5 11/20/11 7:03a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 4 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 3 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 2/04/10 12:03p Blaines
+// EIP-28005
+//
+// Added PostManagerSetAttribute to support display of text in color.
+// Added support for handling string characters --- \n, \r.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 3:34p Madhans
+// Hii string support for UEFI 2.0 or UEFI 2.1
+//
+// 3 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: globals.c
+//
+// Description: file contains code to take care of the globals in boot only
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+PROGRESSBAR_INFO *gProgress;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+EFI_GRAPHICS_OUTPUT_PROTOCOL *gGOP = NULL;
+#else
+EFI_UGA_DRAW_PROTOCOL *gUgaDraw = NULL;
+#endif //SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+
+#ifndef STANDALONE_APPLICATION
+EFI_CONSOLE_CONTROL_PROTOCOL *gConsoleControl = NULL;
+#endif //STANDALONE_APPLICATION
+
+SCREEN_BUFFER *gActiveBuffer;
+SCREEN_BUFFER *gFlushBuffer;
+
+EFI_HANDLE gImageHandle;
+VOID* gHiiHandle;
+
+BOOLEAN gPostMsgProtocolActive = TRUE;
+BOOLEAN gSetupContextActive = FALSE;
+UINT8 gPostMgrAttribute = 0;
+
+#if 0
+// This adds no code space but allows the StrGather utility to know that these tokens are used
+STRING_TOKEN(STR_MAIN_TITLE);
+STRING_TOKEN(STR_MAIN_COPYRIGHT);
+STRING_TOKEN(STR_HELP_TITLE);
+STRING_TOKEN(STR_EVAL_MSG);
+#endif // 0
+
+UINT8 *gApplicationData;
+
+#ifdef USE_DEPRICATED_INTERFACE
+UINT8 *STRING_ARRAY_NAME;
+#endif //USE_DEPRICATED_INTERFACE
+
+NVRAM_VARIABLE *gVariableList = NULL;
+NVRAM_VARIABLE *gFailsafeDefaults = NULL;
+NVRAM_VARIABLE *gOptimalDefaults = NULL;
+
+BOOLEAN gEnterSetup = FALSE;
+BOOLEAN gEnterBoot = FALSE;
+EFI_EVENT gKeyTimer = NULL;
+EFI_EVENT gClickTimer = NULL;
+UINT32 gPasswordType = AMI_PASSWORD_NONE;
+
+UINTN gPostStatus = TSE_POST_STATUS_BEFORE_POST_SCREEN;
+
+UINTN gMaxRows = MAX_ROWS;
+UINTN gMaxCols = MAX_COLS;
+UINTN gPostManagerHandshakeCallIndex = 0;
+
+#define EFI_DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID \
+ { 0x3c4ead08, 0x45ae, 0x4315, 0x8d, 0x15, 0xa6, 0x0e, 0xaa, 0x8c, 0xaf, 0x69 }
+
+#define EFI_DEFAULT_BOOT_ORDER_VARIABLE_GUID \
+ { 0x45cf35f6, 0x0d6e, 0x4d04, 0x85, 0x6a, 0x03, 0x70, 0xa5, 0xb1, 0x6f, 0x53 }
+
+//EIP81581 Default driver order support
+#define EFI_DEFAULT_DRIVER_ORDER_VARIABLE_GUID \
+ { 0xde788bed, 0xb6e2, 0x4290, 0xbd, 0xc8, 0x2a, 0xbb, 0x65, 0xd6, 0x21, 0x78 }
+
+EFI_GUID EfiDefaultLegacyDevOrderGuid = EFI_DEFAULT_LEGACY_DEV_ORDER_VARIABLE_GUID;
+EFI_GUID EfiDefaultBootOrderGuid = EFI_DEFAULT_BOOT_ORDER_VARIABLE_GUID;
+EFI_GUID EfiDefaultDriverOrderGuid = EFI_DEFAULT_DRIVER_ORDER_VARIABLE_GUID;
+
+//Globals for Debug prints
+UINT16 gDbgPrint = TSE_DEBUG_MESSAGES;
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/EDK/MiniSetup/BootOnly/hiistring.c b/EDK/MiniSetup/BootOnly/hiistring.c
new file mode 100644
index 0000000..7fab2ae
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/hiistring.c
@@ -0,0 +1,251 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.c $
+//
+// 5 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 12/02/10 2:33p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 3 2/19/10 1:01p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 3 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 2 6/08/09 5:35p Madhans
+// Functionality moved to CommonHelper.
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 3:34p Madhans
+// Hii string support for UEFI 2.0 or UEFI 2.1
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hiistring.c
+//
+// Description: file contains code to handle the hii sting operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+#define VARIABLE_NAME_LENGTH 40
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiFindStrPrintBoundary
+//
+// Description: function to check the boundary of the print stirng.
+// Find out the index of the character from where the print boundry will be met
+//
+// Input: IN CHAR16 *String, IN UINTN PrintWidth
+//
+// Output: count
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiFindStrPrintBoundary ( IN CHAR16 *String, IN UINTN PrintWidth )
+{
+ UINTN Length = 0;
+ UINT16 Count = 0;
+ CHAR16 TempString[10];
+
+ while (String[Count]) {
+ TempString[0] = String[Count];
+ TempString[1] = 0;
+
+ if((Length + TestPrintLength(TempString) / NG_SIZE) > PrintWidth)
+ break;
+
+ Length += TestPrintLength(TempString) / NG_SIZE;
+
+ Count++;
+ }
+ return Count;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsCharWide
+//
+// Description: function to check the given character is wide
+//
+// Input: CHAR16 strWide
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN IsCharWide( CHAR16 strWide)
+{
+ UINTN Length = 0;
+ CHAR16 TempString[10];
+
+ TempString[0] = strWide;
+ TempString[1] = 0;
+ Length = 0;
+ Length = TestPrintLength( TempString ) / (NG_SIZE);
+ if(2 == Length)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+CHAR16 *HiiGetString( VOID* handle, UINT16 token )
+{
+ if(INVALID_TOKEN != token)
+ return HiiGetStringLanguage( handle, token, NULL );
+ else
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiAddString
+//
+// Description: function to add a string
+//
+// Input: VOID* handle, CHAR16 *string
+//
+// Output: token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINT16 HiiAddString( VOID* handle, CHAR16 *string )
+{
+ UINT16 token = 0;
+
+ if(ItkSupport())
+ {
+ token = HiiChangeStringLanguage( handle, 0, gLanguages[0].Unicode, string );
+ }
+ else
+ {
+ UINT16 FirstToken;
+ UINTN i, j;
+
+ FirstToken = token = HiiChangeStringLanguage( handle, 0, gLanguages[0].Unicode, string );
+ if ( token == INVALID_TOKEN )
+ return token;
+ for ( j = 0, i = 1; i < gLangCount; i++ )
+ {
+ if ( i != j )
+ token = HiiChangeStringLanguage( handle, token, gLanguages[i].Unicode, string );
+ if ( token == INVALID_TOKEN )
+ {
+ token = HiiChangeStringLanguage( handle, 0, gLanguages[i].Unicode, string );
+ if ( token == INVALID_TOKEN )
+ return FirstToken; //token;
+ j = i;
+ i = 0;
+ }
+ }
+ }
+ return token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EfiTestPrintLength
+//
+// Description: function to get the printable lenght of the string
+//
+// Input: CHAR16 *string
+//
+// Output: Size of string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN EfiTestPrintLength ( IN CHAR16 *String )
+{
+ UINTN Size;
+
+ if(String == NULL)
+ return 0;
+
+ String = (UINT16* )TseSkipEscCode(String);
+ Size = (EfiStrLen(String) * NG_SIZE);
+ gBS->FreePool( String );
+ return Size;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
diff --git a/EDK/MiniSetup/BootOnly/hiistring.h b/EDK/MiniSetup/BootOnly/hiistring.h
new file mode 100644
index 0000000..ab76d7c
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/hiistring.h
@@ -0,0 +1,153 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 8 $
+//
+// $Date: 8/28/14 5:30a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/hiistring.h $
+//
+// 8 8/28/14 5:30a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 7 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 5 2/26/10 8:53p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 8 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 7 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 1/09/10 5:13a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 1/04/10 10:40a Mallikarjunanv
+// EIPs 27161/29095 - Added support for reserved boot option names and
+// added support not to create empty boot option names
+//
+// 4 8/17/09 12:19p Presannar
+// Removed References to Tiano.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:11p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 3:34p Madhans
+// Hii string support for UEFI 2.0 or UEFI 2.1
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+// 1 9/17/08 7:57p Madhans
+// Boot Only driver after file split.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hiistring.h
+//
+// Description: Header file for code to handle the hii sting operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _AMIHIISTRING_H_ // DO NOT CHANGE THIS TO _HII_H_ !! That is used by the HII Protocol header
+#define _AMIHIISTRING_H_
+
+#ifdef TSE_FOR_APTIO_4_50
+#include "Token.h"
+#else
+#include "tokens.h"
+#endif
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+
+#define INVALID_HANDLE ((VOID*)(UINTN)-1)
+#define INVALID_TOKEN ((UINT16)-1)
+
+
+UINT16 HiiAddString( /*EFI_HII_HANDLE*/VOID* handle, CHAR16 *string );
+UINT16 HiiChangeStringLanguage( /*EFI_HII_HANDLE*/VOID * handle, UINT16 token, CHAR16 *lang, CHAR16 *string );
+CHAR16 *HiiGetStringLanguage( /*EFI_HII_HANDLE*/VOID * handle, UINT16 token, CHAR16 *lang );
+CHAR16 *GetVariableNameByID( UINT32 VariableID );
+CHAR16 *GetGUIDNameByID( UINT32 VariableID );
+
+UINTN HiiFindStrPrintBoundary ( IN CHAR16 *String, IN UINTN PrintWidth );
+UINTN IsCharWide( CHAR16 strWide);
+
+CHAR16 *SkipEscCode(CHAR16 *String);
+CHAR16 *GetLanguageVariableName();
+UINTN HiiGetGlyphWidth(VOID);
+UINTN HiiGetGlyphHeight(VOID);
+EFI_STATUS GetUnicodeCollection2Protocol(VOID **Protocol);
+EFI_STATUS GetUnicodeCollectionProtocol(VOID **Protocol);
+EFI_STATUS InitUnicodeCollectionProtocol(VOID **Protocol);
+BOOLEAN MetaiMatch(VOID *Protocol,IN CHAR16 *String,IN CHAR16 *Pattern);
+INTN StringColl(VOID *Protocol,IN CHAR16 *String1,IN CHAR16 *String2);
+
+#endif /* _AMIHIISTRING_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/logo.c b/EDK/MiniSetup/BootOnly/logo.c
new file mode 100644
index 0000000..5000447
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/logo.c
@@ -0,0 +1,1163 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/logo.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 29 $
+//
+// $Date: 12/04/13 5:22a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/logo.c $
+//
+// 29 12/04/13 5:22a Premkumara
+// [TAG] EIP123535
+// [Category] Improvement
+// [Description] Moved saving quietboot resolution to DrawQuietBootLogo()
+// to avoid setting resolution of initPostScreenthis while booting.
+// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c
+//
+// 28 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 26 9/18/12 12:50a Rajashakerg
+// [TAG] EIP95518
+// [Category] Improvement
+// [Description] Validate the Gop before usage in all the possible cases
+// and also get instance of Gop through notification
+// [Files] boot.c, notify.c, logo.c
+//
+// 25 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 23 8/29/12 4:22p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 22 5/29/12 4:25a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 21 5/25/12 1:42a Premkumara
+// [TAG] EIP88430
+// [Category] Improvement
+// [Description] Resolution set after logo displayed should retain when
+// boot to device.
+// [Files] boot.c, logo.c
+//
+// 20 4/27/12 1:46a Premkumara
+// [TAG] EIP88527
+// [Category] Improvement
+// [Description] Implement BGRT logo calculation based on Windows-8
+// [Files] CommonHelper.c, Logo.c
+//
+// 19 9/16/11 6:42a Arunsb
+// [TAG] EIP69171
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] POST Logo 1024x768 not displayed properly
+// [RootCause] Mode not set properly
+// [Solution] Mode set properly
+// [Files] BootOnly\logo.c
+//
+// 18 7/01/11 3:28a Arunsb
+// Header corrected for chm file creation
+//
+// 17 6/30/11 4:37a Arunsb
+// If Jpeg off and Bmp on, Jpeg image unsuccess to draw on the screen
+// clearing the
+// drawm bmp image.
+// Fixed this issue.
+//
+// 16 6/29/11 10:08a Arunsb
+// [TAG] EIP58954
+// [Category] Improvement
+// [Description] BGRT status field is cleared when setup key is
+// intervented for
+// setup launch while in quiet boot.
+// [Files] bootonly\logo.c and postmgmt.c
+//
+// 15 6/22/11 9:15a Premkumara
+// [TAG] EIP60048
+// [Category] Improvement
+// [Description] TSE should Change the System Resolution according to
+// the Quite Logo Size
+// [Files] CommonHelper.c, AMITSE.sdl, Logo.c, LogoLib.h
+//
+// 14 5/31/11 7:21p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Quiet boot logos only added for BGRT. BGRT status
+// field cleared if any changes happened in screen other than displaying
+// the images. BltBuffer freed in ConvertBlt2Bmp function.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 13 5/29/11 12:07p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Quiet boot logo's only added for BGRT. BGRT status
+// field cleared if any changes happened in screen other than displaying
+// the image.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 12 5/13/11 2:35p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table. Image blt formed
+// with the coordinates drawn onto the screen.
+// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c
+//
+// 11 5/04/11 5:08p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table.
+// CONTRIB_BGRT_TABLE_TO_ACPI token added. Wrapper function
+// ContribBGRTTableToAcpi added.
+// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c
+//
+// 10 5/03/11 9:53p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI
+// table.CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added.
+// [Files] Postmgmt.c, commonoem.c and commonhelper.c
+//
+// 9 4/29/11 4:43p Madhans
+// [TAG] EIP59177
+// [Category] Improvement
+// [Description] Support for JPEG with RSI markers. Fix to support logo
+// size that bigger then Screen resolution.
+// [Files] Logo.c
+// Jpeg6.c
+// commonHelper.c
+//
+// 8 4/04/11 10:30a Arunsb
+// GetGraphicsBitMapFromFV function moved to commonhelper.c
+//
+// 7 12/29/10 2:25a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP getting
+// corrupted.
+// [Solution] Updated gGop before using it in AMITSE.
+// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c
+//
+// 5 4/21/10 12:01p Madhans
+// Tse 2.02
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 1/09/10 5:14a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 12/04/09 7:13a Mallikarjunanv
+// Fix for EIP:30263 - Gif Logo Issue
+//
+// 4 8/13/09 12:14p Blaines
+// Move Image support to binary module
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 3:37p Madhans
+// Cleanup
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: logo.c
+//
+// Description: file contains code to handle the logo operations.
+// Taken from graphics.c to eliminnate library dependancy
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include "EdidActive.h"
+
+// to retrieve the frame coordinates in case different frames in a image
+UINT16 gGifSrcX=0;
+UINT16 gGifSrcY=0;
+UINT16 gGifDestX=0;
+UINT16 gGifDestY=0;
+BOOLEAN GifImageFlag = 0;
+
+#define TSE_ABS(a,b) (((a) < (b)) ? ((b) - (a)) : ((a) - (b)))
+
+extern LOGO_TYPE GetBmpLogoType(UINT8 *ImageData);
+
+extern EFI_STATUS ConvertBmpToUgaBltWrapper (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth );
+
+VOID *ConvertBlt2Bmp ();
+VOID AddImageDetailToACPI (UINT8 *, INTN, INTN, BOOLEAN);
+UINT8 gAddBgrtResolutions = 0;
+VOID SetGetBgrtCoordinates (
+ UINTN *DestX,
+ UINTN *DestY,
+ UINTN *Width,
+ UINTN *Height,
+ BOOLEAN Command
+ );
+VOID InvalidateStatusInBgrtWrapper (VOID);
+BOOLEAN IsBGRTSupported(VOID); //EIP-88527
+
+
+LOGO_TYPE GetLogoType(UINT8 *ImageData)
+{
+ if ( BMP_Logo == GetBmpLogoType(ImageData))
+ return BMP_Logo;
+
+ return Unsupported_Logo;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanUpLogo
+//
+// Description: function to Clear all the logo buffers.
+//
+// Input: nil
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanUpLogo()
+{
+ CleanUpExtendedLogoWrapper();
+ InvalidateStatusInBgrtWrapper (); //Setup key detected so clearing the status field
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetScreenResolution
+//
+// Description: function to set the screen resolutions.
+//
+// Input: UINTN ResX, UINTN ResY
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetScreenResolution(UINTN ResX, UINTN ResY)
+{
+ EFI_STATUS Status;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ UINT32 i;
+ UINTN SizeOfInfo;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo;
+
+ if( gGOP == NULL )
+ return EFI_UNSUPPORTED;
+
+ for(i=0;i<gGOP->Mode->MaxMode;i++)
+ {
+ Status = gGOP->QueryMode(gGOP,i,&SizeOfInfo,&pModeInfo);
+ if((EFI_SUCCESS == Status) && SizeOfInfo)
+ {
+ if((ResX == pModeInfo->HorizontalResolution) &&
+ (ResY == pModeInfo->VerticalResolution))
+ {
+ //Set to this mode
+ Status = gGOP->SetMode(gGOP,i);
+ return Status;
+ }
+ }
+ }
+
+ return EFI_UNSUPPORTED;
+#else
+ UINT32 ColorDepth, RefreshRate;
+ UINTN CurrResX, CurrResY;
+
+ if ( gUgaDraw == NULL )
+ return EFI_UNSUPPORTED;
+
+ Status = gUgaDraw->GetMode( gUgaDraw, (UINT32 *)(&CurrResX), (UINT32 *)(&CurrResY), &ColorDepth, &RefreshRate );
+
+ if(EFI_SUCCESS == Status)
+ Status = gUgaDraw->SetMode( gUgaDraw, (UINT32)ResX, (UINT32)ResY, ColorDepth, RefreshRate );
+
+ return Status;
+#endif
+}
+
+//EIP60048 starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------------
+// Procedure: GOPSetScreenResolution
+//
+// Description: Sets the mode which approximately fits the current image resolution
+//
+// Input: UINTN *, UINTN * -> Pointer to the width and height of the image to be drawn
+//
+// Output: EFI_STATUS -> Status for the operation
+//
+//----------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GOPSetScreenResolution (UINTN *Width, UINTN *Height)
+{
+ UINT32 i=0, Index = 0;
+ UINTN DiffXY = 0, ResXY = 0;
+ UINTN SizeOfInfo;
+ BOOLEAN ResXYSet = FALSE;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo;
+
+ if( NULL == gGOP )
+ return EFI_UNSUPPORTED;//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification
+ //Find proper mode to fit image
+ for (i=0;i<gGOP->Mode->MaxMode;i++)
+ {
+ Status = gGOP->QueryMode (gGOP,i,&SizeOfInfo,&pModeInfo);
+ if ((EFI_SUCCESS == Status) && SizeOfInfo)
+ {
+ DiffXY = TSE_ABS(*Width , pModeInfo->HorizontalResolution) + TSE_ABS(*Height , pModeInfo->VerticalResolution);
+ if ((ResXY || ResXYSet) ? (DiffXY <= ResXY) : (ResXY <= DiffXY)) //EIP69171, Mode not set properly
+ {
+ Index = i;
+ ResXY = DiffXY;
+ ResXYSet = TRUE;
+ }
+ }
+ }
+ gGOP->SetMode (gGOP, Index);
+ Status = GOPSetScreenResolutionHook (Width, Height, Index);
+ return Status;
+}
+//EIP60048 Ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetScreenResolution
+//
+// Description: function to get the screen resolutions.
+//
+// Input: UINTN *ResX, UINTN *ResY
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetScreenResolution(UINTN *ResX, UINTN *ResY)
+{
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if( gGOP == NULL )
+ return EFI_UNSUPPORTED;
+ *ResX = gGOP->Mode->Info->HorizontalResolution;
+ *ResY = gGOP->Mode->Info->VerticalResolution;
+ return EFI_SUCCESS;
+#else
+ UINT32 ColorDepth, RefreshRate;
+
+ if ( gUgaDraw == NULL )
+ return EFI_UNSUPPORTED;
+ return gUgaDraw->GetMode( gUgaDraw, (UINT32 *)ResX, (UINT32 *) ResY, &ColorDepth, &RefreshRate );
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawImage
+//
+// Description: function to draw a image
+//
+// Input: UINT8 *ImageData, UINTN ImageSize, CO_ORD_ATTRIBUTE Attribute,
+// INTN CoordinateX, INTN CoordinateY, BOOLEAN AdjustScreenResolution,
+// UINTN *Width, UINTN *Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+DrawImage(
+ IN UINT8 *ImageData,
+ IN UINTN ImageSize,
+ IN CO_ORD_ATTRIBUTE Attribute,
+ IN INTN CoordinateX,
+ IN INTN CoordinateY,
+ IN BOOLEAN AdjustScreenResolution,
+ OUT UINTN *Width,
+ OUT UINTN *Height
+)
+{
+
+ EFI_STATUS Status;
+ UINTN SizeOfX, SizeOfY;
+ UINTN UgaBltSize=0;
+ UINTN unBufferWidth=0;
+ UINTN LogoType;
+ BOOLEAN Animate = FALSE;
+
+ EFI_UGA_PIXEL *UgaBlt = NULL;
+
+ *Height = *Width = 0;
+ UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE.
+ Status = GetScreenResolution(&SizeOfX, &SizeOfY);
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ LogoType = GetLogoType(ImageData);
+ switch(LogoType)
+ {
+
+ case BMP_Logo:
+ Status = ConvertBmpToUgaBltWrapper(
+ ImageData,
+ ImageSize,
+ &UgaBlt,
+ &UgaBltSize,
+ Height,
+ Width );
+ unBufferWidth = *Width;
+ break;
+
+ case Unsupported_Logo:
+ default:
+
+ Status = ConvertAdvancedImageToUgaBlt(
+ ImageData,
+ ImageSize,
+ &UgaBlt,
+ &UgaBltSize,
+ Height,
+ Width,
+ &Animate);
+ unBufferWidth = *Width;
+
+
+ break;
+ }
+
+ if( EFI_ERROR(Status) )
+ {
+// CleanUpLogo(); //If Jpeg off bmp on, jpeg image unsuccess clearing the drawn bmp image so commented.
+ return Status;
+ }
+
+ if(AdjustScreenResolution)
+ {
+ //If the image is bigger than the current resolution
+ //then try to set resolution to fit the image
+ if((*Width > SizeOfX) || (*Height > SizeOfY))
+ {
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ Status = GOPSetScreenResolution (Width, Height); //EIP69171, Always check to suite the best resolution
+
+#else
+ UINT32 NewSizeOfX = 0;
+ UINT32 NewSizeOfY = 0;
+
+ if((*Width > 1024) || (*Height > 768))
+ {
+ // Set to max resolution available ie 1024 x 768
+ NewSizeOfX = 1024; NewSizeOfY = 768;
+ }
+ else if((*Width > 800) || (*Height > 600))
+ {
+ //Set to 1024 x 768
+ NewSizeOfX = 1024; NewSizeOfY = 768;
+ }
+ else if((*Width > 640) || (*Height > 480))
+ {
+ //Set to 800 x 600
+ NewSizeOfX = 800; NewSizeOfY = 600;
+ }
+
+ if(NewSizeOfX)
+ {
+ SetScreenResolution(NewSizeOfX,NewSizeOfY);
+ }
+#endif
+ GetScreenResolution (&SizeOfX,&SizeOfY);
+ }
+ }
+ DrawBltBuffer (UgaBlt, Attribute, *Width, *Height, CoordinateX, CoordinateY, unBufferWidth);
+ if(Animate)
+ {
+ DoLogoAnimate(Attribute,CoordinateX,CoordinateY);
+ }
+ else
+ {
+ //MemFreePointer( (VOID **)&ImageData ); //eip 36596 - image data will be freed in the calling function.
+ MemFreePointer( (VOID **)&UgaBlt );
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBltProgressBar
+//
+// Description: function to draw a progress bar
+//
+// Input: nil
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBltProgressBar()
+{
+#ifndef STANDALONE_APPLICATION
+
+ UINTN x = gProgress->x ;
+ UINTN y = gProgress->y ;
+ UINTN w = gProgress->w ;
+ UINTN h = gProgress->h ;
+ UINTN delta = gProgress->delta ;
+ gProgress->completed+=delta ;
+
+ if(gProgress->quiteBootActive && (gProgress->completed <= w))
+ {
+ DrawBlock(x, y, w, h, gProgress->backgroundColor) ; //draw background
+ DrawBlock(x, y, gProgress->completed, h, gProgress->fillColor) ; //draw progression
+ DrawProgressBarBorder(x, y, w, h, gProgress->borderColor, 2) ; //draw border
+ }
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawProgressBarBorder
+//
+// Description: function to draw the border of a progress bar
+//
+// Input: UINTN DestX, UINTN DestY, UINTN Width, UINTN Height,
+// EFI_UGA_PIXEL *BltBuffer, UINTN bw
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawProgressBarBorder(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ EFI_UGA_PIXEL *BltBuffer,
+ UINTN bw
+ )
+{
+#ifndef STANDALONE_APPLICATION
+ //Top
+ DrawBlock(x, y, w, bw, BltBuffer) ;
+ //Bottom
+ DrawBlock(x, y+h-bw, w, bw, BltBuffer) ;
+ //Left
+ DrawBlock(x, y, bw, h, BltBuffer) ;
+ //Right
+ DrawBlock(x+w-bw, y, bw, h, BltBuffer) ;
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBlock
+//
+// Description: function to draw draw a block
+//
+// Input: UINTN DestX, UINTN DestY, UINTN Width, UINTN Height, EFI_UGA_PIXEL *BltBuffer
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBlock(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ EFI_UGA_PIXEL *BltBuffer
+ )
+{
+#ifndef STANDALONE_APPLICATION
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( gQuietBoot && gGOP)
+#else
+ if ( gQuietBoot && gUgaDraw)
+#endif
+ {
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ gGOP->Blt (
+ gGOP,
+ BltBuffer,
+ EfiBltVideoFill,
+ 0, 0,
+ x, y,
+ w, h,
+ 0 /*BufferWidth * sizeof (EFI_UGA_PIXEL)*/
+ );
+#else
+ gUgaDraw->Blt (
+ gUgaDraw,
+ BltBuffer,
+ EfiBltVideoFill,
+ 0, 0,
+ x, y,
+ w, h,
+ 0 /*BufferWidth * sizeof (EFI_UGA_PIXEL)*/
+ );
+#endif
+ }
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBltBuffer
+//
+// Description: function to draw draw a block
+//
+// Input: EFI_UGA_PIXEL *UgaBlt, CO_ORD_ATTRIBUTE Attribute,
+// UINTN Width, UINTN Height, INTN DestX, INTN DestY,
+// UINTN BufferWidth
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBltBuffer(
+ EFI_UGA_PIXEL *UgaBlt,
+ CO_ORD_ATTRIBUTE Attribute,
+ UINTN Width,
+ UINTN Height,
+ INTN DestX,
+ INTN DestY,
+ UINTN BufferWidth
+ )
+{
+ UINTN SizeOfX=0, SizeOfY=0;
+ UINTN SourceX=0, SourceY=0;
+
+ GetScreenResolution(&SizeOfX,&SizeOfY);
+ // In case of gif set the frame position
+ if(GifImageFlag) {
+ SourceX = gGifSrcX;
+ SourceY = gGifSrcY;
+ }
+ switch(Attribute)
+ {
+ case CA_AttributeLeftTop:
+ //Need to alter DestX and DestY based on the image descriptor.
+ if(GifImageFlag) {
+ DestX = SourceX;
+ DestY = SourceY;
+ }
+ //No need to alter DestX and DestY
+ break;
+
+ case CA_AttributeCenterTop:
+ DestX = ((INTN)(SizeOfX - Width)) / 2;
+ //DestY need not be altered
+ break;
+
+ case CA_AttributeRightTop:
+ DestX = (INTN)(SizeOfX - Width - DestX);
+ //DestY need not be altered
+ break;
+
+ case CA_AttributeRightCenter:
+ DestX = (INTN)(SizeOfX - Width - DestX);
+ DestY = ((INTN)(SizeOfY - Height))/2;
+ break;
+
+ case CA_AttributeRightBottom:
+ DestX = (INTN)(SizeOfX - Width - DestX);
+ DestY = (INTN)(SizeOfY - Height - DestY);
+ break;
+
+ case CA_AttributeCenterBottom:
+ DestX = ((INTN)(SizeOfX - Width))/2;
+ DestY = (INTN)(SizeOfY - Height - DestY);
+ break;
+
+ case CA_AttributeLeftBottom:
+ //DestX need not be altered
+ DestY = (INTN)(SizeOfY - Height - DestY);
+ break;
+
+ case CA_AttributeLeftCenter:
+ //DestX need not be altered
+ DestY = ((INTN)(SizeOfY - Height))/2;
+ break;
+
+ case CA_AttributeCenter:
+ // in case of gif, set the video display positions based on the image frame position.
+ if(GifImageFlag) {
+ DestX = ((INTN)(SizeOfX - Width))/2 + SourceX;
+ DestY = ((INTN)(SizeOfY - Height))/2 + SourceY;
+ }
+ //EIP-88527 Logo should be 40% of sreen dimension
+ else if (IsBGRTSupported() && ( Width <= (((UINTN)(40 *SizeOfX))/100) ) && ( Height <= (((UINTN)(40 *SizeOfY))/100) ))
+ {
+ DestX = ((INTN)(SizeOfX - Width))/2; //Exact center of x-axis
+ DestY = (((INTN)(SizeOfY*382))/1000) - ((INTN)Height/2);//Center of logo is 38.2% from the top of screen
+ }
+ else
+ {
+ DestX = ((INTN)(SizeOfX - Width))/2;
+ DestY = ((INTN)(SizeOfY - Height))/2;
+ }
+
+ break;
+
+ default:
+ //DestX and DestY remains as it is
+ break;
+ }
+
+ //Fill the video based on image frame descriptor values
+ if(GifImageFlag) {
+ Width = gGifDestX;
+ Height = gGifDestY;
+ }
+
+ if( DestX < 0 )
+ {
+ SourceX = (-(DestX));
+ DestX = 0;
+ }
+
+ if( DestY < 0 )
+ {
+ SourceY = (-(DestY));
+ DestY = 0;
+ }
+
+ // Fix to show Logo images correctly when it is bigger then screen resolution.
+ if((DestX + (Width - SourceX)) > SizeOfX)
+ Width = (SizeOfX - DestX);
+
+ if((DestY + (Height - SourceY)) > SizeOfY)
+ Height = (SizeOfY - DestY);
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( gGOP)
+ gGOP->Blt (
+ gGOP,
+ UgaBlt,
+ EfiBltBufferToVideo,
+ SourceX, SourceY,
+ (UINTN)DestX, (UINTN)DestY,
+ Width, Height,
+ BufferWidth * sizeof (EFI_UGA_PIXEL)
+ );
+#else
+ if ( gUgaDraw)
+ gUgaDraw->Blt (
+ gUgaDraw,
+ UgaBlt,
+ EfiUgaBltBufferToVideo,
+ SourceX, SourceY,
+ (UINTN)DestX, (UINTN)DestY,
+ Width, Height,
+ BufferWidth * sizeof (EFI_UGA_PIXEL)
+ );
+#endif
+ if (gAddBgrtResolutions)
+ {
+ SetGetBgrtCoordinates (&DestX, &DestY, &Width, &Height, TRUE); //1 for set the value
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertBlt2Bmp
+//
+// Description: Converts the Blt in the screen to Bmp buffer
+//
+// Input: VOID
+//
+// Output: VOID *
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *ConvertBlt2Bmp (VOID)
+{
+ BMP_IMAGE_HEADER BmpHeaderStruct = {
+ 'B', // CHAR8 CharB;
+ 'M', // CHAR8 CharM;
+ 0, // UINT32 Size; // Dynamic
+ {0,0}, // UINT16 Reserved[2];
+ 0x36, // UINT32 ImageOffset;
+ 0x28, // UINT32 HeaderSize;
+ 0, // UINT32 PixelWidth; // Dynamic
+ 0, // UINT32 PixelHeight; // Dynamic
+ 1, // UINT16 Planes; // Must be 1
+ 0x18, // UINT16 BitPerPixel; // 1, 4, 8, or 24
+ 0, // UINT32 CompressionType;
+ 0, // UINT32 ImageSize; // // Dynamic
+ 0, // UINT32 XPixelsPerMeter;
+ 0, // UINT32 YPixelsPerMeter;
+ 0, // UINT32 NumberOfColors;
+ 0, // UINT32 ImportantColors;
+
+ };
+ BMP_IMAGE_HEADER *BmpBuffer=NULL;
+ UINT32 i=0,j=0;
+ UINT8 *Image;
+ UINTN ImageIndex;
+ UINTN AllignWidth = 0;
+ UINTN SourceX = 0, SourceY = 0;
+ UINTN Width = 0, Height = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_UGA_PIXEL *BltBuffer;
+
+ SetGetBgrtCoordinates (&SourceX, &SourceY, &Width, &Height, FALSE); //Get the BGRT logo resolutions
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if(gGOP)
+ {
+ BltBuffer = EfiLibAllocateZeroPool (Width * Height * sizeof (EFI_UGA_PIXEL));
+ if (NULL == BltBuffer)
+ {
+ return NULL;
+ }
+ Status = gGOP->Blt (
+ gGOP,
+ BltBuffer,
+ EfiBltVideoToBltBuffer,
+ SourceX, SourceY,
+ 0, 0,
+ Width, Height,
+ 0);
+ if (EFI_SUCCESS != Status)
+ {
+ MemFreePointer ((VOID **)&BltBuffer);
+ return NULL;
+ }
+ }
+#else
+ if (gUgaDraw)
+ {
+ BltBuffer = EfiLibAllocateZeroPool (Width * Height * sizeof (EFI_UGA_PIXEL));
+ if (NULL == BltBuffer)
+ {
+ return NULL;
+ }
+ Status = gUgaDraw->Blt (
+ gUgaDraw,
+ BltBuffer,
+ EfiUgaVideoToBltBuffer,
+ SourceX, SourceY,
+ 0, 0,
+ Width, Height,
+ 0);
+ if (EFI_SUCCESS != Status)
+ {
+ MemFreePointer ((VOID **)&BltBuffer);
+ return NULL;
+ }
+ }
+#endif
+ else
+ {
+ return NULL;
+ }
+ AllignWidth = Width;
+ if (Width%4 != 0)
+ {
+ AllignWidth += Width%4; //Width should be 4 bytes alligned
+ }
+ BmpHeaderStruct.ImageSize = (UINT32)(3*AllignWidth*Height);
+ BmpHeaderStruct.Size = sizeof (BmpHeaderStruct)+ BmpHeaderStruct.ImageSize;
+ BmpBuffer = EfiLibAllocateZeroPool (BmpHeaderStruct.Size);
+ if (BmpBuffer)
+ {
+ BmpHeaderStruct.PixelWidth = (UINT32)Width;
+ BmpHeaderStruct.PixelHeight = (UINT32)Height;
+
+ gBS->CopyMem(BmpBuffer,&BmpHeaderStruct,sizeof(BmpHeaderStruct));
+ Image = (UINT8*)BmpBuffer;
+ Image += BmpBuffer->ImageOffset;
+
+ for(i=(UINT32)(Width*Height);i;i-=BmpHeaderStruct.PixelWidth)
+ {
+ for(j=BmpHeaderStruct.PixelWidth;j;j--)
+ {
+ *Image++ = BltBuffer[i-j].Blue;
+ *Image++ = BltBuffer[i-j].Green;
+ *Image++ = BltBuffer[i-j].Red;
+ }
+ ImageIndex = (UINTN) (Image - BmpBuffer->ImageOffset);
+ if ((ImageIndex % 4) != 0) // Bmp Image starts each row on a 32-bit boundary!
+ Image = Image + (4 - (ImageIndex % 4));
+ }
+ MemFreePointer ((VOID **)&BltBuffer);
+ return (VOID*)BmpBuffer;
+ }
+ MemFreePointer ((VOID **)&BltBuffer);
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------
+// Procedure: ConvertBmpandAddBGRT
+//
+// Description: Converts Blt to Bmp buffer and form BGRT table and add to ACPI.
+//
+// Input: BOOLEAN = Indicates whether to set the BGRT status field or not.
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ConvertBmpandAddBGRT (
+ BOOLEAN GifImagePresence
+ )
+{
+ VOID *BmpData = NULL;
+ BmpData = ConvertBlt2Bmp ();
+ if (BmpData)
+ {
+ UINTN DestX = 0, DestY = 0, Width = 0, Height = 0;
+ SetGetBgrtCoordinates (&DestX, &DestY, &Width, &Height, FALSE); //Get the Bgrt logo resolution
+ AddImageDetailToACPI (BmpData, DestX, DestY, GifImagePresence);
+ }
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------
+// Procedure: SetGetBgrtCoordinates
+//
+// Description: Sets the BGRT logo coordinates
+//
+// Input: UINTN *DestX = X coordinate
+// UINTN *DestY = Y coordinate
+// UINTN *Width = Width of the logo
+// UINTN *Height = Heigth of the logo
+// BOOLEAN Command = To set or get the Bgrt logo resolutions
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetGetBgrtCoordinates (
+ UINTN *DestX,
+ UINTN *DestY,
+ UINTN *Width,
+ UINTN *Height,
+ BOOLEAN Command
+ )
+{
+ static UINTN gBgrtStartResX = 0;
+ static UINTN gBgrtStartResY = 0;
+ static UINTN gBgrtEndResX = 0;
+ static UINTN gBgrtEndResY = 0;
+
+ if (FALSE == Command) //To get the Bgrt logo resolution
+ {
+ *DestX = gBgrtStartResX;
+ *DestY = gBgrtStartResY;
+ *Width = gBgrtEndResX - gBgrtStartResX;
+ *Height = gBgrtEndResY - gBgrtStartResY;
+ }
+ else
+ {
+ if (1 == gAddBgrtResolutions) //At first time initialize the values
+ {
+ gBgrtStartResX = *DestX;
+ gBgrtStartResY = *DestY;
+ gBgrtEndResX = *DestX + *Width;
+ gBgrtEndResY = *DestY + *Height;
+ }
+ else
+ {
+ if (*DestX < gBgrtStartResX)
+ {
+ gBgrtStartResX = *DestX;
+ }
+ if (*DestY < gBgrtStartResY)
+ {
+ gBgrtStartResY = *DestY;
+ }
+ if (gBgrtEndResX < (*DestX + *Width))
+ {
+ gBgrtEndResX = (*DestX + *Width);
+ }
+ if (gBgrtEndResY < (*DestY + *Height))
+ {
+ gBgrtEndResY = (*DestY + *Height);
+ }
+ }
+ gAddBgrtResolutions ++;
+ }
+}
+
+//EIP94702 starts
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------
+// Procedure: SetGraphicsResolution
+//
+// Description: Sets the graphical resolution corresponding to the input parameter
+//
+// Input: UINT32 - Horizontal resolution of the mode to set
+// UINT32 - Vertical resolution of the mode to set
+//
+// Output: EFI_STATUS - EFI_SUCCESS - If input resolutions are set successfully
+// !EFI_SUCCESS - If input resolutions are not set successfully
+//
+//--------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetGraphicsResolution (UINT32 HorResolution, UINT32 VerResolution)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 iIndex = 0;
+ UINTN SizeOfInfo = 0;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *pModeInfo = NULL;
+
+ for (iIndex = 0; iIndex < gGOP->Mode->MaxMode; iIndex ++)
+ {
+ Status = gGOP->QueryMode (gGOP, iIndex, &SizeOfInfo, &pModeInfo);
+ if (!EFI_ERROR (Status))
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] pModeInfo HorizontalResolution=%d VerticalResolution=%d\n", pModeInfo->HorizontalResolution, pModeInfo->VerticalResolution);
+ if ((HorResolution == pModeInfo->HorizontalResolution) && (VerResolution == pModeInfo->VerticalResolution))
+ {
+ if (gGOP->Mode->Mode != iIndex) //If Current mode not equals the found mode then call SetMode otherwise return success
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] Setting %d Mode\n", iIndex);
+ Status = gGOP->SetMode (gGOP, iIndex);
+ if (!EFI_ERROR (Status)) //Loop for all the cases. Not success also loop for another without returning from here
+ {
+ return EFI_SUCCESS;
+ }
+ }
+ else
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] Without Setting %d Mode\n", iIndex);
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+ return EFI_NOT_FOUND;
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------
+// Procedure: SetNativeResFromEdid
+//
+// Description: Finds and sets the resolution from EDID
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetNativeResFromEdid (VOID)
+{
+ EFI_STATUS Status;
+ UINT32 HorRes;
+ UINT32 VerRes;
+ EFI_EDID_ACTIVE_PROTOCOL *EdidActive;
+ EFI_GUID EdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
+
+ Status = gBS->LocateProtocol (&EdidActiveProtocolGuid, NULL, &EdidActive);
+ if(EFI_ERROR(Status) || EdidActive->SizeOfEdid == 0)
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] Edid active protocol fails \n");
+ Status = SetGraphicsResolution (1024, 768); //If EDID not found set 1024*768 mode
+ return Status;
+ }
+
+ if(!((EdidActive->Edid)[24] & BIT01))
+ {
+ /* native resolution not supported */
+ return EFI_UNSUPPORTED;
+ }
+
+ HorRes = ((((EdidActive->Edid)[0x36 + 4]) & 0xF0) << 4) + (EdidActive->Edid)[0x36 + 2];
+ VerRes = ((((EdidActive->Edid)[0x36 + 7]) & 0xF0) << 4) + (EdidActive->Edid)[0x36 + 5];
+
+ SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 4]);
+ SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 2]);
+ SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 7]);
+ SETUP_DEBUG_TSE ("\n[TSE] %02d, ", EdidActive->Edid[0x36 + 5]);
+ SETUP_DEBUG_TSE ("\n[TSE] EDID HorizontalResolution=%d VerticalResolution=%d\n", HorRes, VerRes);
+
+ Status = SetGraphicsResolution (HorRes, VerRes);
+ if (EFI_ERROR(Status))
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] Setting 1024 * 768 Mode \n");
+ Status = SetGraphicsResolution (1024, 768); //If EDID not found set 1024*768 mode
+ }
+ return Status;
+}
+//EIP94702 ends
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
diff --git a/EDK/MiniSetup/BootOnly/mem.c b/EDK/MiniSetup/BootOnly/mem.c
new file mode 100644
index 0000000..6f68b25
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/mem.c
@@ -0,0 +1,255 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/mem.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/mem.c $
+//
+// 5 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 11/10/11 12:52a Arunsb
+// [TAG] EIP67735
+// [Category] Improvement
+// [Description] Zeroing password buffers before freeing
+// [Files] mem.c, mem.h, popupedit.c, popuppassword.c and tseadvanced.c
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 3:37p Madhans
+// TSE_USE_EDK_LIBRARY
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: mem.c
+//
+// Description: file contains code to handle the memory operations.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemFreePointer
+//
+// Description: function to free the pointers
+//
+// Input: VOID **ptr
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MemFreePointer( VOID **ptr )
+{
+ if ( ( ptr == NULL ) || ( *ptr == NULL ) )
+ return;
+
+ gBS->FreePool( *ptr );
+ *ptr = NULL;
+}
+
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------------
+// Procedure: StringZeroFreeMemory
+//
+// Description: Function to free the string pointers and zeroing its memory, used for strings
+// Care should be taken String Length identification function is used
+//
+// Input: VOID **ptr
+//
+// Output: void
+//
+//-------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StringZeroFreeMemory (VOID **ptr)
+{
+ if ( (ptr == NULL) || (*ptr == NULL))
+ return;
+
+ MemSet (*ptr, (EfiStrLen ((CHAR16 *)*ptr) * sizeof (CHAR16)), 0);
+ gBS->FreePool (*ptr);
+ *ptr = NULL;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemCopy
+//
+// Description: function to copy a memory
+//
+// Input: VOID *dest, VOID *src, UINTN size
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MemCopy( VOID *dest, VOID *src, UINTN size )
+{
+ gBS->CopyMem( dest, src, size );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemSet
+//
+// Description: function to set the memory with the specified value
+//
+// Input: VOID *buffer, UINTN size, UINT8 value
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#if TSE_USE_EDK_LIBRARY
+VOID MemSet( VOID *buffer, UINTN size, UINT8 value )
+{
+ gBS->SetMem( buffer, size, value );
+}
+#endif //#if TSE_USE_EDK_LIBRARY
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemReallocateZeroPool
+//
+// Description: function to reuse a allocated buffer
+//
+// Input: VOID *oldBuffer, UINTN oldSize, UINTN newSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *MemReallocateZeroPool( VOID *oldBuffer, UINTN oldSize, UINTN newSize )
+{
+ VOID *buffer;
+
+ buffer = EfiLibAllocateZeroPool( newSize );
+ if ( buffer == NULL )
+ return buffer;
+
+ if ( newSize < oldSize )
+ oldSize = newSize;
+
+ if ( oldBuffer != NULL )
+ MemCopy( buffer, oldBuffer, oldSize );
+
+ MemFreePointer( (VOID **)&oldBuffer );
+
+ return buffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemFillUINT16Buffer
+//
+// Description: function to fill a UINT16 Buffer
+//
+// Input: VOID *buffer, UINTN bufferSize, UINT16 value
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MemFillUINT16Buffer( VOID *buffer, UINTN bufferSize, UINT16 value )
+{
+ UINTN Index;
+ UINT16 *bufPtr = (UINT16 *)buffer;
+
+ for ( Index = 0; Index < bufferSize; Index++ )
+ *bufPtr++ = value;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemCmp
+//
+// Description: function to compare the memory of two buffers.
+//
+// Input: UINT8 *dest, UINT8 *src, UINTN size
+//
+// Output: 0/1/-1
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#if TSE_USE_EDK_LIBRARY
+INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size )
+{
+ UINTN i;
+
+ for( i=0; i<size; i++)
+ {
+ if(dest[i] < src[i])
+ return -1;
+ if(dest[i] > src[i])
+ return 1;
+ }
+ return 0;
+}
+#endif //#if TSE_USE_EDK_LIBRARY
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/minisetup.c b/EDK/MiniSetup/BootOnly/minisetup.c
new file mode 100644
index 0000000..ef499ff
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/minisetup.c
@@ -0,0 +1,551 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 15 $
+//
+// $Date: 5/08/14 9:16p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.c $
+//
+// 15 5/08/14 9:16p Arunsb
+// [TAG] EIP162981
+// [Category] Improvement
+// [Description] Configuring default Password through SDL token.
+// Made dependency with RT_ACCESS_SUPPORT_IN_HPKTOOL.
+//
+// 14 5/02/14 8:41a Premkumara
+// [TAG] EIP162981
+// [Category] Improvement
+// [Description] Configuring default Password through SDL token
+// [Files] AMITSE.sdl, CommonHelper.c, Minisetup.c, TseAdvanced.c
+//
+// 13 5/01/14 4:05p Premkumara
+// [TAG] EIP149734
+// [Category] Improvement
+// [Description] Softkbd should not display in BBS menu
+// [Files] Minisetup.c
+//
+// 12 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 10 6/25/12 5:39p Arunsb
+// [TAG] EIP93524
+// [Category] Improvement
+// [Description] Invalidate the BGRT table when boot device launched
+// from BBS popup or from shell or launched as second boot device
+// [Files] boot.c and minisetup.c
+//
+// 9 4/27/12 5:16a Rajashakerg
+// [TAG] EIP82804
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System hangs at password prompt when Administrator password
+// set.
+// [RootCause] When admin passwor set, in the absence of built in efi
+// shell and no usb connected to SUT. IF we wont select any option at post
+// we will try to launch setup but before launcing setup mouse is
+// destroyed.
+// [Solution] Fixed the issue by invoking the Mouseinit() for a specail
+// case of admin password set and when no boot option to boot.
+// [Files] minisetup.c
+//
+// 8 4/27/12 2:09a Rajashakerg
+// [TAG] EIP88454
+// [Category] Improvement
+// [Description] SoftKbd activate functionality in BBS Menu by AMITSE
+// [Files] minisetup.c
+//
+// 7 6/20/11 10:33a Arunsb
+// [TAG] EIP54861
+// [Category] Improvement
+// [Description] Updating string token value dynamically for Title Bar
+// and Copyright messages.
+// [Files] minisetup.c and tselite\minisetupext.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/04/10 11:20p Madhans
+// Post Status update for BBS popup.
+//
+// 6 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 5 1/09/10 5:16a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 3:40p Madhans
+// MinisetupLoopInit is moved to minisetup.c
+//
+// 3 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MINISETUP.C
+//
+// Description: This file contains code for entrypoint and setup loop
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION
+// from Resources.c
+#if TSE_USE_EDK_LIBRARY
+EFI_STATUS LoadStrings(
+ EFI_HANDLE ImageHandle, /*EFI_HII_HANDLE*/VOID* *pHiiHandle
+);
+#endif
+#endif
+
+#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION || TSE_FOR_64BIT
+EFI_STATUS ReadImageResource(
+ EFI_HANDLE ImageHandle, EFI_GUID *pGuid,
+ VOID **ppData, UINTN *pDataSize
+);
+#endif
+
+//Internal function definitions
+#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1
+EFI_STATUS InitMiniSetupStrings( VOID );
+#endif
+
+EFI_DRIVER_ENTRY_POINT (MiniSetupApplication)
+
+/////////////////////////////////////////////////////////
+// FUNCTION DECLARATION
+////////////////////////////////////////////////////////
+VOID InitGlobalPointers( VOID );
+VOID UpdategScreenParams (VOID);
+VOID StopClickEvent(VOID);
+AMI_SET_VERSION(TSE_MAJOR,TSE_MINOR,TSE_BUILD,TSE);
+VOID InvalidateStatusInBgrtWrapper (VOID);
+
+//EIP 162981 Providing defaults through sdl tokens
+BOOLEAN TseDefaultSetupPasswordSupported(VOID);
+EFI_STATUS SetDefaultPassword (VOID);
+
+#define TSE_FIRST_BOOT_GUID \
+ { 0xc5912ed9, 0x83c2, 0x4bff, 0x99, 0x36, 0x23, 0x1f, 0xeb, 0x85, 0xf3, 0xe8 }
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MiniSetupApplication
+//
+// Description: This function is the entry point for TSE. It loads
+// resources like strings and setup-data. It registers
+// notification for console protocols. It Installs TSE
+// protocols.
+//
+// Input: EFI_HANDLE ImageHandle
+// EFI_SYSTEM_TABLE *SystemTable
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MiniSetupApplication (
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable )
+{
+ EFI_STATUS Status;
+ UINTN OptionSize = 0;
+ void *FirstBoot = NULL;
+ EFI_GUID TseFirstBootGuid = TSE_FIRST_BOOT_GUID;
+
+ gImageHandle = ImageHandle;
+
+ EfiInitializeDriverLib ( ImageHandle, SystemTable );
+
+ RUNTIME_DEBUG( L"entry" );
+
+#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION
+#if TSE_USE_EDK_LIBRARY
+ LoadStrings(ImageHandle,&gHiiHandle);
+#else
+ LoadStrings(ImageHandle,(EFI_HII_HANDLE*)&gHiiHandle);
+#endif
+#else
+#ifdef USE_DEPRICATED_INTERFACE
+ // Read in the strings from the GUIDed section
+ Status = LoadStringsDriverLib( ImageHandle, &STRING_ARRAY_NAME );
+ if ( EFI_ERROR( Status ) )
+ {
+ return Status;
+ }
+#endif
+
+ Status = InitMiniSetupStrings();
+ if ( EFI_ERROR( Status ) )
+ {
+ return Status;
+ }
+#endif
+
+ Status = HiiInitializeProtocol();
+ if ( EFI_ERROR ( Status ) )
+ return Status;
+
+ // initialize screen buffer
+ RUNTIME_DEBUG( L"screen" );
+ InitializeScreenBuffer( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+
+ RUNTIME_DEBUG( L"guid" );
+
+ Status = InitApplicationData(ImageHandle);
+ if ( EFI_ERROR( Status ) )
+ {
+ return MiniSetupExit( Status );
+ }
+
+ RUNTIME_DEBUG( L"globals" );
+ InitGlobalPointers();
+ UpdategScreenParams ();
+
+ Status = VarLoadVariables( (VOID **)&gVariableList, NULL );
+ if ( EFI_ERROR( Status ) )
+ {
+ return Status;
+ }
+
+ MinisetupDriverEntryHookHook();
+
+ gPostStatus = TSE_POST_STATUS_BEFORE_POST_SCREEN;
+
+#ifndef STANDALONE_APPLICATION
+ // Install our handshake protocol
+ InstallProtocol();
+
+ // Register any notification 'callbacks' that we need
+ Status = RegisterNotification();
+ if ( EFI_ERROR( Status ) )
+ UninstallProtocol();
+#else
+ PostManagerHandshake();
+#endif // STANDALONE_APPLICATION
+
+ if (TseDefaultSetupPasswordSupported ()) //EIP 162981 Providing defaults through sdl tokens
+ {
+ FirstBoot = (BOOT_OPTION *)VarGetNvramName (L"TseFirstBootFlag", &TseFirstBootGuid, NULL, &OptionSize);
+ if (NULL == FirstBoot)
+ {
+ SetDefaultPassword (); //Get default password, if any present in SDL, and set default pass to NVRAM EIP 162981
+ VarSetNvramName( L"TseFirstBootFlag", &TseFirstBootGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, &OptionSize, sizeof (OptionSize) );
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MiniSetupExit
+//
+// Description: This function is responsible for releasing the memory
+// allocated during MinisetuEntry(). It destroys the
+// application hierarchy; clears the memory used for
+// variables; clears the memory used for fixup of
+// setup-data.
+//
+// Input: EFI_STATUS Status: Guideline status for MiniSetupExit
+// to return with.
+//
+// Output: Return Status based on input status and errors that
+// occurred in library functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MiniSetupExit( EFI_STATUS Status )
+{
+ MiniSetupUIExit();
+
+ if(gST->ConOut!=NULL)
+ {
+ gST->ConOut->Reset( gST->ConOut, FALSE );
+ gST->ConOut->ClearScreen( gST->ConOut);
+ gST->ConOut->EnableCursor( gST->ConOut, TRUE );
+ }
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoPopup
+//
+// Description: This function runs the loop for Pop up boot menu.
+// This function is responsible for creating the list
+// box control. It also gathers actions and passes them
+// to list box control and initiates draw sequence.
+//
+// Input: BOOT_FLOW *BootFlow: Ptr to BOOT_FLOW responsible for
+// the call.
+//
+// Output: Return Status based on errors that occurred in
+// library functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DoPopup(BOOT_FLOW *BootFlow)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ gPostStatus = TSE_POST_STATUS_IN_BBS_POPUP;
+
+ DoBbsPopupInit() ; //minisetupext.c
+
+ if (gClickTimer) //EIP-149734 Stopping ClickEvent timer, if gClickTimer event is not stopped, before drawing BBS menu to avoid drawing softkbd if any mouse action happens during BBS menu
+ StopClickEvent();
+
+ //TSEStringReadLoopEntryHook();//EIP 88454 : Initializing the Softkbd for BBS popup menu
+ DrawPopupMenuHook() ; //HookAnchor.c -> DrawBootOnlyBbsPopupMenu (minisetupext.c)
+ BbsBootHook() ; //HookAnchor.c -> BbsBoot (minisetupext.c)
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MainSetupLoopInit
+//
+// Description: Main function that initializes the setup Loops.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MainSetupLoopInit(VOID)
+{
+#ifndef STANDALONE_APPLICATION
+ EFI_CONSOLE_CONTROL_SCREEN_MODE ScreenMode;
+#endif
+ EFI_GUID AmitseSetupEnterGuid = AMITSE_SETUP_ENTER_GUID;
+ static int Initdone =0;
+
+ if(Initdone)
+ {
+ EfiLibNamedEventSignal ( &AmitseSetupEnterGuid );
+ return;
+ }
+ Initdone = 1;
+
+#ifndef STANDALONE_APPLICATION
+ if ( gConsoleControl != NULL )
+ {
+ gConsoleControl->GetMode(gConsoleControl, &ScreenMode, NULL, NULL);
+ if(EfiConsoleControlScreenGraphics == ScreenMode)
+ {
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText );
+ InvalidateStatusInBgrtWrapper (); //EIP93524. Since mode changed invalidating status field in BGRT table. Usefull for boot from BBS Pop up.
+ }
+ }
+#endif
+
+ MouseInit();//EIP 82804 : Initiatializing the Mouse before prompting password
+ ProcessEnterSetupHook();
+
+ TSEUnlockHDD(); ///Modified as a hook
+
+ EfiLibNamedEventSignal ( &AmitseSetupEnterGuid );
+ // Report the Status code DXE_SETUP_START
+ EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_SETUP_START,0,NULL,NULL);
+}
+
+//EIP 162981 starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetDefaultPassword
+//
+// Description: Getting default password from SDL token based on USER/ADMIN token
+//
+// Input: UINT32, AMITSESETUP*
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetDefaultPasswordFromTokens (UINT32 PasswordType);
+EFI_STATUS GetDefaultPassword (UINT32 PasswordInstalled, void **DefaultPassword)
+{
+ CHAR16 *adminPwd = NULL, *usrPwd = NULL;
+ EFI_STATUS Status = EFI_NOT_FOUND;
+ CHAR16 *tmpPasswd = NULL;
+
+ if ((PasswordInstalled == AMI_PASSWORD_ADMIN) || (AMI_PASSWORD_NONE == PasswordInstalled))
+ {
+ usrPwd = GetDefaultPasswordFromTokens (AMI_PASSWORD_USER);
+ if ((NULL != usrPwd) && (EfiStrCmp (usrPwd, L"\"\"")))
+ {
+ tmpPasswd = (CHAR16 *)EfiLibAllocateZeroPool (sizeof (AMITSESETUP));
+ if (NULL == tmpPasswd)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ EfiStrCpy (tmpPasswd, usrPwd);
+ PasswordEncodeHook (tmpPasswd, TsePasswordLength*sizeof(CHAR16));
+ MemCopy (*DefaultPassword, tmpPasswd, TsePasswordLength*sizeof(CHAR16));
+ MemFreePointer ((VOID **) &tmpPasswd);
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ if ((PasswordInstalled == AMI_PASSWORD_USER) || (AMI_PASSWORD_NONE == PasswordInstalled))
+ {
+ adminPwd = GetDefaultPasswordFromTokens (AMI_PASSWORD_ADMIN);
+ if ((NULL != adminPwd) && (EfiStrCmp (adminPwd, L"\"\"")))
+ {
+ tmpPasswd = (CHAR16 *) EfiLibAllocateZeroPool (sizeof (AMITSESETUP));
+ if (NULL == tmpPasswd)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ EfiStrCpy (tmpPasswd, adminPwd);
+ PasswordEncodeHook (tmpPasswd, TsePasswordLength*sizeof(CHAR16));
+ MemCopy ((CHAR16*)(*DefaultPassword) + TsePasswordLength, tmpPasswd, TsePasswordLength*sizeof(CHAR16));
+ MemFreePointer ((VOID **) &tmpPasswd);
+ Status = EFI_SUCCESS;
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetDefaultPassword
+//
+// Description: Function to set defaults password in NVRAM, if any present in SDL
+//
+// Input: void
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN TseRtAccessSupport (VOID);
+EFI_STATUS SetDefaultPassword (VOID)
+{
+ UINTN size = 0;
+ UINT32 Installed = AMI_PASSWORD_NONE;
+ void *DefaultPassword = NULL;
+ UINT32 PasswordInstalled;
+ EFI_STATUS Status = EFI_SUCCESS;
+ AMITSESETUP *pSetupVariable = (AMITSESETUP *)NULL;
+ EFI_GUID amitsesetupGuid = AMITSESETUP_GUID;
+
+ pSetupVariable = HelperGetVariable( VARIABLE_ID_AMITSESETUP, (CHAR16 *)NULL, (EFI_GUID *)NULL, NULL, &size );
+
+ if(size < sizeof(AMITSESETUP))
+ {
+ pSetupVariable = (AMITSESETUP *) EfiLibAllocateZeroPool(sizeof(AMITSESETUP));
+ if(gVariableList && (gVariableList[VARIABLE_ID_AMITSESETUP].Buffer))
+ MemCopy( pSetupVariable, gVariableList[VARIABLE_ID_AMITSESETUP].Buffer, gVariableList[VARIABLE_ID_AMITSESETUP].Size );
+ if (TseRtAccessSupport ())
+ {
+ VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, pSetupVariable, sizeof (AMITSESETUP));
+ }
+ else
+ {
+ VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, pSetupVariable, sizeof (AMITSESETUP));
+ }
+// VarSetNvram( VARIABLE_ID_AMITSESETUP, pSetupVariable, sizeof(AMITSESETUP));
+ }
+ PasswordInstalled = PasswordCheckInstalled();
+
+ if (AMI_PASSWORD_ANY == PasswordInstalled)
+ {
+ return EFI_ALREADY_STARTED;
+ }
+
+ Status = GetDefaultPassword (PasswordInstalled, &pSetupVariable);
+
+ if (!EFI_ERROR (Status))
+ {
+ if (TseRtAccessSupport ())
+ {
+ VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS, pSetupVariable, sizeof (AMITSESETUP));
+ }
+ else
+ {
+ VarSetNvramName( L"AMITSESetup", &amitsesetupGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, pSetupVariable, sizeof (AMITSESETUP));
+ }
+// VarSetNvram( VARIABLE_ID_AMITSESETUP, pSetupVariable, sizeof(AMITSESETUP));
+// VarUpdateDefaults(VARIABLE_ID_AMITSESETUP);
+ }
+ return EFI_SUCCESS;
+}
+//EIP 162981 ends
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/minisetup.h b/EDK/MiniSetup/BootOnly/minisetup.h
new file mode 100644
index 0000000..cdd9a0e
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/minisetup.h
@@ -0,0 +1,1519 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 49 $
+//
+// $Date: 8/28/14 5:43a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $
+//
+// 49 8/28/14 5:43a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 48 2/11/14 7:56p Arunsb
+// [TAG] EIP125719
+// [Category] Improvement
+// [Description] The EfiCreateEventReadyToBoot is conflicted under
+// UefiLib.h and EDKhelper.h.
+// [Files] boot.c
+//
+// 47 10/18/12 5:58a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 37 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 45 5/29/12 4:31a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 44 5/28/12 5:39a Premkumara
+// [TAG] EIP75236
+// [Category] Improvement
+// [Description] Add the support to control the GOP dependency in TSE
+// notification.
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
+// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
+//
+// 43 1/10/12 2:36a Arunsb
+// [TAG] EIP77400
+// [Category] Improvement
+// [Description] Need to do "Clear Screen" whenever boot to EFI Shell
+// [Files] Boot.c and minisetup.h
+//
+// 42 12/08/11 12:34p Arunsb
+// [TAG] EIP63190
+// [Category] New Feature
+// [Description] Security operations in BootOnly module instead of
+// TSELite
+//
+// 41 12/05/11 5:48a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 40 12/01/11 5:36a Rajashakerg
+// [TAG] EIP74963
+// [Category] Improvement
+// [Description] MAX_MSGBOX_WIDTH cannot be overridden
+// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
+// MessageBox.c, MessageBox.h, FormBrowser.c
+//
+// 39 12/01/11 4:58a Arunsb
+// // [TAG] EIP70175
+// // [Category] Improvement
+// // [Description] Removed unwanted declarations
+// // [Files] CommonHelper.c, postmgmtext.c
+//
+// 38 11/21/11 10:44a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 37 11/21/11 5:47a Rajashakerg
+// [TAG] EIP74591
+// [Category] Improvement
+// [Description] Make MainSetupLoop as board module hook
+// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
+// FormBrowser.c, FormBrowser2.c
+//
+// 36 11/20/11 8:10a Premkumara
+// [TAG] EIP70175
+// [Category] Improvement
+// [Description] Color of PopupPassword Window to validate password in
+// GTSE style
+// [Files] CommonHelper.c, postmgmtext.c, minisetup.h
+//
+// 35 11/20/11 7:09a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 34 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 33 11/13/11 12:32p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 32 10/31/11 9:45a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 31 7/19/11 10:50a Blaines
+// [TAG] - EIP 63262
+// [Category]- Defect
+// [Symptom]- Setup page display problem on rose city.
+// When SETUP_GROUP_DYNAMIC_PAGES is enabled and Network Stack is enabled,
+// the "iSCSI" menu is listed as a dynamic page in advanced menu but only
+// 3 of 4 "Port Configuration" pages shows up. The TSE dynamic page count
+// is incorrect.
+//
+// [Solution]- In the functions (RTIfrProcessRunTimeForms,
+// HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack), make sure the
+// nvram cache is updated by calling
+// VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT) when updating
+// "DynamicPageCount" variable name.
+// .
+// [Files] - Hii.c, Minisetup.h, Variable.h
+//
+// 30 7/01/11 5:19a Arunsb
+// Driver health related declaration moved to tsedrvhealth.h.
+//
+// 29 6/30/11 5:05a Premkumara
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Resolve Build error with Driver Health protocol
+//
+// 28 6/30/11 4:14a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// 2.0 & 2.1 compatibility added
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 27 6/29/11 12:19p Rajashakerg
+// [TAG] EIP47086, 62098
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup and the Mouse hotclicks.
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 26 6/23/11 4:06p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 25 6/20/11 11:46a Rajashakerg
+// [TAG] EIP59417
+// [Category] New Feature
+// [Description] Spport LOAD_OPTION_HIDDEN option in TSE
+// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
+// minisetup.h, special.c, callback.c
+//
+// 24 3/28/11 11:40p Madhans
+// [TAG] EIP50878
+// [Category] Improvement
+// [Description] Support to move the Control With Boot Order Change.
+// [Files] AMITSE.sdl
+// commonoem.c
+// minisetup.h
+// popupsel.c
+//
+// 23 3/23/11 8:38p Blaines
+// [TAG] - EIP 23601
+// [Category]- Enhancement
+// [Symptom]- Add support for OEM special controls.
+// [Files] - AmiTse.sdl, CommonHelper.c, Setup.ini, UefiSetup.ini,
+// AmiVfr.h, minisetup.h, minisetup.sdl, variable.c, special.c
+//
+// 22 3/21/11 1:23a Rajashakerg
+// [TAG] EIP53740
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Animation does not continue after the last frame of the
+// logo.
+// [RootCause]
+// Animation is continued upto the last frame of the animated image
+// [Solution] Fixed the issue by handling Gif image data to redraw image
+// if all the frames are completed and if boottimeout is present.
+// [Files] minisetup.h, dogif.c, dogifmgr.c
+//
+// 21 3/15/11 5:14a Rajashakerg
+// [TAG] EIP51671
+// [Category] New Feature
+// [Description] Boot overide menu devices are not disable
+// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl,
+// boot.h, CommonHelper.c
+//
+// 20 1/10/11 3:55p Mallikarjunanv
+// Updated to work with respect to EDK Libraries
+//
+// 19 12/29/10 2:27a Mallikarjunanv
+// Updated the funcation name of the EIP:50479
+//
+// 18 12/28/10 6:14p Mallikarjunanv
+// [TAG] EIP41615
+// [Category] New Feature
+// [Description] Added the file browser support for the Add boot option
+// reated controls
+// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c,
+// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c,
+// AddBootOption.c
+//
+// 17 12/26/10 10:27a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] fter the notification, if the graphics driver uninstalled
+// and reinstalled from core module then gGOP getting corrupted.
+// [Solution] Updated gGop before using it in AMITSE.
+// [Files] logo.c,minisetup.h, notify.c, postmgmt.c
+//
+// 16 10/06/10 5:59p Madhans
+// [TAG] - EIP 45620
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- TSE with TSE_CONTINUE_BOOT_NOW_ON_FAIL ON Not allows to boot
+// to USB group of devices with customized BDS.
+// [RootCause] - BBSTable does not contain the DeviceType called USB. Only
+// in EFI Logical group is created in EFI variables.
+// TSE was checking the DeviceType to set the priorities.
+// [Solution]- TSE is changed to not check for DeviceType in BBSTable. But
+// set the priorities based on LegacyDevOrder.
+// [Files] - bbs.c commonhelper.c minisetup.h
+//
+// 15 10/05/10 5:38p Madhans
+// [TAG] - EIP 45299
+// [Category]- Enhancment
+// [Severity]- Minor
+// [Symptom]- TSE by default saves the Disbaled BBS devices device path in
+// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on
+// this variable to consider the device as disabled inaddtion to
+// LegacyDevOrder.
+// Some BDS customized projects don't want this.
+// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to
+// control this option. Bydefault It is Enabled.
+// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl
+//
+// 14 9/20/10 6:47p Madhans
+// [TAG] EIP44542
+// [Category] BUILD ISSUE FIX
+// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
+// when IdeSecurity and FastBoot modules added to the project
+// [RootCause] -
+// [Solution] Build issues resolved
+// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
+// bbs.c, special.c, Bds.c TseLitehelp
+//
+// 13 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 28 9/08/10 6:53a Mallikarjunanv
+// EIP-42080: TSE updates with respect to Fast Boot Support
+//
+// 27 8/27/10 5:00a Mallikarjunanv
+// EIP-39334: support to build TSE without the CSM module support
+//
+// 26 4/07/10 6:24p Madhans
+// post screen Sroll area support. TSE_POSTSCREEN_SCROLL_AREA SDL
+// configures the area.
+//
+// 25 4/02/10 4:37p Madhans
+// To get ride of TSEOEM.H referance in TSE. Oem hearder files can be
+// refered only in Tse Binary.
+//
+// 24 3/23/10 5:08p Blaines
+// Preseve the order of disabled BBS boot devices.
+//
+// 23 2/26/10 7:06p Madhans
+// Cleanup on formbrowrser.h
+//
+// 3 2/26/10 3:36p Madhans
+// Formbrowser.h need to be in Hii modules.
+//
+// 21 2/17/10 1:02p Madhans
+// minisetupstr.uni removed and Strings token are refered from
+// AMITSEStrTokens.h
+//
+// 20 2/15/10 10:10p Madhans
+// To avoid Compilation issues
+//
+// 19 2/11/10 7:14a Mallikarjunanv
+// added Tse Advanced module dependency to include TseElinks.h
+//
+// 18 2/04/10 12:03p Blaines
+// EIP-28005
+//
+// Added PostManagerSetAttribute to support display of text in color.
+// Added support for handling string characters --- \n, \r.
+//
+// 17 1/18/10 2:07a Mallikarjunanv
+// EIP-28501: Updated for Keyboard scancode as password. Added a new Token
+// SETUP_STORE_KEYCODE_PASSWORD to support the EFI key or Scan code as
+// password
+//
+// 16 1/09/10 5:26a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 15 1/04/10 10:40a Mallikarjunanv
+// EIPs 27161/29095 - Added support for reserved boot option names and
+// added support not to create empty boot option names
+//
+// 14 10/28/09 5:37p Madhans
+//
+// 13 9/24/09 9:41a Sudhirv
+// EIP-24971: moved the dependency for TSE_CONTINUE_BOOT_NOW_ON_FAIL to
+// Tse Binary
+//
+// 12 9/17/09 9:04a Sudhirv
+// Remove Load Driver Option from TSE 2.x as it will be handled from Core
+//
+// 11 9/16/09 6:15p Madhans
+// EIP 25416 : Support have 1/10 sec Timeout
+//
+// 10 9/15/09 9:31a Sudhirv
+// removed Version macros and added function declarations for Add Del boot
+// option handling
+//
+// 9 8/18/09 6:34p Blaines
+// Support additional date styles
+//
+// 8 8/17/09 12:21p Presannar
+// Removed References to Tiano.h
+//
+// 7 8/17/09 10:52a Presannar
+// Added code to include EDKHelper.h
+// Removed redefinition of structure LOGO_TYPE
+// Added fn prototype for CleanUpExtendedLogoWrapper and
+// DoLogoAnimateWrapper
+//
+// 6 8/13/09 7:35a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 5 7/30/09 7:49a Mallikarjunanv
+// updated the code to move the exit page option elinks to Tse Binary -
+// included the new header file TseElinks.h to access all tse modules
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/13/09 2:22p Madhans
+// To patch the version number in the Bootonly TSE. update the build
+// number.
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 9 5/06/09 12:31p Mallikarjunanv
+// updated the version info
+//
+// 8 5/05/09 3:11p Madhans
+// Std Col default.
+//
+// 7 5/01/09 9:45p Blaines
+// Control and Label margin support changes
+//
+// 6 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 3/31/09 3:58p Madhans
+//
+// 4 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MINISETUP.h
+//
+// Description: Main header file takes care of TSE includes.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _MINISETUP_H_
+#define _MINISETUP_H_
+
+#ifdef TSE_FOR_APTIO_4_50
+#include <Token.h>
+#else
+#include "tokens.h"
+#endif
+
+
+#ifndef SETUP_USE_GUIDED_SECTION
+#define SETUP_USE_GUIDED_SECTION 0
+#endif
+
+#ifndef SETUP_JPEG_LOGO_SUPPORT
+#define SETUP_JPEG_LOGO_SUPPORT 0
+#endif
+
+#ifndef SETUP_PCX_LOGO_SUPPORT
+#define SETUP_PCX_LOGO_SUPPORT 0
+#endif
+
+#ifndef SETUP_GIF_LOGO_SUPPORT
+#define SETUP_GIF_LOGO_SUPPORT 0
+#endif
+
+#ifndef TSE_BOOT_NOW_IN_BOOT_ORDER
+#define TSE_BOOT_NOW_IN_BOOT_ORDER 0
+#endif
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+
+#include "EfiDriverLib.h"
+#include "EfiPrintLib.h"
+
+#include EFI_PROTOCOL_DEFINITION(FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem)
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
+// Between GOP and UGA draw protocols blt buffer structure remains
+// the same. The difference is only in the name so we can safely
+// typedef the new structure to old structure's name.
+typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL;
+#else
+#include EFI_PROTOCOL_DEFINITION(UgaDraw)
+#endif
+#include EFI_PROTOCOL_DEFINITION(ConsoleControl)
+#include EFI_PROTOCOL_DEFINITION(DevicePath)
+#include EFI_PROTOCOL_DEFINITION(ComponentName)
+#include EFI_PROTOCOL_DEFINITION(LegacyBios)
+#include EFI_PROTOCOL_DEFINITION(LoadedImage)
+#include EFI_PROTOCOL_DEFINITION(FileInfo)
+#if EFI_SPECIFICATION_VERSION<=0x20000
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#endif
+
+#if SETUP_ITK_COMPATIBILITY
+#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h"
+#else
+#include EFI_PROTOCOL_DEFINITION(EfiOEMBadging)
+#endif
+#include EFI_GUID_DEFINITION(Bmp)
+INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size );
+
+#define MSG_USB_WWID_CLASS_DP MSG_USB_WWID_DP
+#define MSG_USB_LOGICAL_UNIT_CLASS_DP MSG_DEVICE_LOGICAL_UNIT_DP
+#define MSG_USB_SATA_DP MSG_SATA_DP
+#define MSG_USB_ISCSI_DP MSG_ISCSI_DP
+
+#else //TSE_USE_EDK_LIBRARY
+
+#include "Efi.h"
+
+#include "Protocol/FirmwareVolume.h"
+#include "Protocol/SimpleFileSystem.h"
+#include "Protocol/SimpleTextOut.h"
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+#include "Protocol/GraphicsOutput.h"
+ // Between GOP and UGA draw protocols blt buffer structure remains
+ // the same. The difference is only in the name so we can safely
+ // typedef the new structure to old structure's name.
+typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL;
+#else
+#include "UgaDraw.h"
+#endif
+
+#include "Protocol/ConsoleControl.h"
+#include "Protocol/DevicePath.h"
+#include "Protocol/ComponentName.h"
+//#include "LegacyBios.h"
+#include "Protocol/LoadedImage.h"
+
+
+#if SETUP_ITK_COMPATIBILITY
+#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h"
+#else
+#include "Protocol/EfiOemBadging.h"
+#endif
+
+#include "Protocol/SimpleTextInEx.h"
+//#include "LegacyBios.h"
+#include "AmiDxeLib.h"
+#define EFI_DRIVER_ENTRY_POINT(a)
+
+#include "EDKhelper.h"
+
+// EfiDriverlib
+VOID *
+EfiLibAllocateZeroPool (
+ IN UINTN AllocationSize
+ );
+
+VOID
+EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ );
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ );
+VOID *
+EfiLibAllocatePool (
+ IN UINTN AllocationSize
+ );
+EFI_STATUS
+EFIAPI
+TseEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ );
+EFI_STATUS
+EfiLibReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+EFI_DEVICE_PATH_PROTOCOL *
+EfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ );
+EFI_STATUS
+EfiLibNamedEventSignal (
+ IN EFI_GUID *Name
+ );
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ );
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ );
+
+VOID
+EFIAPI
+EfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ );
+
+UINTN
+SPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ );
+EFI_STATUS
+EfiInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+VOID SetupDebugPrint(IN CONST CHAR8 *Format, ...) ;
+
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_RUNTIME_SERVICES *gRT;
+
+#define EFI_TPL_APPLICATION TPL_APPLICATION
+#define EFI_TPL_CALLBACK TPL_CALLBACK
+#define EFI_TPL_NOTIFY TPL_NOTIFY
+#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL
+
+#ifndef BBS_TYPE_FLOPPY
+#define BBS_TYPE_FLOPPY BBS_FLOPPY
+#endif
+#ifndef BBS_TYPE_HARDDRIVE
+#define BBS_TYPE_HARDDRIVE BBS_HARDDISK
+#endif
+#ifndef BBS_TYPE_CDROM
+#define BBS_TYPE_CDROM BBS_CDROM
+#endif
+#ifndef BBS_TYPE_PCMCIA
+#define BBS_TYPE_PCMCIA BBS_PCMCIA
+#endif
+#ifndef BBS_TYPE_USB
+#define BBS_TYPE_USB BBS_USB
+#endif
+#ifndef BBS_TYPE_EMBEDDED_NETWORK
+#define BBS_TYPE_EMBEDDED_NETWORK BBS_EMBED_NETWORK
+#endif
+#ifndef BBS_TYPE_BEV
+#define BBS_TYPE_BEV BBS_BEV_DEVICE
+#endif
+#ifndef BBS_TYPE_UNKNOWN
+#define BBS_TYPE_UNKNOWN BBS_UNKNOWN
+#endif
+
+#ifndef SCAN_NULL
+#define SCAN_NULL EFI_SCAN_NULL
+#endif
+#ifndef SCAN_UP
+#define SCAN_UP EFI_SCAN_UP
+#endif
+#ifndef SCAN_DOWN
+#define SCAN_DOWN EFI_SCAN_DN
+#endif
+#ifndef SCAN_RIGHT
+#define SCAN_RIGHT EFI_SCAN_RIGHT
+#endif
+#ifndef SCAN_LEFT
+#define SCAN_LEFT EFI_SCAN_LEFT
+#endif
+#ifndef SCAN_HOME
+#define SCAN_HOME EFI_SCAN_HOME
+#endif
+#ifndef SCAN_END
+#define SCAN_END EFI_SCAN_END
+#endif
+#ifndef SCAN_INSERT
+#define SCAN_INSERT EFI_SCAN_INS
+#endif
+#ifndef SCAN_DELETE
+#define SCAN_DELETE EFI_SCAN_DEL
+#endif
+#ifndef SCAN_PAGE_UP
+#define SCAN_PAGE_UP EFI_SCAN_PGUP
+#endif
+#ifndef SCAN_PAGE_DOWN
+#define SCAN_PAGE_DOWN EFI_SCAN_PGDN
+#endif
+#ifndef SCAN_F1
+#define SCAN_F1 EFI_SCAN_F1
+#endif
+#ifndef SCAN_F2
+#define SCAN_F2 EFI_SCAN_F2
+#endif
+#ifndef SCAN_F3
+#define SCAN_F3 EFI_SCAN_F3
+#endif
+#ifndef SCAN_F4
+#define SCAN_F4 EFI_SCAN_F4
+#endif
+#ifndef SCAN_F5
+#define SCAN_F5 EFI_SCAN_F5
+#endif
+#ifndef SCAN_F6
+#define SCAN_F6 EFI_SCAN_F6
+#endif
+#ifndef SCAN_F7
+#define SCAN_F7 EFI_SCAN_F7
+#endif
+#ifndef SCAN_F8
+#define SCAN_F8 EFI_SCAN_F8
+#endif
+#ifndef SCAN_F9
+#define SCAN_F9 EFI_SCAN_F9
+#endif
+#ifndef SCAN_F10
+#define SCAN_F10 EFI_SCAN_F10
+#endif
+#ifndef SCAN_F11
+#define SCAN_F11 EFI_SCAN_F11
+#endif
+#ifndef SCAN_F12
+#define SCAN_F12 EFI_SCAN_F12
+#endif
+#ifndef SCAN_ESC
+#define SCAN_ESC EFI_SCAN_ESC
+#endif
+
+#define CHAR_NULL 0x0000
+#define CHAR_BACKSPACE 0x0008
+#define CHAR_TAB 0x0009
+#define CHAR_LINEFEED 0x000A
+#define CHAR_CARRIAGE_RETURN 0x000D
+#define GLYPH_WIDTH 8
+#define GLYPH_HEIGHT 19
+#define NARROW_CHAR 0xFFF0
+#define WIDE_CHAR 0xFFF1
+#define NON_BREAKING_CHAR 0xFFF2
+
+// BMP
+//
+// Definitions for BMP files
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT8 Blue;
+ UINT8 Green;
+ UINT8 Red;
+ UINT8 Reserved;
+} BMP_COLOR_MAP;
+
+typedef struct {
+ CHAR8 CharB;
+ CHAR8 CharM;
+ UINT32 Size;
+ UINT16 Reserved[2];
+ UINT32 ImageOffset;
+ UINT32 HeaderSize;
+ UINT32 PixelWidth;
+ UINT32 PixelHeight;
+ UINT16 Planes; // Must be 1
+ UINT16 BitPerPixel; // 1, 4, 8, or 24
+ UINT32 CompressionType;
+ UINT32 ImageSize; // Compressed image size in bytes
+ UINT32 XPixelsPerMeter;
+ UINT32 YPixelsPerMeter;
+ UINT32 NumberOfColors;
+ UINT32 ImportantColors;
+} BMP_IMAGE_HEADER;
+
+#pragma pack()
+
+#define EFI_DEFAULT_BMP_LOGO_GUID \
+ {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D}
+
+extern EFI_GUID gEfiDefaultBmpLogoGuid;
+
+///DEVICE PATH Definitions
+#ifndef MSG_USB_WWID_CLASS_DP
+#define MSG_USB_WWID_CLASS_DP 0x10
+#endif
+#ifndef MSG_USB_LOGICAL_UNIT_CLASS_DP
+#define MSG_USB_LOGICAL_UNIT_CLASS_DP 0x11
+#endif
+#ifndef MSG_USB_SATA_DP
+#define MSG_USB_SATA_DP 0x12
+#endif
+#ifndef MSG_USB_ISCSI_DP
+#define MSG_USB_ISCSI_DP 0x13
+#endif
+#endif //TSE_USE_EDK_LIBRARY
+
+//USB Class devices - Device path..
+#define USB_PHY_DEV_CLASS 0x05
+#define USB_MASS_DEV_CLASS 0x08
+
+extern EFI_GUID gEfiGlobalVariableGuid;
+
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+#if TSE_USE_EDK_LIBRARY
+#if EFI_SPECIFICATION_VERSION>=0x2000A
+#define __UEFI_HII__H__
+#include<EfiHii.h>
+#else
+#define __HII_PROTOCOL_H__
+#endif
+#endif //TSE_USE_EDK_LIBRARY
+#include "Protocol/AmiKeyCode.h"
+#else
+#ifndef _AMI_EFI_KEY_DATA_
+#define _AMI_EFI_KEY_DATA_
+typedef struct {
+ EFI_INPUT_KEY Key;
+} AMI_EFI_KEY_DATA;
+#endif
+#endif
+
+#ifdef TSE_FOR_APTIO_4_50
+#include "Include/Protocol/AMIPostMgr.h"
+#else
+#include "AMIPostMgr.h"
+#endif
+
+#include "amiver.h"
+
+//handling version macros as tokens
+//#define TSE_MAJOR 0x02
+//#define TSE_MINOR 0x00
+//#define TSE_BUILD 0x1201
+
+#define MINI_SETUP_DATA_GUID \
+ { 0xFE612B72, 0x203C, 0x47B1, 0x85, 0x60, 0xA6, 0x6D, 0x94, 0x6E, 0xB3, 0x71 }
+
+#include "hiistring.h"
+#include "string.h"
+#include "protocol.h"
+#include "variable.h"
+#include "boot.h"
+#include "AMILogo.h"
+#include "bootflow.h"
+#include "Timer.h"
+
+#ifdef TSE_FOR_APTIO_4_50
+#include "AMITSEStrTokens.h"
+#else
+#include STRING_DEFINES_FILE
+#endif
+
+#ifdef TSE_FOR_APTIO_4_50
+#include "Include/AMIVfr.h"
+#else
+#include "AMIVFR.h"
+#endif
+
+#if TSE_APTIO_5_SUPPORT
+#define AMITSE_TEXT(a) a
+#else
+#define AMITSE_TEXT(a) L##a
+#endif
+
+#include "bbs.h"
+
+///for Hotkey customizations - 6/1/09
+#if TSE_STYLE_SOURCES_SUPPORT
+#include "HotkeyBin.h"
+#include "HotclickBin.h" //EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+#endif
+
+#if TSE_LITE_SOURCES_SUPPORT
+#include "frame.h"
+#include "Label.h"
+#include "hotkey.h"
+#include "hotclick.h"//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+#include "minisetupext.h"
+#endif
+
+#ifndef STRING_TOKEN
+#define STRING_TOKEN(t) t
+#endif
+
+UINTN StyleGetTextMode( UINTN Rows, UINTN Cols );
+VOID StyleUpdateVersionString( VOID );
+UINTN StyleGetClearScreenColor(VOID);
+UINT8 StyleGetPageLinkColor(VOID);
+UINT8 StyleGetScrollBarColor(VOID);
+UINT8 StyleGetScrollBarUpArrowColor(VOID);
+UINT8 StyleGetScrollBarDownArrowColor(VOID);
+
+UINTN StyleGetStdMaxRows(VOID);
+UINTN StyleGetStdMaxCols(VOID);
+VOID GetProgressColor(EFI_UGA_PIXEL * BGColor, EFI_UGA_PIXEL * BDRColor, EFI_UGA_PIXEL * FillColor);
+
+#ifndef STYLE_FULL_MAX_ROWS
+#define STYLE_FULL_MAX_ROWS 31
+#endif
+
+#ifndef STYLE_FULL_MAX_COLS
+#define STYLE_FULL_MAX_COLS 100
+#endif
+
+#ifndef STYLE_STD_MAX_ROWS
+#define STYLE_STD_MAX_ROWS 24
+#endif
+
+#ifndef STYLE_STD_MAX_COLS
+#define STYLE_STD_MAX_COLS 80
+#endif
+
+#ifndef STYLE_MAX_COLS
+#define STYLE_MAX_COLS STYLE_FULL_MAX_COLS
+#endif
+
+#ifndef STYLE_MAX_ROWS
+#define STYLE_MAX_ROWS STYLE_FULL_MAX_ROWS
+#endif
+
+#define MAX_ROWS STYLE_MAX_ROWS
+#define MAX_COLS STYLE_MAX_COLS
+#define MAX_DIMENSIONS (STYLE_FULL_MAX_ROWS * STYLE_FULL_MAX_COLS)
+
+#include "screen.h"
+
+#include "commonoem.h"
+#include "LogoLib.h"
+#include "PwdLib.h"
+#include "HiiLib.h"
+#include "mem.h"
+#include "HookAnchor.h"
+#if TSE_ADVANCED_SUPPORT
+#include "TseElinks.h"
+#endif
+#ifdef TSE_FOR_APTIO_4_50
+#include "AmiStatusCodes.h"
+#else
+#include "EfiStatusCode.h"
+#endif
+
+#ifndef BBS_TYPE_DEV
+#ifdef BBS_TYPE_BEV
+#define BBS_TYPE_DEV BBS_TYPE_BEV
+#else
+#define BBS_TYPE_DEV 0x80
+#endif
+#endif
+/* B1DA0ADF-4F77-4070-A88E-BFFE1C60529A */
+#define MINI_SETUP_GUID \
+ { 0xB1DA0ADF, 0x4F77, 0x4070, { 0xA8, 0x8E, 0xBF, 0xFE, 0x1C, 0x60, 0x52, 0x9A } }
+
+#define SETUP_VARIABLE_GUID \
+ { 0xEC87D643, 0xEBA4, 0x4BB5, { 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 } }
+
+/* 47C7B224-C42A-11D2-8E57-00A0C969723B */
+#define ENVIRONMENT_VARIABLE_ID \
+ { 0x47c7b224, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
+
+// End Notifications
+
+
+// Status code reporting - Defines >> Start
+// Defined in AmiStatusCodes.h
+// Redefining for Aptio 3.x
+#ifndef AMI_STATUS_CODE_CLASS
+#define AMI_STATUS_CODE_CLASS EFI_OEM_SPECIFIC //0x8000
+#endif
+
+#ifndef AMI_DXE_BS_EC_INVALID_PASSWORD
+#define AMI_DXE_BS_EC_INVALID_PASSWORD (AMI_STATUS_CODE_CLASS | 0x00000002)
+#endif
+
+#ifndef AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR
+#define AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR (AMI_STATUS_CODE_CLASS | 0x00000003)
+#endif
+
+#ifndef AMI_DXE_BS_EC_BOOT_OPTION_FAILED
+#define AMI_DXE_BS_EC_BOOT_OPTION_FAILED (AMI_STATUS_CODE_CLASS | 0x00000004)
+#endif
+
+
+#ifndef DXE_SETUP_VERIFYING_PASSWORD
+#define DXE_SETUP_VERIFYING_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD)
+#endif
+
+#ifndef DXE_SETUP_START
+#define DXE_SETUP_START (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
+#endif
+
+#ifndef DXE_SETUP_INPUT_WAIT
+#define DXE_SETUP_INPUT_WAIT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
+#endif
+
+#ifndef DXE_READY_TO_BOOT
+#define DXE_READY_TO_BOOT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
+#endif
+
+#ifndef DXE_INVALID_PASSWORD
+#define DXE_INVALID_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_INVALID_PASSWORD)
+#endif
+
+#ifndef DXE_BOOT_OPTION_LOAD_ERROR
+#define DXE_BOOT_OPTION_LOAD_ERROR (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
+#endif
+
+#ifndef DXE_BOOT_OPTION_FAILED
+#define DXE_BOOT_OPTION_FAILED (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_FAILED)
+#endif
+// Status code reporting -Define >> End
+
+#define NG_SIZE 19
+#define WG_SIZE 38
+
+#ifdef EFI_NT_EMULATOR
+#define RUNTIME_DEBUG_SUPPORT
+#define RUNTIME_DEBUG(str) { if ( __RuntimeCheckDebugMode( str ) ) _asm int 3 }
+#else
+#undef RUNTIME_DEBUG_SUPPORT
+#define RUNTIME_DEBUG(str)
+#endif
+
+#ifndef STANDALONE_APPLICATION
+#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1
+extern SETUP_PKG _SetupPackage;
+#endif
+#else
+extern UINT8 DummySetupData[];
+#endif
+
+
+extern SCREEN_BUFFER *gActiveBuffer;
+extern SCREEN_BUFFER *gFlushBuffer;
+#ifdef USE_DEPRICATED_INTERFACE
+extern UINT8 *STRING_ARRAY_NAME;
+#else
+#if APTIO_4_00
+#else
+extern UINT8 STRING_ARRAY_NAME[];
+#endif
+#endif
+extern UINT8 *gApplicationData;
+extern EFI_HANDLE gImageHandle;
+extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
+extern UINT16 gCheckboxTokens[];
+
+extern BOOLEAN gVariableChanged;
+extern BOOLEAN gResetRequired;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+extern EFI_GRAPHICS_OUTPUT_PROTOCOL *gGOP;
+#else
+extern EFI_UGA_DRAW_PROTOCOL *gUgaDraw;
+#endif
+
+#ifndef STANDALONE_APPLICATION
+extern EFI_CONSOLE_CONTROL_PROTOCOL *gConsoleControl;
+#endif
+
+//EIP75481 Support TSE debug print infrastructure
+
+#define PRINT_UEFI 1
+#define PRINT_UEFI_CALLBACK 2
+#define PRINT_UEFI_NOTIFICATION 4
+#define PRINT_UEFI_PARSE 8
+
+#if SUPPRESS_PRINT
+ #define SETUP_DEBUG_TSE(format,...)
+ #define SETUP_DEBUG_UEFI(format,...)
+ #define SETUP_DEBUG_UEFI_PARSE(format,...)
+ #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...)
+ #define SETUP_DEBUG_UEFI_CALLBACK(format,...)
+ #define SETUP_DEBUG_VAR(format,...)
+#else //Else of SUPPRESS_PRINT
+ #define SETUP_DEBUG_TSE(format,...) SetupDebugPrint(format, __VA_ARGS__)
+ #define SETUP_DEBUG_UEFI(format,...) if((gDbgPrint & PRINT_UEFI)== PRINT_UEFI)SetupDebugPrint(format, __VA_ARGS__)
+ #define SETUP_DEBUG_UEFI_PARSE(format,...) if((gDbgPrint & PRINT_UEFI_PARSE)== PRINT_UEFI_PARSE)SetupDebugPrint(format, __VA_ARGS__)
+ #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...) if((gDbgPrint & PRINT_UEFI_NOTIFICATION)== PRINT_UEFI_NOTIFICATION)SetupDebugPrint(format, __VA_ARGS__)
+ #define SETUP_DEBUG_UEFI_CALLBACK(format,...) if((gDbgPrint & PRINT_UEFI_CALLBACK)== PRINT_UEFI_CALLBACK)SetupDebugPrint(format, __VA_ARGS__)
+ #define SETUP_DEBUG_VAR(format,...) SetupDebugPrint(format, __VA_ARGS__)
+#endif //End of SUPPRESS_PRINT
+//EIP75481
+
+
+extern BOOLEAN gQuietBoot;
+extern BOOLEAN gEnterSetup;
+extern EFI_EVENT gKeyTimer;
+extern EFI_EVENT gClickTimer;
+extern UINT32 gPasswordType;
+
+extern UINTN gPostStatus;
+
+extern BOOT_DATA *gBootData;
+
+extern BOOT_DATA *gCurrLegacyBootData;
+
+extern UINTN gLangCount;
+extern LANGUAGE_DATA *gLanguages;
+
+extern BOOLEAN gSetupContextActive;
+extern BOOLEAN gPostMsgProtocolActive;
+extern UINT8 gPostMgrAttribute;
+extern AMI_VERSION gVersion_TSE;
+extern UINT32 gStartPage;
+
+extern UINTN gLabelLeftMargin ;
+extern UINTN gControlLeftPad ;
+extern UINTN gControlLeftMargin;
+extern UINTN gControlRightAreaWidth;
+
+extern UINTN gMaxRows;
+extern UINTN gMaxCols;
+extern UINTN gPostManagerHandshakeCallIndex;
+extern UINT16 gDbgPrint ;
+
+extern EFI_GUID _gBootFlowGuid;
+extern BOOLEAN gDoNotBoot;
+
+extern UINTN gCurrIDESecPage;
+
+
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+extern EFI_GUID gAmiEfiKeycodeProtocolGuid;
+#endif
+
+//EIP-28501: To support SETUP_STORE_KEYCODE_PASSWORD options
+#define PW_EFI_KEY 1
+#define PW_SCAN_CODE 2
+
+#define DATE_STYLE_MMDDYYYY 0
+#define DATE_STYLE_YYYYDDMM 1
+#define DATE_STYLE_DDMMYYYY 2
+#define DATE_STYLE_YYYYMMDD 3
+
+#define TIMER_ONE_SECOND (10 * 1000 * 1000)
+#define TIMER_HALF_SECOND (TIMER_ONE_SECOND / 2)
+#define TIMER_TENTH_SECOND (TIMER_ONE_SECOND / 10)
+
+#define STRUCT_OFFSET(type, field) (UINTN)&(((type *)0)->field)
+
+typedef struct _PROGRESSBAR_INFO //Structure containing global information used by progressbar handler
+{
+ UINTN x; // ProgressBar Left Position
+ UINTN y; // ProgressBar Top Position
+ UINTN w; // ProgressBar width
+ UINTN h; // ProgressBar Height
+ EFI_UGA_PIXEL *backgroundColor; // ProgressBar Background Color
+ EFI_UGA_PIXEL *borderColor; // ProgressBar Border Color
+ EFI_UGA_PIXEL *fillColor; // ProgressBar Fill Color
+ UINTN delta; // Varies increment
+ UINTN completed; // Varies increment
+ BOOLEAN quiteBootActive; // True if quiteBoot is active
+ BOOLEAN active; // True if progressbar has been initialized
+}PROGRESSBAR_INFO;
+
+extern PROGRESSBAR_INFO *gProgress;
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ ///
+ /// Function Number (0 = First Function).
+ ///
+ UINT8 FunctionNumber;
+} AMITSE_PCCARD_DEVICE_PATH;
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ ///
+ /// Firmware file name
+ ///
+ EFI_GUID FvFileName;
+} AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Tid;
+} AMITSE_I2O_DEVICE_PATH;
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ ///
+ /// The MAC address for a network interface padded with 0s.
+ ///
+ EFI_MAC_ADDRESS MacAddress;
+ ///
+ /// Network interface type(i.e. 802.3, FDDI).
+ ///
+ UINT8 IfType;
+} AMITSE_MAC_ADDR_DEVICE_PATH;
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ ///
+ /// The HBA port number that facilitates the connection to the
+ /// device or a port multiplier. The value 0xFFFF is reserved.
+ ///
+ UINT16 HBAPortNumber;
+ ///
+ /// The Port multiplier port number that facilitates the connection
+ /// to the device. Bit 15 should be set if the device is directly
+ /// connected to the HBA.
+ ///
+ UINT16 PortMultiplierPortNumber;
+ ///
+ /// Logical Unit Number.
+ ///
+ UINT16 Lun;
+} AMITSE_SATA_DEVICE_PATH;
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ ///
+ /// Network Protocol (0 = TCP, 1+ = reserved).
+ ///
+ UINT16 NetworkProtocol;
+ ///
+ /// iSCSI Login Options.
+ ///
+ UINT16 LoginOption;
+ ///
+ /// iSCSI Logical Unit Number.
+ ///
+ UINT64 Lun;
+ ///
+ /// iSCSI Target Portal group tag the initiator intends
+ /// to establish a session with.
+ ///
+ UINT16 TargetPortalGroupTag;
+ ///
+ /// iSCSI NodeTarget Name. The length of the name
+ /// is determined by subtracting the offset of this field from Length.
+ ///
+ /// CHAR8 iSCSI Target Name.
+} AMITSE_ISCSI_DEVICE_PATH;
+
+// box.c
+VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib );
+VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type );
+VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height );
+VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow );
+VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib );
+
+// buffer.c
+EFI_STATUS InitializeScreenBuffer( UINT8 attrib );
+VOID SlowFlushLines( UINTN Top, UINTN Bottom );
+VOID FlushLines( UINTN Top, UINTN Bottom );
+VOID DoRealFlushLines();
+void SetDesiredTextMode();
+
+
+// logo.c
+VOID CleanUpExtendedLogoWrapper();
+VOID DoLogoAnimateWrapper(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY);
+VOID DrawBltProgressBar(/*UINTN completed*/ );
+
+VOID DrawProgressBarBorder(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ EFI_UGA_PIXEL *BltBuffer,
+ UINTN bw
+ );
+
+VOID DrawBlock(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ EFI_UGA_PIXEL *BltBuffer
+ );
+
+
+VOID DrawBltBuffer(
+ EFI_UGA_PIXEL *UgaBlt,
+ CO_ORD_ATTRIBUTE Attribute,
+ UINTN Width,
+ UINTN Height,
+ INTN DestX,
+ INTN DestY,
+ UINTN BufferWidth
+ );
+EFI_STATUS GetScreenResolution(UINTN *ResX, UINTN *ResY);
+
+typedef struct RefreshIdInfo{
+ UINT8 *pEvent;
+ UINT8 *pNotifyContext;
+} REFRESH_ID_INFO;
+
+// dobmpmgr.c
+#if SETUP_BMP_LOGO_SUPPORT
+EFI_STATUS ConvertBmpToUgaBlt (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth );
+#endif
+
+EFI_STATUS
+ConvertAdvancedImageToUgaBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth,
+ OUT BOOLEAN *Animate
+);
+
+VOID DoLogoAnimate(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY);
+VOID CleanUpExtendedLogo(VOID);
+
+
+// minisetup.c
+BOOLEAN __RuntimeCheckDebugMode( CHAR16 *string );
+VOID UIUpdateCallbackHook( VOID * Handle, UINT32 OldVariableCount );//EIP 129750: UIUpdateCallback as board module hook
+EFI_STATUS MainSetupLoopHook( VOID );//EIP74591: MainSetupLoop as board module hook
+EFI_STATUS Handshake( VOID );
+EFI_STATUS MiniSetupExit( EFI_STATUS Status );
+EFI_STATUS MiniSetupEntry( VOID );
+
+//EIP# 58925
+extern UINT32 gNavStartPage ;
+extern EFI_STATUS GetParentFormID(UINT16 ChildID, UINT16 *ParentID, UINT32 *StackIndex);
+extern EFI_STATUS SetParentFormID(UINT16 ParentID, UINT16 TargetID);
+extern VOID ResetNavStack();
+//EIP# 58925
+
+// notify.c
+EFI_STATUS RegisterNotification( VOID );
+VOID NotificationFunction( EFI_EVENT Event, VOID *Context );
+VOID ActivateApplication( VOID );
+
+//EIP-75236 Starts
+VOID ActivateInput( VOID );
+BOOLEAN GetNotifyMaskValue (VOID);
+BOOLEAN IsDelayLogoTillInputSupported (VOID);
+//EIP-75236 Ends
+
+// postmgmt.c
+VOID EncodePassword( CHAR16 *Password, UINTN MaxSize );
+VOID CheckEnableQuietBoot( VOID );
+//UINTN DrawAMILogo( VOID );
+VOID InstallKeyHandlers( VOID );
+VOID InstallClickHandlers( VOID );
+VOID _DrawPasswordWindow(UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos);
+VOID _ReportInBox(UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos, UINTN CurrYPos, BOOLEAN bWaitForReturn);
+EFI_STATUS _GetPassword(CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos, UINTN CurrYPos, UINTN *TimeOut);
+
+// helper functions
+VOID * HelperGetVariable( UINT32 variable, CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size );
+EFI_STATUS InitApplicationData(EFI_HANDLE ImageHandle);
+VOID MiniSetupUIExit(VOID);
+VOID TSEIDEPasswordCheck();
+VOID TSEIDEPasswordFreezeDevices();
+VOID TSEUnlockHDD(VOID);
+extern NVRAM_VARIABLE *gVariableList;
+
+// EIP 76381 : Performance Improving of variable data load and usage
+extern NVRAM_VARIABLE *gCurrNvramVarList;
+extern UINTN gCurrNvramVarCount;
+
+#define VARIABLE_ID_SETUP 0
+#define VARIABLE_ID_LANGUAGE 1
+#define VARIABLE_ID_BOOT_TIMEOUT 2
+#define VARIABLE_ID_USER_DEFAULTS 3
+#define VARIABLE_ID_ERROR_MANAGER 4
+#define VARIABLE_ID_AMITSESETUP 5
+#define VARIABLE_ID_IDE_SECURITY 6
+#define VARIABLE_ID_BOOT_ORDER 7
+#define VARIABLE_ID_BBS_ORDER 8
+#define VARIABLE_ID_DEL_BOOT_OPTION 9
+#define VARIABLE_ID_ADD_BOOT_OPTION 10
+#define VARIABLE_ID_BOOT_MANAGER 11
+#define VARIABLE_ID_BOOT_NOW 12
+#define VARIABLE_ID_LEGACY_DEV_INFO 13
+#define VARIABLE_ID_AMI_CALLBACK 14
+#define VARIABLE_ID_LEGACY_GROUP_INFO 15
+#define VARIABLE_ID_OEM_TSE_VAR 17
+#define VARIABLE_ID_DYNAMIC_PAGE_COUNT 18
+
+UINT16 GetBootTimeOut(UINT16 DefaultValue);
+EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer);
+EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size);
+void UpdateAddDeleteBootVar(void);
+UINT16 * BootNowinBootOrderInit(VOID);
+BOOT_DATA * BootGetBootNowBootData(BOOT_DATA *bootData, UINT16 *BootOrder, UINTN i );
+BOOLEAN NoVarStoreSupport(VOID);
+BOOLEAN ItkSupport(VOID);
+VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups);
+VOID CsmBBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount);
+CHAR16 *CsmBBSBootOptionName( BOOT_DATA *bootData);
+EFI_STATUS CsmBBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev);
+VOID CsmBBSGetDeviceList( VOID );
+EFI_STATUS CsmBBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath );
+EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle);
+VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle);
+EFI_STATUS DoBbsPopupInit(VOID);
+VOID MainSetupLoopInit(VOID);
+UINTN TseGetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background);
+CHAR16 *TseSkipEscCode(CHAR16 *String);
+VOID DrawBootOnlyBbsPopupMenu( VOID );
+VOID BbsBoot(VOID);
+VOID BootGetLanguages();
+
+extern BOOLEAN PlatformLangVerSupport();
+extern BOOLEAN BootNowInBootOrderSupport();
+
+VOID TseBootAddBootOption();
+BOOLEAN CheckForAddDelBootOption();
+VOID TSESpecialFixupDelBootOption(VOID *ControlInfo);
+VOID TseDoAddBootOptionFixup(VOID *ControlInfo );
+BOOLEAN TseDoBootDelBootOption(VOID *popupSel);
+VOID TseDiscardAddDelBootOptions();
+VOID TseSaveAddDelBootOptions();
+
+// EIP-41615: Functions for the file browser support in add boot option
+VOID TseLaunchFileSystem();
+
+VOID TseBBSSetBootPriorities_BootOrder(UINT16 Priority); //EIP-24971: moved TSE_CONTINUE_BOOT_NOW_ON_FAIL support to Binary.
+
+#define ___INTERNAL_CONVERT_TO_WSTRING___(a) L#a
+#define CONVERT_TO_WSTRING(a) ___INTERNAL_CONVERT_TO_WSTRING___(a)
+
+///Extended checks for Add/Delete Boot Option support
+BOOLEAN IsUpdateBootOrderCursor();
+BOOLEAN IsReservedBootOptionNamesEnable();
+BOOLEAN IsPreservedDisabledBootOptionOrder();
+EFI_STATUS FastBootLaunch(VOID);
+extern BOOLEAN gIsSaveDisabledBBSDevicePath;
+VOID UpdateGoPUgaDraw( VOID );//EIP:50479 : Function to Update gGop before using it in AMITSE.
+//EIP:51671 Start
+//Function declarations
+BOOLEAN IsBootDeviceEnabled( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup);
+BOOLEAN BootGetOptionStatus(BOOT_DATA *bootData, BOOLEAN FromSetup );
+BOOLEAN BootGetBBSOptionStatus(BOOT_DATA *bootData, UINT16 value, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev);
+//EIP:51671 End
+VOID RedrawGif(VOID);//EIP:53740 : Function to Redraw the Gif animated image.
+BOOLEAN LoadOptionhidden(UINT16, BOOLEAN); //EIP:59417 - Fucntion Decleration to check the LOAD_OPTION_HIDDEN attribute for a boot option
+EFI_STATUS TSEGetCoordinates(INT32 *x, INT32 *y, INT32 *z);
+BOOLEAN CheckHiddenforBootDriverOption (UINT16, BOOLEAN);
+
+//EIP70421 & 70422 Support for driver order starts
+extern BOOT_DATA *gDriverData;
+void UpdateAddDeleteDriverVar (void);
+VOID TseDriverAddDriverOption();
+VOID TSESpecialFixupDelDriverOption (VOID *);
+BOOLEAN TseDoDriverDelDriverOption(VOID *popupSel);
+VOID TseDiscardAddDelDriverOptions();
+VOID TseSaveAddDelDriverOptions();
+//EIP70421 & 70422 Support for driver order ends
+BOOLEAN IsTSEMultilineControlSupported (VOID); //EIP-72610 Moved TSE_MULTILINE_CONTROLS to binary
+UINT32 GetMsgboxWidth(VOID);//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
+extern const UINTN TsePasswordLength;
+VOID GetAMITSEVariable(AMITSESETUP **mSysConf,UINT8 **setup,UINTN *VarSize);
+VOID NoVarStoreUpdateSystemAccess(UINT8 sysAccessValue);
+VOID SetSystemAccessValueItk(UINT8 sysAccessValue);
+VOID TSEStringReadLoopEntryHook(VOID);
+VOID TSEStringReadLoopExitHook(VOID);
+UINT32 PasswordAuthenticate( CHAR16 *Password );
+EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData);
+EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar);
+VOID TSEIDEUpdateConfig(VOID *ideSecConfig, UINTN value);
+//EIP 77400
+#define EFI_SHELL_PROTOCOL_GUID \
+ { \
+ 0x47C7B223, 0xC42A, 0x11D2, 0x8E, 0x57, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \
+ }
+#endif /* _MINISETUP_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/minisetupext.c b/EDK/MiniSetup/BootOnly/minisetupext.c
new file mode 100644
index 0000000..5065488
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/minisetupext.c
@@ -0,0 +1,927 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetupext.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 16 $
+//
+// $Date: 8/28/14 8:37a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetupext.c $
+//
+// 16 8/28/14 8:37a Premkumara
+// [TAG] EIP142551
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Mouse Movement is not initialized to Full Screen Resolution
+// in case of quiet boot mode with high resolution OEM Logo.
+// [Root Cause] Mouse Initialization was not across the full screen incase
+// of High Resolution Quiet Boot Logo.
+// [Solution] Initialised the Mouse with the Resolution Set in case of
+// Quiet Boot logo so that Mouse will move acroos the Whole screen
+// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c,
+// Notify.c, MinisetupExt.c
+//
+// 15 5/02/14 3:56a Premkumara
+// [TAG] EIP151966
+// [Category] Improvement
+// [Description] Added the implementation for getting the BIOS build
+// year dynamically
+// from TimeStamp.h file and updated the Build year in copyright message
+// in both Setup and POST.
+// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper
+// .c,
+// AmiTSEStr.uni,AMITSE.mak
+//
+// 14 2/11/14 7:59p Arunsb
+// [TAG] EIP131739
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] UI is not Displaying properly after enabling Quite Boot
+// [Root Cause] While doing MainSetupLoopInit() it changes the mode to
+// Text.
+// [Solution] A hook function is created in ESA which keeps the mode as
+// Graphics
+// [Files] minisetupext.c
+//
+// 13 12/04/13 2:10p Premkumara
+// [TAG] EIP123535
+// [Category] Improvement
+// [Description] Moved saving quietboot resolution to DrawQuietBootLogo()
+// to avoid setting resolution of initPostScreenthis while booting.
+// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c
+//
+// 12 12/04/13 5:29a Premkumara
+// [TAG] EIP123535
+// [Category] Improvement
+// [Description] Moved saving quietboot resolution to DrawQuietBootLogo()
+// to avoid setting resolution of initPostScreenthis while booting.
+// [Files] commonoem.c, Boot.c, Logo.c, MinisetupExt.c
+//
+// 11 3/16/13 4:02a Rajashakerg
+// [TAG] EIP107221
+// [Category] Improvement
+// [Description] Logo disappear after HDD password verified
+// [Files] CommonHelper.c, notify.c, minisetupext.c
+//
+// 10 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 5/29/12 4:33a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 8 4/25/12 6:08a Rajashakerg
+// [TAG] EIP86827
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] "gBootFlow" variable should be changed to
+// BOOT_FLOW_CONDITION_NORMAL if we press ESC key from pop-pup menu
+// [RootCause] ProcessProceedToBootHook() is not invoked when we press
+// ESC key in the BBS popup Menu.
+// [Solution] Fixed the issue by calling ProcessProceedToBootHook() when
+// we press ESC key in the BBS popup Menu.
+// [Files] BootOlny/minisetupext.c, TseLite/minisetupext.c.
+//
+// 7 6/23/11 5:32a Rajashakerg
+// [TAG] EIP63073
+// [Category] New Feature
+// [Description] Source modules in TSE should get the version details
+// from binary in run time not at build time
+// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+// EzportPlus\style.c, Legacy\style.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/15/10 10:10p Madhans
+// To avoid Compilation issues
+//
+// 6 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 5 1/09/10 5:28a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/13/09 7:35a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/13/09 2:22p Madhans
+// To patch the version number in the Bootonly TSE. update the build
+// number.
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 3:59p Madhans
+// fix in ClearGrphxScreen
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MINISETUPEXT.C
+//
+// Description: This file contains code for entrypoint and setup loop
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+//**************************** BBS POPUP CODE ********************************//
+
+//#if SETUP_BBS_POPUP_ENABLE
+extern EFI_GUID gBootNowCountGuid;
+UINT16 gBBSPopupSel;
+
+extern NVRAM_VARIABLE *gOptimalDefaults;
+extern UINTN CurrentScreenresolutionX, CurrentScreenresolutionY;//EIP-105717
+
+struct DevName
+{
+ CHAR16 *String;
+ int Index;
+} *gDevNames;
+
+int gHiStr = 0;
+int gStrIdx = 0;
+int gNumOfDev = 0;
+CHAR16 *gBlankSpace = L" ";
+#define START_ROW_IDX 10
+#define START_COL_IDX 20
+#define MAX_STR_LEN 28
+#define MAX_LENGTH (MAX_STR_LEN+7)
+#define MAX_DISP_LINES 8
+
+#define _ENTER_KEY 0x0D
+#define _ESC_KEY 0x170000
+#define _UP_ARROW 0x10000
+#define _DOWN_ARROW 0x20000
+
+void CheckStrings(void);
+void SetScrollPosition(int Index, int DirFlg);
+INTN BBS_GetKey(VOID);
+EFI_STATUS BbsPopupMenu( VOID );
+void HighLightLine(int UpDown, int NumLines);
+void DownDisplayList(int Start, int End, int NumLines);
+void UpDisplayList(int Start, int End, int flag, int NumLines);
+VOID MainSetupLoopInitHook(VOID);
+UINT16 _BootSetBootNowCount(VOID);
+CHAR16 *HiiGetStringLanguage( VOID* handle, UINT16 token, CHAR16 *lang );
+UINT16 HiiChangeStringLanguage( VOID* handle, UINT16 token, CHAR16 *lang, CHAR16 *string );
+VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);//EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message
+BOOLEAN IsMouseSupported(VOID);
+BOOLEAN IsSoftKbdSupported(VOID);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ClearGrphxScreen
+//
+// Description: Function to clear the graphics screen.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void ClearGrphxScreen(void)
+{
+ EFI_UGA_PIXEL UgaBlt={0,0,0,0};
+ UINT32 HorizontalResolution = 0;
+ UINT32 VerticalResolution = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if(gGOP)
+ {
+ HorizontalResolution = gGOP->Mode->Info->HorizontalResolution;
+ VerticalResolution = gGOP->Mode->Info->VerticalResolution;
+ Status = gGOP->Blt (
+ gGOP,
+ &UgaBlt,
+ EfiBltVideoFill,
+ 0, 0,
+ 0, 0,
+ HorizontalResolution, VerticalResolution,
+ 0);
+ }
+#else
+ if ( gUgaDraw != NULL )
+ {
+ gUgaDraw->GetMode (gUgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
+ Status = gUgaDraw->Blt (
+ gUgaDraw,
+ &UgaBlt,
+ EfiUgaVideoFill,
+ 0, 0,
+ 0, 0,
+ HorizontalResolution, VerticalResolution,
+ 0);
+ }
+#endif
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoBbsPopupInit
+//
+// Description: This function runs the loop for Pop up boot menu.
+// This function is responsible for creating the list
+// box control. It also gathers actions and passes them
+// to list box control and initiates draw sequence.
+//
+// Input: BOOT_FLOW *BootFlow: Ptr to BOOT_FLOW responsible for
+// the call.
+//
+// Output: Return Status based on errors that occurred in
+// library functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DoBbsPopupInit(VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 i=0, u16BootCount = 2, *pu16BootCount = NULL;
+ UINTN size = 0;
+ UINT16 count;
+
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ MainSetupLoopInitHook();
+
+ count = (UINT16)gBootOptionCount;
+
+ if(gPopupMenuShowAllBbsDev)
+ count = _BootSetBootNowCount();
+
+ VarSetNvramName( L"BootNowCount", &gBootNowCountGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+
+ Status = VarLoadVariables( (VOID **)&gVariableList, (NVRAM_VARIABLE *)gOptimalDefaults );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+#if APTIO_4_00
+ gMaxRows = MAX_ROWS;
+ gMaxCols = MAX_COLS;
+#endif
+
+ pu16BootCount = VarGetNvramName( L"BootNowCount", &gBootNowCountGuid, NULL, &size );
+ if(pu16BootCount)
+ u16BootCount = *pu16BootCount;
+ MemFreePointer(&pu16BootCount);
+
+ //For Boot Only TSE
+ gDevNames = EfiLibAllocatePool(u16BootCount * (sizeof(*gDevNames)));
+ for (i=0; i<u16BootCount; i++)
+ {
+ //EIP - 24971
+ gDevNames[i].String = BootGetBootNowName(i,gPopupMenuShowAllBbsDev,BootNowInBootOrderSupport());
+ //EIP - 24971
+ gDevNames[i].Index = i;
+ }
+
+ gNumOfDev = u16BootCount;
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBootOnlyBbsPopupMenu
+//
+// Description: function for the BBS Popup menu
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawBootOnlyBbsPopupMenu( VOID )
+{
+ int Row = 0;
+ INTN Key;
+ int DispLines=0;
+ int EnoughOfThis = 0;
+
+ if(gST->ConOut == NULL)
+ return;
+
+ SetDesiredTextMode();
+ // Clean of the Graphics Screen
+ ClearGrphxScreen();
+ ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+
+ //Initialise the global buffers
+ InitializeScreenBuffer( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+
+ //check the lengh of device strings, and truncate if it is out of boundaries
+ CheckStrings();
+
+ //Create heading
+ DrawStringWithAttribute( START_COL_IDX+(MAX_STR_LEN/2)-4, START_ROW_IDX-2, L"BBS MENU", EFI_WHITE);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-3, MAX_LENGTH, 3);
+
+ if( gNumOfDev < MAX_DISP_LINES )
+ {
+ DispLines = gNumOfDev;
+ }
+ else {
+ DispLines = MAX_DISP_LINES;
+ }
+ //print all the avilable device info
+ for( Row=START_ROW_IDX; Row < START_ROW_IDX+DispLines; Row++ ) {
+ DrawStringWithAttribute( START_COL_IDX, Row, gDevNames[Row-START_ROW_IDX].String, EFI_LIGHTGRAY);
+ }
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, DispLines+2);
+
+ //keep the cursor in the staring line of strings display
+ gST->ConOut->SetCursorPosition( gST->ConOut, START_COL_IDX, START_ROW_IDX );
+
+ //highlight first option in the list by default
+ DrawStringWithAttribute( START_COL_IDX, START_ROW_IDX, gDevNames[0].String, EFI_WHITE);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, DispLines+2);
+
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE );
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE );
+
+ SetScrollPosition(DispLines, 2);
+ FlushLines( 0, gMaxRows - 1 );
+ DoRealFlushLines();
+
+ while(TRUE)
+ {
+ //Get input key
+ Key = BBS_GetKey();
+
+ if(_ESC_KEY == Key) {
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+ gBBSPopupSel = 0 ;
+ EnoughOfThis = 1 ;
+ ProcessProceedToBootHook();//EIP 86827 : When ESC pressed in the BBS popup menu
+ break;
+ }
+
+ switch(Key)
+ {
+ case _DOWN_ARROW:
+ if(gStrIdx<(gNumOfDev-1)) {
+ gStrIdx++;
+ if( gHiStr >= (DispLines-1) ) {
+ DownDisplayList(gStrIdx-(DispLines-1), gStrIdx, DispLines);
+ }
+ else {
+ HighLightLine(0, DispLines);
+ }
+ }
+ break;
+
+ case _UP_ARROW:
+
+ if(gStrIdx > 0) {
+ gStrIdx--;
+ if( gHiStr == 0 ) {
+ if(gStrIdx>=0)
+ UpDisplayList(gStrIdx, gStrIdx+(DispLines-1), 0, DispLines);
+ }
+ else if( gHiStr > 0 ) {
+ HighLightLine(1, DispLines);
+ }
+ }
+ break;
+
+ case _ENTER_KEY:
+ if( ( gStrIdx >= 0) && ( gStrIdx <= gNumOfDev) ) {
+ //call the function with the selected device index
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+ gBBSPopupSel = (UINT16) gStrIdx ;
+ EnoughOfThis = 1 ;
+ }
+ break;
+ }
+ DoRealFlushLines();
+ if(EnoughOfThis)
+ break ;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BbsBoot
+//
+// Description: This function is a hook called after launching
+// BBS Popup Menu. This function is available as
+// ELINK. In the generic implementation this function is
+// empty. OEMs may choose to do additional logic here.
+//
+// Input: index: The nth option in the boot now menu.
+// ShowAllBbsDev - SETUP_SHOW_ALL_BBS_DEVICES
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID BbsBoot(VOID)
+{
+ if(gEnterSetup != TRUE)
+ BootLaunchBootNow(gBBSPopupSel, gPopupMenuShowAllBbsDev) ;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BbsStrnCpy
+//
+// Description: function the string copy
+//
+// Input: CHAR16 *Dst, CHAR16 *Src, UINTN Length
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BbsStrnCpy ( CHAR16 *Dst, CHAR16 *Src, UINTN Length )
+{
+ UINTN Index;
+ UINTN SrcLen;
+
+ SrcLen = EfiStrLen (Src);
+
+ Index = 0;
+ while (Index < Length && Index < SrcLen) {
+ Dst[Index] = Src[Index];
+ Index++;
+ }
+
+ for (Index = SrcLen; Index < Length; Index++) {
+ Dst[Index] = 0;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBS_GetKey
+//
+// Description: function to read the input key
+//
+// Input: void
+//
+// Output: ScanCode/UniCode
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INTN BBS_GetKey(VOID)
+{
+ EFI_INPUT_KEY Key;
+ UINTN Index;
+
+ // flush keyboard buffer
+ while ( gST->ConIn->ReadKeyStroke(gST->ConIn,&Key) == EFI_SUCCESS );
+
+ gBS->WaitForEvent( 1, &gST->ConIn->WaitForKey, &Index );
+ gST->ConIn->ReadKeyStroke(gST->ConIn,&Key);
+ return (Key.ScanCode<<16)|Key.UnicodeChar;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckStrings
+//
+// Description: function to validate the stings
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void CheckStrings(void)
+{
+ int idx;
+ UINTN Length=0;
+ CHAR16 TmpStr[50];
+
+ for( idx=0; idx < gNumOfDev; idx++ ) {
+
+
+ Length = EfiStrLen( gDevNames[idx].String );
+
+ if(Length > MAX_STR_LEN)
+ {
+ BbsStrnCpy(TmpStr,L" ",MAX_STR_LEN);
+ BbsStrnCpy(TmpStr, gDevNames[idx].String, (MAX_STR_LEN-3));
+ EfiStrCpy (TmpStr + EfiStrLen(TmpStr),L"...");
+
+ BbsStrnCpy(gDevNames[idx].String,L" ",Length);
+ BbsStrnCpy(gDevNames[idx].String, TmpStr, MAX_STR_LEN);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetScrollPosition
+//
+// Description: function to set the position of the Scroll bar
+//
+// Input: int Index, int DirFlg
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void SetScrollPosition(int Index, int DirFlg)
+{
+ if(gNumOfDev > MAX_DISP_LINES)
+ {
+ if(DirFlg==2) {
+ WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE );
+ }
+ else if( (DirFlg==0) && (gStrIdx>Index-1) ) {
+ if(gStrIdx!= gNumOfDev-1)
+ WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE );
+ WriteCharWithAttribute( START_ROW_IDX, (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_UP_TRIANGLE, EFI_WHITE );
+ }
+ else if( (DirFlg==1) && (gStrIdx<gNumOfDev-Index) ) {
+ WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE );
+ if(gStrIdx!= 0)
+ WriteCharWithAttribute( START_ROW_IDX, (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_UP_TRIANGLE, EFI_WHITE );
+ }
+ else if(DirFlg==0) {
+ WriteCharWithAttribute( (START_ROW_IDX+Index-1), (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_DOWN_TRIANGLE, EFI_WHITE );
+ }
+ else if(DirFlg==1) {
+ WriteCharWithAttribute( START_ROW_IDX, (START_COL_IDX+MAX_LENGTH-5),GEOMETRICSHAPE_UP_TRIANGLE, EFI_WHITE );
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpDisplayList
+//
+// Description: function to display the upside list
+//
+// Input: int Start, int End, int flag, int NumLines
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void UpDisplayList(int Start, int End, int flag, int NumLines)
+{
+ int RowNum, i;
+
+ i= End;
+ for( RowNum=START_ROW_IDX; Start<=End; RowNum++ ) {
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gBlankSpace, 0);
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gDevNames[Start++].String, EFI_LIGHTGRAY);
+ }
+ DrawStringWithAttribute( START_COL_IDX, (RowNum-NumLines), gBlankSpace, 0);
+ DrawStringWithAttribute( START_COL_IDX, (RowNum-NumLines), gDevNames[Start-NumLines].String, EFI_WHITE);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2));
+
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE );
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE );
+
+ SetScrollPosition(NumLines, 1);
+
+ FlushLines( 0, gMaxRows - 1 );
+
+ if(gHiStr) gHiStr--;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DownDisplayList
+//
+// Description: function to display the downside list
+//
+// Input: int Start, int End, int NumLines
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void DownDisplayList(int Start, int End, int NumLines)
+{
+ int RowNum;
+
+ for( RowNum=START_ROW_IDX; Start<End; RowNum++ ) {
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gBlankSpace, 0);
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gDevNames[Start++].String, EFI_LIGHTGRAY);
+ }
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gBlankSpace, 0);
+ DrawStringWithAttribute( START_COL_IDX, RowNum, gDevNames[End].String, EFI_WHITE);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2));
+
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE );
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE );
+
+ SetScrollPosition(NumLines, 0);
+ FlushLines( 0, gMaxRows - 1 );
+
+ if(gHiStr<(NumLines-1)) gHiStr++;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HighLightLine
+//
+// Description: function to hilight a perticular line
+//
+// Input: int UpDown, int NumLines
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void HighLightLine(int UpDown, int NumLines)
+{
+
+ if(UpDown) {
+ DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr-1), gDevNames[gStrIdx].String, EFI_WHITE);
+ DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr), gDevNames[gStrIdx+1].String, EFI_LIGHTGRAY);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2));
+ }
+ else {
+ DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr+1), gDevNames[gStrIdx].String, EFI_WHITE);
+ DrawStringWithAttribute( START_COL_IDX, (START_ROW_IDX+gHiStr), gDevNames[gStrIdx-1].String, EFI_LIGHTGRAY);
+ DrawBorder( START_COL_IDX-3, START_ROW_IDX-1, MAX_LENGTH, (NumLines+2));
+ }
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX+MAX_LENGTH-4),BOXDRAW_VERTICAL_LEFT, EFI_WHITE );
+ WriteCharWithAttribute( START_ROW_IDX-1, (START_COL_IDX-3),BOXDRAW_VERTICAL_RIGHT, EFI_WHITE );
+
+ SetScrollPosition(NumLines, UpDown);
+ FlushLines( 0, gMaxRows - 1 );
+
+ if(UpDown) {
+ if( gHiStr>0 ) gHiStr--;
+ }
+ else{
+ if( gHiStr<(NumLines-1) ) gHiStr++;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitgProgress
+//
+// Description:
+//
+// Input: No Arguments
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InitgProgress( VOID )
+{
+ gProgress = EfiLibAllocateZeroPool(sizeof (PROGRESSBAR_INFO) );
+ gProgress->quiteBootActive = FALSE ;
+ gProgress->active = FALSE ;
+ gProgress->completed = 0 ;
+ gProgress->delta = 0 ;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootOnlyUpdateVersionString
+//
+// Description: Function to update version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BootOnlyUpdateVersionString( VOID )
+{
+ CHAR16 *string = NULL, *newString = NULL;
+ UINTN length,TseMajor,TseMinor, TseBuild;
+ UINT16 TseBuildYear=0;
+ UINTN i;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+ GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild);
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseMajor, TseMinor, TseBuild,TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode, newString );
+ }
+
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SavePostScreen
+//
+// Description: Function to save the post screen
+//
+// Input: UINTN *SizeOfX, UINTN *SizeOfY
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *SavePostScreen( UINTN *SizeOfX, UINTN *SizeOfY )
+{
+ EFI_UGA_PIXEL *UgaBlt = NULL;
+ UINTN UgaBltSize;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE.
+
+ MouseStop();
+ if ( gQuietBoot )
+ {
+ if(EFI_SUCCESS == GetScreenResolution(SizeOfX,SizeOfY))
+ {
+ UgaBltSize = (*SizeOfX) * (*SizeOfY) * sizeof(EFI_UGA_PIXEL);
+ UgaBlt = EfiLibAllocatePool(UgaBltSize);
+
+ if(UgaBlt)
+ {
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ Status = gGOP->Blt(
+ gGOP,
+ UgaBlt,
+ EfiBltVideoToBltBuffer,
+ 0, 0,
+ 0, 0,
+ *SizeOfX, *SizeOfY,
+ 0);
+#else
+ Status = gUgaDraw->Blt(
+ gUgaDraw,
+ UgaBlt,
+ EfiBltVideoToBltBuffer,
+ 0, 0,
+ 0, 0,
+ *SizeOfX, *SizeOfY,
+ 0);
+#endif
+ }
+ }
+ }
+
+ MouseRefresh();
+ return (VOID *)UgaBlt;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RestorePostScreen
+//
+// Description: Function to restore the saved screen
+//
+// Input: VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RestorePostScreen( VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_UGA_PIXEL *Buffer = (EFI_UGA_PIXEL *)UgaBlt;
+
+ MouseStop();
+ if ( Buffer )
+ {
+ if(gConsoleControl != NULL)
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenGraphics );
+
+ if( (NULL != gGOP) && (SizeOfX && SizeOfY) && //If it has vaild gGOP and Resolution
+ ( (SizeOfX != gGOP->Mode->Info->HorizontalResolution) || (SizeOfY != gGOP->Mode->Info->VerticalResolution) ) //If QuietBoot resolution is differ
+ )//EIP-105717
+ {
+ GOPSetScreenResolution(&SizeOfX, &SizeOfY);
+ }
+
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ Status = gGOP->Blt (
+ gGOP,
+ Buffer,
+ EfiBltBufferToVideo,
+ 0, 0,
+ 0, 0,
+ SizeOfX, SizeOfY,
+ 0);
+#else
+ Status = gUgaDraw->Blt (
+ gUgaDraw,
+ Buffer,
+ EfiUgaBltBufferToVideo,
+ 0, 0,
+ 0, 0,
+ SizeOfX, SizeOfY,
+ 0);
+#endif
+ }
+
+ MouseRefresh();
+ // If ConOut is available in System Table the activate the post screen.
+ if ( gST->ConOut != NULL )
+ {
+ //Show post screen if it is not quiet boot or if it is a headless system
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( ! gQuietBoot || !gGOP)
+#else
+ if ( ! gQuietBoot || !gUgaDraw)
+#endif
+ {
+ //Clear the flush buffer to avoid messages missing
+ MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0);
+
+ CleanUpLogo();
+ InitPostScreen();
+ }
+ }
+ MemFreePointer((VOID **) &Buffer);
+
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/notify.c b/EDK/MiniSetup/BootOnly/notify.c
new file mode 100644
index 0000000..8507ac9
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/notify.c
@@ -0,0 +1,1271 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/notify.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 46 $
+//
+// $Date: 8/28/14 8:35a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/notify.c $
+//
+// 46 8/28/14 8:35a Premkumara
+// [TAG] EIP142551
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Mouse Movement is not initialized to Full Screen Resolution
+// in case of quiet boot mode with high resolution OEM Logo.
+// [Root Cause] Mouse Initialization was not across the full screen incase
+// of High Resolution Quiet Boot Logo.
+// [Solution] Initialised the Mouse with the Resolution Set in case of
+// Quiet Boot logo so that Mouse will move acroos the Whole screen
+// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c,
+// Notify.c, MinisetupExt.c
+//
+// 45 7/12/14 5:46p Arunsb
+// [TAG] EIP160126
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] When Softkbd Enabled, Post display gets delayed
+// [Root Cause] If softkbd enabled then TSE waits up to mouse
+// notification.
+// Mouse notification will happen next to installing conin so delayed.
+// [Solution] Mouse initialized only when softkbd present and password
+// installed.
+// Removed NOTIFY_MASK_MOUSE_DRIVER in SETUP_DELAY_LOGO_TILL_INPUT
+// [Files] CommonHelper.c and BootOnly\notify.c
+//
+// 44 5/02/14 3:59a Premkumara
+// [TAG] EIP151966
+// [Category] Improvement
+// [Description] Added the implementation for getting the BIOS build
+// year dynamically
+// from TimeStamp.h file and updated the Build year in copyright message
+// in both Setup and POST.
+// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper
+// .c,
+// AmiTSEStr.uni,AMITSE.mak
+//
+// 43 5/02/14 12:05a Arunsb
+// [TAG] EIP141066,141084,144118
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Keys in USB and PS2 are not working to enter into setup.
+// [Solution] Hanlded ConsoleInHandle proplerly with ConsoleOutHandle
+// when ConIn is available.
+// [Files] Notify.c
+//
+// 42 2/11/14 8:06p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 41 11/26/13 7:57a Premkumara
+// [TAG] EIP141066,141084,144118
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Keys in USB and PS2 are not working to enter into setup.
+// [Solution] Hanlded ConsoleInHandle proplerly with ConsoleOutHandle
+// when ConIn is available.
+// [Files] Notify.c
+//
+// 40 5/23/13 12:56a Arunsb
+// [TAG] EIP103962
+// [Description] Reverting the notify TPL from EFI_TPL_NOTIFY to
+// EFI_TPL_CALLBACK
+// [Files] notify.c
+//
+// 39 4/17/13 1:11a Arunsb
+// [TAG] EIP121116
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] AMI small logo has damage on POST and boot
+// [RootCause] When system starts with higher text resolution more than
+// 100*31 then TSE not setting proper text mode
+// [Solution] Mode set properly
+// [Files] notify.c and postmgmt.c
+//
+// 38 3/16/13 4:00a Rajashakerg
+// [TAG] EIP107221
+// [Category] Improvement
+// [Description] Logo disappear after HDD password verified
+// [Files] CommonHelper.c, notify.c, minisetupext.c
+//
+// 37 3/08/13 2:57a Premkumara
+// [TAG] EIP116451
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When User password alone is set, Setup gets hang in post
+// while validating User Password.
+// [RootCause] ConsoleInHandle is NULL while validating password.
+// [Solution] Setting gST->ConsoleInHandle with "gST->ConsoleInHandle"
+// to locate the Keycode protocol
+// [Files] nofify.c
+//
+// 36 1/27/13 11:36p Rajashakerg
+// [TAG] EIP103962
+// [Category] Improvement
+// [Description] AMITSE Simpletextin, Simpletextout etc event should
+// have high priority.
+// [Files] notify.c
+//
+// 35 12/05/12 4:57a Premkumara
+// [TAG] EIP105717
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Splash logo is not displaying when Admin/User password is
+// set in setup
+// [RootCause] The resolution is not handled properly while drawing
+// QuietBoot logo
+// [Solution] Restoring the QuietBoot logo resolution after drawing
+// password window.
+// [Files] Notify.c
+//
+// 34 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 20 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 32 9/26/12 7:21a Arunsb
+// Avoided calling ActivateInput twice
+//
+// 31 9/26/12 4:08a Premkumara
+// [TAG] EIP98112
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When the SETUP_DELAY_LOGO_TILL_INPUT set to 1,
+// ActivateInput() function called very late.
+// [RootCause] ActivateInput and ProcessconInavailability are not
+// handled properly
+// [Solution] Handled ActivateInput(), ActivateAppilcation() and
+// ProcessConInAvailability() properly when all device are available
+// [Files] Notify.c
+//
+// 30 9/25/12 7:20a Premkumara
+// Updated missed changes for EIP98112
+//
+// 29 9/24/12 10:28a Premkumara
+// [TAG] EIP98112
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When the SETUP_DELAY_LOGO_TILL_INPUT set to 1,
+// ActivateInput() function called very late.
+// [RootCause] ActivateInput and ProcessconInavailability are not
+// handled properly
+// [Solution] Handled ActivateInput(), ActivateAppilcation() and
+// ProcessConInAvailability() properly when all device are available
+// [Files] Notify.c
+//
+// 28 9/21/12 6:14a Arunsb
+// GopEvent corrected
+//
+// 27 9/20/12 11:52a Arunsb
+// [TAG] EIP92497
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] ActivateApplication is delayed when softkeyboard is added
+// [RootCause] Notification functions not handled properly
+// [Solution] Notification functions changed from switch to if condition
+// [Files] notify.c
+//
+// 26 9/18/12 12:50a Rajashakerg
+// [TAG] EIP95518
+// [Category] Improvement
+// [Description] Validate the Gop before usage in all the possible cases
+// and also get instance of Gop through notification
+// [Files] boot.c, notify.c, logo.c
+//
+// 25 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 23 8/29/12 4:22p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 22 8/27/12 6:20a Premkumara
+// [TAG] EIP 94616
+// [Category] Improvement
+// [Description] TSE should not wait for key if fast boot is in progress
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Protocol.c
+//
+// 21 5/28/12 5:47a Premkumara
+// [TAG] EIP75236
+// [Category] Improvement
+// [Description] Add the support to control the GOP dependency in TSE
+// notification.
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
+// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
+//
+// 20 4/27/12 5:29a Rajashakerg
+// [TAG] EIP88435
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Touch does not have functionality at POST
+// [RootCause] Mouse is initialized after getting notification from
+// mousedriver. So mouse avaliable at post and if we click at post, then
+// the button status is not consumed by any other application and mouse
+// pointer stuck at post
+// [Solution] Provided the changes to init the mouse at setup in the
+// absence of softkbd.
+// [Files] notify.c, minisetupext.c
+//
+// 19 1/25/12 8:02a Rajashakerg
+// [TAG] EIP81617
+// [Category] Improvement
+// [Description] Avoiding memory leaks in TSE
+// [Files] hiistring21.c, CommonHelper.c, notify.c
+//
+// 18 1/17/12 8:55a Arunsb
+// Break statement added in NOTIFY_MASK_MOUSE_DRIVER. Without break
+// statement postmessage displayed twice.
+//
+// 17 11/20/11 7:14a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 16 7/19/11 3:00p Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Driver health related variables are updated via
+// notification function.
+// [Files] notify.c, Uefi21Wapper.c and variable.h
+//
+// 15 6/29/11 6:29a Arunsb
+// [TAG] EIP 62631
+// [Category] New Feature
+// [Description] Hot key boot option support in TSE as per UEFI spec.
+// section 3.1.6.
+// Hot boot keys formed in AtivateInput function.
+// [Files] AMITSE.sdl, bootflow.c, bootflow.h, CommonHelper.c,
+// commonoem.c, commonoem.h, boot.c,
+// hiistring20.c, hiistring21.c and notify.c.
+//
+// 14 6/23/11 5:36a Rajashakerg
+// [TAG] EIP63073
+// [Category] New Feature
+// [Description] Source modules in TSE should get the version details
+// from binary in run time not at build time
+// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+// EzportPlus\style.c, Legacy\style.c
+//
+// 13 6/19/11 4:04p Arunsb
+// [TAG] EIP58712
+// [Category] New Feature
+// [Description] To disable the BIOS Signon Message and TSE copyright
+// version in post screen.
+// [Files] amitse.sdl, amitse.mak, commonhelper.c and notify.c
+//
+// 12 4/29/11 4:33p Arunsb
+// For 2.13 public patch release signon message hiding feature is omitted
+//
+// 10 1/06/11 1:53a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP is getting
+// corrupted.
+// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the
+// update function and in switch to posty screen returining status as
+// aborted if the gGOP/gUgaDraw is NULL
+// [Files] protocol.c,notify.c,postmgmt.c
+//
+// 9 12/29/10 2:30a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP getting
+// corrupted.
+// [Solution] Updated gGop/UgaDraw before using it in AMITSE.
+// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 14 9/16/10 3:01p Madhans
+// To avoid compiler warning
+//
+// 13 7/12/10 4:49p Madhans
+// EIP 39113: Sign ON Message Support.
+//
+// 12 6/08/10 5:09p Blaines
+// Added new AMITSE hook (hook33), called when TSE determines that console
+// out is available.
+//
+// 11 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 10 2/15/10 10:10p Madhans
+//
+// 9 2/04/10 11:20p Madhans
+// To avoid calling notification function when entring setup.(in Fastboot
+// case)
+//
+// 8 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 7 1/09/10 5:30a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 6 10/28/09 5:36p Madhans
+//
+// 5 9/25/09 6:37a Sudhirv
+// EIP-26893 : when the DisplayPostMessage() function of the AMI Post
+// Manager protocol is called multiple times, strings are truncated when
+// displayed.
+//
+// 4 9/15/09 9:32a Sudhirv
+// //Fix for EIP 21807 - Version number at the Setup/POST Screen corrupted
+// if other language is chosen
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 3/31/09 3:59p Madhans
+// EIP19632
+//
+// 4 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: notify.c
+//
+// Description: file contains code to support the notification functions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+EFI_GUID gEfiDXEMouseDriverProtocolGuid =
+ EFI_MOUSE_DRIVER_PROTOCOL_GUID;
+#include "TseDrvHealth.h" //Has TSE related driver health structures
+
+#define NOTIFY_MASK_UGA (0x00000001)
+#define NOTIFY_MASK_CONSOLE_CONTROL (0x00000002)
+#define NOTIFY_MASK_CONSOLE_IN (0x00000004)
+#define NOTIFY_MASK_CONSOLE_OUT (0x00000008)
+#define NOTIFY_MASK_MOUSE_DRIVER (0x00000010)
+BOOLEAN IsDriverHealthSupported (VOID);
+////////////////////////////////////////////////////////////
+/// VARIABLE DECLARATIONS
+///////////////////////////////////////////////////////////
+typedef struct _NOTIFICATION_INFO
+{
+ EFI_HANDLE NotifyHandle;
+ EFI_EVENT NotifyEvent;
+ UINT32 NotifyMask;
+ EFI_GUID *NotifyGuid;
+ BOOLEAN NotifyDevicePath;
+ VOID *NotifyRegistration;
+ VOID *NotifyProtocol;
+ VOID **pgProtocol;
+}
+NOTIFICATION_INFO;
+
+#ifndef STANDALONE_APPLICATION
+static UINT32 gGlobalNotify = 0;
+BOOLEAN gQuietBoot = FALSE;
+VOID ActivateInput(VOID);
+
+static NOTIFICATION_INFO _gUgaNotify =
+{
+ NULL, //EFI_HANDLE NotifyHandle;
+ NULL, //EFI_EVENT NotifyEvent;
+ NOTIFY_MASK_UGA, //UINT32 NotifyMask;
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ &gEfiGraphicsOutputProtocolGuid, //EFI_GUID *NotifyGuid;
+#else
+ &gEfiUgaDrawProtocolGuid, //EFI_GUID *NotifyGuid;
+#endif
+ TRUE, //BOOLEAN NotifyDevicePath;
+ NULL, //VOID *NotifyRegistration;
+ NULL, //VOID *NotifyProtocol;
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ (VOID**)&gGOP //VOID **pgProtocol;
+#else
+ (VOID**)&gUgaDraw //VOID **pgProtocol;
+#endif
+};
+
+static NOTIFICATION_INFO _gConsoleControlNotify =
+{
+ NULL, //EFI_HANDLE NotifyHandle;
+ NULL, //EFI_EVENT NotifyEvent;
+ NOTIFY_MASK_CONSOLE_CONTROL, //UINT32 NotifyMask;
+ &gEfiConsoleControlProtocolGuid, //EFI_GUID *NotifyGuid;
+ FALSE, //BOOLEAN NotifyDevicePath;
+ NULL, //VOID *NotifyRegistration;
+ NULL, //VOID *NotifyProtocol;
+ NULL //(VOID**)&gConsoleControl //VOID **pgProtocol;
+ //gConsoleControl is used by PostManagerHAndshake to know if ActivateApplication has been called
+ //if we allow Notification function to set it, when PostManager handshake need to call ActivateApplication as in case of
+ //headless system, the call may be missed.
+};
+
+static NOTIFICATION_INFO _gConInNotify =
+{
+ NULL, //EFI_HANDLE NotifyHandle;
+ NULL, //EFI_EVENT NotifyEvent;
+ NOTIFY_MASK_CONSOLE_IN, //UINT32 NotifyMask;
+ &gEfiSimpleTextInProtocolGuid, //EFI_GUID *NotifyGuid;
+ FALSE, //BOOLEAN NotifyDevicePath;
+ NULL, //VOID *NotifyRegistration;
+ NULL, //VOID *NotifyProtocol;
+ NULL //(VOID**)&gConIn //VOID **pgProtocol;
+};
+
+static NOTIFICATION_INFO _gConOutNotify =
+{
+ NULL, //EFI_HANDLE NotifyHandle;
+ NULL, //EFI_EVENT NotifyEvent;
+ NOTIFY_MASK_CONSOLE_OUT, //UINT32 NotifyMask;
+ &gEfiSimpleTextOutProtocolGuid, //EFI_GUID *NotifyGuid;
+ FALSE, //BOOLEAN NotifyDevicePath;
+ NULL, //VOID *NotifyRegistration;
+ NULL, //VOID *NotifyProtocol;
+ NULL //(VOID**)&gConOut //VOID **pgProtocol;
+};
+
+static NOTIFICATION_INFO _gMousedriverNotify =
+{
+ NULL, //EFI_HANDLE NotifyHandle;
+ NULL, //EFI_EVENT NotifyEvent;
+ NOTIFY_MASK_MOUSE_DRIVER, //UINT32 NotifyMask;
+ &gEfiDXEMouseDriverProtocolGuid, //EFI_GUID *NotifyGuid;
+ FALSE, //BOOLEAN NotifyDevicePath;
+ NULL, //VOID *NotifyRegistration;
+ NULL, //VOID *NotifyProtocol;
+ NULL //VOID **pgProtocol;
+};
+
+
+static NOTIFICATION_INFO *_gNotifyList[] =
+{
+ &_gUgaNotify,
+ &_gConsoleControlNotify,
+ &_gConInNotify,
+ &_gConOutNotify,
+ &_gMousedriverNotify,
+ NULL
+};
+
+#if APTIO_4_00
+EFI_STATUS FvReadResources (
+ IN EFI_GUID *NameGuid,
+ IN EFI_GUID *pGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize
+ );
+
+// Signon Section Guide
+// {2EBE0275-6458-4af9-91ED-D3F4EDB100AA}
+#define SGN_ON_SECTION_GUID {0x2ebe0275, 0x6458, 0x4af9, 0x91, 0xed, 0xd3, 0xf4, 0xed, 0xb1, 0x0, 0xaa}
+
+// Signon file guid
+// {A59A0056-3341-44b5-9C9C-6D76F7673817}
+// {0xa59a0056, 0x3341, 0x44b5, 0x9c, 0x9c, 0x6d, 0x76, 0xf7, 0x67, 0x38, 0x17};
+#define SGN_ON_FILE_GUID {0xa59a0056, 0x3341, 0x44b5, 0x9c, 0x9c, 0x6d, 0x76, 0xf7, 0x67, 0x38, 0x17}
+
+typedef struct _SIGNON
+{
+ UINT8 Sig[5];
+ UINT8 Ver;
+ UINT16 Reserved;
+ CHAR8 SgnMsg1[];
+}AMI_SIGN_ON;
+
+#endif
+////////////////////////////////////////////////////////////
+/// EXTERN VARIABLES
+///////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////
+/// FUNCTIONS DECLARATIONS
+///////////////////////////////////////////////////////////
+VOID FindandSetHotKeys (VOID);
+UINT8 IsSetupHideBiosSignOnMsg (void);
+VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);//EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message
+VOID SetDriverHealthCount (VOID);
+BOOLEAN IsMouseSupported(VOID);
+BOOLEAN IsSoftKbdSupported(VOID);
+BOOLEAN TseIgnoreKeyForFastBoot(); //EIP-94616
+
+VOID *SavePostScreen( UINTN *SizeOfX, UINTN *SizeOfY );
+VOID RestorePostScreen( VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY );
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DrvHealthNotifyFunction
+//
+// Description: Notification function for driver health protocol instal.
+//
+// Input: EFI_EVENT , VOID *
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DrvHealthNotifyFunction (EFI_EVENT Event, VOID *Context)
+{
+ SetDriverHealthCount ();
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _UpdateGoPNotifyFunction
+//
+// Description: Notification function for driver health protocol instal.
+//
+// Input: EFI_EVENT , VOID *
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _UpdateGoPNotifyFunction (EFI_EVENT Event, VOID *Context)
+{
+ UpdateGoPUgaDraw();//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RegisterNotification
+//
+// Description: It will create a notify event and register a notification.
+//
+// Input: VOID
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RegisterNotification( VOID )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINTN i;
+ EFI_EVENT Event, GopEvent;
+ EFI_GUID EfiDriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID;
+ VOID *Registration = NULL, *GopRegistration = NULL;
+
+ NOTIFICATION_INFO **notify = _gNotifyList;
+
+ for ( i = 0; *notify != NULL; i++, notify++ )
+ {
+ Status = gBS->CreateEvent(
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ NotificationFunction,
+ *notify,
+ &((*notify)->NotifyEvent)
+ );
+
+ if ( EFI_ERROR(Status) )
+ continue;
+
+ Status = gBS->RegisterProtocolNotify(
+ (*notify)->NotifyGuid,
+ (*notify)->NotifyEvent,
+ &((*notify)->NotifyRegistration)
+ );
+
+ // get any of these events that have occured in the past
+ gBS->SignalEvent( (*notify)->NotifyEvent );
+ }
+ if (IsDriverHealthSupported ()) //EIP 57661 Notifying the driver health protocol installation to update the drv health variable in cache
+ {
+ Status = gBS->CreateEvent(
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ _DrvHealthNotifyFunction,
+ NULL,
+ &Event
+ );
+ if (!EFI_ERROR (Status))
+ {
+ Status = gBS->RegisterProtocolNotify(
+ &EfiDriverHealthProtocolGuid,
+ Event,
+ &Registration
+ );
+ if (!EFI_ERROR(Status))
+ {
+ gBS->SignalEvent (Event);
+ }
+ }
+ }
+
+//EIP 95518 : Validate the Gop before usage in all the possible cases and also get instance of Gop through notification
+ Status = gBS->CreateEvent(
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ _UpdateGoPNotifyFunction,
+ NULL,
+ &GopEvent
+ );
+ if (!EFI_ERROR (Status))
+ {
+ Status = gBS->RegisterProtocolNotify(
+ &gEfiGraphicsOutputProtocolGuid,
+ GopEvent,
+ &GopRegistration
+ );
+ if (!EFI_ERROR(Status))
+ {
+ gBS->SignalEvent (GopEvent);
+ }
+ }
+
+ return Status;
+}
+
+#if 0
+static _gConOutCount = 0;
+#endif
+
+#if !APTIO_4_00
+extern EFI_GUID gEfiConsoleOutDeviceGuid;
+
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NotificationFunction
+//
+// Description: function to perform the notification operations.
+//
+// Input: EFI_EVENT Event, NOTIFICATION_INFO *Context
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID NotificationFunction( EFI_EVENT Event, NOTIFICATION_INFO *Context )
+{
+ EFI_STATUS Status;
+ UINTN Count = 0;
+ EFI_HANDLE *HandleBuffer = NULL;
+ BOOLEAN found = FALSE;
+ UINT32 ModSomething = 0;
+// NOTIFICATION_INFO *Context = NotificationContext;
+ void *MouseDriverProtocol = NULL;
+ UINT32 PasswordInstalled = AMI_PASSWORD_NONE;
+ static BOOLEAN ActivateInputDone = FALSE;
+
+ if ( Context == NULL )
+ return;
+
+ // Do nothing on Notification when Enters to setup/BBSPopup/Booting.
+ if(gPostStatus >= TSE_POST_STATUS_ENTERING_TSE)
+ return;
+
+ //According to UEFI spec 2.0.: When LocateHandleBuffer() is called
+ //with ByRegisterNotify it returns the next handle that is new
+ //for the registration. Only one handle is returned at a time and
+ //the caller must loop until no more handles.
+ do
+ {
+ Status = gBS->LocateHandleBuffer(
+ ByRegisterNotify,
+ NULL,
+ Context->NotifyRegistration,
+ &Count,
+ &HandleBuffer
+ );
+
+ if (EFI_ERROR( Status ))
+ break;
+
+ if(0 != Count)
+ {
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = gBS->HandleProtocol( HandleBuffer[0], &gEfiDevicePathProtocolGuid, &DevicePath );
+
+#if !APTIO_4_00
+ if(Context == &_gConOutNotify) //Special handling for ConOut
+ {
+ if(
+ (_gUgaNotify.NotifyHandle) && //Wait until local console is initiated
+ (EFI_ERROR(Status)) //This is the notification for the virtual ConOut device
+ )
+ {
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer = NULL;
+ UINTN EntryCount = 0, Index;
+
+ Status = gBS->OpenProtocolInformation(
+ _gUgaNotify.NotifyHandle,
+ &gEfiConsoleOutDeviceGuid,
+ &OpenInfoBuffer,
+ &EntryCount
+ );
+ if(EFI_SUCCESS == Status)
+ {
+ for (Index = 0; Index < EntryCount; Index++)
+ {
+ if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER)
+ {
+ found = TRUE;
+ }
+ }
+
+ MemFreePointer((VOID **) &OpenInfoBuffer);
+
+ if(found)
+ break;
+ }
+ }
+ }
+ else
+ {
+#endif
+ //Check if notification for this protocol has to have a
+ //device path
+ if(Context->NotifyDevicePath)
+ {
+ if ( !EFI_ERROR( Status ))
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ else
+ {
+ found = TRUE;
+ break;
+ }
+
+#if !APTIO_4_00
+ }
+#endif
+
+ MemFreePointer( (VOID **)&HandleBuffer );
+ }
+
+ }while(Count);
+
+#if 0
+ if ( Context == &_gConOutNotify )
+ {
+ if ( _gConOutCount == 0 )
+ {
+ if(found)
+ {
+ MemFreePointer( (VOID **)&HandleBuffer );
+ found = FALSE;
+ }
+ }
+
+ _gConOutCount++;
+ }
+#endif
+
+ if ( ! found )
+ return;
+
+ Context->NotifyHandle = HandleBuffer[0];
+
+ MemFreePointer( (VOID **)&HandleBuffer );
+
+ RUNTIME_DEBUG( L"notify" );
+
+ Status = gBS->HandleProtocol( Context->NotifyHandle, Context->NotifyGuid, (VOID **)&Context->NotifyProtocol );
+ if( Context->pgProtocol )
+ *(Context->pgProtocol) = Context->NotifyProtocol;
+
+ if ( gGlobalNotify & Context->NotifyMask )
+ return;
+
+ if(Context->NotifyMask != NOTIFY_MASK_CONSOLE_IN)
+ gGlobalNotify |= Context->NotifyMask;
+ else
+ { //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL. Otherwise not all the ConIn Connected.
+ if(gST->ConIn != NULL )
+ {
+ gGlobalNotify |= Context->NotifyMask;
+ gST->ConsoleInHandle = gST->ConsoleOutHandle;//EIP-141066 Context->NotifyHandle; //EIP:116451, To assign the "gST->ConsoleInHandle" to locate the Keycode protocol.
+ }
+ }
+
+ ModSomething = GetNotifyMaskValue(); //EIP-75236
+ /*if(IsSoftKbdSupported())
+ {//Checking for the presence of Softkbd
+ ModSomething = SOMETHING;
+ }
+ else
+ {//If softkbd is not present the unmasking the mousedriver notify from something
+ ModSomething = SOMETHING & (~NOTIFY_MASK_MOUSE_DRIVER);
+ }*/
+ //EIP-98112 & 92497 Starts
+//Commented because ActivateInput getting called twice
+ /*if (NOTIFY_MASK_CONSOLE_IN == Context->NotifyMask) //EIP92497 if softkbd presented then ActivateApplication invoked in postmanager only
+ { //So changed the logic from switch to if
+ //Check if Input has been activated and if yes Activate input
+ //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL
+ if ( !IsDelayLogoTillInputSupported() ) //EIP-75236
+ {
+ if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) )
+ {
+ ActivateInput();
+ }
+ }
+ }*/
+ if (NOTIFY_MASK_MOUSE_DRIVER == Context->NotifyMask)
+ {
+ if(IsMouseSupported()&& IsSoftKbdSupported())//EIP 88435 : Initializing the mouse at post when mouse and softkbd present
+ {
+ MouseInit(); //If mouse is notified then Initializing the mouse
+ InstallClickHandlers (); //EIP160126 install click handlers in notification itself. In other places installing click handler is removed.
+ }
+ }
+ if (((gGlobalNotify & ModSomething) == ModSomething)) //EIP92497 if gConsoleControl is not validated then ActivateApplication will be invoked twice
+ {
+ /*//All necessary protocols available activate output
+ if (NULL == gConsoleControl) //If kept outside then activateinput wont get call succesully
+ {
+ ActivateApplication();
+ }*/
+
+ //If Simple Text Input already available but input has not been activated yet activate now
+ //EIP19632: ConIn Notification is only valid with gST->ConIn != NULL
+ if (IsDelayLogoTillInputSupported ()) //EIP-75236
+ {
+ if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) && (FALSE == ActivateInputDone))
+ {
+ if (IsMouseSupported()&& IsSoftKbdSupported()) //EIP160126 if softkbd & password presents wait until mouse notify
+ {
+ PasswordInstalled = PasswordCheckInstalled();
+ if(CheckSystemPasswordPolicy(PasswordInstalled))
+ {
+ Status = gBS->LocateProtocol(&gEfiDXEMouseDriverProtocolGuid, NULL, &MouseDriverProtocol);
+ if (EFI_ERROR (Status))
+ {
+ return;
+ }
+ }
+ }
+ ActivateApplication();
+ ActivateInput();
+ ActivateInputDone = TRUE;
+ }
+ }
+ else
+ {
+ if (NULL == gConsoleControl)
+ {
+ ActivateApplication ();
+ }
+ if( (( gGlobalNotify & ModSomething ) == ModSomething) && ( gST->ConIn != NULL ) && (FALSE == ActivateInputDone)) //EIP-98112
+ {
+ if (IsMouseSupported()&& IsSoftKbdSupported()) //EIP160126 if softkbd & password presents wait until mouse notify
+ {
+ PasswordInstalled = PasswordCheckInstalled();
+ if(CheckSystemPasswordPolicy(PasswordInstalled))
+ {
+ Status = gBS->LocateProtocol(&gEfiDXEMouseDriverProtocolGuid, NULL, &MouseDriverProtocol);
+ if (EFI_ERROR (Status))
+ {
+ return;
+ }
+ }
+ }
+ ActivateInput();
+ ActivateInputDone = TRUE;
+ }
+ }
+ }
+ //EIP-98112 & 92497 Ends
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActivateApplication
+//
+// Description: function for the Active application operations.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ActivateApplication( VOID )
+{
+ CHAR16 *text=NULL,*newString=NULL, *text2=NULL;
+ UINTN length, TseMajor,TseMinor, TseBuild;
+ UINT16 TseBuildYear=0;
+#if APTIO_4_00
+ UINTN ConCols,ConRows;
+#endif
+ gConsoleControl = (EFI_CONSOLE_CONTROL_PROTOCOL *)_gConsoleControlNotify.NotifyProtocol;
+
+ BootGetLanguages();
+ CheckEnableQuietBoot ();
+ if(gST->ConOut != NULL)
+ {
+#if !APTIO_4_00
+ SetDesiredTextMode();
+#else
+//eip:26893-Start
+ if(EFI_ERROR(gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, &ConCols, &ConRows )))
+ {
+ gMaxRows = StyleGetStdMaxRows();
+ gMaxCols = StyleGetStdMaxCols();
+ }
+ else
+ {
+ if((gMaxRows > ConRows) && (gMaxCols > ConCols))
+ {
+ // In Aptio 4.x use the Text mode as is it in post screen (Set by the Core)
+ // Old Post messages already provided may be affected.
+ // Preserve Post messages
+ PreservePostMessages(ConCols, gMaxCols);
+ gMaxRows = ConRows;
+ gMaxCols = ConCols;
+ }
+ else if ((gMaxRows < ConRows) && (gMaxCols < ConCols) && (!gQuietBoot)) //EIP94702 Desired Text mode will be set at InitPostScreen, if quiet boot dont set mode for seamless boot
+ {
+ // Current screen mode is bigger then the TSE supports.
+ // TSE sets DesiredTextMode
+ SetDesiredTextMode();
+ }
+ }
+//eip:26893-end
+#endif
+ }
+#if APTIO_4_00
+ {
+ EFI_GUID SgnFile = SGN_ON_FILE_GUID;
+ EFI_GUID SgnSection = SGN_ON_SECTION_GUID;
+ AMI_SIGN_ON *SignOn;
+ VOID *pSection;
+ UINTN SectionSize;
+ EFI_STATUS Status;
+ CHAR8 *SgnMsg2;
+
+ Status = FvReadResources (&SgnFile, &SgnSection,(VOID**)&pSection,&SectionSize);
+ if (! EFI_ERROR( Status ) ) {
+ SignOn = (AMI_SIGN_ON*)((UINT8 *)pSection + sizeof(EFI_GUID));
+ if( (MemCmp( (UINT8*)&SignOn->Sig, (UINT8*)"$SGN$",5) == 0) && (SignOn->Ver >= 2))
+ {
+ text = StrDup8to16( SignOn->SgnMsg1 );
+ if (!IsSetupHideBiosSignOnMsg ())
+ {
+ SgnMsg2 = ((UINT8 *)&SignOn->SgnMsg1 + StrLen8(SignOn->SgnMsg1)+1);
+ text2 = StrDup8to16( SgnMsg2 );
+ }
+ }
+ }
+ else
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT) );
+ }
+#else
+ //EIP 21807 - Version number at the Setup/POST Screen corrupted if other language is chosen
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT) );
+#endif
+
+ if ( text != NULL )
+ {
+ length = EfiStrLen(text) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+ GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild);
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), text, TseMajor, TseMinor, TseBuild,TseBuildYear );
+ PostManagerDisplayPostMessage(newString);
+ MemFreePointer( (VOID **)&newString );
+ }
+ else
+ PostManagerDisplayPostMessage(text);
+ MemFreePointer( (VOID **)&text );
+ }
+ // Sign on OEM String
+ if(text2 != NULL)
+ {
+ PostManagerDisplayPostMessage(text2);
+ MemFreePointer( (VOID **)&text2 );
+ }
+
+ if (IsDelayLogoTillInputSupported()) //EIP-75236
+ ProcessConInAvailabilityHook();
+
+#ifdef EFI_NT_EMULATOR
+ gGlobalNotify = gGlobalNotify | NOTIFY_MASK_CONSOLE_OUT;
+#endif
+
+ if ( gGlobalNotify & NOTIFY_MASK_UGA )
+ {
+ if ( gQuietBoot )
+ {
+ gPostStatus = TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN;
+ if(gConsoleControl != NULL)
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenGraphics );
+ DrawQuietBootLogoHook();
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+ gProgress->quiteBootActive = TRUE ;
+ if(gProgress->active)
+ PostManagerSetProgressBarPosition() ;
+
+ }
+ }
+
+// if ( gGlobalNotify & NOTIFY_MASK_CONSOLE_OUT )
+ if ( gST->ConOut != NULL ) // If ConOut is available in System Table the display the post messages.
+ {
+ //Show post screen if it is not quiet boot or if it is a headless system
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( ! gQuietBoot || !gGOP)
+#else
+ if ( ! gQuietBoot || !gUgaDraw)
+#endif
+ {
+ CleanUpLogo();
+ InitPostScreen();
+ }
+
+ ProcessConOutAvailableHook();
+ }
+
+ if (IsDelayLogoTillInputSupported()) //EIP-75236
+ {
+ if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616
+ InstallKeyHandlers();
+/*
+ //Lets install mouse click event in NotificationFunction itself
+ if( IsMouseSupported() && IsSoftKbdSupported())//EIP62763 : Checking for mouse and softkbd presence
+ InstallClickHandlers();
+*/
+ }
+}
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActivateInput
+//
+// Description: function for the active Input.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ActivateInput( VOID )
+{
+// EFI_STATUS Status; Set not used
+ VOID *UgaBlt = NULL;
+ UINTN SizeOfX=0, SizeOfY=0;
+ BOOLEAN bRedraw = FALSE; //If not initialized then on delay till logo input case we always restoring post due to garabage initialization
+
+ FindandSetHotKeys ();
+ // if it is quiet boot copy the screen for later restoration
+ if ( gGlobalNotify & NOTIFY_MASK_UGA )
+ {
+ UgaBlt = SavePostScreen(&SizeOfX, &SizeOfY);
+ }
+
+ if (!IsDelayLogoTillInputSupported()) //EIP-98112
+ {
+ bRedraw = ProcessConInAvailabilityHook();
+ }
+
+ //Restore
+ if(bRedraw)
+ {
+ RestorePostScreen (UgaBlt, SizeOfX, SizeOfY);
+ }
+ else
+ {
+ MemFreePointer((VOID **) &UgaBlt); //if redraw required this buffer will be freed in RestorePostScreen
+ }
+
+ if (!IsDelayLogoTillInputSupported()) //EIP-98112
+ {
+ if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616
+ InstallKeyHandlers();
+/*
+ //Lets install mouse click event in NotificationFunction itself
+ if( IsMouseSupported() && IsSoftKbdSupported())//EIP62763 : Checking for mouse and softkbd presence
+ InstallClickHandlers();
+*/
+ }
+}
+
+//EIP:50479 : Start
+//Function to update gGop
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateGoPUgaDraw
+//
+// Description: function to update the Gop when controls comes to TSE.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID UpdateGoPUgaDraw( VOID )
+{
+ EFI_STATUS Status;
+ UINTN Count = 0;
+ UINTN Index=0;
+ EFI_HANDLE *HandleBuffer = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ BOOLEAN found = FALSE;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL//EIP:50479 Initializing gGOP/gUgaDraw to NULL before locating
+gGOP = NULL;
+#else
+gUgaDraw = NULL;
+#endif
+
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol,
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ &gEfiGraphicsOutputProtocolGuid,
+#else
+ &gEfiUgaDrawProtocolGuid,
+#endif
+ NULL,
+ &Count,
+ &HandleBuffer
+ );
+
+ for(Index=0;Index < Count;Index++)
+ {
+ Status = gBS->HandleProtocol( HandleBuffer[Index], &gEfiDevicePathProtocolGuid, &DevicePath );
+ if (EFI_ERROR( Status ))
+ continue;
+#if !APTIO_4_00
+ {
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer = NULL;
+ UINTN EntryCount = 0, i;
+
+ Status = gBS->OpenProtocolInformation(
+ HandleBuffer[Index],
+ &gEfiConsoleOutDeviceGuid,
+ &OpenInfoBuffer,
+ &EntryCount
+ );
+ if(EFI_SUCCESS == Status)
+ {
+ for (i = 0; i < EntryCount; i++)
+ {
+ if (OpenInfoBuffer[i].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER)
+ {
+ found = TRUE;
+ }
+ }
+ MemFreePointer((VOID **) &OpenInfoBuffer);
+ }
+ }
+#else
+ found = TRUE;
+#endif
+ if(!found)
+ continue;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ Status = gBS->LocateProtocol(
+ &gEfiGraphicsOutputProtocolGuid,
+ NULL, // Registration key
+ &gGOP //VOID **pgProtocol;
+ );
+ if(EFI_ERROR(Status))
+ gGOP = NULL;
+#else
+ Status = gBS->LocateProtocol(
+ &gEfiUgaDrawProtocolGuid,
+ NULL, // Registration key
+ &gUgaDraw //VOID **pgProtocol;
+ );
+ if(EFI_ERROR(Status))
+ gUgaDraw = NULL;
+#endif
+ }
+
+ //81617 : Avoiding memory leaks in TSE
+ MemFreePointer( (VOID **)&HandleBuffer );
+
+}
+//EIP:50479 : End
+#endif // STANDALONE_APPLICATION
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/password.c b/EDK/MiniSetup/BootOnly/password.c
new file mode 100644
index 0000000..a03bf4d
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/password.c
@@ -0,0 +1,253 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 5/08/14 9:17p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.c $
+//
+// 7 5/08/14 9:17p Arunsb
+// TsePasswordEncodeLocal function moved to PasswordEncode module
+//
+// 6 5/02/14 9:27p Arunsb
+// TsePasswordEncodeLocal function moved to source
+//
+// 5 5/02/14 2:04a Premkumara
+// TAG] EIP162197
+// [Category] Improvement
+// [Description] Password encode feature modify to encode using Hashing
+// based on token.
+// [Files] Password.c, PasswordEncodeBin.cif, AMITSE.cif,
+// TSESource.cif, PasswordEncode.c, PasswordEncode.h, AMITSE.sdl,
+// CommonHelper.c, PasswordEncodeBin.mak, PasswordEncodeBin.sdl
+//
+// 4 5/22/13 10:37a Arunsb
+// EIP123047 -
+//
+// 3 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 12/08/11 12:46p Rajashakerg
+// [TAG] EIP63190
+// [Category] New Feature
+// [Description] Security operations in BootOnly module instead of
+// TSELite. GetAMITSEVariableLocal moved to tselite.
+//
+// 1 12/08/11 4:54a Arunsb
+// EIP63190 => Moving password support from TSELite to BootOnly
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 7/09/09 12:29p Mallikarjunanv
+// updated the password encoding fix
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: password.c
+//
+// Description: This file contains code to handle password operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PasswordCheckInstalledLocal
+//
+// Description: function to check the password type
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 PasswordCheckInstalledLocal(VOID)
+{
+ UINT32 Installed = AMI_PASSWORD_NONE;
+ UINT8 *setup = NULL;
+ AMITSESETUP *mSysConf = NULL;
+ UINTN VarSize = 0;
+ CHAR16 *TestPassword;
+
+ TestPassword = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16));
+
+ GetAMITSEVariable(&mSysConf,&setup,&VarSize);
+
+ if ( ( mSysConf != NULL ) && ( VarSize == sizeof(AMITSESETUP) ) )
+ {
+ MemSet( TestPassword, (TsePasswordLength + 1)*sizeof(CHAR16), 0 );
+ if ( ! EfiCompareMem( TestPassword, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) )
+ Installed |= AMI_PASSWORD_USER;
+ if ( ! EfiCompareMem( TestPassword, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) )
+ Installed |= AMI_PASSWORD_ADMIN;
+ Installed ^= AMI_PASSWORD_ANY;
+ }
+
+ if(setup)
+ MemFreePointer( (VOID **)&setup );
+ else
+ MemFreePointer( (VOID **)&mSysConf );
+
+ MemFreePointer( (VOID **)&TestPassword);
+
+ return Installed;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PasswordAuthenticateLocal
+//
+// Description: function to check the authentication of the password
+//
+// Input: CHAR16 *Password
+//
+// Output: password type
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsPasswordSupportNonCaseSensitive ();
+UINT32 PasswordAuthenticateLocal( CHAR16 *Password )
+{
+ UINT32 PasswordType = AMI_PASSWORD_NONE;
+ UINT8 *setup = NULL;
+ AMITSESETUP *mSysConf = NULL;
+ UINTN VarSize = 0;
+ CHAR16 *EncPass;
+ UINTN ii;
+
+ GetAMITSEVariable(&mSysConf,&setup,&VarSize);
+
+ if ( ( mSysConf == NULL ) || ( VarSize != sizeof(AMITSESETUP) ) )
+ return PasswordType;
+
+ EncPass = EfiLibAllocateZeroPool((TsePasswordLength + 1)*sizeof(CHAR16));
+
+ MemSet( EncPass, (TsePasswordLength + 1)*sizeof(CHAR16), 0 );
+ EfiStrCpy( EncPass, Password );
+ if (IsPasswordSupportNonCaseSensitive ()) //If admin/user passwords are not encoded then case pbm will arose so avoiding that
+ {
+ for (ii = 0; ii < TsePasswordLength; ii++)
+ Password [ii] = ((Password [ii]>=L'a')&&(Password [ii]<=L'z'))?(Password [ii]+L'A'-L'a'):Password [ii];
+ }
+
+ PasswordEncodeHook( EncPass, TsePasswordLength*sizeof(CHAR16));
+
+//EIP 23354 : Start
+ if ( ( ! EfiCompareMem( Password, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) ) ||
+ ( ! EfiCompareMem( EncPass, mSysConf->UserPassword, TsePasswordLength * sizeof(CHAR16) ) ) )
+ {
+ PasswordType = AMI_PASSWORD_USER;
+ }
+
+ if ( ( ! EfiCompareMem( Password, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) ) ||
+ ( ! EfiCompareMem( EncPass, mSysConf->AdminPassword, TsePasswordLength * sizeof(CHAR16) ) ) )
+ {
+ PasswordType = AMI_PASSWORD_ADMIN;
+ }
+//EIP 23354 : End
+
+ if(setup)
+ MemFreePointer( (VOID **)&setup );
+ else
+ MemFreePointer( (VOID **)&mSysConf );
+
+ MemFreePointer( (VOID **)&EncPass );
+
+ return PasswordType;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PasswordUpdateLocal
+//
+// Description: function to ubdate the password
+//
+// Input: CHAR16 *Password, , UINTN Size
+//
+// Output: updated password
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *PasswordUpdateLocal( CHAR16 *Password, UINTN Size )
+{
+ CHAR16 *Buffer = NULL;
+
+ if ( Password[0] == L'\0' )
+ return Password;
+
+ Buffer = EfiLibAllocateZeroPool( Size );
+ if ( Buffer == NULL )
+ return Buffer;
+
+ MemCopy( Buffer, Password, Size );
+ PasswordEncodeHook( Buffer, Size );
+
+ return Buffer;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/password.h b/EDK/MiniSetup/BootOnly/password.h
new file mode 100644
index 0000000..708e4ca
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/password.h
@@ -0,0 +1,111 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/password.h $
+//
+// 2 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:37p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 12/08/11 4:54a Arunsb
+// EIP63190 => Moving password support from TSELite to BootOnly
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: password.h
+//
+// Description: Header file for code to handle password operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _PASSWORD_H_
+#define _PASSWORD_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+BOOLEAN _PasswordProtocolInit( VOID );
+BOOLEAN PasswordBootMode( VOID );
+UINT32 PasswordCheckInstalledVarIndex( UINT32 VarIndex );
+UINT32 PasswordAuthenticate( CHAR16 *Password );
+BOOLEAN PasswordAuthenticateVarIndex( UINT32 VarIndex, CHAR16 *Password );
+CHAR16 *PasswordUpdate( CHAR16 *Password, UINTN Size );
+VOID PasswordCommitChanges( BOOLEAN SaveChanges );
+
+#endif /* _PASSWORD_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/postmgmt.c b/EDK/MiniSetup/BootOnly/postmgmt.c
new file mode 100644
index 0000000..36a332b
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/postmgmt.c
@@ -0,0 +1,897 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmt.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 38 $
+//
+// $Date: 8/28/14 8:38a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmt.c $
+//
+// 38 8/28/14 8:38a Premkumara
+// [TAG] EIP142551
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Mouse Movement is not initialized to Full Screen Resolution
+// in case of quiet boot mode with high resolution OEM Logo.
+// [Root Cause] Mouse Initialization was not across the full screen incase
+// of High Resolution Quiet Boot Logo.
+// [Solution] Initialised the Mouse with the Resolution Set in case of
+// Quiet Boot logo so that Mouse will move acroos the Whole screen
+// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c,
+// Notify.c, MinisetupExt.c
+//
+// 37 8/28/14 7:29a Premkumara
+// [TAG] EIP107833, 125388
+// [Category] Improvement
+// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces
+// before TSE or after TSE.
+// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl,
+// PostMgmtc, PostmgmtExt.c, MessagBox.c
+//
+// 36 8/28/14 5:52a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 35 5/02/14 12:51a Arunsb
+// [TAG] EIP148122
+// [Category] Improvement
+// [Description] INTN to UINTN for CordinateX and CordinateY variable in
+// InitPostScreen to avoid negative condition
+// [Files] postmgmt.c
+//
+// 34 2/11/14 9:30p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 33 2/11/14 8:08p Arunsb
+// [TAG] EIP126104
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Calling SwitchToPostScreen after selecting option from BBS
+// draws PostScreen and display post messages.
+// [RootCause] When switchToPostscreen is called BBS menu is d
+// [Solution] Drawing postscreen image and display post messages before
+// BBS
+// [Files] Postmgmt.c
+//
+// 32 1/29/14 5:43p Arunsb
+// [TAG] EIP148122
+// [Category] Improvement
+// [Description] INTN to UINTN for CordinateX and CordinateY variable in
+// InitPostScreen to avoid negative condition
+// [Files] postmgmt.c
+//
+// 31 5/21/13 12:32p Arunsb
+// [TAG] EIP124369
+// [Category] Bug Fix
+// [Solution] BGRT table header revision revised to 1 as per ACPI spec
+// 5.0
+// [Files] postmgmt.c
+//
+// 30 5/12/13 8:35a Arunsb
+// [TAG] EIP122277
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System halted when 4GB memory installed with Quiet Boot
+// enabled in 32 bit platform
+// [RootCause] Type casting problem
+// [Solution] Type casted properly with UINTN for UINT64 member
+// [Files] postmgmt.c
+//
+// 29 4/17/13 1:13a Arunsb
+// [TAG] EIP121116
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] AMI small logo has damage on POST and boot
+// [RootCause] When system starts with higher text resolution more than
+// 100*31 then TSE not setting proper text mode
+// [Solution] Mode set properly
+// [Files] notify.c and postmgmt.c
+//
+// 28 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 26 9/25/12 12:39p Arunsb
+// [TAG] EIP100558
+// [Category] New Feature
+// [Description] Provide solution to display the small logo in (0,0)
+// graphics position
+// [Files] postmgmt.c
+//
+// 25 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 23 9/08/12 6:40p Arunsb
+// [TAG] EIP100558
+// [Category] New Feature
+// [Description] Provide solution to display the small logo in (0,0)
+// graphics position
+// [Files] AMITSE.sdl, commonhelper.c, postmgmt.c and boot.c
+//
+// 22 8/29/12 4:24p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 21 5/29/12 7:02a Arunsb
+// Commented for build error
+//
+// 20 5/29/12 4:33a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 19 2/04/12 9:06a Premkumara
+// Moved DrawOEMImage with some modification from binary to source
+//
+// 18 1/31/12 1:22p Premkumara
+// [TAG] EIP75136
+// [Category] New Feature
+// [Description] Generic support for logos in RomHoles
+// [Files] CommomHelper.c, AMITSE.sdl, AMITSE.mak, LogoLib.h,
+// Postmgmt.c, AMILogo.h
+//
+// 17 1/31/12 6:44a Arunsb
+// [TAG] EIP81830
+// [Category] Improvement
+// [Description] Support to uninstall the BGRT on legacy boot.
+// [Files] Commonhelper.c, postmgmt.c and boot.c
+//
+// 16 11/21/11 8:37a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 15 11/20/11 7:15a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 14 6/29/11 10:16a Arunsb
+// [TAG] EIP58954
+// [Category] Improvement
+// [Description] Support for BGRT spec. version 1.2.
+// ImageType field added in BGRT_TABLE to represent the
+// type of image.
+// [Files] bootonly\logo.c and postmgmt.c
+//
+// 13 6/04/11 1:52p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Wrapper function added for InvalidateStatusInBgrt
+// function.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 12 5/29/11 12:09p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Quiet boot logo's only added for BGRT. BGRT status
+// field cleared if any changes happened in screen other than displaying
+// the image.
+// [Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+// commonhelper.c
+//
+// 11 5/04/11 5:09p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table.
+// CONTRIB_BGRT_TABLE_TO_ACPI token added. Wrapper function
+// ContribBGRTTableToAcpi added.
+// [Files] Postmgmt.c, commonoem.c,logo.c and commonhelper.c
+//
+// 10 5/03/11 9:54p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table.
+// CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added.
+// [Files] Postmgmt.c, commonoem.c and commonhelper.c
+//
+// 9 5/02/11 3:29p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table.
+// CONTRIB_BGRT_TABLE_TO_ACPI token added. EDK Build support added.
+// [Files] Postmgmt.c, commonoem.c and commonhelper.c
+//
+// 8 4/23/11 3:18p Arunsb
+// [TAG] EIP58954
+// [Category] New Feature
+// [Description] Contributing BGRT table to ACPI table.
+// CONTRIB_BGRT_TABLE_TO_ACPI token added.
+// [Files] Postmgmt.c, commonoem.c and commonhelper.c
+//
+// 7 3/28/11 9:23p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 6 1/06/11 1:55a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP is getting
+// corrupted.
+// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the
+// update function and in switch to posty screen returining status as
+// aborted if the gGOP/gUgaDraw is NULL
+// [Files] protocol.c,notify.c,postmgmt.c
+//
+// 5 12/29/10 2:31a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP getting
+// corrupted.
+// [Solution] Updated gGop/UgaDraw before using it in AMITSE.
+// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/04/10 11:21p Madhans
+// To remove ConsoleControl dependance.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/13/09 11:01a Madhans
+// Signal the event once we create the timer. to read any pending keys
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 3/31/09 4:00p Madhans
+//
+// 4 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: postmgmt.c
+//
+// Description: file to handle the post management operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#if !TSE_USE_EDK_LIBRARY
+#include "Acpi.h"
+#include <Protocol\AcpiSupport.h>
+#else
+#include EFI_PROTOCOL_DEFINITION (AcpiTable)
+#endif
+
+#pragma pack (1)
+typedef struct //Structure for forming BGRT Table
+{
+ UINT16 Version;
+ UINT8 Status;
+ UINT8 ImageType;
+ UINT64 ImageAddress;
+ UINT32 ImageOffsetX;
+ UINT32 ImageOffsetY;
+}BGRT_TABLE;
+#pragma pack()
+#if !TSE_USE_EDK_LIBRARY
+#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
+#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16 (A,B) | (EFI_SIGNATURE_16 (C,D) << 16))
+#endif
+#define BGRT_SIGNATURE EFI_SIGNATURE_32 ('B','G','R','T')
+VOID FormBGRTTable (VOID **, UINTN *, UINT8 *, INTN, INTN, BOOLEAN);
+UINT8 CalculateChecksum (VOID *, UINT8);
+#define CREATOR_ID_AMI 0x20494D41
+#define CREATOR_REV_MS 0x00010013
+UINT8 *GetACPIOEMID (VOID);
+UINT8 *GetACPIOEMTableID (VOID);
+UINT32 GetACPIOEMRevision (VOID);
+LOGO_TYPE GetLogoType(UINT8 *ImageData);
+LOGO_TYPE GetExtendedLogoType(UINT8 *ImageData);
+VOID *gBgrtSafeBuffer = NULL; //EIP 58954 For BGRT table support
+UINTN gTableKey = 0;
+VOID InvalidateStatusInBgrtWrapper (VOID);
+//EIP-75136 ROMHole Support
+BOOLEAN IsOEMPOSTLogoSupport();
+//EIP-75136 End
+BOOLEAN IsMouseSupported(VOID);
+BOOLEAN IsSoftKbdSupported(VOID);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawOEMImage
+//
+// Description: Function to draw OEMLogo to in post screen operations
+//
+// Input: UINTN *, UINTN*, INTN, INTN
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DrawOEMImage (UINTN *width, UINTN *height, INTN CoordinateX, INTN CoordinateY)
+{
+ EFI_GUID OEMLogoGuid = AMI_OEM_LOGO_GUID;
+ UINT8 *ImageData = NULL;
+ UINTN ImageSize = 0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINTN LogoType = 0;
+
+ Status = GetGraphicsBitMapFromFV( &OEMLogoGuid, &ImageData, &ImageSize );
+ if(EFI_SUCCESS == Status)
+ {
+ DrawImage( ImageData, ImageSize, CA_AttributeRightTop, CoordinateX, CoordinateY, FALSE, width, height );
+ LogoType = GetExtendedLogoType (ImageData);
+ if (GIF_Logo != LogoType)
+ {
+ MemFreePointer ((VOID **)&ImageData);
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitPostScreen
+//
+// Description: fucntion to perform the post screen operations
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN DrawPostLogoAt0Pos (VOID);
+VOID InitPostScreen( VOID )
+{
+ UINTN height, width, OrgHeight = 0;
+ UINT8 *ImageData = NULL;
+ UINTN ImageSize = 0;
+ UINTN CoordinateX = 0;
+ UINTN CoordinateY = 0;
+ UINT32 HorizontalResolution = 0;
+ UINT32 VerticalResolution = 0;
+ UINTN ConCols = 0, ConRows = 0;
+#if !SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+#endif
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *pConOut = gST->ConOut;
+ UINTN LogoType = 0;
+ UINTN tempPostStatus;
+
+ if ( pConOut == NULL )
+ return;
+
+ //If any SwitchToPostScreen happens during ProceedToBoot then taking backup of original gPostStatus before changing to IN_POST_SCREEN
+ if (TSE_POST_STATUS_PROCEED_TO_BOOT == gPostStatus)
+ tempPostStatus = gPostStatus;
+
+ if ( gPostStatus <= TSE_POST_STATUS_IN_TSE ) //EIP-126104
+ gPostStatus = TSE_POST_STATUS_IN_POST_SCREEN;
+
+#ifndef STANDALONE_APPLICATION
+ if(gConsoleControl != NULL)
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText );
+#endif
+
+#if !APTIO_4_00
+ SetDesiredTextMode ();
+#else
+ // In Aptio use the Text mode as is it in post screen
+ if (EFI_ERROR (gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &ConCols, &ConRows)))
+ {
+ gMaxRows = StyleGetStdMaxRows();
+ gMaxCols = StyleGetStdMaxCols();
+ }
+ else if ((gMaxRows < ConRows) && (gMaxCols < ConCols))
+ {
+ SetDesiredTextMode ();
+ }
+#endif
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+ pConOut->EnableCursor( pConOut, FALSE );
+ pConOut->SetAttribute( pConOut, EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+ pConOut->ClearScreen( pConOut );
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if(gGOP)
+ {
+ HorizontalResolution = gGOP->Mode->Info->HorizontalResolution;
+ VerticalResolution = gGOP->Mode->Info->VerticalResolution;
+ }
+#else
+ if ( gUgaDraw != NULL )
+ {
+ gUgaDraw->GetMode (gUgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
+ }
+#endif
+
+ if ( gPostStatus > TSE_POST_STATUS_IN_TSE ) //EIP-126104
+ {
+ InvalidateStatusInBgrtWrapper ();
+ return;
+ }
+
+ height = 0;
+
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if(gGOP )
+#else
+ if ( gUgaDraw )
+#endif
+ {
+ if (!DrawPostLogoAt0Pos ())
+ {
+ CoordinateX = (HorizontalResolution - (gMaxCols * HiiGetGlyphWidth ())) / 2;
+ CoordinateY = (VerticalResolution - (gMaxRows * HiiGetGlyphHeight ())) / 2;
+ }
+ //EIP-75136 To display AMILogo on TopLeft corner of setup
+ if(EFI_SUCCESS == GetGraphicsBitMapFromFV( &gAMIEfiLogoGuid, &ImageData, &ImageSize ))
+ {
+
+ MouseStop();//EIP 62763: Mouse stopped before drawing the post image.
+
+ DrawImage(
+ ImageData,
+ ImageSize,
+ CA_AttributeLeftTop,
+ CoordinateX,
+ CoordinateY,
+ FALSE,
+ &width,
+ &height
+ );
+ OrgHeight = height;
+ LogoType = GetExtendedLogoType (ImageData);
+ if (GIF_Logo != LogoType)
+ {
+ MemFreePointer ((VOID **)&ImageData);
+ }
+ InvalidateStatusInBgrtWrapper ();
+ }
+ //EIP-75136 To display OEM_POST_Logo on RightTop corner of setup
+ if (IsOEMPOSTLogoSupport())
+ {
+ if(EFI_SUCCESS == DrawOEMImage(&width, &height, CoordinateX, CoordinateY))
+ {
+ InvalidateStatusInBgrtWrapper ();
+ }
+ }
+ if (DrawPostLogoAt0Pos ())
+ {
+ if (height > (VerticalResolution - (gMaxRows * HiiGetGlyphHeight())) / 2) //If height is lesser than empty space then make height as 0. Occurs for greater graphics resolution with lesser text resolution.
+ {
+ height -= (VerticalResolution - (gMaxRows * HiiGetGlyphHeight())) / 2;
+ }
+ }
+ height = (height / HiiGetGlyphHeight());
+ if(OrgHeight % HiiGetGlyphHeight()) //Seeing remainder for original height
+ height ++;
+ }
+
+ //If SwitchToPostScreen is called during TSE_POST_STATUS_PROCEED_TO_BOOT poststatus then we need to save PROCEED_TO_BOOT to set it back after drawing postlogo to avoid drawing msgbox, message, other postinterfaces
+ if (TSE_POST_STATUS_PROCEED_TO_BOOT == tempPostStatus)
+ gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT;
+
+ DisplayActivePostMsgs(height);
+
+ AfterInitPostScreenHook();
+ MouseRefresh();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InstallKeyHandlers
+//
+// Description: fucntion to install the timer event
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InstallKeyHandlers( VOID )
+{
+ EFI_STATUS Status;
+ if(gKeyTimer != NULL)
+ return; // timer already created.
+ Status = TimerCreateTimer( &gKeyTimer, CheckForKeyHook, NULL, TimerPeriodic, TIMER_HALF_SECOND, EFI_TPL_CALLBACK );
+ // Signal it once immediately.
+ if (!EFI_ERROR(Status))
+ gBS->SignalEvent( gKeyTimer );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InstallClickHandlers
+//
+// Description: fucntion to install the timer event
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InstallClickHandlers( VOID )
+{
+ EFI_STATUS Status;
+ if(gClickTimer != NULL)
+ return; // timer already created.
+ Status = TimerCreateTimer( &gClickTimer, CheckForClickHook, NULL, TimerPeriodic, TIMER_HALF_SECOND, EFI_TPL_CALLBACK );
+ // Signal it once immediately.
+ if (!EFI_ERROR(Status))
+ gBS->SignalEvent( gClickTimer );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FormBGRTTable
+//
+// Description: Created the BGRT table with the input params
+//
+// Input: VOID * = Buffer to store the ACPI table
+// UINTN * = To store the size of the ACPI + BGRT table
+// UINT8 * = Address of the image to be to stored
+// INTN = X coordinate of the image
+// INTN = Y coordinate of the image
+// BOOLEAN = Indicates whether to set the BGRT status field or not.
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FormBGRTTable (VOID **AcpiTableBuffer, UINTN *AcpiTableBufferSize, UINT8 *ImageAddress, INTN ImageXOffset, INTN ImageYOffset, BOOLEAN GifImagePresence)
+{
+ BGRT_TABLE BgrtTable = {0};
+ const UINT8 *OemId = GetACPIOEMID ();
+ const UINT8 *OemTblId = GetACPIOEMTableID ();
+ UINT8 iIndex = 0;
+ UINT8 Checksum = 0;
+ UINT8 AcpiHdrSize = 0;
+#if TSE_USE_EDK_LIBRARY
+ EFI_ACPI_DESCRIPTION_HEADER AcpiHdr = {0};
+ AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
+#else
+ ACPI_HDR AcpiHdr = {0};
+ AcpiHdrSize = sizeof (ACPI_HDR);
+#endif
+ AcpiHdr.Signature = BGRT_SIGNATURE;
+ AcpiHdr.Length = AcpiHdrSize + sizeof(BGRT_TABLE);
+ AcpiHdr.Revision = 1;
+ AcpiHdr.Checksum = 0;
+ AcpiHdr.CreatorId = CREATOR_ID_AMI; //"AMI"
+ for (iIndex = 0; ((iIndex < 6) && (OemId [iIndex])); iIndex ++)
+ {
+ AcpiHdr.OemId [iIndex] = OemId [iIndex];
+ }
+#if TSE_USE_EDK_LIBRARY
+ AcpiHdr.OemRevision = GetACPIOEMRevision ();
+ AcpiHdr.CreatorRevision = CREATOR_REV_MS;
+ for (iIndex = 0; ((iIndex < 8) && (OemTblId [iIndex])); iIndex ++)
+ {
+ ((UINT8 *)(&AcpiHdr.OemTableId)) [iIndex] = OemTblId [iIndex];
+ }
+#else
+ AcpiHdr.OemRev = GetACPIOEMRevision ();
+ AcpiHdr.CreatorRev = CREATOR_REV_MS;
+ for (iIndex = 0; ((iIndex < 8) && (OemTblId [iIndex])); iIndex ++)
+ {
+ AcpiHdr.OemTblId [iIndex] = OemTblId [iIndex];
+ }
+#endif
+ BgrtTable.Version = 1;
+ if (!GifImagePresence) //If gif image presented then status field should be 0.
+ {
+ BgrtTable.Status = 1;
+ }
+ BgrtTable.ImageType = 0; //0 Represents BMP image
+ BgrtTable.ImageAddress = (UINTN)ImageAddress;
+ BgrtTable.ImageOffsetX = (UINT32)ImageXOffset;
+ BgrtTable.ImageOffsetY = (UINT32)ImageYOffset;
+
+ Checksum = CalculateChecksum (&AcpiHdr, AcpiHdrSize);
+ Checksum += CalculateChecksum (&BgrtTable, (UINT8)sizeof (BGRT_TABLE));
+ AcpiHdr.Checksum = Checksum;
+
+ *AcpiTableBuffer = EfiLibAllocatePool (AcpiHdrSize + sizeof (BGRT_TABLE));
+ if (NULL == *AcpiTableBuffer)
+ {
+ return;
+ }
+ EfiCopyMem (*AcpiTableBuffer, &AcpiHdr, AcpiHdrSize);
+ EfiCopyMem (((UINT8 *)(*AcpiTableBuffer)) + AcpiHdrSize, &BgrtTable, sizeof (BGRT_TABLE));
+ *AcpiTableBufferSize = AcpiHdrSize + sizeof(BGRT_TABLE);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddImageDetailToACPI
+//
+// Description: Adds the image data to the ACPI Table.
+//
+// Input: UINT8 * = Address of the image to be to stored
+// INTN = X coordinate of the image
+// INTN = Y coordinate of the image
+// BOOLEAN = Indicates whether to set the BGRT status field or not
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddImageDetailToACPI (UINT8 *ImageData, INTN CoordinateX, INTN CoordinateY, BOOLEAN GifImagePresence)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;
+ VOID *AcpiTableBuffer = NULL;
+ UINTN AcpiTableBufferSize = 0;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL;
+
+ Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance);
+ if (EFI_SUCCESS != Status)
+ {
+ return;
+ }
+ FormBGRTTable (&AcpiTableBuffer, &AcpiTableBufferSize, ImageData, CoordinateX, CoordinateY, GifImagePresence);
+ if (NULL != AcpiTableBuffer)
+ {
+ Status = AcpiTableInstance->InstallAcpiTable (AcpiTableInstance, AcpiTableBuffer, AcpiTableBufferSize, &gTableKey);
+ if (EFI_SUCCESS == Status)
+ {
+ gBgrtSafeBuffer = AcpiTableBuffer;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CalculateChecksum
+//
+// Description: Calculates the checksum for the given structure
+//
+// Input: VOID => Table structure
+// UINT8 => Table Size
+//
+// Output: UINT8 => Checksum for the table
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CalculateChecksum (VOID *AcpiTable, UINT8 TableSize)
+{
+ UINT8 *TablePtr = (UINT8 *)AcpiTable;
+ UINT8 iIndex = 0;
+ UINT8 Checksum = 0;
+
+ for (iIndex= 0; iIndex < TableSize; iIndex ++)
+ {
+ Checksum += TablePtr [iIndex];
+ }
+ return (0 - Checksum);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BGRTSupportedLogoType
+//
+// Description: Checks whether the BGRT data supports the specified logo
+//
+// Input: UINT8 * => Data for the image
+//
+// Output: BOOLEAN => TRUE if BGRT supports otherwise FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN BGRTSupportedLogoType (UINT8 *ImageData)
+{
+ UINTN LogoType;
+ LogoType = GetLogoType (ImageData);
+ if (BMP_Logo== LogoType)
+ {
+ BMP_IMAGE_HEADER *BmpHeader;
+ BmpHeader = (BMP_IMAGE_HEADER *)ImageData;
+ if (24 == BmpHeader->BitPerPixel) //As per spec. BMP image should be 24 bitmap
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------------------------------
+// Procedure: InvalidateStatusInBgrt
+//
+// Description: Disables the BGRT status field if any changes happened in screen other than the image display
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InvalidateStatusInBgrt (VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;
+ BGRT_TABLE *BgrtTable;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL;
+ UINTN TableSize = 0;
+#if TSE_USE_EDK_LIBRARY
+ UINT8 AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
+ EFI_ACPI_DESCRIPTION_HEADER *AcpiHdr;
+#else
+ UINT8 AcpiHdrSize = sizeof (ACPI_HDR);
+ ACPI_HDR *AcpiHdr;
+#endif
+ TRACE((-1,"In InvalidateStatusInBgrt"));
+ if (NULL == gBgrtSafeBuffer) //EIP 58954 For BGRT table support
+ {
+ return;
+ }
+ BgrtTable = (BGRT_TABLE *)((UINT8 *)gBgrtSafeBuffer + AcpiHdrSize);
+ BgrtTable->Status = 0;
+#if TSE_USE_EDK_LIBRARY
+ AcpiHdr = (EFI_ACPI_DESCRIPTION_HEADER *)gBgrtSafeBuffer;
+#else
+ AcpiHdr = (ACPI_HDR *)gBgrtSafeBuffer;
+#endif
+ AcpiHdr->Checksum ++; //Since changing the status bit from 1 to 0 adding checksum by 1.
+ Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance);
+ if (EFI_SUCCESS != Status)
+ {
+ return;
+ }
+ Status = AcpiTableInstance->UninstallAcpiTable (AcpiTableInstance, gTableKey);
+ if (EFI_SUCCESS != Status)
+ {
+ return;
+ }
+ gTableKey = 0; //If not set to 0 then ACPI table is not created again
+ TableSize = AcpiHdrSize + sizeof(BGRT_TABLE);
+ Status = AcpiTableInstance->InstallAcpiTable (AcpiTableInstance, gBgrtSafeBuffer, TableSize, &gTableKey);
+}
+
+//EIP81830 starts - Support to uninstall the BGRT on legacy boot
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------------------------------
+// Procedure: UninstallBGRT
+//
+// Description: UninstallsBGRT table, Called for Legacy Boot
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UninstallBGRT (VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;
+ BGRT_TABLE *BgrtTable;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTableInstance = NULL;
+#if TSE_USE_EDK_LIBRARY
+ UINT8 AcpiHdrSize = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
+#else
+ UINT8 AcpiHdrSize = sizeof (ACPI_HDR);
+#endif
+ TRACE((-1,"In UninstallBGRT"));
+
+ if (NULL == gBgrtSafeBuffer)
+ {
+ return;
+ }
+ BgrtTable = (BGRT_TABLE *)((UINT8 *)gBgrtSafeBuffer + AcpiHdrSize);
+
+ Status = gBS->LocateProtocol (&AcpiTableProtocolGuid, NULL, &AcpiTableInstance);
+ if (EFI_SUCCESS != Status)
+ {
+ return;
+ }
+ Status = AcpiTableInstance->UninstallAcpiTable (AcpiTableInstance, gTableKey);
+ if (EFI_SUCCESS != Status)
+ {
+ return;
+ }
+ MemFreePointer((VOID**)&BgrtTable->ImageAddress);
+ MemFreePointer((VOID**)&gBgrtSafeBuffer);
+
+}
+//EIP81830 ends
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************* \ No newline at end of file
diff --git a/EDK/MiniSetup/BootOnly/postmgmtext.c b/EDK/MiniSetup/BootOnly/postmgmtext.c
new file mode 100644
index 0000000..530be2a
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/postmgmtext.c
@@ -0,0 +1,964 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmtext.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 19 $
+//
+// $Date: 8/28/14 8:39a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/postmgmtext.c $
+//
+// 19 8/28/14 8:39a Premkumara
+// [TAG] EIP142551
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Mouse Movement is not initialized to Full Screen Resolution
+// in case of quiet boot mode with high resolution OEM Logo.
+// [Root Cause] Mouse Initialization was not across the full screen incase
+// of High Resolution Quiet Boot Logo.
+// [Solution] Initialised the Mouse with the Resolution Set in case of
+// Quiet Boot logo so that Mouse will move acroos the Whole screen
+// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c,
+// Notify.c, MinisetupExt.c
+//
+// 18 8/28/14 7:30a Premkumara
+// [TAG] EIP107833, 125388
+// [Category] Improvement
+// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces
+// before TSE or after TSE.
+// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl,
+// PostMgmtc, PostmgmtExt.c, MessagBox.c
+//
+// 17 7/15/14 5:50p Arunsb
+// [TAG] EIP174261
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Location issue of Password Popup
+// [Root Cause] Text Mode was not setting properly when gMaxRows != Rows
+// or gMaxCols != Cols
+// [Solution] Modified the code to set the Text Mode properly when
+// gMaxRows != Rows
+// or gMaxCols != Cols
+// [Files] postmgmtext.c
+//
+// 16 6/25/14 12:33a Premkumara
+// [TAG] EIP173965
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] HDD password prompt is not proper in post.
+// [Root Cause] Since the password length for HDD password is
+// IDE_PASSWORD_LENGTH = 32 and Setup password is SETUP_PASSWORD_LENGTH =
+// 20(TsePasswordLength) . So using TsePasswordLength to find coordinate
+// of X for displaying either HDD/Setup password prompt in post will cause
+// distortion for HDD.
+// [Solution] Using respective password (HDD/Setup) length to find the
+// coordinates of X for drawing post HDD/Setup password prompt in proper
+// place.
+// [Files] PostMgmtExt.c
+//
+// 15 5/03/14 6:24p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// Solved crashing issue in post password when password window title is
+// more than 80
+// [Files] PostMgmtExt.c
+//
+// 14 5/03/14 4:04p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 13 2/11/14 8:21p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 12 12/05/13 10:57a Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 11 9/18/13 7:09a Arunsb
+// [TAG] EIP135029, 136209
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Password popup window displayed with post messages
+// [Root Cause] Since ClearScreen is commented, dorealflushlines displays
+// the previous saved post messages also
+// [Solution] ClearScreen uncommented
+// [Files] postmgmtext.c
+//
+// 10 3/16/13 2:16a Rajashakerg
+// [TAG] EIP111479
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS dialog box is crashed with special
+// monitor(160,53,1280*1024)
+// [RootCause] DesiredTextMode was not set properly.
+// [Solution] Provided proper mode number while setting text mode.
+// [Files] postmgmtext.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 9 10/19/12 6:28a Arunsb
+// [Issue] - Screen is not cleared fully while displaying logo at (0,0)
+// position in post screen.
+// [Solution] - Clearing whole graphics screen while drawing logo at (0,0)
+// co-ordinates
+//
+// 3 10/19/12 5:28a Premkumara
+// [Issue] - Screen is not cleared fully while displaying log at (0,0)
+// position in post screen
+// [Solution] - Clearing complete screen while drawing logo at (0,0)
+// co-ordinates
+//
+// 2 10/10/12 12:37p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 4 8/29/12 8:30a Premkumara
+// [TAG] EIP 91364
+// [Category] Improvement
+// [Description] Token to disable the Cursor of TSE Password Dialog
+// [Files] AMITSE.sdl, CommonHelper.c, Postmgmtext.c, PopupPassword.c,
+// PopupString.c
+//
+// 3 5/28/12 11:27a Premkumara
+// [TAG] EIP88912
+// [Category] Improvement
+// [Description] On password window display the softkbd with only with
+// valid key's
+// [Files] CommonHelper.c, Postmgmtext.c, Mouse.c, PopupPassword.c
+//
+// 2 12/08/11 1:06p Rajashakerg
+// [TAG] EIP75379
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Postmgmtext.c, Uefi21Wapper.c
+//
+// 1 12/08/11 4:54a Arunsb
+// EIP63190 => Moving password support from TSELite to BootOnly
+//
+// 18 11/30/11 11:26a Premkumara
+// [TAG] EIP67695
+// [Category] Improvement
+// [Description] No cursor visible in setup, while editing text input
+// box
+// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c
+//
+// 17 11/22/11 5:33a Rajashakerg
+// [TAG] EIP62763
+// [Description] Removed wanted mouseinit before drawing password window
+// at post.
+//
+// 16 11/22/11 12:13a Premkumara
+// [TAG] EIP70175
+// [Category] Improvement
+// [Description] Color of Password Validation for TSE and GTSE
+// [Files] CommonHelper.c, postmgmtext.c
+//
+// 15 11/20/11 8:16a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 14 11/20/11 8:08a Premkumara
+// [TAG] EIP70175
+// [Category] Improvement
+// [Description] Color of PopupPassword Window to validate password in
+// GTSE style
+// [Files] CommonHelper.c, postmgmtext.c, minisetup.h
+//
+// 13 8/26/11 6:46a Arunsb
+// [TAG] EIP66211
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Password window hangs while pressing ESC
+// [RootCause] If status is not equals success then TSE hangs the
+// system.
+// [Solution] If password window is time out then TSE will hang.
+// If ESC pressed for password window then that try wont taken
+// into account.
+// [Files] postmgmtext.c
+//
+// 12 6/24/11 9:35a Arunsb
+// [TAG] EIP62754
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Time out not occurring in password popup window
+// [RootCause] Timer event was set only for the first try in consecutive
+// tries
+// event not created
+// [Solution] If time out occurs in first try then TSE wont try for next
+// iteration to get password.
+// TSE will report error and waits upto
+// restarting the system.
+//
+// [Files] postmgmtext.c
+//
+// 11 6/08/11 11:26p Arunsb
+// [TAG] EIP59138
+// [Category] Improvement
+// [Description] TSE expects extra key on the last wrong password retry
+// [Files] postmgmtext.c
+//
+// 10 3/28/11 9:25p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 9 1/10/11 3:59p Mallikarjunanv
+// [TAG] EIP51621
+// [Description] Updated with respect to pressing ESC in password dialog
+// box while entring to setup
+//
+// 8 1/07/11 12:42a Mallikarjunanv
+// [TAG] EIP51621
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] pressing ESC in password dialog makes system hang
+// [RootCause] While entering password to boot to setup ESC key is not
+// handled properly
+// [Solution] Fixed the issue by handling the ESC key properly.
+// [Files] postmgmtext.c
+//
+// 7 10/27/10 3:14p Madhans
+// [TAG] EIP44886
+// [Category] Defect
+// [Symptom] If the SETUP_PASSWORD_LENGTH Changed to smaller then while
+// entering Invalid Password in POST causes
+// Error message printed outside of the box.
+// [RootCause] The Boxsize is depending on Max Password length
+// [Solution] Boxsize is desided on Maximum of ErrorString or
+// PasswordLength
+// [Files] postmgmtext.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:56p Madhans
+// EIP-28501: fix for the issue for validating password using scan code
+//
+// 4 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 7 2/25/10 12:27p Madhans
+// EIP 35391 To resolve the Get Password Window if it is called second
+// time.
+//
+// 5 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/19/09 6:32p Madhans
+// DoRealFlushLines added to avoid the image overriding during post if
+// password set
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PostMgmtExt.c
+//
+// Description: This file contains code extended post management operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+////////////////////////////////////////////////////////////////////
+// Function Declarations
+////////////////////////////////////////////////////////////////////
+//EIP-70175 Set Password Popup Window and PopupTextBox color
+UINT8 GetPasswordPopupTextBoxColor (VOID);
+UINT8 GetPasswordPopupWindowColor (VOID);
+UINT8 GetPasswordReportInboxcolor (VOID);
+BOOLEAN IsMouseSupported (VOID);
+BOOLEAN IsSoftKbdSupported (VOID);
+VOID SetPwdKeyboardLayout (VOID);//EIP-88912
+VOID ResetPwdKeyboardLayout (VOID);//EIP-88912
+BOOLEAN IsTSECursorSupport (); //EIP-91364
+void ClearGrphxScreen (void);
+BOOLEAN IsTSEMultilineControlSupported (VOID); //EIP-135665 Multiline support for Password and String control
+EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode );
+EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode );
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetSystemAccessValue
+//
+// Description: function to set the system access Value
+//
+// Input: UINT8 sysAccessValue
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetSystemAccessValue(UINT8 sysAccessValue)
+{
+ EFI_GUID sysAccessGuid = SYSTEM_ACCESS_GUID;
+ if(NoVarStoreSupport())
+ {
+ NoVarStoreUpdateSystemAccess(sysAccessValue);
+ }
+ else
+ VarSetNvramName( L"SystemAccess", &sysAccessGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &sysAccessValue, sizeof(sysAccessValue) );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetPasswordType
+//
+// Description: function to set the type of password
+//
+// Input: UINT32 PasswordType
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetPasswordType( UINT32 PasswordType )
+{
+ UINT8 sysAccessValue = SYSTEM_PASSWORD_ADMIN;
+
+ gPasswordType = PasswordType;
+
+ if ( gPasswordType == AMI_PASSWORD_USER )
+ sysAccessValue = SYSTEM_PASSWORD_USER;
+
+ if ( gPasswordType != AMI_PASSWORD_NONE )
+ {
+ if(ItkSupport())
+ {
+ SetSystemAccessValueItk(sysAccessValue);
+ }
+ else
+ {
+ SetSystemAccessValue(sysAccessValue);
+ }
+ }
+
+ return;
+}
+/*Removed from BootOnly
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckEnableQuietBoot
+//
+// Description: Function to check the quick boot enable option
+//
+// Input: void
+//
+// Output: void
+//
+// Notes : if NVRAM variable field AMISilentBoot = 0, then disable silent
+// mode else enable In case of error reading the Setup variable,
+// then return as silent boot disable
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CheckEnableQuietBoot( VOID )
+{
+#ifndef STANDALONE_APPLICATION
+ if(ItkSupport())
+ gQuietBoot = TRUE;
+ else
+ {
+ UINT8 *setupvar=NULL;
+ UINT8 *setup=NULL;
+ UINTN size = 0;
+ UINTN offset;
+
+ GetAMITSEVariable((AMITSESETUP**)&setup,&setupvar,&size);
+
+ offset = STRUCT_OFFSET( AMITSESETUP, AMISilentBoot );
+ if ( ( setup == NULL ) || ( size < offset ) )
+ gQuietBoot = FALSE;
+ else
+ gQuietBoot = (BOOLEAN)setup[offset];
+
+ if(setupvar)
+ MemFreePointer( (VOID **)&setupvar );
+ else
+ MemFreePointer( (VOID **)&setup );
+ }
+#endif //#ifndef STANDALONE_APPLICATION
+}
+*/
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckSystemPassword
+//
+// Description: Function to check the system password
+//
+// Input: UINT32 EmptyPasswordType, UINTN *NoOfRetries, UINTN *TimeOut
+//
+// Output: PasswordCheck
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 CheckSystemPassword(UINT32 EmptyPasswordType, UINTN *NoOfRetries, UINTN *TimeOut)
+{
+ UINTN PasswordCheck = AMI_PASSWORD_NONE;
+ UINTN CurrXPos, CurrYPos;
+ CHAR16 *PasswordEntered;
+ UINT32 PasswordInstalled;
+ SCREEN_BUFFER *TempScreenBuffer = NULL;
+ CHAR16 *BoxStr=NULL;
+ UINTN BoxLength = TsePasswordLength;
+
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ EFI_GUID AmitsePasswordPromptEnterGuid = AMITSE_PASSWORD_PROMPT_ENTER_GUID;
+ EFI_GUID AmitsePasswordPromptExitGuid = AMITSE_PASSWORD_PROMPT_EXIT_GUID;
+ EFI_GUID AmitseUserPasswordValidGuid = AMITSE_USER_PASSWORD_VALID_GUID;
+ EFI_GUID AmitseAdminPasswordValidGuid = AMITSE_ADMIN_PASSWORD_VALID_GUID;
+ EFI_GUID AmitseInvalidPasswordGuid = AMITSE_INVALID_PASSWORD_GUID;
+
+ EfiLibNamedEventSignal (&AmitsePasswordPromptEnterGuid);
+ // Report the Status code DXE_SETUP_VERIFYING_PASSWORD
+ EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_SETUP_VERIFYING_PASSWORD,0,NULL,NULL);
+
+ CheckForKeyHook( (EFI_EVENT)NULL, NULL );
+ if( IsMouseSupported() && IsSoftKbdSupported())
+ CheckForClickHook( (EFI_EVENT)NULL, NULL );//EIP 62763 : Checking for mouse and softkbd.
+
+ gST->ConIn->Reset( gST->ConIn, FALSE );
+
+ // Copy the contents of Active buffer so password code can use it
+ TempScreenBuffer = EfiLibAllocateZeroPool( sizeof(SCREEN_BUFFER) );
+ if(TempScreenBuffer != NULL)
+ MemCopy(TempScreenBuffer, gActiveBuffer, sizeof(SCREEN_BUFFER));
+
+ BoxStr = HiiGetString( gHiiHandle, STRING_TOKEN(STR_ERROR_PSWD));
+ if ( BoxStr ){
+ if ((TestPrintLength( BoxStr ) / NG_SIZE) > BoxLength ){
+ BoxLength = TestPrintLength( BoxStr ) / NG_SIZE;
+ }
+ }
+ MemFreePointer((VOID**) &BoxStr );
+
+ SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+
+ //Draw password window
+ _DrawPasswordWindow(STRING_TOKEN(STR_PASSWORD_PROMPT), BoxLength, &CurrXPos, &CurrYPos);
+
+ PasswordEntered = EfiLibAllocatePool((TsePasswordLength + 1)*sizeof(CHAR16));
+ PasswordInstalled = PasswordCheckInstalled();
+ PasswordCheck = AMI_PASSWORD_NONE;
+
+ //Give retries based on NoOfRetries
+ while(*NoOfRetries)
+ {
+ //EIP:51621 Handling ESC key for the the input password
+ Status = _GetPassword (PasswordEntered, TsePasswordLength, CurrXPos, CurrYPos, TimeOut);
+ if (EFI_ABORTED == Status) //Status should be aborted, success or timeout. If time out we should not go for another iteration
+ { //If user presses ESC TSE handle that as invalid case so let it for another iteration.
+ continue;
+ }
+ else if (EFI_TIMEOUT == Status)
+ {
+ break; //EIP 62754; Breaking if time out occurs
+ }
+ PasswordCheck = PasswordAuthenticate( PasswordEntered );
+ PasswordCheck &= PasswordInstalled;
+
+ if((PasswordEntered[0] == L'\0') && (AMI_PASSWORD_NONE == PasswordCheck))
+ {
+ //Honour EmptyPasswordType
+ if(
+ (!(PasswordInstalled & AMI_PASSWORD_USER ))&&
+ (EmptyPasswordType & AMI_PASSWORD_USER)
+ )
+ PasswordCheck = AMI_PASSWORD_USER;
+ if(
+ (!(PasswordInstalled & AMI_PASSWORD_ADMIN ))&&
+ (EmptyPasswordType & AMI_PASSWORD_ADMIN)
+ )
+ PasswordCheck = AMI_PASSWORD_ADMIN;
+ }
+
+ if(AMI_PASSWORD_NONE != PasswordCheck)
+ break;
+ else
+ {
+ if (1 == *NoOfRetries) // Do not wait for key if it is the lastest try
+ _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, FALSE);
+ else
+ _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, TRUE);
+ }
+
+ (*NoOfRetries)--;
+ }
+
+ MemFreePointer((VOID **)&PasswordEntered);
+
+ if(AMI_PASSWORD_NONE == PasswordCheck)
+ {
+ EfiLibNamedEventSignal (&AmitseInvalidPasswordGuid);
+ EfiLibReportStatusCode(EFI_ERROR_CODE| EFI_ERROR_MAJOR, DXE_INVALID_PASSWORD,0,NULL,NULL);
+
+ //Report Invalid password
+ _ReportInBox( TsePasswordLength, STRING_TOKEN(STR_ERROR_PSWD), CurrXPos, CurrYPos, FALSE);
+ }
+ else
+ {
+ MouseStop();
+ ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+ DoRealFlushLines();
+ MouseRefresh();
+
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+
+ if (!( PasswordInstalled & AMI_PASSWORD_ADMIN ))
+ PasswordCheck = AMI_PASSWORD_ADMIN;
+ SetPasswordType( (UINT32)PasswordCheck );
+
+ if(AMI_PASSWORD_ADMIN == PasswordCheck)
+ EfiLibNamedEventSignal (&AmitseAdminPasswordValidGuid);
+
+ if(AMI_PASSWORD_USER == PasswordCheck)
+ EfiLibNamedEventSignal (&AmitseUserPasswordValidGuid);
+ }
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+ EfiLibNamedEventSignal (&AmitsePasswordPromptExitGuid);
+
+ //Copy the original active buffer contents
+ if(TempScreenBuffer != NULL)
+ {
+ MemCopy(gActiveBuffer, TempScreenBuffer, sizeof(SCREEN_BUFFER));
+ MemFreePointer((VOID **) &TempScreenBuffer);
+ }
+ return ((UINT32)PasswordCheck);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DrawPasswordWindow
+//
+// Description: Function to draw password window with attributes
+//
+// Input: UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DrawPasswordWindow(UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos)
+{
+ UINTN DlogWidth = PasswordLength + 4;
+ UINTN Height=1;
+ CHAR16 *PasswordPrompt;
+
+#ifndef STANDALONE_APPLICATION
+ if ( gConsoleControl != NULL )
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText );
+#endif
+
+ //Set desired Mode.
+#if !APTIO_4_00
+ SetDesiredTextMode();
+#else
+ // In Aptio use the Text mode as is it in post screen
+ if(gST->ConOut!=NULL)
+ {
+ UINTN Rows, Cols;
+ if(EFI_ERROR(gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, &Cols, &Rows )))
+ {
+ gMaxRows = STYLE_STD_MAX_ROWS;
+ gMaxCols = STYLE_STD_MAX_COLS;
+ }
+ else if ((gMaxRows != Rows) || (gMaxCols != Cols))
+ {
+ //Setting the Desired text mode as is it in post screen
+ SetDesiredTextMode ();
+ }
+
+ }
+ else
+ {
+ gMaxRows = STYLE_STD_MAX_ROWS;
+ gMaxCols = STYLE_STD_MAX_COLS;
+ }
+#endif
+
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+
+ MouseStop();
+ // Clear the Screen
+ ClearGrphxScreen ();//To clear screen while drawing logo at (0,0) co-ordinates
+// ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+ DoRealFlushLines();
+ MouseRefresh();
+
+ PasswordPrompt = HiiGetString( gHiiHandle, PromptToken);
+ if ( PasswordPrompt != NULL )
+ {
+ if ( (TestPrintLength(PasswordPrompt) / NG_SIZE +6) > DlogWidth )
+ DlogWidth = TestPrintLength(PasswordPrompt) / NG_SIZE +6;
+ }
+
+ if (DlogWidth >= (gMaxCols-2)) //EIP-135665 If string is more than gMaxCols 80/100
+ {
+ if ( IsTSEMultilineControlSupported() ) //If multiline supported
+ {
+ Height=(DlogWidth / (gMaxCols-2))+(((DlogWidth % (gMaxCols-2)) > 0)?1:0);
+ DlogWidth = gMaxCols-2;
+ }
+ else
+ {
+ DlogWidth = gMaxCols-2;
+ PasswordPrompt[DlogWidth-4]=L'\0';
+ PasswordPrompt[DlogWidth-5]=L'.';
+ PasswordPrompt[DlogWidth-6]=L'.';
+ PasswordPrompt[DlogWidth-7]=L'.';
+ }
+ }
+
+ *CurrYPos = (gMaxRows - 5) / 2;
+ *CurrXPos = (gMaxCols-2 - DlogWidth) / 2;
+
+ //EIP-70175 Set Password Window color
+ //DrawWindow( *CurrXPos, *CurrYPos, DlogWidth, 5, EFI_BACKGROUND_BLUE | EFI_WHITE, TRUE, FALSE );
+ DrawWindow( *CurrXPos, *CurrYPos, DlogWidth, 4+Height, GetPasswordPopupWindowColor(), TRUE, FALSE );
+
+ if ( PasswordPrompt != NULL )
+ {
+ if ( IsTSEMultilineControlSupported() ) //If multiline supported
+ DrawMultiLineStringWithAttribute ((*CurrXPos)+2, *CurrYPos, DlogWidth-3, Height, PasswordPrompt, 0);
+ else
+ DrawStringJustified( 0, gMaxCols-2, *CurrYPos, JUSTIFY_CENTER, PasswordPrompt );
+ }
+ MemFreePointer( (VOID **)&PasswordPrompt );
+
+ //Record position of the Box
+ *CurrXPos = ((gMaxCols - DlogWidth) / 2)+1; //EIP-173320 HDD password prompt issue
+ *CurrYPos += Height+1;
+
+ FlushLines( *CurrYPos - Height-1, *CurrYPos + 2);
+ MouseStop();
+ DoRealFlushLines();
+ MouseRefresh();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ReportInBox
+//
+// Description: Function to report using Box
+//
+// Input: UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos,
+// UINTN CurrYPos, BOOLEAN bWaitForReturn
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _ReportInBox(
+ UINTN PasswordLength,
+ UINT16 BoxToken,
+ UINTN CurrXPos,
+ UINTN CurrYPos,
+ BOOLEAN bWaitForReturn
+ )
+{
+ CHAR16 *BoxStr=NULL;
+ EFI_INPUT_KEY Key;
+
+ //Draw Box
+ //EIP-70175 Set Password ReportInbox color
+ //DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, EFI_BACKGROUND_BLUE | EFI_WHITE );
+ DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, GetPasswordReportInboxcolor());
+
+ //Draw Box string
+ if(BoxToken != INVALID_TOKEN)
+ {
+ BoxStr = HiiGetString( gHiiHandle, BoxToken );
+ DrawString( CurrXPos, CurrYPos, BoxStr);
+ }
+
+ SetPwdKeyboardLayout();//EIP-88912
+ TSEStringReadLoopEntryHook();
+
+ FlushLines( CurrYPos - 2, CurrYPos + 2 );
+ MouseStop();
+ DoRealFlushLines();
+ MouseRefresh();
+
+ if(bWaitForReturn)
+ {
+ MemFillUINT16Buffer(BoxStr, (TestPrintLength(BoxStr)/ NG_SIZE), L' ');
+
+ Key.UnicodeChar = 0;
+ do
+ {
+ gST->ConIn->ReadKeyStroke( gST->ConIn, &Key );
+ } while( Key.UnicodeChar != CHAR_CARRIAGE_RETURN );
+
+ DrawString( CurrXPos, CurrYPos, BoxStr);
+ MemFreePointer((VOID **) &BoxStr);
+ }
+
+ TSEStringReadLoopExitHook();
+ ResetPwdKeyboardLayout();//EIP-88912
+
+ MemFreePointer((VOID **)&BoxStr);
+}
+
+VOID SetPwdTimeOut( EFI_EVENT Event, BOOLEAN *timeout )
+{
+ if ( timeout != NULL )
+ *timeout = TRUE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _GetPassword
+//
+// Description: Function to get password from the user
+//
+// Input: CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos,
+// UINTN CurrYPos, UINTN *pTimeOut
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetPassword(
+ CHAR16 *PasswordEntered,
+ UINTN PasswordLength,
+ UINTN CurrXPos,
+ UINTN CurrYPos,
+ UINTN *pTimeOut
+ )
+{
+ EFI_INPUT_KEY Key = {0,0};
+ UINTN StrIndex;
+ CHAR16 *StrStar;
+ UINTN i;
+ volatile BOOLEAN bTimeOut = FALSE;
+ UINTN TimeOutValue;
+ EFI_EVENT timer;
+ EFI_STATUS Status;
+ AMI_EFI_KEY_DATA KeyData;
+
+ MemSet( PasswordEntered, (PasswordLength + 1)*sizeof(CHAR16), 0 );
+ StrStar = EfiLibAllocatePool((PasswordLength + 1)*sizeof(CHAR16));
+ StrIndex = 0;
+
+ //EIP-70175 Set Password PopupTextBox color
+ //DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, EFI_BACKGROUND_LIGHTGRAY | EFI_BLUE );
+ DrawBox( CurrXPos, CurrYPos, PasswordLength, 1, GetPasswordPopupTextBoxColor() );
+
+ FlushLines( CurrYPos, CurrYPos );
+ MouseStop();
+ DoRealFlushLines();
+ MouseRefresh();
+
+ SetPwdKeyboardLayout();//EIP-88912
+ TSEStringReadLoopEntryHook();
+
+ if (IsTSECursorSupport()) //EIP-91364
+ {
+ gST->ConOut->SetCursorPosition( gST->ConOut, CurrXPos, CurrYPos); //EIP:67695 Cursor support for msg boxes
+ gST->ConOut->EnableCursor(gST->ConOut, TRUE);//EIP:67695 Enable Cursor support for msg boxes
+ }
+ do
+ {
+ TimeOutValue = pTimeOut ? *pTimeOut : 0;
+
+ if(TimeOutValue)
+ {
+ timer = NULL;
+ Status = TimerCreateTimer( &timer, SetPwdTimeOut, (VOID *)&bTimeOut, TimerRelative, TimeOutValue * TIMER_ONE_SECOND, EFI_TPL_NOTIFY );
+ }
+
+ // While the timeout has not expired
+ while ( ! bTimeOut )
+ {
+ Status = AMIReadKeyStroke(&Key,&KeyData);
+ if ( !(EFI_ERROR(Status)) )
+ break;
+ }
+
+ if(TimeOutValue)
+ TimerStopTimer( &timer );
+
+ if(bTimeOut)
+ {
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ MemFreePointer((VOID **)&StrStar);
+ PasswordEntered[0] = L'\0';
+ break;
+ }
+
+ switch (Key.UnicodeChar)
+ {
+ case CHAR_NULL:
+ if (Key.ScanCode == SCAN_ESC)
+ {
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ MemFreePointer((VOID **)&StrStar);
+ PasswordEntered[0] = L'\0';
+ TSEStringReadLoopExitHook();
+ ResetPwdKeyboardLayout();//EIP-88912
+ return EFI_ABORTED;
+ }
+ if (Key.ScanCode != SCAN_NULL) {
+ if(HelperIsPasswordCharValid(&Key,&KeyData,StrIndex,PasswordLength,&PasswordEntered[StrIndex]) == EFI_SUCCESS)
+ StrIndex++;
+ }
+ else {
+ InvalidActionHookHook();
+ }
+ break;
+
+ case CHAR_CARRIAGE_RETURN:
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ MemFreePointer((VOID **)&StrStar);
+ TSEStringReadLoopExitHook();
+ ResetPwdKeyboardLayout();//EIP-88912
+ return EFI_SUCCESS;
+
+ case CHAR_BACKSPACE:
+ if ( StrIndex != 0 )
+ PasswordEntered[--StrIndex] = L'\0';
+ break;
+
+ default:
+ if(HelperIsPasswordCharValid(&Key,&KeyData,StrIndex,PasswordLength,&PasswordEntered[StrIndex]) == EFI_SUCCESS)
+ StrIndex++;
+ break;
+ }
+ if ( StrIndex > PasswordLength ) {
+ InvalidActionHookHook();
+ }
+ //Draw stars for entered characters
+ for ( i = 0; i < PasswordLength; i++ )
+ StrStar[i] = (i<StrIndex) ? L'*': L' ';
+ StrStar[PasswordLength] = L'\0';
+
+ DrawString( CurrXPos, CurrYPos, StrStar );
+ FlushLines( CurrYPos, CurrYPos );
+ MouseStop();
+ DoRealFlushLines();
+
+ if (IsTSECursorSupport()) //EIP-91364
+ {
+ gST->ConOut->SetCursorPosition( gST->ConOut, ((PasswordLength!=StrIndex)?(CurrXPos + StrIndex):(CurrXPos + StrIndex-1)), CurrYPos); //EIP:67695 For restricting the cursor within the limit
+ gST->ConOut->EnableCursor(gST->ConOut, TRUE); //EIP:67695 Enable Cursor support for msg boxes
+ }
+ MouseRefresh();
+ }
+ while( 1 );
+
+ TSEStringReadLoopExitHook();
+ ResetPwdKeyboardLayout();//EIP-88912
+
+ //EIP-75379 Suppress the warnings from static code analyzer
+ if (pTimeOut)
+ *pTimeOut = 0;
+ return EFI_TIMEOUT;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/print.c b/EDK/MiniSetup/BootOnly/print.c
new file mode 100644
index 0000000..f8a4549
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/print.c
@@ -0,0 +1,476 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/print.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 5/21/14 6:27p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/print.c $
+//
+// 9 5/21/14 6:27p Arunsb
+// [TAG] EIPEIP169096,168632
+// [Description] Changed global variable guid usage for tse debug messages
+// [Files] commonoem.c, setupdbg.h and print.c
+//
+// 8 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 5/29/12 4:34a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 6 11/14/11 2:58p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// Update an incorrect string field.
+//
+// 5 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/15/10 10:11p Madhans
+// to avoid compilation issues
+//
+// 4 6/24/09 6:09p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Print.c
+//
+// Description: file contains code to support the print functionalities
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+/*++
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+#include "minisetup.h"
+#include "setupdbg.h"
+
+#if !TSE_USE_EDK_LIBRARY
+
+typedef struct _EFI_PRINT_PROTOCOL EFI_PRINT_PROTOCOL;
+
+typedef UINTN (EFIAPI *EFI_VSPRINT)(
+ OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString, IN va_list Marker
+);
+extern EFI_GUID gEfiPrintProtocolGuid;
+struct _EFI_PRINT_PROTOCOL{
+ EFI_VSPRINT VSPrint;
+};
+
+#else
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include "EfiPrintLib.h"
+
+#endif
+
+//EIP75481 Support TSE debug print infrastructure
+#if TSE_DEBUG_MESSAGES
+
+extern BOOLEAN SetupDebugKeyHandler(UINT16 ItemIndex, UINT16 Unicode, CHAR16 *Value) ;
+extern EFI_STATUS DisplayParseFormSetData(VOID) ;
+extern EFI_STATUS DebugShowAllHiiVariable(UINT32 formID);
+#endif
+//typedef CHAR16 CHAR_W;
+#if TSE_APTIO_5_SUPPORT
+#define AMITSE_VSPrint Swprintf_s_va_list
+#else
+#define AMITSE_VSPrint VSPrint
+#endif
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------------
+// Procedure: VSPrint
+//
+// Description: VSPrint function to process format and place the results in Buffer. Since a
+// VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+// this is the main print working routine
+//
+// Input: StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
+// BufferSize - Maximum number of characters to put into buffer. Zero means no limit.
+// FormatString - Unicode format string see file header for more details.
+// Marker - Vararg list consumed by processing Format.
+//
+// Output: Number of characters printed.
+//
+//-------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN
+VSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+{
+ EFI_STATUS Status;
+ EFI_PRINT_PROTOCOL *PrintProtocol;
+
+ Status = gBS->LocateProtocol (
+ &gEfiPrintProtocolGuid,
+ NULL,
+ &PrintProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return 0;
+ } else {
+ return PrintProtocol->VSPrint (
+ StartOfBuffer,
+ BufferSize,
+ FormatString,
+ Marker
+ );
+ }
+}
+
+
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------------
+// Procedure: SPrint
+//
+// Description: SPrint function to process format and place the results in Buffer
+//
+// Input: Buffer - Wide char buffer to print the results of the parsing of Format into.
+// BufferSize - Maximum number of characters to put into buffer. Zero means no limit.
+// Format - Format string see file header for more details.
+// ... - Vararg list consumed by processing Format.
+//
+// Output: Number of characters printed.
+//
+//-------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN
+SPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = AMITSE_VSPrint(Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+#define MAX_DEBUG_STRING_SIZE 1000
+
+CHAR16 tmpBuffer[MAX_DEBUG_STRING_SIZE];
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------------------------
+// Procedure: SetupDebugPrint
+//
+// Description:
+//
+// Input:
+//
+// Output:
+//
+//-------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetupDebugPrint(IN CONST CHAR8 *Format, ...)
+{
+ UINTN Return = 0;
+ VA_LIST Marker;
+ CHAR16 *c16Format = (CHAR16 *)NULL;
+ CHAR8 *trace = NULL;
+
+ c16Format = StrDup8to16((CHAR8 *)Format);
+
+ VA_START (Marker, Format);
+ Return = AMITSE_VSPrint(tmpBuffer, MAX_DEBUG_STRING_SIZE, (CONST CHAR16 *)c16Format, Marker);
+ VA_END (Marker);
+
+ //For TRACE (Serial Output)
+#if SERIAL_DEBUG
+// TRACE(-1, Format, Marker);
+
+ trace = StrDup16to8(tmpBuffer);
+ TRACE ((-1, trace));
+ MemFreePointer( (VOID **)&trace );
+
+#else //Else of SERIAL_DEBUG
+
+#if SCREEN_PRINT
+ Print(tmpBuffer);
+#else //Else of SCREEN_PRINT
+ if(gST->ConOut){
+ gST->ConOut->OutputString( gST->ConOut, tmpBuffer );
+ }
+#endif //End of SCREEN_PRINT
+#endif //End of SERIAL_DEBUG
+ MemFreePointer( (VOID **)&c16Format );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SetupShowDebugScreen
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+//extern VOID HandleDebugDumpKey( VOID *app, VOID *hotkey, VOID *cookie );
+VOID SetupShowDebugScreen(VOID *app, VOID *hotkey, VOID *cookie )
+{
+
+#if TSE_DEBUG_MESSAGES
+ CHAR16 HiiParseing[2] = L"x" ;
+ CHAR16 HiiFunction[2] = L"x" ;
+ CHAR16 HiiNotification[2] = L"x";
+ CHAR16 HiiCallback[2] = L"x" ;
+ CHAR16 PrintIfrForm[27] = L"press any key" ;
+ CHAR16 PrintVariableCache[27] = L"press any key" ;
+
+ TEXT_INPUT_TEMPLATE SetupDebugItems[6] =
+ {
+ {STRING_TOKEN(STR_DBG_PRINT_HIIPARSING), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiParseing},
+ {STRING_TOKEN(STR_DBG_PRINT_HIIFUNCTION), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiFunction},
+ {STRING_TOKEN(STR_DBG_PRINT_HIICALLBACK), 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiCallback},
+ {STRING_TOKEN(STR_DBG_PRINT_HIINOTIFICATION) , 1, TSE_FILTER_KEY_CUSTOM, FALSE, HiiNotification},
+ {STRING_TOKEN(STR_DBG_PRINT_IFRFORM), 13, TSE_FILTER_KEY_CUSTOM, FALSE, PrintIfrForm},
+ {STRING_TOKEN(STR_DBG_PRINT_VARIABLE_CACHE), 13, TSE_FILTER_KEY_CUSTOM, FALSE, PrintVariableCache}
+ };
+
+ UINT16 Title = HiiAddString( gHiiHandle, L"TSE Debug Print") ;
+
+ if((gDbgPrint & PRINT_UEFI_PARSE)!= PRINT_UEFI_PARSE)
+ EfiStrCpy( HiiParseing, L" ") ;
+
+ if((gDbgPrint & PRINT_UEFI)!= PRINT_UEFI)
+ EfiStrCpy( HiiFunction, L" ") ;
+
+ if((gDbgPrint & PRINT_UEFI_NOTIFICATION)!= PRINT_UEFI_NOTIFICATION)
+ EfiStrCpy( HiiNotification, L" ") ;
+
+ if((gDbgPrint & PRINT_UEFI_CALLBACK)!= PRINT_UEFI_CALLBACK)
+ EfiStrCpy( HiiCallback, L" ") ;
+
+
+
+ PostManagerDisplayTextBox(
+ gHiiHandle,
+ Title,
+ SetupDebugItems,
+ 6,
+ SetupDebugKeyHandler
+ ) ;
+#endif
+}
+
+#if TSE_DEBUG_MESSAGES
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SetupShowDebugScreen
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetupToggleDebugFeature(UINT16 FeatureBit, CHAR16 *Value)
+{
+
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_GUID guidDbgPrint = TSE_DEBUG_MESSAGES_GUID;
+
+ if((gDbgPrint & FeatureBit)== FeatureBit)
+ {
+ gDbgPrint &= ~((UINT16)FeatureBit) ;
+ EfiStrCpy( Value, L" ") ;
+ }
+ else
+ {
+ gDbgPrint |= (UINT16)FeatureBit ;
+ EfiStrCpy( Value, L"x");
+ }
+
+ Status = pRS->SetVariable(L"TseDebugPrint",
+ &guidDbgPrint,
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(gDbgPrint),
+ &gDbgPrint);
+
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SetupDebugKeyHandler
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN SetupDebugKeyHandler(UINT16 ItemIndex, UINT16 Unicode, CHAR16 *Value)
+{
+
+ switch(ItemIndex)
+ {
+ case 0:
+ SetupToggleDebugFeature(PRINT_UEFI_PARSE, Value) ;
+ break ;
+ case 1:
+ SetupToggleDebugFeature(PRINT_UEFI, Value) ;
+ break ;
+ case 2:
+ SetupToggleDebugFeature(PRINT_UEFI_CALLBACK, Value) ;
+ break ;
+ case 3:
+ SetupToggleDebugFeature(PRINT_UEFI_NOTIFICATION, Value) ;
+ break ;
+ case 4:
+ DisplayParseFormSetData() ;
+ break;
+ case 5:
+ DebugShowAllHiiVariable(0) ;
+ break;
+ default:
+
+ break;
+ }
+
+ return TRUE ;
+}
+
+
+#endif //End of TSE_DEBUG_MESSAGES
+//EIP75481
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/protocol.c b/EDK/MiniSetup/BootOnly/protocol.c
new file mode 100644
index 0000000..d112674
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/protocol.c
@@ -0,0 +1,1870 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 51 $
+//
+// $Date: 8/28/14 7:36a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.c $
+//
+// 51 8/28/14 7:36a Premkumara
+// [TAG] EIP107833, 125388
+// [Category] Improvement
+// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces
+// before TSE or after TSE.
+// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl,
+// PostMgmtc, PostmgmtExt.c, MessagBox.c
+//
+// 50 5/02/14 7:06a Premkumara
+// [TAG] EIP137373
+// [Category] Improvement
+// [Description] Added signal event for BeforeTimeOut and AfterTimeOut
+// with guids
+// [Files] AMIVfr.h,protocol.c
+//
+// 49 5/02/14 6:15a Arunsb
+// [TAG] EIP128665
+// [Category] Improvement
+// [Description] Providing support to invalidate the BGRT status bit.
+// Defined gTSEInvalidateBgrtStatusProtocolGuid
+// [Files] protocol.c and amivfr.h
+//
+// 48 5/02/14 6:12a Arunsb
+// [TAG] EIP128665
+// [Category] Improvement
+// [Description] Providing support to invalidate the BGRT status bit
+// [Files] protocol.c and amivfr.h
+//
+// 47 2/11/14 8:09p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 46 11/07/13 1:55a Premkumara
+// [TAG] EIP-137373
+// [Category] Improvement
+// [Description] Added signal event for BeforeTimeOut and AfterTimeOut
+// with GUID
+// [Files] Protocol.c, AMIVfr.h
+//
+// 45 10/07/13 3:17a Premkumara
+// Resolved build error in EIP-128665
+//
+// 44 9/13/13 2:01p Premkumara
+// Uploaded back for EIP-128665 after TSEBootOnly 1240 release
+// Files - Protocol.c, Protocol.h, AMIPostMgr.h
+//
+// 43 8/26/13 2:16a Premkumara
+// Reverted back for BootOnly1240 release
+//
+// 41 4/18/13 6:15a Arunsb
+// [TAG] EIP113081
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Post message displays twice
+// [RootCause] Buffer not cleared after displaying post message
+// [Solution] Buffer cleared properly. Save and restored the post
+// graphics screen properly.
+// [Files] protocol.c, screen.c and string.c
+//
+// 40 4/17/13 12:38p Arunsb
+// [TAG] EIP107967
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Ami Post Management functionalities reliant on ConOut need
+// checks added.
+// [Files] protocol.c
+//
+// 39 12/05/12 5:31a Rajashakerg
+// [TAG] EIP103381
+// [Category] Improvement
+// [Description] adopting SDL to control timeout spec
+// [Files] AMITSE.sdl, CommonHelper.c, protocol.c
+//
+// 38 12/05/12 4:50a Arunsb
+// [TAG] EIP107967
+// [Category] Improvement
+// [Description] Ami Post Management functionalities reliant on ConOut
+// need checks added
+// [Files] protocol.c
+//
+// 37 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 31 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 35 9/24/12 9:14a Premkumara
+// [TAG] EIP 93797
+// [Category] Improvement
+// [Description] Add support to check for enabled device in BBS priority
+// order before launching legacy boot.
+// [Files] bbs.c, Boot.c, Protocol.c
+//
+// 34 9/17/12 6:10a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 32 8/27/12 6:21a Premkumara
+// [TAG] EIP 94616
+// [Category] Improvement
+// [Description] TSE should not wait for key if fast boot is in progress
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Protocol.c
+//
+// 31 5/29/12 4:35a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 30 5/28/12 5:52a Premkumara
+// [TAG] EIP75236
+// [Category] Improvement
+// [Description] Add the support to control the GOP dependency in TSE
+// notification.
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
+// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
+//
+// 29 4/27/12 10:25a Premkumara
+// [TAG] EIP87769
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Strings are not cleared after calling
+// PostManagerSwitchToPostScreen() function
+// [RootCause] DoRealFlushLines() is not done in
+// PostManagerSwitchToPostScreen() function
+// [Solution] Updateed the PostManagerSwitchToPostScreen() function to
+// perform DoRealFlushLines().
+// [Files] Protocol.c
+//
+// 28 4/04/12 12:27a Rajashakerg
+// [TAG] EIP86253
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse and SoftKbd does not work after displaying "No option
+// to boot to" in POST
+// [RootCause] Mouse timer cleared once after displaying the "No option
+// to boot to" in POST
+// [Solution] Mouse timer cleared only when its going to boot.
+// [Files] CommonHelper.c, commonoem.c, minisetupext.c, protocol.c
+//
+// 27 4/03/12 9:54a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 26 4/03/12 3:01a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 25 1/25/12 5:12a Rajashakerg
+// [TAG] EIP81549
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BOOT_FLOW_NORMAL_INFINITE_LOOP enabled and pressing F7
+// while displaying "No option to boot to" is not working properly
+// [RootCause] When F7 key is pressed we have gBootFlow =
+// BOOT_FLOW_CONDITION_BBS_POPUP, and returning from checkforkey() and the
+// F7 key is not getting consumed and keeps on looping.
+// [Solution] Checking gBootFlow and making to normal in the loop.
+// [Files] protocol.c
+//
+// 24 12/30/11 1:51a Arunsb
+// [TAG] EIP76721
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BOOT_FLOW_NORMAL_INFINITE_LOOP option is not working
+// properly
+// [RootCause] Iterating variable reinitialized to 0 so in next loop it
+// becoming 1 so its missing first boot option
+// [Solution] Iterating vairable reinitialized to -1.
+// [Files] Protocol.c
+//
+// 23 11/21/11 5:48a Rajashakerg
+// [TAG] EIP74591
+// [Category] Improvement
+// [Description] Make MainSetupLoop as board module hook
+// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
+// FormBrowser.c, FormBrowser2.c
+//
+// 22 11/20/11 7:19a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 21 10/31/11 2:14p Premkumara
+// [TAG] EIP73751
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] L"BootFlow" variable uses inconsistent attributes
+// [RootCause] L"BootFlow" variable uses inconsistent attributes in
+// protocol.c
+// [Solution] Made consistent use of L"Bootlow" variable with
+// EFI_VARIABLE_BOOTSERVICE_ACCESS attribute
+// [Files] protocol.c
+//
+// 20 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 19 6/23/11 7:38p Arunsb
+// [TAG] EIP57660
+// [Category] New Feature
+// [Description] Non-removable media boot behavior as described in UEFI
+// specification v 2.3.1, p. 3.4.1.
+// Checks for the setup key if no boot options avail
+// or not succedded to boot. If setup key pressed launches
+// the setup.
+// If no boot option avail then inserting thumb drive with
+// image efi\boot\bootxxxx.efi TSE will launch that image.
+// [Files] amitse.sdl, bootflow.c and protocol.c
+//
+// 18 6/20/11 3:59p Arunsb
+// [TAG] EIP57660
+// [Category] New Feature
+// [Description] Non-removable media boot behavior as described in UEFI
+// specification v 2.3.1, p. 3.4.1.
+// Checks for the setup key if no boot options avail
+// or succedded to boot and launches the setup.
+// [Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c,
+// boot.c and protocol.c
+//
+// 17 1/06/11 1:58a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP is getting
+// corrupted.
+// [Solution] Updated the files, by making gGOP/gUgaDraw to NULL in the
+// update function and in switch to posty screen returining status as
+// aborted if the gGOP/gUgaDraw is NULL
+// [Files] protocol.c,notify.c,postmgmt.c
+//
+// 16 12/29/10 2:33a Mallikarjunanv
+// [TAG] EIP50479
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Calls to PostManagerProtocol->SwitchToPostScreen() after
+// legacy option ROM execution cause CPU exception.
+// [RootCause] After the notification, if the graphics driver
+// uninstalled and reinstalled from core module then gGOP getting
+// corrupted.
+// [Solution] Updated gGop/Ugadraw before using it in AMITSE.
+// [Files] logo.c,minisetup.h, notify.c, postmgmt.c ,protocol.c
+//
+// 15 12/02/10 1:07p Madhans
+// [TAG] - EIP 41838
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Update AMI Post Manager Protocol witht he following. 2.
+// Updating the interface PostManagerDisplayPostMessageEx to handle the
+// cursor position properly. 2. Need to add new interface to GetAttribute
+// To keep the GetAttribute to end of protocol.
+// [Rootcause] - 1. Display string is over written by the next string if
+// the interface PostManagerDisplayPostMessageEx used simultaneously. 2.
+// Need to get the attribute info to use PostManagerDisplayPostMessage
+// interfaces effectively
+// [Solution]- Fix in string.c to handle cursor and line positions. The
+// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface
+// implementaion to get the attribute.
+// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c
+//
+// 14 11/16/10 8:56a Mallikarjunanv
+// [TAG] - EIP 41838
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Update AMI Post Manager Protocol witht he following. 2.
+// Updating the interface PostManagerDisplayPostMessageEx to handle the
+// cursor position properly. 2. Need to add new interface to GetAttribute
+// [Rootcause] - 1. Display string is over written by the next string if
+// the interface PostManagerDisplayPostMessageEx used simultaneously. 2.
+// Need to get the attribute info to use PostManagerDisplayPostMessage
+// interfaces effectively
+// [Solution]- Fix in string.c to handle cursor and line positions. The
+// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface
+// implementaion to get the attribute.
+// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c
+//
+// 13 10/05/10 6:41p Madhans
+// [TAG] - EIP 45301
+// [Category]- Bug Fix
+// [Severity]- Minor
+// [Symptom]- when TSE_PRESERVE_DISABLED_BBS_DEVICE_ORDER is set disabling
+// first device cause system not to boot.
+// [Rootcause] - protocol.c was assuming disabled opens are coming in the
+// End.
+// [Solution]- Fix in protocol.c to handle this case.
+// [Files] - protocol.c
+//
+// 12 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 23 9/13/10 4:34p Madhans
+// 1. To preserve FastBootflow condition before going to Boottimeout.
+// 2. Preformance Calls optimized.
+//
+// 22 9/13/10 12:11p Blaines
+// Fix for the gPostMsgProtocolActive not being available past a certain
+// point
+//
+// 21 9/08/10 6:53a Mallikarjunanv
+// EIP-42080: TSE updates with respect to Fast Boot Support
+//
+// 20 6/17/10 4:19p Madhans
+//
+// 19 6/17/10 3:20p Blaines
+// Added error checking to PostManagerDisplayQuietBootMessage() for
+// messages that are 0 in length.
+//
+// 18 6/14/10 7:06p Madhans
+//
+// 17 4/02/10 4:34p Madhans
+//
+// 16 3/30/10 4:45p Blaines
+// Fix to prevent BBS Popup from being launched twice when selecting
+// ENTER_SETUP option
+//
+// 15 3/23/10 5:09p Blaines
+// Add PostManager Extentions
+//
+// 14 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 13 2/17/10 7:02p Madhans
+// To support PrintQuiteBootmessage for UEFI 2.1
+//
+// 12 2/15/10 10:12p Madhans
+// To support Printquitebootmessage
+//
+// 11 2/04/10 11:21p Madhans
+// To remove Conout dependance
+//
+// 10 2/04/10 12:10p Blaines
+// Correct function header description for PostManagerSetAtribute.
+//
+// 9 2/04/10 12:03p Blaines
+// EIP-28005
+//
+// Added PostManagerSetAttribute to support display of text in color.
+// Added support for handling string characters --- \n, \r.
+//
+// 8 1/09/10 5:35a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 12/14/09 12:21p Blaines
+// Include EIP Comment
+//
+// EIP 28007, FIX: If Post message printed in the Quiteboot by using Set
+// cur position It is better to flash all the screen.
+//
+//
+// 6 10/28/09 5:37p Madhans
+//
+// 5 9/17/09 9:04a Sudhirv
+// Remove Load Driver Option from TSE 2.x as it will be handled from Core
+//
+// 4 9/16/09 6:15p Madhans
+// EIP 25416 : Support have 1/10 sec Timeout
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/13/09 2:22p Madhans
+// To patch the version number in the Bootonly TSE. update the build
+// number.
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 6 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 3/31/09 4:00p Madhans
+// UEFI2.1
+//
+// 4 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PROTOCOL.C
+//
+// Description: This file contains code for TSE exported protocol
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+UINT32 gBootFlow = BOOT_FLOW_CONDITION_NORMAL;
+
+BOOLEAN gDoNotBoot = FALSE;
+VOID StopClickEvent(VOID);//EIP-84150 Stopping ClickEvents
+
+static EFI_HANDLE gProtocolHandle = NULL;
+EFI_GUID gAmiPostManagerProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID;
+EFI_GUID gTSEInvalidateBgrtStatusProtocolGuid = TSE_INVALIDATE_BGRT_STATUS_PROTOCOL_GUID;
+
+BOOLEAN TseIgnoreKeyForFastBoot(); //EIP-94616 Don't wait for key when FastBoot is Enabled
+BOOLEAN GetBBSOptionStatus(BOOT_DATA *pBootData); //EIP-93797
+
+static AMI_POST_MANAGER_PROTOCOL gPostManagerProtocol =
+{
+ PostManagerHandshake,
+ PostManagerDisplayPostMessage,
+ PostManagerDisplayPostMessageEx,
+ PostManagerDisplayQuietBootMessage,
+ PostManagerDisplayMsgBox,
+ PostManagerSwitchToPostScreen,
+ PostManagerSetCursorPosition,
+ PostManagerGetCursorPosition,
+ PostManagerInitProgressBar,
+ PostManagerSetProgressBarPosition,
+ PostManagerGetPostStatus,
+ PostManagerDisplayInfoBox,
+ PostManagerSetAttribute,
+ PostManagerDisplayMenu,
+ PostManagerDisplayMsgBoxEx,
+ PostManagerDisplayProgress,
+ PostManagerGetAttribute, //EIP-41838: New interface added to get the attribute
+ PostManagerDisplayTextBox //EIP-64877: New interface added to get the text input
+};
+
+//EIP 128665 starts
+EFI_STATUS InvalidateBgrtStatusByProtocol (VOID);
+TSE_INVALIDATE_BGRT_STATUS_PROTOCOL gInvalidateBgrtStatus = {InvalidateBgrtStatusByProtocol};
+EFI_STATUS InstallInvalBGRTStatusProtocol (EFI_HANDLE Handle);
+//EIP 128665 ends
+
+EFI_STATUS ShowPostMsgBox(IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection);
+
+
+EFI_STATUS ShowPostMsgBoxEx(
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN MSGBOX_EX_CATAGORY MsgBoxExCatagory,
+ IN UINT8 MsgBoxType,
+ IN UINT16 *OptionPtrTokens, // Valid only with MSGBOX_TYPE_CUSTOM
+ IN UINT16 OptionCount, // Valid only with MSGBOX_TYPE_CUSTOM
+ IN AMI_POST_MGR_KEY *HotKeyList, // NULL - AnyKeyPress closes
+ IN UINT16 HotKeyListCount,
+ OUT UINT8 *MsgBoxSel,
+ OUT AMI_POST_MGR_KEY *OutKey
+ );
+EFI_STATUS ShowInfoBox(IN CHAR16 *InfoBoxTitle, IN CHAR16 *Message, IN UINTN TimeLimit, EFI_EVENT *RetEvent);
+
+EFI_STATUS HiiString2BltBuffer( CHAR16 *Message,
+ EFI_UGA_PIXEL Foreground,
+ EFI_UGA_PIXEL Background,
+ OUT UINTN *Width,
+ OUT EFI_UGA_PIXEL **BltBuffer,
+ OUT UINTN *BltGlyphWidth);
+EFI_STATUS DrawHiiStringBltBuffer(CHAR16 *Message, INTN CoOrdX, INTN CoOrdY, CO_ORD_ATTRIBUTE Attribute, EFI_UGA_PIXEL Foreground, EFI_UGA_PIXEL Background);
+EFI_STATUS ShowPostMenu (
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN UINT16 LegendToken,
+ IN POSTMENU_TEMPLATE *MenuData,
+ IN UINT16 MenuCount,
+ OUT UINT16 *pSelection
+);
+
+EFI_STATUS ShowPostTextBox(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN TEXT_INPUT_TEMPLATE *InputData,
+ IN UINT16 ItemCount,
+ IN DISPLAY_TEXT_KEY_VALIDATE DisplayTextKeyValidate
+);
+
+EFI_STATUS ShowPostProgress(
+ IN UINT8 ProgressBoxState,
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN UINTN Percent,
+ IN OUT VOID **Handle,
+ OUT AMI_POST_MGR_KEY *OutKey
+);
+BOOLEAN IsTseBestTextGOPModeSupported (VOID);
+EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode ); //EIP-107833 Fixing proper mode and resolution for post interfaces
+EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode ); //EIP-107833 Fixing proper mode and resolution for post interfaces
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InstallProtocol
+//
+// Description: This function installs different protocols exported.
+//
+// Input: VOID
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InstallProtocol( VOID )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &gProtocolHandle,
+ &gAmiPostManagerProtocolGuid, &gPostManagerProtocol,
+#ifdef USE_COMPONENT_NAME
+ &gEfiComponentNameProtocolGuid, &gComponentName,
+#endif
+ NULL
+ );
+ if ( !EFI_ERROR( Status ) )
+ {
+ Status = InstallFormBrowserProtocol(gProtocolHandle);
+ Status = InstallInvalBGRTStatusProtocol (gProtocolHandle);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UninstallProtocol
+//
+// Description: This function uninstalls different protocols exported.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UninstallProtocol( VOID )
+{
+ gBS->UninstallMultipleProtocolInterfaces(
+ &gProtocolHandle,
+ &gAmiPostManagerProtocolGuid, &gPostManagerProtocol,
+#ifdef USE_COMPONENT_NAME
+ &gEfiComponentNameProtocolGuid, &gComponentName,
+#endif
+ NULL
+ );
+
+ UnInstallFormBrowserProtocol(gProtocolHandle);
+
+}
+
+VOID SetBootTimeout( EFI_EVENT Event, BOOLEAN *timeout )
+{
+ if ( timeout != NULL )
+ *timeout = TRUE;
+}
+
+VOID AboartFastBootPath(VOID)
+{
+ gBootFlow = BOOT_FLOW_CONDITION_NORMAL;
+ gPostManagerHandshakeCallIndex--;
+ gRT->SetVariable(
+ L"BootFlow",
+ &_gBootFlowGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(gBootFlow),
+ &gBootFlow
+ );
+}
+BOOLEAN IsBootTimeOutValueZero(VOID);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerHandshake
+//
+// Description: This function is the handshake function to which BDS
+// hands-off.
+//
+// Input: VOID
+//
+// Output: This function never returns. It only boots different
+// options.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerHandshake( VOID )
+{
+ EFI_EVENT timer = NULL;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ volatile BOOLEAN bootTimeout = FALSE;
+ UINT16 Value = 1;
+ UINT64 TimeoutValue;
+ UINTN size = 0;
+ EFI_GUID AmitseAfterFirstBootOptionGuid = AMITSE_AFTER_FIRST_BOOT_OPTION_GUID;
+ EFI_GUID AmiTseBeforeTimeOutGuid = AMITSE_BEFORE_TIMEOUT_GUID;
+ EFI_GUID AmiTseAfterTimeOutGuid = AMITSE_AFTER_TIMEOUT_GUID;
+ BOOLEAN AfterFirstBootSignalled = FALSE;
+ UINT16 *pBootOrder=NULL;
+ UINT16 u16BootCount = 0,i; //Dont change i data type, in infinite loop it is reinitialized to -1.
+ UINT16 BootNext, *pBootNext = NULL;
+
+ // Performance measurement starta
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ RUNTIME_DEBUG( L"mre" );
+
+ gPostManagerHandshakeCallIndex++;
+
+ if(gPostManagerHandshakeCallIndex!=1)
+ {
+ gEnterSetup = TRUE;
+ goto _ShowMainMenu;
+ }
+
+ PostManagerHandShakeHookHook();
+
+#ifndef STANDALONE_APPLICATION
+ if ( ! gConsoleControl )
+ {
+ //All necessary protocols are not available yet.
+ //We can still proceed if Uga Draw is the only protocol not available yet.
+ ActivateApplication();
+ //EIP-75236
+ if (!IsDelayLogoTillInputSupported())
+ ActivateInput();
+ }
+#endif
+
+ if(!gVariableList)
+ VarLoadVariables( (VOID **)&gVariableList, NULL );
+
+ TimerStopTimer( &gKeyTimer );
+
+ // this *MUST* be run a EFI_TPL_APPLICATION
+ gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT
+ gBS->RestoreTPL( EFI_TPL_APPLICATION );
+
+ // Performance measurement Pause
+// PERF_END (0,L"Boot", NULL, 0);
+ // Exclude IDEPasswordCheck IDEPasswordCheck that it may get the use input.
+ // IDE password Module takes care of the Password check.
+ //TSEIDEPasswordCheck();
+
+ // Performance measurement continue
+// PERF_START (0, L"Boot", NULL, 0);
+
+ // get the current boot options and languages
+ BootGetBootOptions();
+ BootGetLanguages();
+
+ StyleUpdateVersionString();
+
+ gPostStatus = TSE_POST_STATUS_IN_BOOT_TIME_OUT;
+
+ //EIP 103381 - Providing boot time out value depending on TSE_BOOT_TIME_OUT_AS_ZERO token
+ if(!IsBootTimeOutValueZero())
+ Value = GetBootTimeOut(Value);
+ else
+ Value = 0;
+
+#ifdef STANDALONE_APPLICATION
+ Value = 0;
+ gEnterSetup = TRUE;
+#endif
+
+ if ( Value == 0 )
+ bootTimeout = TRUE;
+
+ if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616
+ {
+ CheckForKeyHook( (EFI_EVENT)NULL, NULL );
+ }
+
+ if((BOOT_FLOW_CONDITION_NORMAL != gBootFlow) || (gEnterSetup==TRUE))
+ {
+ UINT32 condition = BOOT_FLOW_CONDITION_NORMAL;
+ UINT32 *conditionPtr;
+
+ size = 0;
+ conditionPtr = VarGetNvramName( L"BootFlow", &_gBootFlowGuid, NULL, &size );
+ if ( conditionPtr != NULL )
+ condition = *conditionPtr;
+
+ MemFreePointer( (VOID **)&conditionPtr );
+
+ if((condition == BOOT_FLOW_CONDITION_FAST_BOOT) && ((gBootFlow != condition)||(gEnterSetup==TRUE)))
+ {
+ // Take the Normal boot path as Fast boot path is altered by CheckForKeyHook().
+ AboartFastBootPath();
+ return EFI_UNSUPPORTED;
+ }
+
+ if(BOOT_FLOW_CONDITION_NORMAL == condition)
+ {
+ gRT->SetVariable(
+ L"BootFlow",
+ &_gBootFlowGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,//EIP-73751 BootFlow wil use RS attribute to avoid inconsistent attributes
+ sizeof(UINT32),
+ &gBootFlow
+ );
+ }
+ else
+ gBootFlow = BOOT_FLOW_CONDITION_NORMAL;
+ }
+
+ Status = BootFlowManageEntry();
+ if (Status == EFI_UNSUPPORTED)
+ {
+ Value = 0xFFFF;
+ gDoNotBoot = TRUE;
+ }
+ if(Status == EFI_NOT_STARTED)
+ bootTimeout = TRUE;
+
+ if(gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT)
+ {
+ UINT32 PasswordInstalled = PasswordCheckInstalled();
+
+ if((gPasswordType == AMI_PASSWORD_NONE) && (PasswordInstalled != AMI_PASSWORD_NONE))
+ {
+ if(CheckSystemPasswordPolicy(PasswordInstalled))
+ {
+ // Take the Normal boot path as Password is installed and not validated by the user yet
+ AboartFastBootPath();
+ return EFI_UNSUPPORTED;
+ }
+ }
+ }
+ else
+ {
+ // Reinit Before Boottimeout So any action can set the boot flow again.
+ gBootFlow = BOOT_FLOW_CONDITION_NORMAL;
+ }
+
+ if ( Value != 0xFFFF )
+ {
+ TimeoutValue = (UINT64) TIMER_TENTH_SECOND;
+ TimeoutValue = MultU64x32( TimeoutValue, (UINT32) Value );
+
+ TimerCreateTimer( &timer, SetBootTimeout, (VOID *)&bootTimeout, TimerRelative, TimeoutValue, EFI_TPL_CALLBACK );
+ }
+
+ // Performance measurement Pause
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ // While the boot timeout has not expired
+ EfiLibNamedEventSignal (&AmiTseBeforeTimeOutGuid);
+ while ( ! bootTimeout )
+ {
+ if ( gEnterSetup || gBootFlow )
+ {
+ bootTimeout = TRUE;
+ continue;
+ }
+ if ( !TseIgnoreKeyForFastBoot() ) //EIP-94616
+ {
+ // check for 'hotkey' actions that would invoke something
+ CheckForKeyHook( (EFI_EVENT)NULL, NULL );
+ }
+
+ TimeOutLoopHookHook();
+ }
+ EfiLibNamedEventSignal (&AmiTseAfterTimeOutGuid);
+
+ // Performance measurement continue
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+
+ TimerStopTimer( &timer );
+
+ if ((!gDoNotBoot) && (gBootFlow))
+ {
+ gRT->SetVariable(
+ L"BootFlow",
+ &_gBootFlowGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,//EIP-73751 BootFlow wil use RS attribute to avoid inconsistent attributes
+ sizeof(UINT32),
+ &gBootFlow
+ );
+ BootFlowManageEntry();
+ }
+
+_ShowMainMenu:
+
+ if ( gEnterSetup )
+ {
+ // Performance measurement Pause
+ PERF_END (0, AMITSE_TEXT("Boot"), NULL, 0);
+ // Disable access to the post manager protocol display post message functions and to
+ // the switch to post screen functions of post manager protocol
+ gPostMsgProtocolActive = FALSE;
+
+ gPostStatus = TSE_POST_STATUS_ENTERING_TSE;
+ gSetupContextActive = TRUE;
+
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook
+ gSetupContextActive = FALSE;
+
+
+ // Reenable access to the post manager protocol display post message functions and to
+ // the switch to post screen functions of post manager protocol
+ gPostMsgProtocolActive = TRUE;
+ // Performance measurement continue
+ PERF_START (0, AMITSE_TEXT("Boot"), NULL, 0);
+ }
+
+
+ if(gPostManagerHandshakeCallIndex!=1)
+ {
+ // In case of not a first call
+ // Don't do the Boot Manager Work just exit the to caller.
+ gPostManagerHandshakeCallIndex--;
+ return Status;
+ }
+
+ // Pass control to the boot process to handle the selected boot option
+ // if the boot is allowed
+ if (gDoNotBoot)
+ {
+ if(!ItkSupport())
+ {
+ gEnterSetup = TRUE;
+ goto _ShowMainMenu;
+ }
+ else
+ gEnterSetup = FALSE;
+ }
+
+ if(!NoVarStoreSupport())
+ {
+ size = 0;
+ //VarGetNvram( VARIABLE_ID_AMITSESETUP, &size );
+ HelperGetVariable( VARIABLE_ID_AMITSESETUP, (CHAR16 *)NULL, (EFI_GUID *)NULL, NULL, &size );
+
+ if(size < sizeof(AMITSESETUP))
+ {
+ Status = MiniSetupEntry();
+ MiniSetupExit( Status );
+ }
+ }
+
+ gPostStatus = TSE_POST_STATUS_PROCEED_TO_BOOT;
+
+ // LoadDriverOrder(); //EIP: 25799 - Remove Load Driver Option from TSE 2.x as it is handling from Core.
+
+ ProcessProceedToBootHook();
+
+ TSEUnlockHDD();
+
+ if(ItkSupport())
+ BbsItkBoot();
+ else
+ {
+ //Try boot next first
+ size = 0;
+ pBootNext = (UINT16 *)VarGetNvramName(L"BootNext", &gEfiGlobalVariableGuid, NULL, &size);
+ if(pBootNext && (size == sizeof(UINT16)))
+ {
+ BootNext = *pBootNext;
+ //Clear Boot next
+ VarSetNvramName(L"BootNext",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ pBootNext,
+ 0);
+ if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) {
+ // FastBoot module normally checks for Bootnext before taking the FastBoot path
+ // If the Boot next is set in FastBoot case then do the full boot.
+ AboartFastBootPath();
+ return Status;
+ }
+ else {
+ BootLaunchBootOption(BootNext, NULL, 0);
+ }
+ }
+
+
+ if(pBootNext)
+ MemFreePointer((void **) &pBootNext);
+
+ size =0 ;
+ pBootOrder = (UINT16 *)VarGetNvramName( L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+
+ #ifdef EFI_NT_EMULATOR
+ if(!pBootOrder || !gBootData)
+ {
+ VarSetNvramName(L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NULL,
+ 0);
+
+ return Status;
+ }
+ #endif
+
+ //Get enabled options count
+ for(u16BootCount=0; u16BootCount<(UINT16)(size/sizeof(UINT16)); u16BootCount++ )
+ {
+ if(!IsPreservedDisabledBootOptionOrder())
+ {
+ BOOT_DATA *pBootData;
+
+ pBootData = BootGetBootData(pBootOrder[u16BootCount]);
+ if(!(pBootData->Active & LOAD_OPTION_ACTIVE))
+ break;
+ }
+ }
+
+ if(!u16BootCount)
+ {
+ //No valid/enabled boot option
+ Status = BootFlowManageExit();
+ //infinite loop
+ while(EFI_NOT_STARTED == Status)
+ {
+ CHAR16 *text = NULL;
+
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_NO_BOOT_OPTIONS));
+ if ( ( text != NULL ) && (gST->ConOut != NULL))
+ gST->ConOut->OutputString(gST->ConOut, text);
+
+ //Wait for key
+ gBS->WaitForEvent( 1, &gST->ConIn->WaitForKey, &size );
+ CheckForKeyHook( (EFI_EVENT)NULL, NULL );
+ if (TRUE == gEnterSetup) //If setup key detects then launch the setup
+ {
+ goto _ShowMainMenu;
+ }
+ Status = BootFlowManageExit (); //EIP: 57660 Condition: If user plugs the any thumb drive after boot then TSE will try to launch the image from that file system using the path efi\boot\bootxxxx.efi
+ if( gBootFlow )//EIP 81549 : Checking for gBootFlow, making gBootFlow to normal such that the key will be consumed in chcekforkey
+ gBootFlow = BOOT_FLOW_CONDITION_NORMAL;
+ }
+ }
+
+ if ( !gEnterSetup )//EIP-86253 If no key is pressed to go to setup then stopping MousePointingDevice and stopping ClickEvents
+ {
+ StopClickEvent();
+ MouseDestroy();
+ }
+ for ( i = 0; i < u16BootCount; i++)
+ {
+ BOOT_DATA *pBootData;
+
+ pBootData = BootGetBootData(pBootOrder[i]);
+
+ if(pBootData == NULL || !(pBootData->Active & LOAD_OPTION_ACTIVE))
+ continue;
+
+ if ( BBSValidDevicePath(pBootData->DevicePath) ) //EIP-93797
+ if ( GetBBSOptionStatus (pBootData) )
+ continue;
+
+ Status = BootLaunchBootOption(pBootOrder[i], pBootOrder+i, u16BootCount - i);
+
+ if ( !AfterFirstBootSignalled )
+ {
+ EfiLibNamedEventSignal ( &AmitseAfterFirstBootOptionGuid );
+
+ if( gBootFlow == BOOT_FLOW_CONDITION_FAST_BOOT) {
+ AboartFastBootPath();
+ return Status;
+ }
+
+ AfterFirstBootSignalled = TRUE;
+ }
+
+ if((i+1) >= u16BootCount)
+ {
+ Status = BootFlowManageExit();
+ if ( EFI_NOT_STARTED == Status )
+ {
+ CheckForKeyHook( (EFI_EVENT)NULL, NULL );
+ if (TRUE == gEnterSetup) //If setup key detects then launch the setup
+ {
+ goto _ShowMainMenu;
+ }
+ // Infinite loop is true so we start again
+ i = -1; //Changed 0 to -1. Then only in next iteration it will be zero otherwise it will be 1.
+ } //If it is i = 0 then it will miss first boot option
+ }
+ }
+
+ }
+#ifndef STANDALONE_APPLICATION
+ gEnterSetup = TRUE;
+ goto _ShowMainMenu;
+#else
+ return Status;
+#endif
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerDisplayPostMessage
+//
+// Description: This function is the protocol to display messages in
+// the post screen.
+//
+// Input: CHAR16 *message: Unicode string to be displayed.
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerDisplayPostMessage( CHAR16 *message )
+{
+ if ( ! gPostMsgProtocolActive )
+ return EFI_UNSUPPORTED;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ return PrintPostMessage(message, TRUE);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerDisplayPostMessageEx
+//
+// Description: This function is the protocol to display messages with
+// attributes in the post screen.
+//
+// Input: CHAR16 *message: Unicode string to be displayed.
+// UINTN Attribute: Attribute for the message
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerDisplayPostMessageEx( CHAR16 *message, UINTN Attribute )
+{
+ if ( ! gPostMsgProtocolActive )
+ return EFI_UNSUPPORTED;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ switch(Attribute)
+ {
+ case PM_EX_DONT_ADVANCE_TO_NEXT_LINE:
+ return PrintPostMessage(message, FALSE);
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerSwitchToPostScreen
+//
+// Description: This function is the protocol to switch to post screen
+//
+// Input: VOID
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerSwitchToPostScreen( VOID )
+{
+#ifdef STANDALONE_APPLICATION
+ return EFI_UNSUPPORTED;
+#else
+ if ( ! gPostMsgProtocolActive )
+ return EFI_UNSUPPORTED;
+
+ if ( gQuietBoot )
+ {
+ UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE.
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if (!gGOP)
+#else
+ if (!gUgaDraw)
+#endif
+ return EFI_UNSUPPORTED;//EIP:50479 : Returning unsupported if the GOP is NULL
+
+ gQuietBoot = FALSE;
+ CleanUpLogo();
+ //EIP 28007, FIX: If Post message printed in the Quiteboot by using Set cur position
+ // It is better to flash all the screen.
+ FlushLines( 0, gMaxRows - 1 );
+ DoRealFlushLines(); //EIP-87769
+ InitPostScreen();
+ return EFI_SUCCESS;
+ }
+
+ return EFI_UNSUPPORTED;
+#endif
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerInitProgressBar
+//
+// Description: Initializes the PostManagerProgressBar
+//
+// Input: UINTN x - Column or Left screen position of ProgressBar in pixels
+// UINTN y - Row or Top screen position of ProgressBar in pixels
+// UINTN w - Width of ProgressBar in pixels
+// UINTN h - Height of ProgressBar in pixels
+// UINTN iterate - Total number of iterations or Calls
+// to advanced the progressbar to 100% of the given width.
+// The delta or changed value will be computed.
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PostManagerInitProgressBar(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ UINTN iterate)
+{
+ EFI_STATUS Status = 0;
+
+ EFI_UGA_PIXEL *BGColor;
+ EFI_UGA_PIXEL *BDRColor;
+ EFI_UGA_PIXEL *FillColor;
+
+ BGColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL));
+ BDRColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL));
+ FillColor = EfiLibAllocateZeroPool(sizeof (EFI_UGA_PIXEL));
+
+ GetProgressColor(BGColor,BDRColor,FillColor);
+
+ gProgress->delta = w/iterate;
+ gProgress->w = gProgress->delta*iterate;
+ gProgress->h = h;
+ gProgress->x = x;
+ gProgress->y = y;
+ gProgress->backgroundColor = BGColor;
+ gProgress->borderColor = BDRColor;
+ gProgress->fillColor = FillColor;
+ gProgress->quiteBootActive = FALSE ;
+ gProgress->active = TRUE ; // progressbar has been initialized
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerSetProgressBarPosition
+//
+// Description: Increments the PostManagerProgressBar
+//
+// Input: None
+//
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PostManagerSetProgressBarPosition()
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ if(gProgress->active)
+ DrawBltProgressBar();
+ else
+ Status = EFI_UNSUPPORTED;
+
+ return Status;
+}
+
+
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerSetCursorPosition
+//
+// Description: Wrapper function for SetCurPos
+//
+// Input: UINTN X - Value of the column
+// UINTN Y - Number of row below the last written line
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PostManagerSetCursorPosition(UINTN X, UINTN Y)
+{
+ return SetCurPos(X,Y);
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerGetCursorPosition
+//
+// Description: Wrapper function for GetCurPos
+// Writes cursor position into given X and Y locations.
+//
+// Input: UINTN *pX - Pointer to storage for current column value
+// UINTN *pY - Pointer to storage for current row value
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if OK,
+// EFI_INVALID_PARAMETER if NULL pointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS PostManagerGetCursorPosition(UINTN *pX, UINTN *pY)
+{
+ return GetCurPos(pX, pY);
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerDisplayMsgBox
+//
+// Description:
+//
+//
+// Input: IN CHAR16 *MsgBoxTitle,
+// IN CHAR16 *Message,
+// IN UINT8 MsgBoxType,
+//
+// Output: EFI_STATUS status and UINT8 MsgBoxSel
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveGraphicsScreen(VOID);
+VOID RestoreGraphicsScreen(VOID);
+EFI_STATUS
+PostManagerDisplayMsgBox (
+ IN CHAR16 *MsgBoxTitle,
+ IN CHAR16 *Message,
+ IN UINT8 MsgBoxType,
+ OUT UINT8 *MsgBoxSel
+ )
+{
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ if( gPostStatus == TSE_POST_STATUS_IN_POST_SCREEN )
+ SaveGraphicsScreen();
+
+ Status = SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+ if (EFI_ERROR(Status))
+ return Status;
+
+ Status = ShowPostMsgBox(MsgBoxTitle, Message, MsgBoxType,MsgBoxSel);
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+
+ if( gPostStatus == TSE_POST_STATUS_IN_POST_SCREEN )
+ RestoreGraphicsScreen();
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerDisplayQuietBootMessage
+//
+// Description: Function for the quit booting display.
+//
+// Input: CHAR16 *Message, INTN CoOrdX, INTN CoOrdY,
+// CO_ORD_ATTRIBUTE Attribute, EFI_UGA_PIXEL Foreground,
+// EFI_UGA_PIXEL Background
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PostManagerDisplayQuietBootMessage(
+ CHAR16 *Message,
+ INTN CoOrdX,
+ INTN CoOrdY,
+ CO_ORD_ATTRIBUTE Attribute,
+ EFI_UGA_PIXEL Foreground,
+ EFI_UGA_PIXEL Background
+ )
+{
+#ifdef STANDALONE_APPLICATION
+ return EFI_UNSUPPORTED;
+#elif defined TSE_FOR_APTIO_4_50
+ UINTN BltGlyphWidth=0;
+ EFI_UGA_PIXEL *BltBuffer=NULL;
+ UINTN BltIndex;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN SizeOfX, SizeOfY;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ UpdateGoPUgaDraw();//EIP:50479 : Function to Update gGop before using it in AMITSE.
+ if(EFI_SUCCESS != HiiInitializeProtocol())
+ return EFI_UNSUPPORTED;
+
+ if(
+ (EFI_SUCCESS != GetScreenResolution(&SizeOfX, &SizeOfY))||
+ (!gQuietBoot)
+ )
+ return EFI_UNSUPPORTED;
+
+ if ((Message != NULL) && (EfiStrLen(Message) == 0))
+ return EFI_SUCCESS;
+ BltIndex = 0;
+
+ Status = HiiString2BltBuffer(Message,Foreground,Background,&BltIndex,&BltBuffer,&BltGlyphWidth);
+ if(Status == EFI_SUCCESS)
+ DrawBltBuffer(BltBuffer, Attribute, BltIndex, HiiGetGlyphHeight(), CoOrdX, CoOrdY, BltGlyphWidth);
+
+ //Free BltBuffer
+ MemFreePointer((VOID **)&BltBuffer);
+
+ return Status;
+#else
+// For EDK Nt32 support.
+// Status = DrawHiiStringBltBuffer(Message, CoOrdX, CoOrdY, Attribute, Foreground, Background);
+ return EFI_UNSUPPORTED;
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerGetPostStatus
+//
+// Description: Function returns current Post status.
+//
+// Input: none
+//
+// Output: One of the TSE_POST_STATUS
+// TSE_POST_STATUS_BEFORE_POST_SCREEN - TSE Loaded and yet goto post screen
+// TSE_POST_STATUS_IN_POST_SCREEN - In the post screen
+// TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN- In the quite boot screen
+// TSE_POST_STATUS_IN_BOOT_TIME_OUT - Witing for Boot timeout
+// TSE_POST_STATUS_ENTERING_TSE - Entering TSE
+// TSE_POST_STATUS_IN_TSE - Inside TSE
+// TSE_POST_STATUS_IN_BBS_POPUP - Inside BBS Poupup
+// TSE_POST_STATUS_PROCEED_TO_BOOT - Outside TSE and Booting or in Shell
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+TSE_POST_STATUS PostManagerGetPostStatus(VOID)
+{
+ return gPostStatus;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PostManagerDisplayInfoBox
+//
+// Description: Function to display the Information box
+//
+// Input: none
+//
+// Output: One of the TSE_POST_STATUS
+// TSE_POST_STATUS_BEFORE_POST_SCREEN - TSE Loaded and yet goto post screen
+// TSE_POST_STATUS_IN_POST_SCREEN - In the post screen
+// TSE_POST_STATUS_IN_QUITE_BOOT_SCREEN- In the quite boot screen
+// TSE_POST_STATUS_IN_BOOT_TIME_OUT - Witing for Boot timeout
+// TSE_POST_STATUS_ENTERING_TSE - Entering TSE
+// TSE_POST_STATUS_IN_TSE - Inside TSE
+// TSE_POST_STATUS_IN_BBS_POPUP - Inside BBS Poupup
+// TSE_POST_STATUS_PROCEED_TO_BOOT - Outside TSE and Booting or in Shell
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PostManagerDisplayInfoBox( IN CHAR16 *InfoBoxTitle,
+ IN CHAR16 *InfoString,
+ IN UINTN Timeout,
+ OUT EFI_EVENT *Event
+ )
+{
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ Status = SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ Status = ShowInfoBox(InfoBoxTitle, InfoString, Timeout, Event);
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+
+ return Status;
+
+}
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerSetAtribute
+//
+// Description: Function to set color
+//
+// Input: UINT8 Attrib - Text color
+//
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerSetAttribute(UINT8 Attrib)
+{
+ gPostMgrAttribute = Attrib ;
+ return EFI_SUCCESS ;
+}
+//EIP-41838: New interface to get the attribute using AMI Post Manager Protocol
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerGetAttribute
+//
+// Description: Function to Get color
+//
+// Input: UINT8 *Attrib - Pointer to get Text color
+//
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerGetAttribute(UINT8 *Attrib)
+{
+ *Attrib = gPostMgrAttribute ;
+ return EFI_SUCCESS ;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerDisplayMsgBoxEx
+//
+// Description: Wrapper function for Display OEM Message box.
+//
+//
+// Input: IN CHAR16 *MsgBoxTitle - Caption of the Message Box
+// IN CHAR16 *Message - String to be displayed by the Message Box
+// IN CHAR16 *Legend - Legend String to be displayed by the Message Box
+// IN UINT8 MsgBoxType - Message Box type
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if OK,
+// EFI_INVALID_PARAMETER if NULL pointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerDisplayMsgBoxEx (
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN MSGBOX_EX_CATAGORY MsgBoxExCatagory,
+ IN UINT8 MsgBoxType,
+ IN UINT16 *OptionPtrTokens, // Valid only with MSGBOX_TYPE_CUSTOM
+ IN UINT16 OptionCount, // Valid only with MSGBOX_TYPE_CUSTOM
+ IN AMI_POST_MGR_KEY *HotKeyList, // NULL - AnyKeyPress closes
+ IN UINT16 HotKeyListCount,
+ OUT UINT8 *MsgBoxSel,
+ OUT AMI_POST_MGR_KEY *OutKey
+)
+{
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ Status = SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ Status = ShowPostMsgBoxEx (Title, Message, Legend, MsgBoxExCatagory,
+ MsgBoxType, OptionPtrTokens, OptionCount,
+ HotKeyList, HotKeyListCount, MsgBoxSel, OutKey
+ );
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerDisplayProgress
+//
+// Description: Wrapper function for Display OEM Message box.
+//
+//
+// Input: IIN UINTN Percent - Percent Complete
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if OK,
+// EFI_INVALID_PARAMETER if NULL pointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerDisplayProgress (
+ IN UINT8 ProgressBoxState,
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN UINTN Percent, // 0 - 100
+ IN OUT VOID **Handle, //Out HANDLE. Valid Handle for update and close
+ OUT AMI_POST_MGR_KEY *OutKey //Out Key
+)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ Status = ShowPostProgress( ProgressBoxState, Title, Message, Legend, Percent, Handle, OutKey) ;
+ return Status ;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerDisplayMenu
+//
+// Description: Wrapper function for Display Menu.
+//
+//
+// Input: IN VOID *HiiHandle, - Handle that contains String
+// IN UINT16 TitleToken, - Menu Title Token
+// IN UINT16 LegendToken, - Menu Legend Token
+// IN POSTMENU_TEMPLATE *MenuData, - Menu Items to be displayed
+// IN UINT16 MenuCount, - Number of Menu items
+// OUT UINT16 *pSelection - Menu selection (DEFAULT)
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if OK,
+// EFI_INVALID_PARAMETER if NULL pointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PostManagerDisplayMenu (
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN UINT16 LegendToken,
+ IN POSTMENU_TEMPLATE *MenuData,
+ IN UINT16 MenuCount,
+ OUT UINT16 *pSelection
+)
+{
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ if(gPostStatus < TSE_POST_STATUS_IN_BOOT_TIME_OUT)
+ return EFI_NOT_READY;
+
+ Status = SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ Status = ShowPostMenu(HiiHandle, TitleToken, LegendToken, MenuData, MenuCount, pSelection);
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: PostManagerDisplayTextBox
+//
+// Description: Function to display text entry interface
+//
+//
+// Input: IN VOID *HiiHandle,
+// IN UINT16 TitleToken,
+// IN TEXT_INPUT_TEMPLATE *InputData,
+// IN UINT16 ItemCount,
+// IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+//
+// Output: EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PostManagerDisplayTextBox (
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN TEXT_INPUT_TEMPLATE *InputData,
+ IN UINT16 ItemCount,
+ IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+ )
+{
+ UINTN currenttextModeCols = 0, currenttextModeRows = 0;
+ UINT32 currentGOPMode = 0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (NULL == gST->ConOut)
+ return EFI_NOT_READY;
+
+ Status = SaveCurrentTextGOP (&currenttextModeCols, &currenttextModeRows, &currentGOPMode);
+
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ Status = ShowPostTextBox(HiiHandle, TitleToken, InputData, ItemCount, ValidateKeyFunc);
+
+ RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StopClickEvent
+//
+// Description: Function to Stop the Click Event
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StopClickEvent(VOID)
+{
+ if(gClickTimer)
+ {
+ gBS->SetTimer ( gClickTimer,TimerCancel,0);
+ TimerStopTimer( &gClickTimer );
+ }
+}
+
+//EIP 128665 starts
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: InvalidateBgrtStatusByProtocol
+//
+// Description: Protocol interface to invalidate BGRT status
+//
+//
+// Input: VOID
+//
+//
+// Output: EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InvalidateStatusInBgrtWrapper (VOID);
+EFI_STATUS InvalidateBgrtStatusByProtocol (VOID)
+{
+ InvalidateStatusInBgrtWrapper();
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: InvalidateBGRTStatusProtocol
+//
+// Description: Install Invalidate BGRT status protocol
+//
+// Parameter: EFI_HANDLE Handle
+//
+// Return value:EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InstallInvalBGRTStatusProtocol (EFI_HANDLE Handle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gTSEInvalidateBgrtStatusProtocolGuid,
+ &gInvalidateBgrtStatus,
+ NULL
+ );
+
+ return Status;
+}
+//EIP 128665 ends
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name : SaveCurrentTextGOP
+//
+// Description : Function to Save current TextMode and GOP
+//
+// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode
+//
+// Output : EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SaveCurrentTextGOP ( UINTN *currenttextModeCols, UINTN *currenttextModeRows, UINT32 *currentGOPMode )
+{
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( IsTseBestTextGOPModeSupported() && TSE_POST_STATUS_IN_TSE != gPostStatus )
+ {
+ if (gGOP)
+ {
+ *currentGOPMode = gGOP->Mode->Mode;
+ }
+
+ if (TSE_BEST_HORIZONTAL_RESOLUTION != gGOP->Mode->Info->HorizontalResolution || TSE_BEST_VERTICAL_RESOLUTION != gGOP->Mode->Info->VerticalResolution)
+ {
+ SetScreenResolution(TSE_BEST_HORIZONTAL_RESOLUTION,TSE_BEST_VERTICAL_RESOLUTION); //If any postinterface is invoked during QuietBoot
+ }
+
+ Status = gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, currenttextModeCols, currenttextModeRows);
+ if (EFI_ERROR(Status))
+ return EFI_NOT_FOUND;
+
+ if ((STYLE_FULL_MAX_COLS != *currenttextModeCols) || (STYLE_FULL_MAX_ROWS != *currenttextModeRows))
+ {
+ gMaxRows = STYLE_FULL_MAX_ROWS;
+ gMaxCols = STYLE_FULL_MAX_COLS;
+ SetDesiredTextMode ();
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name : RestoreTextGOPMode
+//
+// Description : Function to Save current TextMode and GOP
+//
+// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode
+//
+// Output : EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RestoreTextGOPMode ( UINTN prevTextModeCols, UINTN prevTextModeRows, UINT32 prevGOPMode )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( IsTseBestTextGOPModeSupported() && TSE_POST_STATUS_IN_TSE != gPostStatus )
+ {
+ if ( (gMaxRows != prevTextModeRows) || (gMaxCols != prevTextModeCols) )
+ {
+ gMaxRows = prevTextModeRows;
+ gMaxCols = prevTextModeCols;
+ SetDesiredTextMode (); //Restoring to previous textmode if any changed
+ }
+
+ if (gGOP && prevGOPMode != gGOP->Mode->Mode)
+ {
+ Status = gGOP->SetMode (gGOP, prevGOPMode); //In some case changing text mode will change the graphcis mode, so reverting here.
+ }
+ }
+ return Status;
+}
+//EIP-107833 END
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/protocol.h b/EDK/MiniSetup/BootOnly/protocol.h
new file mode 100644
index 0000000..23b882f
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/protocol.h
@@ -0,0 +1,198 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 12 $
+//
+// $Date: 2/11/14 8:10p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/protocol.h $
+//
+// 12 2/11/14 8:10p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 11 9/13/13 2:02p Premkumara
+// Uploaded back for EIP-128665 after TSEBootOnly 1240 release
+// Files - Protocol.c, Protocol.h, AMIPostMgr.h
+//
+// 10 8/26/13 2:15a Premkumara
+// Reverted back for labelling BootOnly1240
+//
+// 8 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 11/10/11 7:21p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// Added new parameter to the function prototype DISPLAY_TEXT_KEY_VALIDATE
+//
+// 6 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 5 11/16/10 8:57a Mallikarjunanv
+// [TAG] - EIP 41838
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Update AMI Post Manager Protocol witht he following. 2.
+// Updating the interface PostManagerDisplayPostMessageEx to handle the
+// cursor position properly. 2. Need to add new interface to GetAttribute
+// [Rootcause] - 1. Display string is over written by the next string if
+// the interface PostManagerDisplayPostMessageEx used simultaneously. 2.
+// Need to get the attribute info to use PostManagerDisplayPostMessage
+// interfaces effectively
+// [Solution]- Fix in string.c to handle cursor and line positions. The
+// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface
+// implementaion to get the attribute.
+// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/04/10 12:03p Blaines
+// EIP-28005
+//
+// Added PostManagerSetAttribute to support display of text in color.
+// Added support for handling string characters --- \n, \r.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:12p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#ifndef _PROTOCOL_H_
+#define _PROTOCOL_H_
+
+EFI_STATUS InstallProtocol( VOID );
+VOID UninstallProtocol( VOID );
+EFI_STATUS PostManagerHandshake( VOID );
+EFI_STATUS PostManagerSetCursorPosition(UINTN X, UINTN Y);
+EFI_STATUS PostManagerGetCursorPosition(UINTN *pX, UINTN *pY);
+EFI_STATUS PostManagerSetProgressBarPosition();
+EFI_STATUS PostManagerInitProgressBar(
+ UINTN x,
+ UINTN y,
+ UINTN w,
+ UINTN h,
+ UINTN delta);
+
+TSE_POST_STATUS PostManagerGetPostStatus(VOID);
+
+EFI_STATUS PostManagerDisplayInfoBox( CHAR16 *InfoBoxTitle,
+ CHAR16 *InfoString,
+ UINTN Timeout,
+ EFI_EVENT *Event
+ );
+
+
+EFI_STATUS PostManagerSetAttribute(UINT8 ATTRIB);
+EFI_STATUS PostManagerGetAttribute(UINT8 *ATTRIB); //EIP-41838: new interface to get the attribute
+
+EFI_STATUS
+PostManagerDisplayMenu(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN UINT16 LegendToken,
+ IN POSTMENU_TEMPLATE *MenuData,
+ IN UINT16 MenuCount,
+ OUT UINT16 *pSelection
+);
+
+typedef
+BOOLEAN
+(EFIAPI *DISPLAY_TEXT_KEY_VALIDATE) (
+ UINT16 ItemIndex,
+ UINT16 Unicode,
+ CHAR16 *Value
+);
+
+
+EFI_STATUS
+PostManagerDisplayTextBox(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN TEXT_INPUT_TEMPLATE *InputData,
+ IN UINT16 ItemCount,
+ IN DISPLAY_TEXT_KEY_VALIDATE DisplayTextKeyValidate
+);
+
+EFI_STATUS PostManagerDisplayProgress (
+IN UINT8 ProgressBoxState,
+IN CHAR16 *Title,
+IN CHAR16 *Message,
+IN CHAR16 *Legend,
+IN UINTN Percent, // 0 - 100
+IN OUT VOID **Handle, //Out HANDLE. Valid Handle for update and close
+OUT AMI_POST_MGR_KEY *OutKey //Out Key
+);
+#endif /* _PROTOCOL_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/screen.c b/EDK/MiniSetup/BootOnly/screen.c
new file mode 100644
index 0000000..ba1bd23
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/screen.c
@@ -0,0 +1,346 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 4/18/13 6:16a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.c $
+//
+// 7 4/18/13 6:16a Arunsb
+// [TAG] EIP113081
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Post message displays twice
+// [RootCause] Buffer not cleared after displaying post message
+// [Solution] Buffer cleared properly. Save and restored the post
+// graphics screen properly.
+// [Files] protocol.c, screen.c and string.c
+//
+// 6 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 7 6/22/10 5:32a Mallikarjunanv
+// EIP:39102 - Updated Restore screen to restore complete screen
+//
+// 6 4/07/10 6:24p Madhans
+// post screen Sroll area support. TSE_POSTSCREEN_SCROLL_AREA SDL
+// configures the area.
+//
+// 5 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/04/10 11:22p Madhans
+// To remove conout dependance
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: screen.c
+//
+// Description: This file contains code for screen operations.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+VOID MouseStop(VOID);
+VOID MouseRefresh(VOID);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ClearScreenWithoutFlush
+//
+// Description: function to clear screen without flushing.
+//
+// Input: UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ClearScreenWithoutFlush( UINT8 Attrib )
+{
+
+ gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG;
+ MemSet( gActiveBuffer->Attribs, sizeof(gActiveBuffer->Attribs), Attrib );
+
+ MemFillUINT16Buffer( gActiveBuffer->Chars, MAX_DIMENSIONS, (UINT16)L' ' );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ClearLinesWithoutFlush
+//
+// Description: function to clear lines without flushing.
+//
+// Input: UINT8 LineStart, UINT8 NumLines, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ClearLinesWithoutFlush( UINT8 LineStart, UINT8 NumLines, UINT8 Attrib )
+{
+
+ gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG;
+ MemSet(&( gActiveBuffer->Attribs[LineStart*gMaxCols]), NumLines*gMaxCols /*sizeof(gActiveBuffer->Attribs)*/, Attrib );
+
+ MemFillUINT16Buffer( &(gActiveBuffer->Chars[LineStart*gMaxCols]), NumLines*gMaxCols/*MAX_ROWS * MAX_COLS*/, (UINT16)L' ' );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ClearScreen
+//
+// Description: function to clear the screen.
+//
+// Input: UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ClearScreen( UINT8 Attrib )
+{
+ ClearScreenWithoutFlush( Attrib );
+
+ if(gST->ConOut!=NULL)
+ {
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, Attrib );
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+
+ FlushLines( 0, gMaxRows - 1 );
+
+}
+
+EFI_UGA_PIXEL *gPostscreenwithlogo;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveScreen
+//
+// Description: function to get the backup of the screen.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *SaveScreen( VOID )
+{
+ SCREEN_BUFFER *Buffer;
+
+ Buffer = EfiLibAllocatePool( sizeof(SCREEN_BUFFER) );
+
+ if ( Buffer != NULL )
+ {
+ MemCopy( Buffer, gActiveBuffer, sizeof(SCREEN_BUFFER) );
+ Buffer->ScreenTag = SAVE_SCREEN_TAG;
+ }
+
+ return (VOID *)Buffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RestoreScreen
+//
+// Description: function to restore the screen from the saved screen buffer.
+//
+// Input: VOID *ScreenBuffer
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RestoreScreen( VOID *ScreenBuffer )
+{
+ SCREEN_BUFFER *Buffer = (SCREEN_BUFFER *)ScreenBuffer;
+
+ MouseStop();
+
+ if ( ( Buffer == NULL ) || ( Buffer->ScreenTag != SAVE_SCREEN_TAG ) )
+ return;
+
+ ///Clear Original data in the buffers before restoring with saved screen buffer.
+ MemSet(gActiveBuffer, sizeof(SCREEN_BUFFER), 0);
+ MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0);
+
+ MemCopy( gActiveBuffer, Buffer, sizeof(SCREEN_BUFFER) );
+ gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG;
+
+ FlushLines( 0, gMaxRows - 1 );
+ DoRealFlushLines();
+
+ MemFreePointer( (VOID **)&Buffer );
+
+ MouseRefresh();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveGraphicsScreen
+//
+// Description: Saves post graphics screen
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveGraphicsScreen(VOID)
+{
+ UINTN HorizontalResolution = 0;
+ UINTN VerticalResolution = 0;
+
+ GetScreenResolution(&HorizontalResolution, &VerticalResolution);
+ gPostscreenwithlogo = EfiLibAllocateZeroPool( HorizontalResolution * VerticalResolution * sizeof(EFI_UGA_PIXEL));
+
+ if (NULL == gPostscreenwithlogo)
+ {
+ return;
+ }
+ MouseStop();
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( gGOP)
+ gGOP->Blt (
+ gGOP,
+ gPostscreenwithlogo,
+ EfiBltVideoToBltBuffer,
+ (UINTN)0, (UINTN)0,
+ (UINTN)0, (UINTN)0,
+ HorizontalResolution, VerticalResolution,
+ 0
+ );
+#else
+ if ( gUgaDraw)
+ gUgaDraw->Blt (
+ gUgaDraw,
+ gPostscreenwithlogo,
+ EfiUgaVideoToBltBuffer,
+ (UINTN)0, (UINTN)0,
+ (UINTN)0, (UINTN)0,
+ HorizontalResolution, VerticalResolution,
+ 0
+ );
+#endif
+ MouseRefresh();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RestoreGraphicsScreen
+//
+// Description: Restores the saved post graphics screen
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RestoreGraphicsScreen (VOID)
+{
+
+ if( gPostscreenwithlogo != NULL )
+ {
+ UINTN HorizontalResolution = 0;
+ UINTN VerticalResolution = 0;
+
+ GetScreenResolution(&HorizontalResolution, &VerticalResolution);
+ MouseStop();
+#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
+ if ( gGOP)
+ gGOP->Blt (
+ gGOP,
+ gPostscreenwithlogo,
+ EfiBltBufferToVideo,
+ (UINTN)0, (UINTN)0,
+ (UINTN)0, (UINTN)0,
+ HorizontalResolution, VerticalResolution,
+ 0
+ );
+#else
+ if ( gUgaDraw)
+ gUgaDraw->Blt (
+ gUgaDraw,
+ gPostscreenwithlogo,
+ EfiUgaBltBufferToVideo,
+ (UINTN)0, (UINTN)0,
+ (UINTN)0, (UINTN)0,
+ HorizontalResolution, VerticalResolution,
+ 0
+ );
+#endif
+ MouseRefresh();
+ MemFreePointer( (VOID **)&gPostscreenwithlogo );
+ }
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/screen.h b/EDK/MiniSetup/BootOnly/screen.h
new file mode 100644
index 0000000..ce2cb38
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/screen.h
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/screen.h $
+//
+// 4 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 6 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 3 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#ifndef _SCREEN_H_
+#define _SCREEN_H_
+
+VOID ClearScreenWithoutFlush( UINT8 Attrib );
+VOID ClearLinesWithoutFlush( UINT8 LineStart, UINT8 NumLines, UINT8 Attrib );
+VOID ClearScreen( UINT8 Attrib );
+VOID *SaveScreen( VOID );
+VOID RestoreScreen( VOID *ScreenBuffer );
+
+typedef struct
+{
+ UINT32 ScreenTag;
+ UINT8 Attribs[MAX_DIMENSIONS];
+ CHAR16 Chars[MAX_DIMENSIONS];
+}
+SCREEN_BUFFER;
+
+#define ACTIVE_SCREEN_TAG 0x54434153 // "SACT"
+#define SAVE_SCREEN_TAG 0x56415353 // "SSAV"
+
+extern SCREEN_BUFFER *gActiveBuffer;
+
+VOID MemFillUINT16Buffer( VOID *buffer, UINTN bufferSize, UINT16 value );
+
+#endif /* _SCREEN_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/string.c b/EDK/MiniSetup/BootOnly/string.c
new file mode 100644
index 0000000..36908eb
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/string.c
@@ -0,0 +1,1488 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 20 $
+//
+// $Date: 2/11/14 10:10p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.c $
+//
+// 20 2/11/14 10:10p Arunsb
+// [TAG] EIP149640
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] F1 not displaying help message
+// [Root Cause] If we have \n in string then it replaced with 0x0d(\r) and
+// 0xa(\n) so both \r and \n treated as new line so incremented in height
+// not displayed the message box.
+// ie., height is beyond the max rows
+// [Solution] If we have \n in string we will get 0x0d(\r) and 0xa(\n)
+// continuously so removed \r for \n.
+// For \r alone case it will replaced with \0
+// [Files] string.c
+//
+// 19 2/11/14 8:13p Arunsb
+// [TAG] EIP126746
+// [Category] Improvement
+// [Description] AMITSE - ANSI escape code support for multiline
+// [Files] string.c and commonhelper.c
+//
+// 18 12/03/13 1:55p Premkumara
+// [TAG] EIP130420
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] String is getting truncated
+// [RootCause] The string for messagebox, Popup controls is getting
+// truncated
+// [Solution] Used temp variable to store original string and modify the
+// string temp and used to avoid changing org string.
+// [Files] String.c
+//
+// 17 11/08/13 7:55a Premkumara
+// [TAG] EIP131481
+// [Category] Improvement
+// [Description] TSE support '\r' to do line break
+// [Files] String.c
+//
+// 16 4/18/13 6:17a Arunsb
+// [TAG] EIP113081
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Post message displays twice
+// [RootCause] Buffer not cleared after displaying post message
+// [Solution] Buffer cleared properly. Save and restored the post
+// graphics screen properly.
+// [Files] protocol.c, screen.c and string.c
+//
+// 15 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 16 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 14 4/27/12 3:57a Rajashakerg
+// [TAG] EIP87424
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse pointer is destroyed by TSE when it is on SETUP icon
+// during POST
+// [RootCause] When SOFTKBD_ICON_SUPPORT is enabled the mouse pointer is
+// restricted to the ICON location. In the same line we are updating the
+// Post Message in which DoRealFlushLines() will stop the mouse while
+// updating the string in Post, but immediate Mouse refresh is not present
+// in PrintPostMessage() which is causing mouse pointer disappear.
+//
+// [Solution] Provided mouserefresh after DoRealFlushLines() in
+// PrintPostMessage() function.
+// [Files] BootOnly/string.c
+//
+// 13 2/02/12 1:13p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 12 11/30/11 12:17a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 11 10/21/11 2:57a Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Updating the file with fix for issue : maximum 8 byte
+// value shows negative number
+// [Files] numeric.c, numeric.h, string.c, string.h
+//
+// 10 6/20/11 12:25p Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Support for signed decimal value for
+// EFI_IFR_NUMERIC_OP.
+// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+//
+// 9 12/22/10 5:03a Mallikarjunanv
+// [TAG] EIP41838
+// [Category] Improvement
+// [Description] Updated the fix for 41838. Previously for \r is not
+// returning the cursor position to the starting column and \n it is not
+// moved to the first column of the next line. Now \r and \n functionality
+// updated to work properly.
+// [Files] string.c
+//
+// 8 11/16/10 8:55a Mallikarjunanv
+// [TAG] - EIP 41838
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Update AMI Post Manager Protocol witht he following. 2.
+// Updating the interface PostManagerDisplayPostMessageEx to handle the
+// cursor position properly. 2. Need to add new interface to GetAttribute
+// [Rootcause] - 1. Display string is over written by the next string if
+// the interface PostManagerDisplayPostMessageEx used simultaneously. 2.
+// Need to get the attribute info to use PostManagerDisplayPostMessage
+// interfaces effectively
+// [Solution]- Fix in string.c to handle cursor and line positions. The
+// files Protocol.c, Protocol.h and AmiPostMgr.h have the new interface
+// implementaion to get the attribute.
+// [Files] - Protocol.c, Protocol.h, AmiPostMgr.h and string.c
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 8:50p Madhans
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/04/10 12:03p Blaines
+// EIP-28005
+//
+// Added PostManagerSetAttribute to support display of text in color.
+// Added support for handling string characters --- \n, \r.
+//
+// 6 1/09/10 5:43a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 10/05/09 10:36a Madhans
+// To allow printing without affecting the previous screen when it is used
+// with SetCursorPosition.
+//
+// 4 9/25/09 6:37a Sudhirv
+// EIP-26893 : when the DisplayPostMessage() function of the AMI Post
+// Manager protocol is called multiple times, strings are truncated when
+// displayed.
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:49p Madhans
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:01p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: string.c
+//
+// Description: This file contains code for string functionalities.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+static UINTN StartRow = 0;
+static UINTN StartCol = 0;
+static UINTN EndRow = STYLE_FULL_MAX_ROWS;
+static UINTN EndCol = STYLE_FULL_MAX_COLS;
+
+static UINTN stStartLine= 0 ;
+static UINTN stNextLine = 0;
+static UINTN stColNum = 0;
+
+static BOOLEAN stPostScreenActive = FALSE;
+VOID ScrollPostScreenLine();
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetPostScreenScrollArea
+//
+// Description: Sets the PostScreen Scroll Area.
+//
+// Input: UINTN TopX, UINTN TopY, UINTN BottomX, UINTN BottomY
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetPostScreenScrollArea(UINTN TopRow, UINTN TopCol, UINTN BottomRow, UINTN BottomCol)
+{
+ if((TopCol<BottomCol) && (BottomCol<=STYLE_FULL_MAX_COLS) && (TopRow<BottomRow) && (BottomRow<=STYLE_FULL_MAX_ROWS) )
+ {
+ stNextLine = stStartLine = StartRow = TopRow;
+ stColNum = StartCol = TopCol;
+ EndRow = BottomRow;
+ EndCol = BottomCol;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: atoi
+//
+// Description: function to convet a string to integer
+//
+// Input: CHAR16 *string, UINT8 base
+//
+// Output: integer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN atoi(CHAR16 *string, UINT8 base)
+{
+ UINTN dval = 0;//EIP:60563 to support signed integers for NUMERIC opcode
+ CHAR16 ch;
+
+ if ( base == 10 )
+ {
+ while ( (ch = *string++ ) != 0x0)
+ {
+ if ( ch >= L'0' && ch <= L'9' )
+ dval = dval * 10 + ch - L'0';
+ else
+ break;
+
+ }
+ }
+ else if ( base == 16 )
+ {
+ while ( (ch = *string++) != 0x0 )
+ {
+ if ( ch >= L'0' && ch <= L'9' )
+ dval = dval * 16 + ch - L'0';
+ else if ( ch >= L'a' && ch <= L'f' )
+ dval = dval * 16 + ch - L'a' + 10;
+ else if ( ch >= L'A' && ch <= L'F' )
+ dval = dval * 16 + ch - L'A' + 10;
+ else
+ break;
+ }
+ }//EIP:60563 to support signed integers for NUMERIC opcode
+ else if( base == 32)
+ {
+ if(string[0]== L'-')
+ {
+ string++;
+ while ( (ch = *string++ ) != 0x0)
+ {
+ if ( ch >= L'0' && ch <= L'9' )
+ dval = dval * 10 + ch - L'0';
+ else
+ break;
+ }
+ dval= (INTN)((0xffffffffffffffff - dval )+ 0x1);
+ }
+ else
+ {
+ while ( (ch = *string++ ) != 0x0)
+ {
+ if ( ch >= L'0' && ch <= L'9' )
+ dval = dval * 10 + ch - L'0';
+ else
+ break;
+ }
+ }
+ }
+ return dval;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StrZeroPad
+//
+// Description: function to pad with zero
+//
+// Input: INT32 Tm, CHAR16 *Str
+//
+// Output: String
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *StrZeroPad(INT32 Tm, CHAR16 *Str)
+{
+ CHAR16 *fmt = L"%d";
+
+ if ( Tm < 10 )
+ fmt = L"0%d";
+
+ SPrint( Str, 10, fmt, Tm );
+ return Str;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StrDup
+//
+// Description: function to dump and return the string
+//
+// Input: CHAR16 *String
+//
+// Output: String
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *StrDup( CHAR16 *string )
+{
+ CHAR16 *text;
+
+ if(string == NULL)
+ return NULL;
+
+ text = EfiLibAllocatePool( (1 + EfiStrLen( string )) * sizeof(CHAR16) );
+ if ( text != NULL )
+ EfiStrCpy( text, string );
+
+ return text;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawAttribute
+//
+// Description: function to write a attribute
+//
+// Input: UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawAttribute( UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length )
+{
+ UINTN Offset = Row * gMaxCols + Col;
+
+ if ( Row >= gMaxRows )
+ return;
+
+ DrawAttributeOffset( Offset, Attrib, Length );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawAttributeOffset
+//
+// Description: function to write in a peticular offset.
+//
+// Input: UINTN Offset, UINT8 Attrib, UINTN Length
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawAttributeOffset( UINTN Offset, UINT8 Attrib, UINTN Length )
+{
+ if ( Attrib )
+ MemSet( &gActiveBuffer->Attribs[Offset], Length, Attrib );
+}
+UINT8 ForegroundColors[] = {
+ 30, //Black
+ 34, //Blue
+ 32, //Green
+ 36, //Cyan
+ 31, //Red
+ 35, //Magenta
+ 33, //Brown (code is for Yellow)
+ 37, //Light Gray (code is for White)
+};
+
+UINT8 BackgroundColors[] = {
+ 40, //Black
+ 44, //Blue
+ 42, //Green
+ 46, //Cyan
+ 41, //Red
+ 45, //Magenta
+ 43, //Brown (code is for Yellow)
+ 47 //Light Gray (code is for White)
+};
+
+UINT8 GetEFIFG(UINT8 ANSIColor)
+{
+ UINT8 i=0;
+ for(i=0;i<sizeof(ForegroundColors);i++)
+ if(ForegroundColors[i]==ANSIColor)
+ return i;
+ return 0;
+}
+
+UINT8 GetEFIBG(UINT8 ANSIColor)
+{
+ UINT8 i=0;
+ for(i=0;i<sizeof(BackgroundColors);i++)
+ if(BackgroundColors[i]==ANSIColor)
+ return i;
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawMultiLineStringWithAttribute
+//
+// Description: function to write a multiline string.
+//
+// Input: UINTN Col, UINTN Row,UINTN Width, UINTN Height,
+// CHAR16 *line, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawMultiLineStringWithAttribute( UINTN Col, UINTN Row,UINTN Width, UINTN Height, CHAR16 *line, UINT8 Attrib )
+{
+ CHAR16 * text;
+ UINTN i;
+ CHAR16 * String,*newtext;
+ UINT16 height;
+
+ newtext = StringWrapText( line, (UINT16)Width, &height );
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if(NULL == newtext){
+ return;
+ }
+ if(height < Height)
+ Height = height;
+ String = newtext;
+ for(i=0;i<Height;i++)
+ {
+ CHAR16 save;
+
+ text = String;
+ if ( *String == L'\0' )
+ break;
+
+ while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) )
+ String++;
+
+ save = *String;
+ *String = L'\0';
+ DrawStringWithAttribute( Col , Row+i, (CHAR16*)text, Attrib);
+
+ if ( ( *String = save ) != L'\0' )
+ {
+ String++;
+ if ( ( *String == L'\r' ) || ( *String == L'\n' ) )
+ String++;
+ }
+ }
+ MemFreePointer( (VOID **)&newtext );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawPostStringWithAttribute
+//
+// Description: function to write a multiline string in the post screen.
+//
+// Input: UINTN Col, UINTN Row,
+// CHAR16 *line, UINT8 Attrib
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN DrawPostStringWithAttribute( UINTN Col, UINTN Row,CHAR16 *line, UINT8 Attrib, BOOLEAN AdvanceLine )
+{
+ CHAR16 * text;
+ UINTN i=0;
+ CHAR16 * String=line;
+ UINTN Offset;
+ UINTN mxCol=gMaxCols;
+ while(1)
+ {
+ CHAR16 save;
+
+ text = String;
+ if ( *String == L'\0' )
+ break;
+
+ while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) )
+ String++;
+
+ save = *String;
+ *String = L'\0';
+
+ if(AdvanceLine)
+ {
+ mxCol = EndCol;
+ }
+
+ Offset = HiiFindStrPrintBoundary(text,(mxCol - Col));
+
+ if((AdvanceLine) && (Row+i >= gMaxRows))
+ {
+ ScrollPostScreenLine();
+ Row = gMaxRows-1-i;
+ }
+
+ if(Offset < EfiStrLen(text))
+ {// Printing the string printed next line also
+ *String = save;
+ save = text[Offset];
+ text[Offset] = 0;
+ DrawStringWithAttribute( Col , Row+i, (CHAR16*)text, Attrib);
+ String = &text[Offset];
+ }
+ else
+ DrawStringWithAttribute( Col , Row+i, (CHAR16*)text, Attrib);
+
+ stColNum = EfiStrLen(text);//EIP-41838: Updating the col position based on present string length.
+ if ( ( *String = save ) != L'\0' )
+ {
+ stColNum = 0; Col=0;//EIP-41838: Updating the col position to zero in case of \n and \r.
+ if ( *String == L'\r' )
+ { String++;
+ i--;
+ }
+ if ( *String == L'\n' )
+ {
+ String++;
+
+ if ( *(String - sizeof(CHAR16)) == L'\r' )
+ i++;
+ }
+ }
+ else
+ break;
+ i++;
+ //EIP-41838: Update the col position based on string processed to display.
+ if ( (!AdvanceLine) && ( (Col+Offset) >= mxCol) ) {
+ Col =0;
+ }
+ }
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawStringWithAttribute
+//
+// Description: function to write a string with attributes.
+//
+// Input: UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawStringWithAttribute( UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib )
+{
+ UINTN Length,printLength;
+ UINTN Offset = Row * gMaxCols + Col;
+ UINTN nIndex = 0;
+ UINTN Size;
+ UINT8 EscBold,EscFg,EscBg,EscAttrib=Attrib;
+
+ if ( Row >= gMaxRows )
+ return;
+
+ Length = EfiStrLen( String );
+ printLength = TestPrintLength( String ) / (NG_SIZE);
+ if ( Length == 0 )
+ return;
+
+ if ( printLength == 0 )
+ return;
+ DrawAttributeOffset( Offset, Attrib, printLength );
+ EscAttrib = Attrib;
+
+ for(nIndex = 0;nIndex < Length;nIndex++)
+ {
+ if((String[nIndex] == 0xfff0) || (String[nIndex] == 0xfff1))
+ {
+ continue;
+ }
+ Size=TseGetANSIEscapeCode(&String[nIndex],&EscBold,&EscFg,&EscBg);
+ if(Size)
+ {
+ EscAttrib = Attrib;
+ if(EscBg!=0xFF)
+ EscAttrib = (EscAttrib & 0x0F) | (GetEFIBG(EscBg)<<4);
+ if(EscFg!=0xFF)
+ EscAttrib = (EscAttrib & 0xF0) | GetEFIFG(EscFg);
+ if(EscBold!=0xFF)
+ EscAttrib = (EscAttrib & 0xF7) | (EscBold<<3);
+
+ nIndex +=Size;
+ continue;
+ }
+ gActiveBuffer->Chars[Offset] = String[nIndex];
+ if(EscAttrib)
+ gActiveBuffer->Attribs[Offset] = EscAttrib;
+ if(TRUE == IsCharWide(String[nIndex]))
+ {
+ Offset+=2;
+ }
+ else
+ {
+ Offset++;
+ }
+ }
+}
+
+VOID DrawString( UINTN Col, UINTN Row, CHAR16 *String )
+{
+ DrawStringWithAttribute( Col, Row, String, 0 );
+}
+
+VOID DrawStringJustified( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String )
+{
+ DrawStringJustifiedWithAttribute( MinCol, MaxCol, Row, Justify, String, 0 );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawStringJustifiedWithAttribute
+//
+// Description: function to write a string with justify and attributes.
+//
+// Input: UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify,
+// CHAR16 *String, UINT8 Attrib
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DrawStringJustifiedWithAttribute( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String, UINT8 Attrib )
+{
+ UINTN Col = MinCol;
+ CHAR16 *text;
+ UINTN Length = 0;
+
+ text = StrDup(String); //EIP-130420
+
+ Length = TestPrintLength( text ) / (NG_SIZE);
+ if ( Length == 0 )
+ return;
+
+ if ( Justify == JUSTIFY_RIGHT )
+ {
+ if(Length < MaxCol)
+ Col = MaxCol - Length;
+ }
+ else if ( Justify == JUSTIFY_CENTER )
+ {
+ if(Length < (MaxCol - MinCol))
+ Col = MinCol + (((MaxCol - MinCol) - Length) / 2);
+ else
+ text[MaxCol - MinCol] = '\0';
+ }
+
+ if ( Col < MinCol )
+ Col = MinCol;
+
+ DrawStringWithAttribute( Col, Row, text, Attrib );
+ MemFreePointer( (VOID **)&text );
+}
+
+VOID WriteChar( UINTN Row, UINTN Col, CHAR16 Char )
+{
+ WriteCharWithAttribute( Row, Col, Char, 0 );
+}
+
+VOID WriteCharWithAttribute( UINTN Row, UINTN Col, CHAR16 Char, UINT8 Attrib )
+{
+ UINTN Offset = Row * gMaxCols + Col;
+
+ if ( Row >= gMaxRows )
+ return;
+
+ DrawAttributeOffset( Offset, Attrib, 1 );
+
+ gActiveBuffer->Chars[Offset] = Char;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StringWrapText
+//
+// Description: function to create a new text by wrapping the given text.
+//
+// Input: CHAR16 *OrgText, UINT16 width, UINT16 *height
+//
+// Output: text
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void FindAnsiEscCode (CHAR16 *ThisLine, CHAR16 **EscCode);
+BOOLEAN IsANSIEscapeCodeSupported (VOID);
+CHAR16 * StringWrapText( CHAR16 *OrgText, UINT16 width, UINT16 *height )
+{
+ CHAR16 *newText, *text;
+ UINTN TextLen, i, j, newTextLen;
+ CHAR16 *ESCCode = (CHAR16 *)NULL;
+
+ if(OrgText == NULL)
+ return NULL;
+
+ if (IsANSIEscapeCodeSupported ())
+ {
+ ESCCode = EfiLibAllocateZeroPool (12 * sizeof(CHAR16));
+ if (NULL == ESCCode)
+ {
+ return NULL;
+ }
+ }
+ text = StrDup(OrgText);
+ TextLen = EfiStrLen(text);
+ //reformat input string by replacing \n and \r with \0
+ i=0;
+ while(text[i])
+ {
+ switch(text[i])
+ {
+ case L'\r':
+ //IF we have \n in string we will get 0x0d(\r) and 0xa(\n) continuously so removing \r for \n alone
+ j=i;
+ if (text[i+1] == L'\n')
+ {
+ while(text[j])
+ {
+ text[j]= text[j+1];
+ j++;
+ }
+ //Adjust text length
+ TextLen--;
+ break;
+ }
+ case L'\n':
+ text[i] = L'\0';
+ //No break on purpose
+ default:
+ i++;
+ }
+ }
+
+ //Assuming max no of '\n's that may be added is no of rows
+ if (!IsANSIEscapeCodeSupported ())
+ {
+ newText = EfiLibAllocateZeroPool( (TextLen + 1 + gMaxRows) * sizeof(CHAR16));
+ }
+ else
+ {
+ newText = EfiLibAllocateZeroPool( (TextLen + 1 + (gMaxRows * 12)) * sizeof(CHAR16)); //If ANSI supported then chances are there to fill
+ } //ANSI code in all rows so 12 * gMaxRows bytes allocated
+ if (NULL == newText)
+ {
+ return NULL;
+ }
+
+ *height=0;
+ newTextLen = 0;
+ for(i=0; i<TextLen; (*height)++)
+ {
+ CHAR16 *ThisLine;
+
+ ThisLine = text+i;
+
+ if( width >= (TestPrintLength(ThisLine)/(NG_SIZE)) ) //Can accomodate this line
+ {
+ if ((IsANSIEscapeCodeSupported ()) && (*ESCCode))
+ {
+ if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') )
+ {
+ EfiStrCpy (newText + newTextLen, ThisLine);
+ }
+ else
+ {
+ EfiStrCpy (newText + newTextLen, ESCCode);
+ EfiStrCat (newText + newTextLen, ThisLine);
+ }
+ if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') )
+ {
+ newTextLen += EfiStrLen (ESCCode);
+ }
+ newTextLen += EfiStrLen (ThisLine);
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ else
+ {
+ //Found space break the str here
+ EfiStrCpy(newText + newTextLen, ThisLine);
+ newTextLen+=EfiStrLen(ThisLine);
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ if (IsANSIEscapeCodeSupported ())
+ {
+ FindAnsiEscCode (ThisLine, &ESCCode);
+ }
+ i+=EfiStrLen(ThisLine);
+ i++;
+ }
+ else //Can not accomodate this line
+ {
+ //See if we can find a L" "
+ j = HiiFindStrPrintBoundary ( ThisLine, width )-1;
+ while(j)
+ {
+ if(ThisLine[j] == L' ')
+ {
+ //Found space break the str here
+ ThisLine[j]=L'\0';
+ if ((IsANSIEscapeCodeSupported ()) && (*ESCCode))
+ {
+ if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') )
+ {
+ EfiStrCpy (newText + newTextLen, ThisLine);
+ }
+ else
+ {
+ EfiStrCpy (newText + newTextLen, ESCCode);
+ EfiStrCat (newText + newTextLen, ThisLine);
+ }
+ if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') )
+ {
+ newTextLen += EfiStrLen (ESCCode);
+ }
+ newTextLen += EfiStrLen (ThisLine);
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ else
+ {
+ EfiStrCpy(newText + newTextLen, ThisLine);
+ newTextLen+=EfiStrLen(ThisLine);
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ if (IsANSIEscapeCodeSupported ())
+ {
+ FindAnsiEscCode (ThisLine, &ESCCode);
+ }
+ i+=EfiStrLen(ThisLine);
+ i++;
+ break;
+ }
+ j--;
+ }
+
+ if(0==j)
+ {
+ CHAR16 temp;
+
+ //did not find L' '
+ j = HiiFindStrPrintBoundary ( ThisLine, width ) - 1;
+ temp = ThisLine[j];
+ ThisLine[j] = '\0';
+ if ((IsANSIEscapeCodeSupported ()) && (*ESCCode))
+ {
+ if ( (ThisLine [0] == 0x001b) && (ThisLine [1] == L'[') )
+ {
+ EfiStrCpy (newText + newTextLen, ThisLine);
+ }
+ else
+ {
+ EfiStrCpy (newText + newTextLen, ESCCode);
+ EfiStrCat (newText + newTextLen, ThisLine);
+ }
+ if ( (ThisLine [0] != 0x001b) || (ThisLine [1] != L'[') )
+ {
+ newTextLen += EfiStrLen (ESCCode);
+ }
+ newTextLen += EfiStrLen (ThisLine);
+ newText[newTextLen] = temp;
+ newTextLen++;
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ else
+ {
+ EfiStrCpy(newText + newTextLen, ThisLine);
+ newTextLen+=EfiStrLen(ThisLine);
+ newText[newTextLen] = temp;
+ newTextLen++;
+ newText[newTextLen] = L'\n';
+ newTextLen++;
+ }
+ if (IsANSIEscapeCodeSupported ())
+ {
+ FindAnsiEscCode (ThisLine, &ESCCode);
+ }
+ i+=EfiStrLen(ThisLine);
+ i++;
+ }
+ }
+ }
+ newText[newTextLen] = L'\0';
+ MemFreePointer((VOID **)&text);
+
+ if (IsANSIEscapeCodeSupported ())
+ {
+ MemFreePointer((VOID **)&ESCCode);
+ }
+ return newText;
+}
+
+VOID ScrollPostScreenLine()
+{
+ UINTN i,j;
+ UINTN CopyFrom, CopyTo;
+
+
+ for(i=stStartLine;i<EndRow;i++)
+ {
+ //Push up and discard extra line on top
+ CopyFrom = ((i + 1)*gMaxCols)+StartCol;
+ CopyTo = (i * gMaxCols)+StartCol;
+ for(j=0;j<(EndCol-StartCol);j++)
+ {
+ gActiveBuffer->Attribs[CopyTo] = gActiveBuffer->Attribs[CopyFrom];
+ gActiveBuffer->Chars[CopyTo] = gActiveBuffer->Chars[CopyFrom];
+ if((i+1)==EndRow)
+ {
+ gActiveBuffer->Chars[CopyFrom] = L' ';
+ }
+ CopyFrom++;
+ CopyTo++;
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PrintPostMessage
+//
+// Description: function to Print the post massages
+//
+// Input: CHAR16 *message, BOOLEAN bAdvanceLine
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PrintPostMessage( CHAR16 *message, BOOLEAN bAdvanceLine )
+{
+ UINTN LineCount;
+
+ RUNTIME_DEBUG(L"printpostmsg");
+
+ if(bAdvanceLine && (stNextLine > EndRow))
+ {
+ ScrollPostScreenLine();
+ stNextLine = EndRow;
+ stColNum = StartCol;
+ }
+
+ LineCount = DrawPostStringWithAttribute(stColNum,stNextLine,message, gPostMgrAttribute,bAdvanceLine);
+
+ if(stPostScreenActive)
+ {
+ FlushLines(stStartLine,stNextLine+LineCount);
+ DoRealFlushLines();
+ MouseRefresh();//EIP 87424 : Mouse pointer disappear in POST when SOFTKBD_ICON_SUPPORT is enabled
+ }
+
+ if(bAdvanceLine)
+ {
+ stNextLine += LineCount;
+ stColNum = StartCol;
+ stNextLine++;
+ if(stNextLine > gMaxRows)
+ stNextLine = gMaxRows;
+ }
+ else {
+ //EIP-41838: Update the Line number based on the string displayed, to not to overwrite the existing line in case of a big string.
+ if(stColNum > gMaxCols)
+ {
+ stColNum = (stColNum%gMaxCols);
+ }
+ stNextLine = stNextLine+LineCount;
+ if(stNextLine > EndRow)
+ {
+ ScrollPostScreenLine();
+ stNextLine = EndRow;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+//eip:26893-Start
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PreservePostMessages
+//
+// Description: function to take care the postmessages when Screen mode changes
+// Only supported if OldMaxCols <= NewMaxCols
+//
+// Input: UINTN NewMaxCols, UINTN OldMaxCols
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID PreservePostMessages(UINTN NewMaxCols, UINTN OldMaxCols)
+{
+ UINTN i,CharCount;
+
+ if(OldMaxCols <= NewMaxCols)
+ return;
+ // Loop to copy each line to newmax cols
+ for(i=0;i<stNextLine;i++)
+ {
+ gBS->CopyMem ((VOID*)&gActiveBuffer->Attribs[i*NewMaxCols], (VOID*)&gActiveBuffer->Attribs[i*OldMaxCols],NewMaxCols);
+ gBS->CopyMem ((VOID*)&gActiveBuffer->Chars[i*NewMaxCols], (VOID*)&gActiveBuffer->Chars[i*OldMaxCols],NewMaxCols*sizeof(CHAR16));
+ }
+
+ //clear chars after (NewCol * stNextLine) in the buffer
+ CharCount = (stNextLine*OldMaxCols) - (stNextLine*NewMaxCols);
+ for(i=0;i<CharCount;i++)
+ gActiveBuffer->Chars[(stNextLine*NewMaxCols)+i] = L' ';
+}
+//eip:26893-End
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DisplayActivePostMsgs
+//
+// Description: function to Display active messages
+//
+// Input: UINTN LogoHeight
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DisplayActivePostMsgs(UINTN LogoHeight)
+{
+ UINTN LinesToPush;
+
+ if(!stPostScreenActive)
+ {
+ //First time showing the messages received. Adjust buffer to Logo height
+ //Find out no of extra lines
+ if((stNextLine-stStartLine) >= (gMaxRows - LogoHeight))
+ {
+ //Dicard only extra line that can not be shown
+ stStartLine = (stNextLine - stStartLine) - (gMaxRows - LogoHeight);
+ }
+ //Push lines so that they will be seen below the logo
+ LinesToPush = LogoHeight - stStartLine;
+ if(LinesToPush)
+ {
+ UINTN CopyFrom, CopyTo;
+
+ //Copy previous line if any
+ if(stNextLine > stStartLine)
+ {
+ CopyTo = (stNextLine + LinesToPush) * gMaxCols;
+ CopyFrom = stNextLine * gMaxCols;
+
+ //Go to the end char of the previous line
+ CopyTo--;
+ CopyFrom--;
+
+ while(1)
+ {
+ gActiveBuffer->Attribs[CopyTo] = gActiveBuffer->Attribs[CopyFrom];
+ gActiveBuffer->Chars[CopyTo] = gActiveBuffer->Chars[CopyFrom];
+ gActiveBuffer->Chars[CopyFrom] = (UINT16)L' ';
+ gActiveBuffer->Attribs[CopyFrom] = (UINT8) EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY ;
+
+ if(CopyFrom == (stStartLine * gMaxCols)) // Copy till the first char of the start line
+ break;
+
+ CopyFrom--;
+ CopyTo--;
+ }
+ }
+
+ //Modify Start and Next line values to new values
+ stStartLine = LogoHeight;
+ stNextLine = stNextLine + LinesToPush;
+ }
+
+ // make sure EndRow and EndCol is not bigger then ScreenSize
+ EndRow = (EndRow>gMaxRows)?gMaxRows:EndRow;
+ EndCol = (EndCol>gMaxCols)?gMaxCols:EndCol;
+ }
+
+
+ //Post screen activated
+ stPostScreenActive = TRUE;
+
+ //Flush lines if any
+ if(stNextLine > stStartLine)
+ {
+ FlushLines(stStartLine,stNextLine-1);
+ DoRealFlushLines();
+ }
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: SetCurPos
+//
+// Description: Sets the cursor to the position defined by X and Y.
+//
+// Input: UINTN X - Value of the column
+// UINTN Y - Number of row below the last written line
+//
+// Output: EFI_STATUS status - If the function runs correctly, returns
+// EFI_SUCCESS, else other EFI defined error values.
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS SetCurPos(UINTN X, UINTN Y)
+{
+ if((X < gMaxCols) && ( Y < gMaxRows))
+ {
+ stColNum = X;
+ stNextLine = Y;
+ return EFI_SUCCESS;
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: GetCurPos
+//
+// Description: Writes cursor position into given X and Y locations.
+//
+// Input: UINTN *pX - Pointer to storage for current column value
+// UINTN *pY - Pointer to storage for current row value
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if OK,
+// EFI_INVALID_PARAMETER if NULL pointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS GetCurPos(UINTN * const pX, UINTN * const pY)
+{
+ EFI_STATUS retcode = EFI_INVALID_PARAMETER;
+
+ if (NULL != pX && NULL != pY)
+ {
+ if(stColNum < gMaxCols) {
+ *pX = stColNum;
+ }
+ else { //EIP-41753: If the nextline exceeds the limit, set the value based on gMaxCols value.
+ *pX = gMaxCols-1;
+ }
+
+ if(stNextLine < gMaxRows) {
+ *pY = stNextLine;
+ }
+ else { //EIP-41753: If the nextline exceeds the limit, set the value based on gMaxRows value.
+ *pY = gMaxRows-1;
+ }
+
+ retcode = EFI_SUCCESS;
+ }
+ return retcode;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StrDup8
+//
+// Description: Duplicates a String of type CHAR8
+//
+// Input: CHAR8* string
+//
+// Output: CHAR8 *
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR8 *StrDup8( CHAR8 *string )
+{
+ CHAR8 *text;
+
+ text = EfiLibAllocatePool(1 + StrLen8( string ));
+ if ( text != NULL )
+ StrCpy8( text, string );
+
+ return text;
+}
+#pragma warning( disable : 4706 )
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StrDup8to16
+//
+// Description: Duplicates a String from CHAR8 to CHAR16
+//
+// Input: CHAR8* string
+//
+// Output: CHAR16 *
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *StrDup8to16( CHAR8 *string )
+{
+ CHAR16 *text;
+ UINTN i;
+
+ text = EfiLibAllocatePool( (1 + StrLen8( string )) * sizeof(CHAR16));
+ if ( text != NULL )
+ {
+ i=0;
+ while(text[i] = (CHAR16)string[i])
+ i++;
+ }
+
+ return text;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StrLen8
+//
+// Description: Returns Length of a String of type CHAR8
+//
+// Input: CHAR8* string
+//
+// Output: UINTN
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StrLen8(CHAR8 *string)
+{
+ UINTN i=0;
+ while(string[i])
+ i++;
+
+ return i;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StrCpy8
+//
+// Description: Copies a CHAR8 String from source to destination
+//
+// Input: CHAR8 *dest, CHAR8 *src
+//
+// Output: VOID
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StrCpy8(CHAR8 *dest, CHAR8 *src)
+{
+ UINTN i=0;
+ while(dest[i] = src[i])
+ i++;
+}
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: GetTokenCount
+//
+// Description:
+//
+// Input: CHAR8 *String
+//
+// Output: UINTN
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN GetTokenCount(CHAR8 *String)
+{
+ UINTN count = 0;
+ UINTN j = 0;
+ BOOLEAN token = FALSE;
+
+ do
+ {
+ if(String[j] == ';')
+ {
+ if(token)
+ count++;
+ token = FALSE;
+ }else
+ {
+ token = TRUE;
+ }
+ }while(String[j++]);
+
+ return (token? (count + 1) : count);
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: GetTokenString
+//
+// Description:
+//
+// Input: CHAR8 *String, UINTN *pos
+//
+// Output: CHAR8 *
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR8* GetTokenString(CHAR8 *String, UINTN *pos)
+{
+ CHAR8 *text;
+ UINTN i = 0, count = 0, j = 0;
+
+ do
+ {
+ if(String[i] == ';')
+ {
+ break;
+ }
+ count++;
+ }while(String[i++]);
+
+ text = EfiLibAllocateZeroPool( (1 + count) * sizeof(CHAR8));
+ if(text != NULL)
+ {
+ i = 0;
+ do
+ {
+ text[j++] = String[i++];
+ }while(j < count);
+ *pos = i;
+ }
+
+ return text;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StrDup16to8
+//
+// Description: Duplicates a String from CHAR16 to CHAR8
+//
+// Input: CHAR16 *String
+//
+// Output: CHAR8 *
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR8* StrDup16to8(CHAR16 *String)
+{
+ CHAR8 *text;
+ UINTN len = 0, j = 0;
+
+ while(String[j++])
+ len++;
+ text = EfiLibAllocateZeroPool( (1 + len) * sizeof(CHAR8));
+ if(text != NULL)
+ {
+ j = 0;
+ do
+ {
+ text[j] = (CHAR8)String[j];
+ }while(j++ < len);
+ }
+
+ return text;
+}
+
+//EIP-126746 Start
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FindAnsiEscCode
+//
+// Description: Fills the EscCode in current line
+//
+// Input: CHAR16 *, CHAR16 **
+//
+// Output: void
+//
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void FindAnsiEscCode (CHAR16 *ThisLine, CHAR16 **EscCode)
+{
+ UINTN iIndex = 0, size = 0;
+
+ while (ThisLine [iIndex])
+ {
+ if ( (ThisLine [iIndex] == 0x001b) && (ThisLine [iIndex+1] == L'[') )
+ {
+ size = 0;
+ MemSet (*EscCode, 12 * sizeof (CHAR16), 0);
+ while (ThisLine [iIndex] != L'm')
+ {
+ (*EscCode)[size] = ThisLine [iIndex];
+ size++;
+ iIndex++;
+ }
+ (*EscCode)[size] = L'm';
+ }
+ iIndex ++;
+ }
+}
+//EIP-126746 END
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
diff --git a/EDK/MiniSetup/BootOnly/string.h b/EDK/MiniSetup/BootOnly/string.h
new file mode 100644
index 0000000..c855bb2
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/string.h
@@ -0,0 +1,158 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/string.h $
+//
+// 7 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 10/21/11 2:58a Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Updating the file with fix for issue : maximum 8 byte
+// value shows negative number
+// [Files] numeric.c, numeric.h, string.c, string.h
+//
+// 5 6/20/11 12:26p Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Support for signed decimal value for
+// EFI_IFR_NUMERIC_OP.
+// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 5:43a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 9/25/09 6:37a Sudhirv
+// EIP-26893 : when the DisplayPostMessage() function of the AMI Post
+// Manager protocol is called multiple times, strings are truncated when
+// displayed.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:01p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: string.h
+//
+// Description: Header file for string functionalities.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _STRING_H_
+#define _STRING_H_
+
+#define CharIsUpper(c) ((c >= L'A') && (c <= L'Z'))
+#define CharIsLower(c) ((c >= L'a') && (c <= L'z'))
+#define CharIsAlpha(c) (CharIsUpper(c) || CharIsLower(c))
+#define CharIsNumeric(c) ((c >= L'0') && (c <= L'9'))
+#define CharIsAlphaNumeric(c) (CharIsAlpha(c) || CharIsNumeric(c))
+#define CharIsAlphaNumericSpecial(c) ((c >= (CHAR16)0x20) && (c <= (CHAR16)0x7E))
+
+#define JUSTIFY_CENTER (0)
+#define JUSTIFY_LEFT (1)
+#define JUSTIFY_RIGHT (2)
+#define JUSTIFY_MAX JUSTIFY_RIGHT
+
+UINTN atoi(CHAR16 *string, UINT8 base);
+CHAR16 *StrZeroPad(INT32 Tm, CHAR16 *Str);
+CHAR16 *StrDup(CHAR16 *string);
+VOID DrawAttribute( UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length );
+VOID DrawAttributeOffset( UINTN Offset, UINT8 Attrib, UINTN Length );
+VOID DrawString( UINTN Col, UINTN Row, CHAR16 *String );
+VOID DrawStringWithAttribute( UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib );
+VOID DrawMultiLineStringWithAttribute( UINTN Col, UINTN Row,UINTN Width, UINTN Height, CHAR16 *line, UINT8 Attrib );
+VOID DrawStringJustified( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String );
+VOID DrawStringJustifiedWithAttribute( UINTN MinCol, UINTN MaxCol, UINTN Row, UINTN Justify, CHAR16 *String, UINT8 Attrib );
+VOID WriteChar( UINTN Row, UINTN Col, CHAR16 Char );
+VOID WriteCharWithAttribute( UINTN Row, UINTN Col, CHAR16 Char, UINT8 Attrib );
+
+CHAR16 *StringWrapText( CHAR16 *text, UINT16 width, UINT16 *height );
+UINTN StringGetWrapHeight( CHAR16 *text, UINT16 width );
+UINTN _StringFindBreak( CHAR16 *string );
+
+EFI_STATUS PrintPostMessage( CHAR16 *message, BOOLEAN bAdvanceLine );
+VOID DisplayActivePostMsgs(UINTN LogoHeight);
+VOID PreservePostMessages(UINTN NewMaxCols, UINTN OldMaxCols); //eip:26893
+
+EFI_STATUS SetCurPos(UINTN X, UINTN Y);
+EFI_STATUS GetCurPos(UINTN * const pX, UINTN * const pY);
+UINTN GetTokenCount(CHAR8 *String);
+CHAR8* GetTokenString(CHAR8 *String, UINTN *pos);
+CHAR8 *StrDup8( CHAR8 *string );
+CHAR16 *StrDup8to16( CHAR8 *string );
+UINTN StrLen8(CHAR8 *string);
+VOID StrCpy8(CHAR8 *dest, CHAR8 *src);
+CHAR8* StrDup16to8(CHAR16 *String);
+
+#endif /* _STRING_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/timer.c b/EDK/MiniSetup/BootOnly/timer.c
new file mode 100644
index 0000000..54c77be
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/timer.c
@@ -0,0 +1,154 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/timer.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/timer.c $
+//
+// 4 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: timer.c
+//
+// Description: This file contains code to handle the timer.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimerCreateTimer
+//
+// Description: function to create a timer event and to set the timer
+//
+// Input: EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback,
+// VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger,
+// EFI_TPL CallBackTPL
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimerCreateTimer( EFI_EVENT *Event, EFI_EVENT_NOTIFY Callback,
+ VOID *Context, EFI_TIMER_DELAY Delay, UINT64 Trigger, EFI_TPL CallBackTPL )
+{
+ EFI_STATUS Status;
+ UINT32 EventType = EFI_EVENT_TIMER;
+
+ if ( Callback != NULL )
+ EventType |= EFI_EVENT_NOTIFY_SIGNAL;
+
+ Status = gBS->CreateEvent(
+ EventType,
+ CallBackTPL,
+ Callback,
+ Context,
+ Event
+ );
+
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = gBS->SetTimer( *Event, Delay, Trigger );
+ if ( EFI_ERROR( Status ) )
+ TimerStopTimer( Event );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimerStopTimer
+//
+// Description: function to stop the timer event.
+//
+// Input: EFI_EVENT *Event
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimerStopTimer( EFI_EVENT *Event )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( ( Event == NULL ) || ( *Event == NULL ) )
+ return Status;
+
+ gBS->CloseEvent( *Event );
+ *Event = NULL;
+
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2007, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/BootOnly/variable.c b/EDK/MiniSetup/BootOnly/variable.c
new file mode 100644
index 0000000..f600267
--- /dev/null
+++ b/EDK/MiniSetup/BootOnly/variable.c
@@ -0,0 +1,204 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/variable.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 5:59a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/variable.c $
+//
+// 7 10/18/12 5:59a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:36p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 9/28/11 10:48p Arunsb
+// [TAG] EIP66369
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] English strings appears intermediately when Chinese is a
+// current language
+// [RootCause] Some cases lang variable is not NULL terminated
+// [Solution] Lang variable made as NULL terminated.
+// [Files] BootOnly\Variable.c
+//
+// 5 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:14a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/18/10 8:26p Madhans
+// To take care NOGET and NOSET Attribs from Exetendedflags of
+// VariableInfo
+//
+// 4 1/09/10 5:44a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:56p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:41p Presannar
+// Initial implementation of coding standards
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:13p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: variable.c
+//
+// Description: This file contains code to handle bootonly lever variables operations.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+extern UINTN gSetupCount;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetNvramName
+//
+// Description: function to get the NvRam Variable Name
+//
+// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size
+//
+// Output: Name String
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *VarGetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size )
+{
+ VOID *buffer = NULL;
+ UINT32 attrib = 0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ // NO GET Functionality is taken care by VarGetNvram()
+
+ if ( attributes != NULL )
+ {
+ attrib = *attributes;
+ }
+
+ Status = UefiFormCallbackNVRead(name, guid, &attrib, size, &buffer);
+
+ if(EFI_ERROR(Status))
+ {
+ Status = gRT->GetVariable(
+ name,
+ guid,
+ &attrib,
+ size,
+ buffer
+ );
+
+ if ( Status != EFI_BUFFER_TOO_SMALL )
+ return buffer;
+
+ buffer = EfiLibAllocateZeroPool ( *size + 1);
+ if ( buffer == NULL )
+ return buffer;
+
+ Status = gRT->GetVariable(
+ name,
+ guid,
+ &attrib,
+ size,
+ buffer
+ );
+ }
+
+ if ( EFI_ERROR( Status ) )
+ MemFreePointer( (VOID *)&buffer );
+
+ if ( attributes != NULL )
+ *attributes = attrib;
+
+ return buffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarSetNvramName
+//
+// Description: function to Set the NvRam Variable Name
+//
+// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes,
+// VOID *buffer, UINTN *size
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarSetNvramName( CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ // NO SET Functionality is taken care by VarSetNvram()
+
+ Status = UefiFormCallbackNVWrite(name, guid, attributes, buffer, size);
+
+ if(EFI_ERROR(Status ) )
+ Status = gRT->SetVariable(
+ name,
+ guid,
+ attributes,
+ size,
+ buffer
+ );
+
+ return(Status);
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/Ezport/Ezport.cif b/EDK/MiniSetup/Ezport/Ezport.cif
new file mode 100644
index 0000000..030984f
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/Ezport.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "TSE Sources - Style - Ezport"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\Ezport"
+ RefName = "Ezport"
+[files]
+"Ezport.sdl"
+"Ezport.mak"
+"ezport.c"
+"ezport.h"
+"stylecommon.c"
+"style.h"
+"style.c"
+<endComponent>
diff --git a/EDK/MiniSetup/Ezport/Ezport.mak b/EDK/MiniSetup/Ezport/Ezport.mak
new file mode 100644
index 0000000..54bb85f
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/Ezport.mak
@@ -0,0 +1,123 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/Ezport.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 6 $
+##
+## $Date: 10/18/12 6:05a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/Ezport.mak $
+#
+# 6 10/18/12 6:05a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 7 10/10/12 12:42p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 5 2/19/10 1:02p Madhans
+# Updated for TSE 2.01. Refer Changelog.log for File change history.
+##
+## 5 2/19/10 8:15a Mallikarjunanv
+## updated year in copyright message
+##
+## 4 8/17/09 12:23p Presannar
+## Removed Include path to Core directory
+##
+## 3 6/24/09 6:10p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 2:36p Blaines
+## Update coding standard
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:15p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 3 4/28/09 9:39p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 2 4/24/09 9:35p Blaines
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+TSE_STYLE_INCLUDES = \
+ -I $(TSE_STYLE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+ -I $(TSESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\TseStyle.lib : TseStyleLib
+
+TseStyleLib : $(BUILD_DIR)\Ezport.mak TseStyleLibBin
+
+$(BUILD_DIR)\Ezport.mak : $(TSE_STYLE_DIR)\$(@B).cif $(TSE_STYLE_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSE_STYLE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+TseStyleLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\Ezport.mak all\
+ "MY_INCLUDES=$(TSE_STYLE_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TseStyle.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/Ezport/Ezport.sdl b/EDK/MiniSetup/Ezport/Ezport.sdl
new file mode 100644
index 0000000..2564578
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/Ezport.sdl
@@ -0,0 +1,1057 @@
+TOKEN
+ Name = "TSE_STYLE_EZPORT_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable Ezport Style in TSE"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_EZPORT"
+ Value = "1"
+ Help = "Condition to support Ezport Style Sources"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_STYLE_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Don't Edit."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_FULL_SCREEN"
+ Value = "1"
+ Help = "Condition to support full screen layout"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_ROWS"
+ Value = "(UINT8)(31)"
+ Help = "Maximum rows in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_COLS"
+ Value = "(UINT8)(100)"
+ Help = "Maximum columns in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_ROWS"
+ Value = "(UINT8)(24)"
+ Help = "Maximum rows in standard mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_COLS"
+ Value = "(UINT8)(80)"
+ Help = "Maximum columns in Standard mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Page border. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_Y"
+ Value = "(UINT8)(2)"
+ Help = "Y-Coordinate position of the Page border. (Default 2)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal width of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_H"
+ Value = "(UINT8)(STYLE_FULL_MAX_ROWS - 3)"
+ Help = "Vertical height of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_VERTICAL_MAIN_DIVIDER"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS*2/3)"
+ Help = "Vertical divider (border) position between the MainFrame window and (helper and Navigation) frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_HORIZONTAL_HELP_DIVIDER"
+ Value = "(UINT8)(STYLE_FULL_MAX_ROWS/2)"
+ Help = "Horizontal divider (border) position between Help and Navigation frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_Y"
+ Value = "(UINT8)(0)"
+ Help = "Y-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Title bar frame. "
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_H"
+ Value = "(UINT8)(1)"
+ Help = "Vertical Height of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_Y"
+ Value = "(UINT8)(1)"
+ Help = "Y-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_H"
+ Value = "1"
+ Help = "Vertical Height of the Menu bar frame"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_X"
+ Value = "0"
+ Help = "X-Coordinate position of the Help Title frame window"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+PAGEBORDER_FULL_H)"
+ Help = "Y-Coordinate position of the Help Title frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_H"
+ Value = "1"
+ Help = "Vertical Height of the Help Title frame window"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_X"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+1)"
+ Help = "Y-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_W"
+ Value = "(UINT8)(PAGEBORDER_FULL_W - FULL_VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_H"
+ Value = "(UINT8)(FULL_HORIZONTAL_HELP_DIVIDER - PAGEBORDER_FULL_Y - 2)"
+ Help = "Vertical Height of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_X"
+ Value = "(UINT8)(PAGEBORDER_FULL_X+1)"
+ Help = "X-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+1)"
+ Help = "Y-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_W"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER - 2)"
+ Help = "Horizontal Width of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_H"
+ Value = "(UINT8)(PAGEBORDER_FULL_H-2)"
+ Help = "Vertical Height of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_X"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_Y"
+ Value = "(UINT8)(FULL_HORIZONTAL_HELP_DIVIDER+1)"
+ Help = "Y-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_W"
+ Value = "(UINT8)(PAGEBORDER_FULL_W - FULL_VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_H"
+ Value = "(UINT8)(PAGEBORDER_FULL_H - FULL_HORIZONTAL_HELP_DIVIDER)"
+ Help = "Vertical Height of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_X"
+ Value = "0"
+ Help = "X-Coordinate position of the Page border. (Default 0)"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_Y"
+ Value = "2"
+ Help = "Y-Coordinate position of the Page border. (Default 2)"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal width of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_H"
+ Value = "(UINT8)(STYLE_STD_MAX_ROWS - 3)"
+ Help = "Vertical height of the page border."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "VERTICAL_MAIN_DIVIDER"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS*2/3)"
+ Help = "Vertical divider (border) position between the MainFrame window and (helper and Navigation) frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HORIZONTAL_HELP_DIVIDER"
+ Value = "(UINT8)(STYLE_STD_MAX_ROWS/2)"
+ Help = "Horizontal divider (border) position between Help and Navigation frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_Y"
+ Value = "(UINT8)(0)"
+ Help = "Y-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal Width of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_H"
+ Value = "(UINT8)(1)"
+ Help = "Vertical Height of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_Y"
+ Value = "(UINT8)(1)"
+ Help = "Y-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal Width of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_H"
+ Value = "1"
+ Help = "Vertical Height of the Menu bar frame"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_X"
+ Value = "0"
+ Help = "X-Coordinate position of the Help Title frame window"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+PAGEBORDER_H)"
+ Help = "Y-Coordinate position of the Help Title frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal Width of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_H"
+ Value = "1"
+ Help = "Vertical Height of the Help Title frame window"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_X"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+1)"
+ Help = "Y-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_W"
+ Value = "(UINT8)(PAGEBORDER_W - VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_H"
+ Value = "(UINT8)(HORIZONTAL_HELP_DIVIDER - PAGEBORDER_Y - 1)"
+ Help = "Vertical Height of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_X"
+ Value = "(UINT8)(PAGEBORDER_X+1)"
+ Help = "X-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+1)"
+ Help = "Y-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_W"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER - 2)"
+ Help = "Horizontal Width of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_H"
+ Value = "(UINT8)(PAGEBORDER_H-1)"
+ Help = "Vertical Height of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_X"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_Y"
+ Value = "(UINT8)(HORIZONTAL_HELP_DIVIDER+1)"
+ Help = "Y-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_W"
+ Value = "(UINT8)(PAGEBORDER_W - VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_H"
+ Value = "(UINT8)(PAGEBORDER_H - HORIZONTAL_HELP_DIVIDER)"
+ Help = "Vertical Height of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGE_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_LIGHTGRAY)"
+ Help = "Background Color of the main area (Main, Help, and Navigation Frames) in a page."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_FGCOLOR"
+ Value = "(UINT8)(EFI_BLUE)"
+ Help = "Foreground and Border Color of main area in a page (Default EFI_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MAIN_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background Color of the Main frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MAIN_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Main frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background Color of the Title bar frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_FGCOLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Foreground Color of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_FGCOLOR"
+ Value = "(UINT8)(EFI_LIGHTGRAY)"
+ Help = "Foreground Color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SELECTED_MENU_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_LIGHTGRAY)"
+ Help = "Background color of the Selected Menu in the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SELECTED_MENU_FGCOLOR"
+ Value = "(UINT8)(EFI_BLUE)"
+ Help = "Foreground Color of the Selected Menu in the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELP_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Help Frame (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELP_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Help Frame (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELPTITLE_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background color of the Help Title Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELPTITLE_FGCOLOR"
+ Value = "(UINT8)(EFI_LIGHTGRAY)"
+ Help = "Foreground Color of the Help Title Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NAV_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Navigation Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NAV_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Navigation Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar Up-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar Up-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar Down-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_FGCOLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar Down-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background Color of Popup Windows, and Message Boxes (Default EFI_BACKGROUND_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_FGCOLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Foreground Color of Popup Windows, and Message Boxes (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FOCUS_COLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Focused label and control text color (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_FOCUS_COLOR"
+ Value = "(UINT8)(FOCUS_COLOR)"
+ Help = "Focused label text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_FOCUS_COLOR"
+ Value = "(UINT8)(FOCUS_COLOR)"
+ Help = "Focused control text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NON_FOCUS_COLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Non Focused label and control text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_NON_FOCUS_COLOR"
+ Value = "(UINT8)(NON_FOCUS_COLOR)"
+ Help = "Non Focused label text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_NON_FOCUS_COLOR"
+ Value = "(UINT8)(NON_FOCUS_COLOR)"
+ Help = "Non Focused control text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_LINK_COLOR"
+ Value = "(UINT8)(PAGE_FGCOLOR)"
+ Help = "Submenu text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_FGCOLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Foreground color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TEXT_COLOR"
+ Value = "(UINT8)(EFI_DARKGRAY)"
+ Help = "Foreround color of text controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MEMO_COLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground color of Memo controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_MARGIN"
+ Value = "37"
+ Help = "Control column left margin in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_RIGHT_AREA_WIDTH"
+ Value = "((UINT8)FULL_VERTICAL_MAIN_DIVIDER - FULL_STYLE_CONTROL_LEFT_MARGIN - FULL_STYLE_CONTROL_LEFT_PAD)"
+ Help = "Control column width in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_MARGIN"
+ Value = "24"
+ Help = "Control column left margin"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_RIGHT_AREA_WIDTH"
+ Value = "((UINT8)VERTICAL_MAIN_DIVIDER - STYLE_CONTROL_LEFT_MARGIN - STYLE_CONTROL_LEFT_PAD)"
+ Help = "Control column width"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FULL_STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in normal screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_SCROLLBAR_ROLLOVER"
+ Value = "1"
+ Help = "Support rollover when the scroll limit has been reached"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_PAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating to a new page. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SUBPAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating back from submenu. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_HOTKEY_FAILSAFE"
+ Value = "SCAN_F6"
+ Help = " Hot Key to load fail safe values"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SHADOW_SUPPORT"
+ Value = "1"
+ Help = " To enable/disable shadow support"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SPACEKEY_INCREMENT"
+ Value = "1"
+ Help = " < need to add help >"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+
+PATH
+ Name = "TSE_STYLE_DIR"
+End
+
+MODULE
+ Help = "Includes Ezport.mak to Project"
+ File = "Ezport.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\TSEStyle.lib"
+ Parent = "$(TSE_STYLE_DIR)\TSEStyle$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
+
diff --git a/EDK/MiniSetup/Ezport/ezport.c b/EDK/MiniSetup/Ezport/ezport.c
new file mode 100644
index 0000000..3755b71
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/ezport.c
@@ -0,0 +1,731 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/ezport.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 16 $
+//
+// $Date: 11/26/13 12:07a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/ezport.c $
+//
+// 16 11/26/13 12:07a Premkumara
+// [TAG] EIP123006
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When switch language between English to Japanese will have
+// display japanese character in exit page
+// [RootCause] While drawing the frame gFlushBuffer is not flushed
+// properly
+// [Solution] Before drawing frames gFlushBuffer is reset with empty
+// characters to clear the screen properly
+// [Files] Ezport.c
+//
+// 15 2/11/13 5:57a Premkumara
+// [TAG] EIP112628
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] (JP000E)SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY does not work on
+// 4.6.2_TSE_2_15_1234
+// [RootCause] The Exit FormID value will change if any form is
+// generated before Exit page
+// [Solution] Handled Exit FormID from Binary and handling Exit FormID
+// from binary
+// [Files] Ezport.c, Ezport.sdl, Legacy.c, Legacy.sdl, EzportPlus.c,
+// EzportPlus.sdl
+//
+// 14 1/22/13 12:15a Rajashakerg
+// [TAG] EIP103449
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In Setup click\Touch from navigation window, option are not
+// displayed properly
+// [RootCause] Latest mouse driver providing LEFT_DOWN when we hold the
+// mouse left down button.
+// [Solution] Provided fix resolves the issue.
+// [Files] ezport.c, PopupEdit.c, ListBox.c, MessageBox.c
+//
+// 13 10/18/12 6:05a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 12 5/24/12 7:29a Rajashakerg
+// [TAG] EIP88811
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When pop-up window is invoked in setup and Click on ESC
+// icon or ESC/Right Click, it will respond as two times ESC is clicked
+// [RootCause] ESC functionality provided for left click on the ESC
+// sting navigation frame .
+// [Solution] Now providing the ESC sequence for left down and double
+// click
+// [Files] ezport.c, numeric.c, MessageBox.c
+//
+// 11 11/20/11 7:26a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 10 6/29/11 12:26p Rajashakerg
+// [TAG] EIP47086, 62098
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup and the Mouse hotclicks.
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 9 3/28/11 5:13p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 8 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 10 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/15/10 10:12p Madhans
+// To avoid warnings
+//
+// 8 1/09/10 6:11a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 6 8/13/09 1:22p Blaines
+// Support BgColor for MAIN_FRAME, NAV_FRAME, and HELP_FRAME
+//
+// 5 8/04/09 6:57p Blaines
+// Add Support for Exit Page SDL tokens
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 9 5/05/09 3:20p Blaines
+//
+// 8 5/04/09 6:52p Blaines
+// Support customizable Help and Nav frame text Foreground color
+//
+// 7 5/01/09 9:25p Blaines
+//
+// 6 4/30/09 9:54p Blaines
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: ezport.c
+//
+// Description: Main file for ezport style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+#include "ezport.h"
+
+extern STYLECOLORS Colors ;
+extern AMI_IFR_MENU gMenuData ;
+
+extern UINTN gLabelLeftMargin ;
+extern UINTN gControlLeftMargin ;
+extern UINTN gControlLeftPad ;
+extern UINTN gControlRightAreaWidth ;
+static CALLBACK_SUBMENU gMenuCallbackData = { { CALLBACK_TYPE_MENU, sizeof(CALLBACK_MENU) }, 0 };
+static CALLBACK_SUBMENU gSubmenuCallbackData = { { CALLBACK_TYPE_SUBMENU, sizeof(CALLBACK_SUBMENU) }, 0 };
+static CALLBACK_VARIABLE gVariableCallbackData = { { CALLBACK_TYPE_VARIABLE, sizeof(CALLBACK_VARIABLE) }, 0, 0, 0, NULL };
+static CALLBACK_PASSWORD gPasswordCallbackData = { { CALLBACK_TYPE_PASSWORD, sizeof(CALLBACK_PASSWORD) }, 0, 0, 0, NULL, TRUE };
+
+VOID _FrameSubmenuCallback( FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie );
+VOID _FrameMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, VOID *cookie );
+VOID HotclickESCaction(VOID);
+BOOLEAN gotoExitOnEscKey(EFI_GUID *exitFormGuid, UINT16 *pageClass, UINT16 *pageSubclass, UINT16 *pageFormID); //EIP-112628
+
+#if SETUP_STYLE_EZPORT
+
+#if SETUP_STYLE_FULL_SCREEN
+static FRAME_INFO _gStyleFullSubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, TITLE_FULL_W, TITLE_FULL_H, TITLE_FULL_Y, TITLE_FULL_X, TITLE_FGCOLOR, TITLE_BGCOLOR },// TITLE
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, MENU_FULL_W, MENU_FULL_H, MENU_FULL_Y, MENU_FULL_X, MENU_FGCOLOR, MENU_BGCOLOR },// SUBTITLE (MENU)
+ { MAIN_FRAME, TRUE, FALSE, 0, MAIN_FULL_W, MAIN_FULL_H, MAIN_FULL_Y, MAIN_FULL_X, PAGE_FGCOLOR, MAIN_BGCOLOR },// Main
+ { HELP_FRAME, TRUE, FALSE, 0, HELP_FULL_W, HELP_FULL_H, HELP_FULL_Y, HELP_FULL_X, HELP_FGCOLOR, HELP_BGCOLOR },// HELP
+ { NAV_FRAME, TRUE, FALSE, 0, NAV_FULL_W, NAV_FULL_H, NAV_FULL_Y, NAV_FULL_X, NAV_FGCOLOR, NAV_BGCOLOR },// NAVIGATION
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, HELPTITLE_FULL_W, HELPTITLE_FULL_H, HELPTITLE_FULL_Y, HELPTITLE_FULL_X, HELPTITLE_FGCOLOR, HELPTITLE_BGCOLOR } // HELP TITLE (Copyright)
+};
+#endif
+
+static FRAME_INFO _gStyleStandardSubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, TITLE_W, TITLE_H, TITLE_Y, TITLE_X, TITLE_FGCOLOR, TITLE_BGCOLOR },// TITLE
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, MENU_W, MENU_H, MENU_Y, MENU_X, MENU_FGCOLOR, MENU_BGCOLOR },// SUBTITLE (MENU)
+ { MAIN_FRAME, TRUE, FALSE, 0, MAIN_W, MAIN_H, MAIN_Y, MAIN_X, PAGE_FGCOLOR, MAIN_BGCOLOR },// Main
+ { HELP_FRAME, TRUE, FALSE, 0, HELP_W, HELP_H, HELP_Y, HELP_X, HELP_FGCOLOR, HELP_BGCOLOR },// HELP
+ { NAV_FRAME, TRUE, FALSE, 0, NAV_W, NAV_H, NAV_Y, NAV_X, NAV_FGCOLOR, NAV_BGCOLOR },// NAVIGATION
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, HELPTITLE_W, HELPTITLE_H, HELPTITLE_Y, HELPTITLE_X, HELPTITLE_FGCOLOR, HELPTITLE_BGCOLOR } // HELP TITLE (Copyright)
+};
+
+AMITSE_CONTROL_MAP gTseControlMap[] =
+{
+// ControlType ControlMethods CallbackSuppored CallbackFunction CallbackContext
+ { CONTROL_TYPE_MENU, (CONTROL_METHODS*)&gMenu, TRUE, (VOID*)(UINTN)&_FrameMenuCallback, (VOID*)(UINTN)&gMenuCallbackData},
+ { CONTROL_TYPE_SUBMENU, (CONTROL_METHODS*)&gSubMenu,TRUE, (VOID*)(UINTN)&_FrameSubmenuCallback, (VOID*) &gSubmenuCallbackData},
+ { CONTROL_TYPE_LABEL, (CONTROL_METHODS*)&gLabel, TRUE, (VOID*)(UINTN)&StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_TEXT, (CONTROL_METHODS*)&gText, FALSE,(VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUP_STRING, (CONTROL_METHODS*)&gPopupString, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_DATE, (CONTROL_METHODS*)&gDate, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_TIME, (CONTROL_METHODS*)&gTime, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUPSEL, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ // Checkbox is just popup sel
+ { CONTROL_TYPE_CHECKBOX, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_MEMO, (CONTROL_METHODS*)&gMemo, FALSE, (VOID*)NULL, (VOID*)NULL},
+ { CONTROL_TYPE_NUMERIC, (CONTROL_METHODS*)&gNumeric, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_ORDERED_LIST, (CONTROL_METHODS*)&gOrdListBox, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_PASSWORD, (CONTROL_METHODS*)&gPopupPassword, TRUE, (VOID*)(UINTN)&_FramePasswordCallback, (VOID*)&gPasswordCallbackData},
+ { CONTROL_TYPE_ACTION, (CONTROL_METHODS*)&gUefiAction, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_RESET, (CONTROL_METHODS*)&gResetButton, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},//EIP:56413 Updated the Reset Button Control information
+ // CONTROL_TYPE_NULL need to be last member
+ { CONTROL_TYPE_NULL, (CONTROL_METHODS*)NULL, FALSE, (VOID*)NULL, (VOID*) NULL}
+};
+
+static FRAME_INFO *_gStyleSubFrames = _gStyleStandardSubFrames ;
+
+UINT8 gVerticalMainDivider = VERTICAL_MAIN_DIVIDER ;
+UINT8 gHorizontalHelpDivider = HORIZONTAL_HELP_DIVIDER ;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleInit( VOID )
+{
+
+ gLabelLeftMargin = STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = STYLE_CONTROL_LEFT_PAD ;
+ gControlRightAreaWidth = STYLE_CONTROL_RIGHT_AREA_WIDTH ;
+
+
+#if SETUP_STYLE_FULL_SCREEN
+ if ( gMaxCols == STYLE_FULL_MAX_COLS )
+ {
+ _gStyleSubFrames = _gStyleFullSubFrames;
+
+ gVerticalMainDivider = FULL_VERTICAL_MAIN_DIVIDER ;
+ gHorizontalHelpDivider = FULL_HORIZONTAL_HELP_DIVIDER ;
+
+ gLabelLeftMargin = FULL_STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = FULL_STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = FULL_STYLE_CONTROL_LEFT_PAD ;
+ gControlRightAreaWidth = FULL_STYLE_CONTROL_RIGHT_AREA_WIDTH ;
+ }
+#endif
+
+ if(gLabelLeftMargin < 2)
+ gLabelLeftMargin = 2 ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameIndexOf
+//
+// Description: Function to get frame index
+//
+// Input: UINT32 frameType
+//
+// Output: UINT32 index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleFrameIndexOf( UINT32 frameType )
+{
+ UINT32 FrameCount ;
+ UINT32 i;
+
+ FrameCount = sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO);
+
+
+ for ( i = 0; i < FrameCount; i++ )
+ {
+ if( _gStyleSubFrames[i].FrameType == frameType ){
+ return i ;
+ break ;
+ }
+ }
+
+ return i ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageFrames
+//
+// Description: Function to number of frames
+//
+// Input: UINT32 page
+//
+// Output: UINT32 number of frames
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleGetPageFrames( UINT32 page )
+{
+ return sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleDrawPageBorder
+//
+// Description: Function to draw page border
+//
+// Input: UINT32 page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleDrawPageBorder( UINT32 page )
+{
+ PAGE_DATA *Page ;
+ FRAME_DATA *fTitle, *fMenu, *fHelptitle, *fMain;
+
+ CHAR16 *line;
+ UINT8 lineNumber;
+ UINT8 start, end, col;
+ UINT8 pbx,pby,pbw,pbh;
+ UINT8 vertDivider = VERTICAL_MAIN_DIVIDER ;
+ UINT8 horzDivider = HORIZONTAL_HELP_DIVIDER;
+
+ Page = gApp->PageList[page];
+
+ fTitle = Page->FrameList[StyleFrameIndexOf(TITLE_FRAME)];
+ fHelptitle = Page->FrameList[StyleFrameIndexOf(HELPTITLE_FRAME)];
+ fMenu = Page->FrameList[StyleFrameIndexOf(SUBTITLE_FRAME)];
+ fMain = Page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];//EIP-123006
+
+ pbx = PAGEBORDER_X;
+ pby = PAGEBORDER_Y;
+ pbw = PAGEBORDER_W;
+ pbh = PAGEBORDER_H;
+
+ if ( gMaxCols == STYLE_FULL_MAX_COLS )
+ {
+ vertDivider = FULL_VERTICAL_MAIN_DIVIDER ;
+ horzDivider = FULL_HORIZONTAL_HELP_DIVIDER;
+ pbx = PAGEBORDER_FULL_X;
+ pby = PAGEBORDER_FULL_Y;
+ pbw = PAGEBORDER_FULL_W;
+ pbh = PAGEBORDER_FULL_H;
+ }
+
+
+ line = EfiLibAllocateZeroPool( (gMaxCols + 1) * sizeof(CHAR16) );
+ if ( line == NULL )
+ return;
+
+ ClearLinesWithoutFlush( fTitle->FrameData.Top, fTitle->FrameData.Height, fTitle->FrameData.BGColor | fTitle->FrameData.FGColor );
+ ClearLinesWithoutFlush( fHelptitle->FrameData.Top, fHelptitle->FrameData.Height, fHelptitle->FrameData.BGColor | fHelptitle->FrameData.FGColor );
+ ClearLinesWithoutFlush( fMenu->FrameData.Top, fMenu->FrameData.Height, fMenu->FrameData.BGColor | fMenu->FrameData.FGColor );
+
+ //EIP-123006 Clearing gFlushBuffer with attribute(0) and chars(' ')
+ MemSet( &(gFlushBuffer->Attribs[fMain->FrameData.Top*gMaxCols]), fMain->FrameData.Height*gMaxCols, 0 );
+ MemFillUINT16Buffer( &(gFlushBuffer->Chars[fMain->FrameData.Top*gMaxCols]), fMain->FrameData.Height*gMaxCols, (UINT16)L' ' );
+
+ ClearLinesWithoutFlush( pby, pbh, PAGE_BGCOLOR | PAGE_FGCOLOR );
+
+
+ DrawWindow( pbx, pby, pbw, pbh, PAGE_BGCOLOR| PAGE_FGCOLOR, TRUE, FALSE );
+
+
+
+ MemFillUINT16Buffer( &line[1], gMaxCols - 1, BOXDRAW_HORIZONTAL );
+
+ line[0] = BOXDRAW_DOWN_HORIZONTAL;
+ line[1] = L'\0';
+ DrawString( vertDivider, pby, line );
+
+ line[0] = BOXDRAW_UP_HORIZONTAL;
+ DrawString( vertDivider, pby+pbh-1, line );
+
+ // center divider
+ line[0] = BOXDRAW_VERTICAL;
+
+ col = vertDivider ;
+ start = pby+1;
+ end = pby+pbh-1 ;
+
+ for ( lineNumber = start; lineNumber < end ; lineNumber++ )
+ DrawString( col, lineNumber, line );
+
+ // Horizontal Help divider
+ MemFillUINT16Buffer( &line[1], gMaxCols - 1, BOXDRAW_HORIZONTAL );
+ line[0] = BOXDRAW_VERTICAL;
+ //line[1] = BOXDRAW_HORIZONTAL;
+ line[gMaxCols - vertDivider-1] = L'\0';
+ DrawString(col, horzDivider, line );
+
+ FlushLines( 0, end-1 );
+
+ gBS->FreePool( line );
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page, UINT32 frame
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ return &_gStyleSubFrames[frame];
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameAddTitle
+//
+// Description: Function to add frame title
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy )
+{
+ return EFI_UNSUPPORTED;
+}
+
+#endif /* SETUP_STYLE_EZPORT */
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleEscKey
+//
+// Description: Function to handle ESC Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandleEscKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ UINT16 pageClass = 0, pageSubclass = 0, pageFormID = 0;
+ EFI_GUID ExitPageGuid;
+
+
+ if(FormBrowserHandleValid())
+ app->Quit = TRUE;
+
+ else if ( gotoExitOnEscKey (&ExitPageGuid, &pageClass, &pageSubclass, &pageFormID) )//EIP-112628
+ {
+ UINT32 i=0;
+ PAGE_INFO *pageInfo;
+
+ for ( i = 0; i < gPages->PageCount; i++ )
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+ if (
+ ( EfiCompareGuid(&ExitPageGuid,&(gPageIdInfo[pageInfo->PageIdIndex].PageGuid)) ) &&
+ ( pageClass == gPageIdInfo[pageInfo->PageIdIndex].PageClass ) &&
+ ( pageSubclass == gPageIdInfo[pageInfo->PageIdIndex].PageSubClass ) &&
+ ( pageFormID == pageInfo->PageFormID )
+ )
+ {
+ gApp->CurrentPage = i; // Page found go to exit page
+ gApp->CompleteRedraw = TRUE;
+ gApp->Fixed = FALSE;
+ break;
+ }
+ }
+ if(i >= gPages->PageCount) //Page not found exit application
+ app->Quit = ExitApplication();
+ }
+
+ else
+ app->Quit = ExitApplication();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleSaveExitKey
+//
+// Description: Function to handle Save and Exit Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ app->Quit = SaveAndExit();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandlePrevValuesKey
+//
+// Description: Function to handle Load Previous value Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadPreviousValues( TRUE );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleFailsafeKey
+//
+// Description: Function to handle Load Failsafe values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadFailsafeDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleOptimalKey
+//
+// Description: Function to handle Load Optimal values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadOptimalDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleHelpKey
+//
+// Description: Function to handle Help Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ ShowHelpMessageBox();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandlePrnScrnKey
+//
+// Description: Function to handle print screen Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HandlePrnScrnKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ TseHotkeyPrintScreenSupport();
+}
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//EIP:47086 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MainFrameHandlewithMouse
+//
+// Description: Function to handle Main Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+ NumericSoftKbdExit();
+ if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK)
+ app->Quit = ExitApplication();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HelpFrameHandlewithMouse
+//
+// Description: Function to handle Help Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+ NumericSoftKbdExit();
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NavFrameHandlewithMouse
+//
+// Description: Function to handle Navigation Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID NavFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+
+ UINT32 Action;
+// EIP :62098 -Handling mouse hot click operations
+ NumericSoftKbdExit();
+ Action = MapControlMouseActionHook(&app->Action->Input.Data.MouseInfo);
+//EIP 88811 : When pop-up window is invoked in setup and Click on ESC icon or ESC/Right Click, it will respond as two times ESC is clicked
+ if(( ControlActionChoose == Action )||( ControlActionSelect == Action ))//EIP 103449 : In Setup click\Touch from navigation window, option are not displayed properly
+ {
+ if(app->Action->Input.Data.MouseInfo.Top == hotclick->HotClickData.Yo + 4)
+ if ( app->CurrentPage != 0 )
+ {
+ ShowHelpMessageBox();
+ return;
+ }
+
+ if(app->Action->Input.Data.MouseInfo.Top == hotclick->HotClickData.Yo + 5)
+ if ( app->CurrentPage != 0 )
+ {
+ LoadPreviousValues( TRUE );
+ return;
+ }
+ if(app->Action->Input.Data.MouseInfo.Top == hotclick->HotClickData.Yo + 6)
+ if ( app->CurrentPage != 0 )
+ {
+ LoadOptimalDefaults();
+ return;
+ }
+ if(app->Action->Input.Data.MouseInfo.Top == hotclick->HotClickData.Yo + 7)
+ {
+ app->Quit = SaveAndExit();
+ return;
+ }
+
+ if(app->Action->Input.Data.MouseInfo.Top == hotclick->HotClickData.Yo + 8)
+ HotclickESCaction();
+ //app->Quit = ExitApplication();
+
+ }
+}
+//EIP:47086 END
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Ezport/ezport.h b/EDK/MiniSetup/Ezport/ezport.h
new file mode 100644
index 0000000..2281a45
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/ezport.h
@@ -0,0 +1,134 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/ezport.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 6:05a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/ezport.h $
+//
+// 6 10/18/12 6:05a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:12a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 3 8/18/09 6:34p Blaines
+// Support additional date styles
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:14p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: ezport.h
+//
+// Description: Main header file for ezport style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EZPORT_H_
+#define _EZPORT_H_
+
+#if SETUP_STYLE_EZPORT
+
+VOID OverRideStyleInit( VOID );
+VOID OverRideStyleDrawPageBorder( UINT32 page );
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+#if SETUP_STYLE_FULL_SCREEN
+ #define STYLE_MAX_COLS STYLE_FULL_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_FULL_MAX_ROWS
+#else
+ #define STYLE_MAX_COLS STYLE_STD_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_STD_MAX_ROWS
+#endif
+
+#define EFI_BACKGROUND_WHITE (EFI_WHITE << 4)
+#define STYLE_CLEAR_SCREEN_COLOR (HELPTITLE_BGCOLOR | EFI_WHITE)
+
+
+// Style Overrides...
+#define STYLE_OVERRIDE_INIT
+#define STYLE_OVERRIDE_PAGE_BORDER
+#define STYLE_OVERRIDE_FRAME_INIT_DATA
+#define STYLE_OVERRIDE_CONTROL_OVERFLOW
+#define STYLE_OVERRIDE_INITIALIZE_FRAME
+#define STYLE_OVERRIDE_INITIALIZE_OEM_FRAME
+#define STYLE_OVERRIDE_NAV_TOKEN
+#define STYLE_OVERRIDE_ADD_CONTROLS
+#define STYLE_OVERRIDE_FIRST_PAGE
+#define STYLE_OVERRIDE_VERSION_STRING
+#define STYLE_OVERRIDE_FRAME_DRAWABLE
+
+#define MENU_COMPLETE_REDRAW 1
+#define SUBMENU_COMPLETE_REDRAW 2
+#endif /* SETUP_STYLE_EZPORT */
+
+#endif /* _EZPORT_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Ezport/style.c b/EDK/MiniSetup/Ezport/style.c
new file mode 100644
index 0000000..e5c7ab6
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/style.c
@@ -0,0 +1,546 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/style.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 7 $
+//
+// $Date: 5/02/14 4:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/style.c $
+//
+// 7 5/02/14 4:02a Premkumara
+// [TAG] EIP151966
+// [Category] Improvement
+// [Description] Added the implementation for getting the BIOS build
+// year dynamically
+// from TimeStamp.h file and updated the Build year in copyright message
+// in both Setup and POST.
+// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper
+// .c,
+// AmiTSEStr.uni,AMITSE.mak
+//
+// 6 10/18/12 6:05a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 6/23/11 5:42a Rajashakerg
+// [TAG] EIP63073
+// [Category] New Feature
+// [Description] Source modules in TSE should get the version details
+// from binary in run time not at build time
+// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+// EzportPlus\style.c, Legacy\style.c
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/04/10 11:16p Madhans
+// Navgation help for Mouse Added
+//
+// 4 1/09/10 6:13a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.c
+//
+// Description: Contains style override functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+extern UINT8 gVerticalMainDivider ;
+extern UINT8 gHorizontalHelpDivider ;
+extern UINT16 gStrNavToken;
+
+VOID _StyleAddSpacing( FRAME_DATA *frame );
+VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);
+VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message
+
+#if SETUP_STYLE_EZPORT
+
+
+
+STYLECOLORS Colors =
+{
+ TEXT_COLOR, //EFI_WHITE, //FGColor
+ PAGE_BGCOLOR, //BGColor
+ NON_FOCUS_COLOR, //EFI_BLUE, //secondary FGcolor
+ PAGE_BGCOLOR, //secondary BGColor
+ CONTROL_FOCUS_COLOR, //EFI_WHITE, //SelFGColor
+ PAGE_BGCOLOR, //SelBGColor
+ CONTROL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelFGColor
+ PAGE_BGCOLOR, //NSelBGColor
+ PAGE_BGCOLOR, //LabelBGColor
+ LABEL_FOCUS_COLOR, //EFI_WHITE, //LabelFGColor
+ LABEL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelLabelFGColor
+ EDIT_BGCOLOR, //EditBGColor
+ EDIT_FGCOLOR, //EFI_WHITE, //EditFGColor
+ POPUP_FGCOLOR, //popupFGColor
+ POPUP_BGCOLOR //popupBGColor
+};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleHandleControlOverflow
+//
+// Description: Function to handle contro overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA *tempcontrol;
+ UINT16 i=0,Height=0;
+ UINT8 BORDER=(frame->FrameData.Border==TRUE)?1:0 ;
+
+ // show scrollbar if neccessary
+ frame->UseScrollbar = FALSE;
+
+ for(i = 0; i < count; i++)
+ {
+ tempcontrol = (CONTROL_DATA*)(frame->ControlList[i]);
+ if( (Height + tempcontrol->Height ) <= frame->FrameData.Height-2*BORDER )
+ {
+ Height = Height + tempcontrol->Height;
+ frame->LastVisibleCtrl = i;
+ }
+ else
+ {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+
+ return Status;
+}
+
+static AMI_IFR_MENU gMenuData = {CONTROL_TYPE_MENU,2};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInitializeFrame
+//
+// Description: Function to initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT8 justify = JUSTIFY_LEFT /*, BORDER=(frame->FrameData.Border==TRUE)?1:0*/ ;
+ STYLECOLORS saveColors ;
+
+ CONTROL_INFO dummy;
+
+ UINT32 FrameType = frame->FrameData.FrameType ;
+
+ saveColors = Colors ;
+
+ //Allows controls to match the Background Color of the Frame
+ Colors.BGColor = frame->FrameData.BGColor ;
+ Colors.SecBGColor = frame->FrameData.BGColor ;
+ Colors.SelBGColor = frame->FrameData.BGColor ;
+ Colors.NSelBGColor = frame->FrameData.BGColor ;
+ Colors.LabelBGColor = frame->FrameData.BGColor ;
+ Colors.PopupBGColor = frame->FrameData.BGColor ;
+
+ switch ( FrameType )
+ {
+ case MAIN_FRAME:
+ if(LABEL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.LabelFGColor = LABEL_FOCUS_COLOR ;
+
+ if(CONTROL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.SelFGColor = CONTROL_FOCUS_COLOR;
+
+ if(LABEL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelLabelFGColor = LABEL_NON_FOCUS_COLOR ;
+
+ if(CONTROL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelFGColor = CONTROL_NON_FOCUS_COLOR ;
+
+
+ Status = _FrameAddControls( frame, data );
+ break;
+
+ case SUBTITLE_FRAME:
+ Colors.SecBGColor = SELECTED_MENU_BGCOLOR ;
+ Colors.SecFGColor = SELECTED_MENU_FGCOLOR ;
+ Colors.PopupBGColor = MENU_BGCOLOR ;
+ Colors.PopupFGColor = MENU_FGCOLOR ;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = gHiiHandle;
+ dummy.ControlType = CONTROL_TYPE_MENU;
+ dummy.ControlPtr = (VOID*)&gMenuData;
+ dummy.ControlPageID = data->PageID;
+ dummy.ControlFlags.ControlVisible = TRUE;
+ Status=gFrame.AddControl(frame,&dummy);
+ break;
+
+ case TITLE_FRAME:
+
+ case HELPTITLE_FRAME:
+
+ justify = JUSTIFY_CENTER;
+ case HELP_FRAME:
+
+ case NAV_FRAME:
+ Status = _FrameAddTitle( frame, FrameType, data );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ MEMO_DATA *memo = (MEMO_DATA *)frame->ControlList[0];
+
+ if(FrameType == HELPTITLE_FRAME )
+ {
+ memo->ControlData.ControlPtr= (VOID*) UefiCreateSubTitleTemplate(STRING_TOKEN(STR_MAIN_COPYRIGHT));
+
+ }
+
+ gMemo.SetJustify( memo, justify );
+ }
+ break;
+
+ case SCROLLBAR_FRAME:
+ // not implemented at this time
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ //Status = StyleInitializeOemFrame( frame, frame->FrameData.FrameType, data ) ;
+ break;
+ }
+
+
+ Colors = saveColors;
+
+ // initialize frame scroll colors
+ frame->FrameData.ScrlFGColor = SCROLLBAR_FGCOLOR ;
+ frame->FrameData.ScrlBGColor = SCROLLBAR_BGCOLOR ;
+ frame->FrameData.ScrlUpFGColor = SCROLLBAR_UPARROW_FGCOLOR ;
+ frame->FrameData.ScrlUpBGColor = SCROLLBAR_UPARROW_BGCOLOR ;
+ frame->FrameData.ScrlDnFGColor = SCROLLBAR_DOWNARROW_FGCOLOR ;
+ frame->FrameData.ScrlDnBGColor = SCROLLBAR_DOWNARROW_BGCOLOR ;
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetNavToken
+//
+// Description: Function to get navigation frame token
+//
+// Input: UINT32 page number
+//
+// Output: UINT16 token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 OverRideStyleGetNavToken( UINT32 page )
+{
+ return gStrNavToken;
+}
+
+
+
+static AMI_IFR_LABEL gFailSafeLabel = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), STRING_TOKEN(STR_LOAD_FAILSAFE_HELP) };
+static AMI_IFR_LABEL gOptimalLabel = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), STRING_TOKEN(STR_LOAD_OPTIMAL_HELP) };
+static AMI_IFR_LABEL gSaveExitLabel = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), STRING_TOKEN(STR_SAVE_EXIT_HELP) };
+static AMI_IFR_LABEL gExitLabel = { 0, 0, STRING_TOKEN(STR_EXIT), STRING_TOKEN(STR_EXIT_HELP) };
+static AMI_IFR_LABEL gSaveResetLabel = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), STRING_TOKEN(STR_SAVE_RESET_HELP) };
+static AMI_IFR_LABEL gResetLabel = { 0, 0, STRING_TOKEN(STR_RESET), STRING_TOKEN(STR_RESET_HELP) };
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleAddAdditionalControls
+//
+// Description: Function to add additional controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_DATA **control;
+ UINT32 i;
+
+ if ( frame->PageID != 0 )
+ return Status;
+
+ control = frame->ControlList;
+
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ (*control)->Methods->Destroy( *control, TRUE );
+ }
+
+ // initialize counter of control in frame and set focus to false (at this point the are no controls in the frame)
+ frame->ControlCount =0;
+ frame->NullCount=0;
+ focus=0;
+ controlNumber=0;
+
+ // add controls for boot manager, language, failsafe, optimal, save & exit, exit without saving
+/* Status = _StyleAddControl( frame, CONTROL_TYPE_SUBMENU, &gBootManagerRef, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_SUBMENU, &gLanguageRef, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+*/
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gFailSafeLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gOptimalLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveExitLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gExitLabel, &controlNumber, &focus );
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveResetLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gResetLabel, &controlNumber, &focus );
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleSelectFirstDisplayPage
+//
+// Description: Function to set first page display
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleSelectFirstDisplayPage( VOID )
+{
+ gApp->CurrentPage = 1;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleUpdateVersionString
+//
+// Description: Function to update version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleUpdateVersionString( VOID )
+{
+ CHAR16 *string = NULL, *newString = NULL;
+ UINTN length, TseMajor,TseMinor, TseBuild;
+ UINT16 TseBuildYear=0;
+ UINTN i;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+ GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild);
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseMajor, TseMinor, TseBuild,TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode, newString );
+ }
+
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ //EIP 151966 : Use BIOS build year for copyright message
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode, newString );
+ }
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if(!frame->FrameData.Drawable){
+ Status = EFI_UNSUPPORTED;
+ }
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddSpacing
+//
+// Description: Function to add spacing
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleAddSpacing( FRAME_DATA *frame )
+{
+ _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+ if ( frame->ControlCount == 7 )
+ _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddControl
+//
+// Description: Function to add controls
+//
+// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus )
+{
+ EFI_STATUS Status;
+ CONTROL_INFO dummy;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+
+ dummy.ControlType = type;
+ dummy.ControlPtr = (VOID*)data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gFrame.AddControl( frame, &dummy );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ if ( type != CONTROL_TYPE_NULL )
+ {
+ if ( ! *focus )
+ {
+ if ( _FrameSetControlFocus( frame, *controlNumber ) )
+ {
+ frame->CurrentControl = *controlNumber;
+ *focus = TRUE;
+ }
+ }
+
+ (*controlNumber)++;
+ }
+
+ return Status;
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Ezport/style.h b/EDK/MiniSetup/Ezport/style.h
new file mode 100644
index 0000000..5f8139a
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/style.h
@@ -0,0 +1,247 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/style.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 10 $
+//
+// $Date: 10/18/12 6:05a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/style.h $
+//
+// 10 10/18/12 6:05a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 6/29/11 12:24p Rajashakerg
+// [TAG] EIP47086, 62098
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup and the Mouse hotclicks.
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 8 11/18/10 6:38p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 2/26/10 8:53p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 8 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 7 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 5 8/19/09 11:13a Blaines
+// Update OEM Override prototypes
+//
+// 4 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 3 8/17/09 12:23p Presannar
+// Removed References to Tiano.h
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.h
+//
+// Description: Style override prototypes.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+//#define SETUP_STYLE_FULL_SCREEN 1
+//#define SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY 0
+
+#ifndef _STYLE_H_
+#define _STYLE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+//#define SETUP_STYLE_EZPORT 1
+#include "ezport.h"
+#include "page.h"
+#include "frame.h"
+
+INTN GetWindowLevel( UINT16 PageID);
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType) ;
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color);
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+EFI_STATUS OverRideControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+VOID StyleInit( VOID );
+VOID StyleExit( VOID );
+VOID StyleDrawPageBorder( UINT32 page );
+UINT32 StyleGetPageFrames( UINT32 page );
+UINT32 StyleFrameIndexOf( UINT32 frameType );
+VOID StyleBeforeFrame( FRAME_DATA *frame ) ;
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame );
+VOID StyleUpdateFrameStrings(PAGE_DATA *page);
+VOID * StyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo);
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action );
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 StyleGetNavToken( UINT32 page );
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+
+//EFI_STATUS StyleMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, CALLBACK_MENU *data );
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *number, BOOLEAN *focus );
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu );
+BOOLEAN StyleHelpAreaScrollable(VOID);
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+BOOLEAN StyleGetShadowSupport(VOID);
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+
+
+VOID StyleSelectFirstDisplayPage( VOID );
+VOID StyleAddExtraPagesData( VOID );
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color);
+UINTN StyleGetDateFormat(VOID);
+BOOLEAN StyleShowDay(VOID);
+BOOLEAN StyleGetScrollBehavior(VOID) ;
+
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+extern HOTKEY_TEMPLATE gHotKeyInfo[];
+extern HOTCLICK_TEMPLATE gHotClickInfo[];//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+extern UINT32 gHotKeyCount;
+extern UINT32 gHotClickCount;//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//extern UINT8 gLabelLeftMargin ;
+//extern UINT8 gControlLeftMargin ;
+//extern FRAME_INFO _gStyleStandardSubFrames[] ;
+extern UINT32 gSubFrameCount ;
+extern EFI_STATUS FrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy );
+
+
+//Common Overrides
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OverRideStyleGetNavToken( UINT32 page );
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+VOID OverRideStyleSelectFirstDisplayPage( VOID );
+VOID OverRideStyleUpdateVersionString( VOID );
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame );
+
+//Oem Overrides
+UINTN OEMStyleGetDateFormat(VOID);
+EFI_STATUS OEMGetSpecialColor(UINT16 ControlType, UINT8 *Color);
+VOID OEMStyleBeforeFrame( FRAME_DATA *frame );
+VOID OEMStyleUpdateFrameStrings( PAGE_DATA *page );
+EFI_STATUS OEMStyleFrameDrawable( FRAME_DATA *frame );
+VOID OEMStyleInit( VOID );
+VOID OEMStyleExit( VOID );
+VOID OEMStyleDrawPageBorder( UINT32 page );
+VOID OEMDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+VOID OEMDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+VOID *OEMStyleGetFrameInitData( UINT32 page, UINT32 frame );
+EFI_STATUS OEMStyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS OEMStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OEMStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OEMStyleGetNavToken( UINT32 page );
+EFI_STATUS OEMStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+UINT16 OEMStyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 OEMStyleBootManagerPage( SUBMENU_DATA *submenu );
+VOID OEMStyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+VOID OEMStyleSelectFirstDisplayPage( VOID );
+VOID OEMStyleAddExtraPagesData(VOID);
+UINTN OEMStyleGetTextMode( UINTN Rows, UINTN Cols );
+VOID OEMStyleUpdateVersionString( VOID );
+VOID OEMStyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+VOID OEMOverRideComponent(VOID);
+VOID OEMStylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID OEMStyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+
+#endif /* _STYLE_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Ezport/stylecommon.c b/EDK/MiniSetup/Ezport/stylecommon.c
new file mode 100644
index 0000000..17c1bd2
--- /dev/null
+++ b/EDK/MiniSetup/Ezport/stylecommon.c
@@ -0,0 +1,1440 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/stylecommon.c $
+//
+// $Author: Rajashakerg $
+//
+// $Revision: 20 $
+//
+// $Date: 3/16/13 2:21a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport/stylecommon.c $
+//
+// 20 3/16/13 2:21a Rajashakerg
+// [TAG] EIP111479
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS dialog box is crashed with special
+// monitor(160,53,1280*1024)
+// [RootCause] DesiredTextMode was not set properly.
+// [Solution] Provided proper mode number while setting text mode.
+// [Files] postmgmtext.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 19 2/10/13 11:53p Rajashakerg
+// [TAG] EIP104521
+// [Category] Improvement
+// [Description] Customer needs AMITSE modification to popup boxes so
+// highlighted choices can be seen via VT100 console redirection
+// [Files] AMITSE.sdl, CommonHelper.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 18 10/18/12 6:05a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 16 9/17/12 6:24a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 14 8/29/12 4:26p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 13 4/03/12 3:02a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 12 11/28/11 1:23a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c,
+// Date.c, Ezport\Stylecommon.c, EzportPlus\StyleCommon.c,
+// Legacy\StyleCommon.c
+//
+// 11 11/20/11 7:28a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 10 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 9 11/09/11 10:02a Premkumara
+// [TAG] EIP74375
+// [Category] Improvement
+// [Description] Control STYLE_HELP_AREA_SCROLLBAR from binary
+// [Files] CommonHelper.c, AMITSE.sdl, StyleHook.h,
+// Legacy\StyleCommon.c, Legacy.sdl,
+// EzportPlus\StyleCommon.c, EzportPlus.sdl, Ezport\StyleCommon.c,
+// Ezport.sdl
+//
+// 8 1/06/11 7:54p Blaines
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- Style function should allow OEM to override default
+// implementation.
+//
+// [Rootcause] - Style function does not provide override macro.
+// [Solution] - Add Macro Overrides to the following functions:
+//
+// StyleGetClearScreenColor,
+// StyleGetPageLinkColor,
+// StyleGetScrollBarUpArrowColor ,
+// StyleGetScrollBarDownArrowColor.
+//
+// [Files] - stylecommon.c
+//
+// 7 11/18/10 6:38p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 6 11/09/09 4:44a Mallikarjunanv
+// Eip-30111 : fixed the issue to update the help if
+// STYLE_PAGE_FIRSTITEM_FOCUS token enabled.
+//
+// 5 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 4 8/13/09 1:24p Blaines
+// EIP #24980 Fix to properly display right area text;
+//
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: stylecommon.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+#if SETUP_STYLE_EZPORT
+
+
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref );
+VOID UpdatePageFocusedItemHelp(PAGE_DATA *page);
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StyleControlColor
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// STYLECOLORS Colors - Color scheme
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors)
+{
+ //Note: Blaines 01/12/09
+ //The goal here is to allow controls to match the BGColor of their frame.
+ //Normally this is handled in StyleInitializeFrame(), before controls are added to the frame.
+ //But this function is called dynamically during runtime (after pages/frames/controls are styled)
+ //Since controls derive their colors from [STYLECOLORS Colors],
+ //we'll temporarly modify it before controls are added to this frame, then restore it.
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_CONTROL_COLOR
+ Status = OEMControlColor(frame, Colors);
+ #else
+ #ifdef STYLE_CONTROL_COLOR
+ Status = OverRideControlColor(frame, Colors);
+ #else
+ //Temporarly Match the BGColor of the frame
+ Colors->BGColor = frame->FrameData.BGColor ;
+ Colors->SecBGColor = frame->FrameData.BGColor ;
+ Colors->SelBGColor = frame->FrameData.BGColor ;
+ Colors->NSelBGColor = frame->FrameData.BGColor ;
+ Colors->LabelBGColor = frame->FrameData.BGColor ;
+ Colors->PopupBGColor = frame->FrameData.BGColor ;
+
+ #endif
+
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetSpecialColor
+//
+// Description: Function to get control special color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_CONTROL_COLOR
+ Status = OEMGetSpecialColor(ControlType, Color);
+ #else
+
+
+ switch ( ControlType )
+ {
+ case CONTROL_TYPE_MEMO:
+ if (Color !=NULL) *Color = MEMO_COLOR ;
+ break;
+
+ case CONTROL_TYPE_TEXT:
+ if (Color !=NULL) *Color = TEXT_COLOR ;
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;;
+ break;
+ }
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetWindowLevel
+//
+// Description: Function to get window level
+//
+// Input: UINT16 PageID
+//
+// Output: INTN Level
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INTN GetWindowLevel( UINT16 PageID)
+{
+ INTN zIndex = 0 ;
+ UINT16 TempID = PageID ;
+
+ while(gApp->PageList[TempID]->PageData.PageParentID)
+ {
+ TempID = gApp->PageList[TempID]->PageData.PageParentID ;
+ zIndex += 1 ;
+ }
+
+ return zIndex ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetWindowColor
+//
+// Description: Function to get window color
+//
+// Input: UINT8 *Color - Window Color
+// INTN Level - Window Level
+// UINT8 Type - Window Type (0->Setup, 1->PostMenu)
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType)
+{
+ return EFI_SUCCESS ;
+
+}
+
+VOID GetMessageboxColorHook(UINT8 **Color);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetMessageboxColor
+//
+// Description: Function to get control Messagebox color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ if(Color == NULL)
+ return Status ;
+
+
+ switch ( MessageBoxType )
+ {
+ case MSGBOX_EX_CATAGORY_HELP:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_BLUE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_QUERY:
+ *Color = EFI_BACKGROUND_BLUE | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_SUCCESS:
+ *Color = EFI_BACKGROUND_GREEN | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_WARNING:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_ERROR:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_PROGRESS:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_HALT:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_NORMAL:
+
+ default:
+ *Color = EFI_BACKGROUND_BLUE | EFI_WHITE ;
+
+ break;
+ }
+
+ GetMessageboxColorHook(&Color);
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBeforeFrame
+//
+// Description: Function to alter frame styling before frame is drawn
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleBeforeFrame( FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_BEFORE_FRAME
+ OEMStyleBeforeFrame(frame);
+ #else
+ #ifdef STYLE_OVERRIDE_BEFORE_FRAME // from Ezport.h
+ OverRideStyleBeforeFrame(frame ); // From ezport.c
+ #endif
+
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateFrameStrings
+//
+// Description: Function to update frame strings
+//
+// Input: PAGE_DATA *page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateFrameStrings( PAGE_DATA *page )
+{
+ #ifdef STYLE_OEM_FRAME_TOKEN // SDL
+ OEMStyleUpdateFrameStrings(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_TOKEN // from Ezport.h
+ OverRideStyleUpdateFrameStrings(page ); // From ezport.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_FRAME_DRAWABLE // SDL
+ Status = OEMStyleFrameDrawable(frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_DRAWABLE // from Ezport.h
+ Status = OverRideStyleFrameDrawable(frame ); // From ezport.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleInit( VOID )
+{
+ SetDesiredTextMode();
+ OverRideStyleInit(); // From ezport.c
+
+#ifdef STYLE_OEM_INIT // SDL
+ OEMStyleInit(); // OEM
+#endif
+ MouseInit();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleExit
+//
+// Description: Function to do style initialization on exit
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleExit( VOID )
+{
+ #ifdef STYLE_OEM_STYLE_EXIT // SDL
+ OEMStyleExit(); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_EXIT // from Ezport.h
+ OverRideStyleExit(); // From ezport.c
+ #endif
+ #endif
+ MouseDestroy(); //EIP-84150
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawPageBorder
+//
+// Description: Function to draw the page border
+//
+// Input: UINT32 page number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawPageBorder( UINT32 page )
+{
+ #ifdef STYLE_OEM_PAGE_BORDER // SDL
+ OEMStyleDrawPageBorder(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_BORDER // from Ezport.h
+ OverRideStyleDrawPageBorder(page); // From ezport.c
+ #else
+ ClearScreen( EFI_BACKGROUND_BLUE | EFI_WHITE );
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawScrollBar
+//
+// Description: Function to draw the frame scrollbar
+//
+// Input: FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+ #ifdef STYLE_OEM_SCROLLBAR
+ OEMDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ #ifdef STYLE_OVERRIDE_SCROLLBAR
+ OverRideDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ FrameDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawHelpScrollBar
+//
+// Description: Function to draw the help frame scrollbar
+//
+// Input: MEMO_DATA *memo, UINT16 height
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height)
+{
+ #ifdef STYLE_OEM_DRAW_HELP_SCROLLBAR
+ OEMDrawHelpScrollBar(memo, height);
+ #else
+ #ifdef STYLE_OVERRIDE_HELP_SCROLLBAR
+ OverRideDrawHelpScrollBar(memo, height);
+ #else
+ if(IsHelpAreaScrollBarSupport())
+ MemoDrawScrollBar(memo, height);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page number, UINT32 frame number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *StyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ #ifdef STYLE_OEM_FRAME_INIT_DATA
+ return OEMStyleGetFrameInitData(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_INIT_DATA // from Ezport.h
+ return OverRideStyleGetFrameInitData(page, frame); // From ezport.c
+ #else
+ return NULL;
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleKey
+//
+// Description: Function to handle frame action keys
+//
+// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_KEY // SDL
+ Status = OEMStyleFrameHandleKey(frame, Key); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_KEY // from Ezport.h
+ Status = OverRideStyleFrameHandleKey(frame, Key); // From ezport.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleMouse
+//
+// Description: Function to handle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// MOUSE_INFO MouseInfo
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_MOUSE
+ Status = OEMStyleFrameHandleMouse(frame, MouseInfo);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_MOUSE
+ Status = OverRideStyleFrameHandleMouse(frame, MouseInfo);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleTimer
+//
+// Description: Function to handle frame timer action
+//
+// Input: FRAME_DATA *frame, ACTION_DATA *action
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_TIMER
+ Status = OEMStyleFrameHandleTimer(frame, action);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_TIMER
+ Status = OverRideStyleFrameHandleTimer(frame, action);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHandleControlOverflow
+//
+// Description: Function to handle control overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ #ifdef STYLE_OEM_CONTROL_OVERFLOW
+ Status = OEMStyleHandleControlOverflow(frame, control, count );
+ #else
+ #ifdef STYLE_OVERRIDE_CONTROL_OVERFLOW
+ Status = OverRideStyleHandleControlOverflow(frame, control, count );
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInitializeFrame
+//
+// Description: Function to Initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_INITIALIZE_FRAME
+ Status = OEMStyleInitializeFrame(frame, frameType, data );
+ #else
+ #ifdef STYLE_OVERRIDE_INITIALIZE_FRAME
+ Status = OverRideStyleInitializeFrame(frame, frameType, data); //style.c
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetNavToken
+//
+// Description: Function to get navigation token
+//
+// Input: UINT32 page
+//
+// Output: UINT16 token number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleGetNavToken( UINT32 page )
+{
+ UINT16 i=0 ;
+
+ #ifdef STYLE_OEM_NAV_TOKEN
+ i = OEMStyleGetNavToken(page );
+ #else
+ #ifdef STYLE_OVERRIDE_NAV_TOKEN
+ i = OverRideStyleGetNavToken(page);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddAdditionalControls
+//
+// Description: Function to add additinal controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_ADD_CONTROLS
+ Status = OEMStyleAddAdditionalControls(frame, controlNumber, focus );
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_CONTROLS
+ Status = OverRideStyleAddAdditionalControls(frame, controlNumber, focus);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLanguagePage
+//
+// Description: Function to set Language page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_LANGUAGE_PAGE
+ i = OEMStyleLanguagePage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_LANGUAGE_PAGE
+ i = OverRideStyleLanguagePage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+
+
+
+static UINT16 _gBootManagerPageID = 0;
+/*static*/ UINT16 _gHDOrderPageID = 0;
+/*static*/ UINT16 _gCDOrderPageID = 0;
+/*static*/ UINT16 _gFDOrderPageID = 0;
+/*static*/ UINT16 _gNetOrderPageID = 0;
+/*static*/ UINT16 _gBevOrderPageID = 0;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBootManagerPage
+//
+// Description: Function to set boot manager page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_BM_PAGE
+ i = OEMStyleBootManagerPage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_BM_PAGE
+ i = OverRideStyleBootManagerPage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLabelCallback
+//
+// Description: Function to set label callback
+//
+// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie )
+{
+ #ifdef STYLE_OEM_LABEL_CALLBACK
+ OEMStyleLabelCallback(frame, label, cookie );
+ #else
+ #ifdef STYLE_OVERRIDE_LABEL_CALLBACK
+ OverRideStyleLabelCallback(frame, label, cookie );
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSelectFirstDisplayPage
+//
+// Description: Function to set the first display page
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSelectFirstDisplayPage( VOID )
+{
+ #ifdef STYLE_OEM_FIRST_PAGE
+ OEMStyleSelectFirstDisplayPage();
+ #else
+ #ifdef STYLE_OVERRIDE_FIRST_PAGE
+ OverRideStyleSelectFirstDisplayPage();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddExtraPagesData
+//
+// Description: Function to add extra pages
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleAddExtraPagesData(VOID)
+{
+ #ifdef STYLE_OEM_ADD_EXTRA_PAGES
+ OEMStyleAddExtraPagesData();
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES
+ OverRideStyleAddExtraPagesData();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetTextMode
+//
+// Description: Function to get text mode
+//
+// Input: UINTN Rows, UINTN Cols
+//
+// Output: UNNTN mode
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetTextMode( UINTN Rows, UINTN Cols )
+{
+ EFI_STATUS Status;
+ INT32 i;
+ UINTN ModeRows, ModeCols;
+
+ #ifdef STYLE_OEM_GET_TEXT_MODE
+ i = OEMStyleGetTextMode( Rows, Cols );
+ #else
+ #ifdef STYLE_OVERRIDE_GET_TEXT_MODE
+ i = OverRideStyleGetTextMode( Rows, Cols);
+ #else
+ // Default Implementation
+ for ( i = 0; i < gST->ConOut->Mode->MaxMode; i++ )
+ {
+ Status = gST->ConOut->QueryMode( gST->ConOut, i, &ModeCols, &ModeRows );
+ if ( EFI_ERROR( Status ) )
+ continue;
+
+ if ( ( Cols == ModeCols ) && ( Rows == ModeRows ) )
+ return i;
+ }
+
+ // return MaxMode if the mode wasn't found
+ #endif
+ #endif
+
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateVersionString
+//
+// Description: Function to set the version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateVersionString( VOID )
+{
+ #ifdef STYLE_OEM_VERSION_STRING
+ OEMStyleUpdateVersionString();
+ #else
+ #ifdef STYLE_OVERRIDE_VERSION_STRING
+ OverRideStyleUpdateVersionString();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameSetControlPositions
+//
+// Description: Function to set control positioning in a frame
+//
+// Input: FRAME_DATA *frame, UINT32 *pOtherEnd
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd)
+{
+ UINT32 u32Height = 0;
+ UINT32 i;
+ CONTROL_DATA *control;
+ UINT8 u8ChkResult;
+
+ #ifdef STYLE_OEM_FRAME_CONTROL_POSITION
+ OEMStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_CONTROL_POSITION
+ OverRideStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ //Move reference end variable based on action
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ {
+ i = frame->FirstVisibleCtrl;
+ }
+ else
+ {
+ i = frame->LastVisibleCtrl;
+ }
+
+ //Calculate other end variable
+ while( (pOtherEnd == &(frame->LastVisibleCtrl)) ? (i < frame->ControlCount) : TRUE )
+ {
+ control = frame->ControlList[i];
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(control->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ if( (u32Height + control->Height) < frame->FrameData.Height )
+ {
+ *pOtherEnd = i;
+ u32Height += control->Height;
+ }
+ else
+ break; //We cant accommodate
+ }
+ else
+ *pOtherEnd = i; //we can accomodate a suppressed control
+
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ i++;
+ else
+ {
+ // i>=0 in while loop will result in infinite loop
+ // break statement should be introduced inside
+ if (i == 0)
+ break;
+ i--;
+ }
+ }
+
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleOverRideComponent
+//
+// Description: Function to override component or control functionality
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleOverRideComponent(VOID)
+{
+ #ifdef STYLE_OEM_COMPONENT_OVERRIDE // SDL
+ OEMOverRideComponent(); // OEM
+ #else
+ #ifdef STYLE_COMPONENT_OVERRIDE // from Ezport.h
+ OverRideComponent(); // From ezport.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleControlSubmenu
+//
+// Description: Function to initialize submenu control
+//
+// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref )
+{
+ control->ControlHandle = gHiiHandle;
+ control->ControlType = CONTROL_TYPE_SUBMENU;
+ control->ControlFlags.ControlVisible = TRUE;
+ control->ControlPtr = (VOID*)ref;
+ control->ControlPageID = pageID;
+ control->ControlDestPageID = 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHelpAreaScrollable
+//
+// Description: Function to get Help area scroll support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleHelpAreaScrollable(VOID)
+{
+ if(IsHelpAreaScrollBarSupport())
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetShadowSupport
+//
+// Description: Function to get shadow support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetShadowSupport(VOID)
+{
+ if(STYLE_SHADOW_SUPPORT)
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBehavior
+//
+// Description: Function to get scroll behavior
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetScrollBehavior(VOID)
+{
+ return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetDateFormat
+//
+// Description: Function to get date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetDateFormat(VOID)
+{
+ #ifdef STYLE_OEM_DATE_FOMAT
+ return OEMStyleGetDateFormat();
+ #else
+ return STYLE_DATE_FORMAT;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleShowDay
+//
+// Description: Function to show day in date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleShowDay(VOID)
+{
+ return STYLE_SHOW_DAY ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxRows
+//
+// Description: Function to max number of columns
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_ROWS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxRows(VOID)
+{
+ return STYLE_STD_MAX_ROWS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxCols
+//
+// Description: Function to get max number of rows
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_COLS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxCols(VOID)
+{
+ return STYLE_STD_MAX_COLS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetClearScreenColor
+//
+// Description: Function to Get Clear Screen Color
+//
+// Input: VOID
+//
+// Output: STYLE_CLEAR_SCREEN_COLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetClearScreenColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_CLEAR_SCREEN_COLOR
+ return OverRideStyleGetClearScreenColor();
+ #else
+ return STYLE_CLEAR_SCREEN_COLOR;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageLinkColor
+//
+// Description: Function to PageLink (Submenu) color
+//
+// Input: VOID
+//
+// Output: PAGE_LINK_FGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetPageLinkColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_PAGELINK_COLOR
+ return OverRideStyleGetPageLinkColor();
+ #else
+ return PAGE_LINK_COLOR;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarColor
+//
+// Description: Function to get scrollbar color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_COLOR
+ return OverRideStyleGetScrollBarColor();
+ #else
+ return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarUpArrowColor
+//
+// Description: Function to get scrollbar UpArrow Color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarUpArrowColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_UP_ARROW_COLOR
+ return OverRideStyleGetScrollBarUpArrowColor();
+ #else
+ return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarDownArrowColor
+//
+// Description: Function to get scrollbar downarrow color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarDownArrowColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_DOWN_ARROW_COLOR
+ return OverRideStyleGetScrollBarDownArrowColor();
+ #else
+ return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StylePageItemFocus
+//
+// Description: This function is called whenever a user navigates to a new page.
+// OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+
+ #ifdef STYLE_OEM_PAGE_ITEM_FOCUS
+ OEMStylePageItemFocus(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_ITEM_FOCUS
+ OverRideStylePageItemFocus(page, frame);
+ #else
+ if(STYLE_PAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ ///Eip:30111 fix - Update the Help based on the Focussed Item
+ UpdatePageFocusedItemHelp(page);
+ }
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSubPageItemFocus
+//
+// Description: This function is called whenever a user returns (or navigates back)
+// from a submenu page causing a complete page redraw. OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_SUBPAGE_ITEM_FOCUS // SDL
+ OEMStyleSubPageItemFocus(page, frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_SUBPAGE_ITEM_FOCUS // from Ezport.h
+ OverRideStyleSubPageItemFocus(page, frame); // From ezport.c
+ #else
+ if(STYLE_SUBPAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ }
+ #endif
+ #endif
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/EzportPlus/EzportPlus.cif b/EDK/MiniSetup/EzportPlus/EzportPlus.cif
new file mode 100644
index 0000000..ca213fe
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/EzportPlus.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "TSE Sources - Style - EzportPlus"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\EzportPlus"
+ RefName = "EzportPlus"
+[files]
+"EzportPlus.sdl"
+"EzportPlus.mak"
+"ezportplus.c"
+"ezportplus.h"
+"stylecommon.c"
+"style.h"
+"style.c"
+<endComponent>
diff --git a/EDK/MiniSetup/EzportPlus/EzportPlus.mak b/EDK/MiniSetup/EzportPlus/EzportPlus.mak
new file mode 100644
index 0000000..8be7589
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/EzportPlus.mak
@@ -0,0 +1,130 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/EzportPlus.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 2 $
+##
+## $Date: 10/18/12 6:07a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/EzportPlus.mak $
+#
+# 2 10/18/12 6:07a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 2 10/10/12 12:43p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 1 3/28/11 11:51p Madhans
+# [TAG] EIP54968
+# [Category] Improvement
+# [Description] To Support different style modules in TSE generically
+# [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+# added.
+#
+# 5 2/19/10 1:02p Madhans
+# Updated for TSE 2.01. Refer Changelog.log for File change history.
+##
+## 5 2/19/10 8:15a Mallikarjunanv
+## updated year in copyright message
+##
+## 4 8/17/09 12:23p Presannar
+## Removed Include path to Core directory
+##
+## 3 6/24/09 6:10p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 2:36p Blaines
+## Update coding standard
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:15p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 3 4/28/09 9:39p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 2 4/24/09 9:35p Blaines
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+TSE_STYLE_INCLUDES = \
+ -I $(TSE_STYLE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+ -I $(TSESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\TseStyleEzportPlus.lib : TseStyleLib
+
+TseStyleLib : $(BUILD_DIR)\EzportPlus.mak TseStyleLibBinEzportPlus
+
+$(BUILD_DIR)\EzportPlus.mak : $(TSE_STYLE_DIR)\$(@B).cif $(TSE_STYLE_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSE_STYLE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+TseStyleLibBinEzportPlus :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\EzportPlus.mak all\
+ "MY_INCLUDES=$(TSE_STYLE_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TseStyleEzportPlus.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/EzportPlus/EzportPlus.sdl b/EDK/MiniSetup/EzportPlus/EzportPlus.sdl
new file mode 100644
index 0000000..faca143
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/EzportPlus.sdl
@@ -0,0 +1,1073 @@
+TOKEN
+ Name = "TSE_STYLE_EZPORTPLUS_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable EzportPlus Style in TSE"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_EZPORTPLUS"
+ Value = "1"
+ Help = "Condition to support EzportPlus Style Sources"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_STYLE_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Don't Edit."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_FULL_SCREEN"
+ Value = "1"
+ Help = "Condition to support full screen layout"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_ROWS"
+ Value = "(UINT8)(31)"
+ Help = "Maximum rows in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_COLS"
+ Value = "(UINT8)(100)"
+ Help = "Maximum columns in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_ROWS"
+ Value = "(UINT8)(24)"
+ Help = "Maximum rows in standard mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_COLS"
+ Value = "(UINT8)(80)"
+ Help = "Maximum columns in Standard mode"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Page border. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_Y"
+ Value = "(UINT8)(2)"
+ Help = "Y-Coordinate position of the Page border. (Default 2)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal width of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_FULL_H"
+ Value = "(UINT8)(STYLE_FULL_MAX_ROWS - 4)"
+ Help = "Vertical height of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_VERTICAL_MAIN_DIVIDER"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS*2/3)"
+ Help = "Vertical divider (border) position between the MainFrame window and (helper and Navigation) frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_HORIZONTAL_HELP_DIVIDER"
+ Value = "(UINT8)(4)"
+ Help = "Horizontal divider (border) position between Help and Navigation frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_Y"
+ Value = "(UINT8)(0)"
+ Help = "Y-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Title bar frame. "
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_FULL_H"
+ Value = "(UINT8)(1)"
+ Help = "Vertical Height of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_Y"
+ Value = "(UINT8)(1)"
+ Help = "Y-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_FULL_H"
+ Value = "(UINT8)(1)"
+ Help = "Vertical Height of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_X"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+1)"
+ Help = "Y-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_W"
+ Value = "(UINT8)(PAGEBORDER_FULL_W - FULL_VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_FULL_H"
+ Value = "(UINT8)(FULL_HORIZONTAL_HELP_DIVIDER - PAGEBORDER_FULL_Y - 2)"
+ Help = "Vertical Height of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_X"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_Y"
+ Value = "(UINT8)(FULL_HORIZONTAL_HELP_DIVIDER+1)"
+ Help = "Y-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_W"
+ Value = "(UINT8)(PAGEBORDER_FULL_W - FULL_VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_FULL_H"
+ Value = "(UINT8)(PAGEBORDER_FULL_H - FULL_HORIZONTAL_HELP_DIVIDER)"
+ Help = "Vertical Height of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_X"
+ Value = "(UINT8)(PAGEBORDER_FULL_X+1)"
+ Help = "X-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+1)"
+ Help = "Y-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_W"
+ Value = "(UINT8)(FULL_VERTICAL_MAIN_DIVIDER - 2)"
+ Help = "Horizontal Width of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_FULL_H"
+ Value = "(UINT8)(PAGEBORDER_FULL_H-2)"
+ Help = "Vertical Height of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Nav frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_Y"
+ Value = "(UINT8)(PAGEBORDER_FULL_Y+PAGEBORDER_FULL_H)"
+ Help = "Y-Coordinate position of the Help Title frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_W"
+ Value = "(UINT8)(STYLE_FULL_MAX_COLS)"
+ Help = "Horizontal Width of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_FULL_H"
+ Value = "(UINT8)(2)"
+ Help = "Vertical Height of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Page border. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_Y"
+ Value = "(UINT8)(2)"
+ Help = "Y-Coordinate position of the Page border. (Default 2)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal width of the page border"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGEBORDER_H"
+ Value = "(UINT8)(STYLE_STD_MAX_ROWS - 3)"
+ Help = "Vertical height of the page border."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "VERTICAL_MAIN_DIVIDER"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS*2/3)"
+ Help = "Vertical divider (border) position between the MainFrame window and (helper and Navigation) frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HORIZONTAL_HELP_DIVIDER"
+ Value = "(UINT8)(4)"
+ Help = "Horizontal divider (border) position between Help and Navigation frame windows."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_Y"
+ Value = "(UINT8)(0)"
+ Help = "Y-Coordinate position of the Title bar frame. (Default 0)"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal Width of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "TITLE_H"
+ Value = "(UINT8)(1)"
+ Help = "Vertical Height of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_Y"
+ Value = "(UINT8)(1)"
+ Help = "Y-Coordinate position of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_W"
+ Value = "(UINT8)(STYLE_STD_MAX_COLS)"
+ Help = "Horizontal Width of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MENU_H"
+ Value = "1"
+ Help = "Vertical Height of the Menu bar frame"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_X"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+1)"
+ Help = "Y-Coordinate position of the Help Title frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_W"
+ Value = "(UINT8)(PAGEBORDER_W - VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELPTITLE_H"
+ Value = "(UINT8)(HORIZONTAL_HELP_DIVIDER - PAGEBORDER_Y - 2)"
+ Help = "Vertical Height of the Help Title frame window"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_X"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER+1)"
+ Help = "X-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_Y"
+ Value = "(UINT8)(HORIZONTAL_HELP_DIVIDER+1)"
+ Help = "Y-Coordinate position of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_W"
+ Value = "(UINT8)(PAGEBORDER_W - VERTICAL_MAIN_DIVIDER-2)"
+ Help = "Horizontal Width of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "HELP_H"
+ Value = "(UINT8)(PAGEBORDER_H - HORIZONTAL_HELP_DIVIDER)"
+ Help = "Vertical Height of the Help frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_X"
+ Value = "(UINT8)(PAGEBORDER_X+1)"
+ Help = "X-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+1)"
+ Help = "Y-Coordinate position of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_W"
+ Value = "(UINT8)(VERTICAL_MAIN_DIVIDER - 2)"
+ Help = "Horizontal Width of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "MAIN_H"
+ Value = "(UINT8)(PAGEBORDER_H-2)"
+ Help = "Vertical Height of the Main frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_X"
+ Value = "(UINT8)(0)"
+ Help = "X-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_Y"
+ Value = "(UINT8)(PAGEBORDER_Y+PAGEBORDER_H)"
+ Help = "Y-Coordinate position of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_W"
+ Value = "(UINT8)(STYLE_MAX_COLS)"
+ Help = "Horizontal Width of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "NAV_H"
+ Value = "(UINT8)(2)"
+ Help = "Vertical Height of the Navigation frame window."
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "PAGE_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_LIGHTGRAY)"
+ Help = "Background Color of the main area (Main, Help, and Navigation Frames) in a page."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_FGCOLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground and Border Color of main area in a page (Default EFI_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MAIN_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background Color of the Main frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MAIN_FGCOLOR"
+ Value = "(UINT8)(EFI_BLUE)"
+ Help = "Foreground Color of the Main frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_CYAN)"
+ Help = "Background Color of the Title bar frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_FGCOLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground Color of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_FGCOLOR"
+ Value = "(UINT8)(EFI_LIGHTGRAY)"
+ Help = "Foreground Color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SELECTED_MENU_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_LIGHTGRAY)"
+ Help = "Background color of the Selected Menu in the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SELECTED_MENU_FGCOLOR"
+ Value = "(UINT8)(EFI_BLUE)"
+ Help = "Foreground Color of the Selected Menu in the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELP_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Help Frame (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELP_FGCOLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground Color of the Help Frame (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELPTITLE_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Help Title Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELPTITLE_FGCOLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground Color of the Help Title Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NAV_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_CYAN)"
+ Help = "Background color of the Navigation Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NAV_FGCOLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground Color of the Navigation Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_FGCOLOR"
+ Value = "(UINT8)(MAIN_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar Up-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_FGCOLOR"
+ Value = "(UINT8)(MAIN_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar Up-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_BGCOLOR"
+ Value = "(UINT8)(PAGE_BGCOLOR)"
+ Help = "Background color of the Scroll bar Down-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_FGCOLOR"
+ Value = "(UINT8)(MAIN_FGCOLOR)"
+ Help = "Foreground Color of the Scroll bar Down-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background Color of Popup Windows, and Message Boxes (Default EFI_BACKGROUND_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_FGCOLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Foreground Color of Popup Windows, and Message Boxes (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FOCUS_COLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Focused label and control text color (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_FOCUS_COLOR"
+ Value = "(UINT8)(FOCUS_COLOR)"
+ Help = "Focused label text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_FOCUS_COLOR"
+ Value = "(UINT8)(FOCUS_COLOR)"
+ Help = "Focused control text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NON_FOCUS_COLOR"
+ Value = "(UINT8)(MAIN_FGCOLOR)"
+ Help = "Non Focused label and control text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_NON_FOCUS_COLOR"
+ Value = "(UINT8)(NON_FOCUS_COLOR)"
+ Help = "Non Focused label text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_NON_FOCUS_COLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Non Focused control text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_LINK_COLOR"
+ Value = "(UINT8)(MAIN_FGCOLOR)"
+ Help = "Submenu text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_BGCOLOR"
+ Value = "(UINT8)(EFI_BACKGROUND_BLUE)"
+ Help = "Background color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_FGCOLOR"
+ Value = "(UINT8)(EFI_WHITE)"
+ Help = "Foreground color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TEXT_COLOR"
+ Value = "(UINT8)(EFI_BLUE)"
+ Help = "Foreround color of text controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MEMO_COLOR"
+ Value = "(UINT8)(EFI_BLACK)"
+ Help = "Foreground color of Memo controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_MARGIN"
+ Value = "37"
+ Help = "Control column left margin in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_RIGHT_AREA_WIDTH"
+ Value = "((UINT8)FULL_VERTICAL_MAIN_DIVIDER - FULL_STYLE_CONTROL_LEFT_MARGIN - FULL_STYLE_CONTROL_LEFT_PAD)"
+ Help = "Control column width in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_MARGIN"
+ Value = "24"
+ Help = "Control column left margin"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_RIGHT_AREA_WIDTH"
+ Value = "((UINT8)VERTICAL_MAIN_DIVIDER - STYLE_CONTROL_LEFT_MARGIN - STYLE_CONTROL_LEFT_PAD)"
+ Help = "Control column width"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FULL_STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in normal screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_SCROLLBAR_ROLLOVER"
+ Value = "1"
+ Help = "Support rollover when the scroll limit has been reached"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_PAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating to a new page. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SUBPAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating back from submenu. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_HOTKEY_FAILSAFE"
+ Value = "SCAN_F6"
+ Help = " Hot Key to load fail safe values"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SHADOW_SUPPORT"
+ Value = "1"
+ Help = " To enable/disable shadow support"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SPACEKEY_INCREMENT"
+ Value = "1"
+ Help = " < need to add help >"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "OVERRIDE_PopupPwdHandleActionOverRide"
+ Value = "0"
+ Help = "set to 1 to display password prompts for old, new, and confirm in the same window."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "OVERRIDE_PopupPwdAuthenticateIDEPwd"
+ Value = "0"
+ Help = "set to 1 if oem wants to override the PopupPwdAuthenticateIDEPwd function from Board module."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+
+PATH
+ Name = "TSE_STYLE_DIR"
+End
+
+MODULE
+ Help = "Includes EzportPlus.mak to Project"
+ File = "EzportPlus.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\TSEStyleEzportPlus.lib"
+ Parent = "$(TSE_STYLE_DIR)\TSEStyleEzportPlus$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
+
diff --git a/EDK/MiniSetup/EzportPlus/ezportplus.c b/EDK/MiniSetup/EzportPlus/ezportplus.c
new file mode 100644
index 0000000..7e24636
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/ezportplus.c
@@ -0,0 +1,1251 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/ezportplus.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 12 $
+//
+// $Date: 2/11/13 6:06a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/ezportplus.c $
+//
+// 12 2/11/13 6:06a Premkumara
+// [TAG] EIP112628
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] (JP000E)SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY does not work on
+// 4.6.2_TSE_2_15_1234
+// [RootCause] The Exit FormID value will change if any form is
+// generated before Exit page
+// [Solution] Handled Exit FormID from Binary and handling Exit FormID
+// from binary
+// [Files] Ezport.c, Ezport.sdl, Legacy.c, Legacy.sdl, EzportPlus.c,
+// EzportPlus.sdl
+//
+// 11 10/18/12 6:07a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:43p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 10 1/18/12 7:37a Premkumara
+// [TAG] EIP79958
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Softkeyboard is not launched for Password control in
+// EzportPlus style module
+// [RootCause] Soft keyboard was not launched for Password field in
+// EzportPlus module
+// [Solution] Launched Softkeyboard properly in EzportPlus style module
+// [Files] EzportPlus.c
+//
+// 9 1/06/12 5:05p Blaines
+// [TAG] - EIP 77887
+// [Category]- Function Request
+// [Synopsis]- Change input system password box in same window
+// [Description] - Display and get System password prompts for old, new,
+// and confirm text in the same window,
+//
+// [Files]
+// StyleTokens.c, StyleStr.uni, EzportPlus.sdl, ezportplus.c
+//
+// 8 12/14/11 6:24p Blaines
+// Added code to suppress the warnings from static code analyzer
+//
+// 7 12/14/11 3:50p Blaines
+// EIP:74899 Fixed issue with message not getting disaplayed when password
+// is cleared.
+//
+// 6 12/14/11 2:00p Blaines
+// EIP:74899 Add missing interactive support
+//
+// 5 12/14/11 1:37p Blaines
+// Fix in _PopupPasswordActivate function for IDE password applied to
+// _EzportPlusPopupPasswordActivate.
+//
+// 4 12/13/11 6:15p Blaines
+// Remove error message when ESC key pressed.
+// Display message when password is cleared.
+//
+// 3 11/23/11 1:26p Blaines
+// [TAG] - EIP 74899
+// [Category]- Function Request
+// [Synopsis]- Change input password box in same window
+// [Description] - Display Hdd and System password prompts for old, new,
+// and confirm text in the same window,
+//
+// [Files]
+// StyleTokens.c, StyleStr.uni, EzportPlus.sdl, ezportplus.c
+//
+// 2 6/29/11 12:36p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 8 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 10 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/15/10 10:12p Madhans
+// To avoid warnings
+//
+// 8 1/09/10 6:11a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 6 8/13/09 1:22p Blaines
+// Support BgColor for MAIN_FRAME, NAV_FRAME, and HELP_FRAME
+//
+// 5 8/04/09 6:57p Blaines
+// Add Support for Exit Page SDL tokens
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 9 5/05/09 3:20p Blaines
+//
+// 8 5/04/09 6:52p Blaines
+// Support customizable Help and Nav frame text Foreground color
+//
+// 7 5/01/09 9:25p Blaines
+//
+// 6 4/30/09 9:54p Blaines
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: ezportplus.c
+//
+// Description: Main file for ezportplus style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+#include "ezportplus.h"
+
+extern STYLECOLORS Colors ;
+extern AMI_IFR_MENU gMenuData ;
+extern UINTN gInvalidPasswordFailMsgBox;
+
+extern UINTN gLabelLeftMargin ;
+extern UINTN gControlLeftMargin ;
+extern UINTN gControlLeftPad ;
+extern UINTN gControlRightAreaWidth ;
+extern BOOLEAN IsPasswordSupportNonCaseSensitive();
+
+static CALLBACK_SUBMENU gMenuCallbackData = { { CALLBACK_TYPE_MENU, sizeof(CALLBACK_MENU) }, 0 };
+static CALLBACK_SUBMENU gSubmenuCallbackData = { { CALLBACK_TYPE_SUBMENU, sizeof(CALLBACK_SUBMENU) }, 0 };
+static CALLBACK_VARIABLE gVariableCallbackData = { { CALLBACK_TYPE_VARIABLE, sizeof(CALLBACK_VARIABLE) }, 0, 0, 0, NULL };
+static CALLBACK_PASSWORD gPasswordCallbackData = { { CALLBACK_TYPE_PASSWORD, sizeof(CALLBACK_PASSWORD) }, 0, 0, 0, NULL, TRUE };
+
+VOID _FrameSubmenuCallback( FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie );
+VOID _FrameMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, VOID *cookie );
+
+BOOLEAN gotoExitOnEscKey(EFI_GUID *exitFormGuid, UINT16 *pageClass, UINT16 *pageSubclass, UINT16 *pageFormID);//EIP-112628
+
+#if SETUP_STYLE_EZPORTPLUS
+
+#if SETUP_STYLE_FULL_SCREEN
+static FRAME_INFO _gStyleFullSubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, TITLE_FULL_W, TITLE_FULL_H, TITLE_FULL_Y, TITLE_FULL_X, TITLE_FGCOLOR, TITLE_BGCOLOR },// TITLE
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, MENU_FULL_W, MENU_FULL_H, MENU_FULL_Y, MENU_FULL_X, MENU_FGCOLOR, MENU_BGCOLOR },// SUBTITLE (MENU)
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, HELPTITLE_FULL_W, HELPTITLE_FULL_H, HELPTITLE_FULL_Y, HELPTITLE_FULL_X, HELPTITLE_FGCOLOR, HELPTITLE_BGCOLOR },// HELP TITLE (Copyright)
+ { HELP_FRAME, TRUE, FALSE, 0, HELP_FULL_W, HELP_FULL_H, HELP_FULL_Y, HELP_FULL_X, HELP_FGCOLOR, HELP_BGCOLOR },// HELP
+ { MAIN_FRAME, TRUE, FALSE, 0, MAIN_FULL_W, MAIN_FULL_H, MAIN_FULL_Y, MAIN_FULL_X, PAGE_FGCOLOR, MAIN_BGCOLOR },// Main
+ { NAV_FRAME, TRUE, FALSE, 0, NAV_FULL_W, NAV_FULL_H, NAV_FULL_Y, NAV_FULL_X, NAV_FGCOLOR, NAV_BGCOLOR }// NAVIGATION
+
+};
+#endif
+
+static FRAME_INFO _gStyleStandardSubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, TITLE_W, TITLE_H, TITLE_Y, TITLE_X, TITLE_FGCOLOR, TITLE_BGCOLOR },// TITLE
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, MENU_W, MENU_H, MENU_Y, MENU_X, MENU_FGCOLOR, MENU_BGCOLOR },// SUBTITLE (MENU)
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, HELPTITLE_W,HELPTITLE_H,HELPTITLE_Y,HELPTITLE_X,HELPTITLE_FGCOLOR, HELPTITLE_BGCOLOR },// HELP TITLE (Copyright)
+ { HELP_FRAME, TRUE, FALSE, 0, HELP_W, HELP_H, HELP_Y, HELP_X, HELP_FGCOLOR, HELP_BGCOLOR },// HELP
+ { MAIN_FRAME, TRUE, FALSE, 0, MAIN_W, MAIN_H, MAIN_Y, MAIN_X, PAGE_FGCOLOR, MAIN_BGCOLOR },// Main
+ { NAV_FRAME, TRUE, FALSE, 0, NAV_W, NAV_H, NAV_Y, NAV_X, NAV_FGCOLOR, NAV_BGCOLOR }// NAVIGATION
+
+};
+
+AMITSE_CONTROL_MAP gTseControlMap[] =
+{
+// ControlType ControlMethods CallbackSuppored CallbackFunction CallbackContext
+ { CONTROL_TYPE_MENU, (CONTROL_METHODS*)&gMenu, TRUE, (VOID*)(UINTN)&_FrameMenuCallback, (VOID*)(UINTN)&gMenuCallbackData},
+ { CONTROL_TYPE_SUBMENU, (CONTROL_METHODS*)&gSubMenu,TRUE, (VOID*)(UINTN)&_FrameSubmenuCallback, (VOID*) &gSubmenuCallbackData},
+ { CONTROL_TYPE_LABEL, (CONTROL_METHODS*)&gLabel, TRUE, (VOID*)(UINTN)&StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_TEXT, (CONTROL_METHODS*)&gText, FALSE,(VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUP_STRING, (CONTROL_METHODS*)&gPopupString, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_DATE, (CONTROL_METHODS*)&gDate, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_TIME, (CONTROL_METHODS*)&gTime, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUPSEL, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ // Checkbox is just popup sel
+ { CONTROL_TYPE_CHECKBOX, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_MEMO, (CONTROL_METHODS*)&gMemo, FALSE, (VOID*)NULL, (VOID*)NULL},
+ { CONTROL_TYPE_NUMERIC, (CONTROL_METHODS*)&gNumeric, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_ORDERED_LIST, (CONTROL_METHODS*)&gOrdListBox, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_PASSWORD, (CONTROL_METHODS*)&gPopupPassword, TRUE, (VOID*)(UINTN)&_FramePasswordCallback, (VOID*)&gPasswordCallbackData},
+ { CONTROL_TYPE_ACTION, (CONTROL_METHODS*)&gUefiAction, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_RESET, (CONTROL_METHODS*)&gResetButton, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},//EIP:56413 Updated the Reset Button Control information
+ // CONTROL_TYPE_NULL need to be last member
+ { CONTROL_TYPE_NULL, (CONTROL_METHODS*)NULL, FALSE, (VOID*)NULL, (VOID*) NULL}
+};
+
+static FRAME_INFO *_gStyleSubFrames = _gStyleStandardSubFrames ;
+
+UINT8 gVerticalMainDivider = VERTICAL_MAIN_DIVIDER ;
+UINT8 gHorizontalHelpDivider = HORIZONTAL_HELP_DIVIDER ;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleInit( VOID )
+{
+
+ gLabelLeftMargin = STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = STYLE_CONTROL_LEFT_PAD ;
+ gControlRightAreaWidth = STYLE_CONTROL_RIGHT_AREA_WIDTH ;
+
+
+#if SETUP_STYLE_FULL_SCREEN
+ if ( gMaxCols == STYLE_FULL_MAX_COLS )
+ {
+ _gStyleSubFrames = _gStyleFullSubFrames;
+
+ gVerticalMainDivider = FULL_VERTICAL_MAIN_DIVIDER ;
+ gHorizontalHelpDivider = FULL_HORIZONTAL_HELP_DIVIDER ;
+
+ gLabelLeftMargin = FULL_STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = FULL_STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = FULL_STYLE_CONTROL_LEFT_PAD ;
+ gControlRightAreaWidth = FULL_STYLE_CONTROL_RIGHT_AREA_WIDTH ;
+ }
+#endif
+
+ if(gLabelLeftMargin < 2)
+ gLabelLeftMargin = 2 ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameIndexOf
+//
+// Description: Function to get frame index
+//
+// Input: UINT32 frameType
+//
+// Output: UINT32 index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleFrameIndexOf( UINT32 frameType )
+{
+ UINT32 FrameCount ;
+ UINT32 i;
+
+ FrameCount = sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO);
+
+
+ for ( i = 0; i < FrameCount; i++ )
+ {
+ if( _gStyleSubFrames[i].FrameType == frameType ){
+ return i ;
+ break ;
+ }
+ }
+
+ return i ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageFrames
+//
+// Description: Function to number of frames
+//
+// Input: UINT32 page
+//
+// Output: UINT32 number of frames
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleGetPageFrames( UINT32 page )
+{
+ return sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleDrawPageBorder
+//
+// Description: Function to draw page border
+//
+// Input: UINT32 page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleDrawPageBorder( UINT32 page )
+{
+ PAGE_DATA *Page ;
+ FRAME_DATA *fTitle, *fMenu, *fHelptitle ;
+
+ CHAR16 *line;
+ UINT8 lineNumber;
+ UINT8 start, end, col;
+ UINT8 pbx,pby,pbw,pbh;
+ UINT8 vertDivider = VERTICAL_MAIN_DIVIDER ;
+ UINT8 horzDivider = HORIZONTAL_HELP_DIVIDER;
+
+ Page = gApp->PageList[page];
+
+ fTitle = Page->FrameList[StyleFrameIndexOf(TITLE_FRAME)];
+ fHelptitle = Page->FrameList[StyleFrameIndexOf(HELPTITLE_FRAME)];
+ fMenu = Page->FrameList[StyleFrameIndexOf(SUBTITLE_FRAME)];
+
+ pbx = PAGEBORDER_X;
+ pby = PAGEBORDER_Y;
+ pbw = PAGEBORDER_W;
+ pbh = PAGEBORDER_H;
+
+ if ( gMaxCols == STYLE_FULL_MAX_COLS )
+ {
+ vertDivider = FULL_VERTICAL_MAIN_DIVIDER ;
+ horzDivider = FULL_HORIZONTAL_HELP_DIVIDER;
+ pbx = PAGEBORDER_FULL_X;
+ pby = PAGEBORDER_FULL_Y;
+ pbw = PAGEBORDER_FULL_W;
+ pbh = PAGEBORDER_FULL_H;
+ }
+
+
+ line = EfiLibAllocateZeroPool( (gMaxCols + 1) * sizeof(CHAR16) );
+ if ( line == NULL )
+ return;
+
+ ClearLinesWithoutFlush( fTitle->FrameData.Top, fTitle->FrameData.Height, fTitle->FrameData.BGColor | fTitle->FrameData.FGColor );
+ ClearLinesWithoutFlush( fHelptitle->FrameData.Top, fHelptitle->FrameData.Height, fHelptitle->FrameData.BGColor | fHelptitle->FrameData.FGColor );
+ ClearLinesWithoutFlush( fMenu->FrameData.Top, fMenu->FrameData.Height, fMenu->FrameData.BGColor | fMenu->FrameData.FGColor );
+ ClearLinesWithoutFlush( pby, pbh, PAGE_BGCOLOR | PAGE_FGCOLOR );
+
+
+ DrawWindow( pbx, pby, pbw, pbh, PAGE_BGCOLOR| PAGE_FGCOLOR, TRUE, FALSE );
+
+ // Hidden line in first page
+ if (Page->PageData.PageIdIndex == FIRST_PAGE_ID_INDEX)
+ {
+ gBS->FreePool( line );
+ return;
+ }
+
+ MemFillUINT16Buffer( &line[1], gMaxCols - 1, BOXDRAW_HORIZONTAL );
+
+ line[0] = BOXDRAW_DOWN_HORIZONTAL;
+ line[1] = L'\0';
+ DrawString( vertDivider, pby, line );
+
+ line[0] = BOXDRAW_UP_HORIZONTAL;
+ DrawString( vertDivider, pby+pbh-1, line );
+
+ // center divider
+ line[0] = BOXDRAW_VERTICAL;
+
+ col = vertDivider ;
+ start = pby+1;
+ end = pby+pbh-1 ;
+
+ for ( lineNumber = start; lineNumber < end ; lineNumber++ )
+ DrawString( col, lineNumber, line );
+
+ // Horizontal Help divider
+ MemFillUINT16Buffer( &line[1], gMaxCols - 1, BOXDRAW_HORIZONTAL );
+ line[0] = BOXDRAW_VERTICAL;
+ //line[1] = BOXDRAW_HORIZONTAL;
+ line[gMaxCols - vertDivider-1] = L'\0';
+ DrawString(col, horzDivider, line );
+
+ FlushLines( 0, end-1 );
+
+ gBS->FreePool( line );
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page, UINT32 frame
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ return &_gStyleSubFrames[frame];
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameAddTitle
+//
+// Description: Function to add frame title
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy )
+{
+ return EFI_UNSUPPORTED;
+}
+
+#endif /* SETUP_STYLE_EZPORTPLUS */
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandleEscKey
+//
+// Description: Function to handle ESC Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandleEscKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ UINT16 pageClass = 0, pageSubclass = 0, pageFormID = 0;
+ EFI_GUID ExitPageGuid;
+
+
+ if(FormBrowserHandleValid())
+ app->Quit = TRUE;
+
+ else if ( gotoExitOnEscKey (&ExitPageGuid, &pageClass, &pageSubclass, &pageFormID) )//EIP-112628
+ {
+ UINT32 i=0;
+ PAGE_INFO *pageInfo;
+
+ for ( i = 0; i < gPages->PageCount; i++ )
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+ if (
+ ( EfiCompareGuid(&ExitPageGuid,&(gPageIdInfo[pageInfo->PageIdIndex].PageGuid)) ) &&
+ ( pageClass == gPageIdInfo[pageInfo->PageIdIndex].PageClass ) &&
+ ( pageSubclass == gPageIdInfo[pageInfo->PageIdIndex].PageSubClass ) &&
+ ( pageFormID == pageInfo->PageFormID )
+ )
+ {
+ gApp->CurrentPage = i; // Page found go to exit page
+ gApp->CompleteRedraw = TRUE;
+ gApp->Fixed = FALSE;
+ break;
+ }
+ }
+ if(i >= gPages->PageCount) //Page not found exit application
+ app->Quit = ExitApplication();
+ }
+
+ else
+ app->Quit = ExitApplication();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandleSaveExitKey
+//
+// Description: Function to handle Save and Exit Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ app->Quit = SaveAndExit();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandlePrevValuesKey
+//
+// Description: Function to handle Load Previous value Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadPreviousValues( TRUE );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandleFailsafeKey
+//
+// Description: Function to handle Load Failsafe values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadFailsafeDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandleOptimalKey
+//
+// Description: Function to handle Load Optimal values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ LoadOptimalDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandleHelpKey
+//
+// Description: Function to handle Help Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( app->CurrentPage != 0 )
+ ShowHelpMessageBox();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHandlePrnScrnKey
+//
+// Description: Function to handle print screen Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHandlePrnScrnKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ TseHotkeyPrintScreenSupport();
+}
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//EIP:47086 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusMainFrameHandlewithMouse
+//
+// Description: Function to handle Main Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusMainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+ if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK)
+ app->Quit = ExitApplication();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusHelpFrameHandlewithMouse
+//
+// Description: Function to handle Help Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusHelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusNavFrameHandlewithMouse
+//
+// Description: Function to handle Navigation Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusNavFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+}
+//EIP:47086 END
+
+
+
+
+//EIP:74899 START
+#if OVERRIDE_PopupPwdHandleActionOverRide
+extern VOID UpdatePasswordToNonCaseSensitive(CHAR16 *Password, UINTN PwdLength);
+extern UINT8 CallbackShowMessageBox( UINTN data, UINT8 type );
+extern UINTN gClearPasswordMsgBox ;
+
+EFI_STATUS _EzportPlusPopupPasswordHandleAction( VOID *popuppassword, VOID *Data);
+EFI_STATUS PopupPwdHandleActionOverRide(POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data)
+{
+ return _EzportPlusPopupPasswordHandleAction(popuppassword, Data);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusShowPasswordErrorMessageBox
+//
+// Description: Function to Display the password failed message box
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusShowPasswordErrorMessageBox( VOID )
+{
+ UINT8 sel = 0 ;
+ AMI_POST_MGR_KEY OutKey ;
+
+ PostManagerDisplayMsgBoxEx(
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_ERROR)),
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_ERROR_PSWD)),
+ NULL, MSGBOX_EX_CATAGORY_WARNING, MSGBOX_TYPE_OK,
+ NULL, 0, NULL, 0, &sel, &OutKey
+ ) ;
+ TSEStringReadLoopExitHook();//EIP-79958 Exit softkeyboard after display Error Msg Box
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusShowPasswordSuccessMessageBox
+//
+// Description: Function to Display the password success message box
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusShowPasswordSuccessMessageBox( VOID )
+{
+ UINT8 sel = 0 ;
+ AMI_POST_MGR_KEY OutKey ;
+
+ PostManagerDisplayMsgBoxEx(
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_SUCCESS)),
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_PASSWORD_SUCCESS_MSG)),
+ NULL, MSGBOX_EX_CATAGORY_SUCCESS, MSGBOX_TYPE_OK,
+ NULL, 0, NULL, 0, &sel, &OutKey
+ ) ;
+ TSEStringReadLoopExitHook();//EIP-79958 Exit SoftKeyboard after displayed Successful Msg Box
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusShowPasswordClearedMessageBox
+//
+// Description: Function to Display the password success message box
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EzportPlusShowPasswordClearedMessageBox( VOID )
+{
+ UINT8 sel = 0 ;
+ AMI_POST_MGR_KEY OutKey ;
+
+ PostManagerDisplayMsgBoxEx(
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_INFO)),
+ HiiGetString( gHiiHandle, STRING_TOKEN(STR_PASSWORD_CLEARED_MSG)),
+ NULL, MSGBOX_EX_CATAGORY_QUERY, MSGBOX_TYPE_OK,
+ NULL, 0, NULL, 0, &sel, &OutKey
+ ) ;
+ TSEStringReadLoopExitHook(); //EIP-79958 Exit Softkeyboard after displayed Clear Old Password Msg Box
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusPopupPasswordSetPrompt
+//
+// Description: Function to display password prompts for new, and confirm in the same window.
+//
+// Input: POPUP_PASSWORD_DATA *PopupPassword,
+// UINT16 NewPrompt,
+// CHAR16 **NewPwd,
+// UINT16 ConfirmPrompt,
+// CHAR16 **ConfirmPwd,
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EzportPlusPopupPasswordSetPrompt(POPUP_PASSWORD_DATA *PopupPassword, UINT16 NewPrompt, CHAR16 **NewPwd, UINT16 ConfirmPrompt, CHAR16 **ConfirmPwd)
+{
+ EFI_STATUS Status = EFI_SUCCESS ;
+
+ UINT8 Length = (UINT8)UefiGetMaxValue(PopupPassword->ControlData.ControlPtr);
+
+ TEXT_INPUT_TEMPLATE SetPasswordPrompt[2] =
+ {
+ {NewPrompt, Length, TSE_FILTER_KEY_NULL, TRUE, NULL},
+ {ConfirmPrompt, Length, TSE_FILTER_KEY_NULL, TRUE, NULL}
+ };
+
+ UINT16 Title = STRING_TOKEN(STR_SET_PASSWORD_PROMPT) ;
+
+ *NewPwd = EfiLibAllocateZeroPool((Length+1) * sizeof(CHAR16) );
+ *ConfirmPwd = EfiLibAllocateZeroPool((Length+1) * sizeof(CHAR16) );
+
+ SetPasswordPrompt[0].Value = *NewPwd ;
+ SetPasswordPrompt[1].Value = *ConfirmPwd ;
+
+
+ if ( *NewPwd == NULL || *ConfirmPwd == NULL)
+ return EFI_OUT_OF_RESOURCES ;
+
+ TSEStringReadLoopEntryHook(); //EIP-79958 Launch Softkeyboard on selecting Password control for setting password
+
+ Status = PostManagerDisplayTextBox(
+ gHiiHandle,
+ Title,
+ SetPasswordPrompt,
+ 2,
+ NULL
+ ) ;
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EzportPlusPopupPasswordChangePrompt
+//
+// Description: Function to display password prompts for old, new, and confirm in the same window.
+//
+// Input: POPUP_PASSWORD_DATA *PopupPassword,
+// UINT16 OldPrompt,
+// CHAR16 **OldPwd,
+// UINT16 NewPrompt,
+// CHAR16 **NewPwd,
+// UINT16 ConfirmPrompt,
+// CHAR16 **ConfirmPwd,
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EzportPlusPopupPasswordChangePrompt(POPUP_PASSWORD_DATA *PopupPassword, UINT16 OldPrompt, CHAR16 **OldPwd, UINT16 NewPrompt, CHAR16 **NewPwd, UINT16 ConfirmPrompt, CHAR16 **ConfirmPwd)
+{
+
+ EFI_STATUS Status = EFI_SUCCESS ;
+
+ UINT8 Length = (UINT8)UefiGetMaxValue(PopupPassword->ControlData.ControlPtr);
+
+ TEXT_INPUT_TEMPLATE ChangePasswordPrompt[3] =
+ {
+ {OldPrompt, Length, TSE_FILTER_KEY_NULL, TRUE, NULL},
+ {NewPrompt, Length, TSE_FILTER_KEY_NULL, TRUE, NULL},
+ {ConfirmPrompt, Length, TSE_FILTER_KEY_NULL, TRUE, NULL}
+ };
+
+ UINT16 Title = STRING_TOKEN(STR_CHANGE_PASSWORD_PROMPT) ;
+
+ *OldPwd = EfiLibAllocateZeroPool((Length+1) * sizeof(CHAR16) );
+ *NewPwd = EfiLibAllocateZeroPool((Length+1) * sizeof(CHAR16) );
+ *ConfirmPwd = EfiLibAllocateZeroPool((Length+1) * sizeof(CHAR16) );
+
+ ChangePasswordPrompt[0].Value = *OldPwd ;
+ ChangePasswordPrompt[1].Value = *NewPwd ;
+ ChangePasswordPrompt[2].Value = *ConfirmPwd ;
+
+
+ if ( *OldPwd == NULL || NewPwd == NULL || *ConfirmPwd == NULL)
+ return EFI_OUT_OF_RESOURCES ;
+
+ TSEStringReadLoopEntryHook(); //EIP-79958 Launch Softkeyboard on selecting Password control for changing password
+
+ Status = PostManagerDisplayTextBox(
+ gHiiHandle,
+ Title,
+ ChangePasswordPrompt,
+ 3,
+ NULL
+ ) ;
+
+ return Status;
+}
+
+BOOLEAN IsPasswordSupportNonCaseSensitive();
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _EzportPlusPopupPasswordActivate
+//
+// Description: function to set and activate a password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _EzportPlusPopupPasswordActivate(POPUP_PASSWORD_DATA *popuppassword)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ BOOLEAN AbortUpdate = FALSE, ChangePwd = FALSE, ClearPwd = FALSE ;
+ CHAR16 /* *TempText=NULL,*/ *Text=NULL,*NewPswd=NULL,*ConfirmNewPswd=NULL;
+ VOID *data = popuppassword->ControlData.ControlPtr;
+ UINTN NewPwLen = 0, ConfirmPwLen = 0;
+
+ if( PopupPwdAuthenticateIDEPwd(popuppassword,&AbortUpdate,data) != EFI_SUCCESS)
+ {
+
+ AbortUpdate = FALSE;
+
+ if(PopupPasswordCheckInstalled(popuppassword))
+ {
+
+ ChangePwd = TRUE ;
+ Status = EzportPlusPopupPasswordChangePrompt(popuppassword, STRING_TOKEN(STR_OLD_PSWD), &Text, STRING_TOKEN(STR_NEW_PSWD), &NewPswd, STRING_TOKEN(STR_CONFIRM_NEW_PSWD), &ConfirmNewPswd) ;
+
+ if( Status )
+ AbortUpdate = TRUE;
+ else
+ {
+ if(!PopupPasswordAuthenticate( popuppassword, Text ))
+ {
+ // optional message to user: "wrong password" and exit
+ //CallbackShowMessageBox( (UINTN)gInvalidPasswordFailMsgBox, MSGBOX_TYPE_OK );
+ EzportPlusShowPasswordErrorMessageBox();
+ AbortUpdate = TRUE;
+ }
+ }
+ }
+ }
+#if OVERRIDE_PopupPwdAuthenticateIDEPwd && SETUP_IDE_SECURITY_SUPPORT
+ else
+ {
+ BOOLEAN bCheckUser = FALSE;
+ BOOLEAN EnabledBit = FALSE;
+ UINTN size = 0;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+ VOID* DataPtr = TSEIDEPasswordGetDataPtr(gCurrIDESecPage);
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL != ideSecConfig) {
+
+ if(ideSecConfig->Enabled) EnabledBit = TRUE;
+
+ if(EnabledBit)
+ {
+ if(UefiGetQuestionOffset(data) /*data->QuestionId*/ == STRUCT_OFFSET(IDE_SECURITY_CONFIG,IDEUserPassword))
+ bCheckUser = TRUE;
+
+ if(bCheckUser || ideSecConfig->MasterPasswordStatus)
+ {
+ //Status = _DoPopupEdit( *popuppassword, STRING_TOKEN(STR_OLD_PSWD), &Text);
+ ChangePwd = TRUE ;
+ Status = EzportPlusPopupPasswordChangePrompt(popuppassword, STRING_TOKEN(STR_OLD_PSWD), &Text, STRING_TOKEN(STR_NEW_PSWD), &NewPswd, STRING_TOKEN(STR_CONFIRM_NEW_PSWD), &ConfirmNewPswd) ;
+
+ if(Status )
+ {
+ AbortUpdate = TRUE;
+ }
+ else
+ {
+ Status = TSEIDEPasswordAuthenticate( Text, DataPtr, bCheckUser );
+ if(EFI_ERROR( Status ))
+ {
+ //CallbackShowMessageBox( (UINTN)gInvalidPasswordFailMsgBox, MSGBOX_TYPE_OK );
+ EzportPlusShowPasswordErrorMessageBox();
+ AbortUpdate = TRUE;
+ }
+ else
+ {
+ NewPwLen = EfiStrLen(NewPswd);
+ ConfirmPwLen = EfiStrLen(ConfirmNewPswd);
+
+ if(NewPwLen == 0 && ConfirmPwLen == 0)
+ {
+ ClearPwd = TRUE ;
+ }
+ }
+ }
+ }
+ }
+
+ MemFreePointer((VOID **) &ideSecConfig);
+ }
+ }
+#endif
+
+ if(AbortUpdate == FALSE)
+ {
+Password:
+
+ if(ChangePwd == FALSE)
+ {
+ Status = EzportPlusPopupPasswordSetPrompt(popuppassword, STRING_TOKEN(STR_NEW_PSWD), &NewPswd, STRING_TOKEN(STR_CONFIRM_NEW_PSWD), &ConfirmNewPswd) ;
+
+ if(!Status && EfiStrLen(NewPswd) == 0)
+ {
+ //Report Message box
+ EzportPlusShowPasswordErrorMessageBox();
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+
+ if(!Status)
+ {
+ NewPwLen = EfiStrLen(NewPswd);
+ ConfirmPwLen = EfiStrLen(ConfirmNewPswd);
+ //EIP-39764 : non case sensitive support during setting password
+ if( IsPasswordSupportNonCaseSensitive() && (NewPwLen != 0)) {
+ UpdatePasswordToNonCaseSensitive(NewPswd, NewPwLen);
+ }
+
+ if (VARIABLE_ID_IDE_SECURITY != popuppassword->ControlData.ControlVariable)
+ {
+ if(PopupPasswordCheckInstalled(popuppassword))
+ {
+ // Override the minmax validation for password clearing
+ if(NewPwLen == 0 && ConfirmPwLen == 0)
+ {
+ //Report Message box for Clearing Old password
+ if(CallbackShowMessageBox( (UINTN)gClearPasswordMsgBox, MSGBOX_TYPE_YESNO )!= MSGBOX_YES)
+ {
+ ChangePwd = FALSE ;
+ ClearPwd = FALSE ;
+ goto Password;
+ //Status = EFI_UNSUPPORTED; //Do not clear the password
+ }
+ else
+ {
+ ClearPwd = TRUE ;
+ }
+ }
+ }
+ }else if( (NewPwLen < (UINT8)UefiGetMinValue(popuppassword->ControlData.ControlPtr)) ||
+ (NewPwLen > (UINT8)UefiGetMaxValue(popuppassword->ControlData.ControlPtr))
+ )
+ {
+ //Report Message box
+ EzportPlusShowPasswordErrorMessageBox();
+
+ Status = EFI_UNSUPPORTED;
+ }
+
+ if( ClearPwd == TRUE)
+ {
+ if(ConfirmNewPswd)
+ StringZeroFreeMemory ((VOID **)&ConfirmNewPswd);
+
+ ConfirmNewPswd = EfiLibAllocateZeroPool( sizeof(CHAR16) );
+
+ if(ConfirmNewPswd)
+ {
+ *ConfirmNewPswd = '\0'; //Set confirmation password to null string
+ }
+ else
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+
+ }
+ }
+
+ if ( !Status )
+ {
+ //EIP-39764 : non case sensitive support during setting password
+ if( IsPasswordSupportNonCaseSensitive() && EfiStrLen(ConfirmNewPswd)) {
+ NewPwLen = EfiStrLen(ConfirmNewPswd);
+ UpdatePasswordToNonCaseSensitive( ConfirmNewPswd, NewPwLen );
+ }
+ if ( EfiStrCmp(NewPswd, ConfirmNewPswd)==0 )
+ {
+ //EIP-75521 Support for Interactive Password control
+ if(popuppassword->Text != NULL){
+ MemFreePointer( (VOID **)&popuppassword->Text );
+ }
+ popuppassword->Text = (CHAR16 *) EfiLibAllocateZeroPool((NewPwLen + 1) * sizeof(CHAR16));
+ EfiStrCpy(popuppassword->Text, NewPswd);
+
+ //save new password
+ if ( ( popuppassword->Callback != NULL ) && ( popuppassword->Cookie != NULL ) )
+ {
+ VOID *ifrData = popuppassword->ControlData.ControlPtr;
+ CALLBACK_PASSWORD *callbackData = (CALLBACK_PASSWORD *)popuppassword->Cookie;
+
+ callbackData->Variable = popuppassword->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = (UINT8)UefiGetMaxValue(ifrData) * sizeof(CHAR16);
+ callbackData->Data = (VOID *)NewPswd;
+ UefiPreControlUpdate(&(popuppassword->ControlData));
+ popuppassword->Callback( popuppassword->Container,popuppassword, popuppassword->Cookie );
+
+ PopupPwdUpdateIDEPwd ();
+ }
+
+
+ //For interactive control invoke the formcallback function.
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ {
+ VOID *Handle = popuppassword->ControlData.ControlHandle;
+ UINT16 Key = UefiGetControlKey(&(popuppassword->ControlData));
+ CONTROL_DATA *Control = (CONTROL_DATA *)NULL;
+
+ //Call the callback passing the input value and value size.
+ Status = CallFormCallBack( &(popuppassword->ControlData),Key,0,AMI_CALLBACK_CONTROL_UPDATE);
+
+ Control = GetUpdatedControlData((CONTROL_DATA*)popuppassword, CONTROL_TYPE_PASSWORD, Handle, Key);
+ if(Control == NULL){ //Control deleted.
+ return EFI_SUCCESS;
+ }
+ if(Control != (CONTROL_DATA *)popuppassword){
+ popuppassword = (POPUP_PASSWORD_DATA *)Control; //Control Updated.
+ }
+ }
+
+ popuppassword->ControlActive = FALSE;
+
+ if(ClearPwd)
+ {
+ EzportPlusShowPasswordClearedMessageBox();
+ }
+ else if(NewPwLen != 0)
+ {
+ EzportPlusShowPasswordSuccessMessageBox();
+ }
+ }
+ else
+ {
+ EzportPlusShowPasswordErrorMessageBox();
+ }
+ }
+ }
+
+ StringZeroFreeMemory ((VOID **)&Text); //EIP67735 zeroing the password prompt memories
+ StringZeroFreeMemory ((VOID **)&NewPswd);
+ StringZeroFreeMemory ((VOID **)&ConfirmNewPswd);
+
+ TSEStringReadLoopExitHook();//EIP-79958 Exit softkeyboard on pressing ESC
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _EzportPlusPopupPasswordHandleAction
+//
+// Description: function to handle the password actions
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, , ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _EzportPlusPopupPasswordHandleAction( POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ return Status;
+
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ CONTROL_ACTION Action;
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ if(ControlActionSelect == Action)
+ {
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ if(PopupPasswordFormCallback(&(popuppassword->ControlData),UefiGetControlKey(&(popuppassword->ControlData)),0) == EFI_SUCCESS)
+ return EFI_SUCCESS;
+
+ return _EzportPlusPopupPasswordActivate(popuppassword);
+ }
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ if(ControlActionSelect == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ {
+ if( popuppassword->Top == (Data->Input.Data.MouseInfo.Top) )
+ {
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ if(PopupPasswordFormCallback(&(popuppassword->ControlData),UefiGetControlKey(&(popuppassword->ControlData)),0) == EFI_SUCCESS)
+ return EFI_SUCCESS;
+
+ return _EzportPlusPopupPasswordActivate(popuppassword);
+ }
+ }
+ }
+ return Status;
+}
+#endif
+
+
+#if OVERRIDE_PopupPwdAuthenticateIDEPwd
+
+EFI_STATUS PopupPwdAuthenticateIDEPwd(POPUP_PASSWORD_DATA *popuppassword, BOOLEAN *AbortUpdate,VOID *data)
+{
+#if SETUP_IDE_SECURITY_SUPPORT
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CHAR16 *Text=NULL;
+ if(popuppassword->ControlData.ControlVariable == VARIABLE_ID_IDE_SECURITY )
+ {
+ //if drive is locked ask for the old password to unlock the drive
+ VOID* DataPtr = TSEIDEPasswordGetDataPtr(gCurrIDESecPage);
+ BOOLEAN bCheckUser = FALSE;
+ BOOLEAN EnabledBit = FALSE;
+ UINTN size = 0;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == ideSecConfig)
+ return EFI_NOT_FOUND;
+
+ if(ideSecConfig->Enabled) EnabledBit = TRUE;
+
+ if(EnabledBit)
+ {
+ return EFI_SUCCESS;
+ }
+
+ MemFreePointer((VOID **) &ideSecConfig);
+ return EFI_SUCCESS;
+ }
+ return EFI_UNSUPPORTED;
+#else
+ return EFI_UNSUPPORTED;
+#endif
+}
+#endif
+//EIP:74899 END
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/EzportPlus/ezportplus.h b/EDK/MiniSetup/EzportPlus/ezportplus.h
new file mode 100644
index 0000000..225b8f6
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/ezportplus.h
@@ -0,0 +1,141 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/ezportplus.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:07a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/ezportplus.h $
+//
+// 2 10/18/12 6:07a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:43p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:12a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 3 8/18/09 6:34p Blaines
+// Support additional date styles
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:14p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: ezportplus.h
+//
+// Description: Main header file for ezportplus style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _EZPORTPLUS_H_
+#define _EZPORTPLUS_H_
+
+#if SETUP_STYLE_EZPORTPLUS
+
+VOID OverRideStyleInit( VOID );
+VOID OverRideStyleDrawPageBorder( UINT32 page );
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+#if SETUP_STYLE_FULL_SCREEN
+ #define STYLE_MAX_COLS STYLE_FULL_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_FULL_MAX_ROWS
+#else
+ #define STYLE_MAX_COLS STYLE_STD_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_STD_MAX_ROWS
+#endif
+
+#define EFI_BACKGROUND_WHITE (EFI_WHITE << 4)
+#define STYLE_CLEAR_SCREEN_COLOR (HELPTITLE_BGCOLOR | EFI_WHITE)
+
+
+// Style Overrides...
+#define STYLE_OVERRIDE_INIT
+#define STYLE_OVERRIDE_PAGE_BORDER
+#define STYLE_OVERRIDE_FRAME_INIT_DATA
+#define STYLE_OVERRIDE_CONTROL_OVERFLOW
+#define STYLE_OVERRIDE_INITIALIZE_FRAME
+#define STYLE_OVERRIDE_INITIALIZE_OEM_FRAME
+#define STYLE_OVERRIDE_NAV_TOKEN
+#define STYLE_OVERRIDE_ADD_CONTROLS
+#define STYLE_OVERRIDE_FIRST_PAGE
+#define STYLE_OVERRIDE_VERSION_STRING
+#define STYLE_OVERRIDE_FRAME_DRAWABLE
+
+#define MENU_COMPLETE_REDRAW 1
+#define SUBMENU_COMPLETE_REDRAW 2
+#endif /* SETUP_STYLE_EZPORTPLUS */
+
+#endif /* _EZPORTPLUS_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/EzportPlus/style.c b/EDK/MiniSetup/EzportPlus/style.c
new file mode 100644
index 0000000..ca83694
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/style.c
@@ -0,0 +1,625 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/style.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 4 $
+//
+// $Date: 5/02/14 4:05a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/style.c $
+//
+// 4 5/02/14 4:05a Premkumara
+// [TAG] EIP151966
+// [Category] Improvement
+// [Description] Added the implementation for getting the BIOS build
+// year dynamically
+// from TimeStamp.h file and updated the Build year in copyright message
+// in both Setup and POST.
+// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper
+// .c,
+// AmiTSEStr.uni,AMITSE.mak
+//
+// 3 10/18/12 6:07a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:43p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 6/23/11 5:46a Rajashakerg
+// [TAG] EIP63073
+// [Category] New Feature
+// [Description] Source modules in TSE should get the version details
+// from binary in run time not at build time
+// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+// EzportPlus\style.c, Legacy\style.c
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/04/10 11:16p Madhans
+// Navgation help for Mouse Added
+//
+// 4 1/09/10 6:13a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.c
+//
+// Description: Contains style override functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+extern UINT8 gVerticalMainDivider ;
+extern UINT8 gHorizontalHelpDivider ;
+extern UINT16 gStrNavToken;
+
+VOID _StyleAddSpacing( FRAME_DATA *frame );
+VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);
+VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message
+
+#if SETUP_STYLE_EZPORTPLUS
+
+
+
+STYLECOLORS Colors =
+{
+ TEXT_COLOR, //EFI_WHITE, //FGColor
+ PAGE_BGCOLOR, //BGColor
+ NON_FOCUS_COLOR, //EFI_BLUE, //secondary FGcolor
+ PAGE_BGCOLOR, //secondary BGColor
+ CONTROL_FOCUS_COLOR, //EFI_WHITE, //SelFGColor
+ PAGE_BGCOLOR, //SelBGColor
+ CONTROL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelFGColor
+ PAGE_BGCOLOR, //NSelBGColor
+ PAGE_BGCOLOR, //LabelBGColor
+ LABEL_FOCUS_COLOR, //EFI_WHITE, //LabelFGColor
+ LABEL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelLabelFGColor
+ EDIT_BGCOLOR, //EditBGColor
+ EDIT_FGCOLOR, //EFI_WHITE, //EditFGColor
+ POPUP_FGCOLOR, //popupFGColor
+ POPUP_BGCOLOR //popupBGColor
+};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleHandleControlOverflow
+//
+// Description: Function to handle contro overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA *tempcontrol;
+ UINT16 i=0,Height=0;
+ UINT8 BORDER=(frame->FrameData.Border==TRUE)?1:0 ;
+
+ // show scrollbar if neccessary
+ frame->UseScrollbar = FALSE;
+
+ for(i = 0; i < count; i++)
+ {
+ tempcontrol = (CONTROL_DATA*)(frame->ControlList[i]);
+ if( (Height + tempcontrol->Height ) <= frame->FrameData.Height-2*BORDER )
+ {
+ Height = Height + tempcontrol->Height;
+ frame->LastVisibleCtrl = i;
+ }
+ else
+ {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+
+ return Status;
+}
+
+static AMI_IFR_MENU gMenuData = {CONTROL_TYPE_MENU,2};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInitializeFrame
+//
+// Description: Function to initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT8 justify = JUSTIFY_LEFT /*, BORDER=(frame->FrameData.Border==TRUE)?1:0*/ ;
+ STYLECOLORS saveColors ;
+
+ CONTROL_INFO dummy;
+
+ UINT32 FrameType = frame->FrameData.FrameType ;
+
+ saveColors = Colors ;
+
+ //Allows controls to match the Background Color of the Frame
+ Colors.BGColor = frame->FrameData.BGColor ;
+ Colors.SecBGColor = frame->FrameData.BGColor ;
+ Colors.SelBGColor = frame->FrameData.BGColor ;
+ Colors.NSelBGColor = frame->FrameData.BGColor ;
+ Colors.LabelBGColor = frame->FrameData.BGColor ;
+ Colors.PopupBGColor = frame->FrameData.BGColor ;
+
+ switch ( FrameType )
+ {
+ case MAIN_FRAME:
+ if(LABEL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.LabelFGColor = LABEL_FOCUS_COLOR ;
+
+ if(CONTROL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.SelFGColor = CONTROL_FOCUS_COLOR;
+
+ if(LABEL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelLabelFGColor = LABEL_NON_FOCUS_COLOR ;
+
+ if(CONTROL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelFGColor = CONTROL_NON_FOCUS_COLOR ;
+
+ if (frame->PageID == FIRST_PAGE_ID_INDEX)
+ {
+ // Reset frame width
+ frame->FrameData.Width = (UINT8)(gMaxCols - gLabelLeftMargin - 1);
+
+ // Reset clear frame area width
+ gBS->FreePool(frame->BlankLine);
+ frame->BlankLine = EfiLibAllocateZeroPool( sizeof(CHAR16) * (frame->FrameData.Width + 1) );
+ if ( frame->BlankLine != NULL )
+ MemFillUINT16Buffer( frame->BlankLine, frame->FrameData.Width, L' ' );
+ }
+ Status = _FrameAddControls( frame, data );
+ break;
+
+ case SUBTITLE_FRAME:
+ Colors.SecBGColor = SELECTED_MENU_BGCOLOR ;
+ Colors.SecFGColor = SELECTED_MENU_FGCOLOR ;
+ Colors.PopupBGColor = MENU_BGCOLOR ;
+ Colors.PopupFGColor = MENU_FGCOLOR ;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = gHiiHandle;
+ dummy.ControlType = CONTROL_TYPE_MENU;
+ dummy.ControlPtr = (VOID*)&gMenuData;
+ dummy.ControlPageID = data->PageID;
+ dummy.ControlFlags.ControlVisible = TRUE;
+ Status=gFrame.AddControl(frame,&dummy);
+ break;
+
+ case TITLE_FRAME:
+
+
+ case NAV_FRAME:
+
+ justify = JUSTIFY_CENTER;
+ Status = _FrameAddTitle( frame, FrameType, data );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ MEMO_DATA *memo = (MEMO_DATA *)frame->ControlList[0];
+
+ if(FrameType == NAV_FRAME )
+ {
+ memo->ControlData.ControlPtr= (VOID*) UefiCreateSubTitleTemplate(STRING_TOKEN(STR_NAV_STRINGS_5));
+ if ( gMaxCols <= 80 )
+ {
+ gMaxRows=25;
+ memo->ControlData.ControlPtr= (VOID*) UefiCreateSubTitleTemplate(STRING_TOKEN(STR_NAV_STRINGS_6));
+ }
+ }
+ if (FrameType == HELPTITLE_FRAME)
+ justify = JUSTIFY_CENTER; // EIP25281.style +
+ gMemo.SetJustify( memo, justify );
+ }
+
+ break;
+ case HELP_FRAME:
+
+ justify = JUSTIFY_LEFT;
+ case HELPTITLE_FRAME:
+ Status = _FrameAddTitle( frame, FrameType, data );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ MEMO_DATA *memo = (MEMO_DATA *)frame->ControlList[0];
+
+ if(FrameType == NAV_FRAME )
+ {
+ memo->ControlData.ControlPtr= (VOID*) UefiCreateSubTitleTemplate(STRING_TOKEN(STR_NAV_STRINGS_5));
+ if ( gMaxCols <= 80 )
+ {
+ memo->ControlData.ControlPtr= (VOID*) UefiCreateSubTitleTemplate(STRING_TOKEN(STR_NAV_STRINGS_6));
+ }
+ }
+ if (FrameType == HELPTITLE_FRAME)
+ justify = JUSTIFY_CENTER; // EIP25281.style +
+ gMemo.SetJustify( memo, justify );
+ }
+ break;
+
+ case SCROLLBAR_FRAME:
+ // not implemented at this time
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ //Status = StyleInitializeOemFrame( frame, frame->FrameData.FrameType, data ) ;
+ break;
+ }
+
+
+ Colors = saveColors;
+
+ // initialize frame scroll colors
+ frame->FrameData.ScrlFGColor = SCROLLBAR_FGCOLOR ;
+ frame->FrameData.ScrlBGColor = SCROLLBAR_BGCOLOR ;
+ frame->FrameData.ScrlUpFGColor = SCROLLBAR_UPARROW_FGCOLOR ;
+ frame->FrameData.ScrlUpBGColor = SCROLLBAR_UPARROW_BGCOLOR ;
+ frame->FrameData.ScrlDnFGColor = SCROLLBAR_DOWNARROW_FGCOLOR ;
+ frame->FrameData.ScrlDnBGColor = SCROLLBAR_DOWNARROW_BGCOLOR ;
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetNavToken
+//
+// Description: Function to get navigation frame token
+//
+// Input: UINT32 page number
+//
+// Output: UINT16 token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 OverRideStyleGetNavToken( UINT32 page )
+{
+ UINT16 Token=0;
+
+ Token = STRING_TOKEN(STR_NAV_STRINGS_5);
+
+ if ( gMaxCols <= 80 )
+ {
+ Token = STRING_TOKEN(STR_NAV_STRINGS_6);
+ }
+
+ return Token ;// return gStrNavToken;
+}
+
+
+
+static AMI_IFR_LABEL gFailSafeLabel = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), STRING_TOKEN(STR_LOAD_FAILSAFE_HELP) };
+static AMI_IFR_LABEL gOptimalLabel = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), STRING_TOKEN(STR_LOAD_OPTIMAL_HELP) };
+static AMI_IFR_LABEL gSaveExitLabel = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), STRING_TOKEN(STR_SAVE_EXIT_HELP) };
+static AMI_IFR_LABEL gExitLabel = { 0, 0, STRING_TOKEN(STR_EXIT), STRING_TOKEN(STR_EXIT_HELP) };
+static AMI_IFR_LABEL gSaveResetLabel = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), STRING_TOKEN(STR_SAVE_RESET_HELP) };
+static AMI_IFR_LABEL gResetLabel = { 0, 0, STRING_TOKEN(STR_RESET), STRING_TOKEN(STR_RESET_HELP) };
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleAddAdditionalControls
+//
+// Description: Function to add additional controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_DATA **control;
+ UINT32 i;
+
+ if ( frame->PageID != 0 )
+ return Status;
+
+ control = frame->ControlList;
+
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ (*control)->Methods->Destroy( *control, TRUE );
+ }
+
+ // initialize counter of control in frame and set focus to false (at this point the are no controls in the frame)
+ frame->ControlCount =0;
+ frame->NullCount=0;
+ focus=0;
+ controlNumber=0;
+
+ // add controls for boot manager, language, failsafe, optimal, save & exit, exit without saving
+/* Status = _StyleAddControl( frame, CONTROL_TYPE_SUBMENU, &gBootManagerRef, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_SUBMENU, &gLanguageRef, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+*/
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gFailSafeLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gOptimalLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveExitLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gExitLabel, &controlNumber, &focus );
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveResetLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gResetLabel, &controlNumber, &focus );
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleSelectFirstDisplayPage
+//
+// Description: Function to set first page display
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleSelectFirstDisplayPage( VOID )
+{
+ gApp->CurrentPage = 1;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleUpdateVersionString
+//
+// Description: Function to update version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleUpdateVersionString( VOID )
+{
+ CHAR16 *string = NULL, *newString = NULL;
+ UINTN length, TseMajor,TseMinor, TseBuild;
+ UINT16 TseBuildYear=0;
+ UINTN i;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+ GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild);
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseMajor, TseMinor, TseBuild,TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode, newString );
+ }
+
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ //EIP 151966 : Use BIOS build year for copyright message
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode, newString );
+ }
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ static UINTN TempRightAreaWidth = 0;
+
+ if (frame->PageID == FIRST_PAGE_ID_INDEX)
+ {
+
+ switch ( frame->FrameData.FrameType )
+ {
+ // Hidden NAV and HELP frame
+ case HELP_FRAME:
+ case HELPTITLE_FRAME:
+ Status = EFI_UNSUPPORTED;
+ break;
+
+ // Set right area width
+ case MAIN_FRAME:
+ if (TempRightAreaWidth == 0)
+ {
+ // Set right area width
+ TempRightAreaWidth = gControlRightAreaWidth;
+ gControlRightAreaWidth = gMaxCols - gControlLeftMargin - gLabelLeftMargin - 2;
+ }
+ break;
+ }
+
+ return Status;
+ }
+ if (TempRightAreaWidth != 0)
+ {
+ gControlRightAreaWidth = TempRightAreaWidth;
+ TempRightAreaWidth = 0;
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddSpacing
+//
+// Description: Function to add spacing
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleAddSpacing( FRAME_DATA *frame )
+{
+ _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+ if ( frame->ControlCount == 7 )
+ _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddControl
+//
+// Description: Function to add controls
+//
+// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus )
+{
+ EFI_STATUS Status;
+ CONTROL_INFO dummy;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+
+ dummy.ControlType = type;
+ dummy.ControlPtr = (VOID*)data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gFrame.AddControl( frame, &dummy );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ if ( type != CONTROL_TYPE_NULL )
+ {
+ if ( ! *focus )
+ {
+ if ( _FrameSetControlFocus( frame, *controlNumber ) )
+ {
+ frame->CurrentControl = *controlNumber;
+ *focus = TRUE;
+ }
+ }
+
+ (*controlNumber)++;
+ }
+
+ return Status;
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/EzportPlus/style.h b/EDK/MiniSetup/EzportPlus/style.h
new file mode 100644
index 0000000..b4c3cde
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/style.h
@@ -0,0 +1,255 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/style.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 3 $
+//
+// $Date: 10/18/12 6:07a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/style.h $
+//
+// 3 10/18/12 6:07a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:43p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 6/29/11 12:33p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 8 11/18/10 6:38p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 2/26/10 8:53p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 8 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 7 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 5 8/19/09 11:13a Blaines
+// Update OEM Override prototypes
+//
+// 4 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 3 8/17/09 12:23p Presannar
+// Removed References to Tiano.h
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.h
+//
+// Description: Style override prototypes.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+//#define SETUP_STYLE_FULL_SCREEN 1
+//#define SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY 0
+
+#ifndef _STYLE_H_
+#define _STYLE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+//#define SETUP_STYLE_EZPORTPLUS 1
+#include "ezportplus.h"
+#include "page.h"
+#include "frame.h"
+
+INTN GetWindowLevel( UINT16 PageID);
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType) ;
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color);
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+EFI_STATUS OverRideControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+VOID StyleInit( VOID );
+VOID StyleExit( VOID );
+VOID StyleDrawPageBorder( UINT32 page );
+UINT32 StyleGetPageFrames( UINT32 page );
+UINT32 StyleFrameIndexOf( UINT32 frameType );
+VOID StyleBeforeFrame( FRAME_DATA *frame ) ;
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame );
+VOID StyleUpdateFrameStrings(PAGE_DATA *page);
+VOID * StyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo);
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action );
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 StyleGetNavToken( UINT32 page );
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+
+//EFI_STATUS StyleMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, CALLBACK_MENU *data );
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *number, BOOLEAN *focus );
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu );
+BOOLEAN StyleHelpAreaScrollable(VOID);
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+BOOLEAN StyleGetShadowSupport(VOID);
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+
+
+VOID StyleSelectFirstDisplayPage( VOID );
+VOID StyleAddExtraPagesData( VOID );
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color);
+UINTN StyleGetDateFormat(VOID);
+BOOLEAN StyleShowDay(VOID);
+BOOLEAN StyleGetScrollBehavior(VOID) ;
+
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+extern HOTKEY_TEMPLATE gHotKeyInfo[];
+extern HOTCLICK_TEMPLATE gHotClickInfo[];//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+extern UINT32 gHotKeyCount;
+extern UINT32 gHotClickCount;//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//extern UINT8 gLabelLeftMargin ;
+//extern UINT8 gControlLeftMargin ;
+//extern FRAME_INFO _gStyleStandardSubFrames[] ;
+extern UINT32 gSubFrameCount ;
+extern EFI_STATUS FrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy );
+
+
+//Common Overrides
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OverRideStyleGetNavToken( UINT32 page );
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+VOID OverRideStyleSelectFirstDisplayPage( VOID );
+VOID OverRideStyleUpdateVersionString( VOID );
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame );
+
+//Oem Overrides
+UINTN OEMStyleGetDateFormat(VOID);
+EFI_STATUS OEMGetSpecialColor(UINT16 ControlType, UINT8 *Color);
+VOID OEMStyleBeforeFrame( FRAME_DATA *frame );
+VOID OEMStyleUpdateFrameStrings( PAGE_DATA *page );
+EFI_STATUS OEMStyleFrameDrawable( FRAME_DATA *frame );
+VOID OEMStyleInit( VOID );
+VOID OEMStyleExit( VOID );
+VOID OEMStyleDrawPageBorder( UINT32 page );
+VOID OEMDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+VOID OEMDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+VOID *OEMStyleGetFrameInitData( UINT32 page, UINT32 frame );
+EFI_STATUS OEMStyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS OEMStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OEMStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OEMStyleGetNavToken( UINT32 page );
+EFI_STATUS OEMStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+UINT16 OEMStyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 OEMStyleBootManagerPage( SUBMENU_DATA *submenu );
+VOID OEMStyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+VOID OEMStyleSelectFirstDisplayPage( VOID );
+VOID OEMStyleAddExtraPagesData(VOID);
+UINTN OEMStyleGetTextMode( UINTN Rows, UINTN Cols );
+VOID OEMStyleUpdateVersionString( VOID );
+VOID OEMStyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+VOID OEMOverRideComponent(VOID);
+VOID OEMStylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID OEMStyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+
+#endif /* _STYLE_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/EzportPlus/stylecommon.c b/EDK/MiniSetup/EzportPlus/stylecommon.c
new file mode 100644
index 0000000..6f70096
--- /dev/null
+++ b/EDK/MiniSetup/EzportPlus/stylecommon.c
@@ -0,0 +1,1437 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/stylecommon.c $
+//
+// $Author: Rajashakerg $
+//
+// $Revision: 13 $
+//
+// $Date: 3/16/13 2:18a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus/stylecommon.c $
+//
+// 13 3/16/13 2:18a Rajashakerg
+// [TAG] EIP111479
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS dialog box is crashed with special
+// monitor(160,53,1280*1024)
+// [RootCause] DesiredTextMode was not set properly.
+// [Solution] Provided proper mode number while setting text mode.
+// [Files] postmgmtext.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 12 2/10/13 11:56p Rajashakerg
+// [TAG] EIP104521
+// [Category] Improvement
+// [Description] Customer needs AMITSE modification to popup boxes so
+// highlighted choices can be seen via VT100 console redirection
+// [Files] AMITSE.sdl, CommonHelper.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 11 10/18/12 6:07a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:43p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 9/17/12 6:27a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 7 8/29/12 4:28p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 6 4/03/12 3:05a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 5 12/13/11 6:15p Blaines
+// Remove error message when ESC key pressed.
+// Display message when password is cleared.
+//
+// 4 11/28/11 1:29a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 3 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 2 11/09/11 10:06a Premkumara
+// [TAG] EIP74375
+// [Category] Improvement
+// [Description] Control STYLE_HELP_AREA_SCROLLBAR from binary
+// [Files] CommonHelper.c, AMITSE.sdl, StyleHook.h,
+// Legacy\StyleCommon.c, Legacy.sdl,
+// EzportPlus\StyleCommon.c, EzportPlus.sdl, Ezport\StyleCommon.c,
+// Ezport.sdl
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 8 1/06/11 7:54p Blaines
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- Style function should allow OEM to override default
+// implementation.
+//
+// [Rootcause] - Style function does not provide override macro.
+// [Solution] - Add Macro Overrides to the following functions:
+//
+// StyleGetClearScreenColor,
+// StyleGetPageLinkColor,
+// StyleGetScrollBarUpArrowColor ,
+// StyleGetScrollBarDownArrowColor.
+//
+// [Files] - stylecommon.c
+//
+// 7 11/18/10 6:38p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 6 11/09/09 4:44a Mallikarjunanv
+// Eip-30111 : fixed the issue to update the help if
+// STYLE_PAGE_FIRSTITEM_FOCUS token enabled.
+//
+// 5 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 4 8/13/09 1:24p Blaines
+// EIP #24980 Fix to properly display right area text;
+//
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: stylecommon.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+#if SETUP_STYLE_EZPORTPLUS
+
+
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref );
+VOID UpdatePageFocusedItemHelp(PAGE_DATA *page);
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StyleControlColor
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// STYLECOLORS Colors - Color scheme
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors)
+{
+ //Note: Blaines 01/12/09
+ //The goal here is to allow controls to match the BGColor of their frame.
+ //Normally this is handled in StyleInitializeFrame(), before controls are added to the frame.
+ //But this function is called dynamically during runtime (after pages/frames/controls are styled)
+ //Since controls derive their colors from [STYLECOLORS Colors],
+ //we'll temporarly modify it before controls are added to this frame, then restore it.
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_CONTROL_COLOR
+ Status = OEMControlColor(frame, Colors);
+ #else
+ #ifdef STYLE_CONTROL_COLOR
+ Status = OverRideControlColor(frame, Colors);
+ #else
+ //Temporarly Match the BGColor of the frame
+ Colors->BGColor = frame->FrameData.BGColor ;
+ Colors->SecBGColor = frame->FrameData.BGColor ;
+ Colors->SelBGColor = frame->FrameData.BGColor ;
+ Colors->NSelBGColor = frame->FrameData.BGColor ;
+ Colors->LabelBGColor = frame->FrameData.BGColor ;
+ Colors->PopupBGColor = frame->FrameData.BGColor ;
+
+ #endif
+
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetSpecialColor
+//
+// Description: Function to get control special color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_SPECIAL_COLOR
+ Status = OEMGetSpecialColor(ControlType, Color);
+ #else
+
+
+ switch ( ControlType )
+ {
+ case CONTROL_TYPE_MEMO:
+ if (Color !=NULL) *Color = MEMO_COLOR ;
+ break;
+
+ case CONTROL_TYPE_TEXT:
+ if (Color !=NULL) *Color = TEXT_COLOR ;
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;;
+ break;
+ }
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetWindowLevel
+//
+// Description: Function to get window level
+//
+// Input: UINT16 PageID
+//
+// Output: INTN Level
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INTN GetWindowLevel( UINT16 PageID)
+{
+ INTN zIndex = 0 ;
+ UINT16 TempID = PageID ;
+
+ while(gApp->PageList[TempID]->PageData.PageParentID)
+ {
+ TempID = gApp->PageList[TempID]->PageData.PageParentID ;
+ zIndex += 1 ;
+ }
+
+ return zIndex ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetWindowColor
+//
+// Description: Function to get window color
+//
+// Input: UINT8 *Color - Window Color
+// INTN Level - Window Level
+// UINT8 Type - Window Type (0->Setup, 1->PostMenu)
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType)
+{
+ return EFI_SUCCESS ;
+
+}
+
+VOID GetMessageboxColorHook(UINT8 **Color);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetMessageboxColor
+//
+// Description: Function to get control Messagebox color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ if(Color == NULL)
+ return Status ;
+
+
+ switch ( MessageBoxType )
+ {
+ case MSGBOX_EX_CATAGORY_HELP:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_BLUE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_QUERY:
+ *Color = EFI_BACKGROUND_CYAN | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_SUCCESS:
+ *Color = EFI_BACKGROUND_GREEN | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_WARNING:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_ERROR:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_PROGRESS:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_HALT:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_NORMAL:
+
+ default:
+ *Color = EFI_BACKGROUND_BLUE | EFI_WHITE ;
+
+ break;
+ }
+
+ GetMessageboxColorHook(&Color);
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBeforeFrame
+//
+// Description: Function to alter frame styling before frame is drawn
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleBeforeFrame( FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_BEFORE_FRAME
+ OEMStyleBeforeFrame(frame);
+ #else
+ #ifdef STYLE_OVERRIDE_BEFORE_FRAME // from EzportPlus.h
+ OverRideStyleBeforeFrame(frame ); // From ezportplus.c
+ #endif
+
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateFrameStrings
+//
+// Description: Function to update frame strings
+//
+// Input: PAGE_DATA *page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateFrameStrings( PAGE_DATA *page )
+{
+ #ifdef STYLE_OEM_FRAME_TOKEN // SDL
+ OEMStyleUpdateFrameStrings(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_TOKEN // from EzportPlus.h
+ OverRideStyleUpdateFrameStrings(page ); // From ezportplus.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_FRAME_DRAWABLE // SDL
+ Status = OEMStyleFrameDrawable(frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_DRAWABLE // from EzportPlus.h
+ Status = OverRideStyleFrameDrawable(frame ); // From ezportplus.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleInit( VOID )
+{
+ SetDesiredTextMode();
+ OverRideStyleInit(); // From ezportplus.c
+
+#ifdef STYLE_OEM_INIT // SDL
+ OEMStyleInit(); // OEM
+#endif
+ MouseInit(); //EIP-84150
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleExit
+//
+// Description: Function to do style initialization on exit
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleExit( VOID )
+{
+ #ifdef STYLE_OEM_STYLE_EXIT // SDL
+ OEMStyleExit(); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_EXIT // from EzportPlus.h
+ OverRideStyleExit(); // From ezportplus.c
+ #endif
+ #endif
+ MouseDestroy(); //EIP-84150
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawPageBorder
+//
+// Description: Function to draw the page border
+//
+// Input: UINT32 page number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawPageBorder( UINT32 page )
+{
+ #ifdef STYLE_OEM_PAGE_BORDER // SDL
+ OEMStyleDrawPageBorder(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_BORDER // from EzportPlus.h
+ OverRideStyleDrawPageBorder(page); // From ezportplus.c
+ #else
+ ClearScreen( EFI_BACKGROUND_BLUE | EFI_WHITE );
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawScrollBar
+//
+// Description: Function to draw the frame scrollbar
+//
+// Input: FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+ #ifdef STYLE_OEM_SCROLLBAR
+ OEMDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ #ifdef STYLE_OVERRIDE_SCROLLBAR
+ OverRideDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ FrameDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawHelpScrollBar
+//
+// Description: Function to draw the help frame scrollbar
+//
+// Input: MEMO_DATA *memo, UINT16 height
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height)
+{
+ #ifdef STYLE_OEM_DRAW_HELP_SCROLLBAR
+ OEMDrawHelpScrollBar(memo, height);
+ #else
+ #ifdef STYLE_OVERRIDE_HELP_SCROLLBAR
+ OverRideDrawHelpScrollBar(memo, height);
+ #else
+ if(IsHelpAreaScrollBarSupport())
+ MemoDrawScrollBar(memo, height);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page number, UINT32 frame number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *StyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ #ifdef STYLE_OEM_FRAME_INIT_DATA
+ return OEMStyleGetFrameInitData(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_INIT_DATA // from EzportPlus.h
+ return OverRideStyleGetFrameInitData(page, frame); // From ezportplus.c
+ #else
+ return NULL;
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleKey
+//
+// Description: Function to handle frame action keys
+//
+// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_KEY // SDL
+ Status = OEMStyleFrameHandleKey(frame, Key); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_KEY // from EzportPlus.h
+ Status = OverRideStyleFrameHandleKey(frame, Key); // From ezportplus.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleMouse
+//
+// Description: Function to handle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// MOUSE_INFO MouseInfo
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_MOUSE
+ Status = OEMStyleFrameHandleMouse(frame, MouseInfo);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_MOUSE
+ Status = OverRideStyleFrameHandleMouse(frame, MouseInfo);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleTimer
+//
+// Description: Function to handle frame timer action
+//
+// Input: FRAME_DATA *frame, ACTION_DATA *action
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_TIMER
+ Status = OEMStyleFrameHandleTimer(frame, action);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_TIMER
+ Status = OverRideStyleFrameHandleTimer(frame, action);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHandleControlOverflow
+//
+// Description: Function to handle control overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ #ifdef STYLE_OEM_CONTROL_OVERFLOW
+ Status = OEMStyleHandleControlOverflow(frame, control, count );
+ #else
+ #ifdef STYLE_OVERRIDE_CONTROL_OVERFLOW
+ Status = OverRideStyleHandleControlOverflow(frame, control, count );
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInitializeFrame
+//
+// Description: Function to Initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_INITIALIZE_FRAME
+ Status = OEMStyleInitializeFrame(frame, frameType, data );
+ #else
+ #ifdef STYLE_OVERRIDE_INITIALIZE_FRAME
+ Status = OverRideStyleInitializeFrame(frame, frameType, data); //style.c
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetNavToken
+//
+// Description: Function to get navigation token
+//
+// Input: UINT32 page
+//
+// Output: UINT16 token number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleGetNavToken( UINT32 page )
+{
+ UINT16 i=0 ;
+
+ #ifdef STYLE_OEM_NAV_TOKEN
+ i = OEMStyleGetNavToken(page );
+ #else
+ #ifdef STYLE_OVERRIDE_NAV_TOKEN
+ i = OverRideStyleGetNavToken(page);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddAdditionalControls
+//
+// Description: Function to add additinal controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_ADD_CONTROLS
+ Status = OEMStyleAddAdditionalControls(frame, controlNumber, focus );
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_CONTROLS
+ Status = OverRideStyleAddAdditionalControls(frame, controlNumber, focus);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLanguagePage
+//
+// Description: Function to set Language page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_LANGUAGE_PAGE
+ i = OEMStyleLanguagePage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_LANGUAGE_PAGE
+ i = OverRideStyleLanguagePage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+
+
+
+static UINT16 _gBootManagerPageID = 0;
+/*static*/ UINT16 _gHDOrderPageID = 0;
+/*static*/ UINT16 _gCDOrderPageID = 0;
+/*static*/ UINT16 _gFDOrderPageID = 0;
+/*static*/ UINT16 _gNetOrderPageID = 0;
+/*static*/ UINT16 _gBevOrderPageID = 0;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBootManagerPage
+//
+// Description: Function to set boot manager page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_BM_PAGE
+ i = OEMStyleBootManagerPage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_BM_PAGE
+ i = OverRideStyleBootManagerPage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLabelCallback
+//
+// Description: Function to set label callback
+//
+// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie )
+{
+ #ifdef STYLE_OEM_LABEL_CALLBACK
+ OEMStyleLabelCallback(frame, label, cookie );
+ #else
+ #ifdef STYLE_OVERRIDE_LABEL_CALLBACK
+ OverRideStyleLabelCallback(frame, label, cookie );
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSelectFirstDisplayPage
+//
+// Description: Function to set the first display page
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSelectFirstDisplayPage( VOID )
+{
+ #ifdef STYLE_OEM_FIRST_PAGE
+ OEMStyleSelectFirstDisplayPage();
+ #else
+ #ifdef STYLE_OVERRIDE_FIRST_PAGE
+ OverRideStyleSelectFirstDisplayPage();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddExtraPagesData
+//
+// Description: Function to add extra pages
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleAddExtraPagesData(VOID)
+{
+ #ifdef STYLE_OEM_ADD_EXTRA_PAGES
+ OEMStyleAddExtraPagesData();
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES
+ OverRideStyleAddExtraPagesData();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetTextMode
+//
+// Description: Function to get text mode
+//
+// Input: UINTN Rows, UINTN Cols
+//
+// Output: UNNTN mode
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetTextMode( UINTN Rows, UINTN Cols )
+{
+ EFI_STATUS Status;
+ INT32 i;
+ UINTN ModeRows, ModeCols;
+
+ #ifdef STYLE_OEM_GET_TEXT_MODE
+ i = OEMStyleGetTextMode( Rows, Cols );
+ #else
+ #ifdef STYLE_OVERRIDE_GET_TEXT_MODE
+ i = OverRideStyleGetTextMode( Rows, Cols);
+ #else
+ // Default Implementation
+ for ( i = 0; i < gST->ConOut->Mode->MaxMode; i++ )
+ {
+ Status = gST->ConOut->QueryMode( gST->ConOut, i, &ModeCols, &ModeRows );
+ if ( EFI_ERROR( Status ) )
+ continue;
+
+ if ( ( Cols == ModeCols ) && ( Rows == ModeRows ) )
+ return i;
+ }
+
+ // return MaxMode if the mode wasn't found
+ #endif
+ #endif
+
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateVersionString
+//
+// Description: Function to set the version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateVersionString( VOID )
+{
+ #ifdef STYLE_OEM_VERSION_STRING
+ OEMStyleUpdateVersionString();
+ #else
+ #ifdef STYLE_OVERRIDE_VERSION_STRING
+ OverRideStyleUpdateVersionString();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameSetControlPositions
+//
+// Description: Function to set control positioning in a frame
+//
+// Input: FRAME_DATA *frame, UINT32 *pOtherEnd
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd)
+{
+ UINT32 u32Height = 0;
+ UINT32 i;
+ CONTROL_DATA *control;
+ UINT8 u8ChkResult;
+
+ #ifdef STYLE_OEM_FRAME_CONTROL_POSITION
+ OEMStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_CONTROL_POSITION
+ OverRideStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ //Move reference end variable based on action
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ {
+ i = frame->FirstVisibleCtrl;
+ }
+ else
+ {
+ i = frame->LastVisibleCtrl;
+ }
+
+ //Calculate other end variable
+ while( (pOtherEnd == &(frame->LastVisibleCtrl)) ? (i < frame->ControlCount) : TRUE )
+ {
+ control = frame->ControlList[i];
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(control->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ if( (u32Height + control->Height) < frame->FrameData.Height )
+ {
+ *pOtherEnd = i;
+ u32Height += control->Height;
+ }
+ else
+ break; //We cant accommodate
+ }
+ else
+ *pOtherEnd = i; //we can accomodate a suppressed control
+
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ i++;
+ else
+ {
+ // i>=0 in while loop will result in infinite loop
+ // break statement should be introduced inside
+ if (i == 0)
+ break;
+ i--;
+ }
+ }
+
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleOverRideComponent
+//
+// Description: Function to override component or control functionality
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleOverRideComponent(VOID)
+{
+ #ifdef STYLE_OEM_COMPONENT_OVERRIDE // SDL
+ OEMOverRideComponent(); // OEM
+ #else
+ #ifdef STYLE_COMPONENT_OVERRIDE // from EzportPlus.h
+ OverRideComponent(); // From ezportplus.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleControlSubmenu
+//
+// Description: Function to initialize submenu control
+//
+// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref )
+{
+ control->ControlHandle = gHiiHandle;
+ control->ControlType = CONTROL_TYPE_SUBMENU;
+ control->ControlFlags.ControlVisible = TRUE;
+ control->ControlPtr = (VOID*)ref;
+ control->ControlPageID = pageID;
+ control->ControlDestPageID = 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHelpAreaScrollable
+//
+// Description: Function to get Help area scroll support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleHelpAreaScrollable(VOID)
+{
+ if(IsHelpAreaScrollBarSupport())
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetShadowSupport
+//
+// Description: Function to get shadow support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetShadowSupport(VOID)
+{
+ if(STYLE_SHADOW_SUPPORT)
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBehavior
+//
+// Description: Function to get scroll behavior
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetScrollBehavior(VOID)
+{
+ return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetDateFormat
+//
+// Description: Function to get date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetDateFormat(VOID)
+{
+ #ifdef STYLE_OEM_DATE_FOMAT
+ return OEMStyleGetDateFormat();
+ #else
+ return STYLE_DATE_FORMAT;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleShowDay
+//
+// Description: Function to show day in date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleShowDay(VOID)
+{
+ return STYLE_SHOW_DAY ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxRows
+//
+// Description: Function to max number of columns
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_ROWS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxRows(VOID)
+{
+ return STYLE_STD_MAX_ROWS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxCols
+//
+// Description: Function to get max number of rows
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_COLS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxCols(VOID)
+{
+ return STYLE_STD_MAX_COLS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetClearScreenColor
+//
+// Description: Function to Get Clear Screen Color
+//
+// Input: VOID
+//
+// Output: STYLE_CLEAR_SCREEN_COLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetClearScreenColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_CLEAR_SCREEN_COLOR
+ return OverRideStyleGetClearScreenColor();
+ #else
+ return STYLE_CLEAR_SCREEN_COLOR;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageLinkColor
+//
+// Description: Function to PageLink (Submenu) color
+//
+// Input: VOID
+//
+// Output: PAGE_LINK_FGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetPageLinkColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_PAGELINK_COLOR
+ return OverRideStyleGetPageLinkColor();
+ #else
+ return PAGE_LINK_COLOR;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarColor
+//
+// Description: Function to get scrollbar color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_COLOR
+ return OverRideStyleGetScrollBarColor();
+ #else
+ return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarUpArrowColor
+//
+// Description: Function to get scrollbar UpArrow Color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarUpArrowColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_UP_ARROW_COLOR
+ return OverRideStyleGetScrollBarUpArrowColor();
+ #else
+ return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarDownArrowColor
+//
+// Description: Function to get scrollbar downarrow color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarDownArrowColor(VOID)
+{
+ #ifdef STYLE_OVERRIDE_SCROLLBAR_DOWN_ARROW_COLOR
+ return OverRideStyleGetScrollBarDownArrowColor();
+ #else
+ return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StylePageItemFocus
+//
+// Description: This function is called whenever a user navigates to a new page.
+// OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+
+ #ifdef STYLE_OEM_PAGE_ITEM_FOCUS
+ OEMStylePageItemFocus(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_ITEM_FOCUS
+ OverRideStylePageItemFocus(page, frame);
+ #else
+ if(STYLE_PAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ ///Eip:30111 fix - Update the Help based on the Focussed Item
+ UpdatePageFocusedItemHelp(page);
+ }
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSubPageItemFocus
+//
+// Description: This function is called whenever a user returns (or navigates back)
+// from a submenu page causing a complete page redraw. OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_SUBPAGE_ITEM_FOCUS // SDL
+ OEMStyleSubPageItemFocus(page, frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_SUBPAGE_ITEM_FOCUS // from EzportPlus.h
+ OverRideStyleSubPageItemFocus(page, frame); // From ezportplus.c
+ #else
+ if(STYLE_SUBPAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ }
+ #endif
+ #endif
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Legacy/Legacy.cif b/EDK/MiniSetup/Legacy/Legacy.cif
new file mode 100644
index 0000000..7da244b
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/Legacy.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "TSE Sources - Style - Legacy"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\Legacy"
+ RefName = "Legacy"
+[files]
+"Legacy.sdl"
+"Legacy.mak"
+"legacy.c"
+"legacy.h"
+"stylecommon.c"
+"style.h"
+"style.c"
+<endComponent>
diff --git a/EDK/MiniSetup/Legacy/Legacy.mak b/EDK/MiniSetup/Legacy/Legacy.mak
new file mode 100644
index 0000000..04fcd6f
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/Legacy.mak
@@ -0,0 +1,131 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/Legacy.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 2 $
+##
+## $Date: 10/18/12 6:06a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/Legacy.mak $
+#
+# 2 10/18/12 6:06a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 2 10/10/12 12:42p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 1 3/28/11 11:52p Madhans
+# [TAG] EIP54968
+# [Category] Improvement
+# [Description] To Support different style modules in TSE generically
+# [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+# added.
+##
+## 1 9/16/10 6:37p Blaines
+##
+## 1 9/16/10 6:32p Blaines
+##
+## 5 2/19/10 8:15a Mallikarjunanv
+## updated year in copyright message
+##
+## 4 8/17/09 12:23p Presannar
+## Removed Include path to Core directory
+##
+## 3 6/24/09 6:10p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 2:36p Blaines
+## Update coding standard
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:15p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 3 4/28/09 9:39p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 2 4/24/09 9:35p Blaines
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+TSE_STYLE_INCLUDES = \
+ -I $(TSE_STYLE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+ -I $(TSESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\TseStyleLegacy.lib : TseStyleLib
+
+TseStyleLib : $(BUILD_DIR)\Legacy.mak TseStyleLibBinLegacy
+
+$(BUILD_DIR)\Legacy.mak : $(TSE_STYLE_DIR)\$(@B).cif $(TSE_STYLE_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSE_STYLE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+TseStyleLibBinLegacy :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\Legacy.mak all\
+ "MY_INCLUDES=$(TSE_STYLE_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TseStyleLegacy.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy , Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/Legacy/Legacy.sdl b/EDK/MiniSetup/Legacy/Legacy.sdl
new file mode 100644
index 0000000..f83ca13
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/Legacy.sdl
@@ -0,0 +1,445 @@
+TOKEN
+ Name = "TSE_STYLE_LEGACY_SUPPORT"
+ Value = "0"
+ Help = "Main switch to enable Legacy Style in TSE"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_LEGACY"
+ Value = "1"
+ Help = "Condition to support Legacy Style Sources"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_STYLE_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Don't Edit."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_STYLE_FULL_SCREEN"
+ Value = "1"
+ Help = "Condition to support full screen layout"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_ROWS"
+ Value = "31"
+ Help = "Maximum rows in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_FULL_MAX_COLS"
+ Value = "100"
+ Help = "Maximum columns in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_ROWS"
+ Value = "24"
+ Help = "Maximum rows in standard mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_STD_MAX_COLS"
+ Value = "80"
+ Help = "Maximum columns in Standard mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "PAGE_BGCOLOR"
+ Value = "EFI_BACKGROUND_BLUE"
+ Help = "Background Color of the main area (Main, Help, and Navigation Frames) in a page."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_FGCOLOR"
+ Value = "EFI_WHITE"
+ Help = "Foreground and Border Color of main area in a page (Default EFI_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_BGCOLOR"
+ Value = "PAGE_BGCOLOR"
+ Help = "Background Color of the Title bar frame."
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TITLE_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Title bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_BGCOLOR"
+ Value = "PAGE_BGCOLOR"
+ Help = "Background color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MENU_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Menu bar frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELP_FGCOLOR"
+ Value = "EFI_YELLOW"
+ Help = "Foreground Color of the Help Frame (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "HELPTITLE_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Help Title Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NAV_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Navigation Frame"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_BGCOLOR"
+ Value = "PAGE_BGCOLOR"
+ Help = "Background color of the Scroll bar (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Scroll bar (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_BGCOLOR"
+ Value = "PAGE_BGCOLOR"
+ Help = "Background color of the Scroll bar Up-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_UPARROW_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Scroll bar Up-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_BGCOLOR"
+ Value = "PAGE_BGCOLOR"
+ Help = "Background color of the Scroll bar Down-Arrow (Default PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "SCROLLBAR_DOWNARROW_FGCOLOR"
+ Value = "PAGE_FGCOLOR"
+ Help = "Foreground Color of the Scroll bar Down-Arrow (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_BGCOLOR"
+ Value = "EFI_BACKGROUND_RED"
+ Help = "Background Color of Popup Windows, and Message Boxes (Default EFI_BACKGROUND_BLUE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "POPUP_FGCOLOR"
+ Value = "EFI_WHITE"
+ Help = "Foreground Color of Popup Windows, and Message Boxes (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FOCUS_COLOR"
+ Value = "EFI_YELLOW"
+ Help = "Focused label and control text color (Default EFI_WHITE)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_FOCUS_COLOR"
+ Value = "EFI_WHITE"
+ Help = "Focused label text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_FOCUS_COLOR"
+ Value = "EFI_WHITE"
+ Help = "Focused control text color (Default same as FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_FOCUS_BGCOLOR"
+ Value = "EFI_BACKGROUND_RED"
+ Help = "Focused control background color (Default same as PAGE_BGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "NON_FOCUS_COLOR"
+ Value = "EFI_WHITE"
+ Help = "Non Focused label and control text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "LABEL_NON_FOCUS_COLOR"
+ Value = "NON_FOCUS_COLOR"
+ Help = "Non Focused label text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "CONTROL_NON_FOCUS_COLOR"
+ Value = "EFI_YELLOW"
+ Help = "Non Focused control text color (Default same as NON_FOCUS_COLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "PAGE_LINK_COLOR"
+ Value = "NON_FOCUS_COLOR"
+ Help = "Submenu text color (Default PAGE_FGCOLOR)"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_BGCOLOR"
+ Value = "EFI_BACKGROUND_BLUE"
+ Help = "Background color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "EDIT_FGCOLOR"
+ Value = "EFI_WHITE"
+ Help = "Foreground color of focused edit controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "TEXT_COLOR"
+ Value = "EFI_LIGHTGRAY"
+ Help = "Foreround color of text controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "MEMO_COLOR"
+ Value = "TEXT_COLOR"
+ Help = "Foreground color of Memo controls"
+ TokenType = Expression
+ TargetH = Yes
+ Range = "0x0-0x0f"
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_MARGIN"
+ Value = "30"
+ Help = "Control column left margin in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "FULL_STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding in full screen mode"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_MARGIN"
+ Value = "24"
+ Help = "Control column left margin"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_CONTROL_LEFT_PAD"
+ Value = "2"
+ Help = "Control left padding"
+ TokenType = Integer
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "FULL_STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in full screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_LABEL_LEFT_MARGIN"
+ Value = "2"
+ Help = "Label column left margin in normal screen mode"
+ TokenType = Expression
+ TargetH = Yes
+
+End
+
+TOKEN
+ Name = "STYLE_SCROLLBAR_ROLLOVER"
+ Value = "1"
+ Help = "Support rollover when the scroll limit has been reached"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_PAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating to a new page. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SUBPAGE_FIRSTITEM_FOCUS"
+ Value = "0"
+ Help = "Reset focus to the first item when navigating back from submenu. (Default 0 => Set focus to previously selected item)"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_HOTKEY_FAILSAFE"
+ Value = "SCAN_F6"
+ Help = " Hot Key to load fail safe values"
+ TokenType = Expression
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SHADOW_SUPPORT"
+ Value = "1"
+ Help = " To enable/disable shadow support"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "STYLE_SPACEKEY_INCREMENT"
+ Value = "1"
+ Help = " < need to add help >"
+ TokenType = Integer
+ TargetH = Yes
+End
+
+PATH
+ Name = "TSE_STYLE_DIR"
+End
+
+MODULE
+ Help = "Includes Legacy.mak to Project"
+ File = "Legacy.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\TSEStyleLegacy.lib"
+ Parent = "$(TSE_STYLE_DIR)\TSEStyleLegacy$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
+
diff --git a/EDK/MiniSetup/Legacy/legacy.c b/EDK/MiniSetup/Legacy/legacy.c
new file mode 100644
index 0000000..6c34aa1
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/legacy.c
@@ -0,0 +1,1622 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/legacy.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 10 $
+//
+// $Date: 8/28/14 11:19a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/legacy.c $
+//
+// 10 8/28/14 11:19a Premkumara
+// [TAG] EIP174031
+// [Category] Improvement
+// [Description] Removed TODO comments and added proper comments in those
+// places
+// [Files] commonoem.c, commonhelper.c, special.c, submenu.c,
+// minisetupext.c, uefi21wapper.c and legacy.c
+//
+// 9 2/11/13 6:01a Premkumara
+// [TAG] EIP112628
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] (JP000E)SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY does not work on
+// 4.6.2_TSE_2_15_1234
+// [RootCause] The Exit FormID value will change if any form is
+// generated before Exit page
+// [Solution] Handled Exit FormID from Binary and handling Exit FormID
+// from binary
+// [Files] Ezport.c, Ezport.sdl, Legacy.c, Legacy.sdl, EzportPlus.c,
+// EzportPlus.sdl
+//
+// 8 10/18/12 6:06a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 12/01/11 5:40a Rajashakerg
+// [TAG] EIP74963
+// [Category] Improvement
+// [Description] MAX_MSGBOX_WIDTH cannot be overridden
+// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
+// MessageBox.c, MessageBox.h, FormBrowser.c
+//
+// 6 11/21/11 10:39a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 5 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 4 6/29/11 12:43p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 3 6/23/11 3:49p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 2 3/29/11 12:13a Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 3/28/11 11:51p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 9/16/10 6:37p Blaines
+//
+// 1 9/16/10 6:32p Blaines
+//
+// 12 6/14/10 7:07p Madhans
+// to avoid warnings
+//
+// 11 3/26/10 6:52p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 10 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/15/10 10:12p Madhans
+// To avoid warnings
+//
+// 8 1/09/10 6:11a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 6 8/13/09 1:22p Blaines
+// Support BgColor for MAIN_FRAME, NAV_FRAME, and HELP_FRAME
+//
+// 5 8/04/09 6:57p Blaines
+// Add Support for Exit Page SDL tokens
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 9 5/05/09 3:20p Blaines
+//
+// 8 5/04/09 6:52p Blaines
+// Support customizable Help and Nav frame text Foreground color
+//
+// 7 5/01/09 9:25p Blaines
+//
+// 6 4/30/09 9:54p Blaines
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: alternate1.c
+//
+// Description: Main file for alternate1 style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+#include "Legacy.h"
+
+extern STYLECOLORS Colors ;
+extern AMI_IFR_MENU gMenuData ;
+
+extern UINTN gLabelLeftMargin ;
+extern UINTN gControlLeftMargin ;
+extern UINTN gControlLeftPad ;
+extern UINTN gControlRightAreaWidth ;
+static CALLBACK_SUBMENU gMenuCallbackData = { { CALLBACK_TYPE_MENU, sizeof(CALLBACK_MENU) }, 0 };
+static CALLBACK_SUBMENU gSubmenuCallbackData = { { CALLBACK_TYPE_SUBMENU, sizeof(CALLBACK_SUBMENU) }, 0 };
+static CALLBACK_VARIABLE gVariableCallbackData = { { CALLBACK_TYPE_VARIABLE, sizeof(CALLBACK_VARIABLE) }, 0, 0, 0, NULL };
+static CALLBACK_PASSWORD gPasswordCallbackData = { { CALLBACK_TYPE_PASSWORD, sizeof(CALLBACK_PASSWORD) }, 0, 0, 0, NULL, TRUE };
+
+VOID _FrameSubmenuCallback( FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie );
+VOID _FrameMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, VOID *cookie );
+
+BOOLEAN gotoExitOnEscKey(EFI_GUID *exitFormGuid, UINT16 *pageClass, UINT16 *pageSubclass, UINT16 *pageFormID);//EIP-112628 GotoExitPageOnEscKey
+
+#if SETUP_STYLE_LEGACY
+
+static FRAME_INFO _gStyleLegacyMainFrames[] =
+{
+// {FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, 80, 1, 0, 0, TITLE_FGCOLOR, TITLE_BGCOLOR }, // Title
+ { MAIN_FRAME, TRUE, FALSE, 0, 78, 15, 2, 1, PAGE_FGCOLOR, PAGE_BGCOLOR }, // Main
+ { HELP_FRAME, TRUE, FALSE, 0, 76, 1, 21, 1, HELP_FGCOLOR, PAGE_BGCOLOR }, // Help text
+ { NAV_FRAME, TRUE, FALSE, 0, 76, 2, 18, 2, NAV_FGCOLOR, PAGE_BGCOLOR } // Navigation
+};
+
+static FRAME_INFO _gStyleLegacySubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+
+ { TITLE_FRAME, TRUE, FALSE, 0, 80, 1, 0, 0, TITLE_FGCOLOR, TITLE_BGCOLOR}, // Title
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, 80, 1, 1, 0, MENU_FGCOLOR, MENU_BGCOLOR }, // Subtitle
+ { MAIN_FRAME, TRUE, FALSE, 0, 50, 19, 3, 1, PAGE_FGCOLOR, PAGE_BGCOLOR }, // Main
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, 23, 1, 3, 56, HELPTITLE_FGCOLOR, PAGE_BGCOLOR }, // Help title
+ { HELP_FRAME, TRUE, FALSE, 0, 23, 16, 5, 56, HELP_FGCOLOR, PAGE_BGCOLOR }, // Help text
+ { NAV_FRAME, TRUE, FALSE, 0, 80, 2, 22, 0, NAV_FGCOLOR, PAGE_BGCOLOR }, // Navigation
+};
+
+#if SETUP_STYLE_FULL_SCREEN
+static FRAME_INFO _gStyleLegacyFullMainFrames[] =
+{
+// {FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, 100, 1, 0, 0, TITLE_FGCOLOR, TITLE_BGCOLOR }, // Title
+ { MAIN_FRAME, TRUE, FALSE, 0, 98, 19, 2, 1, PAGE_FGCOLOR, PAGE_BGCOLOR }, // Main
+ { HELP_FRAME, TRUE, FALSE, 0, 95, 1, 28, 1, HELP_FGCOLOR, PAGE_BGCOLOR }, // Help text
+ { NAV_FRAME, TRUE, FALSE, 0, 95, 2, 25, 2, NAV_FGCOLOR, PAGE_BGCOLOR } // Navigation
+};
+
+static FRAME_INFO _gStyleLegacyFullSubFrames[] =
+{
+// { FrameType Drawable Border, BorderType, Width, Height, Top, Left, FGColor, BGColor }
+ { TITLE_FRAME, TRUE, FALSE, 0, 100, 1, 0, 0, TITLE_FGCOLOR, TITLE_BGCOLOR}, // Title
+ { SUBTITLE_FRAME, TRUE, FALSE, 0, 100, 1, 1, 0, MENU_FGCOLOR, MENU_BGCOLOR }, // Subtitle
+ { MAIN_FRAME, TRUE, FALSE, 0, 63, 25, 3, 1, PAGE_FGCOLOR, PAGE_BGCOLOR }, // Main
+ { HELPTITLE_FRAME, TRUE, FALSE, 0, 29, 1, 3, 70, HELPTITLE_FGCOLOR, PAGE_BGCOLOR }, // Help title
+ { HELP_FRAME, TRUE, FALSE, 0, 29, 21, 5, 70, HELP_FGCOLOR, PAGE_BGCOLOR }, // Help text
+ { NAV_FRAME, TRUE, FALSE, 0, 100, 2, 29, 0, NAV_FGCOLOR, PAGE_BGCOLOR }, // Navigation
+};
+#endif
+
+FRAME_INFO *_gStyleMainFrames = _gStyleLegacyMainFrames ;
+FRAME_INFO *_gStyleSubFrames = _gStyleLegacySubFrames ;
+
+INT16 gTabIndex = 0 ;
+
+AMITSE_CONTROL_MAP gTseControlMap[] =
+{
+// ControlType ControlMethods CallbackSuppored CallbackFunction CallbackContext
+ { CONTROL_TYPE_MENU, (CONTROL_METHODS*)&gMenu, TRUE, (VOID*)(UINTN)&_FrameMenuCallback, (VOID*)(UINTN)&gMenuCallbackData},
+ { CONTROL_TYPE_SUBMENU, (CONTROL_METHODS*)&gSubMenu,TRUE, (VOID*)(UINTN)&_FrameSubmenuCallback, (VOID*) &gSubmenuCallbackData},
+ { CONTROL_TYPE_LABEL, (CONTROL_METHODS*)&gLabel, TRUE, (VOID*)(UINTN)&StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_TEXT, (CONTROL_METHODS*)&gText, FALSE,(VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUP_STRING, (CONTROL_METHODS*)&gPopupString, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_DATE, (CONTROL_METHODS*)&gDate, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_TIME, (CONTROL_METHODS*)&gTime, FALSE, (VOID*)NULL, (VOID*) NULL},
+ { CONTROL_TYPE_POPUPSEL, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ // Checkbox is just popup sel
+ { CONTROL_TYPE_CHECKBOX, (CONTROL_METHODS*)&gPopupSel, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_MEMO, (CONTROL_METHODS*)&gMemo, FALSE, (VOID*)NULL, (VOID*)NULL},
+ { CONTROL_TYPE_NUMERIC, (CONTROL_METHODS*)&gNumeric, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_ORDERED_LIST, (CONTROL_METHODS*)&gOrdListBox, TRUE, (VOID*)(UINTN)&_FrameVariableCallback, (VOID*) &gVariableCallbackData},
+ { CONTROL_TYPE_PASSWORD, (CONTROL_METHODS*)&gPopupPassword, TRUE, (VOID*)(UINTN)&_FramePasswordCallback, (VOID*)&gPasswordCallbackData},
+ { CONTROL_TYPE_ACTION, (CONTROL_METHODS*)&gUefiAction, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},
+ { CONTROL_TYPE_RESET, (CONTROL_METHODS*)&gResetButton, TRUE, (VOID*)(UINTN) &StyleLabelCallback, (VOID*) NULL},//EIP:56413 Updated the Reset Button Control information
+ // CONTROL_TYPE_NULL need to be last member
+ { CONTROL_TYPE_NULL, (CONTROL_METHODS*)NULL, FALSE, (VOID*)NULL, (VOID*) NULL}
+};
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacyPageHandleAction
+//
+// Description: function to handle the page actions
+//
+// Input: PAGE_DATA *page, ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacyPageHandleAction( PAGE_DATA *page, ACTION_DATA *action )
+{
+ UINT32 i;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+//EIP# 58925
+ UINT32 stackIndex = 0xFFFFFFFF;
+ UINT16 parentPgID = 0;
+//EIP# 58925
+ // On printScreen HotKey, Just return Unsupported and It will handed by Application Hotkey Handler.
+ if( ( action->Input.Type == ACTION_TYPE_KEY ) &&
+ (TsePrintScreenEventSupport(action->Input.Data.AmiKey.Key.ScanCode) ) )
+ {
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+
+ }
+/*
+#if TSE_PRN_SCRN_EVENT_SUPPORT
+ if (( action->Input.Type == ACTION_TYPE_KEY ) && ( action->Input.Data.AmiKey.Key.ScanCode == TSE_PRN_SCRN_KEY_SCAN ))
+ return EFI_UNSUPPORTED;
+#endif
+*/
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ if ( gFrame.HandleAction( page->FrameList[StyleFrameIndexOf(i)], action ) == EFI_SUCCESS )
+ {
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+
+ for ( i = 0; i < page->HotKeyCount; i++ )
+ {
+ if ( gHotKey.HandleAction( page->HotKeyList[i], action ) == EFI_SUCCESS )
+ {
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+
+ if(
+ (( action->Input.Type == ACTION_TYPE_KEY ) && (ControlActionAbort == MapControlKeysHook(action->Input.Data.AmiKey)))
+ || ((action->Input.Type == ACTION_TYPE_MOUSE) && (ControlActionAbort == MapControlMouseActionHook(&(action->Input.Data.MouseInfo))) /*(TSEMOUSE_RIGHT_CLICK == action->Input.Data.MouseInfo.ButtonStatus)*/)
+ )
+ {
+
+ //Commented for Legacy Style 07/07/10
+ //if ( page->PageData.PageParentID == 0 )
+ // return EFI_UNSUPPORTED;
+
+
+ if ( page->PageData.PageID != page->PageData.PageParentID )
+ {
+ // check for inconsistency here too.
+ if (CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[page->PageData.PageID]))!= TRUE )
+ {
+ // reset focus to first control
+ FRAME_DATA *frame = page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+//EIP# 58925
+ if(IsLinkHistorySupport())
+ {
+ // tell application that we need to change pages
+ Status = GetParentFormID((UINT16)gApp->CurrentPage, &parentPgID, &stackIndex); //Gets the parent page of the current page
+ if(Status != EFI_SUCCESS)
+ gApp->CurrentPage = page->PageData.PageParentID;
+ else
+ gApp->CurrentPage = parentPgID; //Else set the current page to the parent page
+ }
+ else
+ {
+ gApp->CurrentPage = page->PageData.PageParentID;
+ }
+//EIP# 58925
+ gApp->CompleteRedraw = TRUE;
+ gApp->OnRedraw = SUBMENU_COMPLETE_REDRAW;
+ }
+
+ Status = EFI_SUCCESS;
+ }
+ }
+DONE:
+//EIP# 58925
+ if(IsLinkHistorySupport())
+ {
+ if(Status == EFI_SUCCESS){
+ SetParentFormID(page->PageData.PageID, (UINT16)gApp->CurrentPage);
+ }
+ }
+//EIP# 58925
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: LegacyFrameAddControl
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// CONTROL_INFO *controlData - Control date to be added
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacyFrameAddControl( FRAME_DATA *frame, CONTROL_INFO *controlData )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA **control;
+ POSITION_INFO *pos;
+ UINT16 count = (UINT16)frame->ControlCount;
+ UINT16 i;
+ BOOLEAN IsValidControl = FALSE;
+ PAGE_INFO *pageInfo=NULL;
+
+ gActiveFrame = frame;
+
+
+ if(controlData->ControlType == CONTROL_TYPE_SUBMENU)
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlData->ControlDestPageID]);
+
+ if(pageInfo->PageHandle == NULL)
+ {
+ frame->NullCount--;
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
+
+ control = MemReallocateZeroPool( frame->ControlList, count * sizeof(CONTROL_INFO *), (count + 1) * sizeof(CONTROL_INFO *) );
+
+ if ( control == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ frame->ControlList = control;
+ control = &frame->ControlList[ count ];
+
+ for(i=0;gTseControlMap[i].ControlType != CONTROL_TYPE_NULL;i++)
+ {
+ if(gTseControlMap[i].ControlType == controlData->ControlType)
+ {
+ Status = gTseControlMap[i].ControlMethods->Create(control);
+ if ( ! EFI_ERROR(Status) )
+ {
+ if(gTseControlMap[i].CallbackSuppored )
+ gTseControlMap[i].ControlMethods->SetCallback(*control, frame,
+ (OBJECT_CALLBACK)(UINTN)gTseControlMap[i].CallbackFunction,
+ (VOID*)gTseControlMap[i].CallbackContext);
+ }
+ IsValidControl = TRUE;
+ }
+ }
+
+ if(!IsValidControl)
+ {
+ if(controlData->ControlType == CONTROL_TYPE_NULL )
+ frame->NullCount++;
+ return Status;
+ }
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ Status = (*control)->Methods->Initialize( *control, controlData );
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ UINT16 height = 1;
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ Status = (*control)->Methods->GetControlHeight( *control, (VOID*)frame,&height);
+ height = height ? height:1;
+ }
+
+ if(frame->FrameData.FrameType == SUBTITLE_FRAME)
+ (*control)->Methods->SetDimensions( *control, frame->FrameData.Width , height );
+ else
+ (*control)->Methods->SetDimensions( *control, frame->FrameData.Width - (UINT8)gLabelLeftMargin - 2 , height );
+
+ (*control)->ParentFrameType = frame->FrameData.FrameType ;
+
+ frame->ControlCount++;
+ count++;
+
+ (*control)->Methods->SetPosition( *control, frame->FrameData.Left + (UINT8)gLabelLeftMargin, frame->FrameData.Top + count -1 );
+
+
+ if( EFI_ERROR( StyleHandleControlOverflow( frame, frame->ControlList[ count -1 ], (UINT16)frame->ControlCount )) )
+ {
+ frame->LastVisibleCtrl = frame->ControlCount-1;
+ }
+
+ // set position information
+ pos = MemReallocateZeroPool( frame->OrigPosition, (count-1) * sizeof(POSITION_INFO), (count ) * sizeof(POSITION_INFO) );
+ if ( pos != NULL )
+ {
+ pos[count-1].Left = (*control)->Left;
+ pos[count-1].Top = (*control)->Top;
+ frame->OrigPosition = pos;
+ }
+
+ MemFreePointer( (VOID **)&frame->CurrPosition );
+ frame->CurrPosition = EfiLibAllocateZeroPool( count * sizeof(POSITION_INFO) );
+
+ }
+
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: LegacyFrameDrawScrollBar
+//
+// Description: Draws the scrollbar controls for the frame..
+//
+// Input: FRAME_DATA *frame - Pointer to the current frame
+// UINT32 FirstLine - FirstLine of the scrollbar
+// UINT32 LastLine - LastLine
+// UINT32 modVal - modVal
+// UINT32 sizeOfBar - Size of the Scrollbar
+// UINT32 numOfBlocks - Number of blocks
+// BOOLEAN bEraseScrollBar - flag to erase the scrollbar
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a next page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacyFrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+ UINT32 i, j ; //,FirstLine=0,LastLine=0, count,visibleControlCount = 0, modVal=0, sizeOfBar, numOfBlocks = 0;
+ CHAR16 ArrUp[2]={{GEOMETRICSHAPE_UP_TRIANGLE},{0x0000}},ArrDown[2]={{GEOMETRICSHAPE_DOWN_TRIANGLE},{0x0000}},ScrlSel[2]={{BLOCKELEMENT_FULL_BLOCK/*L'N'*/},{0x0000}},ScrlNSel[2]={{BLOCKELEMENT_LIGHT_SHADE/*L'S'*/},{0x0000}};
+
+
+ // draw scrollbar if necessary
+ if ( frame->BlankLine != NULL )
+ {
+ j = frame->FrameData.Top;
+ for ( i = 1; i < frame->FrameData.Height; i++, j++ )
+ {
+ // use this loop to draw the scrollbar
+ if(frame->UseScrollbar)
+ {
+ if(i==1)
+ DrawStringWithAttribute( frame->FrameData.Left + frame->FrameData.Width+2 , j, ArrUp,
+ StyleGetScrollBarUpArrowColor() );
+ else if(i==(UINT16)(frame->FrameData.Height - 1))
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width+2, j, ArrDown,
+ StyleGetScrollBarDownArrowColor() );
+ else
+ {
+ if( (j > FirstLine) && (j < LastLine) && ((sizeOfBar + modVal) != 0))
+ {
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width+2, j, ScrlSel,
+ StyleGetScrollBarColor() );
+ sizeOfBar--;
+ }
+ else
+ {
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width+2, j, ScrlNSel,
+ StyleGetScrollBarColor() );
+ }
+ }
+ }
+ else if (bEraseScrollBar == TRUE)
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width+2, j, L" ",
+ StyleGetScrollBarColor() );
+
+ }
+ bEraseScrollBar = FALSE;
+ }
+
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: LegacyFrameDraw
+//
+// Description: Draws the controls for the given frame
+//
+// Input: FRAME_DATA *frame - Frame information to draw controls
+//
+// Output: EFI_STATUS - EFI_SUCCESS if successful, else EFI_ERROR
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacyFrameDraw( FRAME_DATA *frame )
+{
+ CONTROL_DATA **control;
+ UINT32 i, j,FirstLine=0,LastLine=0, count,visibleControlCount = 0, modVal=0, sizeOfBar, numOfBlocks = 0;
+ UINT16 CurrHeight, ControlTop;
+ UINT8 u8ChkResult;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ BOOLEAN bCurrNotFocused = FALSE,bEraseScrollBar=FALSE;
+
+ if((frame->FrameData.FrameType != MAIN_FRAME) || ( frame->PageID != 0 ))
+ {
+ Status = FrameDraw(frame );
+ return Status;
+ }
+
+
+ if(StyleFrameDrawable(frame))
+ return EFI_UNSUPPORTED;
+
+ if ( frame->ControlCount == 0 )
+ return EFI_UNSUPPORTED;
+
+ //If there is an active control send draw only for that
+ if(frame->CurrentControl == FRAME_NONE_FOCUSED)
+ {
+ control = NULL;
+ bCurrNotFocused = TRUE; // Non is focused
+ }
+ else
+ control = &frame->ControlList[frame->CurrentControl];
+
+ if ( control != NULL )
+ {
+ //If a control is active only draw that
+ if( (*control)->ControlActive == TRUE )
+ {
+ (*control)->Methods->Draw( *control );
+ return EFI_SUCCESS;
+ }
+
+ if(COND_NONE == CheckControlCondition( &((*control)->ControlData) ))
+ {
+ // Set the Focus to current control
+ if((*control)->Methods->SetFocus(*control,TRUE) != EFI_SUCCESS)
+ {
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ bCurrNotFocused = TRUE; // Non is focused
+ }
+ }
+ }
+
+ //There is no active control we have to draw all in the view.
+
+ // First, clear the frame.
+ if ( frame->BlankLine != NULL )
+ {
+ j = frame->FrameData.Top;
+ for ( i = 1; i < frame->FrameData.Height; i++, j++ )
+ {
+ DrawStringWithAttribute( frame->FrameData.Left, j, frame->BlankLine, frame->FrameData.FGColor | frame->FrameData.BGColor );
+ }
+ }
+
+ //Set position for all controls begining from FirstVisibleControl.
+ //In the process calculate the correct LastVisibleControl.
+ control = frame->ControlList;
+
+ control = control+ frame->FirstVisibleCtrl;
+ CurrHeight = frame->FrameData.Top;
+ frame->LastVisibleCtrl = frame->FirstVisibleCtrl;
+
+ for ( i = frame->FirstVisibleCtrl; i < frame->ControlCount; i++, control++ )
+ {
+ ControlTop = CurrHeight;
+
+ //Check conditional
+ u8ChkResult = CheckControlCondition( &((*control)->ControlData) );
+
+ if(u8ChkResult == COND_NONE || u8ChkResult == COND_GRAYOUT)
+ {
+ //Control is drawn increament height
+ CurrHeight = CurrHeight + (*control)->Height;
+ if((frame->ControlCount > 1) && ((frame->FrameData.Top +frame->FrameData.Height) < CurrHeight+1 ))
+ {
+ break;
+ }
+ else
+ {
+ frame->LastVisibleCtrl = i;
+ }
+ }
+
+ if(u8ChkResult != COND_NONE)
+ {
+ //Control grayed out or suppressed
+ if(frame->CurrentControl == i)
+ {
+ //Current control cant be focused
+ (*control)->Methods->SetFocus(*control,FALSE);
+ bCurrNotFocused = TRUE;
+ }
+ }
+
+ //(*control)->Methods->SetPosition( *control, (*control)->Left, ControlTop);
+ }
+
+ //Current control can not be focused? Find another one to focus.
+ if(bCurrNotFocused)
+ {
+ control = frame->ControlList;
+ control = control+ frame->FirstVisibleCtrl;
+
+ for ( i = frame->FirstVisibleCtrl; i <= frame->LastVisibleCtrl; i++, control++ )
+ {
+ if ( (*control)->Methods->SetFocus( *control, TRUE ) == EFI_SUCCESS )
+ {
+ frame->CurrentControl = i;
+ break;
+ }
+ }
+
+ if(i > frame->LastVisibleCtrl)
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ }
+
+ //Draw controls in the set positions
+ control = frame->ControlList;
+ control = control+ frame->FirstVisibleCtrl;
+ for ( i = frame->FirstVisibleCtrl; i <= frame->LastVisibleCtrl; i++, control++ )
+ {
+ (*control)->Methods->Draw( *control );
+ }
+
+ CurrHeight = frame->FrameData.Top;
+ for (count = 0; count < frame->ControlCount; count++)
+ {
+ u8ChkResult = COND_NONE;
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[count]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ visibleControlCount++ ;
+ CurrHeight = CurrHeight + frame->ControlList[count]->Height;
+ }
+ }
+
+ // if already have a Scroll bar and due some changes (some controls may bedisabled) we don't need a scroll bar in this frame.
+ if((frame->UseScrollbar) && ((frame->FrameData.Top + frame->FrameData.Height) >= CurrHeight+1))
+ {
+ bEraseScrollBar = TRUE;
+ frame->UseScrollbar = FALSE;
+ }
+
+ // if we don't have a Scroll bar and due some changes (some controls may be enabled) we need a scroll bar in this frame.
+ if((frame->ControlCount > 1) && (!frame->UseScrollbar) && ((frame->FrameData.Top + frame->FrameData.Height) < CurrHeight+1))
+ {
+ frame->UseScrollbar = TRUE;
+ }
+
+ if(visibleControlCount==0)visibleControlCount=1;
+ FirstLine = (frame->FrameData.Height* frame->FirstVisibleCtrl/visibleControlCount )+ frame->FrameData.Top;
+ LastLine = (frame->FrameData.Height* frame->LastVisibleCtrl/visibleControlCount )+ frame->FrameData.Top;
+
+ numOfBlocks = frame->FrameData.Height - 2;
+ sizeOfBar = ((frame->FrameData.Height -1) * numOfBlocks) / visibleControlCount;
+ modVal = ((((frame->FrameData.Height -1) * numOfBlocks) % visibleControlCount)* numOfBlocks) > (numOfBlocks/2) ? 1 : 0;
+
+ // draw scrollbar if necessary
+ StyleDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+
+ FlushLines( frame->FrameData.Top, frame->FrameData.Top + frame->FrameData.Height );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacyMsgBoxInitialize
+//
+// Description: Function to Initialize Message Box, which uses the Popup functions.
+//
+// Input: MSGBOX_DATA *msgbox, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacyMsgBoxInitialize( MSGBOX_DATA *msgbox, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Length =0 ;
+ VOID *buff;
+ CONTROL_INFO MemoCtrlData;
+ MEMO_DATA *memo;
+ UINT8 Color ;
+
+ UINT16 titleToken;
+ VOID* TextHandle =((AMI_IFR_MSGBOX*)(((CONTROL_INFO*)data)->ControlPtr))->TextHandle;
+
+ // initializes the heigth and width
+ Status = gPopup.Initialize( msgbox, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ Status = StyleGetMessageboxColor(msgbox->MsgBoxCatagory, &Color) ;
+
+ if ( EFI_ERROR( Status ) == EFI_SUCCESS)
+ {
+ msgbox->FGColor = Color & 0x0f ;
+ msgbox->BGColor = Color & 0xf0 ;
+ }else
+ // add extra initialization here...
+ SetControlColorsHook( NULL, NULL, NULL , NULL, NULL , NULL, NULL ,
+ NULL , NULL, NULL,NULL ,
+ NULL,NULL ,&(msgbox->FGColor),&(msgbox->BGColor) );
+
+ msgbox->FGColor = Colors.PopupFGColor ;
+ msgbox->BGColor = Colors.PopupBGColor ;
+
+ msgbox->Container = NULL;
+
+ msgbox->Border =TRUE;
+
+ titleToken = (UINT16)(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Title);
+ if ( titleToken != 0 ) {
+ msgbox->Title = HiiGetString(msgbox->ControlData.ControlHandle, titleToken);
+ if ( msgbox->Title == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Length = (UINT16)HiiMyGetMultiLineStringLength(msgbox->ControlData.ControlHandle, (UINT16)(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Text));
+
+ if ( ( msgbox->Title != NULL) && ( Length < (TestPrintLength( msgbox->Title )/ (NG_SIZE)) ) )
+ Length = (UINT16)(TestPrintLength( msgbox->Title ) / (NG_SIZE));
+
+ msgbox->Width = (UINT16)(Length + 4);
+
+ if(( msgbox->MsgBoxType == MSGBOX_TYPE_NULL ) && ( msgbox->Legend != NULL ))
+ {
+ if ( msgbox->Width < (UINT16)(TestPrintLength( msgbox->Legend )/ (NG_SIZE)) )
+ msgbox->Width = (UINT16)(TestPrintLength( msgbox->Legend ) / (NG_SIZE)) + 8;
+ }
+//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
+ if ( msgbox->Width > GetMsgboxWidth())
+ msgbox->Width = GetMsgboxWidth();
+
+ msgbox->ScreenBuf = SaveScreen();
+
+ // initialize memo control
+ memo = msgbox->Memo;
+
+ buff = UefiCreateSubTitleTemplate(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Text );
+
+
+ MemSet( &MemoCtrlData, sizeof(MemoCtrlData), 0 );
+ MemoCtrlData.ControlPtr = (VOID*)buff;
+ MemoCtrlData.ControlHandle = TextHandle;
+ MemoCtrlData.ControlFlags.ControlVisible = TRUE;
+ gMemo.Initialize(memo,(VOID *)&(MemoCtrlData));
+ memo->Width = msgbox->Width - 2;
+ gMemo.GetControlHeight( memo, NULL, &msgbox->Height );
+ msgbox->Height += 4;
+
+ gMemo.SetAttributes(memo,msgbox->FGColor ,msgbox->BGColor);
+ gMemo.SetDimensions( memo, msgbox->Width-2 , msgbox->Height-3 );
+ gMemo.SetJustify( memo, JUSTIFY_CENTER );
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacySubMenuInitialize
+//
+// Description: this function uses the initialize function of control
+// and initializes the submenu.
+//
+// Input: SUBMENU_DATA *submenu, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacySubMenuInitialize( SUBMENU_DATA *submenu, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ //PAGE_INFO *pageInfo=NULL;
+ //PAGE_DATA *Page ;
+
+ Status = gControl.Initialize( submenu, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+
+
+ // add extra initialization here...
+ submenu->ControlData.ControlHelp = UefiGetHelpField((VOID *)submenu->ControlData.ControlPtr); //refPtr->Help;
+ submenu->ControlFocus = FALSE;
+ submenu->LabelMargin = (UINT8)gControlLeftMargin;
+
+ // initialize default colors
+ SetControlColorsHook(&(submenu->BGColor), &(submenu->FGColor),
+ NULL, NULL,
+ &(submenu->SelBGColor), &(submenu->SelFGColor),
+ &(submenu->NSelBGColor), &(submenu->NSelFGColor),
+ NULL,&(submenu->LabelFGColor) ,
+ &(submenu->NSelLabelFGColor),
+ NULL,NULL,
+ NULL,NULL );
+
+
+ //if((submenu->SubMenuType==0) && (submenu->ControlData.ControlPageID!=0))
+ // submenu->SelFGColor = FOCUS_COLOR ;
+
+
+
+/*
+
+ if(submenu->SubMenuType==0)
+ {
+ Page = gApp->PageList[gApp->CurrentPage];
+
+ if(Page->PageData.PageTitle == STRING_TOKEN(STR_EXIT))
+ {
+ submenu->SelFGColor = FOCUS_COLOR ;
+
+ }
+ }
+*/
+
+/*
+ if((submenu->SubMenuType==0) && (submenu->ControlData.ControlPageID!=0))
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[submenu->ControlData.ControlPageID]);
+
+ if(pageInfo->PageTitle == STRING_TOKEN(STR_EXIT))
+ {
+ submenu->SelFGColor = FOCUS_COLOR ;
+
+ }
+ }
+*/
+
+
+
+#if SETUP_STYLE_LEGACY
+ submenu->SubMenuType = (UINT8)(submenu->ControlData.ControlPageID != 0);
+#endif
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacySubMenuDraw
+//
+// Description: function to draw a sub-menu.
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LegacySubMenuDraw( SUBMENU_DATA *submenu )
+{
+ CHAR16 *text=NULL,*text1;
+ UINTN length;
+ EFI_STATUS Status = EFI_SUCCESS;
+// UINT8 ColorSubMenu = submenu->NSelFGColor;
+ UINT8 ColorLabel = (submenu->ControlFocus) ? submenu->LabelFGColor : submenu->NSelLabelFGColor ;
+ UINT32 PageNum ;
+
+ PageNum = gApp->CurrentPage ;
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( submenu->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &submenu->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text1 = HiiGetString( submenu->ControlData.ControlHandle, UefiGetPromptField((VOID *)(submenu->ControlData.ControlPtr)));
+ if ( text1 == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ // XXX check to see if text1 is not NULL
+ length = (3 + (TestPrintLength( text1 ) / (NG_SIZE))) * sizeof(CHAR16);
+ text = EfiLibAllocateZeroPool( length );
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ if((submenu->SubMenuType == 0)&&( PageNum == 0 ))
+ SPrint( text, length, L"%s", text1 );
+ else if(submenu->SubMenuType == 2)
+ SPrint( text, length, L"%s", text1 );
+ else
+ SPrint( text, length, L"%c %s", GEOMETRICSHAPE_RIGHT_TRIANGLE, text1 );
+
+
+ //SPrint( text, length, L"%c %s", (submenu->SubMenuType == 2)?L' ':GEOMETRICSHAPE_RIGHT_TRIANGLE, text1 );
+
+ //SPrint( text, length, ((submenu->SubMenuType == 0)&&( PageNum == 0 ))?L"%c%s":L"%c %s", ((submenu->SubMenuType == 2)||( PageNum == 0 ))?L' ':GEOMETRICSHAPE_RIGHT_TRIANGLE, text1 );
+
+ //SPrint( text, length, ((submenu->SubMenuType == 0)&&( PageNum == 0 ))?L"%c%s":L"%c %s", ((submenu->SubMenuType == 2)||( PageNum == 0 ))?L' ':GEOMETRICSHAPE_RIGHT_TRIANGLE, text1 );
+ MemFreePointer( (VOID **)&text1 );
+
+ if ( submenu->SubMenuType != 1 )
+ {
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(submenu->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( submenu->Left , submenu->Top,
+ (UINTN)(submenu->Width-2),(UINTN) submenu->Height,
+ &text[2], (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | ColorLabel /*submenu->SelFGColor*/ :
+ submenu->NSelBGColor | ColorLabel /*ColorSubMenu*/ ) );
+ if(submenu->SubMenuType != 2)
+ {
+ text[2]=0;
+ DrawStringWithAttribute( submenu->Left - 2, submenu->Top, (CHAR16*)text,
+ (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | ColorLabel /*submenu->SelFGColor*/ :
+ submenu->NSelBGColor | ColorLabel /*ColorSubMenu*/ ) );
+ }
+ }
+ else
+ {
+
+ if(submenu->SubMenuType==0 && !submenu->ControlFocus && ColorLabel != CONTROL_GRAYOUT_COLOR)
+ ColorLabel = StyleGetPageLinkColor();
+
+
+ if( PageNum == 0 )
+ {
+ if((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)((submenu->Width/2)-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)((submenu->Width/2)-5))],L"...");
+
+ }else{
+
+
+ if((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(submenu->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-5))],L"...");
+
+ }
+
+ DrawStringWithAttribute( submenu->Left, submenu->Top, (CHAR16*)text,
+ (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | submenu->SelFGColor :
+ submenu->NSelBGColor | ColorLabel ) );
+ }
+ }
+ else
+ {
+ if((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(submenu->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-5))],L"...");
+
+ text1 = HiiGetString( gHiiHandle, STRING_TOKEN(STR_SUBMENU_OPTION) );
+ if ( text1 != NULL )
+ {
+ DrawStringWithAttribute( submenu->Left - 2, submenu->Top, (CHAR16*)text,
+ EFI_BACKGROUND_BLUE | EFI_WHITE );
+ MemFreePointer( (VOID **)&text );
+
+ length = (3 + (TestPrintLength( text1 ) / (NG_SIZE))) * sizeof(CHAR16);
+ text = EfiLibAllocatePool( length );
+ if ( text != NULL )
+ {
+ SPrint( text, length, L"[%s]", text1 );
+
+ if ((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(submenu->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-5))],L"...");
+
+ DrawStringWithAttribute( submenu->Left + submenu->LabelMargin , submenu->Top, text,
+ (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | submenu->SelFGColor :
+ submenu->NSelBGColor | submenu->NSelFGColor ) );
+
+ //if ( submenu->ControlFocus )
+ // DrawStringWithAttribute( submenu->Left + submenu->LabelMargin + 1,
+ // submenu->Top, text1, (UINT8)(submenu->SelBGColor | submenu->SelFGColor) );
+ }
+ }
+ }
+
+ MemFreePointer( (VOID **)&text );
+ MemFreePointer( (VOID **)&text1 );
+
+ FlushLines( submenu->Top, submenu->Top );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleInit( VOID )
+{
+ VOID *data = NULL ;
+ data = (UINT8 *)gApplicationData + gPages->PageList[0] ;
+
+ if( ((PAGE_INFO*)data)->PageHandle == 0)
+ ((PAGE_INFO*)data)->PageHandle = gHiiHandle ;
+
+
+ gLabelLeftMargin = STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = STYLE_CONTROL_LEFT_PAD ;
+
+
+ #if SETUP_STYLE_FULL_SCREEN
+ if ( gMaxCols == STYLE_FULL_MAX_COLS )
+ {
+ _gStyleMainFrames = _gStyleLegacyFullMainFrames ;
+ _gStyleSubFrames = _gStyleLegacyFullSubFrames ;
+
+ gLabelLeftMargin = FULL_STYLE_LABEL_LEFT_MARGIN ;
+ gControlLeftMargin = FULL_STYLE_CONTROL_LEFT_MARGIN ;
+ gControlLeftPad = FULL_STYLE_CONTROL_LEFT_PAD ;
+
+ }
+ #endif
+
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameIndexOf
+//
+// Description: Function to get frame index
+//
+// Input: UINT32 frameType
+//
+// Output: UINT32 index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleFrameIndexOf( UINT32 frameType )
+{
+ UINT32 FrameCount ;
+ UINT32 i, PageNum ;
+
+ PageNum = gApp->CurrentPage ;
+
+
+ if ( PageNum == 0 )
+ FrameCount = sizeof(_gStyleLegacyMainFrames) / sizeof(FRAME_INFO);
+ else
+ FrameCount = sizeof(_gStyleLegacySubFrames) / sizeof(FRAME_INFO);
+
+
+ for ( i = 0; i < FrameCount; i++ )
+ {
+ if ( PageNum == 0 )
+ {
+ if( _gStyleMainFrames[i].FrameType == frameType )
+ {
+ return i ;
+ break ;
+ }
+ }else{
+
+ if( _gStyleSubFrames[i].FrameType == frameType )
+ {
+ return i ;
+ break ;
+ }
+
+ }
+
+ }
+
+ return i ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageFrames
+//
+// Description: Function to number of frames
+//
+// Input: UINT32 page
+//
+// Output: UINT32 number of frames
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleGetPageFrames( UINT32 page )
+{
+ if ( page == 0 )
+ return sizeof(_gStyleLegacyMainFrames) / sizeof(FRAME_INFO);
+
+ return sizeof(_gStyleLegacySubFrames) / sizeof(FRAME_INFO);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleDrawPageBorder
+//
+// Description: Function to draw page border
+//
+// Input: UINT32 page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleDrawPageBorder( UINT32 page )
+{
+ CHAR16 *line;
+ UINT8 lineNumber;
+
+ UINT8 start, end, col;
+
+ PAGE_DATA *Page=NULL ;
+ FRAME_DATA *fHelptitle=NULL, *fHelp=NULL ;
+
+ Page = gApp->PageList[page];
+
+ fHelptitle = Page->FrameList[StyleFrameIndexOf(HELPTITLE_FRAME)];
+ fHelp = Page->FrameList[StyleFrameIndexOf(HELP_FRAME)];
+
+
+
+
+
+ line = EfiLibAllocateZeroPool( (gMaxCols + 1) * sizeof(CHAR16) );
+ if ( line == NULL )
+ return;
+
+ ClearScreenWithoutFlush( EFI_BACKGROUND_BLUE | EFI_WHITE );
+
+ MemFillUINT16Buffer( &line[1], gMaxCols - 2, L' ' );
+ line[0] = line[gMaxCols - 1] = BOXDRAW_DOUBLE_VERTICAL;
+
+ if ( page == 0 )
+ {
+ start = 2;
+ end = (UINT8)(gMaxRows - 2);
+ }
+ else
+ {
+ start = 3;
+ end = (UINT8)(gMaxRows - 3);
+ }
+
+ for ( lineNumber = start; lineNumber < end; lineNumber++ )
+ DrawString( 0, lineNumber, line );
+
+ MemFillUINT16Buffer( &line[1], gMaxCols - 2, BOXDRAW_DOUBLE_HORIZONTAL );
+ // top line
+ line[0] = BOXDRAW_DOUBLE_DOWN_RIGHT;
+ line[gMaxCols - 1] = BOXDRAW_DOUBLE_DOWN_LEFT;
+ DrawString( 0, start - 1, line );
+
+ // bottom line
+ line[0] = BOXDRAW_DOUBLE_UP_RIGHT;
+ line[gMaxCols - 1] = BOXDRAW_DOUBLE_UP_LEFT;
+ DrawString( 0, end, line );
+
+ MemFillUINT16Buffer( &line[1], gMaxCols - 2, BOXDRAW_HORIZONTAL );
+
+ if ( page == 0 )
+ {
+ line[0] = BOXDRAW_VERTICAL_DOUBLE_RIGHT;
+ line[gMaxCols - 1] = BOXDRAW_VERTICAL_DOUBLE_LEFT;
+ DrawString( 0, gMaxRows - 4, line );
+ line[gMaxCols / 2] = BOXDRAW_UP_HORIZONTAL;
+ DrawString( 0, gMaxRows - 7, line );
+
+ line[0] = BOXDRAW_DOWN_HORIZONTAL_DOUBLE;
+ line[1] = L'\0';
+ DrawString( gMaxCols / 2, 1, line );
+ }
+ else
+ {
+ // dividing line
+ line[0] = BOXDRAW_VERTICAL_RIGHT;
+ line[fHelp->FrameData.Width + 2] = BOXDRAW_VERTICAL_DOUBLE_LEFT;
+ line[fHelp->FrameData.Width + 3] = L'\0';
+ DrawString( fHelp->FrameData.Left - 2, 4, line );
+ line[0] = BOXDRAW_DOWN_HORIZONTAL_DOUBLE;
+ line[1] = L'\0';
+ DrawString( fHelp->FrameData.Left - 2, 2, line );
+ line[0] = BOXDRAW_UP_HORIZONTAL_DOUBLE;
+ DrawString( fHelp->FrameData.Left - 2, gMaxRows - 3, line );
+
+ }
+
+ // center divider
+ line[0] = BOXDRAW_VERTICAL;
+
+ if ( page == 0 )
+ {
+ start = 2;
+ end = (UINT8)(gMaxRows - 7);
+ col = (UINT8)(gMaxCols / 2);
+ }
+ else
+ {
+ start = 5;
+ end = (UINT8)(gMaxRows - 3);
+ col = fHelp->FrameData.Left - 2;
+ }
+ for ( lineNumber = start; lineNumber < end; lineNumber++ )
+ DrawString( col, lineNumber, line );
+
+ if ( page != 0 )
+ DrawString( fHelp->FrameData.Left - 2, 3, line );
+
+ FlushLines( 0, gMaxRows - 1 );
+
+ gBS->FreePool( line );
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page, UINT32 frame
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ if ( page == 0 )
+ return &_gStyleMainFrames[frame];
+
+ return &_gStyleSubFrames[frame];
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideComponent
+//
+// Description: Function to override component or control functionality
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideComponent(VOID)
+{
+ gMsgBox.Initialize = LegacyMsgBoxInitialize ;
+ gSubMenu.Initialize = LegacySubMenuInitialize ;
+ gSubMenu.Draw = LegacySubMenuDraw ;
+ gFrame.Draw = LegacyFrameDraw ; // Override framedraw
+ gFrame.AddControl = LegacyFrameAddControl ; // Override FrameAddControl
+ gPage.HandleAction = LegacyPageHandleAction ; // Override FrameAddControl
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameAddTitle
+//
+// Description: Function to add frame title
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy )
+{
+ return EFI_UNSUPPORTED;
+}
+
+#endif /* SETUP_STYLE_LEGACY */
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleEscKey
+//
+// Description: Function to handle ESC Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandleEscKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ UINT16 pageClass = 0, pageSubclass = 0, pageFormID = 0;
+ EFI_GUID ExitPageGuid;
+
+
+ if(FormBrowserHandleValid())
+ app->Quit = TRUE;
+
+ else if ( gotoExitOnEscKey (&ExitPageGuid, &pageClass, &pageSubclass, &pageFormID) )//EIP-112628 GotoExitPageOnEscKey
+ {
+ UINT32 i=0;
+ PAGE_INFO *pageInfo;
+
+ for ( i = 0; i < gPages->PageCount; i++ )
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+ if (
+ ( EfiCompareGuid(&ExitPageGuid,&(gPageIdInfo[pageInfo->PageIdIndex].PageGuid)) ) &&
+ ( pageClass == gPageIdInfo[pageInfo->PageIdIndex].PageClass ) &&
+ ( pageSubclass == gPageIdInfo[pageInfo->PageIdIndex].PageSubClass ) &&
+ ( pageFormID == pageInfo->PageFormID )
+ )
+ {
+ gApp->CurrentPage = i; // Page found go to exit page
+ gApp->CompleteRedraw = TRUE;
+ gApp->Fixed = FALSE;
+ break;
+ }
+ }
+ if(i >= gPages->PageCount) //Page not found exit application
+ app->Quit = ExitApplication();
+ }
+
+ else
+ app->Quit = ExitApplication();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleSaveExitKey
+//
+// Description: Function to handle Save and Exit Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ app->Quit = SaveAndExit();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandlePrevValuesKey
+//
+// Description: Function to handle Load Previous value Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ //if ( app->CurrentPage != 0 )
+ LoadPreviousValues( TRUE );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleFailsafeKey
+//
+// Description: Function to handle Load Failsafe values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ //if ( app->CurrentPage != 0 )
+ LoadFailsafeDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleOptimalKey
+//
+// Description: Function to handle Load Optimal values Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ //if ( app->CurrentPage != 0 )
+ LoadOptimalDefaults();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandleHelpKey
+//
+// Description: Function to handle Help Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ //if ( app->CurrentPage != 0 )
+ ShowHelpMessageBox();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HandlePrnScrnKey
+//
+// Description: Function to handle print screen Hotkey action
+//
+// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHandlePrnScrnKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ TseHotkeyPrintScreenSupport();
+}
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//EIP:47086 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacyMainFrameHandlewithMouse
+//
+// Description: Function to handle Main Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyMainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+ if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK)
+ app->Quit = ExitApplication();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacyHelpFrameHandlewithMouse
+//
+// Description: Function to handle Help Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyHelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LegacyNavFrameHandlewithMouse
+//
+// Description: Function to handle Navigation Frame with Mouse
+//
+// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LegacyNavFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie )
+{
+
+}
+//EIP:47086 END
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Legacy/legacy.h b/EDK/MiniSetup/Legacy/legacy.h
new file mode 100644
index 0000000..b615152
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/legacy.h
@@ -0,0 +1,160 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/legacy.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:06a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/legacy.h $
+//
+// 2 10/18/12 6:06a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 3/28/11 11:52p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 9/16/10 6:37p Blaines
+//
+// 1 9/16/10 6:32p Blaines
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:12a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/24/09 5:15p Blaines
+// Fix issue setting title and helptitle background color after clear
+// screen
+//
+// 3 8/18/09 6:34p Blaines
+// Support additional date styles
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:14p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: alternate1.h
+//
+// Description: Main header file for alternate1 style module.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#ifndef _LEGACY_H_
+#define _LEGACY_H_
+
+#if SETUP_STYLE_LEGACY
+
+VOID OverRideStyleInit( VOID );
+VOID OverRideStyleDrawPageBorder( UINT32 page );
+VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+#if SETUP_STYLE_FULL_SCREEN
+ #define STYLE_MAX_COLS STYLE_FULL_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_FULL_MAX_ROWS
+#else
+ #define STYLE_MAX_COLS STYLE_STD_MAX_COLS
+ #define STYLE_MAX_ROWS STYLE_STD_MAX_ROWS
+#endif
+
+#define MAIN_FULL_Y 3
+#define MAIN_Y 3
+#define MAIN_FULL_W 98
+#define MAIN_W 78
+
+
+//#define STYLE_CONTROL_LEFT_PAD ((UINT8)4)
+//#define STYLE_CONTROL_RIGHT_AREA_WIDTH 28
+//#define STYLE_CONTROL_LEFT_MARGIN ((UINT8)28)
+#define STYLE_CLEAR_SCREEN_COLOR (EFI_BACKGROUND_BLUE | EFI_WHITE)
+//#define FULL_STYLE_CONTROL_LEFT_MARGIN 37
+//#define FULL_STYLE_CONTROL_LEFT_PAD 2
+#define FULL_STYLE_CONTROL_RIGHT_AREA_WIDTH ((UINT8)FULL_VERTICAL_MAIN_DIVIDER - FULL_STYLE_CONTROL_LEFT_MARGIN - FULL_STYLE_CONTROL_LEFT_PAD)
+#define FULL_STYLE_LABEL_LEFT_MARGIN 2
+#define STYLE_LABEL_LEFT_MARGIN 2
+#define EFI_BACKGROUND_WHITE (EFI_WHITE << 4)
+//#define STYLE_CLEAR_SCREEN_COLOR (HELPTITLE_BGCOLOR | EFI_WHITE)
+
+
+// Style Overrides...
+#define STYLE_OVERRIDE_INIT
+#define STYLE_OVERRIDE_PAGE_BORDER
+#define STYLE_OVERRIDE_FRAME_INIT_DATA
+#define STYLE_OVERRIDE_CONTROL_OVERFLOW
+#define STYLE_OVERRIDE_INITIALIZE_FRAME
+#define STYLE_OVERRIDE_INITIALIZE_OEM_FRAME
+#define STYLE_OVERRIDE_NAV_TOKEN
+#define STYLE_OVERRIDE_ADD_CONTROLS
+#define STYLE_OVERRIDE_FIRST_PAGE
+#define STYLE_OVERRIDE_VERSION_STRING
+#define STYLE_OVERRIDE_FRAME_DRAWABLE
+#define STYLE_COMPONENT_OVERRIDE
+#define STYLE_OVERRIDE_HANDLE_KEY
+#define STYLE_OVERRIDE_LABEL_CALLBACK
+#define MENU_COMPLETE_REDRAW 1
+#define SUBMENU_COMPLETE_REDRAW 2
+#define STYLE_OVERRIDE_SCROLLBAR
+#endif /* SETUP_STYLE_LEGACY */
+
+#endif /* _LEGACY_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Legacy/style.c b/EDK/MiniSetup/Legacy/style.c
new file mode 100644
index 0000000..293e836
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/style.c
@@ -0,0 +1,725 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/style.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 5 $
+//
+// $Date: 5/02/14 4:04a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/style.c $
+//
+// 5 5/02/14 4:04a Premkumara
+// [TAG] EIP151966
+// [Category] Improvement
+// [Description] Added the implementation for getting the BIOS build
+// year dynamically
+// from TimeStamp.h file and updated the Build year in copyright message
+// in both Setup and POST.
+// [Files] style.c,style.c,style.c,notify.c,minisetupext.c,CommonHelper
+// .c,
+// AmiTSEStr.uni,AMITSE.mak
+//
+// 4 10/18/12 6:06a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 6/23/11 3:48p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 2 6/23/11 5:44a Rajashakerg
+// [TAG] EIP63073
+// [Category] New Feature
+// [Description] Source modules in TSE should get the version details
+// from binary in run time not at build time
+// [Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+// EzportPlus\style.c, Legacy\style.c
+//
+// 1 3/28/11 11:52p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 9/16/10 6:37p Blaines
+//
+// 1 9/16/10 6:32p Blaines
+//
+// 6 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/04/10 11:16p Madhans
+// Navgation help for Mouse Added
+//
+// 4 1/09/10 6:13a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.c
+//
+// Description: Contains style override functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+extern UINT8 gVerticalMainDivider ;
+extern UINT8 gHorizontalHelpDivider ;
+extern UINT16 gStrNavToken;
+
+VOID _StyleAddSpacing( FRAME_DATA *frame );
+VOID GetTseBuildVersion(UINTN *TseMajor, UINTN *TseMinor, UINTN *TseBuild);
+VOID GetTseBuildYear(UINT16 *TseBuildYear);//EIP 151966 : Use BIOS build year for copyright message
+
+#if SETUP_STYLE_LEGACY
+
+
+
+STYLECOLORS Colors =
+{
+ TEXT_COLOR, //EFI_WHITE, //FGColor
+ PAGE_BGCOLOR, //BGColor
+ NON_FOCUS_COLOR, //EFI_BLUE, //secondary FGcolor
+ PAGE_BGCOLOR, //secondary BGColor
+ CONTROL_FOCUS_COLOR, //EFI_WHITE, //SelFGColor
+ PAGE_BGCOLOR, //SelBGColor
+ CONTROL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelFGColor
+ PAGE_BGCOLOR, //NSelBGColor
+ PAGE_BGCOLOR, //LabelBGColor
+ LABEL_FOCUS_COLOR, //EFI_WHITE, //LabelFGColor
+ LABEL_NON_FOCUS_COLOR, //EFI_BLUE, //NSelLabelFGColor
+ EDIT_BGCOLOR, //EditBGColor
+ EDIT_FGCOLOR, //EFI_WHITE, //EditFGColor
+ POPUP_FGCOLOR, //popupFGColor
+ POPUP_BGCOLOR //popupBGColor
+};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleLabelCallback
+//
+// Description: Function to set label callback
+//
+// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie )
+{
+ UINT16 token = 0 ;
+
+ if ( frame->PageID != 0 )
+ return ;
+
+ token = ((AMI_IFR_LABEL *)label->ControlData.ControlPtr)->Text;
+
+ switch(token)
+ {
+ case STRING_TOKEN(STR_LOAD_FAILSAFE):
+ LoadFailsafeDefaults();
+ break;
+
+ case STRING_TOKEN(STR_LOAD_OPTIMAL):
+ _SubMenuAmiCallback( RESTORE_DEFAULTS_VALUE );
+ //LoadOptimalDefaults();
+ break;
+
+ case STRING_TOKEN(STR_SAVE_EXIT):
+ _SubMenuAmiCallback( SAVE_AND_EXIT_VALUE );
+ //HandleSaveAndExit();
+ break;
+
+ case STRING_TOKEN(STR_EXIT):
+ _SubMenuAmiCallback( DISCARD_AND_EXIT_VALUE );
+ //HandleExitApplication();
+ break;
+
+ case STRING_TOKEN(STR_SAVE_RESET):
+ _SubMenuAmiCallback( SAVE_AND_RESET_VALUE );
+ //HandleSaveAndReset();
+ break;
+
+ case STRING_TOKEN(STR_RESET):
+ _SubMenuAmiCallback( DISCARD_AND_RESET_VALUE );
+ //HandleResetSys();
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleFrameHandleKey
+//
+// Description: Function to handle action key
+//
+// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ INT32 prevControl = frame->CurrentControl;
+
+ INT32 thisControl = prevControl;
+ INT32 lastControl = frame->ControlCount - 1;
+ CONTROL_DATA *control;
+
+ if ( frame->PageID != 0 )
+ return Status;
+
+ if ( frame->ControlCount == 0 )
+ return Status;
+
+ switch ( Key.ScanCode )
+ {
+ case SCAN_LEFT:
+ if ( thisControl - gTabIndex >= 0 )
+ thisControl -= gTabIndex;
+ else if ( thisControl + gTabIndex <= lastControl )
+ thisControl += gTabIndex;
+ break;
+ case SCAN_RIGHT:
+ if ( thisControl + gTabIndex <= lastControl )
+ thisControl += gTabIndex;
+ else if ( thisControl - gTabIndex >= 0 )
+ thisControl -= gTabIndex;
+ break;
+ default:
+ return Status;
+ }
+
+ control = frame->ControlList[prevControl];
+ control->Methods->SetFocus( control, FALSE );
+
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ Status = EFI_SUCCESS;
+ frame->CurrentControl = thisControl;
+ }
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleHandleControlOverflow
+//
+// Description: Function to handle contro overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 top, left;
+ CONTROL_DATA *tempcontrol;
+ UINT16 i=0,Height=0;
+
+ if ( frame->PageID != 0 )
+ {
+ // Add scrollbar if not present linking it with the frame 0 thorugh a callback
+ for(i = 0; i < count; i++)
+ {
+ tempcontrol = (CONTROL_DATA*)(frame->ControlList[i]);
+ if( (Height + tempcontrol->Height ) < frame->FrameData.Height )
+ {
+ Height = Height + tempcontrol->Height;
+ frame->LastVisibleCtrl = i;
+ }
+ else
+ {
+// frame->UseScrollbar = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ return Status;
+ }
+
+ frame->UseScrollbar = FALSE;
+ Status = EFI_SUCCESS;
+
+ //_StyleAddSpacing( frame );
+
+ //Double Space layout
+ count = count*2 ;// + (UINT16)(frame->NullCount) ;
+ left = frame->FrameData.Left + (UINT8)gLabelLeftMargin;
+ top = frame->FrameData.Top + (UINT8)(count - 2) ;
+
+ if(count > frame->FrameData.Height)
+ {
+ left = frame->FrameData.Left + (UINT8)gControlLeftPad + (UINT8)(gMaxCols / 2);
+ top = frame->FrameData.Top + (UINT8)(count - 1 - frame->FrameData.Height) ;
+ }else
+ gTabIndex = frame->ControlCount ;
+
+ control->Methods->SetPosition( control, left, top );
+//EIP# 59971 Start
+ count = frame->ControlCount ;
+
+ //If the double spaced layout exceeds the left + right columns,
+ //reflow the layout using single spacing.
+ if((count*2) > (frame->FrameData.Height*2))
+ {
+ CONTROL_DATA **Control=NULL;
+ Control = frame->ControlList;
+ top = frame->FrameData.Top ;
+ left = frame->FrameData.Left + (UINT8)gLabelLeftMargin;
+
+ //Update the column tab index
+ gTabIndex = (UINT32)((frame->ControlCount)/2) ;
+
+ //Update using single space layout
+ for(i = 0; i< frame->ControlCount; i++, Control++ )
+ {
+ (*Control)->Methods->SetPosition( *Control, left, top );
+ frame->LastVisibleCtrl = i ;
+ top++;
+
+ if( top > (frame->FrameData.Top + gTabIndex))
+ {
+ left = frame->FrameData.Left + (UINT8)gControlLeftPad +(UINT8)(gMaxCols / 2);
+ top = frame->FrameData.Top ;
+ }
+ }
+ }
+//EIP# 59971 End
+ frame->LastVisibleCtrl = frame->ControlCount -1;
+ Status = EFI_SUCCESS;
+ return Status;
+
+}
+
+static AMI_IFR_MENU gMenuData = {CONTROL_TYPE_MENU,2};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleInitializeFrame
+//
+// Description: Function to initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT8 justify = JUSTIFY_LEFT /*, BORDER=(frame->FrameData.Border==TRUE)?1:0*/ ;
+ STYLECOLORS saveColors ;
+
+ //CONTROL_INFO dummy;
+
+ UINT32 FrameType = frame->FrameData.FrameType ;
+
+ saveColors = Colors ;
+
+ //Allows controls to match the Background Color of the Frame
+ Colors.BGColor = frame->FrameData.BGColor ;
+ Colors.SecBGColor = frame->FrameData.BGColor ;
+ Colors.SelBGColor = frame->FrameData.BGColor ;
+ Colors.NSelBGColor = frame->FrameData.BGColor ;
+ Colors.LabelBGColor = frame->FrameData.BGColor ;
+ //Colors.EditBGColor = frame->FrameData.BGColor ;
+ Colors.PopupBGColor = frame->FrameData.BGColor ;
+
+ switch ( FrameType )
+ {
+ case MAIN_FRAME:
+
+ if ( frame->PageID == 0 )
+ {
+ Colors.SelFGColor = EFI_WHITE ;
+ Colors.SelBGColor = EFI_BACKGROUND_RED ;
+ Colors.NSelFGColor = EFI_YELLOW ;
+ Colors.NSelLabelFGColor = EFI_YELLOW ;
+ Colors.LabelFGColor = EFI_WHITE ;
+ Colors.PopupFGColor = POPUP_FGCOLOR ;
+ Colors.PopupBGColor = POPUP_BGCOLOR ;
+ }else{
+
+ if(LABEL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.LabelFGColor = LABEL_FOCUS_COLOR ;
+
+ if(CONTROL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors.SelFGColor = CONTROL_FOCUS_COLOR;
+
+ if(LABEL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelLabelFGColor = LABEL_NON_FOCUS_COLOR ;
+
+ if(CONTROL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors.NSelFGColor = CONTROL_NON_FOCUS_COLOR ;
+
+ Colors.SelBGColor = CONTROL_FOCUS_BGCOLOR ;
+ Colors.EditBGColor = CONTROL_FOCUS_BGCOLOR ;
+ }
+
+ Status = _FrameAddControls( frame, data );
+ break;
+
+ case TITLE_FRAME:
+ case SUBTITLE_FRAME:
+ case HELPTITLE_FRAME:
+ justify = JUSTIFY_CENTER;
+ case HELP_FRAME:
+ if ( frame->PageID == 0 )
+ justify = JUSTIFY_CENTER;
+ case NAV_FRAME:
+ if ( FrameType == NAV_FRAME)
+ justify = JUSTIFY_CENTER;
+ Status = _FrameAddTitle( frame, FrameType, data );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ MEMO_DATA *memo = (MEMO_DATA *)frame->ControlList[0];
+ gMemo.SetJustify( memo, justify );
+ }
+ break;
+ case SCROLLBAR_FRAME:
+ // not implemented at this time
+ Status = EFI_SUCCESS;
+ break;
+ default:
+ break;
+ }
+
+ // initialize frame scroll colors
+ frame->FrameData.ScrlFGColor = (frame->FrameData.FGColor == 0) ? Colors.SecFGColor:frame->FrameData.FGColor ;
+ frame->FrameData.ScrlBGColor = (frame->FrameData.BGColor == 0) ? Colors.SecBGColor : frame->FrameData.BGColor ;
+
+
+
+ Colors = saveColors;
+
+ // initialize frame scroll colors
+ frame->FrameData.ScrlFGColor = SCROLLBAR_FGCOLOR ;
+ frame->FrameData.ScrlBGColor = SCROLLBAR_BGCOLOR ;
+ frame->FrameData.ScrlUpFGColor = SCROLLBAR_UPARROW_FGCOLOR ;
+ frame->FrameData.ScrlUpBGColor = SCROLLBAR_UPARROW_BGCOLOR ;
+ frame->FrameData.ScrlDnFGColor = SCROLLBAR_DOWNARROW_FGCOLOR ;
+ frame->FrameData.ScrlDnBGColor = SCROLLBAR_DOWNARROW_BGCOLOR ;
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleGetNavToken
+//
+// Description: Function to get navigation frame token
+//
+// Input: UINT32 page number
+//
+// Output: UINT16 token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 OverRideStyleGetNavToken( UINT32 page )
+{
+ return gStrNavToken;
+}
+
+
+
+static AMI_IFR_LABEL gFailSafeLabel = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), STRING_TOKEN(STR_LOAD_FAILSAFE_HELP) };
+static AMI_IFR_LABEL gOptimalLabel = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), STRING_TOKEN(STR_LOAD_OPTIMAL_HELP) };
+static AMI_IFR_LABEL gSaveExitLabel = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), STRING_TOKEN(STR_SAVE_EXIT_HELP) };
+static AMI_IFR_LABEL gExitLabel = { 0, 0, STRING_TOKEN(STR_EXIT), STRING_TOKEN(STR_EXIT_HELP) };
+static AMI_IFR_LABEL gSaveResetLabel = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), STRING_TOKEN(STR_SAVE_RESET_HELP) };
+static AMI_IFR_LABEL gResetLabel = { 0, 0, STRING_TOKEN(STR_RESET), STRING_TOKEN(STR_RESET_HELP) };
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleAddAdditionalControls
+//
+// Description: Function to add additional controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_DATA **control;
+ UINT8 top=0, left=0;
+ UINT16 i=0, count = 0;
+
+
+ if ( frame->PageID != 0 )
+ return Status;
+
+
+// _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gFailSafeLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gOptimalLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveExitLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gExitLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gSaveResetLabel, &controlNumber, &focus );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ _StyleAddSpacing( frame );
+ Status = _StyleAddControl( frame, CONTROL_TYPE_LABEL, &gResetLabel, &controlNumber, &focus );
+
+ control = frame->ControlList;
+ count = frame->ControlCount ;
+
+ //Note: Initially, the root page layout of controls is from top->bottom left->right column with single spacing.
+ //If the initial layout spans more than the left and right column, update the layout using no spacing.
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleSelectFirstDisplayPage
+//
+// Description: Function to set first page display
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleSelectFirstDisplayPage( VOID )
+{
+ gApp->CurrentPage = 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleUpdateVersionString
+//
+// Description: Function to update version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID OverRideStyleUpdateVersionString( VOID )
+{
+ CHAR16 *string = NULL, *newString = NULL;
+ UINTN length, TseMajor,TseMinor, TseBuild;
+ UINT16 TseBuildYear=0;
+ UINTN i;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 63073 : Source modules in TSE should get the version details from binary in run time not at build time
+ GetTseBuildVersion(&TseMajor,&TseMinor,&TseBuild);
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseMajor, TseMinor, TseBuild,TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_COPYRIGHT), gLanguages[i].Unicode, newString );
+ }
+
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ //EIP 151966 : Use BIOS build year for copyright message
+ string = HiiGetStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode );
+ if ( string == NULL )
+ return;
+ length = EfiStrLen(string) + 10;
+ newString = EfiLibAllocateZeroPool( length * sizeof(CHAR16) );
+ if ( newString != NULL )
+ {
+ //EIP 151966 : Use BIOS build year for copyright message
+ GetTseBuildYear(&TseBuildYear);
+ SPrint( newString, length * sizeof(CHAR16), string, TseBuildYear );
+ HiiChangeStringLanguage( gHiiHandle, STRING_TOKEN(STR_MAIN_TITLE), gLanguages[i].Unicode, newString );
+ }
+ MemFreePointer( (VOID **)&newString );
+ MemFreePointer( (VOID **)&string );
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OverRideStyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if(!frame->FrameData.Drawable){
+ Status = EFI_UNSUPPORTED;
+ }
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddSpacing
+//
+// Description: Function to add spacing
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleAddSpacing( FRAME_DATA *frame )
+{
+ _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+ //if ( frame->ControlCount == 7 )
+ // _StyleAddControl( frame, CONTROL_TYPE_NULL, NULL, NULL, NULL );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleAddControl
+//
+// Description: Function to add controls
+//
+// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus )
+{
+ EFI_STATUS Status;
+ CONTROL_INFO dummy;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+
+ dummy.ControlType = type;
+ dummy.ControlPtr = (VOID*)data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gFrame.AddControl( frame, &dummy );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ if ( type != CONTROL_TYPE_NULL )
+ {
+ if ( ! *focus )
+ {
+ if ( _FrameSetControlFocus( frame, *controlNumber ) )
+ {
+ frame->CurrentControl = *controlNumber;
+ *focus = TRUE;
+ }
+ }
+
+ (*controlNumber)++;
+ }
+
+ return Status;
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Legacy/style.h b/EDK/MiniSetup/Legacy/style.h
new file mode 100644
index 0000000..bef8e19
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/style.h
@@ -0,0 +1,259 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/style.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 6:06a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/style.h $
+//
+// 4 10/18/12 6:06a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 6/29/11 12:41p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 2 6/23/11 3:47p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 1 3/28/11 11:52p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 9/16/10 6:37p Blaines
+//
+// 1 9/16/10 6:32p Blaines
+//
+// 10 3/31/10 11:40a Blaines
+// Remove the hook StyleFrameAddControl
+//
+// 9 3/23/10 5:10p Blaines
+// Add new style module hooks
+//
+// 8 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 7 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 5 8/19/09 11:13a Blaines
+// Update OEM Override prototypes
+//
+// 4 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 3 8/17/09 12:23p Presannar
+// Removed References to Tiano.h
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: style.h
+//
+// Description: Style override prototypes.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+//#define SETUP_STYLE_FULL_SCREEN 1
+//#define SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY 0
+
+#ifndef _STYLE_H_
+#define _STYLE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+//#define SETUP_STYLE_LEGACY 1
+#include "legacy.h"
+#include "page.h"
+#include "frame.h"
+
+extern INT16 gTabIndex ;
+EFI_STATUS LegacyFrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color);
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+EFI_STATUS OverRideControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+VOID StyleInit( VOID );
+VOID StyleExit( VOID );
+VOID StyleDrawPageBorder( UINT32 page );
+UINT32 StyleGetPageFrames( UINT32 page );
+UINT32 StyleFrameIndexOf( UINT32 frameType );
+VOID StyleBeforeFrame( FRAME_DATA *frame ) ;
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame );
+VOID StyleUpdateFrameStrings(PAGE_DATA *page);
+VOID * StyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo);
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action );
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 StyleGetNavToken( UINT32 page );
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+
+//EFI_STATUS StyleMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, CALLBACK_MENU *data );
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *number, BOOLEAN *focus );
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu );
+BOOLEAN StyleHelpAreaScrollable(VOID);
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+BOOLEAN StyleGetShadowSupport(VOID);
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+
+
+VOID StyleSelectFirstDisplayPage( VOID );
+VOID StyleAddExtraPagesData( VOID );
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color);
+UINTN StyleGetDateFormat(VOID);
+BOOLEAN StyleShowDay(VOID);
+BOOLEAN StyleGetScrollBehavior(VOID) ;
+
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+extern HOTKEY_TEMPLATE gHotKeyInfo[];
+extern HOTCLICK_TEMPLATE gHotClickInfo[];//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+extern UINT32 gHotKeyCount;
+extern UINT32 gHotClickCount;//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+//extern UINT8 gLabelLeftMargin ;
+//extern UINT8 gControlLeftMargin ;
+//extern FRAME_INFO _gStyleStandardSubFrames[] ;
+extern UINT32 gSubFrameCount ;
+extern EFI_STATUS FrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy );
+
+
+//Common Overrides
+VOID OverRideStyleLabelCallback(FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+EFI_STATUS OverRideStyleFrameHandleKey(FRAME_DATA *frame, EFI_INPUT_KEY Key);
+EFI_STATUS OverRideStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OverRideStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OverRideStyleGetNavToken( UINT32 page );
+EFI_STATUS OverRideStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+VOID OverRideStyleSelectFirstDisplayPage( VOID );
+VOID OverRideStyleUpdateVersionString( VOID );
+EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame );
+VOID OverRideComponent(VOID);
+
+//Oem Overrides
+UINTN OEMStyleGetDateFormat(VOID);
+EFI_STATUS OEMGetSpecialColor(UINT16 ControlType, UINT8 *Color);
+VOID OEMStyleBeforeFrame( FRAME_DATA *frame );
+VOID OEMStyleUpdateFrameStrings( PAGE_DATA *page );
+EFI_STATUS OEMStyleFrameDrawable( FRAME_DATA *frame );
+VOID OEMStyleInit( VOID );
+VOID OEMStyleExit( VOID );
+VOID OEMStyleDrawPageBorder( UINT32 page );
+VOID OEMDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+VOID OEMDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+VOID *OEMStyleGetFrameInitData( UINT32 page, UINT32 frame );
+EFI_STATUS OEMStyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS OEMStyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS OEMStyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 OEMStyleGetNavToken( UINT32 page );
+EFI_STATUS OEMStyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+UINT16 OEMStyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 OEMStyleBootManagerPage( SUBMENU_DATA *submenu );
+VOID OEMStyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+VOID OEMStyleSelectFirstDisplayPage( VOID );
+VOID OEMStyleAddExtraPagesData(VOID);
+UINTN OEMStyleGetTextMode( UINTN Rows, UINTN Cols );
+VOID OEMStyleUpdateVersionString( VOID );
+VOID OEMStyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+VOID OEMOverRideComponent(VOID);
+VOID OEMStylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID OEMStyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+
+#endif /* _STYLE_H_ */
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/Legacy/stylecommon.c b/EDK/MiniSetup/Legacy/stylecommon.c
new file mode 100644
index 0000000..86f0d3d
--- /dev/null
+++ b/EDK/MiniSetup/Legacy/stylecommon.c
@@ -0,0 +1,1362 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/stylecommon.c $
+//
+// $Author: Rajashakerg $
+//
+// $Revision: 12 $
+//
+// $Date: 3/16/13 2:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy/stylecommon.c $
+//
+// 12 3/16/13 2:20a Rajashakerg
+// [TAG] EIP111479
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS dialog box is crashed with special
+// monitor(160,53,1280*1024)
+// [RootCause] DesiredTextMode was not set properly.
+// [Solution] Provided proper mode number while setting text mode.
+// [Files] postmgmtext.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 11 2/10/13 11:55p Rajashakerg
+// [TAG] EIP104521
+// [Category] Improvement
+// [Description] Customer needs AMITSE modification to popup boxes so
+// highlighted choices can be seen via VT100 console redirection
+// [Files] AMITSE.sdl, CommonHelper.c, Ezport\stylecommon.c,
+// EzportPlus\stylecommon.c, Legacy\stylecommon.c
+//
+// 10 10/18/12 6:06a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:42p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 9/17/12 6:26a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 6 8/29/12 4:27p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 5 4/03/12 3:03a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 4 11/28/11 1:34a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 3 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 2 11/09/11 10:04a Premkumara
+// [TAG] EIP74375
+// [Category] Improvement
+// [Description] Control STYLE_HELP_AREA_SCROLLBAR from binary
+// [Files] CommonHelper.c, AMITSE.sdl, StyleHook.h,
+// Legacy\StyleCommon.c, Legacy.sdl,
+// EzportPlus\StyleCommon.c, EzportPlus.sdl, Ezport\StyleCommon.c,
+// Ezport.sdl
+//
+// 1 3/28/11 11:52p Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 1 9/16/10 6:37p Blaines
+//
+// 1 9/16/10 6:32p Blaines
+//
+// 10 3/31/10 11:40a Blaines
+// Remove the hook StyleFrameAddControl
+//
+// 9 3/23/10 5:10p Blaines
+// Add new style module hooks
+//
+// 8 2/19/10 8:15a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 6 11/09/09 4:44a Mallikarjunanv
+// Eip-30111 : fixed the issue to update the help if
+// STYLE_PAGE_FIRSTITEM_FOCUS token enabled.
+//
+// 5 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 4 8/13/09 1:24p Blaines
+// EIP #24980 Fix to properly display right area text;
+//
+//
+// 3 6/23/09 6:54p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 2:36p Blaines
+// Update coding standard
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 4 5/20/09 3:37p Blaines
+// Add functions to access date format and Scroll behavior
+//
+// 3 5/18/09 12:18p Blaines
+// Fix Help Frame text scroll
+// Add OEM Style override prototype declarations
+//
+// 2 5/07/09 10:35a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:15p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/24/09 9:35p Blaines
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: stylecommon.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+#if SETUP_STYLE_LEGACY
+
+
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref );
+VOID UpdatePageFocusedItemHelp(PAGE_DATA *page);
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StyleControlColor
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// STYLECOLORS Colors - Color scheme
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors)
+{
+ //The goal here is to allow controls to match the BGColor of their frame.
+ //Normally this is handled in StyleInitializeFrame(), before controls are added to the frame.
+ //But this function is called dynamically during runtime (after pages/frames/controls are styled)
+ //Since controls derive their colors from [STYLECOLORS Colors],
+ //we'll temporarly modify it before controls are added to this frame, then restore it.
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_CONTROL_COLOR
+ Status = OEMControlColor(frame, Colors);
+ #else
+ #ifdef STYLE_CONTROL_COLOR
+ Status = OverRideControlColor(frame, Colors);
+ #else
+
+
+ if(LABEL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors->LabelFGColor = LABEL_FOCUS_COLOR ;
+
+ if(CONTROL_FOCUS_COLOR != FOCUS_COLOR)
+ Colors->SelFGColor = CONTROL_FOCUS_COLOR;
+
+ if(LABEL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors->NSelLabelFGColor = LABEL_NON_FOCUS_COLOR ;
+
+ if(CONTROL_NON_FOCUS_COLOR != NON_FOCUS_COLOR)
+ Colors->NSelFGColor = CONTROL_NON_FOCUS_COLOR ;
+
+ Colors->SelBGColor = CONTROL_FOCUS_BGCOLOR ;
+ Colors->EditBGColor = CONTROL_FOCUS_BGCOLOR ;
+
+
+ #endif
+
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetSpecialColor
+//
+// Description: Function to get control special color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_CONTROL_COLOR
+ Status = OEMGetSpecialColor(ControlType, Color);
+ #else
+
+
+ switch ( ControlType )
+ {
+ case CONTROL_TYPE_MEMO:
+ if (Color !=NULL) *Color = MEMO_COLOR ;
+ break;
+
+ case CONTROL_TYPE_TEXT:
+ if (Color !=NULL) *Color = TEXT_COLOR ;
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;;
+ break;
+ }
+ #endif
+
+ return Status ;
+}
+
+VOID GetMessageboxColorHook(UINT8 **Color);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetMessageboxColor
+//
+// Description: Function to get control Messagebox color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color)
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ if(Color == NULL)
+ return Status ;
+
+
+ switch ( MessageBoxType )
+ {
+ case MSGBOX_EX_CATAGORY_HELP:
+ *Color = POPUP_BGCOLOR | POPUP_FGCOLOR ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_QUERY:
+ *Color = EFI_BACKGROUND_BLUE | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_SUCCESS:
+ *Color = EFI_BACKGROUND_GREEN | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_WARNING:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_ERROR:
+ *Color = EFI_BACKGROUND_RED | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_PROGRESS:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_HALT:
+ *Color = EFI_BACKGROUND_LIGHTGRAY | EFI_WHITE ;
+ break;
+
+ case MSGBOX_EX_CATAGORY_NORMAL:
+
+ default:
+ *Color = EFI_BACKGROUND_BLUE | EFI_WHITE ;
+
+ break;
+ }
+
+ GetMessageboxColorHook(&Color);
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBeforeFrame
+//
+// Description: Function to alter frame styling before frame is drawn
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleBeforeFrame( FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_BEFORE_FRAME
+ OEMStyleBeforeFrame(frame);
+ #else
+ #ifdef STYLE_OVERRIDE_BEFORE_FRAME // from alternate1.h
+ OverRideStyleBeforeFrame(frame ); // From alternate1.c
+ #endif
+
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateFrameStrings
+//
+// Description: Function to update frame strings
+//
+// Input: PAGE_DATA *page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateFrameStrings( PAGE_DATA *page )
+{
+ #ifdef STYLE_OEM_FRAME_TOKEN // SDL
+ OEMStyleUpdateFrameStrings(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_TOKEN // from Ezport.h
+ OverRideStyleUpdateFrameStrings(page ); // From ezport.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_FRAME_DRAWABLE // SDL
+ Status = OEMStyleFrameDrawable(frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_DRAWABLE // from Ezport.h
+ Status = OverRideStyleFrameDrawable(frame ); // From ezport.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleInit( VOID )
+{
+ SetDesiredTextMode();
+ OverRideStyleInit(); // From ezport.c
+
+#ifdef STYLE_OEM_INIT // SDL
+ OEMStyleInit(); // OEM
+#endif
+ MouseInit(); //EIP-84150
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleExit
+//
+// Description: Function to do style initialization on exit
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleExit( VOID )
+{
+ #ifdef STYLE_OEM_STYLE_EXIT // SDL
+ OEMStyleExit(); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_EXIT // from Ezport.h
+ OverRideStyleExit(); // From ezport.c
+ #endif
+ #endif
+ MouseDestroy(); //EIP-84150
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawPageBorder
+//
+// Description: Function to draw the page border
+//
+// Input: UINT32 page number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawPageBorder( UINT32 page )
+{
+ #ifdef STYLE_OEM_PAGE_BORDER // SDL
+ OEMStyleDrawPageBorder(page); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_BORDER // from Ezport.h
+ OverRideStyleDrawPageBorder(page); // From ezport.c
+ #else
+ ClearScreen( EFI_BACKGROUND_BLUE | EFI_WHITE );
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawScrollBar
+//
+// Description: Function to draw the frame scrollbar
+//
+// Input: FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+ #ifdef STYLE_OEM_SCROLLBAR
+ OEMDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ #ifdef STYLE_OVERRIDE_SCROLLBAR
+ LegacyFrameDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #else
+ FrameDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawHelpScrollBar
+//
+// Description: Function to draw the help frame scrollbar
+//
+// Input: MEMO_DATA *memo, UINT16 height
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height)
+{
+ #ifdef STYLE_OEM_DRAW_HELP_SCROLLBAR
+ OEMDrawHelpScrollBar(memo, height);
+ #else
+ #ifdef STYLE_OVERRIDE_HELP_SCROLLBAR
+ OverRideDrawHelpScrollBar(memo, height);
+ #else
+ if(IsHelpAreaScrollBarSupport())
+ MemoDrawScrollBar(memo, height);
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page number, UINT32 frame number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *StyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ #ifdef STYLE_OEM_FRAME_INIT_DATA
+ return OEMStyleGetFrameInitData(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_INIT_DATA // from Ezport.h
+ return OverRideStyleGetFrameInitData(page, frame); // From ezport.c
+ #else
+ return NULL;
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleKey
+//
+// Description: Function to handle frame action keys
+//
+// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_KEY // SDL
+ Status = OEMStyleFrameHandleKey(frame, Key); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_KEY // from Ezport.h
+ Status = OverRideStyleFrameHandleKey(frame, Key); // From ezport.c
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleMouse
+//
+// Description: Function to handle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// MOUSE_INFO MouseInfo
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_MOUSE
+ Status = OEMStyleFrameHandleMouse(frame, MouseInfo);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_MOUSE
+ Status = OverRideStyleFrameHandleMouse(frame, MouseInfo);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleTimer
+//
+// Description: Function to handle frame timer action
+//
+// Input: FRAME_DATA *frame, ACTION_DATA *action
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;;
+
+ #ifdef STYLE_OEM_HANDLE_TIMER
+ Status = OEMStyleFrameHandleTimer(frame, action);
+ #else
+ #ifdef STYLE_OVERRIDE_HANDLE_TIMER
+ Status = OverRideStyleFrameHandleTimer(frame, action);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHandleControlOverflow
+//
+// Description: Function to handle control overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ #ifdef STYLE_OEM_CONTROL_OVERFLOW
+ Status = OEMStyleHandleControlOverflow(frame, control, count );
+ #else
+ #ifdef STYLE_OVERRIDE_CONTROL_OVERFLOW
+ Status = OverRideStyleHandleControlOverflow(frame, control, count );
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInitializeFrame
+//
+// Description: Function to Initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;;
+
+ #ifdef STYLE_OEM_INITIALIZE_FRAME
+ Status = OEMStyleInitializeFrame(frame, frameType, data );
+ #else
+ #ifdef STYLE_OVERRIDE_INITIALIZE_FRAME
+ Status = OverRideStyleInitializeFrame(frame, frameType, data); //style.c
+ #endif
+ #endif
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetNavToken
+//
+// Description: Function to get navigation token
+//
+// Input: UINT32 page
+//
+// Output: UINT16 token number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleGetNavToken( UINT32 page )
+{
+ UINT16 i=0 ;
+
+ #ifdef STYLE_OEM_NAV_TOKEN
+ i = OEMStyleGetNavToken(page );
+ #else
+ #ifdef STYLE_OVERRIDE_NAV_TOKEN
+ i = OverRideStyleGetNavToken(page);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddAdditionalControls
+//
+// Description: Function to add additinal controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ #ifdef STYLE_OEM_ADD_CONTROLS
+ Status = OEMStyleAddAdditionalControls(frame, controlNumber, focus );
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_CONTROLS
+ Status = OverRideStyleAddAdditionalControls(frame, controlNumber, focus);
+ #endif
+ #endif
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLanguagePage
+//
+// Description: Function to set Language page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_LANGUAGE_PAGE
+ i = OEMStyleLanguagePage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_LANGUAGE_PAGE
+ i = OverRideStyleLanguagePage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+
+
+
+static UINT16 _gBootManagerPageID = 0;
+/*static*/ UINT16 _gHDOrderPageID = 0;
+/*static*/ UINT16 _gCDOrderPageID = 0;
+/*static*/ UINT16 _gFDOrderPageID = 0;
+/*static*/ UINT16 _gNetOrderPageID = 0;
+/*static*/ UINT16 _gBevOrderPageID = 0;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBootManagerPage
+//
+// Description: Function to set boot manager page
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: UINT16 page number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu )
+{
+ UINT16 i = 0 ;
+
+ #ifdef STYLE_OEM_BM_PAGE
+ i = OEMStyleBootManagerPage(submenu );
+ #else
+ #ifdef STYLE_OVERRIDE_BM_PAGE
+ i = OverRideStyleBootManagerPage(submenu);
+ #endif
+ #endif
+
+ return i ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleLabelCallback
+//
+// Description: Function to set label callback
+//
+// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie )
+{
+ #ifdef STYLE_OEM_LABEL_CALLBACK
+ OEMStyleLabelCallback(frame, label, cookie );
+ #else
+ #ifdef STYLE_OVERRIDE_LABEL_CALLBACK
+ OverRideStyleLabelCallback(frame, label, cookie );
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSelectFirstDisplayPage
+//
+// Description: Function to set the first display page
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSelectFirstDisplayPage( VOID )
+{
+ #ifdef STYLE_OEM_FIRST_PAGE
+ OEMStyleSelectFirstDisplayPage();
+ #else
+ #ifdef STYLE_OVERRIDE_FIRST_PAGE
+ OverRideStyleSelectFirstDisplayPage();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddExtraPagesData
+//
+// Description: Function to add extra pages
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleAddExtraPagesData(VOID)
+{
+ #ifdef STYLE_OEM_ADD_EXTRA_PAGES
+ OEMStyleAddExtraPagesData();
+ #else
+ #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES
+ OverRideStyleAddExtraPagesData();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetTextMode
+//
+// Description: Function to get text mode
+//
+// Input: UINTN Rows, UINTN Cols
+//
+// Output: UNNTN mode
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetTextMode( UINTN Rows, UINTN Cols )
+{
+ EFI_STATUS Status;
+ INT32 i;
+ UINTN ModeRows, ModeCols;
+
+ #ifdef STYLE_OEM_GET_TEXT_MODE
+ i = OEMStyleGetTextMode( Rows, Cols );
+ #else
+ #ifdef STYLE_OVERRIDE_GET_TEXT_MODE
+ i = OverRideStyleGetTextMode( Rows, Cols);
+ #else
+ // Default Implementation
+ for ( i = 0; i < gST->ConOut->Mode->MaxMode; i++ )
+ {
+ Status = gST->ConOut->QueryMode( gST->ConOut, i, &ModeCols, &ModeRows );
+ if ( EFI_ERROR( Status ) )
+ continue;
+
+ if ( ( Cols == ModeCols ) && ( Rows == ModeRows ) )
+ return i;
+ }
+
+ // return MaxMode if the mode wasn't found
+ #endif
+ #endif
+
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateVersionString
+//
+// Description: Function to set the version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateVersionString( VOID )
+{
+ #ifdef STYLE_OEM_VERSION_STRING
+ OEMStyleUpdateVersionString();
+ #else
+ #ifdef STYLE_OVERRIDE_VERSION_STRING
+ OverRideStyleUpdateVersionString();
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameSetControlPositions
+//
+// Description: Function to set control positioning in a frame
+//
+// Input: FRAME_DATA *frame, UINT32 *pOtherEnd
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd)
+{
+ UINT32 u32Height = 0;
+ UINT32 i;
+ CONTROL_DATA *control;
+ UINT8 u8ChkResult;
+
+ #ifdef STYLE_OEM_FRAME_CONTROL_POSITION
+ OEMStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ #ifdef STYLE_OVERRIDE_FRAME_CONTROL_POSITION
+ OverRideStyleFrameSetControlPositions(frame, pOtherEnd);
+ #else
+ if(frame->PageID != 0 )
+ {
+ //Move reference end variable based on action
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ {
+ i = frame->FirstVisibleCtrl;
+ }
+ else
+ {
+ i = frame->LastVisibleCtrl;
+ }
+
+ //Calculate other end variable
+ while( (pOtherEnd == &(frame->LastVisibleCtrl)) ? (i < frame->ControlCount) : TRUE )
+ {
+ control = frame->ControlList[i];
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(control->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ if( (u32Height + control->Height) < frame->FrameData.Height )
+ {
+ *pOtherEnd = i;
+ u32Height += control->Height;
+ }
+ else
+ break; //We cant accommodate
+ }
+
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ i++;
+ else
+ {
+ // i>=0 in while loop will result in infinite loop
+ // break statement should be introduced inside
+ if (i == 0)
+ break;
+ i--;
+ }
+ }
+ }
+ else
+ {
+ // frame is double sided in alternate1, let it be drawn
+ frame->FirstVisibleCtrl=0;
+ frame->LastVisibleCtrl = frame->ControlCount -1;
+ }
+
+ #endif
+ #endif
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleOverRideComponent
+//
+// Description: Function to override component or control functionality
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleOverRideComponent(VOID)
+{
+ #ifdef STYLE_OEM_COMPONENT_OVERRIDE // SDL
+ OEMOverRideComponent(); // OEM
+ #else
+ #ifdef STYLE_COMPONENT_OVERRIDE // from Ezport.h
+ OverRideComponent(); // From ezport.c
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StyleControlSubmenu
+//
+// Description: Function to initialize submenu control
+//
+// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref )
+{
+ control->ControlHandle = gHiiHandle;
+ control->ControlType = CONTROL_TYPE_SUBMENU;
+ control->ControlFlags.ControlVisible = TRUE;
+ control->ControlPtr = (VOID*)ref;
+ control->ControlPageID = pageID;
+ control->ControlDestPageID = 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHelpAreaScrollable
+//
+// Description: Function to get Help area scroll support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleHelpAreaScrollable(VOID)
+{
+ if(IsHelpAreaScrollBarSupport())
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetShadowSupport
+//
+// Description: Function to get shadow support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetShadowSupport(VOID)
+{
+ if(STYLE_SHADOW_SUPPORT)
+ return TRUE ;
+ else
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBehavior
+//
+// Description: Function to get scroll behavior
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetScrollBehavior(VOID)
+{
+ return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetDateFormat
+//
+// Description: Function to get date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetDateFormat(VOID)
+{
+ #ifdef STYLE_OEM_DATE_FOMAT
+ return OEMStyleGetDateFormat();
+ #else
+ return STYLE_DATE_FORMAT;
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleShowDay
+//
+// Description: Function to show day in date format
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleShowDay(VOID)
+{
+ return STYLE_SHOW_DAY ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxRows
+//
+// Description: Function to max number of columns
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_ROWS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxRows(VOID)
+{
+ return STYLE_STD_MAX_ROWS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxCols
+//
+// Description: Function to get max number of rows
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_COLS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxCols(VOID)
+{
+ return STYLE_STD_MAX_COLS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetClearScreenColor
+//
+// Description: Function to Get Clear Screen Color
+//
+// Input: VOID
+//
+// Output: STYLE_CLEAR_SCREEN_COLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetClearScreenColor(VOID)
+{
+ return STYLE_CLEAR_SCREEN_COLOR;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageLinkColor
+//
+// Description: Function to PageLink (Submenu) color
+//
+// Input: VOID
+//
+// Output: PAGE_LINK_FGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetPageLinkColor(VOID)
+{
+ UINT32 PageNum = gApp->CurrentPage ;
+
+ if( PageNum == 0 )
+ return EFI_YELLOW;
+ else
+ return PAGE_LINK_COLOR;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarColor
+//
+// Description: Function to get scrollbar color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarColor(VOID)
+{
+ return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarUpArrowColor
+//
+// Description: Function to get scrollbar UpArrow Color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarUpArrowColor(VOID)
+{
+ return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarDownArrowColor
+//
+// Description: Function to get scrollbar downarrow color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarDownArrowColor(VOID)
+{
+ return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StylePageItemFocus
+//
+// Description: This function is called whenever a user navigates to a new page.
+// OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+
+ #ifdef STYLE_OEM_PAGE_ITEM_FOCUS
+ OEMStylePageItemFocus(page, frame);
+ #else
+ #ifdef STYLE_OVERRIDE_PAGE_ITEM_FOCUS
+ OverRideStylePageItemFocus(page, frame);
+ #else
+ if(STYLE_PAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ ///Eip:30111 fix - Update the Help based on the Focussed Item
+ UpdatePageFocusedItemHelp(page);
+ }
+ #endif
+ #endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSubPageItemFocus
+//
+// Description: This function is called whenever a user returns (or navigates back)
+// from a submenu page causing a complete page redraw. OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+ #ifdef STYLE_OEM_SUBPAGE_ITEM_FOCUS // SDL
+ OEMStyleSubPageItemFocus(page, frame); // OEM
+ #else
+ #ifdef STYLE_OVERRIDE_SUBPAGE_ITEM_FOCUS // from Ezport.h
+ OverRideStyleSubPageItemFocus(page, frame); // From ezport.c
+ #else
+ if(STYLE_SUBPAGE_FIRSTITEM_FOCUS)
+ {
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+ }
+ #endif
+ #endif
+}
+#endif
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c
new file mode 100644
index 0000000..461b626
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c
@@ -0,0 +1,101 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/PasswordEncode/TsePasswordEncode.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 7/16/14 1:40p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/PasswordEncode/TsePasswordEncode.c $
+//
+// 2 7/16/14 1:40p Arunsb
+// [TAG] EIP178064
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Password window hangs on post
+// [Root Cause] Memory accessed over the allocated range
+// [Solution] While changing the incoming password to non case sensitivie
+// memory accessed only within range.
+// [Files] PasswordEncode\PasswordEncode.c and
+// PasswordEncode\TsePasswordEncode.c
+//
+// 1 5/08/14 4:37p Arunsb
+// [TAG] EIP162197
+// [Category] Improvement
+// [Description] Password encode feature. Modify to encode using Hashing
+// based on token.
+// Separate module created for TSE password encoding logic.
+//
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CtrlCond.C
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TsePasswordEncodeLocal
+//
+// Description: Function to encode the password string
+//
+// Parameter: CHAR16 *Password, UINTN MaxSize
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsPasswordSupportNonCaseSensitive();
+VOID TsePasswordEncodeLocal ( CHAR16 *Password, UINTN MaxSize)
+{
+ UINTN ii;
+ unsigned int key = 0x935b;
+
+ if (IsPasswordSupportNonCaseSensitive ())
+ {
+ for ( ii = 0; ii < MaxSize/2; ii++ )
+ Password[ii] = ((Password[ii]>=L'a')&&(Password[ii]<=L'z'))?(Password[ii]+L'A'-L'a'):Password[ii];
+ }
+ // Encode the password..
+ for ( ii = 1; ii <= MaxSize/2; ii++ )
+ Password[ii-1] = (CHAR16)(Password[ii-1] ^ (key*ii));
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif
new file mode 100644
index 0000000..ffa35ac
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif
@@ -0,0 +1,10 @@
+<component>
+ name = "TSE Sources - PasswordEncode"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\PasswordEncode"
+ RefName = "TsePasswordEncode"
+[files]
+"TsePasswordEncode.sdl"
+"TsePasswordEncode.mak"
+"TsePasswordEncode.c"
+<endComponent> \ No newline at end of file
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak
new file mode 100644
index 0000000..d750c6b
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak
@@ -0,0 +1,145 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2004, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/PasswordEncode/TsePasswordEncode.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 1 $
+##
+## $Date: 5/08/14 4:37p $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/PasswordEncode/TsePasswordEncode.mak $
+#
+# 1 5/08/14 4:37p Arunsb
+# [TAG] EIP162197
+# [Category] Improvement
+# [Description] Password encode feature. Modify to encode using Hashing
+# based on token.
+# Separate module created for TSE password encoding logic.
+#
+# 9 10/18/12 5:58a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 12 10/10/12 12:36p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 8 4/02/10 6:13p Madhans
+# EIP 37036 : To make TSE 2.01 Binary module to work with older Cores
+#
+# 7 2/26/10 8:53p Madhans
+# For TSE 2.01.1024. refer changelog.log for file checkin history .
+##
+## 8 2/26/10 1:29p Madhans
+## Bootonly source module need AMITSEStrTokens.h
+##
+## 7 2/19/10 8:14a Mallikarjunanv
+## updated year in copyright message
+##
+## 6 2/17/10 1:02p Madhans
+## minisetupstr.uni removed and Strings token are refered from
+## AMITSEStrTokens.h
+##
+## 5 10/28/09 5:37p Madhans
+##
+## 4 8/17/09 12:22p Presannar
+## Removed include directory Core
+##
+## 3 6/24/09 6:09p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 7:41p Presannar
+## Initial implementation of coding standards
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:12p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 5 4/28/09 9:39p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 4 3/31/09 3:58p Madhans
+##
+## 3 2/05/09 10:15a Madhans
+## Style Module created.
+##
+## 2 1/30/09 6:06p Madhans
+## Function headers added.
+##
+## 1 12/18/08 7:58p Madhans
+## Intial version of TSE Lite sources
+##*****************************************************************##
+
+# MAK file for the eModule:MiniSetup
+
+MINISETUP_INCLUDES = \
+ -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 $(BUILD_DIR) \
+ -I $(TSE_PWD_ENCODE_DIR) \
+
+!if "$(TseLite_SUPPORT)" == "1"
+MINISETUP_INCLUDES = -I $(UEFISRC_DIR) $(MINISETUP_INCLUDES) -I $(TSELITESRC_DIR) -I $(TSE_STYLE_DIR)
+!endif
+
+
+$(BUILD_DIR)\TsePasswordEncode.lib : TsePasswordEncodeLib
+
+TsePasswordEncodeLib : $(BUILD_DIR)\TsePasswordEncode.mak TsePasswordEncodeLibBin
+
+$(BUILD_DIR)\TsePasswordEncode.mak : $(TSE_PWD_ENCODE_DIR)\$(@B).cif $(TSE_PWD_ENCODE_DIR)\$(@B).mak $(BUILD_RULES) $(BUILD_DIR)\AMITSEStrTokens.h
+ $(CIF2MAK) $(TSE_PWD_ENCODE_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+TsePasswordEncodeLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\TsePasswordEncode.mak all\
+ "MY_INCLUDES=$(MINISETUP_INCLUDES)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TsePasswordEncode.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl
new file mode 100644
index 0000000..11e11ca
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl
@@ -0,0 +1,34 @@
+TOKEN
+ Name = "TSE_PASSWORD_ENCODE_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable TSE password encode support"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "TSE_PWD_ENCODE_DIR"
+End
+
+MODULE
+ Help = "Includes TsePasswordEncode.mak to Project"
+ File = "TsePasswordEncode.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)/TsePasswordEncode.lib"
+ Parent = "$(TSE_PWD_ENCODE_DIR)/TsePasswordEncode$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
+TOKEN
+ Name = "PASSWORDENCODELIB"
+ Value = "$(BUILD_DIR)/TsePasswordEncode.lib"
+ Help = "Password encode library"
+ TokenType = Expression
+ TargetMAK = Yes
+ TargetH = Yes
+End \ No newline at end of file
diff --git a/EDK/MiniSetup/TSESources.Sdl b/EDK/MiniSetup/TSESources.Sdl
new file mode 100644
index 0000000..73e46d7
--- /dev/null
+++ b/EDK/MiniSetup/TSESources.Sdl
@@ -0,0 +1,20 @@
+TOKEN
+ Name = "TSE_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable MiniSetup support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+
+TOKEN
+ Name = "SETUP_OEM_SPECIAL_CONTROL_SUPPORT"
+ Value = "0"
+ Help = "Turn on to have OEM Special Control Support."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
diff --git a/EDK/MiniSetup/TSESources.cif b/EDK/MiniSetup/TSESources.cif
new file mode 100644
index 0000000..0ecf7c2
--- /dev/null
+++ b/EDK/MiniSetup/TSESources.cif
@@ -0,0 +1,20 @@
+<component>
+ name = "TSE Sources"
+ category = eModule
+ LocalRoot = "EDK\MiniSetup\"
+ RefName = "TSESources"
+[files]
+"TSESources.Sdl"
+"AMITSE.chm"
+"changelog.log"
+[parts]
+"TseAdvanced"
+"Minisetup"
+"TseLite"
+"Uefi20"
+"Uefi21"
+"Ezport"
+"Legacy"
+"EzportPlus"
+"TsePasswordEncode"
+<endComponent>
diff --git a/EDK/MiniSetup/TseAdvanced/Bbs.c b/EDK/MiniSetup/TseAdvanced/Bbs.c
new file mode 100644
index 0000000..fe46455
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/Bbs.c
@@ -0,0 +1,946 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Bbs.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 13 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Bbs.c $
+//
+// 13 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 12 5/29/12 3:44a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 11 11/13/11 12:33p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 10 2/04/11 4:43p Mallikarjunanv
+// added the UpdateBootVariables() fucntion to update BOOT and BBS order
+// variables
+//
+// 9 12/21/10 11:48a Mallikarjunanv
+//
+// 9 9/21/10 11:26a Madhans
+// EIP44542 changes
+//
+// 7 9/20/10 6:47p Madhans
+// [TAG] EIP44542
+// [Category] BUILD ISSUE FIX
+// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
+// when IdeSecurity and FastBoot modules added to the project
+// [RootCause] -
+// [Solution] Build issues resolved
+// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
+// bbs.c, special.c, Bds.c TseLitehelp
+//
+// 6 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 8 9/16/10 3:14p Madhans
+// To Avoid build issues with TSE_USE_EDK_LIBRARY Building.
+//
+// 7 9/13/10 4:35p Madhans
+// To avoid build issue when EDK Build Support is turned off. Aptio 4.6.x
+// does not define I2O_DEVICE_PATH structure.
+//
+// 6 7/28/10 4:46a Mallikarjunanv
+// EIP-29951: TSE Device Path Name support updated
+//
+// 5 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 1/09/10 4:47a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: bds.c
+//
+// Description: This file contains code for legacy boot device handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetDevStr
+//
+// Description: function to get the device strings
+//
+// Input: UINT16 DevType
+//
+// Output: device string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetDevStr(UINT16 DevType)
+{
+ CHAR16 *DevText=NULL;
+
+ switch ( DevType )
+ {
+ case BBS_TYPE_FLOPPY:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_FDD));
+ break;
+
+ case BBS_TYPE_HARDDRIVE:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_HDD));
+ break;
+
+ case BBS_TYPE_CDROM:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_CDROM));
+ break;
+
+ case BBS_TYPE_USB:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB));
+ break;
+
+ case BBS_TYPE_EMBEDDED_NETWORK:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_NETWORK));
+ break;
+
+ case BBS_TYPE_DEV:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_BEV));
+ break;
+ }
+
+ return DevText;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsSATADevice
+//
+// Description: function to check for SATA Devices
+//
+// Input: UINT16 *IdentifyDriveData - 512 bytes of device information
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsSATADevice(UINT16 *IdentifyDriveData)
+{
+ UINT16 data16;
+
+ if(NULL == IdentifyDriveData)
+ return FALSE;
+
+ // Check Word76 for BIT1 and BIT2; set for SATA drives
+ data16 = IdentifyDriveData[76];
+ if ((data16 != 0xFFFF) && (data16 & 6))
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBusStr
+//
+// Description: function to get the bus type string
+//
+// Input: EFI_HANDLE Handle, UINTN index, HDD_INFO *HDDInfo
+//
+// Output: Bus string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetBusStr(EFI_HANDLE Handle, UINTN index, HDD_INFO *HDDInfo)
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath = NULL;
+ UINT8 PortNo;
+ CHAR16 *Format = NULL;
+ CHAR16 *BusText = NULL;
+
+ //Right now generate names only for internal devices (index 1 to
+ //16). Devices reported by option ROMs will show string provided
+ //by Option ROMs. Later this may be extended for all devices.
+// if((index<1) || (index>16))
+// return NULL;
+
+ if (!Handle)
+ return NULL;
+
+ Status = gBS->HandleProtocol(Handle, &gEfiDevicePathProtocolGuid, &DevPath);
+
+ if(EFI_ERROR(Status))
+ return NULL;
+
+ while( !(IsDevicePathEnd(DevPath)) )
+ {
+ if(MESSAGING_DEVICE_PATH == DevPath->Type)
+ {
+ switch(DevPath->SubType)
+ {
+ case MSG_ATAPI_DP:
+ PortNo = (((ATAPI_DEVICE_PATH*)DevPath)->PrimarySecondary<<1)|((ATAPI_DEVICE_PATH*)DevPath)->SlaveMaster;
+ if(IsSATADevice(HDDInfo[(index-1)/2].IdentifyDrive[(index-1)%2].Raw))
+ {
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SATA_X));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PortNo);
+ }
+ else
+ {
+ switch(PortNo)
+ {
+ case 0:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_PRI_MAS));
+ break;
+ case 1:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_PRI_SLA));
+ break;
+ case 2:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SEC_MAS));
+ break;
+ case 3:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SEC_SLA));
+ break;
+ }
+ }
+ break;
+ //EIP-29951: extended for all devices.
+ case MSG_SCSI_DP:
+ { //Showing the SCSI device with Physical and Logical unit numbers
+ UINT16 PhyUnitNum, LogclUnitNum;
+ PhyUnitNum = ((SCSI_DEVICE_PATH*)DevPath)->Pun;
+ LogclUnitNum = ((SCSI_DEVICE_PATH*)DevPath)->Lun;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SCSI_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PhyUnitNum, LogclUnitNum);
+ }
+ break;
+
+ case MSG_FIBRECHANNEL_DP:
+ {// showing Fibre channel with Logical unit number and WWN
+ UINT64 WWN,Lun;
+ WWN = ((FIBRECHANNEL_DEVICE_PATH*)DevPath)->WWN;
+ Lun = ((FIBRECHANNEL_DEVICE_PATH*)DevPath)->Lun;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_FIBRE_CHANNEL_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun, WWN);
+ }
+ break;
+
+ case MSG_1394_DP:
+ //For 1394 device support
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_1394_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format);
+ break;
+
+ case MSG_USB_DP:
+ {
+ // usb device with port number
+ PortNo = ((USB_DEVICE_PATH*)DevPath)->ParentPortNumber;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PortNo);
+ }
+ break;
+
+ case MSG_I2O_DP:
+ { // I2O device with Tid
+ UINT32 Tid;
+
+ Tid = ((AMITSE_I2O_DEVICE_PATH*)DevPath)->Tid;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_I20_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Tid);
+ }
+ break;
+
+ case MSG_INFINIBAND_DP: //Need to know what type of device is this..
+ { // InfiniBand device with Device Id
+ UINT64 DeviceId;
+
+ DeviceId = ((INFINIBAND_DEVICE_PATH*)DevPath)->DeviceId;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_INFINIBAND_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, DeviceId);
+ }
+ break;
+
+ case MSG_VENDOR_DP:
+ // for vendor specific device
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_VENDOR_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format);
+ break;
+
+ case MSG_MAC_ADDR_DP:
+ { // network device with mac address
+ UINT8 Mac[32];
+
+ MemCopy( Mac, (UINT8*)&(((AMITSE_MAC_ADDR_DEVICE_PATH*)DevPath)->MacAddress),32*sizeof(UINT8));
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_MAC_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Mac);
+ }
+
+ break;
+
+ case MSG_IPv4_DP:
+ { //IPv4 Device with Logical Port number
+ UINT16 LocalPort;
+
+ LocalPort = ((IPv4_DEVICE_PATH*)DevPath)->LocalPort;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_NETWORK_IPV4_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, LocalPort);
+ }
+ break;
+
+ case MSG_IPv6_DP:
+ { //IPv6 Device with Logical Port number
+ UINT16 LocalPort;
+
+ LocalPort = ((IPv6_DEVICE_PATH*)DevPath)->LocalPort;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_NETWORK_IPV6_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, LocalPort);
+ }
+
+ break;
+
+ case MSG_UART_DP:
+ { //UART device with Baud Rate
+ UINT64 BaudRate;
+
+ BaudRate = ((UART_DEVICE_PATH*)DevPath)->BaudRate;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_UART_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, BaudRate);
+ }
+ break;
+
+ case MSG_USB_CLASS_DP:
+ { ////for UBS Class id specific devices.
+ UINT8 DeviceClass;
+
+ DeviceClass = ((USB_CLASS_DEVICE_PATH*)DevPath)->DeviceClass;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ switch(DeviceClass)
+ { //To show the type of device based on the class
+ case USB_PHY_DEV_CLASS:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_PHY_DP));
+ break;
+
+ case USB_MASS_DEV_CLASS:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_MASS_DP));
+ break;
+
+ default:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_DP));
+
+ }
+ SPrint(BusText, MAX_DRIVE_NAME, Format, DeviceClass);
+ }
+ break;
+
+ case MSG_USB_WWID_CLASS_DP:
+ //need the info about USB WWID devices...
+ break;
+
+ case MSG_USB_LOGICAL_UNIT_CLASS_DP:
+ { //for USB logical unit class devices with Logical Unit Numnber
+ UINT8 Lun;
+
+#if TSE_USE_EDK_LIBRARY
+ Lun = ((DEVICE_LOGICAL_UNIT_DEVICE_PATH*)DevPath)->Lun;
+#else
+ Lun = ((LOGICAL_UNIT_DEVICE_PATH*)DevPath)->Lun;
+#endif
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_LOGICAL_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun);
+ }
+ break;
+
+ case MSG_USB_SATA_DP:
+ { // for USB SATA devices with Port Number
+ UINT16 PortNumber;
+ PortNumber = ((AMITSE_SATA_DEVICE_PATH*)DevPath)->HBAPortNumber;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_SATA_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PortNumber);
+ }
+ break;
+
+ case MSG_USB_ISCSI_DP:
+ { // for USB iSCSI devices with Logical Unit Number
+ UINT64 Lun;
+ Lun = ((AMITSE_ISCSI_DEVICE_PATH*)DevPath)->Lun;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_ISCSI_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun);
+ }
+ break;
+ }
+ }
+
+ DevPath = NextDevicePathNode(DevPath);
+ }
+
+ MemFreePointer((VOID **) &Format);
+ return BusText;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSBuildDevicePathName
+//
+// Description: function to build the bbs device path
+//
+// Input: CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSBuildDevicePathName( CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo )
+{
+ EFI_HANDLE Handle;
+ CHAR16 *BusText, *DevText;
+ UINT8 *StringDesc;
+ UINTN i;
+
+ Handle = *(VOID**)(&info->IBV1);
+
+ BusText = GetBusStr(Handle, index, HDDInfo);
+ DevText = GetDevStr(info->DeviceType);
+
+ if(BusText && DevText)
+ {
+ SPrint(String, MAX_DRIVE_NAME, L"%s %s", BusText, DevText);
+ }
+ else
+ {
+ StringDesc = (UINT8*)(UINTN)((info->DescStringSegment << 4) +
+ info->DescStringOffset);
+ if ( StringDesc != NULL )
+ {
+ for ( i = 0; (i < (MAX_DRIVE_NAME - 1)) && (StringDesc[i] != '\0'); i++ )
+ String[i] = (CHAR16)StringDesc[i];
+ String[i] = L'\0';
+ }
+ else
+ {
+ SPrint(String, MAX_DRIVE_NAME, L"%s %s", BusText ? BusText : L"Unknown", DevText ? DevText : L"Unknown");
+ }
+ }
+
+ MemFreePointer((VOID **)&BusText);
+ MemFreePointer((VOID **)&DevText);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateLegacyDevVariable
+//
+// Description:
+//
+// Input: UINT16 NoOfLegacyGroups
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups)
+{
+ VarSetNvramName( L"LegacyDev", &gLegacyDevGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &NoOfLegacyGroups, sizeof(NoOfLegacyGroups) );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSUpdateOrder
+//
+// Description: function to update Bbs device order
+//
+// Input: UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSUpdateOrder(UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer)
+{
+ UINT8 *pDevOrder;
+ UINT16 count = 0, *optionList = NULL, oldOption;
+ UINTN i,j,optionNumber;
+
+ *size = 0;
+
+ pDevOrder = VarGetVariable( VARIABLE_ID_BBS_ORDER, size );
+
+ *offset -= (sizeof(UINT32) + sizeof(UINT16));
+
+ count = gCurrLegacyBootData->LegacyDevCount;
+ *offset -= (UINT32)gCurrLegacyBootData->LegacyEntryOffset;
+ optionList = (UINT16 *)(pDevOrder + gCurrLegacyBootData->LegacyEntryOffset + sizeof(UINT32) + sizeof(UINT16));
+ optionNumber = *offset / sizeof(UINT16);
+
+ *offset = 0;
+ *buffer = (VOID *)pDevOrder;
+
+ oldOption = optionList[optionNumber];
+
+ if ( *newOption == oldOption )
+ return;
+
+ if(DISABLED_BOOT_OPTION == *newOption)
+ {
+ for(i = optionNumber; i < count; i++)
+ {
+ if((i+1) < count)
+ optionList[i] = optionList[i + 1];
+ else
+ optionList[i] = *newOption; // or DISABLED_BOOT_OPTION
+ }
+ }
+ else if(DISABLED_BOOT_OPTION == oldOption)
+ {
+ //Find newOption's position
+ for(i=0;i<count;i++)
+ {
+ if(*newOption == optionList[i])
+ break;
+ }
+
+ if(i < count)//New option found
+ {
+ //Move new option to the last of enabled devices
+ for(j=i; j<count; j++)
+ {
+ if( DISABLED_BOOT_OPTION != optionList[j+1])
+ optionList[j] = optionList[j+1];
+ else
+ {
+ optionList[j] = *newOption;
+ break;
+ }
+ }
+ }
+ else//New option not enabled
+ {
+ //Replace first disabled with new one
+ for(i=0;i<count;i++)
+ {
+ if(DISABLED_BOOT_OPTION == optionList[i])
+ break;
+ }
+ optionList[i] = *newOption;
+ }
+ }
+ else
+ {
+ optionList[optionNumber] = *newOption;
+ for(i=0;i<count;i++)
+ {
+ if(i == optionNumber)
+ continue;
+ if(*newOption == optionList[i])
+ {
+ optionList[i] = oldOption;
+ break;
+ }
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetUefiDevPathString
+//
+// Description: function to get the device string using device path for UEFI options.
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevPath
+//
+// Output: Device string.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetUefiDevPathString(EFI_DEVICE_PATH_PROTOCOL *DevPath)
+{
+ UINT8 PortNo;
+ CHAR16 *Format = NULL;
+ CHAR16 *BusText = NULL;
+ CHAR16 *DevText = NULL;
+ CHAR16 *String = NULL;
+
+ while( !(IsDevicePathEnd(DevPath)) )
+ {
+ if(MESSAGING_DEVICE_PATH == DevPath->Type)
+ {
+ switch(DevPath->SubType)
+ {
+ case MSG_ATAPI_DP:
+ PortNo = (((ATAPI_DEVICE_PATH*)DevPath)->PrimarySecondary<<1)|((ATAPI_DEVICE_PATH*)DevPath)->SlaveMaster;
+ switch(PortNo)
+ {
+ case 0:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_PRI_MAS));
+ break;
+ case 1:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_PRI_SLA));
+ break;
+ case 2:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SEC_MAS));
+ break;
+ case 3:
+ BusText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SEC_SLA));
+ break;
+ }
+ break;
+ //Later this may be extended for all devices.
+ case MSG_SCSI_DP:
+ { //Showing the SCSI device with Physical and Logical unit numbers
+ UINT16 PhyUnitNum, LogclUnitNum;
+ PhyUnitNum = ((SCSI_DEVICE_PATH*)DevPath)->Pun;
+ LogclUnitNum = ((SCSI_DEVICE_PATH*)DevPath)->Lun;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_SCSI_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PhyUnitNum, LogclUnitNum);
+ }
+ break;
+
+ case MSG_FIBRECHANNEL_DP:
+ {// showing Fibre channel with Logical unit number and WWN
+ UINT64 WWN,Lun;
+ WWN = ((FIBRECHANNEL_DEVICE_PATH*)DevPath)->WWN;
+ Lun = ((FIBRECHANNEL_DEVICE_PATH*)DevPath)->Lun;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_FIBRE_CHANNEL_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun, WWN);
+ }
+ break;
+
+ case MSG_1394_DP:
+ //For 1394 device support
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_1394_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format);
+ break;
+
+ case MSG_USB_DP:
+ {
+ // usb device with port number
+ PortNo = ((USB_DEVICE_PATH*)DevPath)->ParentPortNumber;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PortNo);
+ }
+ break;
+
+ case MSG_I2O_DP:
+ { // I2O device with Tid
+ UINT32 Tid;
+
+ Tid = ((AMITSE_I2O_DEVICE_PATH*)DevPath)->Tid;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_I20_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Tid);
+ }
+ break;
+
+ case MSG_INFINIBAND_DP: //Need to know what type of device is this..
+ { // InfiniBand device with Device Id
+ UINT64 DeviceId;
+
+ DeviceId = ((INFINIBAND_DEVICE_PATH*)DevPath)->DeviceId;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_INFINIBAND_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, DeviceId);
+ }
+ break;
+
+ case MSG_VENDOR_DP:
+ // for vendor specific device
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_VENDOR_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format);
+ break;
+
+ case MSG_MAC_ADDR_DP:
+ { // network device with mac address
+ UINT8 Mac[32];
+
+ MemCopy( Mac, (UINT8*)&(((AMITSE_MAC_ADDR_DEVICE_PATH*)DevPath)->MacAddress),32*sizeof(UINT8));
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_MAC_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Mac);
+ }
+
+ break;
+
+ case MSG_IPv4_DP:
+ { //IPv4 Device with Logical Port number
+ UINT16 LocalPort;
+
+ LocalPort = ((IPv4_DEVICE_PATH*)DevPath)->LocalPort;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_NETWORK_IPV4_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, LocalPort);
+ }
+ break;
+
+ case MSG_IPv6_DP:
+ { //IPv6 Device with Logical Port number
+ UINT16 LocalPort;
+
+ LocalPort = ((IPv6_DEVICE_PATH*)DevPath)->LocalPort;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_NETWORK_IPV6_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, LocalPort);
+ }
+
+ break;
+
+ case MSG_UART_DP:
+ { //UART device with Baud Rate
+ UINT64 BaudRate;
+
+ BaudRate = ((UART_DEVICE_PATH*)DevPath)->BaudRate;
+
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_UART_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, BaudRate);
+ }
+ break;
+
+ case MSG_USB_CLASS_DP:
+ { ////for UBS Class id specific devices.
+ UINT8 DeviceClass;
+
+ DeviceClass = ((USB_CLASS_DEVICE_PATH*)DevPath)->DeviceClass;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ switch(DeviceClass)
+ { //To show the type of device based on the class
+ case USB_PHY_DEV_CLASS:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_PHY_DP));
+ break;
+
+ case USB_MASS_DEV_CLASS:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_MASS_DP));
+ break;
+
+ default:
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_CLASS_DP));
+
+ }
+ SPrint(BusText, MAX_DRIVE_NAME, Format, DeviceClass);
+ }
+ break;
+
+ case MSG_USB_LOGICAL_UNIT_CLASS_DP:
+ { //for USB logical unit class devices with Logical Unit Numnber
+ UINT8 Lun;
+
+#if TSE_USE_EDK_LIBRARY
+ Lun = ((DEVICE_LOGICAL_UNIT_DEVICE_PATH*)DevPath)->Lun;
+#else
+ Lun = ((LOGICAL_UNIT_DEVICE_PATH*)DevPath)->Lun;
+#endif
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_LOGICAL_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun);
+ }
+ break;
+
+ case MSG_USB_SATA_DP:
+ { // for USB SATA devices with Port Number
+ UINT16 PortNumber;
+ PortNumber = ((AMITSE_SATA_DEVICE_PATH*)DevPath)->HBAPortNumber;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_SATA_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, PortNumber);
+ }
+ break;
+
+ case MSG_USB_ISCSI_DP:
+ { // for USB iSCSI devices with Logical Unit Number
+ UINT64 Lun;
+ Lun = ((AMITSE_ISCSI_DEVICE_PATH*)DevPath)->Lun;
+ BusText = (CHAR16 *)EfiLibAllocatePool(MAX_DRIVE_NAME * sizeof(CHAR16));
+ Format = HiiGetString(gHiiHandle, STRING_TOKEN(STR_USB_ISCSI_DP));
+ SPrint(BusText, MAX_DRIVE_NAME, Format, Lun);
+ }
+ break;
+ }
+ }
+
+ if(MEDIA_DEVICE_PATH == DevPath->Type)
+ {
+ switch(DevPath->SubType)
+ {
+ case MEDIA_HARDDRIVE_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_HDD));
+ break;
+
+ case MEDIA_CDROM_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_CDROM));
+ break;
+
+ case MEDIA_VENDOR_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_VENDOR));
+ break;
+
+ case MEDIA_FILEPATH_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_FILEPATH));
+ break;
+
+ case MEDIA_PROTOCOL_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_PROTOCOL));
+ break;
+
+ case MEDIA_FV_FILEPATH_DP:
+ DevText = HiiGetString(gHiiHandle, STRING_TOKEN(STR_FV_FILEPATH));
+ break;
+
+ }
+ }
+
+ DevPath = NextDevicePathNode(DevPath);
+ }
+
+ if(BusText && DevText)
+ {
+ String = (CHAR16 *)EfiLibAllocatePool((MAX_DRIVE_NAME+10) * sizeof(CHAR16));
+ SPrint(String, MAX_DRIVE_NAME, L"%s %s", BusText, DevText);
+
+ MemFreePointer((VOID **) &BusText);
+ MemFreePointer((VOID **) &DevText);
+ }
+
+ MemFreePointer((VOID **) &Format);
+
+ return String;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateBootVariables
+//
+// Description: Update the BootOrder,BBSOrder Cache From the NVRAM.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateBootVariables ()
+{
+ VarUpdateVariable(VARIABLE_ID_BOOT_ORDER);
+ VarUpdateVariable(VARIABLE_ID_BBS_ORDER);
+}
+
+//EIP70421 starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateDriverVariables
+//
+// Description: Update the DriverOrder Cache From the NVRAM.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateDriverVariables()
+{
+ VarUpdateVariable (VARIABLE_ID_DRIVER_ORDER);
+}
+//EIP70421 ends
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/Jpeg6.h b/EDK/MiniSetup/TseAdvanced/Jpeg6.h
new file mode 100644
index 0000000..6f873ff
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/Jpeg6.h
@@ -0,0 +1,123 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Jpeg6.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Jpeg6.h $
+//
+// 5 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 1/09/10 4:43a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 9/26/06 4:03p Madhans
+// JpegC Implimentation
+//
+// 1 8/01/06 8:03a Shirinmd
+// Files for JPEG decoding (C version)
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: jpeg6.h
+//
+// Description: Header file for jpeg6 image format related code
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _JPEG_6_H_
+#define _JPEG_6_H_
+
+#include "Mydefs.h"
+
+
+
+#pragma pack(1)
+
+typedef struct _AMI_TRUECOLOR_PIXEL_JPEG{
+ UINT8 Red;
+ UINT8 Green;
+ UINT8 Blue;
+ UINT8 Reserved;
+}AMI_TRUECOLOR_PIXEL_JPEG, *PAMI_TRUECOLOR_PIXEL_JPEG;
+
+#pragma pack()
+
+#define MKF_JPEG_YUV111_SUPPORT 1
+#define c_g_cb 5638 //; 0.34414 * 16384
+#define c_g_cr 11700 //; 0.71417 * 16384
+
+
+#define c1_16 8352 //;0.509795
+#define c3_16 9852 //;0.601344
+#define c5_16 14745 //;0.899976
+#define c7_16 41990 //;2.562915
+#define c1_8 8867 //;0.541196
+#define c3_8 21407 //;1.306562
+#define c1_4 11585 //;0.707196
+#define c1_sqrt2 11585 //;0.707106
+
+
+#endif //#ifndef _JPEG_6_H_
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/Logo.c b/EDK/MiniSetup/TseAdvanced/Logo.c
new file mode 100644
index 0000000..49920a0
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/Logo.c
@@ -0,0 +1,282 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Logo.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/Logo.c $
+//
+// 6 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 6/13/11 12:32p Rajashakerg
+// [TAG] EIP60910
+// [Category] New Feature
+// [Description] PNG image support in TSE.
+// [Files] LogoLib.h, AMITSE.sdl, CommonHelper.c, logo.c, png.c, png.h,
+// pnguncmp.c, TseAdvanced.cif
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 8/17/09 10:46a Presannar
+// Use proper tycasting for the parameters of fn ConvertGifToUgaBltWrapper
+// to avoid compiler warnings.
+//
+// 4 8/13/09 12:16p Blaines
+// Move Image support to binary module
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: logo.c
+//
+// Description: This file contains code for advanced logo support
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+extern LOGO_TYPE GetGifLogoType(UINT8 *ImageData);
+extern LOGO_TYPE GetJPEGLogoType(UINT8 *ImageData);
+extern LOGO_TYPE GetPCXLogoType(UINT8 *ImageData);
+extern LOGO_TYPE GetPNGLogoType(UINT8 *ImageData);
+LOGO_TYPE GetOEMLogoType(UINT8 *ImageData);
+
+extern EFI_STATUS ConvertBmpToUgaBltWrapper (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth );
+
+extern EFI_STATUS ConvertGifToUgaBltWrapper ( IN VOID *GifImage, IN UINTN GifImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth, OUT BOOLEAN *Animate );
+
+extern EFI_STATUS ConvertJPEGToUgaBltWrapper ( IN VOID *JPEGImage, IN UINT32 JPEGImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth, OUT UINT32 *punBufferWidth);
+
+extern EFI_STATUS ConvertPCXToUgaBltWrapper ( IN VOID *PCXImage, IN UINT32 PCXImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth) ;
+
+extern EFI_STATUS ConvertPNGToUgaBltWrapper ( IN VOID *PCXImage, IN UINT32 PCXImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth) ;
+
+extern EFI_STATUS ConvertOEMFormatToUgaBltWrapper ( IN VOID *OEMImage, IN UINT32 OEMImageSize, IN OUT VOID **UgaBlt,
+ IN OUT UINT32 *UgaBltSize, OUT UINT32 *Height, OUT UINT32 *Width, BOOLEAN * Animate);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetExtendedLogoType
+//
+// Description: function to get the type of extended logo
+//
+// Input: UINT8 *ImageData
+//
+// Output: LOGO_TYPE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+LOGO_TYPE GetExtendedLogoType(UINT8 *ImageData)
+{
+ if ( GIF_Logo == GetGifLogoType(ImageData))
+ return GIF_Logo;
+
+ if ( JPEG_Logo == GetJPEGLogoType(ImageData))
+ return JPEG_Logo;
+
+ if ( PCX_Logo == GetPCXLogoType(ImageData))
+ return PCX_Logo;
+
+ if ( PNG_Logo == GetPNGLogoType(ImageData))
+ return PNG_Logo;
+
+ if( OEM_Format_LOGO == GetOEMLogoType(ImageData))
+ return OEM_Format_LOGO;
+
+ return Unsupported_Logo;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertAdvancedImageToUgaBlt
+//
+// Description: Convert a advanced graphics image to a UGA blt buffer.
+//
+// Input: IN VOID *ImageData,
+// IN UINTN ImageSize,
+// IN OUT VOID **UgaBlt,
+// IN OUT UINTN *UgaBltSize,
+// OUT UINTN *Height,
+// OUT UINTN *Width,
+// OUT BOOLEAN *Animate
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+ConvertAdvancedImageToUgaBlt (
+ IN VOID *ImageData,
+ IN UINTN ImageSize,
+ IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize,
+ OUT UINTN *Height,
+ OUT UINTN *Width,
+ OUT BOOLEAN *Animate
+)
+{
+ UINTN LogoType;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ UINT32 Temp=0;
+
+
+ LogoType = GetExtendedLogoType(ImageData);
+ switch(LogoType)
+ {
+
+ case GIF_Logo:
+
+ Status = ConvertGifToUgaBltWrapper(
+ ImageData,
+ (UINT32)ImageSize,
+ UgaBlt,
+ (UINTN*)UgaBltSize,
+ (UINTN*)Height,
+ (UINTN*)Width,
+ Animate
+ );
+
+ break;
+
+ case JPEG_Logo:
+
+ Status = ConvertJPEGToUgaBltWrapper(
+ ImageData,
+ (UINT32)ImageSize,
+ UgaBlt,
+ (UINT32*)UgaBltSize,
+ (UINT32*)Height,
+ (UINT32*)&Temp,
+ (UINT32*)Width
+ );
+ break;
+
+ case PCX_Logo:
+
+ Status = ConvertPCXToUgaBltWrapper(
+ ImageData,
+ (UINT32)ImageSize,
+ UgaBlt,
+ (UINT32*)UgaBltSize,
+ (UINT32*)Height,
+ (UINT32*)Width
+ );
+ break;
+ case PNG_Logo:
+
+ Status = ConvertPNGToUgaBltWrapper(
+ ImageData,
+ (UINT32)ImageSize,
+ UgaBlt,
+ (UINT32*)UgaBltSize,
+ (UINT32*)Height,
+ (UINT32*)Width
+ );
+ break;
+
+ case OEM_Format_LOGO:
+
+ Status = ConvertOEMFormatToUgaBltWrapper(
+ ImageData,
+ (UINT32)ImageSize,
+ UgaBlt,
+ (UINT32*)UgaBltSize,
+ (UINT32*)Height,
+ (UINT32*)Width,
+ Animate
+ );
+ break;
+
+ default:
+ break;
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoLogoAnimate
+//
+// Description: function to Handle logo animation
+//
+// Input: CO_ORD_ATTRIBUTE Attribute,
+// INTN CoordinateX,INTN CoordinateY
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoLogoAnimate(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY)
+{
+ DoLogoAnimateWrapper(Attribute,CoordinateX,CoordinateY);
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/MyDefs.h b/EDK/MiniSetup/TseAdvanced/MyDefs.h
new file mode 100644
index 0000000..57261ef
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/MyDefs.h
@@ -0,0 +1,103 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/MyDefs.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/MyDefs.h $
+//
+// 5 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 7/08/09 3:34p Madhans
+// Coding Standards.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 9/26/06 4:03p Madhans
+// JpegC Implimentation
+//
+// 1 8/01/06 8:03a Shirinmd
+// Files for JPEG decoding (C version)
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: mydefs.h
+//
+// Description: Header file common definitions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _MYDEFS_H_
+#define _MYDEFS_H_
+
+#include "minisetup.h"
+#define memset MemSet
+#define memcpy MemCopy
+
+#define BOOL INTN
+#define BYTE unsigned char
+#define WORD UINT16
+#define DWORD UINT32
+
+
+#endif //#ifndef _MYDEFS_H_
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/TseAdvanced.c b/EDK/MiniSetup/TseAdvanced/TseAdvanced.c
new file mode 100644
index 0000000..f161ee9
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/TseAdvanced.c
@@ -0,0 +1,3962 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/TseAdvanced.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 69 $
+//
+// $Date: 9/05/14 2:39p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/TseAdvanced.c $
+//
+// 69 9/05/14 2:39p Premkumara
+// Moved GetSetDefaultsFromControlPtr() function from Uefi2.1\Hii.c to
+// TseAdvanced.c
+//
+// 68 8/28/14 9:39a Premkumara
+// [TAG] EIP172956
+// [Category] Bug Fix
+// [Severity:] Critical
+// [Symptom:] Build error is displayed when TSE_CLEAR_USERPW_WITH_ADMINPW
+// token is ON
+// [Root Cause] When we do clear password then with Admin password its
+// only clearing user password from cache not from NVRAM. But in ESA it
+// working fine
+// [Solution] In ClearUserPasswordPolicy in TseAdvanced.c, we just
+// clearing password from Cache not from NVRAM if save paswd to nvram
+// token ios ON, so added that feature.
+// [Files] TseAdvanced.c
+//
+// 67 8/28/14 9:28a Premkumara
+// [TAG] EIP170151
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] DisplayTextBox does not close before it returns.
+// [Root Cause] Text box was not clearing before showing message box or
+// info box.
+// [Solution] modified the code to clear the Text box before showing
+// message box or info box
+// [Files] TseAdvanced.c
+//
+// 66 8/28/14 6:48a Premkumara
+// [TAG] EIP93340
+// [Category] Improvement
+// [Description] - Defaults can be given to string type controls using tag
+// "Default = STRING_TOKEN(STR_DEFAULT_STRING)".
+// - New token TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL is introduced for
+// this support.
+// - Enabling this TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL token will
+// display default string mention in setup.
+// - On loading optimal defaults also string will load default mentioned
+// in default value tag.
+// [Files] AMITSE.sdl, HiiString21.c, TseAdvanced.c, MiniSetupExt.c, Hii.c
+//
+// 65 5/02/14 8:44a Premkumara
+// [TAG] EIP162981
+// [Category] Improvement
+// [Description] Configuring default Password through SDL token
+// [Files] AMITSE.sdl, CommonHelper.c, Minisetup.c, TseAdvanced.c
+//
+// 64 5/02/14 2:20a Premkumara
+// [TAG] EIP131553
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] SoftKbd clearance issue on selecting UEFI shell from Save
+// and Exit tab [when SoftKbd icon is selected]
+// [RootCause] TSE was deactivating the softkbd after clearing the
+// screen when we are selecting UEFI shell from Save and Exit tab
+// [when SoftKbd icon is selected].
+// [Solution] Modified the code to deactivate the softkbd before
+// clearing
+// the TSE screen when we are selecting UEFI shell from Save and Exit tab
+// [when SoftKbd icon is selected].
+// [Files] TseAdvanced.c
+//
+// 63 5/01/14 11:27p Arunsb
+// [TAG] EIP128948
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] TSE security code check failure for using uninitialized
+// variable "Action"
+// [RootCause] Action variable in TimeHanldeActionKeyMouse and
+// _PostPopupEditGetValues is not initialized
+// [Solution] Initialized Action variable.
+// [Files] Time.c, TseAdvanced.c
+//
+// 62 2/11/14 7:49p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 61 11/26/13 9:48a Premkumara
+// [TAG] EIP118342
+// [Category] Improvement
+// [Description] Show meaningful error message when HDD is locked after
+// reached maximum unlocking attempt.
+// [Files] TseAdvanced.c, CommonHelper.c, FakeToken.c, AmiTseStr.uni
+//
+// 60 11/26/13 1:31a Premkumara
+// [TAG] EIP118342
+// [Category] Improvement
+// [Description] Show meaningful error message when HDD is locked after
+// reached maximum unlocking attempt.
+// [Files] TseAdvanced.c, CommonHelper.c
+//
+// 59 11/06/13 1:26a Premkumara
+// [TAG] EIP128948
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] TSE security code check failure for using uninitialized
+// variable "Action"
+// [RootCause] Action variable in TimeHanldeActionKeyMouse and
+// _PostPopupEditGetValues is not initialized
+// [Solution] Initialized Action variable.
+// [Files] Time.c, TseAdvanced.c
+//
+// 58 10/07/13 3:06a Premkumara
+// Intergrated missed EIP130529 changes (sysAccessGuid variable in
+// LoadUserDefaultsSilently) to avoid build error
+//
+// 57 9/19/13 7:58a Arunsb
+// [TAG] EIP127375
+// [Category] Bug Fix
+// [Severity:] Critical
+// [Symptom:] Legacy boot doesn't work after UEFI Shell is launched from
+// LaunchAppHotkey menu. The system hangs
+// [Root Cause] If ShowPostMsgBoxEx is invoked through postmgr protcol
+// then gMsgBoxAction will be NULL initially,
+// so this time action is assigned and used.
+// ACTION_DATA *action = gMsgBoxAction; so accessing NULL pointer leads to
+// hang.
+// [Solution] gMsgBoxAction is created again inside ShowPostMsgBoxEx,
+// reassign gMsgBoxAction to action.
+// [Files] TseAdvanced.c
+//
+// 56 8/06/13 4:02a Premkumara
+// [TAG] EIP130529
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When entered into setup with User mode and On pressing
+// "Restore User Defaults" SystemAccess variable is loading and the user
+// mode is changes to Admin mode so the controls are editable
+// [RootCause] LoadUserDefaultsSilently() function is loading defaults
+// for all types of variable
+// [Solution] Skipping loading SystemAccess variable while loading
+// defaults for user default variable.
+// [Files] TseAdvanced.c, AMITSE.sdl, CommonHelper.c
+//
+// 55 5/23/13 3:44a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\UefiWapper20.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+// - TseAdvanced.c
+//
+// 54 5/22/13 10:22a Arunsb
+// [TAG] EIP122907
+// [Category] Improvement
+// [Description] For getting name value offset preserving page number
+// then it will be easy to find handle of the hii which published name
+// value
+//
+// 53 12/05/12 5:20a Arunsb
+// [TAG] EIP106749
+// [Category] New Feature
+// [Description] Message box can lock the computer if ConIn not present
+// [Files] TseAdvanced.c
+//
+// 52 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 40 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 50 10/10/12 11:22a Arunsb
+//
+// 49 10/10/12 11:21a Arunsb
+// Properly checked in the EIP98918
+//
+// 48 9/24/12 1:17a Premkumara
+// [TAG] EIP98918
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Restore User Defaults causes system hang
+// [Files] TseAdvanced.c
+//
+// 47 9/21/12 12:33p Premkumara
+// [TAG] EIP99092
+// [Category] Improvement
+// [Description] Tokenize the feature of flushing keyboard after every
+// key read
+// [Files] AMITSE.sdl, CommonHelper.c, TseAdvanced.c, Action.c
+//
+// 46 9/17/12 6:08a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 44 9/03/12 3:12a Premkumara
+// [TAG] EIP 96246
+// [Category] Improvement
+// [Description] Improvement of a boots override when firmware has a
+// BootNext variable
+// [Files] AMITSE.sdl, CommonHelper.c, FakeToken.c, AmiTSEStr.uni,
+// TseAdvanced.c
+//
+// 43 5/28/12 6:23a Rajashakerg
+// [TAG] EIP80873
+// [Category] Improvement
+// [Description] TSE Load/Save defaults without Messaaagebox.
+// [Files] TseElinks.h, Tseadvanced.c
+//
+// 42 5/24/12 9:00a Arunsb
+// [TAG] EIP90379
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] UefiBootFailHook asserts when it is trying to call
+// MsgBoxDestroy
+// [RootCause] Tried to free the NULL pointer
+// [Solution] Checked NULL before freeing
+// [Files] TseAdvanced.c and MessageBox.c
+//
+// 41 5/09/12 4:56p Premkumara
+// [TAG] EIP87117
+// [Category] Improvement
+// [Description] AMITSE should handle partial key support
+// [Files] TseAdvanced.c
+//
+// 40 2/02/12 1:15p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 39 1/13/12 1:22a Arunsb
+// [TAG] EIP80360
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDDSecurity module - Issue in login with TSE, Master
+// password disabled
+// [RootCause] Cache not updated
+// [Solution] Cache updated properly
+// [Files] Tseadvanced.c, special.c and uefi21wapper.c
+//
+// 38 12/08/11 12:30p Rajashakerg
+// Updated the file to overcome build errors when build for x32 mode.
+//
+// 37 12/01/11 7:16p Blaines
+// Fix build errors in Uefi2.0
+//
+// 36 11/30/11 1:28p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 35 11/30/11 12:00p Premkumara
+// [TAG] EIP75521
+// [Category] Improvement
+// [Description] Need to support interactive password controls
+// [Files] PopupPassword.c, PopupPassword.h, TsetAdvanced.c
+//
+// 34 11/30/11 12:25a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 33 11/16/11 11:21a Madhans
+// [TAG] EIP75736
+// [Category] Improvement
+// [Description] To avoid flicks when booting UEFI OS for seamless boot.
+// [Files] Boot.c
+// Tseadvanced.c
+//
+// 32 11/14/11 2:01p Blaines
+// Add function headers for the changes made in TSEAdvanced.c for EIP
+// 66860
+//
+// 31 11/13/11 12:50p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 30 11/10/11 7:25p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// Added new parameter to the function prototype DISPLAY_TEXT_KEY_VALIDATE
+//
+// Initialize textbox witih default value
+//
+// 29 11/10/11 12:51a Arunsb
+// [TAG] EIP67735
+// [Category] Improvement
+// [Description] Zeroing password buffers before freeing
+// [Files] mem.c, mem.h, popupedit.c, popuppassword.c and tseadvanced.c
+//
+// 28 10/31/11 9:41a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 27 10/19/11 3:52p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry. Add cursor
+// support.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c,
+// uefi20Wapper.c, PopupEdit.c
+//
+// 26 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 25 7/19/11 12:30p Arunsb
+// [TAG] EIP63895
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Same message "Save & reset" displayed twice
+// [RootCause] guidInfo->GuidFlags.GuidLaunchFilename condition also
+// executed after executing guidInfo->GuidFlags.GuidLaunchGuid condition.
+// [Solution] Made as any one condition will execute
+// [Files] Tseadvanced.c
+//
+// 24 6/30/11 4:12a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Driver health special controls handled.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 23 12/29/10 6:51a Mallikarjunanv
+// [TAG] EIP 49745
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Hangs on CP06 when Core is update to 4.6.4.1
+// [RootCause] It hangs on CP06 when go to SETUP if updated core to
+// 4.6.4.1 and added TSE source and X64 = 0.
+// [Solution] Fixed the Stack Frame corruption by passing NULL for Var
+// or Flags.
+// [Files] TseAdvanced.c
+//
+// 22 12/28/10 6:09p Mallikarjunanv
+// [TAG] EIP41615
+// [Category] New Feature
+// [Description] Added the file browser support for the Add boot option
+// reated controls
+// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c,
+// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c,
+// AddBootOption.c
+//
+// 21 12/28/10 12:54p Mallikarjunanv
+// [TAG] EIP 47260
+// [Category] Improvement
+// [Description] Updated with TSE_NVRAM_DEFAULTS_SUPPORT token name
+// [Files] TseAdvanced.sdl, TseAdvanced.c
+//
+// 20 12/24/10 1:15p Mallikarjunanv
+// [TAG] EIP 47932
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Screen changing to Normal TSE from GTSE if the boot fails
+// rom the selected boot option
+// [RootCause] Style Initilization is not done before BootLaunchFailed .
+// [Solution] Fixed by updating style Initilization BootLaunchFailed.
+//
+// [Files] TseAdvanced.c
+//
+// 19 12/22/10 5:28a Mallikarjunanv
+// [TAG] EIP47260
+// [Category] Improvement
+// [Description] To Build TSE sources without NVRAM module support.
+// [Files] TseAdvanced.c, TseAdvanced.mak, TseAdvanced.sdl
+//
+// 18 11/18/10 7:13p Blaines
+// [TAG] - EIP 47962
+// [Category]- Defect
+// [Symptom]- Post Manager's DisplayMsgBox displays a corrupted screen
+// When the French or Japanese langues are selected and a call is made to
+// DisplayMsgBox, the screen that is displayed is corrupted
+//
+// [Rootcause]
+// The bounding box area of the message box is drawn, which may not span
+// previous screen redraws.
+// Therefore, artifacts from previous screen displays may appear.
+// [Solution]- Clear the screen before drawing message box to clear
+// artifacts from previous screen redraws.
+// [Files] - TseAdvanced.c, AMIPostMgr.h,
+//
+// 17 9/29/10 1:36p Blaines
+// Function ShowPostMsgBoxEx was updated to allow a buttonless messages
+// box to be displayed without a legend.
+//
+// 16 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 33 8/31/10 11:32a Blaines
+// Fix for ShowPostProgress function not calling gAction.Destroy, casuing
+// system to appear to hang and to not be responsive to input.
+//
+// 32 8/10/10 7:13p Madhans
+// EIP 40555 : To avoid Compilation issues with Fareast Windows.
+//
+// 31 6/22/10 5:31a Mallikarjunanv
+// EIP:39102 - Handling Scrren corruption if Launching shell from file
+// system fails
+//
+// 30 6/14/10 7:08p Madhans
+// To keep the NVRAM defaults only for Aptio 4.x
+//
+// 29 6/08/10 5:13p Blaines
+// Fix for EIP #39416 - PostManagerDisplayProgress does not update
+// message.
+//
+// 28 5/19/10 4:11p Blaines
+// Added parameter error checking to the function ShowPostMsgBoxEx
+//
+// 27 4/22/10 6:21p Blaines
+// Fix build error when TSE_USE_AMI_EFI_KEYCODE_PROTOCOL token
+// enabled
+//
+// In function ShowPostMsgBoxEx, set property msgbox->Legend before
+// calling gMsgBox.Initialize.
+//
+// 26 4/20/10 6:15p Blaines
+// Add MessageBox Hotkey support
+//
+// 25 4/15/10 4:49p Blaines
+// In function ShowPostMsgBox,
+// check if pSelection is null before it attempts to use it.
+//
+// 24 4/07/10 6:24p Madhans
+// To Fix the build issue.
+//
+// 23 3/30/10 4:46p Blaines
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 22 3/26/10 6:12p Madhans
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 21 3/26/10 6:01p Madhans
+// Fix in Load Defaults from NVRAM Defaults, To make work for Runtime
+// pages. Before this fix it only work for Offline parsing Data and For
+// Runtime pages the defaults are broken.
+//
+// 20 3/23/10 5:11p Blaines
+// Add support for new PostManager Extentions
+//
+// 19 3/19/10 2:39p Madhans
+// Support to Load Defaults from NVRAM Defaults.
+//
+// 18 2/26/10 11:09a Madhans
+// to resove build errors;.
+//
+// 17 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 16 2/15/10 10:13p Madhans
+// For EDK Nt32 version
+//
+// 15 2/04/10 11:19p Madhans
+// Fix for Password with AMIKeyCode ON without EfiKey or Scancode support.
+//
+// 14 1/18/10 2:09a Mallikarjunanv
+// EIP-28501: Updated for Keyboard scancode as password. Added a new Token
+// SETUP_STORE_KEYCODE_PASSWORD to support the EFI key or Scan code as
+// password
+//
+// 13 1/09/10 4:51a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 12 10/30/09 9:47a Mallikarjunanv
+// EIP-28551 : Fixed TSE 2.0 Build error releated to
+// SETUP_STORE_EFI_KEY_PASSWORD and TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+//
+// 11 9/17/09 9:05a Sudhirv
+// EIP:25799 - Remove Load Driver Option from TSE 2.x as it will be
+// handled from Core
+//
+// 10 9/15/09 9:41a Sudhirv
+// updated with support for SETUP_OEM_SPECIAL_CONTROL_SUPPORT and the
+// support for Add Del boot option support
+//
+// 9 8/19/09 6:33p Madhans
+// IsToggleStateKey Function added
+//
+// 8 8/19/09 10:42a Mallikarjunanv
+// Fixed the issue regarding loading defaults by desabling the chipset
+// menu.
+//
+// 7 8/13/09 7:37a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 6 7/30/09 7:48a Mallikarjunanv
+// updated the code to move the exit page option elinks to Tse Binary
+//
+// 5 7/20/09 1:17p Mallikarjunanv
+// updated the return values
+//
+// 4 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 3 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 2 6/05/09 11:55a Blaines
+// Fix screen corruption for GTSE
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: TseAdvanced.c
+//
+// Description: This file contains code to handle the Advanced TSE Operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include "Special.h"
+#include "TseElinks.h"
+
+//////////////////////////////////////////////////
+/////// INTERNAL VARIABLE DECLARATION
+//////////////////////////////////////////////////
+///Exit Page options info. from Elink...
+extern EXIT_PAGE_OPTIONS gExitPageOptions[END_OF_EXIT_PAGE_OPTION_LIST];
+extern APPLICATION_DATA *gApp;
+extern UINTN gSaveUserMsgBox;
+extern UINTN gLoadUserMsgBox;
+extern UINTN gBootLaunchFailedMsgBox;
+extern UINTN gInvalidPasswordFailMsgBox;
+
+
+#define AMITSE_PRINT_SCREEN_PRESS_GUID \
+{ 0x71030b81, 0xf72, 0x4b48, 0xb5, 0xe8, 0xbc, 0xcd, 0x51, 0x78, 0x60, 0x9e }
+
+
+#define CONSTRUCT_DEFAULTS_FIRST_BOOT_GUID \
+{ 0xc5912ed9, 0x83c2, 0x4bff, 0x99, 0x36, 0x23, 0x1f, 0xeb, 0x85, 0xf3, 0xe8 }
+
+MSGBOX_DATA *gInfoBox = NULL;
+UINT32 gtempCurrentPage;
+//////////////////////////////////////////////////
+/////// INTERNAL FUNCTIONS DECLARATION
+//////////////////////////////////////////////////
+///Exit page options handling using Elinks...
+VOID HandleSaveAndExit(VOID);
+VOID HandleExitApplication(VOID);
+VOID HandleSaveAndReset(VOID);
+VOID HandleResetSys(VOID);
+VOID HandleSaveWithoutExit(VOID);
+VOID HandleLoadPreviousValues(VOID);
+VOID HandleLoadOptimalDefaults(VOID);
+VOID HandleSaveUserDefaults(VOID);
+VOID HandleRestoreUserDefaults(VOID);
+VOID HandleBootAddBootOption(VOID);
+VOID HandleDriverAddDriverOption(VOID);
+
+//EIP-41615: Start
+VOID HandleLaunchFileSystem(VOID);
+VOID HandleLaunchFileSystemDriver(VOID);
+//EIP-41615: End
+
+VOID SaveUserDefaults( VOID );
+VOID LoadUserDefaults( VOID );
+BOOLEAN CheckIsAllowedPasswordChar(CHAR16 Char);
+BOOLEAN CheckIsAllowedChar(CHAR16 Char);
+
+//////////////////////////////////////////////////
+/////// EXTERN FUNCTIONS DECLARATION
+//////////////////////////////////////////////////
+extern VOID *UefiCreateStringTemplate(UINT16 Token);
+extern EFI_STATUS ReadImageResource(EFI_HANDLE ImageHandle, EFI_GUID *pGuid, VOID **ppData, UINTN *pDataSize);
+extern BOOLEAN IsLoadSysteAccessOnUserDefault(VOID);
+extern BOOLEAN IsSupportDefaultForStringControl (VOID);
+EFI_STATUS GetSetDefaultsFromControlPtr(NVRAM_VARIABLE *optimalDefaultlist, NVRAM_VARIABLE *failSafeDefaultlist);
+UINTN GetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background);
+VOID OEMSpecialGotoSelect(UINT16 value);
+BOOLEAN IsShowPromptStringAsTitle(VOID);//EIP-116315 password window title string
+extern BOOLEAN TSEPwdSavetoNvram(VOID);
+
+typedef UINT16 VAR_SIZE_TYPE;
+#pragma pack(push)
+#pragma pack(1)
+typedef struct{
+ UINT32 signature;
+ VAR_SIZE_TYPE size;
+ UINT32 next:24;
+ UINT32 flags:8;
+// guid and name are there only if NVRAM_FLAG_DATA_ONLY is not set
+// UINT8 guid;
+// CHAR8 or CHAR16 name[...];
+// UINT8 data[...];
+// if NVRAM_FLAG_EXT_HEDER is set
+// UINT8 extflags;
+// UINT8 extdata[...];
+// VAR_SIZE_TYPE extsize;
+}NVAR;
+#pragma pack(pop)
+
+typedef struct {
+ UINT8 *NvramAddress;
+ UINTN NvramSize;
+ EFI_GUID* NvramGuidsAddress;
+ UINT8 *pEndOfVars, *pFirstVar;
+ INT16 NextGuid;
+ VAR_SIZE_TYPE LastVarSize;
+ NVAR *pLastReturned;
+ UINT8 Flags;
+} NVRAM_STORE_INFO;
+
+
+VOID NvInitInfoBuffer(IN NVRAM_STORE_INFO *pInfo, UINTN HeaderSize, UINT8 Flags);
+EFI_STATUS NvGetVariable(
+ IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize, OUT VOID *Data,
+ IN NVRAM_STORE_INFO *pInfo, OUT UINT8 *Flags
+);
+BOOLEAN IsTseLoadPasswordOnDefaults();
+
+#define NVRAM_STORE_FLAG_NON_VALATILE 1
+
+#define DEFAULTS_GUID {0x4599d26f, 0x1a11, 0x49b8, 0xb9, 0x1f, 0x85, 0x87, 0x45, 0xcf, 0xf8, 0x24}
+
+EFI_GUID DefaultsGuid = DEFAULTS_GUID;
+VOID SetDrvHealthHandleAndCtrlCount (UINT16);
+VOID DoDriverHealthOperation (CONTROL_INFO *, UINT16);
+BOOLEAN FlushKeysAfterRead(void);
+//EIP-96246 starts
+EFI_STATUS ShowBootOverrideSelectOption (VOID);
+BOOLEAN IsBootOverrideBootNextSupport (VOID);
+#define BOOT_OVERRIDE_OPTION_MENU_COUNT 3
+//EIP-96246 Ends
+
+#ifndef KEY_STATE_EXPOSED
+#define KEY_STATE_EXPOSED 0x40 //EIP-87117
+#endif
+
+//EIP 162981 Providing defaults through sdl tokens
+BOOLEAN DefaultSetupPwdAtFirstBootOnly (void);
+BOOLEAN TseDefaultSetupPasswordSupported(VOID);
+EFI_STATUS GetDefaultPassword (UINT32 PasswordInstalled, void **DefaultPassword);
+
+
+BOOLEAN TseLiteIsSpecialOptionList(CONTROL_DATA *ControlData)
+{
+ // For TSE Advanced we papulate and add the control dynamically.
+ // So it is not TSE lite Special control
+ // TSE Lite special controls are patched instad of removing and adding.
+ return FALSE;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootUpdateOrder
+//
+// Description: Function to update the boot/driver order
+//
+// Input: UINT16 *buffer
+// UINT32 *offset
+// UINTN *size
+// VOID **realBuffer
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BootUpdateOrder(UINT16 *buffer,UINT32 *offset,UINTN *size, VOID **realBuffer)
+{
+ UINTN i, j, optionNumber = *offset / sizeof(UINT16);
+ UINT16 index = *(UINT16 *)buffer;
+ UINT16 newOption = index;
+ UINT16 oldOption, *optionList;
+
+#if TSE_SEPERATE_EFI_LEGACY_OPTIONS
+ UINT16 *OrgOptionList;
+ OrgOptionList = EfiLibAllocateZeroPool( *size );
+ MemCopy( OrgOptionList, gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer, *size );
+#endif
+
+ *realBuffer = EfiLibAllocateZeroPool( *size );
+ if (NULL == *realBuffer)
+ {
+ return;
+ }
+ *offset = 0;
+ MemCopy( *realBuffer, gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer, *size );
+
+ optionList = (UINT16 *)*realBuffer;
+ oldOption = optionList[ optionNumber ];
+
+ if ( newOption == oldOption )
+ return;
+
+ if(DISABLED_BOOT_OPTION == newOption)
+ {
+ for (i = optionNumber, j = 0; i < gBootOptionCount; i++)
+ {
+ if ((i+1) < gBootOptionCount)
+ {
+ if ( (CheckHiddenforBootDriverOption (optionList [i + 1], BOOT_ORDER_OPTION)) && gLoadOptionHidden )
+ {
+ j ++;
+ continue;
+ }
+ optionList [i] = optionList [i + 1];
+ }
+ else
+ optionList [i-j] = newOption; // or DISABLED_BOOT_OPTION; boot order will be like active boot option
+ } //then hidden options, so hidden option will always maintain at same place(last positions).
+ }
+ else if (DISABLED_BOOT_OPTION == oldOption)
+ {
+ //Find newOption's position
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(newOption == optionList[i])
+ break;
+ }
+
+ if(i < gBootOptionCount)//New option found
+ {
+ //Move new option to the last of enabled devices
+ for(j=i; j<gBootOptionCount; j++)
+ {
+ if( DISABLED_BOOT_OPTION != optionList[j+1])
+ optionList[j] = optionList[j+1];
+ else
+ {
+ optionList[j] = newOption;
+ break;
+ }
+ }
+ }
+ else//New option not enabled
+ {
+ //Replace first disabled with new one
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(DISABLED_BOOT_OPTION == optionList[i])
+ break;
+ }
+ optionList[i] = newOption;
+ }
+#if TSE_SEPERATE_EFI_LEGACY_OPTIONS
+ ReGroupOptions(optionList,NULL);
+#endif
+ }
+ else
+ {
+ optionList[optionNumber] = newOption;
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(i == optionNumber)
+ continue;
+ if(newOption == optionList[i])
+ {
+ optionList[i] = oldOption;
+ break;
+ }
+ }
+#if TSE_SEPERATE_EFI_LEGACY_OPTIONS
+ ReGroupOptions(optionList,OrgOptionList);
+#endif
+ }
+#if TSE_SEPERATE_EFI_LEGACY_OPTIONS
+ MemFreePointer( (VOID **)&OrgOptionList );
+#endif
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DriverUpdateOrder
+//
+// Description: Function to update the driver order
+//
+// Input: UINT16 *buffer
+// UINT32 *offset
+// UINTN *size
+// VOID **realBuffer
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DriverUpdateOrder (UINT16 *buffer,UINT32 *offset,UINTN *size, VOID **realBuffer)
+{
+ UINTN i, j, optionNumber = *offset / sizeof(UINT16);
+ UINT16 index = *(UINT16 *)buffer;
+ UINT16 newOption = index;
+ UINT16 oldOption, *optionList;
+
+ *realBuffer = EfiLibAllocateZeroPool (*size);
+ if (NULL == *realBuffer)
+ {
+ return;
+ }
+ *offset = 0;
+
+ MemCopy (*realBuffer, gVariableList [VARIABLE_ID_DRIVER_ORDER].Buffer, *size);
+ optionList = (UINT16 *)*realBuffer;
+ oldOption = optionList [optionNumber];
+
+ if (newOption == oldOption)
+ return;
+
+ if (DISABLED_BOOT_OPTION == newOption)
+ {
+ for (i = optionNumber, j = 0; i < gDriverOptionCount; i++)
+ {
+ if ((i+1) < gDriverOptionCount)
+ {
+ if ( (CheckHiddenforBootDriverOption (optionList [i + 1], DRIVER_ORDER_OPTION)) && gLoadOptionHidden )
+ {
+ j ++;
+ continue;
+ }
+ optionList [i] = optionList [i + 1];
+ }
+ else
+ optionList [i-j] = newOption; // or DISABLED_BOOT_OPTION; boot order will be like active boot option
+ } //then hidden options, so hidden option will always maintain at same place(last positions).
+ }
+ else if (DISABLED_BOOT_OPTION == oldOption)
+ {
+ //Find newOption's position
+ for (i = 0; i < gDriverOptionCount; i ++)
+ {
+ if (newOption == optionList [i])
+ break;
+ }
+ if (i < gDriverOptionCount)//New option found
+ {
+ //Move new option to the last of enabled devices
+ for (j = i; j < gDriverOptionCount; j ++)
+ {
+ if (DISABLED_BOOT_OPTION != optionList [j+1])
+ optionList [j] = optionList [j+1];
+ else
+ {
+ optionList [j] = newOption;
+ break;
+ }
+ }
+ }
+ else//New option not enabled
+ {
+ //Replace first disabled with new one
+ for (i = 0; i < gDriverOptionCount; i ++)
+ {
+ if (DISABLED_BOOT_OPTION == optionList [i])
+ break;
+ }
+ optionList [i] = newOption;
+ }
+ }
+ else
+ {
+ optionList[optionNumber] = newOption;
+ for (i = 0; i < gDriverOptionCount; i ++)
+ {
+ if(i == optionNumber)
+ continue;
+ if(newOption == optionList[i])
+ {
+ optionList[i] = oldOption;
+ break;
+ }
+ }
+ }
+}
+
+/// functions to handle the exit page options
+VOID HandleSaveAndExit()
+{
+ gApp->Quit = SaveAndExit();
+}
+
+VOID HandleExitApplication()
+{
+ gApp->Quit = ExitApplication();
+}
+
+VOID HandleSaveAndReset()
+{
+ gApp->Quit = SaveAndReset();
+}
+
+VOID HandleResetSys()
+{
+ gApp->Quit = ResetSys();
+}
+
+VOID HandleSaveWithoutExit()
+{
+ SaveWithoutExit();
+}
+
+VOID HandleLoadPreviousValues()
+{
+ LoadPreviousValues( TRUE );
+}
+
+VOID HandleLoadOptimalDefaults()
+{
+ LoadOptimalDefaults();
+}
+
+VOID HandleSaveUserDefaults()
+{
+ SaveUserDefaults();
+}
+
+VOID HandleRestoreUserDefaults(VOID)
+{
+ LoadUserDefaults();
+}
+
+VOID HandleBootAddBootOption(VOID)
+{
+ TseBootAddBootOption();
+}
+
+//EIP70421 & 70422
+VOID HandleDriverAddDriverOption(VOID)
+{
+ TseDriverAddDriverOption();
+}
+
+// EIP-41615: Function to handle selection of the file system
+VOID HandleLaunchFileSystem(VOID)
+{
+ TseLaunchFileSystem(VARIABLE_ID_ADD_BOOT_OPTION);
+}
+
+//EIP70421 & 70422
+VOID HandleLaunchFileSystemDriver(VOID)
+{
+ TseLaunchFileSystem(VARIABLE_ID_ADD_DRIVER_OPTION);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SubMenuAmiCallback
+//
+// Description: Function implemented to handle the Exit page
+// options using Elinks.
+//
+// Input: UINT16 value - index of the exit page option
+//
+// Output: TRUE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _SubMenuAmiCallback( UINT16 value )
+{
+ UINT8 idx=0;
+
+ for(idx=0;idx<(sizeof(gExitPageOptions)/sizeof(EXIT_PAGE_OPTIONS));idx++)
+ {
+ if( gExitPageOptions[idx].OptIdx == END_OF_EXIT_PAGE_OPTION_LIST ) {
+ break;
+ }
+ else if(value == gExitPageOptions[idx].OptIdx) {
+ gExitPageOptions[idx].ExitPageCallBack();
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SubMenuHandleSpecialOp
+//
+// Description: Sub menu handle for Special operations.
+//
+// Input: Submenu data
+//
+// Output: Bool - Interpreted by the Caller.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _SubMenuHandleSpecialOp( SUBMENU_DATA *submenu )
+{
+ BOOLEAN status = FALSE;
+ BOOLEAN BootLaunchFailed = FALSE;
+ BOOLEAN StyleExitDone = FALSE;
+ UINT16 value;
+ GUID_INFO *guidInfo;
+ EFI_STATUS Status;
+
+// EIP:39412 - START
+ VOID *ScreenBuf;
+
+ //Save the screen buffer to restore later if required
+ ScreenBuf = SaveScreen();
+// EIP:39412 - END
+
+ value = SpecialGetValue( (CONTROL_DATA *)submenu, &guidInfo );
+ if ( value != (UINT16)-2 )
+ {
+ if ( guidInfo->GuidFlags.GuidLaunchCallback )
+ {
+ switch ( guidInfo->GuidKey )
+ {
+ case GUID_KEY_BOOT_NOW:
+ //EIP-96246 Starts
+ if ( !gResetRequired && IsBootOverrideBootNextSupport () )
+ {
+ UINT16 *pBootNext = NULL;
+ UINTN size = 0;
+ pBootNext = (UINT16 *)VarGetNvramName(L"BootNext", &gEfiGlobalVariableGuid, NULL, &size);
+ if ( pBootNext && (size == sizeof(UINT16)))//If BootNext Variable is present
+ {
+ Status = ShowBootOverrideSelectOption ();//EIP-96246 To show Override menu option for BootNext variable
+ if ( Status != EFI_SUCCESS )//Exit menu and retain in override menu
+ {
+ status = TRUE;
+ break;
+ }
+ }
+ if(pBootNext)
+ MemFreePointer((void **) &pBootNext);
+ }
+ //EIP-96246 Ends
+ if(!gResetRequired)
+ {
+ if(!gDoNotBoot)
+ {
+ gApp->ClearScreen = TRUE;
+ //EIP 75736
+ StyleExit();
+ if (gST->ConOut != NULL)
+ {
+ //Disable cursor, set desired attributes and clear screen
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, (EFI_BACKGROUND_BLACK | EFI_WHITE));
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+
+ BootLaunchBootNow( value, gShowAllBbsDev/*SETUP_SHOW_ALL_BBS_DEVICES*/ );
+ StyleInit();
+ }
+ }
+ else
+ {
+ gApp->Quit = SaveAndReset();
+ }
+ status = TRUE;
+ break;
+
+ case GUID_KEY_AMI_CALLBACK:
+ status = _SubMenuAmiCallback( value );
+ break;
+
+ case GUID_KEY_ERROR_MANAGER:
+ {
+ UefiSpecialGuidCallback(submenu->ControlData.ControlHandle, value, &guidInfo->GuidValue);
+ }
+ break;
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+ case GUID_KEY_OEM_CONTROL:
+ {
+ OEMSpecialGotoSelect(value);
+ break;
+ }
+#endif
+ case GUID_KEY_IDE_SECURITY:
+ {
+ UINTN size;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+
+
+ //Update mem copy of the IDE sec variable
+ size = 0;
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == ideSecConfig) {
+ break;
+ }
+
+ TSEIDEUpdateConfig(ideSecConfig, value);
+
+ VarSetValue( VARIABLE_ID_IDE_SECURITY, 0, size, ideSecConfig );
+ MemFreePointer((VOID **)&ideSecConfig);
+ }
+ break;
+ case GUID_KEY_BBS_ORDER:
+ {
+ BBSUpdateBootData(value);
+ VarSetValue(VARIABLE_ID_LEGACY_GROUP_INFO, 0, sizeof(UINT16), &(gCurrLegacyBootData->LegacyDevCount));
+ }
+ break;
+ //EIP 57661 Start
+ case GUID_KEY_DRIVER_HEALTH:
+ {
+ SetDrvHealthHandleAndCtrlCount (value);
+ break;
+ }
+ case GUID_KEY_DRV_HEALTH_CTRL_COUNT:
+ {
+ DoDriverHealthOperation ((VOID *)&((CONTROL_DATA *)submenu)->ControlData, value);
+ break;
+ }
+ //EIP 57661 End
+ default:
+ break;
+ }
+ }
+ else
+ {
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( guidInfo->GuidFlags.GuidLaunchGuid )
+ {
+ if(!gResetRequired)
+ {
+ if(!gDoNotBoot)
+ {
+ gApp->ClearScreen = TRUE;
+ //EIP 75736
+ StyleExit();
+ if (gST->ConOut != NULL)
+ {
+ //Disable cursor, set desired attributes and clear screen
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, (EFI_BACKGROUND_BLACK | EFI_WHITE));
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+ StyleExitDone = TRUE;
+ Status = BootLaunchGuid( &guidInfo->GuidValue );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ gApp->ClearScreen = TRUE;
+ status = TRUE;
+ }
+ else
+ BootLaunchFailed = TRUE;
+ }
+ }
+ else
+ {
+ gApp->Quit = SaveAndReset();
+ status = TRUE;
+ }
+ }
+
+ if (( guidInfo->GuidFlags.GuidLaunchFilename ) && (FALSE == status))
+ {
+ if(!gResetRequired)
+ {
+ if(!gDoNotBoot)
+ {
+ CHAR16 FileName[VARIABLE_NAME_LENGTH];
+ UINTN i = 0, j;
+ while(guidInfo->GuidName[i])
+ {
+ j=0;
+ for(;guidInfo->GuidName[i];i++)
+ {
+ if(L'|' == guidInfo->GuidName[i])
+ {
+ i++;
+ break;
+ }
+ FileName[j] = guidInfo->GuidName[i];
+ j++;
+ }
+ FileName[j] = 0;
+ if(!StyleExitDone){
+ gApp->ClearScreen = TRUE;
+ //EIP 75736
+ StyleExit();
+ if (gST->ConOut != NULL)
+ {
+ //Disable cursor, set desired attributes and clear screen
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, (EFI_BACKGROUND_BLACK | EFI_WHITE));
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+
+ StyleExitDone = TRUE;
+ }
+ Status = BootLaunchFilename( FileName );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ gApp->ClearScreen = TRUE;
+ status = TRUE;
+ BootLaunchFailed = FALSE;
+ break;
+ }else
+ BootLaunchFailed = TRUE;
+ }
+ //BootLaunchFailed = TRUE;
+ }
+ }
+ else {
+ gApp->Quit = SaveAndReset();
+ status = TRUE;
+ }
+ }
+
+ // EIP:47932 - Start
+ if(StyleExitDone)
+ StyleInit();
+ // EIP:47932 - End
+
+// EIP:39412 - START
+ if ( BootLaunchFailed ){
+
+ //Restore the Original screen before boot launch
+ RestoreScreen( ScreenBuf );
+ CallbackShowMessageBox( (UINTN)gBootLaunchFailedMsgBox, MSGBOX_TYPE_OK );
+ }
+ else {
+ //In case Boot Launch not failed, free the saved screen buffer
+ MemFreePointer((VOID **) &ScreenBuf);
+ }
+// EIP:39412 - END
+ }
+ }
+
+
+
+
+
+ return status;
+
+}
+
+#ifdef TSE_FOR_APTIO_4_50
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitApplicationData
+//
+// Description: function to initialize the application data
+//
+// Input: EFI_HANDLE ImageHandle
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitApplicationData(EFI_HANDLE ImageHandle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION || TSE_FOR_64BIT
+ VOID *pSection;
+ UINTN SectionSize;
+ EFI_GUID dataGuid = MINI_SETUP_DATA_GUID;
+
+ Status=ReadImageResource(ImageHandle,&dataGuid,&pSection,&SectionSize);
+ if ( EFI_ERROR( Status ) ) {
+ return Status;
+ }
+ gApplicationData = (UINT8 *)pSection + sizeof(EFI_GUID);
+#else
+#ifdef USE_DEPRICATED_INTERFACE
+
+ // Read in the data files from the GUIDed section
+ Status = LoadGuidedDataDriverLib( gImageHandle, dataGuid, &gApplicationData );
+ if ( EFI_ERROR( Status ) )
+ {
+ return Status;
+ }
+#else
+#ifndef STANDALONE_APPLICATION
+ gApplicationData = (UINT8 *)&_SetupPackage;
+#else
+ gApplicationData = (UINT8 *)&DummySetupData;
+#endif //#ifndef STANDALONE_APPLICATION
+#endif //#ifdef USE_DEPRICATED_INTERFACE
+#endif //#if APTIO_4_00 || SETUP_USE_GUIDED_SECTION || TSE_FOR_64BIT
+
+ return Status;
+}
+
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadUserDefaultsSilently
+//
+// Description: Function to load the user set defaults Silently
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadUserDefaultsSilently(VOID)
+{
+ NVRAM_VARIABLE *nvramVar, *tmpPtr;
+ UINTN i = 0;
+ UINT8 *buffer;
+ UINT16 size;
+ UINT32 count;
+//EIP-98918 Starts
+ VARIABLE_INFO *varInfo = NULL;
+ EFI_GUID sysAccessGuid = SYSTEM_ACCESS_GUID;
+
+ VARIABLE_INFO *InnerLoopvarInfo = NULL;
+ UINT32 InnerLoop;
+ BOOLEAN MatchFound = FALSE;
+//EIP-98918 Ends
+ nvramVar = &gVariableList [VARIABLE_ID_USER_DEFAULTS];
+ if ( ( nvramVar->Size == 0 ) || ( nvramVar->Buffer == NULL ) )
+ return;
+
+ buffer = nvramVar->Buffer;
+ count = *(UINT32 *)buffer;
+ buffer += sizeof(UINT32);
+
+ for ( i = 0; i < count; i++ )
+ {
+ varInfo = VarGetVariableInfoIndex (*(UINT32 *)buffer);//EIP-98918
+ tmpPtr = &gVariableList[ *(UINT32 *)buffer ];
+
+ if ( IsLoadSysteAccessOnUserDefault() ) //EIP-130529 Skip loading SYSTEM_ACCESS variable for user defaults
+ {
+ if ( !EfiStrCmp(varInfo->VariableName, L"SystemAccess") && EfiCompareGuid(&sysAccessGuid, &(varInfo->VariableGuid)) )//EIP-UserDefault - Skip to load SystemAccess variable on pressing Restore User Defaults
+ {
+ buffer += sizeof(UINT32);
+ size = *(UINT16 *)buffer;
+ buffer += sizeof(UINT16);
+ buffer += (sizeof (EFI_GUID) + sizeof (CHAR16) * VARIABLE_NAME_LENGTH); //Move to next variable
+ buffer += size;
+ continue;
+ }
+ }
+
+ buffer += sizeof(UINT32);
+ size = *(UINT16 *)buffer;
+ buffer += sizeof(UINT16);
+
+//EIP-98918 Starts
+ if (
+ (size == tmpPtr->Size) &&
+ (!MemCmp (&varInfo->VariableGuid, buffer, sizeof (EFI_GUID) )) &&
+ (!EfiStrCmp (varInfo->VariableName, (CHAR16 *)(buffer + sizeof (EFI_GUID)) ))
+ )
+ {
+ buffer += (sizeof (EFI_GUID) + sizeof (CHAR16) * VARIABLE_NAME_LENGTH);
+ MemCopy (tmpPtr->Buffer, buffer, size);
+ }
+ else //If any variable deleted then order wont be same, so trying in all possible variable and loading the user defaults
+ {
+ MatchFound = FALSE;
+ for (InnerLoop = 0; InnerLoop < gVariables->VariableCount; InnerLoop ++)
+ {
+ InnerLoopvarInfo = VarGetVariableInfoIndex (InnerLoop);
+ if ( NULL != InnerLoopvarInfo)
+ {
+ if (
+ (size == InnerLoopvarInfo->VariableSize) &&
+ (!MemCmp (&InnerLoopvarInfo->VariableGuid, buffer, sizeof(EFI_GUID))) &&
+ (!EfiStrCmp (InnerLoopvarInfo->VariableName, (CHAR16 *)(buffer + sizeof (EFI_GUID)) ))
+ )
+ {
+ buffer += (sizeof(EFI_GUID)+ sizeof(CHAR16) * VARIABLE_NAME_LENGTH);
+ tmpPtr = &gVariableList [InnerLoop];
+ MemCopy (tmpPtr->Buffer, buffer, size);
+ MatchFound = TRUE;
+ break;
+ }
+ }
+ }
+ if (FALSE == MatchFound)
+ {
+ SETUP_DEBUG_TSE ("\nERROR : Variable %s has been modified so skipping the USER default loading for this variable alone.", varInfo->VariableName );
+ buffer += (sizeof(EFI_GUID)+ sizeof(CHAR16) * VARIABLE_NAME_LENGTH);
+ }
+ }
+//EIP-98918 Ends
+ buffer += size;
+ }
+ LoadedUserDefaultsHook();
+ gResetRequired = TRUE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadUserDefaults
+//
+// Description: Function to load the user set defaults
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadUserDefaults( VOID )
+{
+
+ if ( CallbackShowMessageBox( (UINTN)gLoadUserMsgBox, MSGBOX_TYPE_YESNO ) != MSGBOX_YES )
+ return;
+
+ LoadUserDefaultsSilently();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveUserDefaultsSilently
+//
+// Description: Function to save the user set defaults Silently
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveUserDefaultsSilently(VOID)
+{
+ NVRAM_VARIABLE *nvramVar, *tmpPtr;
+ UINT32 i,count;
+ UINT8 *buffer;
+ VARIABLE_INFO *varInfo = NULL;
+
+ nvramVar = &gVariableList[ VARIABLE_ID_USER_DEFAULTS ];
+ if ( ( nvramVar->Size != 0 ) || ( nvramVar->Buffer != NULL ) )
+ MemFreePointer( (VOID **)&(nvramVar->Buffer) );
+
+ nvramVar->Size = sizeof(UINT32);
+ count = 0;
+ for ( i = 0; i < gVariables->VariableCount; i++ ) {
+ if ( (i == VARIABLE_ID_USER_DEFAULTS) ||
+ (i == VARIABLE_ID_ERROR_MANAGER) ||
+ (i == VARIABLE_ID_BOOT_ORDER) ||
+ (i == VARIABLE_ID_BBS_ORDER) ||
+ (i == VARIABLE_ID_BOOT_MANAGER) ||
+ (i == VARIABLE_ID_BOOT_NOW))
+ continue;
+ nvramVar->Size += sizeof(UINT32) + sizeof(UINT16) + sizeof (EFI_GUID) + (sizeof (CHAR16) * VARIABLE_NAME_LENGTH) + gVariableList[ i ].Size;
+ count++;
+ }
+
+ buffer = EfiLibAllocateZeroPool( nvramVar->Size );
+ if ( buffer == NULL )
+ return;
+
+ nvramVar->Buffer = buffer;
+
+ *(UINT32 *)buffer = count;
+ buffer += sizeof(UINT32);
+
+ for ( i = 0, tmpPtr = gVariableList; i < gVariables->VariableCount; i++, tmpPtr++ )
+ {
+ if ( (i == VARIABLE_ID_USER_DEFAULTS) ||
+ (i == VARIABLE_ID_ERROR_MANAGER) ||
+ (i == VARIABLE_ID_BOOT_ORDER) ||
+ (i == VARIABLE_ID_BBS_ORDER) ||
+ (i == VARIABLE_ID_BOOT_MANAGER) ||
+ (i == VARIABLE_ID_BOOT_NOW))
+ continue;
+ *(UINT32 *)buffer = i;
+ buffer += sizeof(UINT32);
+ *(UINT16 *)buffer = (UINT16)tmpPtr->Size;
+ buffer += sizeof(UINT16);
+
+ varInfo = VarGetVariableInfoIndex (i);
+ MemCopy (buffer, &varInfo->VariableGuid, sizeof (EFI_GUID));
+ buffer += sizeof (EFI_GUID);
+
+ EfiStrCpy ((CHAR16 *)buffer, varInfo->VariableName);
+// MemCopy( buffer, varInfo->VariableName, sizeof(CHAR16) * VARIABLE_NAME_LENGTH );
+ buffer += sizeof(CHAR16) * VARIABLE_NAME_LENGTH;
+
+ MemCopy( buffer, tmpPtr->Buffer, tmpPtr->Size );
+ buffer += tmpPtr->Size;
+ }
+
+ VarSetNvram( VARIABLE_ID_USER_DEFAULTS, nvramVar->Buffer, nvramVar->Size );
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveUserDefaults
+//
+// Description: Function to save the user specified defaults
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveUserDefaults( VOID )
+{
+
+ if ( CallbackShowMessageBox( (UINTN)gSaveUserMsgBox, MSGBOX_TYPE_YESNO ) != MSGBOX_YES )
+ return;
+
+ SaveUserDefaultsSilently();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetANSIEscapeCode
+//
+// Description: Return Size of Escape Code and gets the FG,BGColor.
+//
+// Input: CHAR16 *String,
+// UINT8 *Bold,
+// UINT8 *Foreground,
+// UINT8 *Background
+//
+// Output: UINTN - Escape code length (in CHAR16), 0 if not an escape code
+// Bold, Forground, Background - Filled with -1 if value not found in Escape Code
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN GetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background)
+{
+ CHAR16 *TempStr;
+ UINTN i;
+ BOOLEAN Bld=FALSE,Fg=FALSE;
+ UINT8 Num=0xff;
+
+ //Is ESC Code
+ if((String[0]==L'\x1b')&&(String[1]==L'['))
+ {
+ TempStr = &String[2];
+
+ // ESC [ x ; x x ; x x m = Color esc code format
+ // 0 1 2 3 4 5 6 7 8 9
+ // Check till Code m or Upto 10 char
+
+ for(i=2;(*TempStr!=L'm')&&(i<10);i++,TempStr++)
+ {
+ if(*TempStr == L';')
+ {
+ if(!Bld)
+ {
+ *Bold = Num;
+ Num = 0xFF;
+ Bld = TRUE;
+ }
+ else if(!Fg)
+ {
+ *Foreground = Num;
+ Num = 0xFF;
+ Fg = TRUE;
+ }
+ }
+ else
+ {
+ if(Num==0xFF)
+ Num =(UINT8)(*TempStr-L'0');
+ else
+ Num = (Num*10)+(UINT8)(*TempStr-L'0');
+ }
+ if(TempStr[1]==L'm')
+ *Background=Num;
+ }
+ if(*TempStr==L'm')
+ return (TempStr-String);
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SkipEscCode
+//
+// Description: function to perform the esc key operation
+//
+// Input: CHAR16 *string
+//
+// Output: string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *SkipEscCode(CHAR16 *String)
+{
+ CHAR16 *TempString;
+ UINTN i=0,j=0;
+
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == String) {
+ return NULL;
+ }
+ // Check For escape Code and remove that from the string
+ TempString = StrDup(String);
+ while(String[i])
+ {
+ if((String[i] == 0x001b) && (String[i+1] == L'[')) // ESC Code
+ {
+ while(String[i] != L'm')i++;
+ i++;
+ }
+ TempString[j] = String[i];
+ i++; j++;
+ }
+ TempString[j]=0;
+
+ return TempString;
+}
+static UINT8 result = (UINT8)-1;
+static CALLBACK_MESSAGEBOX gCbMsgBox = { { CALLBACK_TYPE_MESSAGEBOX, sizeof(CALLBACK_MESSAGEBOX) }, 0 };
+
+VOID _CallbackMsgboxEx( VOID *container, VOID *object, VOID *cookie )
+{
+ if ( (cookie != NULL) && ( ((CALLBACK_MESSAGEBOX*)cookie)->Header.Type == CALLBACK_TYPE_MESSAGEBOX) )
+ result = (UINT8)(((CALLBACK_MESSAGEBOX*)cookie)->Result);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _CallbackGetValueEx
+//
+// Description: Callback function to get the message box return value
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: Message box return value
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _CallbackGetValueEx( MSGBOX_DATA *msgbox )
+{
+ ACTION_DATA *action = gMsgBoxAction;
+
+ result = (UINT8)-1;
+ gMsgBox.SetCallback( msgbox, NULL, _CallbackMsgboxEx, &gCbMsgBox );
+
+ while ( result == (UINT8)-1 )
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gMsgBox.Draw( msgbox );
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ gMsgBox.HandleAction( msgbox, action );
+ DoRealFlushLines();
+ }
+
+ return result;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMsgBoxEx
+//
+// Description: Function to display the message box
+//
+// Input: CHAR16 *MsgBoxTitle,
+// CHAR16 *Message,
+// UINT8 MsgBoxType,
+// UINT8 *pSelection
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostMsgBoxEx(
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN MSGBOX_EX_CATAGORY MsgBoxExCatagory,
+ IN UINT8 MsgBoxType,
+ IN UINT16 *OptionPtrTokens,
+ IN UINT16 OptionCount,
+ IN AMI_POST_MGR_KEY *HotKeyList,
+ IN UINT16 HotKeyListCount,
+ OUT UINT8 *MsgBoxSel,
+ OUT AMI_POST_MGR_KEY *OutKey
+)
+{
+ static AMI_IFR_MSGBOX MsgBox = { 0, 0, 0, INVALID_HANDLE, 0 };
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 retValue = (UINT8)-1;
+ MSGBOX_DATA *msgbox = NULL;
+ CONTROL_INFO dummy;
+ ACTION_DATA *action = gMsgBoxAction;
+ UINT16 i = 0;
+
+ if (NULL == gST->ConIn)
+ return EFI_NOT_READY;
+
+ if(Title == NULL || Message == NULL ||
+ //Note: Messagebox should not require a legend
+ /*((Legend == NULL ) && (MsgBoxType == MSGBOX_TYPE_NULL)) ||*/
+ ((MsgBoxType == MSGBOX_TYPE_CUSTOM) && (OptionPtrTokens == NULL)) ||
+ ((OptionCount > 0) && (OptionPtrTokens == NULL)) ||
+ ((HotKeyListCount > 0) && (HotKeyList == NULL)))
+ return EFI_INVALID_PARAMETER;
+
+ if((MsgBoxType == MSGBOX_TYPE_CUSTOM) && (OptionCount > MSGBOX_MAX_OPTIONS))
+ return EFI_UNSUPPORTED ;
+
+ MsgBox.Title = HiiChangeString(gHiiHandle, MsgBox.Title, Title);
+ MsgBox.Text = HiiChangeString(gHiiHandle, MsgBox.Text, Message);
+
+ if(!gApp)
+ {
+ Status = gAction.Create( &gMsgBoxAction );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+ action = gMsgBoxAction; //EIP127375, If NULL while initialization then this assignment will be helpful
+ }
+
+
+ Status = gMsgBox.Create( (void**)&msgbox );
+ if ( EFI_ERROR( Status ) )
+ return retValue;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+ dummy.ControlPtr = (VOID*)&MsgBox ; //data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ msgbox->MsgBoxCatagory = (MsgBoxExCatagory & (~MSGBOX_EX_ATTRIB_CLEARSCREEN)) ;
+
+ msgbox->Legend = StrDup (Legend); //EIP-88918
+ if (OptionCount) //EIP 90379
+ {
+ msgbox->PtrTokens = EfiLibAllocateZeroPool (sizeof (UINT16) * OptionCount);
+ if (NULL == msgbox->PtrTokens)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ MemCopy (msgbox->PtrTokens, OptionPtrTokens, sizeof (UINT16) * OptionCount);
+ }
+ else
+ {
+ msgbox->PtrTokens = NULL;
+ }
+// msgbox->PtrTokens = OptionPtrTokens;
+ msgbox->OptionCount = OptionCount ;
+
+ Status = gMsgBox.Initialize( msgbox, &dummy );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ gMsgBox.SetType( msgbox, MsgBoxType );
+
+ //*MsgBoxSel = (UINT8)_CallbackGetValueEx( msgbox );
+
+ result = (UINT8)-1;
+ gMsgBox.SetCallback( msgbox, NULL, _CallbackMsgboxEx, &gCbMsgBox );
+
+//EIP:47962 Start
+ if((MsgBoxExCatagory & MSGBOX_EX_ATTRIB_CLEARSCREEN) == MSGBOX_EX_ATTRIB_CLEARSCREEN)
+ ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+//EIP:47962 End
+
+ while ( result == (UINT8)-1 )
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gMsgBox.Draw( msgbox );
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ gMsgBox.HandleAction( msgbox, action );
+ DoRealFlushLines();
+
+ if(HotKeyList!=NULL && HotKeyListCount>0)
+ {
+ for(i=0 ; i<HotKeyListCount; i++)
+ {
+ if( (HotKeyList[i].Key.ScanCode == action->Input.Data.AmiKey.Key.ScanCode ) &&
+ (HotKeyList[i].Key.UnicodeChar == action->Input.Data.AmiKey.Key.UnicodeChar) &&
+ (TseCheckShiftState( action->Input.Data.AmiKey, HotKeyList[i].KeyShiftState) ) )
+ {
+ // Verify passed argument is not NULL before attempting to assign to it
+ if(OutKey != NULL)
+ {
+ OutKey->Key.ScanCode = action->Input.Data.AmiKey.Key.ScanCode ;
+ OutKey->Key.UnicodeChar = action->Input.Data.AmiKey.Key.UnicodeChar;
+
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+ OutKey->KeyShiftState = (UINT32)action->Input.Data.AmiKey.KeyState.KeyShiftState ;
+#else
+ OutKey->KeyShiftState = 0 ;
+#endif
+ }
+ goto Done;
+
+ }
+
+ }
+
+ }
+ else
+ {
+ if((msgbox->MsgBoxType == MSGBOX_TYPE_NULL) && (action ->Input.Type == ACTION_TYPE_KEY))
+ goto Done;
+
+ }
+
+ }
+
+ if((result != -1) && (MsgBoxSel != NULL))
+ *MsgBoxSel = (UINT8) result;
+
+
+Done:
+ gMsgBox.Destroy( msgbox, TRUE );
+
+
+ if(!gApp)
+ {
+ gAction.Destroy( gMsgBoxAction, TRUE );
+ gMsgBoxAction = NULL ;
+ }
+
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostProgress
+//
+// Description: Function to display the progress bar
+//
+// Input: IN UINT8 ProgressBoxState - Progress bar state
+// IN CHAR16 *Title - Progress bar title
+// IN CHAR16 *Message, - Progress bar message string
+// IN CHAR16 *Legend, - Progress bar legend string
+// IN UINTN Percent, - Percent Complete (0 - 100)
+// IN OUT VOID **Handle, - HANDLE. Valid Handle for update and close
+// OUT AMI_POST_MGR_KEY *OutKey - Out Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostProgress(
+ IN UINT8 ProgressBoxState,
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN UINTN Percent,
+ IN OUT VOID **Handle,
+ OUT AMI_POST_MGR_KEY *OutKey
+)
+{
+ static AMI_IFR_MSGBOX MsgBox = { 0, 0, 0, INVALID_HANDLE, 0 };
+ EFI_STATUS Status = EFI_SUCCESS;
+ MSGBOX_DATA *msgbox = NULL;
+ CONTROL_INFO dummy;
+ ACTION_DATA *action=NULL;
+ UINT16 MessageToken = 0 ;
+ MEMO_DATA *memo = NULL;
+
+ switch(ProgressBoxState)
+ {
+ case AMI_PROGRESS_BOX_INIT:
+
+ Status = gMsgBox.Create( &msgbox );
+ if ( EFI_ERROR( Status ) )
+ return EFI_UNSUPPORTED;
+
+ MsgBox.Title = HiiChangeString(gHiiHandle, STRING_TOKEN(STR_MSGBOX_PROGRESS_TITLE), Title);
+ MsgBox.Text = HiiChangeString(gHiiHandle, STRING_TOKEN(STR_MSGBOX_PROGRESS_TEXT), Message);
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+ dummy.ControlPtr = (VOID*)&MsgBox ; //data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ msgbox->MsgBoxCatagory = MSGBOX_EX_CATAGORY_NORMAL ;
+
+ Status = gMsgBox.Initialize( msgbox, &dummy );
+
+ if ( EFI_ERROR( Status ) )
+ {
+ gMsgBox.Destroy( msgbox, TRUE );
+ return Status;
+ }
+
+ *Handle = msgbox ;
+ msgbox->Legend = Legend ;
+ msgbox->Percent = 0 ;
+ gMsgBox.SetType( msgbox, MSGBOX_TYPE_PROGRESS );
+
+ gMsgBox.Draw( msgbox );
+ DoRealFlushLines();
+
+ break;
+
+ case AMI_PROGRESS_BOX_UPDATE:
+
+ if(Handle == NULL)
+ return EFI_UNSUPPORTED;
+
+ msgbox = *Handle ;
+ msgbox->Percent = Percent ;
+
+//EIP:39416 START
+ if(Message != NULL)
+ {
+ memo = msgbox->Memo;
+ MessageToken = HiiChangeString(gHiiHandle, MessageToken, Message);
+ UefiSetSubTitleField((VOID *)memo->ControlData.ControlPtr, MessageToken);
+ }
+//EIP:39416 END
+
+ gMsgBox.Draw( msgbox );
+ DoRealFlushLines();
+
+ //Output the key
+ if (! EFI_ERROR( gAction.Create( &action ) ) )
+ {
+ if(!EFI_ERROR(gAction.GetAction( action )))
+ {
+ OutKey->Key.ScanCode = action->Input.Data.AmiKey.Key.ScanCode ;
+ OutKey->Key.UnicodeChar = action->Input.Data.AmiKey.Key.UnicodeChar;
+
+ #if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+ OutKey->KeyShiftState = action->Input.Data.AmiKey.KeyState.KeyShiftState ;
+ #else
+ OutKey->KeyShiftState = 0 ;
+ #endif
+ }
+ Status = gAction.Destroy(action, TRUE);
+ }
+ break;
+
+ case AMI_PROGRESS_BOX_CLOSE:
+ msgbox = *Handle ;
+ gMsgBox.Destroy( msgbox, TRUE );
+ //restore the screen
+ break;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMsgBox
+//
+// Description: Function to display the message box
+//
+// Input: CHAR16 *MsgBoxTitle,
+// CHAR16 *Message,
+// UINT8 MsgBoxType,
+// UINT8 *pSelection
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostMsgBox(IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection)
+{
+ static AMI_IFR_MSGBOX MsgBox = { 0, 0, 0, INVALID_HANDLE, 0 };
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 Selection;
+
+ MsgBox.Title = HiiChangeString(gHiiHandle, MsgBox.Title, MsgBoxTitle);
+ MsgBox.Text = HiiChangeString(gHiiHandle, MsgBox.Text, Message);
+
+ if(!gApp)
+ {
+ Status = gAction.Create( &gMsgBoxAction );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+ }
+
+ Selection = CallbackShowMessageBox((UINTN)&MsgBox, MsgBoxType);
+
+ if(!gApp)
+ {
+ gAction.Destroy( gMsgBoxAction, TRUE );
+ gMsgBoxAction = NULL;
+ }
+
+ if(pSelection!=NULL)
+ *pSelection = Selection;
+
+ return Status;
+}
+
+#define PADDING 8
+#define GUTTER 2
+#define BRACKET 1
+UINT16 gPostLabelMargin = 0 ;
+extern EFI_STATUS _CBPopupStringEdit(VOID *container, VOID *object, VOID *cookie);
+extern UINT8 res ;
+extern CALLBACK_VARIABLE gPopupEditCb ;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PostEditCallback
+//
+// Description: Callback function for text entry popup
+//
+// Input: VOID *container, VOID *object, VOID *cookie
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PostEditCallback(VOID *container, VOID *object, VOID *cookie)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+/*
+ if(cookie!=NULL)
+ {
+ res=0;
+ }
+ else
+ res=1;
+*/
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PostEditDraw
+//
+// Description: Function to draw text entry edit box
+//
+// Input: POPUPEDIT_DATA *popup
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PostEditDraw( POPUPEDIT_DATA *popup )
+{
+ UINT16 Length = 0 ;
+ BOOLEAN bShadow = StyleGetShadowSupport() ;
+
+ //DrawWindow( popup->Left, popup->Top, popup->Width, popup->Height, (UINT8)(popup->BGColor | popup->FGColor) , FALSE, FALSE );
+
+ if ( popup->Title != NULL )
+ {
+ Length = (UINT16)TestPrintLength( popup->Title ) / (NG_SIZE);
+ DrawStringWithAttribute( popup->Left - Length - GUTTER, popup->Top, popup->Title, (popup->ControlActive?EFI_WHITE:popup->FGColor) | popup->BGColor );
+ }
+
+ Length = (UINT16)UefiGetMaxValue(popup->ControlData.ControlPtr);
+ DrawStringWithAttribute( popup->Left, popup->Top, L"[", (popup->ControlActive?EFI_WHITE:popup->FGColor) | popup->BGColor );
+ DrawStringWithAttribute( popup->Left+Length+1 , popup->Top, L"]", (popup->ControlActive?EFI_WHITE:popup->FGColor) | popup->BGColor );
+ if(popup->ControlActive)
+ DrawWindow( popup->Left+1, popup->Top, Length, popup->Height, (UINT8)(EFI_BLACK | popup->FGColor) , FALSE, FALSE );
+
+ return gControl.Draw( popup );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PostPopupEditDraw
+//
+// Description: Function to draw text entry popup window
+//
+// Input: POPUPEDIT_DATA *PopupEdit
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PostPopupEditDraw( POPUPEDIT_DATA *PopupEdit )
+{
+ EFI_STATUS Status;
+ CHAR16 *text = NULL, *newText = NULL;
+ CHAR16 *line;
+ UINT16 pos, height,i,ii=0;;
+
+
+ text = StrDup(PopupEdit->Text);
+
+ Status = _PostEditDraw( PopupEdit );
+ if(EFI_ERROR(Status))
+ return Status;
+
+ // clear out old wrapped string
+ for ( pos = ii; pos < PopupEdit->Height-2; pos++ )
+ DrawStringWithAttribute( PopupEdit->Left+1, PopupEdit->Top + pos, PopupEdit->EmptyString, PopupEdit->FGColor | PopupEdit->BGColor );
+
+ newText = StringWrapText( text, PopupEdit->Width-1, &height );
+ if ( newText != text )
+ MemFreePointer( (VOID **)&text );
+
+ line = newText;
+
+ for ( pos = ii; pos < PopupEdit->Height; pos++ )
+ {
+ CHAR16 save;
+
+ text = line;
+ if ( *line == L'\0' )
+ break;
+
+ while ( ( *line != L'\n' ) &&( *line != L'\r' ) && ( *line != L'\0' ) )
+ line++;
+
+ save = *line;
+ *line = L'\0';
+ i=0;
+ while( (text[i] != L'\0') && (PopupEdit->Chr !=0x0 ) )
+ {
+// if(text[i] != L' ') //all chars should be treated the same
+ text[i] = PopupEdit->Chr;
+ i++;
+ }
+
+ if(PopupEdit->ControlActive)
+ DrawStringWithAttribute( PopupEdit->Left+1, PopupEdit->Top + pos, text, EFI_WHITE | EFI_BLACK );
+ else
+ DrawStringWithAttribute( PopupEdit->Left+1, PopupEdit->Top + pos, text, PopupEdit->FGColor | PopupEdit->BGColor );
+
+ if ( ( *line = save ) != L'\0' )
+ {
+ line++;
+ if ( ( *line == L'\r' ) || ( *line == L'\n' ) )
+ line++;
+ }
+ }
+ MemFreePointer( (VOID **)&newText );
+
+ if ( pos < height )
+ height = pos;
+
+ PopupEdit->DisplayLines = height;
+ FlushLines( 0, 24 );
+ //FlushLines( PopupEdit->Top, PopupEdit->Top + PopupEdit->Height );
+ return EFI_SUCCESS;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PostPopupEditGetValues
+//
+// Description: Function to draw text entry popup window
+//
+// Input: POPUP_DATA *popup,
+// POPUPEDIT_DATA *editList,
+// TEXT_INPUT_TEMPLATE *InputData,
+// UINT16 ItemCount,
+// DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+//
+// Output: UINTN - 0/1 (success/abort)
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _PostPopupEditGetValues(
+ POPUP_DATA *popup,
+ POPUPEDIT_DATA *editList,
+ TEXT_INPUT_TEMPLATE *InputData,
+ UINT16 ItemCount,
+ DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+)
+{
+ EFI_STATUS Status;
+ POPUPEDIT_DATA *ptrEdit=NULL;
+ CONTROL_ACTION Action = ControlActionUnknown;
+ ACTION_DATA *action=NULL ;
+ UINT16 i=0, Length=0, CurPos=0;
+ UINT16 count = 0;
+ res = (UINT8)-1;
+
+
+ if(!gApp)
+ {
+ Status = gAction.Create( &action );
+ if ( EFI_ERROR( Status ) )
+ {
+ res=0;
+ goto Done;
+ }
+ } else {
+ action = gApp->Action;
+ }
+
+
+ gPopup.Draw( popup );
+
+ //1. Position Child items
+ for ( i = 0; i < ItemCount; i++)
+ {
+ Length = (UINT16)TestPrintLength( editList[i].Title ) / (NG_SIZE);
+ editList[i].Top = popup->Top+1+i ;
+ editList[i].Left = popup->Left + gPostLabelMargin ;
+ editList[i].Height = 1 ;
+ }
+
+
+
+ res = (UINT8)-1;
+
+ while ( res == (UINT8)-1 )
+ {
+ //2. Clear the action
+ if ( action->Input.Type != ACTION_TYPE_NULL ) {
+ gAction.ClearAction( action );
+ }
+
+ //3. Draw the controls
+ gPopup.Draw( popup );
+
+ ptrEdit = editList;
+
+ for ( i = 0; i < ItemCount; i++, ptrEdit++)
+ {
+ _PostPopupEditDraw( ptrEdit );
+ }
+
+ FlushLines( popup->Top-2, popup->Top + popup->Height );
+ DoRealFlushLines();
+
+ //4. Get the action
+ Status = gAction.GetAction( action );
+ if( Status != EFI_SUCCESS ) {
+ continue;
+ }
+
+ //5. Set the count to control the active item
+ if (action->Input.Type == ACTION_TYPE_KEY)
+ {
+ Action = MapControlKeysHook(action->Input.Data.AmiKey) ;
+
+ switch(Action)
+ {
+ case ControlActionHome:
+ count = 0;
+ break;
+
+ case ControlActionEnd:
+ count = ItemCount-1;
+ break;
+
+ case ControlActionNextUp:
+ if (count > 0 )
+ count--;
+ break;
+
+ case ControlActionNextSelection:
+ case ControlActionNextDown:
+ if (count < ItemCount-1 )
+ count++;
+ break;
+ /*
+ case ControlActionSelect:
+ count++;
+ if(count >= ItemCount)
+ res=0;
+ break;
+ */
+ case ControlActionAbort:
+ res=1;
+ break;
+ }
+ }
+
+ ptrEdit = editList;
+
+ //6. Scan Items, Set Active Status and handle the action
+ for ( i = 0; i < ItemCount; i++, ptrEdit++)
+ {
+ if(count == i)
+ {
+ //Handle the action ONLY for the active item
+ ptrEdit->ControlActive = TRUE ;
+
+ //Check filter key, skip the character/Action if required
+ if( (action->Input.Data.AmiKey.Key.UnicodeChar) &&
+ (Action != ControlActionBackSpace) &&
+ (Action != ControlActionAbort) &&
+ //(Action != ControlActionSelect) &&
+ (Action != ControlActionNextSelection) &&
+ (Action != ControlActionUnknown)
+ /* (action->Input.Data.AmiKey.Key.UnicodeChar != 0x20 )*/ )
+ {
+
+ if(InputData[i].FilterKey == TSE_FILTER_KEY_NUMERIC)
+ {
+ if(!CharIsNumeric(action->Input.Data.AmiKey.Key.UnicodeChar))
+ continue ;
+ }
+ else if(InputData[i].FilterKey == TSE_FILTER_KEY_ALPHA)
+ {
+ if(!CharIsAlpha(action->Input.Data.AmiKey.Key.UnicodeChar))
+ continue ;
+ }
+ else if(InputData[i].FilterKey == TSE_FILTER_KEY_ALPHANUMERIC)
+ {
+ if(!CharIsAlphaNumeric(action->Input.Data.AmiKey.Key.UnicodeChar))
+ continue ;
+ }
+ else if((InputData[i].FilterKey == TSE_FILTER_KEY_CUSTOM) && (ValidateKeyFunc!=NULL))
+ {
+ if(!(ValidateKeyFunc(i, action->Input.Data.AmiKey.Key.UnicodeChar, ptrEdit->Text)))
+ continue ;
+ }
+ }
+
+ gPopupEdit.HandleAction( ptrEdit, action );
+ CurPos = (UINT16)EfiStrLen(ptrEdit->Text)+1 ;
+ gST->ConOut->SetAttribute ( gST->ConOut, ptrEdit->FGColor | ptrEdit->BGColor );
+ gST->ConOut->SetCursorPosition( gST->ConOut,
+ ptrEdit->Left + CurPos, ptrEdit->Top );
+
+ if(CurPos <= ptrEdit->TextWidth)
+ {
+ gST->ConOut->EnableCursor(gST->ConOut, TRUE);
+ }
+ else
+ {
+ gST->ConOut->EnableCursor(gST->ConOut, FALSE);
+ }
+
+
+ }
+ else
+ {
+ ptrEdit->ControlActive = FALSE ;
+ }
+
+ }
+
+ if(Action == ControlActionSelect)
+ {
+ count++;
+
+ if(count >= ItemCount)
+ {
+ res=0;
+ }
+ }
+
+ Action = ControlActionUnknown ;
+
+ }
+
+Done:
+ if(!gApp)
+ {
+ gAction.Destroy( action, TRUE );
+ action = NULL ;
+ }
+
+
+ return res;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: ShowPostTextBox
+//
+// Description: Function to display text entry interface
+//
+//
+// Input: IN VOID *HiiHandle,
+// IN UINT16 TitleToken,
+// IN TEXT_INPUT_TEMPLATE *InputData,
+// IN UINT16 ItemCount,
+// IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+//
+// Output: EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostTextBox(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN TEXT_INPUT_TEMPLATE *InputData,
+ IN UINT16 ItemCount,
+ IN DISPLAY_TEXT_KEY_VALIDATE FilterKeyFunc)
+{
+
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 Token=0, i=0, Length=0, MaxLabelWidth=0, MaxControlWidth=0;
+ UINT8 retValue = (UINT8)-1;
+ VOID *OriginalPopupEditDraw = NULL ;
+ CHAR16 *Text=NULL;
+ VOID *IFRString ;
+ CONTROL_INFO dummy;
+
+ POPUP_DATA *popup = NULL ;
+ POPUPEDIT_DATA *PopupEditList=NULL, *ptrEdit=NULL;
+ CALLBACK_VARIABLE *PopupEditCb=NULL, *ptrCb=NULL ;
+ CONTROL_INFO *dummys=NULL, *ptrDummy=NULL;
+ EFI_TPL OrgTPL;
+ BOOLEAN PreviousCursorState = gST->ConOut->Mode->CursorVisible;
+
+ if(HiiHandle == NULL)
+ {
+ return EFI_UNSUPPORTED ;
+ }
+
+ Status = gPopup.Create( &popup );
+ if ( EFI_ERROR( Status ) )
+ {
+ return Status;
+ }
+
+ // this *MUST* be run a EFI_TPL_APPLICATION
+ OrgTPL = gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT
+ gBS->RestoreTPL( EFI_TPL_APPLICATION );
+
+ PopupEditList = EfiLibAllocateZeroPool( sizeof(POPUPEDIT_DATA) * ItemCount);
+ PopupEditCb = EfiLibAllocateZeroPool( sizeof(CALLBACK_VARIABLE) * ItemCount);
+ dummys = EfiLibAllocateZeroPool( sizeof(CONTROL_INFO) * ItemCount);
+
+ ptrEdit = PopupEditList;
+ ptrDummy = dummys ;
+ ptrCb = PopupEditCb ;
+
+ IFRString = UefiCreateSubTitleTemplate(TitleToken);
+ //((EFI_IFR_STRING*)IFRString)->MaxSize = 10 ;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlPtr = (VOID*)IFRString;
+ dummy.ControlHandle = HiiHandle;
+ dummy.ControlType = CONTROL_TYPE_POPUP_STRING;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+
+ Status = gPopup.Initialize( popup, &dummy );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ SetControlColorsHook( NULL, NULL , NULL, NULL , NULL, NULL ,
+ NULL , NULL, NULL,NULL ,
+ NULL,NULL ,NULL,&(popup->FGColor),&(popup->BGColor) );
+
+ popup->Border = TRUE ;
+ popup->Title = HiiGetString(HiiHandle, TitleToken);
+ popup->Style = POPUP_STYLE_BBS ;
+
+ if ( popup->Title == NULL )
+ {
+ Status = EFI_UNSUPPORTED ;
+ goto Done;
+ }
+
+
+ for ( i = 0; i < ItemCount; i++, ptrEdit++, ptrDummy++, ptrCb++)
+ {
+
+ if((InputData[i].Value == NULL) || (InputData[i].MaxSize < 1 ))
+ {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ // Create PopupEdit Control
+ Status = gPopupEdit.Create( &((POPUPEDIT_DATA *)ptrEdit) );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ MemSet( ptrDummy, sizeof(CONTROL_INFO), 0 );
+ ptrDummy->ControlPtr = (VOID*)UefiCreateStringTemplate(InputData[i].ItemToken);
+ ptrDummy->ControlHandle = HiiHandle;
+ ptrDummy->ControlType = CONTROL_TYPE_POPUP_STRING;
+ ptrDummy->ControlFlags.ControlVisible = TRUE;
+ ((EFI_IFR_STRING*)ptrDummy->ControlPtr)->MaxSize = InputData[i].MaxSize ;
+
+ //Set the text, caller may want to display default value
+ gPopupEdit.SetText(ptrEdit, InputData[i].Value);
+ gPopupEdit.SetType( ptrEdit, InputData[i].Hidden?POPUPEDIT_TYPE_PASSWORD:POPUPEDIT_TYPE_STRING );
+
+ // Initialize PopupEdit Control
+ Status = gPopupEdit.Initialize( ptrEdit, ptrDummy ) ;
+
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ ptrEdit->Border = FALSE ;
+ ptrEdit->Style = POPUP_STYLE_NORMAL ;
+
+ gPopupEdit.SetCallback( ptrEdit, NULL, _PostEditCallback, ptrCb );
+
+ // Item width = PromptStringLength + "[" + ControlWidth +"]"
+
+ //Get maximum label width
+ Length = (UINT16)TestPrintLength( ptrEdit->Title ) / (NG_SIZE);
+ if(Length > MaxLabelWidth)
+ MaxLabelWidth = Length ;
+
+
+ //Get maximum control width
+ Length = (UINT16)UefiGetMaxValue(ptrEdit->ControlData.ControlPtr);
+ if(Length > MaxControlWidth)
+ MaxControlWidth = Length ;
+ }
+
+ //popup->width = MaxLabelWidth + GUTTER + "[" + MaxControlWidth + "]"
+ popup->Width = MaxLabelWidth + GUTTER + BRACKET + MaxControlWidth + BRACKET ;
+ popup->Width += PADDING ;
+
+ Length = (UINT16)TestPrintLength( popup->Title ) / (NG_SIZE);
+
+ //Check if the title exceeds the popup window width
+ if(Length > popup->Width)
+ {
+ //Adjust the popup window width
+ popup->Width = Length + PADDING ;
+ //Set the label margin
+ gPostLabelMargin = (popup->Width - (MaxLabelWidth + GUTTER + MaxControlWidth))/2 + MaxLabelWidth ;
+ }
+ else
+ {
+ //Set the label margin
+ gPostLabelMargin = MaxLabelWidth + GUTTER + PADDING/2;
+ }
+
+ //Set the popup window height
+ popup->Height = ItemCount + 2 ;
+
+ //Check screen overflow
+ if( (popup->Width > gMaxCols - 2) ||
+ (popup->Height > gMaxRows - 2) )
+ {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ // Save gPopupEdit.Draw (It may be an override function)
+ OriginalPopupEditDraw = gPopupEdit.Draw ;
+
+ // Override gPopupEdit.Draw with our functiion (It will be called by the PopupEdit control)
+ gPopupEdit.Draw = _PostPopupEditDraw ;
+
+ gST->ConOut->EnableCursor(gST->ConOut, TRUE);
+ gST->ConOut->SetAttribute ( gST->ConOut, popup->FGColor | popup->BGColor );
+
+ // Launch the textbox and get the values.
+ retValue = (UINT8)_PostPopupEditGetValues( popup, PopupEditList, InputData, ItemCount, FilterKeyFunc );
+
+ gST->ConOut->EnableCursor(gST->ConOut, PreviousCursorState);
+
+ // Restore gPopupEdit.Draw to the original
+ gPopupEdit.Draw = OriginalPopupEditDraw ;
+
+
+ if(retValue == 0)
+ {
+ for ( i = 0; i < ItemCount; i++)
+ {
+ if(InputData[i].Value == NULL)
+ {
+ // Allocate space for the user entered value
+ //EntryData[i].Value = EfiLibAllocateZeroPool( (PopupEditCb[i].Length+1) * sizeof(CHAR16) );
+
+ //if(EntryData[i].Value == NULL)
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ // Get the user entered value
+ EfiStrCpy( InputData[i].Value, PopupEditList[i].Text );
+ //EfiStrCpy( InputData[i].Value, PopupEditCb[i].Data );
+ }
+ }
+
+Done:
+
+ gPopupEdit.Destroy( PopupEditList, TRUE );//EIP-170151 Destroy text box before message box
+
+ // Free allocated init data
+
+ MemFreePointer((VOID**)&PopupEditCb);
+ MemFreePointer((VOID**)&dummys);
+ gPopup.Destroy( popup, TRUE );
+
+ if (gApp != NULL) {
+ gApp->CompleteRedraw = TRUE ; //CompleteRedraw;
+ gApp->OnRedraw = SUBMENU_COMPLETE_REDRAW;
+ }
+
+ gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT
+ gBS->RestoreTPL( OrgTPL );
+
+ if (res == 1) {
+ Status = EFI_ABORTED;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DisplayInfoCancelTimer
+//
+// Description: Timer notify fucntion
+//
+// Input: EFI_EVENT Event
+// VOID *Context
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DisplayInfoCancelTimer( EFI_EVENT Event, VOID *Context )
+{
+ if ( gInfoBox != NULL )
+ gMsgBox.Destroy( gInfoBox, TRUE );
+
+ gInfoBox = NULL;
+
+ TimerStopTimer( &Event );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowInfoBox
+//
+// Description: fucntiont to display the information box
+//
+// Input: CHAR16 *InfoBoxTitle,
+// CHAR16 *Message,
+// UINTN TimeLimit,
+// EFI_EVENT *RetEvent)
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowInfoBox(IN CHAR16 *InfoBoxTitle, IN CHAR16 *Message, IN UINTN TimeLimit, EFI_EVENT *RetEvent)
+{
+ EFI_STATUS Status;
+ static AMI_IFR_MSGBOX msgbox = { 0, 0, 0, INVALID_HANDLE, 0 };
+ CONTROL_INFO dummy;
+
+ msgbox.Title = HiiChangeString(gHiiHandle, msgbox.Title, InfoBoxTitle);
+ msgbox.Text = HiiChangeString(gHiiHandle, msgbox.Text, Message);
+
+ Status = gMsgBox.Create( &gInfoBox );
+ if ( EFI_ERROR( Status ) )
+ return 1;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+
+ dummy.ControlHandle = INVALID_HANDLE;
+ dummy.ControlPtr = (VOID*)(UINTN) &msgbox;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ gMsgBox.Initialize( gInfoBox, &dummy );
+
+ gMsgBox.SetType( gInfoBox, MSGBOX_TYPE_NULL );
+ gMsgBox.Draw( gInfoBox );
+
+ if ( TimeLimit != 0 )
+ {
+ UINT32 EventType = EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL; //|EFI_EVENT_NOTIFY_WAIT, EFI_EVENT_NOTIFY_SIGNAL|
+
+ Status = gBS->CreateEvent(
+ EventType,
+ EFI_TPL_CALLBACK,
+ _DisplayInfoCancelTimer,
+ NULL,
+ RetEvent
+ );
+
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = gBS->SetTimer( *RetEvent, TimerRelative, MultU64x32((UINT64)TIMER_ONE_SECOND, TimeLimit) );
+
+ if ( EFI_ERROR( Status ) )
+ TimerStopTimer( RetEvent );
+ }
+
+ return Status;
+}
+
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionReadKeyWithAMIKeyCode
+//
+// Description: fucntion to read the a key using AMI Key Code Protocol
+//
+// Input: AMI_EFI_KEY_DATA *pAmiKey,
+// UINT64 Timeout
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionReadKeyWithAMIKeyCode( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout )
+{
+ EFI_STATUS Status;
+ EFI_STATUS StatusFlush;
+ EFI_EVENT EventList[2] = { NULL, NULL };
+ UINTN Count = 1, Index = 1;
+ AMI_EFI_KEY_DATA KeyFlush;
+
+ AMI_EFIKEYCODE_PROTOCOL *pKeyCodeProtocol;
+ Status = gBS->HandleProtocol(gST->ConsoleInHandle, &gAmiEfiKeycodeProtocolGuid, (void*)&pKeyCodeProtocol);
+ if (EFI_ERROR(Status)) return Status;
+
+ if ( Timeout )
+ {
+ EventList[0] = pKeyCodeProtocol->WaitForKeyEx;
+
+ Status = TimerCreateTimer( &EventList[1], NULL, NULL, TimerRelative, Timeout, EFI_TPL_CALLBACK );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Count++;
+
+ gBS->WaitForEvent( Count, EventList, &Index );
+
+ TimerStopTimer( &EventList[1] );
+
+ if ( Index == 1 )
+ return EFI_NOT_READY;
+ }
+
+ Status = pKeyCodeProtocol->ReadEfikey( pKeyCodeProtocol, pAmiKey );
+ ////EIP-87117 If it Partial Key make the Status as Error to ignore
+ // the Partial Key.
+ if((pAmiKey->KeyState.KeyToggleState & KEY_STATE_EXPOSED) == KEY_STATE_EXPOSED) {
+ if( (!EFI_ERROR( Status )) && (pAmiKey->Key.ScanCode==0) && (pAmiKey->Key.UnicodeChar==0)) {
+ Status = EFI_NOT_READY;
+ }
+ }
+
+ if ( ! EFI_ERROR( Status ) && FlushKeysAfterRead())//EIP 99022 :check for the FLUSH_KEYS_AFTER_READ token before flushing the keys
+ {
+ do
+ {
+ StatusFlush = pKeyCodeProtocol->ReadEfikey( pKeyCodeProtocol, &KeyFlush );
+ ////EIP-87117 If it Partial Key make the Status as Error to ignore
+ // the Partial Key.
+ if((KeyFlush.KeyState.KeyToggleState & KEY_STATE_EXPOSED) == KEY_STATE_EXPOSED) {
+ if( (!EFI_ERROR( Status )) && (KeyFlush.Key.ScanCode==0) && (KeyFlush.Key.UnicodeChar==0)) {
+ StatusFlush = EFI_NOT_READY;
+ }
+ }
+ } while ( ! EFI_ERROR( StatusFlush ) );
+
+ }
+
+ return Status;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionReadKey
+//
+// Description: fucntion to handle the read key action
+//
+// Input: AMI_EFI_KEY_DATA *pAmiKey,
+// UINT64 Timeout
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionReadKey( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout )
+{
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+ return ActionReadKeyWithAMIKeyCode( pAmiKey, Timeout );
+#else
+ return _ActionReadKey( pAmiKey, Timeout );
+#endif
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AMIReadKeyStroke
+//
+// Description: function to read a key stroke
+//
+// Input: EFI_INPUT_KEY *Key,
+// AMI_EFI_KEY_DATA *KeyData
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData)
+{
+ EFI_STATUS Status;
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+ AMI_EFIKEYCODE_PROTOCOL *pKeyCodeProtocol;
+
+ Status = gBS->HandleProtocol(gST->ConsoleInHandle, &gAmiEfiKeycodeProtocolGuid, (void*)&pKeyCodeProtocol);
+ if (EFI_ERROR(Status)) return Status;
+
+ Status = pKeyCodeProtocol->ReadEfikey( pKeyCodeProtocol, KeyData );
+
+ ////EIP-87117 If it Partial Key make the Status as Error to ignore
+ // the Partial Key.
+ if((KeyData->KeyState.KeyToggleState & KEY_STATE_EXPOSED) == KEY_STATE_EXPOSED) {
+ if( (!EFI_ERROR( Status )) && (KeyData->Key.ScanCode==0) && (KeyData->Key.UnicodeChar==0)) {
+ Status = EFI_NOT_READY;
+ }
+ }
+ *Key = KeyData->Key;
+#else
+ Status = gST->ConIn->ReadKeyStroke( gST->ConIn, Key );
+#endif
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HelperIsPasswordCharValid
+//
+// Description: function to check whether the password char is valid
+//
+// Input: EFI_INPUT_KEY *Key,
+// AMI_EFI_KEY_DATA *KeyData,
+// UINTN StrIndex,
+// UINTN PasswordLength,
+// CHAR16 *OutChar
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar)
+{
+#if (TSE_USE_AMI_EFI_KEYCODE_PROTOCOL )
+ switch( SETUP_STORE_KEYCODE_PASSWORD )
+ {
+ case PW_EFI_KEY:
+ if ( (StrIndex < PasswordLength) && (KeyData->EfiKeyIsValid) ) {
+ /// EIP:28551 - Get EFI Key with the help of AMI key code protocol
+ *OutChar = (0x8000)^(CHAR16)(KeyData->EfiKey);
+ return EFI_SUCCESS;
+ }
+ break;
+ case PW_SCAN_CODE:
+ if ( (StrIndex < PasswordLength) && (KeyData->PS2ScanCodeIsValid) ) {
+ *OutChar = (CHAR16)(KeyData->PS2ScanCode);
+ return EFI_SUCCESS;
+ }
+ break;
+ default:
+ break;
+ }
+
+#endif
+ // if tokens not enabled then, check whether the character is alphanumeric and return the key
+ if ( CheckIsAllowedPasswordChar(Key->UnicodeChar) && ( StrIndex < PasswordLength ) )
+ {
+ *OutChar = Key->UnicodeChar;
+ return EFI_SUCCESS;
+ }
+
+ // If AMI key code support TOKEN not enabled and the character is not alphanumeric then return as Unsupported.
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditHandlePassword
+//
+// Description: function to handle the popup password edit
+//
+// Input: VOID *pPopupEdit,
+// VOID *pData
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditHandlePassword( VOID *pPopupEdit, VOID *pData)
+{
+#if (TSE_USE_AMI_EFI_KEYCODE_PROTOCOL && SETUP_STORE_KEYCODE_PASSWORD)
+ POPUPEDIT_DATA *PopupEdit = pPopupEdit;
+ ACTION_DATA *Data = pData;
+
+ // Check whether the popup edit type is Password,
+ if(( PopupEdit->PopupEditType == POPUPEDIT_TYPE_PASSWORD )&&( EfiStrLen(PopupEdit->Text) < PopupEdit->TextWidth ))
+ {
+ if(PopupEdit->ControlActive ==FALSE)
+ {
+ // copy the password text into temp and make the control active.
+ MemCopy(PopupEdit->TempText,PopupEdit->Text,PopupEdit->TextWidth* sizeof(UINT16));
+ PopupEdit->ControlActive = TRUE;
+ }
+ switch( SETUP_STORE_KEYCODE_PASSWORD )
+ {
+ case PW_EFI_KEY:
+ if(Data->Input.Data.AmiKey.EfiKeyIsValid)
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)] = 0x8000 ^(CHAR16)(Data->Input.Data.AmiKey.EfiKey);
+ else
+ return EFI_UNSUPPORTED;
+ break;
+
+ case PW_SCAN_CODE:
+ if(Data->Input.Data.AmiKey.PS2ScanCodeIsValid)
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)] = (CHAR16)(Data->Input.Data.AmiKey.PS2ScanCode);
+ else
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ // set end of string and return success
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)] = 0x0 ;
+
+ return EFI_SUCCESS;
+ }
+#endif
+ return EFI_UNSUPPORTED;
+}
+
+//TSE_CLEAR_USERPW_WITH_ADMINPW
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ClearUserPasswordPolicy
+//
+// Description: fucntion to clear the user password if admin password is empty,
+// Only Valid with Password Local
+//
+// Input: CALLBACK_PASSWORD *callbackData,
+// CHAR16 *saveData
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ClearUserPasswordPolicy(CALLBACK_PASSWORD *callbackData,CHAR16 *saveData)
+{
+ if(
+ (VARIABLE_ID_AMITSESETUP == callbackData->Variable)&&
+ (STRUCT_OFFSET(AMITSESETUP,AdminPassword) == callbackData->Offset)&&
+ (0 == ((CHAR16 *)callbackData->Data)[0])
+ )
+ {
+ //Admin password is being cleared
+ //Clear user pw; write the same thing for user
+ //EIP-172956 To update password values properly
+ if((TSEPwdSavetoNvram())&&( VARIABLE_ID_AMITSESETUP == callbackData->Variable ))
+ {
+ AMITSESETUP *TempSaveData = (AMITSESETUP *)NULL;
+ UINTN size=0;
+ TempSaveData = (AMITSESETUP *) EfiLibAllocateZeroPool(sizeof(AMITSESETUP));
+ size = sizeof(AMITSESETUP);
+
+ TempSaveData = VarGetNvram(VARIABLE_ID_AMITSESETUP, &size);
+ MemCopy( ((UINT8*)(TempSaveData))+(STRUCT_OFFSET(AMITSESETUP,UserPassword)), saveData, callbackData->Length );
+ VarSetNvram( VARIABLE_ID_AMITSESETUP, TempSaveData, sizeof(AMITSESETUP));
+ MemFreePointer( (VOID **)&TempSaveData );
+ }
+ else{
+ VarSetValue(VARIABLE_ID_AMITSESETUP, STRUCT_OFFSET(AMITSESETUP,UserPassword), callbackData->Length, saveData);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseFramePwdCallbackIdePasswordUpdate
+//
+// Description: function to update the ide password
+//
+// Input: CONTROL_DATA *control,
+// CHAR16 *saveData
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TseFramePwdCallbackIdePasswordUpdate ( CONTROL_DATA *control,CHAR16 *saveData)
+{
+ BOOLEAN bCheckUser = FALSE;
+ VOID * data =control->ControlData.ControlPtr;
+
+ if (control->ControlData.ControlVariable == VARIABLE_ID_IDE_SECURITY ) // IDE Password
+ {
+ if(/*data->QuestionId*/UefiGetQuestionOffset(data) == STRUCT_OFFSET(IDE_SECURITY_CONFIG,IDEUserPassword))
+ bCheckUser = TRUE;
+ TSEIDEPasswordUpdate( (UINT32)gCurrIDESecPage, saveData, bCheckUser );
+ return EFI_SUCCESS;
+ }
+ else
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TsePopupPwdAuthenticateIDEPwd
+//
+// Description: Function to authenticate the IDE password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword,
+// BOOLEAN *AbortUpdate,
+// VOID *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TsePopupPwdAuthenticateIDEPwd(POPUP_PASSWORD_DATA *popuppassword, BOOLEAN *AbortUpdate,VOID *data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CHAR16 *Text=NULL;
+ if(popuppassword->ControlData.ControlVariable == VARIABLE_ID_IDE_SECURITY )
+ {
+ //if drive is locked ask for the old password to unlock the drive
+ VOID* DataPtr = TSEIDEPasswordGetDataPtr(gCurrIDESecPage);
+ BOOLEAN bCheckUser = FALSE;
+ BOOLEAN EnabledBit = FALSE;
+ UINTN size = 0;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == ideSecConfig) {
+ return EFI_NOT_FOUND;
+ }
+ if(ideSecConfig->Enabled) EnabledBit = TRUE;
+
+ if(EnabledBit)
+ {
+ if(UefiGetQuestionOffset(data) /*data->QuestionId*/ == STRUCT_OFFSET(IDE_SECURITY_CONFIG,IDEUserPassword))
+ bCheckUser = TRUE;
+
+ if(bCheckUser || ideSecConfig->MasterPasswordStatus)
+ {
+ Status = _DoPopupEdit( popuppassword, (IsShowPromptStringAsTitle() ? STRING_TOKEN(STR_OLD_PSWD_LABEL): STRING_TOKEN(STR_OLD_PSWD)), &Text);//EIP-116315 password window title string
+ if(EFI_SUCCESS != Status )
+ {
+ *AbortUpdate = TRUE;
+ }
+ else
+ {
+ Status = TSEIDEPasswordAuthenticate( Text, DataPtr, bCheckUser );
+ if(EFI_ERROR( Status ))
+ {
+ CallbackShowMessageBox( (UINTN)gInvalidPasswordFailMsgBox, MSGBOX_TYPE_OK );
+ *AbortUpdate = TRUE;
+ }
+ StringZeroFreeMemory ((VOID **)&Text);
+ }
+ }
+ }
+
+ MemFreePointer((VOID **) &ideSecConfig);
+ return EFI_SUCCESS;
+ }
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TsePopupPwdUpdateIDEPwd
+//
+// Description: function to update the IDE password
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TsePopupPwdUpdateIDEPwd (VOID)
+{
+ UINTN size = 0;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == ideSecConfig) {
+ return;
+ }
+ TSEIDEUpdateConfig((VOID*)ideSecConfig, gCurrIDESecPage);
+ VarSetValue (VARIABLE_ID_IDE_SECURITY, 0, size, ideSecConfig); //Updating the cache
+ if (gApp != NULL)
+ gApp->CompleteRedraw = TRUE; //EIP 80360 Complete redraw bcoz if User password set it should grayout the Master password.
+ MemFreePointer((VOID **)&ideSecConfig);
+}
+
+
+#if TSE_SEPERATE_EFI_LEGACY_OPTIONS
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsLegacyOption
+//
+// Description: function to check for legacy option
+//
+// Input: UINT16 Option
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsLegacyOption(UINT16 Option)
+{
+ BOOT_DATA *pBootData;
+
+ pBootData = BootGetBootData(Option);
+
+ if(pBootData)
+ {
+ if(BBSValidDevicePath( pBootData->DevicePath ))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReGroupOptions
+//
+// Description: function to regroup the boot options
+//
+// Input: UINT16 *optionList,
+// UINT16 *OrgOptionList
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ReGroupOptions(UINT16 *optionList,UINT16 *OrgOptionList)
+{
+ UINTN src, dest, i;
+ UINT16 *TempList;
+ UINTN LegDevStartIndex=0xFFFF,LegDevStopIndex=0xFFFF;
+
+ TempList = EfiLibAllocatePool(gBootOptionCount * sizeof(UINT16));
+ MemCopy(TempList, optionList, gBootOptionCount * sizeof(UINT16));
+
+ dest = 0;
+ //Copy all first EFI option
+ for(src=0; (src<gBootOptionCount)&&(DISABLED_BOOT_OPTION!=TempList[src]); src++)
+ {
+ if(IsLegacyOption(TempList[src]))
+ break;
+
+ optionList[dest] = TempList[src];
+ dest++;
+ }
+
+ //Gather all Legacy option
+ for(i = src; (i<gBootOptionCount)&&(DISABLED_BOOT_OPTION!=TempList[i]); i++)
+ {
+ if(IsLegacyOption(TempList[i]))
+ {
+ optionList[dest] = TempList[i];
+ dest++;
+ if(LegDevStartIndex == 0xFFFF)
+ LegDevStartIndex = i; // Start Index
+ LegDevStopIndex = i; // End Index Updated for Each Legacy Entry
+ }
+ }
+
+ //Gather all EFI option
+ for(i = src; (i<gBootOptionCount)&&(DISABLED_BOOT_OPTION!=TempList[i]); i++)
+ {
+ if(!IsLegacyOption(TempList[i]))
+ {
+ if(OrgOptionList != NULL)
+ // Don't Allow Mixing of Legacy and UEFI Boot Options
+ if( (i > LegDevStartIndex) && (i < LegDevStopIndex))
+ {
+ // Restore the Orginal Boot Options
+ MemCopy( optionList, OrgOptionList, gBootOptionCount*sizeof(UINT16));
+ break;
+ }
+
+ optionList[dest] = TempList[i];
+ dest++;
+ }
+ }
+
+ MemFreePointer((VOID **) &TempList);
+}
+#endif
+
+
+#ifdef TSE_FOR_APTIO_4_50
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEGetNVVariable
+//
+// Description: reads the NV Varaiable from Nram buffer using NVLib.
+//
+// Input: UINT32 variable, NVRAM_STORE_INFO *pInfo , UINTN *size
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *TSEGetNVVariable( UINT32 variable, NVRAM_STORE_INFO *pInfo , UINTN *size )
+{
+ VOID *buffer = NULL;
+#if TSE_NVRAM_DEFAULTS_SUPPORT //EIP-47260: To build TSE without NVRAM module support.
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ VARIABLE_INFO *varInfo;
+ //UINT8 Flags; EIP: 49745 To fix the CPU hangs when Core is update to 4.6.4.1
+
+ varInfo = VarGetVariableInfoIndex( variable );
+ if ( varInfo == NULL )
+ return buffer;
+
+ *size=0;
+ Status = NvGetVariable(
+ varInfo->VariableName,
+ &varInfo->VariableGuid,
+ NULL,
+ size,
+ buffer,
+ pInfo, /*&Flags*/ NULL //EIP: 49745 To fix the CPU hangs when Core is update to 4.6.4.1
+
+ );
+
+ if ( Status != EFI_BUFFER_TOO_SMALL )
+ return buffer;
+
+ buffer = EfiLibAllocatePool( *size );
+ if ( buffer == NULL )
+ return buffer;
+
+ Status = NvGetVariable(
+ varInfo->VariableName,
+ &varInfo->VariableGuid,
+ NULL,
+ size,
+ buffer,
+ pInfo,/*&Flags*/ NULL //EIP: 49745 To fix the CPU hangs when Core is update to 4.6.4.1
+ );
+
+ if ( EFI_ERROR( Status ) )
+ MemFreePointer( (VOID *)&buffer );
+
+#endif //TSE_NVRAM_DEFAULTS_SUPPORT
+ return buffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateNVDefautls
+//
+// Description: Updated the Variable buffer with NVRam Defaults buffer.
+//
+// Input: UINT32 index, NVRAM_STORE_INFO *NvInfo, NVRAM_VARIABLE * VarPtr
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateNVDefautls(UINT32 index, NVRAM_STORE_INFO *NvInfo, NVRAM_VARIABLE * VarPtr)
+{
+ UINTN Nvsize;
+ UINT8 * NvVarBuffer;
+
+ Nvsize = 0;
+ NvVarBuffer = TSEGetNVVariable( index, NvInfo , &Nvsize );
+ if(NvVarBuffer && Nvsize)
+ {
+ if(index == VARIABLE_ID_AMITSESETUP)
+ {
+ if(!IsTseLoadPasswordOnDefaults())
+ {
+ // To preserve password
+ if(Nvsize>=sizeof(AMITSESETUP))
+ {
+ if(VarPtr->Buffer && (VarPtr->Size>=sizeof(AMITSESETUP)))
+ {
+ MemCopy(((AMITSESETUP*)NvVarBuffer)->UserPassword, ((AMITSESETUP*)VarPtr->Buffer)->UserPassword,TsePasswordLength*sizeof(CHAR16));
+ MemCopy(((AMITSESETUP*)NvVarBuffer)->AdminPassword, ((AMITSESETUP*)VarPtr->Buffer)->AdminPassword,TsePasswordLength*sizeof(CHAR16));
+ }
+ }
+ }
+ }
+
+ if(VarPtr->Size >= Nvsize)
+ {
+ MemCopy(VarPtr->Buffer,NvVarBuffer,Nvsize);
+ MemFreePointer( (VOID **)&NvVarBuffer );
+ }
+ else
+ {
+ MemFreePointer( (VOID **)&VarPtr->Buffer);
+ VarPtr->Buffer = NvVarBuffer;
+ VarPtr->Size = Nvsize;
+ }
+ }
+
+}
+#endif
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseVarBuildAMIDefaults
+//
+// Description: function build the AMI defaults
+//
+// Input: None
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TseVarBuildAMIDefaults(VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 page, control;
+ VOID *defaults4FirstBootVar = NULL;
+#if TSE_NVRAM_DEFAULTS_SUPPORT //EIP-47260: To build TSE without NVRAM module support.
+ NVRAM_VARIABLE *OptvarPtr;
+ NVRAM_VARIABLE *FailsafevarPtr;
+ UINT32 index;
+
+#ifdef TSE_FOR_APTIO_4_50
+ NVRAM_STORE_INFO NvInfo={0};
+ UINTN Nvsize;
+ UINT8 * NvVarBuffer=NULL;
+ UINT32 attribute=7;
+#endif
+#endif
+ //EIP-93340 Setting "ConstructDefaults4FirstBoot" variable in NVRAM for first boot only
+ if ( IsSupportDefaultForStringControl() )
+ {
+ EFI_GUID ConstructDefaults4FirstBootGuid = CONSTRUCT_DEFAULTS_FIRST_BOOT_GUID;
+ UINTN varSize = 0;
+
+ defaults4FirstBootVar = (VOID *)VarGetNvramName (L"ConstructDefaults4FirstBoot", &ConstructDefaults4FirstBootGuid, NULL, &varSize);
+ if (NULL == defaults4FirstBootVar)
+ {
+ VarSetNvramName( L"ConstructDefaults4FirstBoot", &ConstructDefaults4FirstBootGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE, &varSize, sizeof (varSize) );
+ }
+ }//EIP-93340 End
+
+ gFailsafeDefaults = EfiLibAllocateZeroPool( sizeof(NVRAM_VARIABLE) * gVariables->VariableCount );
+ if ( gFailsafeDefaults == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ gOptimalDefaults = EfiLibAllocateZeroPool( sizeof(NVRAM_VARIABLE) * gVariables->VariableCount );
+ if (gOptimalDefaults == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+#if TSE_NVRAM_DEFAULTS_SUPPORT //EIP-47260: To build TSE without NVRAM module support.
+ // Load the Current NVRAM variable then update the defaults.
+ OptvarPtr = gOptimalDefaults;
+ FailsafevarPtr = gFailsafeDefaults;
+ for ( index = 0; index < gVariables->VariableCount; index++, OptvarPtr++, FailsafevarPtr++)
+ {
+ if ((VARIABLE_ID_AMITSESETUP == index) && (TseDefaultSetupPasswordSupported ()))
+ {
+ OptvarPtr->Buffer = VarGetNvram( index, &OptvarPtr->Size );
+ if (OptvarPtr->Buffer)
+ {
+ MemSet(OptvarPtr->Buffer, ((TsePasswordLength * 2) * sizeof(CHAR16)), 0 ); //Preserving quietboot details
+ if ((!DefaultSetupPwdAtFirstBootOnly ()))
+ {
+ GetDefaultPassword (AMI_PASSWORD_NONE, &OptvarPtr->Buffer);
+ }
+ }
+ }
+ else
+ {
+ OptvarPtr->Buffer = VarGetNvram( index, &OptvarPtr->Size );
+ }
+ if(OptvarPtr->Size)
+ {
+ // init mfg defautls from Std Defaults
+ FailsafevarPtr->Buffer = EfiLibAllocateZeroPool (OptvarPtr->Size);
+ if (NULL == FailsafevarPtr->Buffer)
+ continue;
+ if (NULL == OptvarPtr->Buffer) //Add the fix for: If name value string is not able to retrieve then system hang
+ {
+ OptvarPtr->Buffer = EfiLibAllocateZeroPool (OptvarPtr->Size);
+ if (NULL == OptvarPtr->Buffer)
+ continue;
+ }
+ MemCopy(FailsafevarPtr->Buffer, OptvarPtr->Buffer,OptvarPtr->Size);
+ }
+ else
+ FailsafevarPtr->Buffer = NULL;
+ FailsafevarPtr->Size = OptvarPtr->Size;
+ }
+#endif //TSE_NVRAM_DEFAULTS_SUPPORT
+
+ // this is the AMIBCP compatible user defaults
+ for ( page = 0; page < gPages->PageCount; page++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+
+ if(pageInfo->PageHandle ==0)
+ continue;
+ if (NULL == gApp)
+ {
+ gtempCurrentPage = page; //Will be used in UefiGetQuestionOffset. Since gApp will not be filled but we need handle to find name value variable so
+ } //saving current page
+ else
+ {
+ gApp->CurrentPage = page;
+ }
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE ) || ( controlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER ) || (controlInfo->ControlVariable == VARIABLE_ID_BBS_ORDER) )
+ continue;
+
+ if ( controlInfo->ControlDataWidth > 0 )
+ {
+ VOID *ifrData = controlInfo->ControlPtr;
+ UINT8 *failValue = NULL, *optValue = NULL;
+ UINT32 ControlVarOffset = 0;
+
+ if ( ifrData == NULL )
+ continue;
+
+ failValue = (UINT8 *)controlInfo + sizeof(CONTROL_INFO);
+ optValue = failValue + controlInfo->ControlDataWidth;
+
+ ControlVarOffset = UefiGetQuestionOffset(ifrData);
+ //EIP-93340 Updating gOptimalDefaults and gFailSafeDefaults for stringType controls based on controlPtr
+ if (IsSupportDefaultForStringControl () && controlInfo->ControlType == CONTROL_TYPE_POPUP_STRING)
+ {
+ CHAR16 *failDefStr = NULL, *optimalDefStr = NULL;
+
+ if (*(UINT16*)(failValue))
+ {
+ failDefStr = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(failValue));
+ if (NULL == failDefStr)
+ continue;
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen(failDefStr)*sizeof(CHAR16), (VOID*)failDefStr );
+ }
+
+ if (*(UINT16*)(optValue))
+ {
+ optimalDefStr = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(optValue));
+ if (NULL == optimalDefStr)
+ continue;
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen(optimalDefStr)*sizeof(CHAR16), (VOID*)optimalDefStr );
+ }
+
+ if (NULL == defaults4FirstBootVar && optimalDefStr) //Modify NVRAM for first time for string type controls based on defaults from controlPtr
+ {
+ VOID *optiBuffer = NULL, *failBuffer = NULL;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL;
+ UINTN size = 0;
+ EFI_STATUS status = EFI_SUCCESS;
+
+ varInfo = VarGetVariableInfoIndex (controlInfo->ControlVariable);
+
+ optiBuffer = VarGetNvram( controlInfo->ControlVariable, &size );
+ if (NULL == optiBuffer)
+ {
+ continue;
+ }
+
+ MemCopy ( ((UINT8*)optiBuffer)+ControlVarOffset, (UINT8*)optimalDefStr, EfiStrLen(optimalDefStr)*sizeof(CHAR16) );
+
+ status = VarSetNvramName( varInfo->VariableName, &varInfo->VariableGuid, varInfo->VariableAttributes, optiBuffer, size );
+ if (optiBuffer)
+ MemFreePointer( (VOID **)&optiBuffer );
+ }
+ if (failDefStr)
+ MemFreePointer( (VOID **)&failDefStr );
+
+ if (optimalDefStr)
+ MemFreePointer( (VOID **)&optimalDefStr );
+
+ }
+ //EIP-93340 End
+ else
+ {
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, controlInfo->ControlVariable, ControlVarOffset, controlInfo->ControlDataWidth, failValue );
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, ControlVarOffset, controlInfo->ControlDataWidth, optValue );
+ }
+ }
+ }
+ }
+
+#ifdef TSE_FOR_APTIO_4_50
+#if TSE_NVRAM_DEFAULTS_SUPPORT //EIP-47260: To build TSE without NVRAM module support.
+ // StdDefaults
+ Nvsize = 0;
+ NvVarBuffer = VarGetNvramName( L"StdDefaults", &DefaultsGuid, &attribute, &Nvsize );
+ if(NvVarBuffer && Nvsize)
+ {
+ NvInfo.NvramAddress = NvVarBuffer;
+ NvInfo.NvramSize = Nvsize;
+ NvInitInfoBuffer(&NvInfo, 0, NVRAM_STORE_FLAG_NON_VALATILE );
+
+ // Update the defaults.
+ OptvarPtr = gOptimalDefaults;
+ for ( index = 0; index < gVariables->VariableCount; index++, OptvarPtr++)
+ {
+ UpdateNVDefautls(index, &NvInfo, OptvarPtr);
+ }
+ MemFreePointer( (VOID **)&NvVarBuffer );
+ }
+
+ // MfgDefaults
+ Nvsize = 0;
+ NvVarBuffer = VarGetNvramName( L"MfgDefaults", &DefaultsGuid, &attribute, &Nvsize );
+ if(NvVarBuffer && Nvsize)
+ {
+ NvInfo.NvramAddress = NvVarBuffer;
+ NvInfo.NvramSize = Nvsize;
+ NvInitInfoBuffer(&NvInfo, 0, NVRAM_STORE_FLAG_NON_VALATILE );
+
+ FailsafevarPtr = gFailsafeDefaults;
+ for ( index = 0; index < gVariables->VariableCount; index++, FailsafevarPtr++ )
+ {
+ UpdateNVDefautls(index, &NvInfo, FailsafevarPtr);
+ }
+ MemFreePointer( (VOID **)&NvVarBuffer );
+ }
+ //EIP-93340 Updating optimalDefaults and gFailsafeDefaults for STRING_TYPE controls
+ //based on defalut stringID present in controlPtr
+ GetSetDefaultsFromControlPtr(gOptimalDefaults, gFailsafeDefaults);
+#endif //TSE_NVRAM_DEFAULTS_SUPPORT
+#endif
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseBootNowinBootOrderInit
+//
+// Description: function build the AMI defaults
+//
+// Input: None
+//
+// Output: boot order string
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 * TseBootNowinBootOrderInit(VOID)
+{
+ UINT16 *BootOrder=NULL;
+ UINTN size = 0;
+ UINTN j,k,i;
+
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == BootOrder) {
+ ASSERT (0);
+ return NULL;
+ }
+ //Find the first disabled option
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( DISABLED_BOOT_OPTION == BootOrder[i] )
+ break;
+ }
+
+ if(i<gBootOptionCount)
+ {
+ //There are disabled options replace them with valid options
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ for(k=0;k<gBootOptionCount;k++)
+ {
+ if(BootOrder[k] == gBootData[j].Option)
+ break;
+ }
+
+ if(k >= gBootOptionCount)
+ {
+ //gBootData[j].Option is not present in BootOrder; fill it
+ BootOrder[i] = gBootData[j].Option;
+ i++;
+ }
+ }
+ }
+ return BootOrder;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckShiftState
+//
+// Description: function to check the shift state value
+//
+// Input: None
+//
+// Output: 1 - valid shift state
+// 0 - invalid shift state
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckShiftState(UINT32 KeyShiftState, UINT32 HotkeyState)
+{
+ if( KeyShiftState == HotkeyState)
+ return 1;
+ else
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SupportPrintScreen
+//
+// Description: function to support the print screen.
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SupportPrintScreen()
+{
+ EFI_GUID guid = AMITSE_PRINT_SCREEN_PRESS_GUID;
+ // Install the PrintScreen Notification.
+ EfiLibNamedEventSignal (&guid);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SupportPrintScreenEvent
+//
+// Description: function to check the print screen supprot event.
+//
+// Input: UINT16 ScanCode
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN SupportPrintScreenEvent(UINT16 ScanCode)
+{
+ if( ScanCode == TSE_PRN_SCRN_KEY_SCAN )
+ return 1;
+ else
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsToggleStateKey
+//
+// Description: function to check Is any of ToggleStateKey (CapsLock,Numlock ScrollLock) Keys pressed.
+//
+// Input: ACTION_DATA *Data
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsToggleStateKey(ACTION_DATA *Data)
+{
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
+ if(Data->Input.Data.AmiKey.EfiKey == EfiKeyCapsLock || Data->Input.Data.AmiKey.EfiKey == EfiKeySLck || Data->Input.Data.AmiKey.EfiKey == EfiKeyNLck)
+ return TRUE;
+ else
+#endif
+ {
+ // Normal EFI_KEY will return ScanCode and Unicode as 0 for this toggleStateKeys.
+ if(Data->Input.Data.AmiKey.Key.ScanCode || Data->Input.Data.AmiKey.Key.UnicodeChar)
+ return FALSE;
+ else
+ return TRUE;
+ }
+ }
+ else
+ return FALSE;
+}
+
+//EIP-96246 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowBootOverrideSelectOption
+//
+// Description: function to Show menu with below option on selecting options under Boot Override
+// 1) Override now and clear the BootNext data
+// 2) Override now but keep the BootNext data
+// 3) Boot to BootNext and clear BootNext data
+// Input: VOID
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowBootOverrideSelectOption (VOID)
+{
+
+ UINT16 ItemCount = 3,itemSelected = 0;
+ UINT16 Title, Legend;
+ UINT8 i;
+ EFI_STATUS Status;
+ POSTMENU_TEMPLATE *BootNextOverrideOptionsMenu = NULL;
+
+ UINT16 BootNextOverrideOptionString[3] = {STRING_TOKEN (STR_OVERRIDE_BOOTNEXT_OPTION_1), STRING_TOKEN (STR_OVERRIDE_BOOTNEXT_OPTION_2), STRING_TOKEN (STR_OVERRIDE_BOOTNEXT_OPTION_3)};
+
+ BootNextOverrideOptionsMenu = EfiLibAllocateZeroPool ( sizeof( POSTMENU_TEMPLATE ) * BOOT_OVERRIDE_OPTION_MENU_COUNT);
+
+ for ( i = 0; i < BOOT_OVERRIDE_OPTION_MENU_COUNT; i++ )
+ {
+ BootNextOverrideOptionsMenu[i].ItemToken = BootNextOverrideOptionString[i];
+ BootNextOverrideOptionsMenu[i].Callback = (VOID*)NULL ;
+ BootNextOverrideOptionsMenu[i].CallbackContext = (VOID*)NULL ;
+ BootNextOverrideOptionsMenu[i].Attribute = AMI_POSTMENU_ATTRIB_FOCUS;
+ BootNextOverrideOptionsMenu[i].Key.Key.ScanCode = 0 ;
+ BootNextOverrideOptionsMenu[i].Key.Key.UnicodeChar = 0 ;
+ BootNextOverrideOptionsMenu[i].Key.KeyShiftState = 0 ;
+ }
+
+
+ Title = STRING_TOKEN (STR_OVERRIDE_OPTION_MENU_TITLE) ;
+ Legend = STRING_TOKEN (STR_OVERRIDE_OPTION_MENU_LEGEND) ;
+
+ //To show menu with options
+ Status = PostManagerDisplayMenu (gHiiHandle, Title, Legend, BootNextOverrideOptionsMenu, BOOT_OVERRIDE_OPTION_MENU_COUNT, &itemSelected);
+
+ if( Status == EFI_SUCCESS )
+ {
+ UINTN size = 0;
+ UINT16 *pBootNext = NULL;
+ pBootNext = (UINT16 *)VarGetNvramName (L"BootNext", &gEfiGlobalVariableGuid, NULL, &size);
+
+ //Override now and clear the BootNext data
+ if ( BootNextOverrideOptionsMenu[itemSelected].ItemToken == BootNextOverrideOptionString[0] )
+ {
+ if( pBootNext && (size == sizeof(UINT16)))
+ {
+ //Clear Boot next variable
+ VarSetNvramName (L"BootNext",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NULL,
+ 0);
+ }
+ if(pBootNext)
+ MemFreePointer((void **) &pBootNext);
+ Status = EFI_SUCCESS;
+ }
+ //Override now but keep the BootNext data
+ else if(BootNextOverrideOptionsMenu[itemSelected].ItemToken == BootNextOverrideOptionString[1])
+ {
+ Status = EFI_SUCCESS;
+ return Status;
+ }
+ //Boot to BootNext and clear BootNext data
+ else if(BootNextOverrideOptionsMenu[itemSelected].ItemToken == BootNextOverrideOptionString[2])
+ {
+ if( pBootNext && (size == sizeof(UINT16)))
+ {
+ //Clear Boot next variable
+ VarSetNvramName (L"BootNext",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ NULL,
+ 0);
+ if(!gResetRequired)
+ {
+ if(!gDoNotBoot)
+ {
+ gApp->ClearScreen = TRUE;
+ StyleExit();
+ if (gST->ConOut != NULL)
+ {
+ gST->ConOut->EnableCursor( gST->ConOut, FALSE );
+ gST->ConOut->SetAttribute( gST->ConOut, (EFI_BACKGROUND_BLACK | EFI_WHITE));
+ gST->ConOut->ClearScreen( gST->ConOut);
+ }
+ BootLaunchBootOption(*pBootNext, NULL, 0); //Boot to BootNext option
+ StyleInit();
+ }
+ }
+ }
+ if(pBootNext)
+ MemFreePointer((void **) &pBootNext);
+
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ return Status;
+}
+//EIP-96246 Ends
+
+//EIP-93340 Start
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetSetDefaultsFromControlPtr
+//
+// Description: Function to get default stringID for String Type control from controlPtr and
+// fetch respective string from Hii database and set as default to NVRAM, gOptimalDefaults, gFailSafeDefaults buffer
+// Input: NVRAM_VARIABLE *OptimalDefs, NVRAM_VARIABLE *FailSafeDefs
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetSetDefaultsFromControlPtr(NVRAM_VARIABLE *optimalDefaultlist, NVRAM_VARIABLE *failSafeDefaultlist)
+{
+ EFI_STATUS status = EFI_UNSUPPORTED;
+
+ if ( IsSupportDefaultForStringControl () )
+ {
+ UINT32 page = 0, control = 0;
+
+ for ( page = 0; page < gPages->PageCount; page++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+
+ if(pageInfo->PageHandle ==0)
+ continue;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE ) || ( controlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER ) || (controlInfo->ControlVariable == VARIABLE_ID_BBS_ORDER) )
+ continue;
+
+ //To update Optimal and FailSafe defaults with STRING default based on StringID from controlPtr
+ if ( (controlInfo->ControlType == CONTROL_TYPE_POPUP_STRING) && (controlInfo->ControlDataWidth > 0) )
+ {
+ if ( (optimalDefaultlist) || (failSafeDefaultlist))
+ {
+ CHAR16 *failDefStr = NULL, *optimalDefStr = NULL;
+ UINT8 *failValue, *optValue;
+ UINT32 ControlVarOffset, size = 0;
+
+ //Getting stringID if any present in controlPtr for failsafe default
+ failValue = (UINT8 *)controlInfo + sizeof(CONTROL_INFO);
+
+ //Getting stringID if any present in controlPtr for optimal default
+ optValue = failValue + controlInfo->ControlDataWidth;
+ //size = controlInfo->ControlDataWidth;
+
+ size = UefiGetWidth (controlInfo->ControlPtr) * sizeof(CHAR16);
+ ControlVarOffset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+
+ //Getting string based on StrigID from controlPtr and updating failsafeDefaults
+ if (NULL != failSafeDefaultlist)
+ {
+ if (*(UINT16*)(failValue))
+ {
+ failDefStr = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(failValue));
+ if (NULL == failDefStr)
+ continue;
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen(failDefStr)*sizeof(CHAR16), failDefStr );
+ }
+ }
+
+ //Getting string based on StrigID from controlPtr and updating optimalDefaults
+ if (NULL != optimalDefaultlist)
+ {
+ if (*(UINT16*)(optValue))
+ {
+ optimalDefStr = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(optValue));
+ if (NULL == optimalDefStr)
+ continue;
+ status = _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen(optimalDefStr)*sizeof(CHAR16), optimalDefStr );
+ }
+ }
+
+ if (failDefStr)
+ MemFreePointer( (VOID **)&failDefStr );
+
+ if (optimalDefStr)
+ MemFreePointer( (VOID **)&optimalDefStr );
+ }//End of optimal/Failsafe condition check
+ }//End of ControlType condition check
+ }//End of control iteration
+ }//End of Page iteration
+ }//End of Default support condition check
+ return status;
+}
+//EIP-93340 End
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/TseAdvanced.cif b/EDK/MiniSetup/TseAdvanced/TseAdvanced.cif
new file mode 100644
index 0000000..6ca25c9
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/TseAdvanced.cif
@@ -0,0 +1,28 @@
+<component>
+ name = "TSE Sources - Advanced TSE"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\TseAdvanced"
+ RefName = "TseAdvanced"
+[files]
+"TseAdvanced.sdl"
+"TseAdvanced.mak"
+"MyDefs.h"
+"iJpeg.c"
+"jpeg6.c"
+"Jpeg6.h"
+"jpeg.h"
+"Logo.c"
+"ipcx.c"
+"pcx.h"
+"pcxc.c"
+"dogifmgr.c"
+"dogif.c"
+"Bbs.c"
+"TseAdvanced.c"
+"special.c"
+"special.h"
+"bootflowLib.c"
+"png.c"
+"png.h"
+"pnguncmp.c"
+<endComponent>
diff --git a/EDK/MiniSetup/TseAdvanced/TseAdvanced.mak b/EDK/MiniSetup/TseAdvanced/TseAdvanced.mak
new file mode 100644
index 0000000..3112ab3
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/TseAdvanced.mak
@@ -0,0 +1,160 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/TseAdvanced.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 14 $
+##
+## $Date: 10/18/12 5:53a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/TseAdvanced.mak $
+#
+# 14 10/18/12 5:53a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 11 10/10/12 12:35p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 13 1/07/11 1:20a Mallikarjunanv
+# [TAG] EIP47260
+# [Description] Updated the changes made in EIP:47260 proprely
+#
+# 12 12/29/10 6:12a Mallikarjunanv
+# [TAG] EIP 47260
+# [Category] Improvement
+# [Description] Updated TSE_NVRAM_SUPPORT with
+# TSE_NVRAM_DEFAULTS_SUPPORT sdl token name
+# [Files] TseAdvanced.mak, TseAdvanced.sdl, TseAdvanced.c
+#
+# 10 9/21/10 6:28p Madhans
+# [TAG] -
+# [Category] BUILD ISSUE FIX
+# [Symptom] Build issues When TSEsource listed before TSE binary module
+# [RootCause] ExitPageElinkList Is added TSEadvanced.mak
+# [Solution] remove the ExitPageElinkList from TSEadvanced.mak
+# [Files] TSEadvanced.mak
+# #
+#
+# 9 6/04/10 12:51p Blaines
+# Add ExitPageElinkList
+#
+# 8 4/23/10 6:04p Madhans
+# to cleanup.
+#
+# 7 4/16/10 5:13p Madhans
+# Changes for Tse 2.02. Please see Changelog.log for more details.
+#
+# 6 2/19/10 1:04p Madhans
+# Updated for TSE 2.01. Refer Changelog.log for File change history.
+##
+## 5 2/19/10 8:11a Mallikarjunanv
+## updated year in copyright message
+##
+## 4 8/17/09 12:23p Presannar
+## Removed include path to core dir
+##
+## 3 6/24/09 6:10p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 7:43p Presannar
+## Initial implementation of coding standards for AMITSE2.0
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 2 5/07/09 10:36a Madhans
+# Changes after Bin module
+#
+# 1 4/28/09 11:16p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 1 4/28/09 10:27p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+TSE_ADVANCED_INCLUDES = \
+ -I $(TSE_ADVANCED_DIR) \
+ -I $(TSE_STYLE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+ -I $(TSESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_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 $(BUILD_DIR) \
+
+$(BUILD_DIR)\TseAdvanced.lib : TseAdvancedLib
+
+TseAdvancedLib : $(BUILD_DIR)\TseAdvanced.mak TseAdvancedLibBin
+
+$(BUILD_DIR)\TseAdvanced.mak : $(TSE_ADVANCED_DIR)\$(@B).cif $(TSE_ADVANCED_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSE_ADVANCED_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+!if "$(TSE_NVRAM_DEFAULTS_SUPPORT)" == "1" ##EIP-47260: to build TSE without NVRAM module support
+TseAdvancedLibBin : $(BUILD_DIR)\NVRAMDXE.lib
+!else
+#if nvram_support is disabled, then OEM should provide their own variable library name here
+TseAdvancedLibBin :
+!endif
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\TseAdvanced.mak all\
+ "MY_INCLUDES=$(TSE_ADVANCED_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TseAdvanced.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl b/EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl
new file mode 100644
index 0000000..acf7657
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl
@@ -0,0 +1,42 @@
+TOKEN
+ Name = "TSE_ADVANCED_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable Ezport Style in TSE"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "TSE_SEPERATE_EFI_LEGACY_OPTIONS"
+ Value = "0"
+ Help = "Turn on to have EFI options and Legacy options seperate. This will have effect only if BDS also seperates EFI and Legacy options."
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_NVRAM_DEFAULTS_SUPPORT"
+ Value = "1"
+ Help = "To enable NVRAM support in TSE modules. This token requires TSE Sources support"
+ TokenType = Boolean
+ TargetH = Yes
+ TargetMAK = Yes
+ Token = "NVRAM_SUPPORT" "!=" "0"
+End
+
+PATH
+ Name = "TSE_ADVANCED_DIR"
+End
+
+MODULE
+ Help = "Includes TseAdvanced.mak to Project"
+ File = "TseAdvanced.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\TseAdvanced.lib"
+ Parent = "$(TSE_ADVANCED_DIR)\TseAdvanced$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
diff --git a/EDK/MiniSetup/TseAdvanced/bootflowLib.c b/EDK/MiniSetup/TseAdvanced/bootflowLib.c
new file mode 100644
index 0000000..32fdc36
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/bootflowLib.c
@@ -0,0 +1,199 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/bootflowLib.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 8 $
+//
+// $Date: 8/28/14 8:42a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/bootflowLib.c $
+//
+// 8 8/28/14 8:42a Premkumara
+// [TAG] EIP142551
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Mouse Movement is not initialized to Full Screen Resolution
+// in case of quiet boot mode with high resolution OEM Logo.
+// [Root Cause] Mouse Initialization was not across the full screen incase
+// of High Resolution Quiet Boot Logo.
+// [Solution] Initialised the Mouse with the Resolution Set in case of
+// Quiet Boot logo so that Mouse will move acroos the Whole screen
+// [Files] Mouse.c, BootFlowLib.c, PostMgmt.c, PostMgmtExt.c,
+// Notify.c, MinisetupExt.c
+//
+// 7 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 3/26/10 5:06p Madhans
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:12a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/29/10 4:37p Madhans
+// To not to depend on ConsoleControl and ConOut.
+//
+// 4 10/12/09 4:11p Madhans
+// //EIP 28577 : Fix to avoid "Checker: SIGN_EXTENSION"
+//
+// 3 7/08/09 3:35p Madhans
+// In Aptio use the Text mode as is it in post screen
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/07/08 10:34a Arunkumars
+// Stand alone application support for x64 and nt32
+//
+// 1 7/09/07 1:29p Arunkumars
+// - Added elink hooks for Logo, Password management and Control Keys
+// customizations
+//
+//*****************************************************************//
+//*****************************************************************//
+
+#include "minisetup.h"
+BOOLEAN IsMouseSupported(VOID);
+BOOLEAN IsSoftKbdSupported(VOID);
+static MSGBOX_DATA *_gBootFlowMsg = NULL;
+
+VOID _BootFlowCancelTimer( EFI_EVENT Event, VOID *Context )
+{
+ if ( _gBootFlowMsg != NULL )
+ gMsgBox.Destroy( _gBootFlowMsg, TRUE );
+
+ _gBootFlowMsg = NULL;
+
+ TimerStopTimer( &Event );
+}
+
+VOID _BootFlowShowMessageBox( BOOT_FLOW *bootFlowPtr )
+{
+ AMI_IFR_MSGBOX msgBox;
+ CONTROL_INFO dummy;
+
+#ifndef STANDALONE_APPLICATION
+ if ( gConsoleControl != NULL )
+ gConsoleControl->SetMode( gConsoleControl, EfiConsoleControlScreenText );
+#endif
+
+ if (gST->ConOut == NULL) // Headless system/NoVideo in BIOS
+ return;
+
+ gST->ConOut->Reset( gST->ConOut, FALSE );
+#if !APTIO_4_00
+ SetDesiredTextMode();
+#else
+ // In Aptio use the Text mode as is it in post screen
+ if(EFI_ERROR(gST->ConOut->QueryMode( gST->ConOut, gST->ConOut->Mode->Mode, &gMaxCols, &gMaxRows )))
+ {
+ gMaxRows = StyleGetStdMaxRows();
+ gMaxCols = StyleGetStdMaxCols();
+ }
+#endif
+
+ if(IsMouseSupported()&& IsSoftKbdSupported())//Initializing the mouse at post when mouse and softkbd present
+ MouseInit();
+
+ ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+
+ MemSet( &msgBox, sizeof(msgBox), 0 );
+ msgBox.Text = bootFlowPtr->MessageBoxToken;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = INVALID_HANDLE;
+ dummy.ControlPtr = (VOID*)(UINTN)&msgBox;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ gMsgBox.Create( &_gBootFlowMsg );
+ if ( _gBootFlowMsg == NULL )
+ return;
+
+ gMsgBox.Initialize( _gBootFlowMsg, &dummy );
+ gMsgBox.SetType( _gBootFlowMsg, MSGBOX_TYPE_NULL );
+ gMsgBox.Draw( _gBootFlowMsg );
+
+ if ( bootFlowPtr->MessageBoxTimeout != 0 )
+ {
+ EFI_EVENT Event;
+
+ //EIP 28577 : Fix to avoid "Checker: SIGN_EXTENSION"
+ TimerCreateTimer( &Event, _BootFlowCancelTimer, NULL,
+ TimerRelative, MultU64x32( (UINT64)TIMER_ONE_SECOND, (UINT32) bootFlowPtr->MessageBoxTimeout ), EFI_TPL_CALLBACK );
+ }
+}
+
+VOID _BootFlowSetActivePage( BOOT_FLOW *bootFlowPtr )
+{
+ PAGE_INFO *pageInfo;
+ UINT32 i;
+
+ for ( i = 0; i < gPages->PageCount; i++ )
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gSetupPkg + gPages->PageList[i]);
+ if (
+ ( bootFlowPtr->PageClass == gPageIdInfo[pageInfo->PageIdIndex].PageClass ) &&
+ ( bootFlowPtr->PageSubClass == gPageIdInfo[pageInfo->PageIdIndex].PageSubClass ) &&
+ ( bootFlowPtr->PageFormID == pageInfo->PageFormID )
+ )
+ {
+ gEnterSetup = TRUE;
+ gStartPage = i;
+ break;
+ }
+ }
+
+}
+
+VOID _BootFlowSetActiveControl( BOOT_FLOW *bootFlowPtr )
+{
+ // select the control from the currently active page
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/dogif.c b/EDK/MiniSetup/TseAdvanced/dogif.c
new file mode 100644
index 0000000..0c641eb
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/dogif.c
@@ -0,0 +1,1197 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/dogif.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/dogif.c $
+//
+// 8 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 3/28/11 9:35p Arunsb
+// [TAG] EIP55548
+// [Category] Improvement
+// [Description] Support to display Multiple GIF and to display other
+// image format when Active animated Gif is displaying
+// [Files] dogif.c and dogifmgr.c
+//
+// 6 3/21/11 1:16a Rajashakerg
+// [TAG] EIP53740
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Animation does not continue after the last frame of the
+// logo.
+// [RootCause] The animation is done upto last frame of the animated
+// image.
+// [Solution] Fixed the issue by handling Gif image data to redraw image
+// if all the frames are completed and if boottimeout is present.
+// [Files] minisetup.h, dogif.c, dogifmgr.c
+//
+// 5 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/15/10 10:12p Madhans
+// To avoid warnings
+//
+// 5 1/09/10 4:46a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 12/04/09 7:12a Mallikarjunanv
+// Fix for EIP:30263 - Gif Logo Issue
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 7/06/06 6:38p Arunkumars
+// warn fix
+//
+// 1 1/24/06 3:01a Stefanor
+// quiet boot support
+// implementation of buffering for POST messages
+// gif support
+// support for OEM badging protocol
+// fixed fallback from 100x31 to 80x25
+// cleanup of set graphic/text mode
+// ver 1.17.1051
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: dogif.c
+//
+// Description: This file contains code for gif image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#include<minisetup.h>
+
+// definitions
+#undef DEBUG
+#undef TRUE
+#undef FALSE
+
+#define DEBUG 0
+#define TIANO 1
+#if TIANO
+#define TRUE 1
+#else
+#define TRUE (-1)
+#endif
+#define FALSE 0
+
+#define MaxColors 256 /* rev 87a */
+
+struct ColorEntry
+ {
+ unsigned char blue, green, red, dummy;
+ };
+
+#if TIANO
+#define short int
+//#define unsigned
+#define huge
+#define far
+unsigned char * blitbuf = 0;
+static struct ColorEntry * pColorMap = 0;
+#else
+#define _FP_SEG(fp) (*((unsigned __far *)&(fp)+1))
+#define _FP_OFF(fp) (*((unsigned __far *)&(fp)))
+#define _MK_FP(seg, offset) (void __far *)(((unsigned long)seg << 16) \
+ + (unsigned long)(unsigned)offset)
+#endif
+
+// variables
+#if TIANO
+int screen_width = 800;
+int screen_height = 600;
+#else
+int screen_width = 640;
+int screen_height = 480;
+#endif
+
+unsigned char huge * pbuf = 0;
+unsigned long lenbuf = 0;
+unsigned long firstframeadd = 0; //EIP: 53740 global decleration such that we access the first frame address of the gif image
+
+static char GIF87signature[] = "GIF87a";
+static char GIF89signature[] = "GIF89a";
+static char GIFversion = 0;
+#define GIF87 1
+#define GIF89 2
+static struct ColorEntry GlobalColorMap[MaxColors] = {{0}};
+static struct ColorEntry LocalColorMap[MaxColors] = {{0}};
+static unsigned int BackdropWidth = 0;
+static unsigned int BackdropHeight = 0;
+static unsigned int LeftMargin = 0;
+static unsigned int TopMargin = 0;
+static unsigned int ColorRez = 0;
+static unsigned int FillColor = 0;
+#if TIANO
+static short DefaultNumColors = 0;
+#else
+static unsigned int DefaultNumColors = 0;
+#endif
+static unsigned int LeftEdge = 0;
+static unsigned int TopEdge = 0;
+static unsigned int Width = 0;
+static unsigned int Height = 0;
+static unsigned int Interlaced = 0;
+#if TIANO
+static short LocalNumColors = 0;
+#else
+static unsigned int LocalNumColors = 0;
+#endif
+static unsigned int RightEdge = 0;
+static unsigned int BottomEdge = 0;
+static unsigned int InterlacePass = 0;
+static unsigned int X = 0;
+static unsigned int Y = 0;
+static short BaseLine[5] = {0, 4, 2, 1, 0};
+static short LineOffset[5] = {8, 8, 4, 2, 0};
+
+unsigned char huge * pcurbuf = 0;
+static unsigned long unreadbuf = 0;
+
+static unsigned int CurrentBank = 0;
+static unsigned long PixelAdd = 0;
+
+static int TransparentColor = -1;
+static int GlobalColorMapActive = FALSE;
+
+static int UnexpectedError = FALSE;
+
+// functions
+#if TIANO
+unsigned long dofirst( unsigned char *, unsigned long );
+unsigned long donext( unsigned char * );
+#else
+unsigned long far _loadds dofirst(void);
+unsigned long far _loadds donext(void);
+#endif
+static int _inline readbuf(void);
+static void _inline writepixel(unsigned char);
+static void setbank(unsigned int);
+static short ReadScreenDesc(void);
+static short ReadImageDesc(void);
+static unsigned long ReadGraphicControlExt(void);
+#if DEBUG
+static short ReadCommentExt(void);
+static short ReadPlainTextExt(void);
+static short ReadApplicationExt(void);
+#endif
+static short SkipObject(void);
+static void SetPalette( struct ColorEntry [], unsigned int );
+static short Expand_Data(void);
+
+extern UINT16 gGifSrcX;
+extern UINT16 gGifSrcY;
+extern UINT16 gGifDestX;
+extern UINT16 gGifDestY;
+extern BOOLEAN GifImageFlag;
+
+// Expander
+struct code_entry
+ {
+ short prefix; /* prefix code */
+ char suffix; /* suffix character */
+ char stack;
+ };
+static short code_size = 0;
+static short clear_code = 0;
+static short eof_code = 0;
+static short first_free = 0;
+static short bit_offset = 0;
+static short byte_offset = 0;
+static short bits_left = 0;
+static short max_code = 0;
+static short free_code = 0;
+static short old_code = 0;
+static short input_code = 0;
+static short code = 0;
+static short suffix_char = 0;
+static short final_char = 0;
+static short bytes_unread = 0;
+static unsigned char code_buffer[64] = {0};
+static struct code_entry code_table[4096] = {0};
+static short mask[12] =
+ {0x001, 0x003, 0x007, 0x00F,
+ 0x01F, 0x03F, 0x07F, 0x0FF,
+ 0x1FF, 0x3FF, 0x7FF, 0xFFF};
+static unsigned int endofdata = 0;
+
+#if TIANO
+unsigned long dofirst( unsigned char * filemem, unsigned long filememlen )
+#else
+unsigned long far _loadds dofirst( )
+#endif
+{
+
+#if TIANO
+ pbuf = filemem;
+ lenbuf = filememlen;
+#endif
+ pcurbuf = pbuf;
+ unreadbuf = lenbuf;
+ if (!ReadScreenDesc())
+ {
+ /* Invalid GIF dataset */
+#if DEBUG
+ printf("\nnot a GIF file - 1\n");
+#endif
+ return 0xffffffffL;
+ }
+#if DEBUG
+ printf("\nscreen width = %d, screen height = %d\n", BackdropWidth, BackdropHeight);
+ printf("# of colors = %d out of %ld\n", DefaultNumColors, (long)(1L << (3*ColorRez)));
+ printf("fill color index = %d\n", FillColor);
+#endif
+
+ SetPalette( GlobalColorMap, DefaultNumColors );
+ GlobalColorMapActive = TRUE;
+
+#if TIANO
+ LeftMargin = 0;
+ TopMargin = 0;
+ screen_width = BackdropWidth;
+ screen_height = BackdropHeight;
+ firstframeadd = (unsigned long)pcurbuf;//EIP:53740 Storing the first frame address and unread buffer length of the first frame to a static global variable
+ return (BackdropWidth << 16) | BackdropHeight;
+#else
+ LeftMargin = ( screen_width - BackdropWidth ) / 2;
+ TopMargin = ( screen_height - BackdropHeight ) / 2;
+#if DEBUG
+ printf("LeftMargin = %d, TopMargin = %d\n", LeftMargin, TopMargin);
+#endif
+ if (FillColor > 0)
+ {
+ /* Set the default color palette. Flood the backdrop region with
+ the FillColor. */
+ setbank( 0 );
+ Width = BackdropWidth;
+ Height = BackdropHeight;
+ LeftEdge = 0;
+ TopEdge = 0;
+ RightEdge = LeftEdge + Width - 1;
+ BottomEdge = TopEdge + Height - 1;
+ Interlaced = 0;
+#if DEBUG
+ printf("LeftEdge = %d, RightEdge = %d, Width = %d\n", LeftEdge, RightEdge, Width);
+ printf("TopEdge = %d, BottomEdge = %d, Height = %d\n", TopEdge, BottomEdge, Height);
+#endif
+ X = LeftEdge;
+ Y = TopEdge;
+ InterlacePass = 0;
+ {
+ PixelAdd = ( Y + TopMargin ) * (unsigned long)screen_width + ( X + LeftMargin );
+ if( CurrentBank != (PixelAdd >> 16) )
+ setbank((unsigned int)(PixelAdd >> 16));
+ }
+ for( ; Y <= BottomEdge ; Y++ )
+ for( ; X <= BottomEdge ; X++ )
+ writepixel( (unsigned char)FillColor );
+ }
+ return donext();
+#endif
+}
+
+#if TIANO
+unsigned long donext( unsigned char * BlitBuf )
+#else
+unsigned long far _loadds donext( )
+#endif
+{
+ unsigned int Done;
+ short Id; /* object identifier */
+ short Status; /* return status code */
+ unsigned long ret = 0;
+
+#if TIANO
+ blitbuf = BlitBuf;
+#endif
+ Done = FALSE;
+ /* Now display one or more GIF objects */
+ while(!Done)
+ {
+ switch (readbuf())
+ {
+ case ';':
+ /* End of the GIF dataset */
+ Done = TRUE;
+ break;
+
+ case ',':
+ /* Start of an image object.
+ Read the image description. */
+ if (!ReadImageDesc())
+ {
+ /* Invalid GIF dataset */
+#if DEBUG
+ printf("\nnot a GIF file - 2\n");
+#endif
+ ret = 0xffffffffL;
+ Done = TRUE;
+ break;
+ }
+ /* Setup the color palette for the image */
+ if (LocalNumColors > 0)
+ {
+ /* Change the palette table */
+ SetPalette( LocalColorMap, LocalNumColors );
+ GlobalColorMapActive = FALSE;
+ }
+ else if (DefaultNumColors > 0)
+ {
+ /* Reset the palette table back to the default setting */
+ if( !GlobalColorMapActive )
+ {
+ SetPalette( GlobalColorMap, DefaultNumColors );
+ GlobalColorMapActive = TRUE;
+ }
+ }
+
+ X = LeftEdge;
+ Y = TopEdge;
+ RightEdge = LeftEdge + Width - 1;
+ BottomEdge = TopEdge + Height - 1;
+
+ ///Need to update the image based on the current frame coordinates.
+ gGifSrcX = (UINT16)LeftEdge;
+ gGifSrcY = (UINT16)TopEdge;
+ if(Width) gGifDestX = (UINT16)Width-1;
+ if(Height) gGifDestY = (UINT16)Height-1;
+ GifImageFlag=1;
+
+#if DEBUG
+ printf("LeftEdge = %d, RightEdge = %d, Width = %d\n", LeftEdge, RightEdge, Width);
+ printf("TopEdge = %d, BottomEdge = %d, Height = %d\n", TopEdge, BottomEdge, Height);
+#endif
+ InterlacePass = 0;
+ {
+ PixelAdd = ( Y + TopMargin ) * (unsigned long)screen_width + ( X + LeftMargin );
+ if( CurrentBank != (PixelAdd >> 16) )
+ setbank((unsigned int)(PixelAdd >> 16));
+
+ }
+
+ Status = Expand_Data();
+
+ if (Status != 0)
+ {
+ /* Error expanding the raster image */
+#if DEBUG
+ printf("\nnot a GIF file - 3\n");
+#endif
+ ret = 0xffffffffL;
+ Done = TRUE;
+ break;
+ }
+ break;
+
+ case '!':
+ /* Start of an extended object (not in rev 87a) */
+ Id = readbuf(); /* Get the object identifier */
+ if (Id < 0)
+ {
+ /* Error reading object identifier */
+#if DEBUG
+ printf("\nnot a GIF file - 4\n");
+#endif
+ ret = 0xffffffffL;
+ Done = TRUE;
+ break;
+ }
+ switch ( Id )
+ {
+ case 0xF9:
+ ret = ReadGraphicControlExt();
+ if( ret != 0 )
+ {
+#if DEBUG
+ if (ret == 0xffffffffL)
+ printf("\nnot a GIF file - 9\n");
+#endif
+ Done = TRUE;
+ }
+ break;
+#if DEBUG
+ case 0xFE:
+ if (!ReadCommentExt())
+ {
+ printf("\nnot a GIF file - 6\n");
+ ret = 0xffffffffL;
+ Done = TRUE;
+ }
+ break;
+ case 0x01:
+ if (!ReadPlainTextExt())
+ {
+ printf("\nnot a GIF file - 7\n");
+ ret = 0xffffffffL;
+ Done = TRUE;
+ }
+ break;
+ case 0xFF:
+ if (!ReadApplicationExt())
+ {
+ printf("\nnot a GIF file - 8\n");
+ ret = 0xffffffffL;
+ Done = TRUE;
+ }
+ break;
+#endif
+ default:
+ /* Since there no extented objects defined in rev 87a, we
+ will just skip over them. In the future, we will handle
+ the extended object here. */
+ if (!SkipObject())
+ {
+#if DEBUG
+ printf("\nnot a GIF file - 5\n");
+#endif
+ ret = 0xffffffffL;
+ Done = TRUE;
+ }
+ break;
+ }
+ break;
+
+ default:
+ /* Error */
+#if DEBUG
+ printf("\nnot a GIF file - 10\n");
+#endif
+ ret = 0xffffffffL;
+ Done = TRUE;
+ break;
+ }
+ }
+#if DEBUG
+ printf("offset = %lx\n", lenbuf-unreadbuf);
+ printf("wait = %ld\n", ret);
+#endif
+ if( (ret > 0) && (ret < 100) )
+ ret = 100;
+ return ret;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: readbuf
+//
+// Description: Read the next byte from buffer
+//
+// Input: None
+//
+// Output: 0 .. 255 the byte
+// -1 end of file
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static int _inline readbuf( )
+{
+
+ if( unreadbuf == 0 )
+ return -1;
+
+ unreadbuf--;
+#if TIANO
+ return (((int)*pcurbuf++)&0xff);
+#else
+ return (int) *pcurbuf++;
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: writepixel
+//
+// Description: Write a pixel at (X,Y) on the screen.
+//
+// Input: unsigned char Pixel
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static void _inline writepixel(unsigned char Pixel)
+{
+ unsigned char far * fp;
+ // Display the pixel on the screen
+ if( Pixel != TransparentColor )
+ {
+#if TIANO
+ fp = blitbuf + PixelAdd * 4;
+ *fp++ = pColorMap[Pixel].blue;
+ *fp++ = pColorMap[Pixel].green;
+ *fp++ = pColorMap[Pixel].red;
+ *fp++ = 0;
+#else
+ fp = _MK_FP( 0xa000, PixelAdd );
+ *fp = Pixel;
+#endif
+ }
+ // Advance the point
+ X++;
+ PixelAdd++;
+ if (X > RightEdge)
+ {
+ X = LeftEdge;
+
+ if (Interlaced)
+ {
+ Y += LineOffset[InterlacePass];
+ if (Y > BottomEdge)
+ {
+ InterlacePass++;
+ Y = TopEdge + BaseLine[InterlacePass];
+ }
+ }
+ else
+ Y++;
+ PixelAdd = ( Y + TopMargin ) * (unsigned long)screen_width + ( X + LeftMargin );
+ }
+ if( CurrentBank != (PixelAdd >> 16) )
+ setbank((unsigned int)(PixelAdd >> 16));
+}
+
+static void setbank(unsigned int bank)
+{
+ CurrentBank = bank;
+#if TIANO == 0
+ _asm
+ {
+ mov ax,4f05h
+ mov bx,0
+ mov dx,CurrentBank
+ int 10h
+ /*mov retvesa,ax*/
+ }
+
+ _asm
+ {
+ mov ax,4f05h
+ mov bx,1
+ mov dx,CurrentBank
+ int 10h
+ /*mov retvesa,ax*/
+ }
+
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReadScreenDesc
+//
+// Description: Read the signature, the screen description, and the optional
+// default color map.
+//
+// Input: None
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static short ReadScreenDesc( )
+{
+ unsigned char Buffer[16];
+
+ short
+ I, J,
+ Status,
+ HaveColorMap,
+ NumPlanes;
+
+ for (I = 0; I < 13; I++)
+ {
+ Status = readbuf();
+ if (Status < 0) return FALSE;
+ Buffer[I] = (unsigned char) Status;
+ }
+
+ for (I = 0; I < 6; I++)
+ if (Buffer[I] != GIF87signature[I])
+ break;
+ if (I >= 6)
+ GIFversion = GIF87;
+ else
+ {
+ for (I = 0; I < 6; I++)
+ if (Buffer[I] != GIF89signature[I])
+ break;
+ if (I >= 6)
+ GIFversion = GIF89;
+ else
+ return FALSE;
+ }
+
+ BackdropWidth = Buffer[6] | Buffer[7] << 8;
+ BackdropHeight = Buffer[8] | Buffer[9] << 8;
+ NumPlanes = (Buffer[10] & 0x07) + 1;
+ ColorRez = ((Buffer[10] & 0x70) >> 4) + 1;
+ HaveColorMap = (Buffer[10] & 0x80) != 0;
+ DefaultNumColors = 1 << NumPlanes;
+ FillColor = Buffer[11];
+
+ if (HaveColorMap)
+ {
+ for (I = 0; I < DefaultNumColors; I++)
+ {
+ for (J = 0; J < 3; J++)
+ {
+ Status = readbuf();
+ if (Status < 0) return FALSE;
+ Buffer[J] = (unsigned char) Status;
+ }
+
+ if (I < MaxColors)
+ {
+ GlobalColorMap[I].red = Buffer[0];
+ GlobalColorMap[I].green = Buffer[1];
+ GlobalColorMap[I].blue = Buffer[2];
+ }
+ }
+ }
+ else
+ DefaultNumColors = 0;
+
+ return TRUE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReadImageDesc
+//
+// Description: Read the image description and the optional color map.
+//
+// Input: None
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static short ReadImageDesc( )
+{
+ unsigned char Buffer[16];
+
+ short
+ I, J,
+ NumPlanes,
+ HaveColorMap,
+ Status;
+
+ for (I = 0; I < 9; I++)
+ {
+ if ((Status = readbuf()) < 0) return FALSE;
+ Buffer[I] = (unsigned char) Status;
+ }
+
+ LeftEdge = Buffer[0] | Buffer[1] << 8;
+ TopEdge = Buffer[2] | Buffer[3] << 8;
+ Width = Buffer[4] | Buffer[5] << 8;
+ Height = Buffer[6] | Buffer[7] << 8;
+ NumPlanes = (Buffer[8] & 0x07) + 1;
+ LocalNumColors = 1 << NumPlanes;
+ Interlaced = (Buffer[8] & 0x40) != 0;
+ HaveColorMap = (Buffer[8] & 0x80) != 0;
+
+ if (HaveColorMap)
+ {
+ for (I = 0; I < LocalNumColors; I++)
+ {
+ for (J = 0; J < 3; J++)
+ {
+ if ((Status = readbuf()) < 0) return FALSE;
+ Buffer[J] = (unsigned char) Status;
+ }
+
+ if (I < MaxColors)
+ {
+ LocalColorMap[I].red = Buffer[0];
+ LocalColorMap[I].green = Buffer[1];
+ LocalColorMap[I].blue = Buffer[2];
+ }
+ }
+ }
+ else
+ LocalNumColors = 0;
+
+ return TRUE;
+}
+
+static unsigned long ReadGraphicControlExt()
+{
+ unsigned char Buffer[6];
+ short I;
+ short Status;
+ short HaveTransparentColor;
+ unsigned long timewait;
+
+#if DEBUG
+ printf("Graphic Control Extension : ");
+#endif
+ for (I = 0; I < 6; I++)
+ {
+ if ((Status = readbuf()) < 0) return 0xffffffffL;
+ Buffer[I] = (unsigned char) Status;
+ }
+ timewait = (Buffer[2] | Buffer[3] << 8)*10;
+ HaveTransparentColor = (Buffer[1] & 0x01) != 0;
+ if (HaveTransparentColor)
+ TransparentColor = Buffer[4];
+#if DEBUG
+ printf("%ld\n", timewait);
+#endif
+ return timewait;
+}
+
+#if DEBUG
+static short ReadCommentExt()
+{
+ short Count;
+ short c;
+
+ printf("Comment Extension : ");
+ while ((Count = readbuf()) > 0)
+ {
+ printf("\n#");
+ do
+ {
+ if ((c = readbuf()) < 0)
+ return FALSE;
+ printf("%c", c);
+ }while (--Count > 0);
+ printf("#");
+ }
+ if (Count < 0)
+ return FALSE;
+ printf("\n");
+ return TRUE;
+}
+
+static short ReadPlainTextExt()
+{
+ unsigned char Buffer[13];
+ short I;
+ short Status;
+ short Count;
+ short c;
+
+ printf("Plain Text Extension : ");
+ for (I = 0; I < 13; I++)
+ {
+ if ((Status = readbuf()) < 0) return FALSE;
+ Buffer[I] = (unsigned char) Status;
+ }
+ while ((Count = readbuf()) > 0)
+ {
+ printf("\n#");
+ do
+ {
+ if ((c = readbuf()) < 0)
+ return FALSE;
+ printf("%c", c);
+ }while (--Count > 0);
+ printf("#");
+ }
+ if (Count < 0)
+ return FALSE;
+ printf("\n");
+ return TRUE;
+}
+
+static short ReadApplicationExt()
+{
+ unsigned char Buffer[13];
+ short I;
+ short Status;
+ short Count;
+ short c;
+
+ printf("Application Extension : ");
+ for (I = 0; I < 12; I++)
+ {
+ if ((Status = readbuf()) < 0) return FALSE;
+ Buffer[I] = (unsigned char) Status;
+ }
+ for (I = 1; I < 9; I++)
+ printf("%c", Buffer[I]);
+ printf(" ");
+ for (I = 9; I < 12; I++)
+ printf("%c", Buffer[I]);
+ while ((Count = readbuf()) > 0)
+ {
+ printf("\n%2.2X", Count);
+ do
+ {
+ if ((c = readbuf()) < 0)
+ return FALSE;
+ printf("%2.2X", c);
+ }while (--Count > 0);
+ }
+ if (Count < 0)
+ return FALSE;
+ printf("\n");
+ return TRUE;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SkipObject
+//
+// Description: Skip over an extended GIF object.
+//
+// Input: None
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static short SkipObject()
+{
+ short Count;
+
+ while ((Count = readbuf()) > 0)
+ do
+ {
+ if (readbuf() < 0)
+ return FALSE;
+ }while (--Count > 0);
+ if (Count < 0)
+ return FALSE;
+ return TRUE;
+}
+
+void SetPalette( struct ColorEntry ColorMap[], unsigned int num_colors )
+{
+#if TIANO
+ pColorMap = ColorMap;
+ num_colors;
+ return;
+#else
+ int i;
+ int bitofcolor;
+ int retvesa;
+ unsigned int segval, offval;
+ unsigned char far * fp;
+
+ _asm
+ {
+ mov ax,4f08h
+ mov bx,0001h
+ int 10h
+ mov retvesa,ax
+ mov bitofcolor,bx
+ }
+ if(retvesa != 0x004f)
+ bitofcolor = 8;
+ else
+ bitofcolor >>= 8;
+ if( 8 != bitofcolor )
+ {
+ if( 8 > bitofcolor )
+ for (i = 0; i < num_colors; i++)
+ {
+ ColorMap[i].red >>= (8 - bitofcolor);
+ ColorMap[i].green >>= (8 - bitofcolor);
+ ColorMap[i].blue >>= (8 - bitofcolor);
+ }
+ else
+ for (i = 0; i < num_colors; i++)
+ {
+ ColorMap[i].red <<= (bitofcolor - 8);
+ ColorMap[i].green <<= (bitofcolor - 8);
+ ColorMap[i].blue <<= (bitofcolor - 8);
+ }
+ }
+ fp = (unsigned char far *)ColorMap;
+ segval = _FP_SEG( fp );
+ offval = _FP_OFF( fp );
+ _asm
+ {
+ push di
+ mov ax,4f09h
+ mov bl,0
+ mov cx,num_colors
+ mov dx,0
+ mov di,segval
+ mov es,di
+ mov di,offval
+ int 10h
+ mov retvesa,ax
+ pop di
+ }
+
+#endif
+}
+
+// Expander
+#if TIANO
+static int _inline init_table(short min_code_size)
+#else
+static int _inline init_table(min_code_size)
+ short min_code_size;
+#endif
+ {
+ code_size = min_code_size + 1;
+ clear_code = 1 << min_code_size;
+ eof_code = clear_code + 1;
+ first_free = clear_code + 2;
+ free_code = first_free;
+ max_code = 1 << code_size;
+ return 0; //WARN FIX
+ }
+
+static int _inline read_code()
+ {
+ short bytes_to_move, i, ch;
+ long temp;
+
+ byte_offset = bit_offset >> 3;
+ bits_left = bit_offset & 7;
+
+ if (byte_offset >= 61)
+ {
+ bytes_to_move = 64 - byte_offset;
+
+ for (i = 0; i < bytes_to_move; i++)
+ code_buffer[i] = code_buffer[byte_offset + i];
+
+ while (i < 64)
+ {
+ if (bytes_unread == 0)
+ {
+ /* Get the length of the next record. A zero-length record
+ * denotes "end of data".
+ */
+ if( endofdata )
+ break;
+
+ if( unreadbuf > 0 )
+ {
+ bytes_unread = *pcurbuf++;
+ unreadbuf--;
+ }
+ else
+ {
+ UnexpectedError = TRUE;
+ return -1;
+ }
+
+ if (bytes_unread == 0) /* end of data */
+ {
+ endofdata = TRUE;
+ break;
+ }
+ }
+
+ if( unreadbuf > 0 )
+ {
+ ch = *pcurbuf++;
+ unreadbuf--;
+ }
+ else
+ {
+ UnexpectedError = TRUE;
+ return -1;
+ }
+
+#if TIANO
+ code_buffer[i++] = (char)ch;
+#else
+ code_buffer[i++] = ch;
+#endif
+ bytes_unread--;
+ }
+
+ bit_offset = bits_left;
+ byte_offset = 0;
+ }
+
+ bit_offset += code_size;
+ temp = (long) code_buffer[byte_offset]
+ | (long) code_buffer[byte_offset + 1] << 8
+ | (long) code_buffer[byte_offset + 2] << 16;
+
+ if (bits_left > 0)
+ temp >>= bits_left;
+
+ return temp & mask[code_size - 1];
+ }
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Expand_Data
+//
+// Description: Decompress a LZW compressed data stream.
+//
+// Input: None
+//
+// Output: 0 OK
+// -1 expected end-of-file
+// -2 cannot allocate memory
+// -3 bad "min_code_size"
+// < -3 error status from the get_byte or put_byte routine
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static short Expand_Data( )
+{
+#if TIANO == 0
+ short i;
+#endif
+ short sp; /* stack ptr */
+#if TIANO == 0
+ short status;
+#endif
+ short min_code_size;
+
+ /* Get the minimum code size (2 to 9) */
+
+ if( unreadbuf > 0 )
+ {
+ min_code_size = *pcurbuf++;
+ unreadbuf--;
+ }
+ else
+ return -4;
+
+ if (min_code_size < 2 || min_code_size > 9)
+ return -3;
+
+ init_table(min_code_size);
+ sp = 0;
+ bit_offset = 64*8; /* force "read_code" to start a new */
+ bytes_unread = 0; /* record */
+ endofdata = FALSE;
+
+ while ((code = read_code()) != eof_code)
+ {
+ if( UnexpectedError )
+ return -4;
+ if (code == clear_code)
+ {
+ init_table(min_code_size);
+ code = read_code();
+ if( UnexpectedError )
+ return -4;
+ old_code = code;
+ suffix_char = code;
+ final_char = code;
+ //(*put_byte)(suffix_char);
+ writepixel((unsigned char)suffix_char);
+ }
+ else
+ {
+ input_code = code;
+
+ if (code >= free_code)
+ {
+ code = old_code;
+#if TIANO
+ code_table[sp++].stack = (char)final_char;
+#else
+ code_table[sp++].stack = final_char;
+#endif
+ }
+
+ while (code >= first_free)
+ {
+ code_table[sp++].stack = code_table[code].suffix;
+ code = code_table[code].prefix;
+ }
+
+ final_char = code;
+ suffix_char = code;
+#if TIANO
+ code_table[sp++].stack = (char)final_char;
+#else
+ code_table[sp++].stack = final_char;
+#endif
+
+ while (sp > 0)
+ //(*put_byte)(code_table[--sp].stack);
+ writepixel((unsigned char)code_table[--sp].stack);
+
+#if TIANO
+ code_table[free_code].suffix = (char)suffix_char;
+#else
+ code_table[free_code].suffix = suffix_char;
+#endif
+ code_table[free_code].prefix = old_code;
+ free_code++;
+ old_code = input_code;
+
+ if (free_code >= max_code)
+ if (code_size < 12)
+ {
+ code_size++;
+ max_code <<= 1;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/dogifmgr.c b/EDK/MiniSetup/TseAdvanced/dogifmgr.c
new file mode 100644
index 0000000..03eb6e0
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/dogifmgr.c
@@ -0,0 +1,486 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/dogifmgr.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 10 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/dogifmgr.c $
+//
+// 10 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 3/29/11 6:59p Madhans
+// To fix the function header
+//
+// 8 3/28/11 9:38p Arunsb
+// [TAG] EIP55548
+// [Category] Improvement
+// [Description] Support to display Multiple GIF and display other image
+// format when Active animated Gif is displaying.
+// [Files] dogif.c and dogifmgr.c
+//
+// 7 3/21/11 1:19a Rajashakerg
+// [TAG] EIP53740
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Animation does not continue after the last frame of the
+// logo.
+// [RootCause] Animation is continued upto the last frame of the
+// animated image
+// [Solution] Fixed the issue by handling Gif image data to redraw image
+// if all the frames are completed and if boottimeout is present.
+// [Files] minisetup.h, dogif.c, dogifmgr.c
+//
+// 6 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 12 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 11 1/09/10 4:46a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 10 12/04/09 7:13a Mallikarjunanv
+// Fix for EIP:30263 - Gif Logo Issue
+//
+// 9 10/28/09 5:37p Madhans
+// To do the clean up.
+//
+// 8 9/02/09 7:39p Madhans
+// To Realy fix the Logo Security issue
+//
+// 7 8/13/09 12:15p Blaines
+// Move Image support to binary module
+//
+// 6 7/09/09 10:56a Madhans
+// To fix the compilation error
+//
+// 4 6/24/09 6:10p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 6/30/06 4:21p Madhans
+// To Integrate the PCX and Jpeg Support. SDL tokens created to support
+// different image formats.
+//
+// 2 6/16/06 3:40p Madhans
+// 64 Bit Support. Set SDL token TSE_FOR_64BIT for 64 bit support.
+//
+// 1 1/24/06 3:01a Stefanor
+// quiet boot support
+// implementation of buffering for POST messages
+// gif support
+// support for OEM badging protocol
+// fixed fallback from 100x31 to 80x25
+// cleanup of set graphic/text mode
+// ver 1.17.1051
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: dogifmgr.c
+//
+// Description: This file contains code for gif image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//#if SETUP_GIF_LOGO_SUPPORT
+//static EFI_EVENT NextFrameEvent;
+//static EFI_UGA_PIXEL *UgaBltForGif = NULL;
+//static UINT8 *ImageDataForGif = NULL;
+//static CO_ORD_ATTRIBUTE GifAttribute;
+//static UINTN GifWidth, GifHeight, GifX, GifY, GifBufferWidth;
+static UINTN gGifDelay, animateDelay;
+//#endif
+
+extern unsigned long dofirst( unsigned char *, unsigned long );
+extern unsigned long donext( unsigned char * );
+
+UINT64 RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+//EIP: 55548: To display multiple gif
+typedef struct //Structure to preserve the various gif images data
+{
+ UINTN GifWidth;
+ UINTN GifHeight;
+ UINTN GifX;
+ UINTN GifY;
+ UINTN GifBufferWidth;
+ EFI_EVENT GifEvent;
+ EFI_UGA_PIXEL *UgaBltForGif;
+ CO_ORD_ATTRIBUTE GifAttribute;
+ unsigned char *GifCurBufLocation;
+ unsigned char *ImageBuffer;
+ UINTN ImageSize;
+ unsigned long FistFrameAddress;
+} GIF_ANIMATE_DATA;
+
+struct GIF_IMAGE_DATAS //Structure used to cleanup the logo buffers
+{
+ GIF_ANIMATE_DATA *GifAnimateData;
+ struct GIF_IMAGE_DATAS *Next;
+};
+
+struct GIF_IMAGE_DATAS *GifEntries;
+GIF_ANIMATE_DATA *GifAnimateData;
+extern unsigned char *pcurbuf;
+extern unsigned long firstframeadd; //EIP: 53740 preserving first frame address for drawing the gif image until the time out occurs
+void SaveCleanUpGifDatas (GIF_ANIMATE_DATA **GifDatas);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetGifNextFrame
+//
+// Description:
+//
+// Input: VOID **UgaBlt , UINTN *GifDelay
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS
+GetGifNextFrame(IN OUT VOID **GifImageData, OUT UINTN *GifDelay)
+{
+ GIF_ANIMATE_DATA **GifData;
+ EFI_TPL OldTpl;
+
+ GifData = (GIF_ANIMATE_DATA **)GifImageData;
+
+ OldTpl = gBS->RaiseTPL(EFI_TPL_NOTIFY);
+ dofirst ((*GifData)->ImageBuffer, (unsigned long)(*GifData)->ImageSize);
+ while (pcurbuf != (*GifData)->GifCurBufLocation)
+ {
+ *GifDelay = donext ((unsigned char *)((*GifData)->UgaBltForGif));
+ }
+ *GifDelay = donext ((unsigned char *)((*GifData)->UgaBltForGif));
+ (*GifData)->GifCurBufLocation = pcurbuf;
+ gBS->RestoreTPL (OldTpl);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NextFrame
+//
+// Description: function to get the next frame.
+//
+// Input: EFI_EVENT Event, VOID *Context
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID NextFrame(IN EFI_EVENT Event, VOID *Context)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ GIF_ANIMATE_DATA *GifContextData = (GIF_ANIMATE_DATA *)Context;
+
+ if (NULL == GifContextData)
+ { //Add clean up function
+ return;
+ }
+ if (gPostStatus > TSE_POST_STATUS_IN_BOOT_TIME_OUT)// if boot timeout is occured then we have to clean the logo and return
+ {
+ CleanUpLogo ();
+ return;
+ }
+ GetGifNextFrame (&GifContextData, &gGifDelay);
+ if (gGifDelay >= 0)
+ {
+ DrawBltBuffer (GifContextData->UgaBltForGif, GifContextData->GifAttribute, GifContextData->GifWidth, GifContextData->GifHeight, GifContextData->GifX, GifContextData->GifY, GifContextData->GifBufferWidth);
+ //DrawBltBuffer(UgaBltForGif, GifAttribute, GifWidth, GifHeight, GifX, GifY, GifBufferWidth);
+ Status = gBS->SetTimer (GifContextData->GifEvent, TimerRelative, gGifDelay*10000);
+ if (EFI_ERROR (Status))
+ TimerStopTimer (GifAnimateData->GifEvent);
+ }
+ else
+ {
+ CleanUpLogo ();
+ }
+
+ if ((0 == gGifDelay) && (gPostStatus <= TSE_POST_STATUS_IN_BOOT_TIME_OUT))// checking gGifDelay and boot timeout to assing the first frame address to the current buffer pointer
+ {
+ GifContextData->GifCurBufLocation = (unsigned char *)GifContextData->FistFrameAddress;
+ }
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoGifAnimate
+//
+// Description: function to Handle gif logo animation
+//
+// Input: CO_ORD_ATTRIBUTE Attribute,
+// INTN CoordinateX,INTN CoordinateY
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID DoGifAnimate(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (animateDelay)
+ {
+ GifAnimateData->GifX = CoordinateX;
+ GifAnimateData->GifY = CoordinateY;
+ GifAnimateData->GifAttribute = Attribute;
+
+ Status = gBS -> CreateEvent (
+ EFI_EVENT_TIMER|EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_NOTIFY,
+ &NextFrame,
+ GifAnimateData, //NULL
+ &GifAnimateData->GifEvent); //NextFrameEvent
+ if (gEnterSetup == TRUE && !(EFI_ERROR (Status)))
+ {
+ CleanUpLogo();
+ return;
+ }
+ Status = gBS->SetTimer (GifAnimateData->GifEvent, TimerRelative, animateDelay*10000);
+ if (EFI_ERROR (Status)) {
+ TimerStopTimer (GifAnimateData->GifEvent);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertGifToUgaBlt
+//
+// Description: Convert a *.GIF graphics image to a UGA blt buffer. If a
+// NULL UgaBlt buffer is passed in a UgaBlt buffer will be
+// allocated by this routine. If a UgaBlt buffer is passed in
+// it will be used if it is big enough.
+//
+// Input: GifImage - Pointer to GIF file
+// GifImageSize - Number of bytes in BmpImage
+// UgaBlt - Buffer containing UGA version of GifImage.
+// UgaBltSize - Size of UgaBlt in bytes.
+// PixelHeight - Height of UgaBlt/BmpImage in pixels
+// PixelWidth - Width of UgaBlt/BmpImage in pixels
+// GifDelay -
+//
+// Output: EFI_SUCCESS - UgaBlt and UgaBltSize are returned.
+// EFI_UNSUPPORTED - GifImage is not a valid *.GIF image
+// EFI_BUFFER_TOO_SMALL - The passed in UgaBlt buffer is not big enough.
+// UgaBltSize will contain the required size.
+// EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS
+ConvertGifToUgaBlt (
+ IN VOID *GifImage,
+ IN UINTN GifImageSize,
+ IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth,
+ OUT UINTN *GifDelay
+ )
+{
+ UINT64 BltBufferSize;
+ UINTN Height;
+ UINTN Width;
+ EFI_TPL OldTpl;
+ unsigned char *TempCurBuf = NULL;
+ unsigned long tempfirstframeadd;
+
+// unsigned long tempstartunreadbuf;
+
+ OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY); // prepare BLT buffer for the GIF image
+ BltBufferSize = dofirst (GifImage, (unsigned long)GifImageSize);
+ gBS->RestoreTPL (OldTpl);
+
+ Width = (UINTN)RShiftU64(BltBufferSize,16);
+ Height = (UINTN)(BltBufferSize & 0xffff);
+
+ // Make sure to do x64 Mul
+ BltBufferSize = MultU64x32((UINT64)Width , Height);
+
+ /// Check whether the Size exceeds the limit...
+ // 4GB/PIXEL_SIZE becoz we need Resolution*PIXEL_SIZE for bltbuffer
+ if ( BltBufferSize >= (FOUR_GB_LIMIT/sizeof (EFI_UGA_PIXEL))) {
+ // The buffer size extends the limitation
+ return EFI_UNSUPPORTED;
+ }
+ BltBufferSize = MultU64x32( BltBufferSize ,sizeof (EFI_UGA_PIXEL));
+
+ if (*UgaBlt == NULL)
+ {
+ *UgaBltSize = (UINTN)BltBufferSize;
+ *UgaBlt = EfiLibAllocatePool (*UgaBltSize);
+ if (*UgaBlt == NULL) return EFI_OUT_OF_RESOURCES;
+ }
+ else
+ {
+ if (*UgaBltSize < (UINTN)BltBufferSize)
+ {
+ *UgaBltSize = (UINTN)BltBufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ //corrected the assignment.
+ *PixelWidth = Width;
+ *PixelHeight = Height;
+ OldTpl = gBS->RaiseTPL(EFI_TPL_NOTIFY);
+ BltBufferSize = dofirst (GifImage, (unsigned long)GifImageSize);
+ tempfirstframeadd = firstframeadd; //Using temp variable because call to allocatepool
+ gGifDelay = *GifDelay = donext ((unsigned char *)(*UgaBlt)); //may lead to trigger the previous gif events so pcurbuf value might change
+ TempCurBuf = pcurbuf;
+ gBS->RestoreTPL (OldTpl);
+ if (*GifDelay)
+ {
+ GifAnimateData = (GIF_ANIMATE_DATA *)EfiLibAllocateZeroPool (sizeof (GIF_ANIMATE_DATA));
+ if (NULL == GifAnimateData)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ GifAnimateData->ImageBuffer = GifImage;
+ GifAnimateData->ImageSize = GifImageSize;
+ GifAnimateData->FistFrameAddress = tempfirstframeadd;
+ GifAnimateData->GifWidth = Width;
+ GifAnimateData->GifHeight = Height;
+ GifAnimateData->GifBufferWidth = Width;
+ GifAnimateData->UgaBltForGif = *UgaBlt;
+ GifAnimateData->GifCurBufLocation = TempCurBuf;
+ GetGifNextFrame ((void **)&GifAnimateData, &gGifDelay);
+ animateDelay = gGifDelay;
+ SaveCleanUpGifDatas (&GifAnimateData);
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanUpGif
+//
+// Description: Cleans the gif datas
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID CleanUpGif (VOID)
+{
+ while (NULL != GifEntries)
+ {
+ gBS->CloseEvent (GifEntries->GifAnimateData->GifEvent);
+ MemFreePointer( (VOID **)&GifEntries->GifAnimateData->UgaBltForGif);
+ MemFreePointer( (VOID **)&GifEntries->GifAnimateData->ImageBuffer);
+ GifEntries = GifEntries->Next;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveCleanUpGifDatas
+//
+// Description: Saves the structures used for preserving the gif images
+//
+//
+// Input: GifDatas - Pointer to a pointer for GIF image structure
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+void SaveCleanUpGifDatas (GIF_ANIMATE_DATA **GifDatas)
+{
+ struct GIF_IMAGE_DATAS *HoldGifData = NULL, *tempGifEntries = NULL;
+
+ HoldGifData = (struct GIF_IMAGE_DATAS *)EfiLibAllocateZeroPool (sizeof (struct GIF_IMAGE_DATAS));
+ if (NULL == HoldGifData)
+ {
+ return;
+ }
+ HoldGifData->GifAnimateData = *GifDatas;
+ HoldGifData->Next = NULL;
+ tempGifEntries = GifEntries;
+ if (NULL == tempGifEntries)
+ {
+ GifEntries = HoldGifData;
+ }
+ else
+ {
+ while (NULL != tempGifEntries->Next)
+ {
+ tempGifEntries = tempGifEntries->Next;
+ }
+ tempGifEntries->Next = HoldGifData;
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/iJpeg.c b/EDK/MiniSetup/TseAdvanced/iJpeg.c
new file mode 100644
index 0000000..42f2546
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/iJpeg.c
@@ -0,0 +1,253 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/iJpeg.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/iJpeg.c $
+//
+// 8 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 5/10/11 10:43a Madhans
+// [TAG] EIP59139
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Jpeg image with the resolution 1366x768 is not displayed in
+// Screen resolution 1366x768.
+// [RootCause] Jepg Algorithem does the decoding in 16 pixel boudary. As
+// 1366 is not in 16 bit boundary the image width is returned as 1376 to
+// make 16bit boundary.
+// [Solution] Once decoded the Blt buffer is formed with orginal
+// resolution from the image.
+// [Files] ijpeg.c
+//
+// 6 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 9 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 8 1/09/10 4:43a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 9/02/09 7:39p Madhans
+// To fix the Logo Security issue correctly.
+//
+// 6 8/13/09 12:15p Blaines
+// Move Image support to binary module
+//
+// 5 7/08/09 3:34p Madhans
+// Coding Standards.
+//
+// 4 6/24/09 6:10p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 9/26/06 4:03p Madhans
+// JpegC Implimentation
+//
+// 2 9/15/06 9:57a Shirinmd
+// Initialized UgaBlt buffer to 0
+//
+// 1 8/01/06 8:03a Shirinmd
+// Files for JPEG decoding (C version)
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: iJpeg.c
+//
+// Description: Adds jpeg Support.
+//
+//<AMI_FHDR_END>
+//*****************************************************************//
+#include "jpeg.h"
+
+BOOL GetJPEGDimensions(BYTE * pbyJPEGInputData, UINT32 * pun32Width, UINT32 * pun32Height);
+BOOL DecodeJPEG(WORD wXPos, WORD wYPos, BYTE * pbyJPEGInputData, BYTE * pbyJPEGOutputData, UINT32 un32BufferWidth, UINT32 un32BufferHeight);
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertJPEGToUgaBlt
+//
+// Description: Decode the JPEG and store the output in UGA format. The
+// JPEG images are stored in 16X16 blocks. Hence Buffer will
+// require width and hieght that are equal to or more than
+// the actual width and hieght. Buffer Width and Height will
+// be the lowest multipe of 16 that is equal to or greater than
+// the actual width and height.
+// Eg: For decoding an image with Actual sizes being 17X33 will
+// require a buffer of 32X48.
+//
+// Input: IN VOID *JPEGImage - Pointer to the memory that has the
+// JPEG Image that need to be decoded.
+// IN UINT32 JPEGImageSize - Size of the JPEG Image
+// IN OUT VOID **UgaBlt - Two cases
+// Case 1: Memory is expected to be allocated by the callee.
+// Address provided as input should be NULL.
+// pointer that will recieve the address of the UGA buffer.
+// The buffer is allocated by callee.
+// This buffer need to be freed by the caller.
+// Case 2: Memory is allocated by the caller
+// IN OUT UINT32 *UgaBltSize - Pointer that stores Size of UgaBlt
+// in bytes. This will be treated as an input. This should have
+// value ZERO for Case 2 above.
+// OUT UINT32 *PixelHeight - Height of UgaBlt/JPEG Image in pixels
+// OUT UINT32 *PixelWidth - Width of UgaBlt/JPEG Image in pixels
+// OUT UINT32 *pun32BufferWidth - Width of UgaBlt/JPEG Buffer
+//
+// Output: EFI_SUCCESS - The image was successfully decoded and placed in the buffer
+// EFI_UNSUPPORTED
+// EFI_BUFFER_TOO_SMALL
+// EFI_OUT_OF_RESOURCES
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ConvertJPEGToUgaBlt ( IN VOID *JPEGImage, IN UINT32 JPEGImageSize, IN OUT VOID **UgaBlt, IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth, OUT UINT32 *pun32BufferWidth)
+{
+ BOOL bStatus=FALSE;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT64 BltBufferSize =0;
+ UINT32 un32PadWidth= 0, un32PadHeight=0;
+
+ bStatus = GetJPEGDimensions(JPEGImage, PixelWidth, PixelHeight);
+
+ if(bStatus){
+//We need to add a little memory to deal cases when the Width or height is not a
+//multiple of 16 or else we need to add a fix with in output_8x8_image function
+ un32PadWidth = 16 - (*PixelWidth)%16;
+ if(un32PadWidth==16){
+ un32PadWidth = 0;
+ }
+ un32PadHeight = 16 - (*PixelHeight)%16;
+ if(un32PadHeight==16){
+ un32PadHeight = 0;
+ }
+ *pun32BufferWidth = *PixelWidth + un32PadWidth;
+
+ // Make sure to do x64 Mul
+ BltBufferSize = MultU64x32((UINT64)(*pun32BufferWidth) ,(*PixelHeight + un32PadHeight));
+
+ /// Check whether the Size exceeds the limit...
+ // 4GB/PIXEL_SIZE becoz we need Resolution*PIXEL_SIZE for bltbuffer
+ if ( BltBufferSize >= (FOUR_GB_LIMIT/sizeof (EFI_UGA_PIXEL))) {
+ // The buffer size extends the limitation
+ return EFI_UNSUPPORTED;
+ }
+
+ BltBufferSize = MultU64x32( BltBufferSize ,sizeof (EFI_UGA_PIXEL));
+
+ if(NULL!=*UgaBlt)
+ {
+ if (*UgaBltSize < (UINT32)BltBufferSize)
+ {
+ *UgaBltSize = (UINT32)BltBufferSize;
+ bStatus = FALSE;
+ Status = EFI_BUFFER_TOO_SMALL;
+ }
+ }
+ else
+ {
+ *UgaBltSize = (UINT32)BltBufferSize;
+ *UgaBlt = EfiLibAllocatePool((UINT32)BltBufferSize);
+ if(*UgaBlt == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ bStatus = FALSE;
+ }
+
+ }
+ if(TRUE==bStatus)
+ {
+ memset(*UgaBlt, (UINT32)BltBufferSize, 0 );
+ bStatus = DecodeJPEG(0,0, JPEGImage, *UgaBlt, *pun32BufferWidth , (*PixelHeight + un32PadHeight));
+ if(bStatus){
+ Status = EFI_SUCCESS;
+ if(un32PadWidth)
+ {
+ // Padding Done. Need to discard the Extra Width and Height.
+ EFI_UGA_PIXEL *BltBuf = NULL;
+ UINT32 i;
+
+ // Recalculate the actual Buffer
+ BltBufferSize = MultU64x32((UINT64)(*PixelWidth) ,*PixelHeight);
+ BltBufferSize = MultU64x32( BltBufferSize ,sizeof (EFI_UGA_PIXEL));
+ BltBuf = EfiLibAllocatePool((UINT32)BltBufferSize);
+
+ if(BltBuf == NULL)
+ { // Out of resources.
+ MemFreePointer( (VOID **)UgaBlt);
+ Status = EFI_OUT_OF_RESOURCES;
+ bStatus = FALSE;
+ }
+ // Copy the bltbuf for *PixelWidth in each line.
+ for(i=0;i<*PixelHeight;i++)
+ {
+ gBS->CopyMem((VOID*)&(BltBuf[(*PixelWidth * i)]),(VOID*)&(((EFI_UGA_PIXEL*)(*UgaBlt))[(*pun32BufferWidth * i)]),sizeof(EFI_UGA_PIXEL) * *PixelWidth);
+ }
+ *pun32BufferWidth = *PixelWidth; // Unpadded Width.
+ MemFreePointer( (VOID **)UgaBlt); // Free the Orgianl Blt.
+ *UgaBlt = (VOID*)BltBuf; // New blt
+ *UgaBltSize = (UINT32)BltBufferSize; // New size
+ }
+ }
+ }
+ }
+
+ return Status;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/ipcx.c b/EDK/MiniSetup/TseAdvanced/ipcx.c
new file mode 100644
index 0000000..ddc222c
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/ipcx.c
@@ -0,0 +1,188 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/ipcx.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/ipcx.c $
+//
+// 7 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 1/09/10 4:44a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 6 9/02/09 7:39p Madhans
+// To Realy fix the Logo Security issue
+//
+// 5 8/13/09 12:16p Blaines
+// Move Image support to binary module
+//
+// 4 6/24/09 6:10p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 7/06/06 6:41p Arunkumars
+// include minisetup.h
+// include tiano.h instead of efi.h
+//
+// 1 6/30/06 4:22p Madhans
+// PCX image support in C.
+//
+// 2 6/26/06 8:41a Shirinmd
+// Modifications based on design change suggested by Madhan
+//
+// 1 6/16/06 8:15a Shirinmd
+// Added PCX Support in C for Minisetup
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ipcx.c
+//
+// Description: This file contains code related to pcx image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+#include "MyDefs.h"
+
+
+BOOL DecodePCX(BYTE * pbyPCXInputData, BYTE * pbyPCXOutputData, DWORD dwPCXImageSize); //Function implemented in PCX_ADV.c
+BOOL GetPCXDimensions( BYTE * pbyPCXImageData, UINT32 * pun32Width, UINT32 * pun32Height); //Function implemented in PCX_ADV.c
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertPCXToUgaBlt
+//
+// Description: Decode the PCX Image and store the output in UGA Format
+//
+// Input: VOID *PCXImage - Pointer to the memory that has the PCX
+// Image that need to be decoded.
+// UINT32 PCXImageSize - Size of the PCX Image
+// OUT VOID **UgaBlt - Two cases
+// Case 1: Memory is expected to be allocated by the callee.
+// Address provided as input should be NULL.
+// pointer that will receive the address of the UGA buffer.
+// The buffer is allocated by callee.
+// This buffer need to be freed by the caller.
+// Case 2: Memory is allocated by the caller
+// OUT UINT32 *UgaBltSize - Pointer that stores Size of UgaBlt in bytes.
+// This will be treated as an input. This should have value ZERO for Case 2 above.
+// UINT32 *PixelHeight - Height of UgaBlt/PCX Image in pixels
+// UINT32 *PixelWidth - Width of UgaBlt/PCX Image in pixels
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ConvertPCXToUgaBlt ( IN VOID *PCXImage, IN UINT32 PCXImageSize, IN OUT VOID **UgaBlt, IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth){
+ BOOL bStatus = FALSE;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT64 unBltBufferSize = 0;
+ bStatus = GetPCXDimensions(PCXImage, PixelWidth, PixelHeight);
+ if(bStatus)
+ {
+ // Make sure to do x64 Mul
+ unBltBufferSize = MultU64x32((UINT64)(*PixelWidth), (*PixelHeight));
+
+ /// Check whether the Size exceeds the limit...
+ // 4GB/PIXEL_SIZE becoz we need Resolution*PIXEL_SIZE for bltbuffer
+ if ( unBltBufferSize >= (FOUR_GB_LIMIT/sizeof (EFI_UGA_PIXEL))) {
+ // The buffer size extends the limitation
+ return EFI_UNSUPPORTED;
+ }
+
+ unBltBufferSize = MultU64x32( unBltBufferSize ,sizeof (EFI_UGA_PIXEL));
+
+ if(NULL!=*UgaBlt)
+ {
+ if(*UgaBltSize<(UINT32)unBltBufferSize)
+ {
+ *UgaBltSize = (UINT32)unBltBufferSize;
+ Status = EFI_BUFFER_TOO_SMALL;
+ bStatus = FALSE;
+ }
+ }
+ else
+ {
+ *UgaBltSize = (UINT32)unBltBufferSize;
+ *UgaBlt = EfiLibAllocatePool((UINT32)unBltBufferSize);
+ if(NULL == *UgaBlt)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ bStatus = FALSE;
+ }
+ }
+ if(bStatus)
+ {
+ MemSet(*UgaBlt,*UgaBltSize,0);
+ bStatus = DecodePCX(PCXImage, *UgaBlt, PCXImageSize);
+ if(bStatus)
+ Status = EFI_SUCCESS;
+ }
+ }
+ return Status;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/jpeg.h b/EDK/MiniSetup/TseAdvanced/jpeg.h
new file mode 100644
index 0000000..39d66eb
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/jpeg.h
@@ -0,0 +1,106 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/jpeg.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/jpeg.h $
+//
+// 5 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 1/09/10 4:44a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 9/26/06 4:03p Madhans
+// JpegC Implimentation
+//
+// 1 8/01/06 8:03a Shirinmd
+// Files for JPEG decoding (C version)
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: jpeg.h
+//
+// Description: Header file for jpeg image format related code
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _JPEG_H_
+#define _JPEG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "MyDefs.h"
+#include "jpeg6.h"
+
+EFI_STATUS ConvertJPEGToUgaBlt ( IN VOID *JPEGImage, IN UINT32 JPEGImageSize, IN OUT VOID **UgaBlt, IN OUT UINT32 *UgaBltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth, OUT UINT32 *pun32BufferWidth);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //#ifndef _JPEG_H_
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/jpeg6.c b/EDK/MiniSetup/TseAdvanced/jpeg6.c
new file mode 100644
index 0000000..4ba6534
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/jpeg6.c
@@ -0,0 +1,1320 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/jpeg6.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 11 $
+//
+// $Date: 5/21/13 1:29a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/jpeg6.c $
+//
+// 11 5/21/13 1:29a Premkumara
+// [TAG] EIP114841
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When use the broken JPG file as user logo, system hangs up
+// CP:0xb4
+// [RootCause] When corrupted Jpeg image has no proper AC co-efficent
+// value in Huffman table then dc_value_length is incremented beyond its
+// range value.
+// [Solution] Checked dc_value_length boundary value.
+// [Files] Jpeg6.c
+//
+// 10 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 4/26/12 3:25a Arunsb
+// [TAG] EIP78033
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] YUV122 sampling JPEG image not displayed
+// [RootCause] No support for YUV122 sampling
+// [Solution] Support added for YUV122 sampling
+// [Files] jpeg6.c
+//
+// 8 5/03/11 1:42p Madhans
+// [TAG] EIP59177
+// [Category] Improvement
+// [Description] Support for JPEG with RSI markers. Fix to support logo
+// size that bigger then Screen resolution.
+// [Files] Logo.c
+// Jpeg6.c
+// commonHelper.c
+//
+// 7 4/29/11 4:44p Madhans
+// [TAG] EIP59177
+// [Category] Improvement
+// [Description] Support for JPEG with RSI markers. Fix to support logo
+// size that bigger then Screen resolution.
+// [Files] Logo.c
+// Jpeg6.c
+// commonHelper.c
+//
+// 6 9/27/10 7:47a Mallikarjunanv
+// EIP 40555 : To avoid Compilation issues with Fareast Windows.
+//
+// 5 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 1/09/10 4:43a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 6 8/13/09 12:16p Blaines
+// Move Image support to binary module
+//
+// 5 7/08/09 3:34p Madhans
+// Coding Standards.
+//
+// 4 6/29/09 12:46p Blaines
+// EIP #22305 Fix for improper JPEG Image size calculation logic
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 9/26/06 4:03p Madhans
+// JpegC Implimentation
+//
+// 5 9/22/06 3:23a Shirinmd
+// Added Support for JPEG Images having 1 Huffman Table and 1 Quantization
+// table
+//
+// 4 9/15/06 9:54a Shirinmd
+// Added the check to find the type of Huffman table
+//
+// 3 8/03/06 7:16a Shirinmd
+// Removed initialization of global buffers in InitGlobals function to
+// reduce code size
+//
+// 2 8/02/06 8:55a Shirinmd
+// Made changes to reduce the code size
+//
+// 1 8/01/06 8:03a Shirinmd
+// Files for JPEG decoding (C version)
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: jpeg6.c
+//
+// Description: Support for JPEG decoding
+//
+//<AMI_FHDR_END>
+//*****************************************************************//
+
+#include "Mydefs.h"
+#include "Jpeg6.h"
+
+
+//Globals_START
+
+UINTN unBitStreamOFFSET;
+BYTE bNumBitsRead;
+BYTE btempBitStreamByte;
+
+UINTN unSOF0;
+WORD wDCLumtable[13*3];
+WORD wACLumtable[170*3];
+WORD wDCChrtable[13*3];
+WORD wACChrtable[170*3];
+
+WORD space_image[256*4];
+AMI_TRUECOLOR_PIXEL_JPEG * ScreenBufferJPEG = (AMI_TRUECOLOR_PIXEL_JPEG *)NULL;
+
+WORD image_Y[64];
+WORD image_Y1[64];
+WORD image_Y2[64];
+WORD image_Y3[64];
+WORD image_Cr[64];
+WORD image_Cb[64];
+UINTN QT[2];
+UINTN HT[4];
+BYTE bQTLumTable[64];
+BYTE bQTChrTable[64];
+WORD jpeg_zigzag_order[] = { \
+ 0, 1, 5, 6, 14, 15, 27, 28, \
+ 2, 4, 7, 13, 16, 26, 29, 42, \
+ 3, 8, 12, 17, 25, 30, 41, 43, \
+ 9, 11, 18, 24, 31, 40, 44, 53, \
+ 10, 19, 23, 32, 39, 45, 52, 54, \
+ 20, 22, 33, 38, 46, 51, 55, 60, \
+ 21, 34, 37, 47, 50, 56, 59, 61, \
+ 35, 36, 48, 49, 57, 58, 62, 63 \
+ };
+
+WORD jpeg_zigzag_order_temp[64];
+
+
+WORD diff_Y ;
+WORD diff_Cr;
+WORD diff_Cb;
+WORD gRsi = 0;
+UINT32 g_un32BufferWidth ;
+UINT32 g_un32BufferHeight;
+
+//Globals_End
+
+
+//Function Declarations
+void BuildHuffmanCodeTable(WORD * pwHuffCodeTable ,BYTE * pbySrcHT);
+void HuffmanDecoding(WORD * pwDCCoeffTable, WORD * pwACCoeffTable, WORD * pwImage);
+void GetDCValue(WORD * pwHuffmanTable, WORD * pwValue, WORD * pwLengthDC_RunSizeAC);
+BOOL SearchHuffmanCode(WORD * pwSearchTablePos, WORD * pwHuffmanCodeValue, WORD wDc_value_length);
+BOOL GetEncodedBit();
+void ReadJPEGImage(WORD * pwDCCoeffTable, WORD * pwACCoeffTable, WORD * pwImage, WORD * diff, BYTE * pbySrcQT, int nLumFlag);
+void ReadJPEGImage_YUV(DWORD * pdwBuffer, WORD wSampling);
+void OutputJPEGImage_YUV(WORD wXPos, WORD wYPos, WORD wXLength, WORD wYLength, WORD wSampling);
+void Output8x8Image(WORD wLeft, WORD wTop, BYTE * pspace_image);
+BOOL InitJpegParams(BYTE * pbyImage);
+DWORD ConvertYCbCrToRGB(short Y, short Cb, short Cr);
+void InvertDCT(WORD * pwSource);
+void InvertDCT_xy(WORD * pwSource, WORD wVal);
+void GetTables(BYTE bNumQT, BYTE bNumHT);
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitGlobals
+//
+// Description: Initializes required global variables
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void InitGlobals(){
+ diff_Y = 0;
+ diff_Cr = 0;
+ diff_Cb = 0;
+ bNumBitsRead = 8;
+ btempBitStreamByte = 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DecodeJPEG
+//
+// Description: Decode the JPEG image into the given buffer at given position,
+// subject to the limit of the Buffer Width and Height
+//
+// Input: WORD wXPos - X Start Postion with in the Buffer
+// where the image need to be decoded
+// WORD wYPos - Y Start Postion with in the Buffer
+// where the image need to be decoded
+// BYTE * pbyJPEGInputData - Pointer that gives the memory location
+// where the Input data is available
+// BYTE * pbyJPEGOutputData - Pointer that gives the pointer
+// for the output buffer
+// UINT32 un32BufferWidth - Width of the output Buffer
+// UINT32 un32BufferHeight - Height of the output Buffer
+//
+// Output: BOOL - TRUE/FALSE Indicate whether the Decoding was successful
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL DecodeJPEG(WORD wXPos, WORD wYPos, BYTE * pbyJPEGInputData, BYTE * pbyJPEGOutputData, UINT32 un32BufferWidth, UINT32 un32BufferHeight){
+ WORD wX_Length=0, wY_Length=0;
+ ScreenBufferJPEG = (AMI_TRUECOLOR_PIXEL_JPEG *)pbyJPEGOutputData;
+ g_un32BufferWidth = un32BufferWidth ;
+ g_un32BufferHeight = un32BufferHeight;
+
+ gRsi = 0;
+ InitGlobals();
+
+ if(InitJpegParams(pbyJPEGInputData)){
+ wX_Length = (*(WORD*)((BYTE *)unSOF0+5)<<8)|*((BYTE *)unSOF0+6);
+ wY_Length = (*(WORD*)((BYTE *)unSOF0+3)<<8)|*((BYTE *)unSOF0+4);
+
+if((0x11==(*(BYTE *)(unSOF0+3+4+1+1+3)))&&(0x11==((*(BYTE *)(unSOF0+3+4+1+1+3+3)))))
+ {
+#if MKF_JPEG_YUV111_SUPPORT
+ if(0x11==(*(BYTE *)(unSOF0+3+4+1+1)))
+ OutputJPEGImage_YUV(wXPos, wYPos, wX_Length, wY_Length, 0x111);
+ else
+#endif
+ if(0x22==(*(BYTE *)(unSOF0+3+4+1+1)))
+ OutputJPEGImage_YUV(wXPos, wYPos, wX_Length, wY_Length, 0x122);
+ }
+ return TRUE;
+ }
+ else
+ return FALSE;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetJPEGDimensions
+//
+// Description: Get the dimensions (Width and Height) for the JPEG image
+//
+// Input: BYTE * pbyJPEGInputData - Pointer that gives the memory
+// location where the Input data is available
+// UINT32 * pun32Width - Pointer to the UINT32 variable that
+// will recieve the Width of the Image
+// UINT32 * pun32Height - Pointer to the UINT32 variable that
+// will recieve the Height of the Image
+//
+// Output: BOOL - TRUE/FALSE.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL GetJPEGDimensions(BYTE * pbyJPEGInputData, UINT32 * pun32Width, UINT32 * pun32Height){
+ if(InitJpegParams(pbyJPEGInputData)){
+ *pun32Width = (WORD)((*(WORD*)((BYTE *)unSOF0+5)<<8)|*((BYTE *)unSOF0+6));
+ *pun32Height= (WORD)((*(WORD*)((BYTE *)unSOF0+3)<<8)|*((BYTE *)unSOF0+4));
+ return TRUE;
+ }
+ else return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildHuffmanCodeTable
+//
+// Description: Builds the Huffman codes for the particular JPEG Huffman table.
+// By incrementing the offset of the Huffman table by 3,
+// the offset of the actual data is obtained. The first
+// 16 bytes represent the no: of code words for a paricular
+// bit-size. Having the bit-size and the no: of code words
+// for each bit-size, the Huffman code table is built.
+//
+// Input: WORD * pwHuffCodeTable - Pointer to the memory location
+// that contains the Huffman codes for the particular JPEG Huffman table.
+// BYTE * pbySrcHT - Pointer to the memory location that contains
+// the offset of the JPEG Huffman Table.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void BuildHuffmanCodeTable(WORD * pwHuffCodeTable ,BYTE * pbySrcHT){
+
+ BYTE * pbySrcHTCopy = NULL;
+ int nCounter=0;
+ int nOffSet=0;
+ BYTE wCodeSize = 1;
+ WORD wCodeWord = 0;
+
+ pbySrcHT += 1;
+ pbySrcHTCopy = pbySrcHT;
+ do{
+ for(nCounter=*pbySrcHT;nCounter>0; nCounter--){
+ pwHuffCodeTable[nOffSet++] = wCodeSize;
+ pwHuffCodeTable[nOffSet++] = wCodeWord++;
+ pwHuffCodeTable[nOffSet++] = *(pbySrcHTCopy+16);
+ pbySrcHTCopy++;
+ }
+ wCodeWord<<=1;
+ pbySrcHT++;
+ wCodeSize++;
+ }while(wCodeSize<=16);
+ pwHuffCodeTable[nOffSet] = 17;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReadJPEGImage
+//
+// Description: Reads the 8x8 matrix data for each of Y_0,Y_1,Y_2,Y_3,Cb and Cr.
+// The final output will be image data after inverse DCT is applied.
+//
+// Input: WORD * pwDCCoeffTable - DC Luminance/ Chrominance Huffman Table.
+// WORD * pwACCoeffTable - AC Luminance/ Chrominance Huffman Table.
+// WORD * pwImage - Pointer to the 8x8 matrix data for each of Y_0,Y_1,Y_2,Y_3,Cb and Cr.
+// WORD * pwDiff - Pointer to the variable that hold the differences of the DC coefficients.
+// Adds the difference to the Prev Dc coefficient value to get the present DC coefficient value.
+// BYTE * pbySrcQT - Pointer to the Quantization table.
+// int nLumFlag - Flag if it is set, indicates that the image component is luminance.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void ReadJPEGImage(WORD * pwDCCoeffTable, WORD * pwACCoeffTable, WORD * pwImage, WORD * diff, BYTE * pbySrcQT, int nLumFlag)
+{
+ int nCounter;
+ HuffmanDecoding(pwDCCoeffTable, pwACCoeffTable, pwImage);
+ *diff = *diff + pwImage[0];
+ pwImage[0] = *diff;
+
+ //DeQuantization
+ for(nCounter=0; nCounter<64; nCounter++)
+ {
+ pwImage[nCounter] = pwImage[nCounter] * (WORD)pbySrcQT[nCounter];
+ }
+
+ //InvertZigZagOrder
+ for(nCounter=0; nCounter<64; nCounter++)
+ {
+ jpeg_zigzag_order_temp[nCounter] = *((WORD *)((BYTE *)pwImage+(jpeg_zigzag_order[nCounter]<<1)));
+ }
+ memcpy(pwImage,jpeg_zigzag_order_temp, 128);
+ InvertDCT(pwImage);
+
+ if(nLumFlag)
+ {
+ //Add128
+ for(nCounter=0; nCounter<64; nCounter++)
+ pwImage[nCounter] +=128;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ReadJPEGImage_YUV
+//
+// Description: Reads the 8x8 matrix data for each of Y_0,Y_1,Y_2,Y_3,Cb and Cr.
+// The final output will be RGB pixel data.
+//
+// Input: DWORD * pdwBuffer - RGB format of image data.
+// WORD wSampling - Value tells whether image is YUV111(luminance
+// as well as chrominance is taken for every pixel) or
+// YUV122(luminance is taken for every pixel while chrominance
+// is taken as medium value for 2x2 block of pixels).
+// Since the sampling factor for Luminance is 2, all the pixel
+// values are stored, where as for Cb and Cr, only the average
+// of 2x2 pixels is stored.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void ReadJPEGImage_YUV(DWORD * pdwBuffer, WORD wSampling){
+ int nCounter = 0;
+ int nCbCrCounter = 0;
+ ReadJPEGImage(wDCLumtable, wACLumtable, image_Y, &diff_Y, bQTLumTable, 1);
+
+ if(0x122 ==wSampling)
+ {
+ ReadJPEGImage(wDCLumtable, wACLumtable, image_Y1,&diff_Y, bQTLumTable, 1);
+ ReadJPEGImage(wDCLumtable, wACLumtable, image_Y2,&diff_Y, bQTLumTable, 1);
+ ReadJPEGImage(wDCLumtable, wACLumtable, image_Y3,&diff_Y, bQTLumTable, 1);
+ }
+
+ ReadJPEGImage(wDCChrtable, wACChrtable, image_Cr,&diff_Cr, bQTChrTable, 0);
+ ReadJPEGImage(wDCChrtable, wACChrtable, image_Cb,&diff_Cb, bQTChrTable, 0);
+
+ for(nCounter=0; nCounter< 64; nCounter++){
+#if MKF_JPEG_YUV111_SUPPORT
+ if(0x111 ==wSampling)
+ pdwBuffer[nCounter] = ConvertYCbCrToRGB(image_Y[nCounter], image_Cr[nCounter], image_Cb[nCounter]);
+ else
+#endif
+ if(0x122 ==wSampling)
+ {
+ nCbCrCounter = (nCounter&0xfff7)/2;
+ pdwBuffer[nCounter] = ConvertYCbCrToRGB(image_Y[nCounter], image_Cr[nCbCrCounter], image_Cb[nCbCrCounter]);
+ pdwBuffer[64+nCounter] = ConvertYCbCrToRGB(image_Y1[nCounter], image_Cr[nCbCrCounter + 4], image_Cb[nCbCrCounter + 4]);
+ pdwBuffer[128+nCounter] = ConvertYCbCrToRGB(image_Y2[nCounter], image_Cr[nCbCrCounter + 32], image_Cb[nCbCrCounter + 32]);
+ pdwBuffer[192+nCounter] = ConvertYCbCrToRGB(image_Y3[nCounter], image_Cr[nCbCrCounter + 32 + 4], image_Cb[nCbCrCounter + 32 + 4]);
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HuffmanDecoding
+//
+// Description: This routine decodes the AC and DC coefficients using the
+// Huffman tables stored in the JPEG image.
+//
+// Input: WORD * pwDCCoeffTable - DC Luminance/ Chrominance Huffman Table.
+// WORD * pwACCoeffTable - AC Luminance/ Chrominance Huffman Table.
+// WORD * pwImage -Pointer to the memory location that contains the decoded data.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void HuffmanDecoding(WORD * pwDCCoeffTable, WORD * pwACCoeffTable, WORD * pwImage)
+{
+ int nBlockCount=0;
+
+ WORD wLengthDC_RunSizeAC = 0;
+ WORD wCoeffVal = 0;
+
+ memset(pwImage,(64*sizeof(WORD)),0);
+
+ GetDCValue(pwDCCoeffTable, &wCoeffVal, &wLengthDC_RunSizeAC);
+ pwImage[nBlockCount++] = wCoeffVal; // DC coefficient Value
+
+ for(;nBlockCount<64;nBlockCount++)
+ {
+ GetDCValue(pwACCoeffTable, &wCoeffVal, &wLengthDC_RunSizeAC);
+ if(0==wLengthDC_RunSizeAC){
+ break;
+ }
+ wLengthDC_RunSizeAC&=0x0F0;
+ wLengthDC_RunSizeAC>>=4;
+
+ for(;wLengthDC_RunSizeAC>0;wLengthDC_RunSizeAC--){
+ pwImage[nBlockCount++] = 0;
+ }
+
+ pwImage[nBlockCount] = wCoeffVal; // AC coefficient Value
+ }
+
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetDCValue
+//
+// Description: This routine returns the differences(DCCoefficientpresent -
+// DCCoefficientprev) for the DC coefficient. For AC coefficients,
+// it returns the actual AC coefficient value and Run/Size.
+//
+// Input: WORD * pwHuffmanTable - Pointer to the huffman table ?DC Luminance,
+// DC Chrominance, AC Luminance, AC Chrominance.
+// WORD * pwValue - Code Word (Actual Bit representation).
+// WORD * pwLengthDC_RunSizeAC - Indicates the no: of zeroes.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void GetDCValue(WORD * pwHuffmanTable, WORD * pwValue, WORD * pwLengthDC_RunSizeAC)
+{
+ WORD dc_value_length=0;
+ WORD wCoeffLen=0;
+ DWORD dwCoeffVal=0;
+ int i=0;
+
+ while(1)
+ {
+ wCoeffLen<<=1;
+ if(GetEncodedBit())
+ wCoeffLen|=0x1;
+
+ dc_value_length++;
+
+ if( 0xffff == dc_value_length ) //EIP-114841 Corrupted Jpeg
+ return;
+
+ if(SearchHuffmanCode(pwHuffmanTable, (WORD*)&wCoeffLen,dc_value_length)){
+ break;
+ }
+ };
+
+
+ *pwLengthDC_RunSizeAC = wCoeffLen;
+
+ wCoeffLen&=0x0f;
+
+ for(i=0;i<wCoeffLen;i++)
+ {
+ dwCoeffVal<<=1;
+ if(GetEncodedBit())
+ dwCoeffVal|=0x1;
+ }
+
+
+ if(0!=wCoeffLen--)
+ {
+ if(!( dwCoeffVal & (0x1<<(wCoeffLen%16)) ) )
+ {
+ wCoeffLen = (14+16) - wCoeffLen;
+
+ dwCoeffVal=(dwCoeffVal<<(wCoeffLen&0xff)) | 0x80000000;
+
+ *((signed int *)(&dwCoeffVal)) >>= (wCoeffLen&0xff);
+ dwCoeffVal++;
+ }
+ }
+
+ *pwValue = (WORD)dwCoeffVal;
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SearchHuffmanCode
+//
+// Description: Searches the Huffman code of the DC/AC Luminance/Chrominace
+// values in Huffman code tables and find the appropriate HuffmanCodeValue.
+//
+// Input: WORD * pwSearchTablePos - Pointer to the huffman table ?DC Luminance,
+// DC Chrominance, AC Luminance, AC Chrominance.
+// WORD * pwHuffmanCodeValue - Pointer to the variable that contains
+// the Huffman code value.
+// WORD wDc_value_length - No: of bits in the Huffman code.
+//
+// Output: BOOL - TRUE/FALSE.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL SearchHuffmanCode(WORD * pwSearchTablePos, WORD * pwHuffmanCodeValue, WORD wDc_value_length)
+{
+ BOOL bReturn = FALSE;
+
+ while(wDc_value_length>=(*pwSearchTablePos))
+ {
+ if(wDc_value_length==(*pwSearchTablePos))
+ {
+ if(*pwHuffmanCodeValue==*(pwSearchTablePos+1))
+ {
+ *pwHuffmanCodeValue=*(pwSearchTablePos+2);
+ bReturn = TRUE;
+ break;
+ }
+ }
+ pwSearchTablePos+=3;
+ }
+ return bReturn;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetEncodedBit
+//
+// Description: Reads bits from the stream and returns whether the carry
+// flag is set or not.
+//
+// Input: None
+//
+// Output: BOOL - TRUE/FALSE depending on whether the Carry flag is set or not.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL GetEncodedBit()
+{
+
+ UINTN unBitStreamOFFSETCopy;
+ BYTE bStreamData;
+
+ unBitStreamOFFSETCopy = unBitStreamOFFSET;
+ if(8==bNumBitsRead){
+ bStreamData=*(BYTE *)(unBitStreamOFFSETCopy++);
+ if(0xff==bStreamData){
+ if(0!=(*(BYTE *)(unBitStreamOFFSETCopy++))){
+ bStreamData=*(BYTE *)(unBitStreamOFFSETCopy++);
+ }
+ }
+ unBitStreamOFFSET = unBitStreamOFFSETCopy;
+ btempBitStreamByte = bStreamData;
+ bNumBitsRead=0;
+ }
+ bNumBitsRead++;
+ bStreamData = btempBitStreamByte;
+
+ if( (bStreamData&(0x1<<(8-bNumBitsRead))) ){
+ return TRUE;
+ }
+ else{
+ return FALSE;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OutputJPEGImage_YUV
+//
+// Description: This functions writes to the Global Screen Buffer by calling
+// Output8x8Image function.
+//
+// Input: WORD wX_position - X Start Position within the output buffer
+// from where the image needs to be decoded.
+// WORD wY_position - Y Start Position within the output buffer
+// from where the image needs to be decoded.
+// WORD wX_length - Width of the image.
+// WORD wY_length - Height of the image.
+// WORD wSampling - Value tells whether image is YUV111(luminance
+// as well as chrominance is taken for every pixel) or YUV122
+// (luminance is taken for every pixel while chrominance is
+// taken as medium value for 2x2 block of pixels).
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void OutputJPEGImage_YUV(WORD wX_position, WORD wY_position, WORD wX_length, WORD wY_length, WORD wSampling)
+{
+ WORD Temp_X_Pos= wX_position;
+ WORD Temp_X_Len= wX_length;
+ UINTN BlkCount=0;
+
+ if(wSampling==0x122)
+ {
+ wY_length+= 0x0f;
+ wY_length >>=4;
+ }
+#if MKF_JPEG_YUV111_SUPPORT
+ else if(wSampling==0x111)
+ {
+ wY_length+= 0x07;
+ wY_length >>=3;
+ }
+#endif
+ for(;wY_length>0;wY_length--)
+ {
+ wX_position = Temp_X_Pos;
+ wX_length = Temp_X_Len;
+
+ if(wSampling==0x122)
+ {
+ wX_length+= 0x0f;
+ wX_length >>=4;
+
+ for(;wX_length>0;wX_length--)
+ {
+// memset(space_image,sizeof(space_image),0);
+ {
+ ReadJPEGImage_YUV((DWORD *)space_image,wSampling);
+ Output8x8Image(wX_position, wY_position, (BYTE *)space_image);
+ Output8x8Image(wX_position+8, wY_position, (BYTE *)space_image+256);
+ Output8x8Image(wX_position, wY_position+8, (BYTE *)space_image+(256*2));
+ Output8x8Image(wX_position+8, wY_position+8, (BYTE *)space_image+(256*3));
+ wX_position+=16;
+ BlkCount++;
+ // if Restart Interval valid Support for YUV122
+ if(gRsi && ((BlkCount%gRsi) == 0))
+ {
+ UINT8 *jpgScan = (UINT8*)unBitStreamOFFSET;
+ // It is going to be 0xFFD0 .. 0xFFD7
+ if((jpgScan[0] == 0xFF) && ((jpgScan[1]& 0xF8 ) == 0xD0))
+ {
+ // Restart the scan params
+ InitGlobals();
+ // Skip the Rsi maraker
+ unBitStreamOFFSET+=2;
+ }
+ }
+ }
+ }
+ wY_position+=16;
+ }
+#if MKF_JPEG_YUV111_SUPPORT
+ else if(wSampling==0x111)
+ {
+ wX_length+= 0x07;
+ wX_length >>=3;
+ for(;wX_length>0;wX_length--)
+ {
+ //memset(space_image,sizeof(space_image),wSampling);
+ ReadJPEGImage_YUV((DWORD *)space_image,wSampling);
+ Output8x8Image(wX_position, wY_position, (BYTE *)space_image);
+ wX_position+=8;
+ BlkCount++;
+ // if Restart Interval valid
+ if(gRsi && ((BlkCount%gRsi) == 0))
+ {
+ UINT8 *jpgScan = (UINT8*)unBitStreamOFFSET;
+ // It is going to be 0xFFD0 .. 0xFFD7
+ if((jpgScan[0] == 0xFF) && ((jpgScan[1]& 0xF8 ) == 0xD0))
+ {
+ // Restart the scan params
+ InitGlobals();
+ // Skip the Rsi maraker
+ unBitStreamOFFSET+=2;
+ }
+ }
+ }
+ wY_position+=8;
+ }
+#endif
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Output8x8Image
+//
+// Description: This functions writes to the Global Screen Buffer.
+//
+// Input: WORD wLeft - Left coordinate from where the Screen buffer
+// is to be filled.
+// WORD wTop - Top coordinate from where the Screen buffer is to be filled.
+// BYTE * pspace_image - Pointer to 8x8 block of image.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Output8x8Image(WORD wLeft, WORD wTop, BYTE * pspace_image){
+ int nCounterY=0;
+ int nCounterX=0;
+ AMI_TRUECOLOR_PIXEL_JPEG * pStartofLineInScreenBuffer = (AMI_TRUECOLOR_PIXEL_JPEG *)ScreenBufferJPEG + wTop * g_un32BufferWidth + wLeft;
+
+ for(;nCounterY<8;nCounterY++){
+ if((UINT32)(wTop + nCounterY) >= g_un32BufferHeight){
+ break;
+ }
+ for(nCounterX=0;nCounterX<8; nCounterX++){
+ if( (UINT32)(wLeft + nCounterX) < g_un32BufferWidth){
+ (pStartofLineInScreenBuffer + nCounterX)->Red = *pspace_image;
+ (pStartofLineInScreenBuffer + nCounterX)->Green = *(pspace_image+1);
+ (pStartofLineInScreenBuffer + nCounterX)->Blue = *(pspace_image+2);
+ }
+ pspace_image+=4;
+ }
+ pStartofLineInScreenBuffer+=g_un32BufferWidth;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetTables
+//
+// Description: Gets the 2 Quantization Tables and 4 Huffman Tables.
+// Checks the type of table and then builds the corresponding table.
+//
+// Input: BYTE bNumQT - Number of Quantization Tables.
+// BYTE bNumHT - Number of Huffman Tables.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void GetTables(BYTE bNumQT, BYTE bNumHT)
+{
+ int i,j;
+
+ for(j=0;j<bNumQT;j++)
+ {
+
+ switch(*((BYTE*)QT[j]))
+ {
+ case 0x00:
+ for(i=0;i<64;i++)
+ {
+ bQTLumTable[i] = *((BYTE*)QT[j]+i+1);
+ }
+ break;
+ case 0x01:
+ for(i=0;i<64;i++)
+ {
+ bQTChrTable[i] = *((BYTE*)QT[j]+i+1);
+ }
+ break;
+ }
+ }
+ for(i=0;i<bNumHT;i++)
+ {
+ switch((*(BYTE*)(HT[i])))
+ {
+ case 0x00:
+ BuildHuffmanCodeTable(wDCLumtable,(BYTE *)(HT[i]));
+ break;
+ case 0x10:
+ BuildHuffmanCodeTable(wACLumtable,(BYTE *)(HT[i]));
+ break;
+ case 0x01:
+ BuildHuffmanCodeTable(wDCChrtable,(BYTE *)(HT[i]));
+ break;
+ case 0x11:
+ BuildHuffmanCodeTable(wACChrtable,(BYTE *)(HT[i]));
+ break;
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitJpegParams
+//
+// Description: Reads the image parameters and checks whether the image
+// is supported or not.
+// TSE Jpeg Algorithm Supports following Markers
+// ==================================================
+// 0C0h - Start Of Frame (Baseline DCT) (REQUIRED)
+// 0C4h - Define Huffman Table (REQUIRED)
+// 0D0h - RSI0 Marker (OPTIONAL)
+// 0D1h - RSI1 Marker (OPTIONAL)
+// 0D2h - RSI2 Marker (OPTIONAL)
+// 0D3h - RSI3 Marker (OPTIONAL)
+// 0D4h - RSI4 Marker (OPTIONAL)
+// 0D5h - RSI5 Marker (OPTIONAL)
+// 0D6h - RSI6 Marker (OPTIONAL)
+// 0D7h - RSI7 Marker (OPTIONAL)
+// 0D8h - Start of Image (REQUIRED)
+// 0D9h - End of Image (REQUIRED)
+// 0DAh - Start Of Scan (REQUIRED)
+// 0DBh - Define Quantization Table (REQUIRED)
+// 0DDh - Define Restart Interval (OPTIONAL)
+// 0E0h - 0xEF - APPx Markers (Does Depend on and just Skips marker) (DON'T CARE)
+// 0F0h - 0xFD - Reserved for JPEG extensions (Does Depend on and just Skips marker) (DON'T CARE)
+// 0FEh - Jpeg Comment (Does Depend on and just Skips marker) (DON'T CARE)
+//
+// TSE Jpeg Algorithom Does not Support following Markers
+// ======================================================
+// 000h-0BFh - RESERVED
+// 0C1h - Start Of Frame (Extended sequential DCT)
+// 0C2h - Start Of Frame (Progressive DCT)
+// 0C3h - Start Of Frame (Lossless (sequential))
+// 0C5h - Start Of Frame (Differential sequential DCT)
+// 0C6h - Start Of Frame (Differential progressive DCT)
+// 0C7h - Start Of Frame (Differential lossless (sequential))
+// 0C8h - Start Of Frame (Reserved for JPEG extensions)
+// 0C9h - Start Of Frame (Extended sequential DCT)
+// 0CAh - Start Of Frame (Progressive DCT)
+// 0CBh - Start Of Frame (Lossless (sequential))
+// 0CDh - Start Of Frame (Differential sequential DCT)
+// 0CEh - Start Of Frame (Differential progressive DCT)
+// 0CFh - Start Of Frame (Differential lossless (sequential))
+// 0CCh - Arithmetic coding conditioning
+// 0DCh - Define number of lines
+// 0DEh - Define hierarchical progression
+// 0DFh - Expand reference component(s)
+// 0FFh - RESERVED
+//
+// Input: BYTE * pbyImage - Pointer to the JPEG image.
+//
+// Output: BOOL TRUE/FALSE.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL InitJpegParams(BYTE * pbyImage)
+{
+
+ BYTE bJpegImageFlag = 0;
+ BYTE bCount = 0;
+ int i = 0;
+ BYTE bNumHT=0;
+ BYTE bNumQT=0;
+ WORD wLen = 0;
+
+ if ( ( *pbyImage != 0xFF ) || ( *(pbyImage+1) != 0xD8 ) ) // if marker is not Start Of Image
+ return FALSE;
+ do{
+ if(0x0FF== *pbyImage){
+ pbyImage++;
+ //; start of image
+ if ( 0xD8 == *pbyImage )
+ {
+ pbyImage++;
+ continue;
+ }
+ //; end of image
+ if(0x0D9== *pbyImage){
+ break;
+ }
+ if(*pbyImage){
+ // APPx Marks No information needed for us
+ if((0x0F0 & *pbyImage) == 0x0E0){
+ }
+ // ; if maker is Start Of Frame
+ else if(0x0C0== *pbyImage){
+ bJpegImageFlag|=2;
+ unSOF0 = (UINTN)(pbyImage+1);
+ }
+ //; if maker is Define Huffman Table
+ else if(0x0C4== *pbyImage){
+ HT[bNumHT] = (UINTN)(pbyImage+3);
+ bNumHT++;
+ }
+ else if((0x0F0 & *pbyImage) == 0xC0){
+ // ; if Frame markers
+ switch(*pbyImage)
+ {
+ //Unsupported Frame Markers
+ case 0x0C1: //Start Of Frame (Extended sequential DCT)
+ case 0x0C2: //Start Of Frame (Progressive DCT)
+ case 0x0C3: //Start Of Frame (Lossless (sequential))
+ case 0x0C5: //Start Of Frame (Differential sequential DCT)
+ case 0x0C6: //Start Of Frame (Differential progressive DCT)
+ case 0x0C7: //Start Of Frame (Differential lossless (sequential))
+ case 0x0C8: //Start Of Frame (Reserved for JPEG extensions)
+ case 0x0C9: //Start Of Frame (Extended sequential DCT)
+ case 0x0CA: //Start Of Frame (Progressive DCT)
+ case 0x0CB: //Start Of Frame (Lossless (sequential))
+ case 0x0CD: //Start Of Frame (Differential sequential DCT)
+ case 0x0CE: //Start Of Frame (Differential progressive DCT)
+ case 0x0CF: //Start Of Frame (Differential lossless (sequential))
+ //Arithmetic coding conditioning
+ case 0x0CC:
+ return FALSE;
+ default:
+ // Never comes here as C4 and C0 is handled above
+ break;
+ }
+ }
+ //; if maker is Start Of Scan
+ else if(0x0DA== *pbyImage){
+ //SOS = (UINTN)(pbyImage+1);
+ unBitStreamOFFSET = (UINTN)(pbyImage+13);
+ break;
+ }
+ //; if maker is Define Quantization Table
+ else if(0x0DB== *pbyImage){
+ QT[bNumQT] = (UINTN)(pbyImage+3);
+ bNumQT++;
+ }
+ //; if marker is Define Restart Interval Start
+ else if(0x0DD== *pbyImage){
+ *((BYTE *)&gRsi) = *(pbyImage+4);
+ *((BYTE *)&gRsi+1) = *(pbyImage+3);
+ }
+ // if Restart RSIx Marker
+ else if((*pbyImage & 0xF8 ) == 0xD0){
+ }
+ //; if marker is Define number of lines
+ else if(0x0DC== *pbyImage){
+ return FALSE;
+ }
+ //; if marker is Define hierarchical progression
+ else if(0x0DE== *pbyImage){
+ return FALSE;
+ }
+
+ //; if marker is Expand reference component(s)
+ else if(0x0DF== *pbyImage){
+ return FALSE;
+ }
+ // Reserved for JPEG extensions and Comment. Skip it
+ else if((*pbyImage >= 0xF0) && (*pbyImage <= 0xFE)){
+ }
+ // if the Marker is Less then 0xC0 Or 0xFF then they are reserved marker. No Valid
+ // JPEG file may use it. We don't handle such files
+ // that is ((*pbyImage < 0xC0) || (*pbyImage == 0xFF))
+ else
+ {
+ return FALSE;
+ }
+ pbyImage++;
+ *((BYTE *)&wLen) = *(pbyImage+1);
+ *((BYTE *)&wLen+1) = *pbyImage;
+ pbyImage += wLen;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+ }while(1);
+
+ //Support for 1 QT
+ if(1 == bNumQT)
+ {
+ QT[bNumQT++] = (UINTN)(QT[0]+65);
+ }
+
+ //Support for 1 HT
+ if(1 == bNumHT)
+ {
+ while(bNumHT<4)
+ {
+ bCount = 0;
+ for(i=0;i<16;i++)
+ {
+ bCount = bCount + *(BYTE*)(HT[bNumHT-1]+i+1);
+ }
+ HT[bNumHT++] = (UINTN)(HT[bNumHT-1]+bCount+17);
+ }
+ }
+// Check for 4 HT and 2 QT and SOF0
+ if((4==bNumHT)&&(2==bNumQT)&&(0x02 & bJpegImageFlag))
+ {
+ GetTables(bNumQT, bNumHT);
+ return TRUE;
+ }
+else
+return FALSE;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Check
+//
+// Description: Internal function for doing a check for each color component
+//
+// Input: INT32 n32ColorComp - Color Component (R, G or B).
+//
+// Output: The color component value after the check.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INT32 Check(INT32 n32ColorComp)
+{
+ n32ColorComp>>=14;
+ if(0x8000==(n32ColorComp&0x8000))
+ n32ColorComp=0;
+
+ if((n32ColorComp&0xffff)>255)
+ n32ColorComp=0x00ff;//mov CX,255
+
+ return n32ColorComp;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ConvertYCbCrToRGB
+//
+// Description: Converts the luminance(Y) and chrominance(Cb and Cr) values
+// of the image to R, G, B values. The R,G, B values are stored
+// in a DWORD variable.
+//
+// Input: short Y - Y is the luminance value.
+// short Cb - Cb is the chrominance Hue value.
+// short Cr - Cr is the chrominance Saturation value.
+//
+// Output: Variable having the RGB value, which is a DWORD.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+DWORD ConvertYCbCrToRGB(short Y, short Cb, short Cr)
+{
+ DWORD dwRGB =0;
+ INT32 n32ColorComp =0;
+ INT32 YComp = (((INT32)(Y))<<14);
+ INT32 CrComp = (((INT32)(Cr))*c_g_cr);
+ INT32 CbComp = ((INT32)(Cb) * c_g_cb);
+ //;;;cal r
+ n32ColorComp = Check((YComp + (CrComp<<1)));
+ dwRGB = ((n32ColorComp<<16)|((unsigned int)n32ColorComp>>16));
+
+ //;;;cal g
+ n32ColorComp = Check((YComp-CrComp-CbComp));
+ *(((char *)(&dwRGB))+1) = *(char *)(&n32ColorComp);
+
+ //;;;cal b
+ n32ColorComp = Check((YComp + CbComp + (CbComp<<2) + (CbComp>>3)));
+ *(char *)(&dwRGB) = *(char *)(&n32ColorComp);
+
+ return dwRGB;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InvertDCT
+//
+// Description: Performs inverse discrete cosine transform on dequantized data.
+//
+// Input: WORD * pwSource - Input is dequantized array of 8x8 pixels and
+// output is data after applying inverse discrete cosine transform.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void InvertDCT(WORD * pwSource){
+ WORD * pwSourceCopy=pwSource;
+ int nCounter=0;
+
+ for(nCounter=0; nCounter<8; nCounter++){
+ InvertDCT_xy(pwSource,1);
+ pwSource+=8;
+ }
+ pwSource = pwSourceCopy;
+ for(nCounter=0; nCounter<8; nCounter++){
+ InvertDCT_xy(pwSource,8);
+ pwSource++;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InvertDCT_xy
+//
+// Description: Performs inverse discrete cosine transform on dequantized
+// data in x and y direction.
+//
+// Input: WORD * pwSource - Input is dequantized array of 8x8 pixels
+// and output is data after applying inverse discrete cosine transform.
+// WORD wVal -
+// wVal = 1, then the routine performs inverse discrete
+// cosine transform on dequantized data in x direction.
+// wVal = 8, then the routine performs inverse discrete cosine
+// transform on dequantized data in y direction.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void InvertDCT_xy(WORD * pwSource, WORD wVal)
+{
+INT32 buf1[8];
+INT32 buf2[8];
+int Index[8];
+int i=0;
+for(;i<8;i++)
+Index[i] = i*wVal;
+
+//;;;stage 1, 2 ,3
+
+// ;;o0=x0 and normalize
+ buf2[0] = (((INT32)(INT16)(pwSource[0])*c1_sqrt2))>>14;
+
+
+// ;;o1=x4*c1_4
+ buf2[1] = (((INT32)(INT16)(pwSource[Index[4]]))*c1_4)>>14;
+
+// ;;o2=x2
+
+ buf2[2] = ((INT32)(INT16)(pwSource[Index[2]]));
+// ;;;o3=(x2+x6)*c1_4
+
+ buf2[3] = ((((buf2[2] + (INT32)(INT16)(pwSource[Index[6]]))*c1_4))>>14);
+
+// ;;o4=x1
+
+ buf2[4] = (INT32)(INT16)(pwSource[Index[1]]);
+
+// ;;;o6=x1+x3
+
+ buf2[6] = buf2[4] + (INT32)(INT16)(pwSource[Index[3]]);
+
+// ;;;o7=(x1+x3+x5+x7)*c1_4
+
+ buf2[7] = (((buf2[6]+((INT32)(INT16)(pwSource[Index[5]]))+((INT32)(INT16)(pwSource[Index[7]])))*c1_4)>>14);
+
+// ;;;o5=(x3+x5)*c1_4
+
+ buf2[5] = (((((INT32)(INT16)(pwSource[Index[3]]))+((INT32)(INT16)(pwSource[Index[5]])))*c1_4)>>14);
+
+//;;;stage 4, 5
+
+// ;;b0=o0+o1
+ buf1[0] = buf2[0]+buf2[1];
+
+// ;;b1=o0-o1
+ buf1[1] = buf2[0]-buf2[1];
+
+// ;;b2=(o2+o3)*c1_8
+
+ buf1[2]=(((buf2[2]+buf2[3])*c1_8)>>14);
+
+// ;;b3=(o2-o3)*c3_8
+
+ buf1[3]=(((buf2[2]-buf2[3])*c3_8)>>14);
+
+// ;;b4=o4+o5
+ buf1[4] = buf2[4]+buf2[5];
+
+// ;;b5=o4-o5
+ buf1[5] = buf2[4]-buf2[5];
+
+// ;;b6=(o6+o7)*c1_8
+
+ buf1[6]=(((buf2[6]+buf2[7])*c1_8)>>14);
+
+// ;;b7=(o6-o7)*c3_8
+
+ buf1[7]=(((buf2[6]-buf2[7])*c3_8)>>14);
+
+//;;;stage 6, 7
+
+// ;;o0=b0+b2
+ buf2[0] = buf1[0]+buf1[2];
+
+// ;;o2=b0-b2
+ buf2[2] = buf1[0]-buf1[2];
+
+// ;;o1=b1+b3
+ buf2[1] = buf1[1]+buf1[3];
+
+// ;;o3=b1-b3
+ buf2[3] = buf1[1]-buf1[3];
+
+// ;;o4=(b4+b6)*c1_16
+
+ buf2[4] = (((buf1[4]+buf1[6])*c1_16)>>14);
+
+// ;;o6=(b4-b6)*c7_16
+
+ buf2[6] = (((buf1[4]-buf1[6])*c7_16)>>14);
+
+// ;;o5=(b5+b7)*c3_16
+
+ buf2[5] = (((buf1[5]+buf1[7])*c3_16)>>14);
+
+// ;;o7=(b5-b7)*c5_16
+
+ buf2[7] = (((buf1[5]-buf1[7])*c5_16)>>14);
+
+//;;;stage 8
+
+// ;;b0=o0+o4
+
+ pwSource[0] = (WORD)((buf2[0]+buf2[4])>>1);
+
+// ;;b7=o0-o4
+
+ pwSource[Index[7]] = (WORD)((buf2[0]-buf2[4])>>1);
+
+// ;;b1=o1+o5
+
+ pwSource[Index[1]] = (WORD)((buf2[1]+buf2[5])>>1);
+
+// ;;b6=o1-o5
+
+ pwSource[Index[6]] = (WORD)((buf2[1]-buf2[5])>>1);
+
+// ;;b2=o3+o7
+
+ pwSource[Index[2]] = (WORD)((buf2[3]+buf2[7])>>1);
+
+// ;;b5=o3-o7
+
+ pwSource[Index[5]] = (WORD)((buf2[3]-buf2[7])>>1);
+
+// ;;b3=o2+o6
+
+ pwSource[Index[3]] = (WORD)((buf2[2]+buf2[6])>>1);
+
+// ;;b4=o2-o6
+
+ pwSource[Index[4]] = (WORD)((buf2[2]-buf2[6])>>1);
+ }
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/pcx.h b/EDK/MiniSetup/TseAdvanced/pcx.h
new file mode 100644
index 0000000..0295c8d
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/pcx.h
@@ -0,0 +1,138 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pcx.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pcx.h $
+//
+// 4 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 6 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 6/30/06 4:22p Madhans
+// PCX image support in C.
+//
+// 1 6/16/06 8:15a Shirinmd
+// Added PCX Support in C for Minisetup
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: pcx.h
+//
+// Description: Header file for pcx image format related code
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+#ifndef _PCX_H_13_JUNE_2006
+#define _PCX_H_13_JUNE_2006
+
+#include "MyDefs.h"
+
+#pragma pack(1)
+
+typedef struct _AMI_TRUECOLOR_PIXEL{
+ BYTE Blue;
+ BYTE Green;
+ BYTE Red;
+ BYTE Reserved;
+}AMI_TRUECOLOR_PIXEL, *PAMI_TRUECOLOR_PIXEL;
+
+#pragma pack()
+
+
+//PCX File Header (128 bytes)
+typedef struct _PCX_HEADER{
+ BYTE bManufacturer;
+ BYTE bVersion;
+ BYTE bEncoding;
+ BYTE bBitsPerPixel;
+ WORD wXmin;
+ WORD wYmin;
+ WORD wXmax;
+ WORD wYmax;
+ WORD wHres;
+ WORD wVres;
+ BYTE bPalette[48];
+ BYTE bReserved;
+ BYTE bColorPlanes;
+ WORD wBytesPerLine;
+ WORD wPaletteType;
+ WORD wHorizontalSize;
+ WORD wVerticalSize;
+ BYTE bFiller[54];
+}PCX_HEADER;
+
+typedef struct _PCX_INFO{
+ WORD wImageWidth;
+ WORD wImageHeight;
+ WORD wBytesPerLine;
+ BYTE bBitsPerPixel;
+ DWORD dwPCXImageSize;
+ BYTE *bpPCXData;
+ BYTE *bpPalette;
+}PCX_INFO;
+
+
+#endif //#ifndef _PCX_H_13_JUNE_2006
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2007, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/pcxc.c b/EDK/MiniSetup/TseAdvanced/pcxc.c
new file mode 100644
index 0000000..6c1f9fc
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/pcxc.c
@@ -0,0 +1,321 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pcxc.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pcxc.c $
+//
+// 5 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:11a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 8/13/09 12:16p Blaines
+// Move Image support to binary module
+//
+// 4 8/04/09 10:23a Madhans
+// Fix to support big PCX images.(previously it was not supporing 800x600
+// images.)
+//
+// 3 6/23/09 7:09p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 7/05/06 11:19a Madhans
+//
+// 2 7/05/06 11:09a Madhans
+// DecodePCX function optimized.
+//
+// 1 6/30/06 4:22p Madhans
+// PCX image support in C.
+//
+// 2 6/26/06 8:41a Shirinmd
+// Modifications based on design change suggested by Madhan
+//
+// 1 6/16/06 8:15a Shirinmd
+// Added PCX Support in C for Minisetup
+//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: pcx.c
+//
+// Description: This file contains code for pcx image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "pcx.h"
+
+
+AMI_TRUECOLOR_PIXEL * ScreenBuffer = (AMI_TRUECOLOR_PIXEL *)NULL;
+
+//Functions
+BOOL PCX_Init(BYTE * pbyPCXImage, PCX_INFO *pPCX_INFO, DWORD dwPCXImageSize);
+BOOL GetPCXDimensions( BYTE * pbyPCXImageData, UINT32 * pn32Width, UINT32 * pn32Height);
+BOOL DecodePCX(BYTE * pbyPCXInputData, BYTE * pbyPCXOutputData, DWORD dwPCXImageSize);
+void Decode_Line(DWORD *wCountX, PCX_INFO *pPCX_INFO, BYTE *pbOneLineBuffer);
+void Output_Line(DWORD wTop, PCX_INFO *pPCX_INFO, BYTE *pbOneLineBuffer);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PCX_Init
+//
+// Description: This routine is used to fill the PCX_INFO structure.
+//
+// Input: BYTE * pbyPCXImage - Pointer that gives the memory location
+// where the PCX input data is available.
+// PCX_INFO *pPCX_INFO - Pointer to PCX_INFO structure
+// DWORD dwPCXImageSize - Size of the PCX Image
+//
+// Output: BOOL - TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL PCX_Init(BYTE * pbyPCXImage, PCX_INFO *pPCX_INFO, DWORD dwPCXImageSize)
+{
+ PCX_HEADER *pPCX_HEADER = (PCX_HEADER *)pbyPCXImage;
+
+ if(pPCX_HEADER->bVersion != 5 || pPCX_HEADER->bBitsPerPixel == 1 || pPCX_HEADER->bBitsPerPixel == 2 || pPCX_HEADER->bColorPlanes != 1)
+ return FALSE;
+
+ pPCX_INFO->wImageWidth = pPCX_HEADER->wXmax - pPCX_HEADER->wXmin + 1;
+ pPCX_INFO->wImageHeight = pPCX_HEADER->wYmax - pPCX_HEADER->wYmin + 1;
+ pPCX_INFO->wBytesPerLine = pPCX_HEADER->wBytesPerLine;
+ pPCX_INFO->bBitsPerPixel = pPCX_HEADER->bBitsPerPixel;
+ pPCX_INFO->dwPCXImageSize = dwPCXImageSize;
+ pPCX_INFO->bpPCXData = pbyPCXImage + 128;
+ if(pPCX_HEADER->bBitsPerPixel == 8) //256 color image palette at the end
+ pPCX_INFO->bpPalette = pbyPCXImage + dwPCXImageSize - 768;
+ else if(pPCX_HEADER->bBitsPerPixel == 4) //16 color image palette in the header
+ pPCX_INFO->bpPalette = pPCX_HEADER->bPalette;
+ return TRUE;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetPCXDimensions
+//
+// Description: Get the dimensions (Width and Height of the PCX Image).
+//
+// Input: BYTE * pbyPCXImageData - Pointer to the buffer that contains the PCX data
+// UINT32 * pun32Width - Pointer to the UINT32 variable that will
+// receive the Width of the PCX Image
+// UINT32 * pun32Height - Pointer to the UINT32 variable that
+// will receive the Height of the PCX Image
+//
+// Output: BOOL - TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL GetPCXDimensions( BYTE * pbyPCXImageData, UINT32 * pun32Width, UINT32 * pun32Height){
+ BOOL bReturn = FALSE;
+ WORD wWidth = 0;
+ WORD wHeight= 0;
+ wWidth = *((WORD*)(pbyPCXImageData+8)) - *((WORD*)(pbyPCXImageData+4)) + 1;
+ wHeight = *((WORD*)(pbyPCXImageData+10)) - *((WORD*)(pbyPCXImageData+6)) + 1;
+ if( (wWidth > 0) && (wHeight > 0))
+ {
+ *pun32Width = (UINT32)wWidth;
+ *pun32Height = (UINT32)wHeight;
+ bReturn = TRUE;
+ }
+ return bReturn;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Decode_Line
+//
+// Description: This routine will first check whether the PCX image is 16
+// color or 256 color and then decode the PCX image data one
+// line at a time and put the decoded data in a One Line Buffer.
+//
+// Input: WORD *wCountX - Pointer to the index of the image data after 128 byte header
+// PCX_INFO *pPCX_INFO - Pointer to PCX_INFO structure
+// BYTE *pbOneLineBuffer - Pointer to the buffer that holds one line of decoded data.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Decode_Line(DWORD *wCountX, PCX_INFO *pPCX_INFO, BYTE *pbOneLineBuffer)
+{
+ WORD wOffset_of_buffer = 0;
+ int nDataCount = 0;
+ WORD wLength_of_buffer = 0;
+ while(wLength_of_buffer < (pPCX_INFO->wImageWidth))
+ {
+ if((pPCX_INFO->bpPCXData[*wCountX] & 0xC0) >= 0xC0)
+ nDataCount = (pPCX_INFO->bpPCXData[(*wCountX)++] & 0x3f);
+ else
+ nDataCount = 1;
+
+ while(nDataCount--)
+ {
+ if(pPCX_INFO->bBitsPerPixel == 8)
+ {
+ pbOneLineBuffer[wOffset_of_buffer++] = pPCX_INFO->bpPCXData[*wCountX];
+ (wLength_of_buffer)++;
+ }
+ else if(pPCX_INFO->bBitsPerPixel == 4)
+ {
+ pbOneLineBuffer[wOffset_of_buffer++] = ((pPCX_INFO->bpPCXData[*wCountX]) >> 4);
+ pbOneLineBuffer[wOffset_of_buffer++] = ((pPCX_INFO->bpPCXData[*wCountX]) & 0x0f);
+ (wLength_of_buffer) = (wLength_of_buffer)+2;
+ }
+ }
+ (*wCountX)++;
+ }
+
+
+ if(pPCX_INFO->bBitsPerPixel == 8)
+ {
+ if((pPCX_INFO->wImageWidth) != (pPCX_INFO->wBytesPerLine))
+ (*wCountX)++;
+ }
+ else if(pPCX_INFO->bBitsPerPixel == 4)
+ {
+ if(wLength_of_buffer < ((pPCX_INFO->wBytesPerLine)<<1))
+ (*wCountX)++;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Output_Line
+//
+// Description: This routine is used to map the decoded data to the palette
+// and fill the global Screen Buffer.
+//
+// Input: WORD wTop - This variable gives the position from where a
+// line should start in the Screen Buffer
+// PCX_INFO *pPCX_INFO - Pointer to PCX_INFO structure
+// BYTE *pbOneLineBuffer - Pointer to the buffer that holds one line of decoded data.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Output_Line(DWORD wTop, PCX_INFO *pPCX_INFO, BYTE *pbOneLineBuffer)
+{
+ WORD wCountX;
+ int nIndex;
+ AMI_TRUECOLOR_PIXEL * pStartofLineInScreenBuffer = (AMI_TRUECOLOR_PIXEL *)ScreenBuffer + (wTop*(pPCX_INFO->wImageWidth));
+
+ for(wCountX = 0; wCountX< pPCX_INFO->wImageWidth; wCountX++)
+ {
+ nIndex = (3 * (int)(pbOneLineBuffer[wCountX]));
+ pStartofLineInScreenBuffer->Red = pPCX_INFO->bpPalette[nIndex];
+ pStartofLineInScreenBuffer->Green = pPCX_INFO->bpPalette[nIndex + 1];
+ pStartofLineInScreenBuffer->Blue = pPCX_INFO->bpPalette[nIndex + 2];
+ pStartofLineInScreenBuffer++;
+ }
+
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DecodePCX
+//
+// Description: This routine will call functions to decode both 16 and 256
+// color PCX images of version 5 (with palette information) and
+// fill the Screen Buffer.
+//
+// Input: BYTE * pbyPCXInputData - Pointer that gives the memory location
+// where the PCX input data is available.
+// BYTE * pbyPCXOutputData - Pointer to the buffer that will
+// receive the decoded PCX image
+// DWORD dwPCXImageSize - Size of the PCX Image
+//
+// Output: BOOL - TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOL DecodePCX(BYTE * pbyPCXInputData, BYTE * pbyPCXOutputData, DWORD dwPCXImageSize)
+{
+ PCX_INFO pcx_info;
+ BYTE * bOneLineBuffer = NULL;
+ DWORD wCountY = 0;
+ DWORD wCountX = 0;
+
+ bOneLineBuffer = EfiLibAllocatePool(sizeof(BYTE)*1280);
+ if(bOneLineBuffer == NULL)
+ return FALSE;
+
+ ScreenBuffer = (AMI_TRUECOLOR_PIXEL *)pbyPCXOutputData;
+ if(PCX_Init(pbyPCXInputData, &pcx_info, dwPCXImageSize))
+ {
+ for(wCountY = 0; wCountY < pcx_info.wImageHeight; wCountY++)
+ {
+ Decode_Line(&wCountX, &pcx_info, bOneLineBuffer);
+ Output_Line(wCountY, &pcx_info, bOneLineBuffer);
+ }
+ MemFreePointer( (VOID **)&bOneLineBuffer);
+ return TRUE;
+ }
+ else
+ {
+ MemFreePointer( (VOID **)&bOneLineBuffer);
+ return FALSE;
+ }
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/png.c b/EDK/MiniSetup/TseAdvanced/png.c
new file mode 100644
index 0000000..b2abf2e
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/png.c
@@ -0,0 +1,1353 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/png.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 3 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/png.c $
+//
+// 3 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 6/20/11 1:20p Rajashakerg
+// [TAG] EIP60910
+// [Description] Updated with respect to the review comments.
+//
+// 1 6/13/11 12:21p Rajashakerg
+// EIP:60910 -PNG image support in TSE.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: png.c
+//
+// Description: This file contains code for png image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include "png.h"
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
+//---------------------------------------------------------------------------
+// Macros
+//---------------------------------------------------------------------------
+#define MakeDword(a,b,c,d) ((a)*0x1000000+(b)*0x10000+(c)*0x100+(d))
+#define IHDR MakeDword('I','H','D','R')
+#define IDAT MakeDword('I','D','A','T')
+#define PLTE MakeDword('P','L','T','E')
+#define IEND MakeDword('I','E','N','D')
+#define pHYs MakeDword('p','H','y','s')
+#define tRNS MakeDword('t','R','N','S')
+#define gAMA MakeDword('g','A','M','A')
+#define PNG_SIGNATURE_LENGTH 8
+#define CHUNK_LENGTH 4
+#define CHUNK_TYPE 4
+#define CRC_LENGTH 4
+
+static unsigned char *ImageBuffer = (unsigned char *)NULL;
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PngGetUnsignedInt()
+//
+// Description: To get decimal values
+//
+// Input: const unsigned char dat[]
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned int PngGetUnsignedInt(const unsigned char dat[4])
+{
+ return (unsigned)dat[3] + (unsigned)dat[2] * 0x100 + (unsigned)dat[1] * 0x10000 + (unsigned)dat[0] * 0x1000000;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: FindImageSize()
+//
+// Description: To find the PNG image size
+//
+// Input: none
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned int FindImageSize()
+{
+ unsigned char *dwBuf = (unsigned char *)NULL;
+ UINT32 i = 0;
+ unsigned int ImageSize = 0;
+ unsigned int length = 0;
+ unsigned int chunkType = 0;
+
+ ImageBuffer = ImageBuffer + PNG_SIGNATURE_LENGTH;
+ dwBuf = (unsigned char *)EfiLibAllocateZeroPool(CHUNK_LENGTH);
+ if (dwBuf == NULL) {
+ goto ERREND;
+ }
+ ImageSize = PNG_SIGNATURE_LENGTH;
+ while (chunkType != IEND) //IEND is end of PNG image file
+ {
+ for (i = 0; i < CHUNK_LENGTH; i++) {
+ dwBuf[i] = ImageBuffer[i];
+ }
+ ImageSize = ImageSize + CHUNK_LENGTH; //Adding 4 byte for Chunk Length to move the pointer to Chunk type field
+ ImageBuffer = ImageBuffer + CHUNK_LENGTH;
+
+ length = PngGetUnsignedInt(dwBuf);
+
+ for (i = 0; i < CHUNK_TYPE; i++) {
+ dwBuf[i] = ImageBuffer[i];
+ }
+ ImageSize = ImageSize + CHUNK_TYPE; //Adding 4 byte for Chunk type to move the pointer to Chunk data field
+ ImageBuffer = ImageBuffer + CHUNK_TYPE;
+
+ chunkType = PngGetUnsignedInt(dwBuf);
+ ImageSize = ImageSize + length + CRC_LENGTH; //Adding Chunk data length and CRC length to move the pointer to next Chunk
+ ImageBuffer = ImageBuffer + length + CRC_LENGTH;
+ }
+ if (dwBuf) {
+ MemFreePointer(&dwBuf);
+ }
+
+ return ImageSize;
+ERREND:
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Header_Decode()
+//
+// Description: To Store the header values in the PngHeader variables
+//
+// Input: unsigned char dat[]
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Header_Decode(unsigned char dat[])
+{
+ gPng_Info.hdr.width = PngGetUnsignedInt(dat);
+ gPng_Info.hdr.height = PngGetUnsignedInt(dat+4);
+ gPng_Info.hdr.bitDepth = dat[8]; // Storing IHDR values in PngHeader structure
+ gPng_Info.hdr.colorType = dat[9];
+ gPng_Info.hdr.compressionMethod = dat[10];
+ gPng_Info.hdr.filterMethod = dat[11];
+ gPng_Info.hdr.interlaceMethod = dat[12];
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Palette_Decode()
+//
+// Description: To store the PLTE data values in PngPalette variables
+//
+// Input: unsigned length,unsigned char dat[]
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS Palette_Decode(unsigned length, unsigned char dat[])
+{
+ if (length%3 != 0) //PLTE Length should be divisable by three
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (gPng_Info.plt.entry != NULL)
+ {
+ MemFreePointer(&gPng_Info.plt.entry);
+ gPng_Info.plt.nEntry = 0;
+ }
+
+ if (length > 0)
+ {
+ gPng_Info.plt.entry = (unsigned char *)EfiLibAllocateZeroPool(length);
+ if (gPng_Info.plt.entry != NULL)
+ {
+ unsigned int i;
+ gPng_Info.plt.nEntry = length/3;
+ for (i = 0; i < length; i++)
+ {
+ gPng_Info.plt.entry[i] = dat[i];
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Transparency_Decode()
+//
+// Description: To store the tRNS data values in PngPalette variables
+//
+// Input: unsigned int length,unsigned char dat[],unsigned int colorType
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS Transparency_Decode(unsigned int length, unsigned char dat[], unsigned int colorType)
+{
+ unsigned int i;
+ switch (colorType) //See PNG specification for the color Types
+ {
+ case 0:
+ if (length >= 2)
+ {
+ gPng_Info.trns.col[0] = (unsigned int)dat[0] * 256 + (unsigned int)dat[1];
+ return EFI_SUCCESS;
+ }
+ break;
+ case 2:
+ if (length >= 6)
+ {
+ gPng_Info.trns.col[0] = (unsigned int)dat[0] * 256 + (unsigned int)dat[1];
+ gPng_Info.trns.col[1] = (unsigned int)dat[2] * 256 + (unsigned int)dat[3];
+ gPng_Info.trns.col[2] = (unsigned int)dat[4] * 256 + (unsigned int)dat[5];
+ return EFI_SUCCESS;
+ }
+ break;
+ case 3:
+ for (i=0; i < 3 && i < length; i++)
+ {
+ gPng_Info.trns.col[i] = dat[i];
+ }
+ return EFI_SUCCESS;
+ }
+ return EFI_ABORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Initialize()
+//
+// Description: to initialize the PngImageDecoder member variables
+//
+// Input: none
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Initialize(void)
+{
+ gPng_Info.gamma = gamma_default;
+ gPng_Info.trns.col[0] = 0x7fffffff;
+ gPng_Info.trns.col[1] = 0x7fffffff;
+ gPng_Info.trns.col[2] = 0x7fffffff;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ReadChunk()
+//
+// Description: To Read all the chunk data
+//
+// Input: unsigned &length,unsigned char *&buf,unsigned &chunkType,unsigned &crc
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ReadChunk(unsigned *length, unsigned char **buf, unsigned *chunkType, unsigned *crc)
+{
+ unsigned char *dwBuf = (unsigned char *)NULL;
+ UINT32 i = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ dwBuf = (unsigned char *)EfiLibAllocateZeroPool(4);
+ if (dwBuf == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EndRead;
+ }
+ for (i = 0; i < 4; i++) {
+ dwBuf[i] = ImageBuffer[i];
+ }
+ ImageBuffer = ImageBuffer + CHUNK_LENGTH; //Adding 4 byte for Chunk Length to move the pointer to Chunk type field
+
+ *length = PngGetUnsignedInt(dwBuf);
+
+ for (i = 0; i < 4; i++) {
+ dwBuf[i] = ImageBuffer[i];
+ }
+ ImageBuffer = ImageBuffer + CHUNK_TYPE; //Adding 4 byte for Chunk type to move the pointer to Chunk data field
+
+ *chunkType = PngGetUnsignedInt(dwBuf);
+
+ if(*length > 0)
+ {
+ *buf = (unsigned char *)EfiLibAllocateZeroPool(*length);
+ if (*buf == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EndRead;
+ }
+ for (i = 0; i < *length; i++) {
+ (*buf)[i] = ImageBuffer[i];
+ }
+ }
+ else
+ {
+ *buf = (unsigned char *)NULL;
+ }
+ ImageBuffer = ImageBuffer + *length; //Adding Chunk data length to move the pointer to CRC field
+
+ for (i = 0; i < 4; i++) {
+ dwBuf[i] = ImageBuffer[i];
+ }
+ ImageBuffer = ImageBuffer + CRC_LENGTH; //Adding 4 byte for CRC length to move the pointer to next Chunk
+
+ *crc = PngGetUnsignedInt(dwBuf);
+
+EndRead:
+
+ if (dwBuf) { //Fix for Fortify issue - Memory Leak
+ MemFreePointer(&dwBuf);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Decode()
+//
+// Description: Read all the PNG chunks and do convert the png format to RGB format.
+//
+// Input: unsigned char *PNGImage,UINT32 PNGImageSize
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS Decode(unsigned char *PNGImage, UINT32 PNGImageSize)
+{
+ unsigned char *datBuf = (unsigned char *)NULL;
+ unsigned datBufUsed;
+ unsigned char *buf;
+ unsigned length,chunkType,crc;
+
+ if (PNGImage)
+ {
+ ImageBuffer = PNGImage;
+ PNGImageSize = FindImageSize(); //Find the png image size if the PNGImageSize is zero
+
+ datBufUsed = 0;
+ datBuf = (unsigned char *)EfiLibAllocateZeroPool(PNGImageSize);
+ if (datBuf == NULL) {
+ goto ERREND;
+ }
+
+ ImageBuffer = PNGImage + PNG_SIGNATURE_LENGTH; //Adding 8 bytes to move the pointer to Chunk length
+ while (ReadChunk(&length,&buf,&chunkType,&crc) == EFI_SUCCESS && chunkType != IEND) //Read the Chunk data upto IEND(End of the PNG image)
+ {
+ if(buf == NULL){
+ break; //If the buffer is invalid, break from the loop
+ }
+ switch (chunkType)
+ {
+ case IHDR:
+ if (length >= 13)
+ {
+ Header_Decode(buf); //Stores the IHDR values in the PngHeader structure
+ }
+ MemFreePointer(&buf);
+ break;
+ case PLTE:
+ if (Palette_Decode(length,buf)) //Stores the PLTE values in the PngPalette structure
+ {
+ MemFreePointer(&buf);
+ goto ERREND;
+ }
+ MemFreePointer(&buf);
+ break;
+ case tRNS:
+ if (Transparency_Decode(length,buf,gPng_Info.hdr.colorType)) //Stores the tRNS values in the PngTransparency structure
+ {
+ MemFreePointer(&buf);
+ goto ERREND;
+ }
+ MemFreePointer(&buf);
+ break;
+ case gAMA:
+ if(length >= 4)
+ {
+ gPng_Info.gamma = PngGetUnsignedInt(buf); //Stores the gAMA chunk values
+ MemFreePointer(&buf);
+ }
+ break;
+ case IDAT:
+ if (buf != NULL)
+ {
+ unsigned i;
+ for (i = 0; i < length; i++)
+ {
+ datBuf[datBufUsed+i] = buf[i]; //Stores the IDAT chunk value in datbuf[]
+ }
+ datBufUsed += length; //datBufUsed used to store consecutive IDAT chunk sequentialy
+ MemFreePointer(&buf);
+ }
+ break;
+ default:
+ MemFreePointer(&buf); //Modified to remove the fortify warning
+ break;
+ }
+ }
+
+ if (PrepareOutput() == EFI_SUCCESS) // Check the combination of Color type and bit debth
+ {
+ //PngUncompressor uncompressor;
+ //uncompressor.output = this;
+ if (Uncompress(datBufUsed,datBuf)) { //Convert the PNG image data into the RGB format in PngImageDecoder.rgba variable
+ goto ERREND;
+ }
+ } else {
+ goto ERREND;
+ }
+
+ MemFreePointer(&datBuf);
+ return EFI_SUCCESS;
+ }
+
+ERREND:
+ if (datBuf) {
+ MemFreePointer(&datBuf);
+ }
+ return EFI_ABORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Paeth()
+//
+// Description:
+//
+// Input: unsigned int ua,unsigned int ub,unsigned int uc
+//
+// Output: unsigned char
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned char Paeth(unsigned int ua,unsigned int ub,unsigned int uc)
+{
+ int a,b,c,p,pa,pb,pc;
+
+ a = (int)ua;
+ b = (int)ub;
+ c = (int)uc;
+
+ p = a + b - c;
+ pa = (p>a ? p-a : a-p); //Paeth filtering as per the PNG Specification
+ pb = (p>b ? p-b : b-p);
+ pc = (p>c ? p-c : c-p);
+
+ if (pa <= pb && pa <= pc)
+ {
+ return (unsigned char)a; //Fix for Fortify issue - Type Mismatch : Signed to Unsigned
+ }
+ else if(pb <= pc)
+ {
+ return (unsigned char)b; //Fix for Fortify issue - Type Mismatch : Signed to Unsigned
+ }
+ else
+ {
+ return (unsigned char)c; //Fix for Fortify issue - Type Mismatch : Signed to Unsigned
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Filter8()
+//
+// Description:
+//
+// Input: unsigned char curLine[],unsigned char prvLine[],int x,int y,int unitLng,int filter
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void Filter8(unsigned char curLine[],unsigned char prvLine[],int x,int y,int unitLng,int filter)
+{
+ int i;
+ switch (filter) //filtering algorithm
+ {
+ case 1:
+ if (x > 0)
+ {
+ for (i = 0; i < unitLng; i++)
+ {
+ curLine[ x * unitLng + i] = curLine[ x * unitLng + i] + curLine[ x * unitLng + i - unitLng];
+ }
+ }
+ break;
+ case 2:
+ if (y > 0)
+ {
+ for (i = 0; i < unitLng; i++)
+ {
+ curLine[x * unitLng + i] = curLine[x * unitLng + i] + prvLine[ x * unitLng + i];
+ }
+ }
+ break;
+ case 3:
+ for (i = 0; i < unitLng; i++)
+ {
+ unsigned int a;
+ a = (x > 0 ? curLine[x * unitLng + i - unitLng] : 0);
+ a += (y > 0 ? prvLine[x * unitLng + i] : 0);
+ curLine[x * unitLng + i] += (unsigned char)a / 2;
+ }
+ break;
+ case 4:
+ for (i = 0; i < unitLng; i++)
+ {
+ unsigned int a,b,c;
+ a = (x > 0 ? curLine[x * unitLng + i - unitLng] : 0);
+ b = (y > 0 ? prvLine[x * unitLng + i] : 0);
+ c = ((x > 0 && y > 0) ? prvLine[x * unitLng - unitLng + i] : 0);
+ curLine[x * unitLng + i] = curLine[x * unitLng + i] + Paeth(a,b,c);
+ }
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ShiftTwoLineBuf()
+//
+// Description:
+//
+// Input: none
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void ShiftTwoLineBuf(void)
+{
+ if (gPng_Info.twoLineBuf8 != NULL)
+ {
+ unsigned char *swap;
+ swap = gPng_Info.curLine8;
+ gPng_Info.curLine8 = gPng_Info.prvLine8;
+ gPng_Info.prvLine8 = swap;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PrepareOutput()
+//
+// Description: To validate the colorType and bitDepth combination and prepare the output data
+//
+// Input: none
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PrepareOutput(void)
+{
+ int supported;
+ unsigned int twoLineBufLngPerLine = 0;
+
+ supported = 0;
+ switch ( gPng_Info.hdr.colorType)
+ {
+ case 0: // Greyscale
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ case 1:
+ supported = 1;
+ break;
+ case 2:
+ case 4:
+ case 16:
+ break;
+ }
+ break;
+ case 2: // Truecolor
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ case 16:
+ supported = 1;
+ break;
+ }
+ break;
+ case 3: // Indexed-color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 4:
+ case 8:
+ supported = 1;
+ break;
+ case 1:
+ case 2:
+ break;
+ }
+ break;
+ case 4: // Greyscale with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ supported = 1;
+ break;
+ case 16:
+ break;
+ }
+ break;
+ case 6: // Truecolor with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ supported = 1;
+ break;
+ case 16:
+ break;
+ }
+ break;
+ }
+
+ if (supported == 0)
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ gPng_Info.wid = gPng_Info.hdr.width;
+ gPng_Info.hei =gPng_Info.hdr.height;
+ if(gPng_Info.autoDeleteRgbaBuffer == 1 && gPng_Info.rgba != NULL)
+ {
+ MemFreePointer(&gPng_Info.rgba);
+ gPng_Info.rgba = (unsigned char *)NULL;
+ }
+ gPng_Info.rgba = (unsigned char *)EfiLibAllocateZeroPool(gPng_Info.wid * gPng_Info.hei * 4);
+ gPng_Info.x = -1;
+ gPng_Info.y = 0;
+ gPng_Info.filter = 0;
+ gPng_Info.inLineCount = 0;
+ gPng_Info.inPixelCount = 0;
+ gPng_Info.firstByte = 1;
+ gPng_Info.index = 0;
+ gPng_Info.interlacePass = 1;
+
+ if (gPng_Info.twoLineBuf8 != NULL)
+ {
+ MemFreePointer(&gPng_Info.twoLineBuf8);
+ }
+
+
+ switch (gPng_Info.hdr.colorType)
+ {
+ case 0: // Greyscale
+ switch(gPng_Info.hdr.bitDepth)
+ {
+ case 1:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 7) /8;
+ break;
+ case 2:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 3) / 4;
+ break;
+ case 4:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 1) / 2;
+ break;
+ case 8:
+ twoLineBufLngPerLine = gPng_Info.hdr.width;
+ break;
+ case 16:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 2;
+ break;
+ }
+ break;
+ case 2: // Truecolor
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 3;
+ break;
+ case 16:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 6;
+ break;
+ }
+ break;
+ case 3: // Indexed-color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 1:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 7) / 8;
+ break;
+ case 2:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 3) / 4;
+ break;
+ case 4:
+ twoLineBufLngPerLine = (gPng_Info.hdr.width + 1) / 2;
+ break;
+ case 8:
+ twoLineBufLngPerLine = gPng_Info.hdr.width;
+ break;
+ }
+ break;
+ case 4: // Greyscale with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 2;
+ break;
+ case 16:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 4;
+ break;
+ }
+ break;
+ case 6: // Truecolor with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 4;
+ break;
+ case 16:
+ twoLineBufLngPerLine = gPng_Info.hdr.width * 8;
+ break;
+ }
+ break;
+ }
+
+ gPng_Info.twoLineBuf8 = (unsigned char *) EfiLibAllocateZeroPool(twoLineBufLngPerLine*2);
+ gPng_Info.curLine8 = gPng_Info.twoLineBuf8;
+ gPng_Info.prvLine8 = gPng_Info.twoLineBuf8 + twoLineBufLngPerLine;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Output()
+//
+// Description: To create the output values in the RGB format.
+//
+// Input: unsigned char dat
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS Output(unsigned char dat)
+{
+ unsigned int i;
+ unsigned int colIdx;
+ unsigned int interlaceWid,interlaceHei,interlaceX,interlaceY;
+
+ if (gPng_Info.y >= gPng_Info.hei || (gPng_Info.rgba == NULL))
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (gPng_Info.x == -1) // First byte is filter type for the line.
+ {
+ gPng_Info.filter = dat; // See PNG Specification for filtering
+ gPng_Info.inLineCount = 0;
+ gPng_Info.inPixelCount = 0;
+ gPng_Info.x++;
+ return EFI_SUCCESS;
+ }
+ else
+ {
+ switch (gPng_Info.hdr.interlaceMethod)
+ {
+ case 0: // Non-Interlace
+ switch (gPng_Info.hdr.colorType) // See PNG Specification for colortype and values
+ {
+ case 0: // Grayscale
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 1:
+ gPng_Info.curLine8[gPng_Info.x/8] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x/8, gPng_Info.y, 1, gPng_Info.filter);
+
+ for (i = 0; i < 8 && gPng_Info.x < gPng_Info.wid; i++)
+ {
+ colIdx = (gPng_Info.curLine8[gPng_Info.x/8] >> (7 - i))&1;
+ colIdx = (colIdx << 1) + colIdx;
+ colIdx = (colIdx << 2) + colIdx;
+ colIdx = (colIdx << 4) + colIdx;
+
+ gPng_Info.rgba[gPng_Info.index] = (char)colIdx;
+ gPng_Info.rgba[gPng_Info.index+1] = (char)colIdx;
+ gPng_Info.rgba[gPng_Info.index+2] = (char)colIdx;
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ }
+ break;
+
+ case 8:
+ gPng_Info.curLine8[gPng_Info.x] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 1, gPng_Info.filter);
+
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.x];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.x];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.x];
+ if (gPng_Info.curLine8[gPng_Info.x] == gPng_Info.trns.col[0] || gPng_Info.curLine8[gPng_Info.x] == gPng_Info.trns.col[1] || gPng_Info.curLine8[gPng_Info.x] == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ break;
+ }
+ break;
+
+ case 2: //True color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 3)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x,gPng_Info.y, 3, gPng_Info.filter);
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+
+ if (gPng_Info.curLine8[gPng_Info.inLineCount] == gPng_Info.trns.col[0] &&
+ gPng_Info.curLine8[gPng_Info.inLineCount+1] == gPng_Info.trns.col[1] &&
+ gPng_Info.curLine8[gPng_Info.inLineCount+2] == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ gPng_Info.inLineCount += 3;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ case 16:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 6)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 6, gPng_Info.filter);
+ gPng_Info.rgba[gPng_Info.index] =gPng_Info. curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+4];
+
+ gPng_Info.r = gPng_Info.curLine8[gPng_Info.inLineCount] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.g = gPng_Info.curLine8[gPng_Info.inLineCount+2] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+3];
+ gPng_Info.b = gPng_Info.curLine8[gPng_Info.inLineCount+4] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+5];
+ if (gPng_Info.r == gPng_Info.trns.col[0] && gPng_Info.g == gPng_Info.trns.col[1] && gPng_Info.b == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ gPng_Info.inLineCount += 6;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+
+ case 3: // Indexed color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 4:
+ gPng_Info.curLine8[gPng_Info.x/2] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x/2, gPng_Info.y, 1, gPng_Info.filter);
+
+ for (i = 0; i<2 && gPng_Info.x < gPng_Info.wid; i++)
+ {
+ colIdx = (gPng_Info.curLine8[gPng_Info.x/2] >> ((1 - i) * 4))&0x0f;
+
+ if (colIdx < gPng_Info.plt.nEntry)
+ {
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.plt.entry[colIdx*3];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.plt.entry[colIdx*3+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.plt.entry[colIdx*3+2];
+ if (colIdx == gPng_Info.trns.col[0] || colIdx == gPng_Info.trns.col[1] || colIdx == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+ }
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ }
+ break;
+
+ case 8:
+ gPng_Info.curLine8[gPng_Info.x] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 1, gPng_Info.filter);
+ colIdx = gPng_Info.curLine8[gPng_Info.x];
+
+ if (colIdx < gPng_Info.plt.nEntry)
+ {
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.plt.entry[colIdx*3];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.plt.entry[colIdx*3+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.plt.entry[colIdx*3+2];
+ if (colIdx == gPng_Info.trns.col[0] || colIdx == gPng_Info.trns.col[1] || colIdx == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+ }
+ gPng_Info.x++;
+ gPng_Info.index += 4;
+ break;
+ }
+ break;
+
+ case 4: // Greyscale with alpha
+ switch(gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount + gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 2)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 2, gPng_Info.filter);
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+3] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.index += 4;
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 2;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+
+ case 6: // Truecolor with alpha
+ switch(gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 4)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8,gPng_Info.x, gPng_Info.y, 4, gPng_Info.filter);
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+ gPng_Info.rgba[gPng_Info.index+3] = gPng_Info.curLine8[gPng_Info.inLineCount+3];
+ gPng_Info.index += 4;
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 4;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+ } // switch(hdr.colorType)
+
+ if (gPng_Info.x >= gPng_Info.wid)
+ {
+ gPng_Info.y++;
+ gPng_Info.x = -1;
+ ShiftTwoLineBuf();
+ }
+
+ return EFI_SUCCESS;
+
+ case 1: // Interlace
+ // 1 6 4 6 2 6 4 6
+ // 7 7 7 7 7 7 7 7
+ // 5 6 5 6 5 6 5 6
+ // 7 7 7 7 7 7 7 7
+ // 3 6 4 6 3 6 4 6
+ // 7 7 7 7 7 7 7 7
+ // 5 6 5 6 5 6 5 6
+ // 7 7 7 7 7 7 7 7
+ switch (gPng_Info.interlacePass)
+ {
+ case 1:
+ interlaceWid = (gPng_Info.wid + 7) / 8;
+ interlaceHei = (gPng_Info.hei + 7) / 8;
+ interlaceX = gPng_Info.x * 8;
+ interlaceY = gPng_Info.y * 8;
+ break;
+ case 2:
+ interlaceWid = (gPng_Info.wid + 3) / 8;
+ interlaceHei = (gPng_Info.hei + 7) / 8;
+ interlaceX = 4 + gPng_Info.x * 8;
+ interlaceY = gPng_Info.y * 8;
+ break;
+ case 3:
+ interlaceWid = (gPng_Info.wid + 3) / 4;
+ interlaceHei = (gPng_Info.hei + 3) / 8;
+ interlaceX = gPng_Info.x * 4;
+ interlaceY = 4 + gPng_Info.y * 8;
+ break;
+ case 4:
+ interlaceWid = (gPng_Info.wid + 1) / 4;
+ interlaceHei = (gPng_Info.hei + 3) / 4;
+ interlaceX = 2 + gPng_Info.x * 4;
+ interlaceY = gPng_Info.y * 4;
+ break;
+ case 5:
+ interlaceWid = (gPng_Info.wid + 1) / 2;
+ interlaceHei = (gPng_Info.hei + 1) / 4;
+ interlaceX = gPng_Info.x * 2;
+ interlaceY = 2 + gPng_Info.y * 4;
+ break;
+ case 6:
+ interlaceWid = (gPng_Info.wid) / 2;
+ interlaceHei = (gPng_Info.hei + 1) / 2;
+ interlaceX = 1 + gPng_Info.x * 2;
+ interlaceY = gPng_Info.y * 2;
+ break;
+ case 7:
+ interlaceWid = gPng_Info.wid;
+ interlaceHei = gPng_Info.hei / 2;
+ interlaceX = gPng_Info.x;
+ interlaceY = 1 + gPng_Info.y * 2;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ } // switch(interlacePass)
+
+ switch (gPng_Info.hdr.colorType) // See PNG Specification for Colour types and values
+ {
+ case 0: // Grayscale
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 1, gPng_Info.filter);
+
+ gPng_Info.index = interlaceX * 4 + interlaceY * gPng_Info.wid * 4;
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount];
+
+ if (gPng_Info.curLine8[gPng_Info.inLineCount] == gPng_Info.trns.col[0] ||
+ gPng_Info.curLine8[gPng_Info.inLineCount] == gPng_Info.trns.col[1] ||
+ gPng_Info.curLine8[gPng_Info.inLineCount] == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount++;
+ break;
+ }
+ break;
+
+ case 2: // True color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 3)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 3, gPng_Info.filter);
+
+ gPng_Info.index = interlaceX * 4 + interlaceY * gPng_Info.wid * 4;
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+
+ if ( gPng_Info.curLine8[ gPng_Info.inLineCount] == gPng_Info.trns.col[0] &&
+ gPng_Info.curLine8[ gPng_Info.inLineCount+1] == gPng_Info.trns.col[1] &&
+ gPng_Info.curLine8[ gPng_Info.inLineCount+2] == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[ gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[ gPng_Info.index+3] = 255;
+ }
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 3;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+
+ case 16:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 6)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 6, gPng_Info.filter);
+ gPng_Info.index = interlaceX * 4 + interlaceY * gPng_Info.wid * 4;
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+4];
+
+ gPng_Info.r = gPng_Info.curLine8[gPng_Info.inLineCount] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.g = gPng_Info.curLine8[gPng_Info.inLineCount+2] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+3];
+ gPng_Info.b = gPng_Info.curLine8[gPng_Info.inLineCount+4] * 256 + gPng_Info.curLine8[gPng_Info.inLineCount+5];
+
+ if(gPng_Info.r==gPng_Info.trns.col[0] && gPng_Info.g==gPng_Info.trns.col[1] && gPng_Info.b==gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 6;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+
+ case 3: // Indexed color
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount] = dat;
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 1, gPng_Info.filter);
+
+ gPng_Info.index = interlaceX * 4 + interlaceY *gPng_Info.wid * 4;
+ colIdx = gPng_Info.curLine8[gPng_Info.inLineCount];
+ if (colIdx < gPng_Info.plt.nEntry)
+ {
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.plt.entry[colIdx*3];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.plt.entry[colIdx*3+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.plt.entry[colIdx*3+2];
+ if (colIdx == gPng_Info.trns.col[0] || colIdx == gPng_Info.trns.col[1] || colIdx == gPng_Info.trns.col[2])
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 0;
+ }
+ else
+ {
+ gPng_Info.rgba[gPng_Info.index+3] = 255;
+ }
+ }
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount++;
+ break;
+ }
+ break;
+
+ case 4: // Greyscale with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 2)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 2, gPng_Info.filter);
+
+ gPng_Info.index = interlaceX * 4 + interlaceY * gPng_Info.wid * 4;
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+3] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 2;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+
+ case 6: // Truecolor with alpha
+ switch (gPng_Info.hdr.bitDepth)
+ {
+ case 8:
+ gPng_Info.curLine8[gPng_Info.inLineCount+gPng_Info.inPixelCount] = dat;
+ gPng_Info.inPixelCount++;
+ if (gPng_Info.inPixelCount == 4)
+ {
+ Filter8(gPng_Info.curLine8, gPng_Info.prvLine8, gPng_Info.x, gPng_Info.y, 4, gPng_Info.filter);
+
+ gPng_Info.index = interlaceX * 4 + interlaceY * gPng_Info.wid * 4;
+ gPng_Info.rgba[gPng_Info.index] = gPng_Info.curLine8[gPng_Info.inLineCount];
+ gPng_Info.rgba[gPng_Info.index+1] = gPng_Info.curLine8[gPng_Info.inLineCount+1];
+ gPng_Info.rgba[gPng_Info.index+2] = gPng_Info.curLine8[gPng_Info.inLineCount+2];
+ gPng_Info.rgba[gPng_Info.index+3] = gPng_Info.curLine8[gPng_Info.inLineCount+3];
+
+ gPng_Info.x++;
+ gPng_Info.inLineCount += 4;
+ gPng_Info.inPixelCount = 0;
+ }
+ break;
+ }
+ break;
+ } // switch(hdr.colorType)
+
+ if (gPng_Info.x >= (int)interlaceWid)
+ {
+ gPng_Info.y++;
+ gPng_Info.x = -1;
+ ShiftTwoLineBuf();
+ if (gPng_Info.y >= (int)interlaceHei)
+ {
+ gPng_Info.y = 0;
+ gPng_Info.interlacePass++;
+ }
+ }
+
+ return EFI_SUCCESS;
+ default:
+ return EFI_UNSUPPORTED;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ConvertPNGToBlt()
+//
+// Description: Decode the PNG and store the output in RGB format
+//
+// Input: IN VOID *PNGImage, IN UINT32 PNGImageSize, IN OUT VOID **Blt,
+// IN OUT UINTN *BltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ConvertPNGToUgaBlt( IN VOID *PNGImage, IN UINT32 PNGImageSize, IN OUT VOID **Blt, IN OUT UINTN *BltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth )
+{
+ //PngImageDecoder pngDecoder;
+ //pngDecoder.Initialize();
+ EFI_STATUS Status = EFI_SUCCESS;
+ unsigned int x,y;
+ EFI_UGA_PIXEL *buf = (EFI_UGA_PIXEL *)NULL;
+ unsigned char *tempRGBA;
+ PNGImageSize = 0;
+ Initialize();
+ if (Decode((unsigned char*)PNGImage, PNGImageSize) == EFI_SUCCESS) //Decodes the PNG image to convert PNG image data to RGB format
+ {
+
+
+ *PixelHeight = gPng_Info.hei;
+ *PixelWidth = gPng_Info.wid;
+ *BltSize = (*PixelHeight) * (*PixelWidth) * 4;
+
+ *Blt = EfiLibAllocateZeroPool(*BltSize);
+ if (*Blt == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ return Status;
+ }
+
+ buf = (EFI_UGA_PIXEL *)*Blt;
+
+ for(y = 0; y < *PixelHeight; y++) {
+ for(x = 0; x < *PixelWidth; x++) {
+
+ if(x < (unsigned int)gPng_Info.wid)
+ {
+ tempRGBA = gPng_Info.rgba + (y * gPng_Info.wid + x) * 4;
+ }
+ else
+ {
+ tempRGBA = gPng_Info.rgba + (y * gPng_Info.wid + gPng_Info.wid - 1) * 4;
+ }
+
+ buf->Blue = tempRGBA[2];
+ buf->Green = tempRGBA[1]; //Stores the converted image data(RGB format)
+ buf->Red = tempRGBA[0];
+ buf++;
+ }
+ }
+ } else {
+ Status = EFI_ABORTED;
+ }
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/png.h b/EDK/MiniSetup/TseAdvanced/png.h
new file mode 100644
index 0000000..3e18132
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/png.h
@@ -0,0 +1,136 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/png.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/png.h $
+//
+// 2 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 6/13/11 12:21p Rajashakerg
+// EIP:60910 -PNG image support in TSE.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: png.h
+//
+// Description: Header file for png image format related code
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+#include "MyDefs.h"
+
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
+#ifndef _PNG_H_
+#define _PNG_H_
+
+EFI_STATUS ConvertPNGToBlt ( IN VOID *PNGImage, IN UINT32 PNGImageSize, IN OUT VOID **Blt, IN OUT UINTN *BltSize, OUT UINT32 *PixelHeight, OUT UINT32 *PixelWidth);
+
+typedef struct _PngHeader //information about the PNG image
+{
+ unsigned int width; //width of the image in pixels
+ unsigned int height; //height of the image in pixels
+ unsigned int bitDepth;
+ unsigned int colorType;
+ unsigned int compressionMethod; //compression method of the original file
+ unsigned int filterMethod; //filter method of the original file
+ unsigned int interlaceMethod; //interlace method of the original file
+} PngHeader;
+
+typedef struct _PngPalette
+{
+ unsigned int nEntry;
+ unsigned char *entry;
+} PngPalette;
+
+typedef struct _PngTransparency
+{
+ unsigned int col[3];
+} PngTransparency;
+
+enum{
+ gamma_default=100000
+ };
+
+typedef struct _PngImageDecoder
+{
+ PngHeader hdr;
+ PngPalette plt;
+ PngTransparency trns;
+ int wid,hei;
+ unsigned char *rgba; // Raw data of R,G,B,A
+ int autoDeleteRgbaBuffer;
+ int filter,x,y,firstByte;
+ int inLineCount;
+ int inPixelCount;
+ unsigned int r,g,b,msb; // msb for reading 16 bit depth
+ unsigned int index;
+ unsigned int interlacePass;
+ unsigned char *twoLineBuf8,*curLine8,*prvLine8; // For filtering
+ unsigned int gamma;
+}PngImageDecoder;
+
+PngImageDecoder gPng_Info;
+
+void Initialize(void);
+ int CheckSignature(CHAR8 *PNGImage);
+ EFI_STATUS ReadChunk(unsigned *length,unsigned char **buf,unsigned *chunkType,unsigned *crc);
+ void Header_Decode(unsigned char dat[]);
+ EFI_STATUS Palette_Decode(unsigned length,unsigned char dat[]);
+ EFI_STATUS Transparency_Decode(unsigned length,unsigned char dat[],unsigned int colorType);
+ EFI_STATUS Decode(unsigned char *PNGImage,UINT32 PNGImageSize);
+ void ShiftTwoLineBuf(void);
+ EFI_STATUS PrepareOutput(void);
+ EFI_STATUS Output(unsigned char dat);
+ EFI_STATUS EndOutput(void);
+EFI_STATUS Uncompress(unsigned length, unsigned char dat[]);
+
+
+#endif //#ifndef _PNG_H_
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseAdvanced/pnguncmp.c b/EDK/MiniSetup/TseAdvanced/pnguncmp.c
new file mode 100644
index 0000000..655994f
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/pnguncmp.c
@@ -0,0 +1,879 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pnguncmp.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 3 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/pnguncmp.c $
+//
+// 3 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 6/20/11 1:19p Rajashakerg
+// [TAG] EIP60910
+// [Description] Updated with respect to the review comments.
+//
+// 1 6/13/11 12:21p Rajashakerg
+// EIP:60910 -PNG image support in TSE.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: pnguncmp.c
+//
+// Description: This file contains code for pcx image handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "png.h"
+#define codeLengthLen 19
+
+typedef struct _PngHuffmanTree
+{
+ unsigned dat;
+ struct _PngHuffmanTree *zero, *one;
+}PngHuffmanTree;
+
+void MakeFixedHuffmanCode(unsigned *hLength, unsigned *hCode);
+void MakeDynamicHuffmanCode(unsigned hLength[288], unsigned hCode[288], unsigned nLng, unsigned lng[]);
+EFI_STATUS DecodeDynamicHuffmanCode
+ (unsigned int *hLit, unsigned int *hDist, unsigned int*hCLen,
+ unsigned int **hLengthLiteral, unsigned int **hCodeLiteral,
+ unsigned int **hLengthDist, unsigned int **hCodeDist,
+ unsigned int *hLengthBuf, unsigned int *hCodeBuf,
+ const unsigned char dat[], unsigned int *bytePtr, unsigned int *bitPtr);
+
+PngHuffmanTree *MakeHuffmanTree(unsigned n, unsigned *hLength, unsigned *hCode);
+void DeleteHuffmanTree(PngHuffmanTree *node);
+
+unsigned GetCopyLength(unsigned value, unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr);
+unsigned GetBackwardDistance(unsigned distCode, unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr);
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: GetNextBit()
+//
+// Description: To get the Next Bit
+//
+// Input: const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned int GetNextBit(const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr)
+{
+ unsigned a;
+ unsigned b;
+ a = dat[*bytePtr] & *bitPtr;
+ *bitPtr <<= 1;
+ if(*bitPtr >= 256)
+ {
+ *bitPtr = 1;
+ (*bytePtr)++;
+ }
+ b = (a != 0 ? 1 : 0);
+ return b;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: GetNextMultiBit()
+//
+// Description: To get the Next multiple Bits.
+//
+// Input: const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr, unsigned n
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned int GetNextMultiBit(const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr, unsigned n)
+{
+ unsigned value,mask,i;
+ value = 0;
+ mask = 1;
+ for(i = 0; i < n; i++)
+ {
+ if(GetNextBit(dat,bytePtr,bitPtr))
+ {
+ value |= mask;
+ }
+ mask <<= 1;
+ }
+ return value;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MakeFixedHuffmanCode()
+//
+// Description: To make the fixed huffman code
+//
+// Input: unsigned hLength[288],unsigned hCode[288]
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void MakeFixedHuffmanCode(unsigned *hLength, unsigned *hCode)
+{
+ unsigned i;
+ for(i = 0; i <= 143; i++)
+ {
+ hLength[i] = 8;
+ hCode[i] = 0x30+i;
+ }
+ for(i = 144; i <= 255; i++)
+ {
+ hLength[i] = 9;
+ hCode[i] = 0x190 + (i-144);
+ }
+ for(i = 256; i <= 279; i++)
+ {
+ hLength[i] = 7;
+ hCode[i] = i - 256;
+ }
+ for(i=280; i<=287; i++)
+ {
+ hLength[i] = 8;
+ hCode[i] = 0xc0 + (i-280);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MakeDynamicHuffmanCode()
+//
+// Description: To make the Dynamic Huffman Code
+//
+// Input: unsigned hLength[],unsigned hCode[],unsigned nLng,unsigned lng[]
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void MakeDynamicHuffmanCode(unsigned hLength[], unsigned hCode[], unsigned nLng, unsigned lng[])
+{
+ unsigned i, maxLng, code, *bl_count, *next_code, bits, n;
+
+ for(i = 0; i < nLng; i++)
+ {
+ hLength[i] = lng[i];
+ hCode[i] = 0;
+ }
+
+ maxLng = 0;
+ for(i = 0; i < nLng; i++)
+ {
+ if(maxLng < lng[i])
+ {
+ maxLng = lng[i];
+ }
+ }
+
+ bl_count = (unsigned int *) EfiLibAllocateZeroPool((maxLng+1)*sizeof(unsigned));
+ if (!bl_count) {
+ return;
+ }
+ next_code = (unsigned int *) EfiLibAllocateZeroPool((maxLng+1)*sizeof(unsigned));
+ if (!next_code) {
+ MemFreePointer(&bl_count);
+ return;
+ }
+ for(i = 0; i < maxLng+1; i++)
+ {
+ bl_count[i] = 0;
+ next_code[i] = 0;
+ }
+ for(i = 0; i < nLng; i++)
+ {
+ bl_count[lng[i]]++;
+ }
+
+ code = 0;
+ bl_count[0] = 0;
+ for (bits = 1; bits <= maxLng; bits++)
+ {
+ code = (code + bl_count[bits-1]) << 1;
+ next_code[bits] = code;
+ }
+
+ for (n = 0; n < nLng; n++)
+ {
+ unsigned len;
+ len = lng[n];
+ if (len > 0)
+ {
+ hCode[n] = next_code[len]++;
+ }
+ }
+
+ if (bl_count != NULL)
+ {
+ MemFreePointer(&bl_count);
+ }
+ if (next_code != NULL)
+ {
+ MemFreePointer(&next_code);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: DecodeDynamicHuffmanCode()
+//
+// Description: Decodeing the Dynamic Huffman Code
+//
+// Input: unsigned int &hLit,unsigned int &hDist,unsigned int &hCLen,
+// unsigned int *&hLengthLiteral,unsigned int *&hCodeLiteral,
+// unsigned int *&hLengthDist,unsigned int *&hCodeDist,
+// unsigned int hLengthBuf[322],unsigned int hCodeBuf[322],
+// const unsigned char dat[],unsigned int &bytePtr,unsigned int &bitPtr
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DecodeDynamicHuffmanCode
+ (unsigned int *hLit, unsigned int *hDist, unsigned int *hCLen,
+ unsigned int **hLengthLiteral, unsigned int **hCodeLiteral,
+ unsigned int **hLengthDist, unsigned int **hCodeDist,
+ unsigned int *hLengthBuf, unsigned int *hCodeBuf,
+ const unsigned char dat[], unsigned int *bytePtr, unsigned int *bitPtr)
+{
+ unsigned int i;
+ unsigned int nExtr=0;
+ PngHuffmanTree *lengthTree, *lengthTreePtr;
+ unsigned value, copyLength;
+ unsigned codeLengthOrder[codeLengthLen] =
+ {
+ 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15
+ };
+ unsigned codeLengthCode[codeLengthLen];
+ unsigned hLengthCode[codeLengthLen],hCodeCode[codeLengthLen];
+
+ *hLit = 0;
+ *hDist = 0;
+ *hCLen = 0;
+
+ *hLit = GetNextMultiBit(dat, bytePtr, bitPtr, 5);
+ *hDist = GetNextMultiBit(dat, bytePtr, bitPtr, 5);
+ *hCLen = GetNextMultiBit(dat, bytePtr, bitPtr, 4);
+
+ for (i = 0; i < codeLengthLen; i++)
+ {
+ codeLengthCode[i] = 0;
+ }
+ for (i = 0; i < *hCLen+4; i++)
+ {
+ codeLengthCode[codeLengthOrder[i]] = GetNextMultiBit(dat, bytePtr, bitPtr, 3);
+ }
+
+ MakeDynamicHuffmanCode(hLengthCode, hCodeCode, codeLengthLen, codeLengthCode);
+
+ *hLengthLiteral = hLengthBuf;
+ *hCodeLiteral = hCodeBuf;
+ *hLengthDist = hLengthBuf + *hLit + 257;
+ *hCodeDist = hCodeBuf+ *hLit + 257;
+
+
+ lengthTree = MakeHuffmanTree(codeLengthLen, hLengthCode, hCodeCode);
+ if (lengthTree == NULL) {
+ return EFI_ABORTED;
+ }
+
+ lengthTreePtr = lengthTree;
+ while (nExtr < *hLit + 257 + *hDist +1)
+ {
+ if (GetNextBit(dat, bytePtr, bitPtr))
+ {
+ if(lengthTreePtr->one){
+ lengthTreePtr = lengthTreePtr->one;
+ }
+ }
+ else
+ {
+ if(lengthTreePtr->zero){
+ lengthTreePtr = lengthTreePtr->zero;
+ }
+ }
+ if (lengthTreePtr->zero == NULL && lengthTreePtr->one == NULL)
+ {
+
+ value = lengthTreePtr->dat;
+
+ if (value <= 15)
+ {
+ hLengthBuf[nExtr++] = value;
+ }
+ else if (value == 16)
+ {
+ copyLength = 3 + GetNextMultiBit(dat, bytePtr, bitPtr, 2);
+ while (copyLength > 0)
+ {
+ hLengthBuf[nExtr] = hLengthBuf[nExtr-1];
+ nExtr++;
+ copyLength--;
+ }
+ }
+ else if (value == 17)
+ {
+ copyLength = 3 + GetNextMultiBit(dat, bytePtr, bitPtr, 3);
+ while (copyLength > 0)
+ {
+ hLengthBuf[nExtr++] = 0;
+ copyLength--;
+ }
+ }
+ else if (value == 18)
+ {
+ copyLength = 11 + GetNextMultiBit(dat, bytePtr, bitPtr, 7);
+ while (copyLength > 0)
+ {
+ hLengthBuf[nExtr++] = 0;
+ copyLength--;
+ }
+ }
+
+ lengthTreePtr = lengthTree;
+ }
+ }
+
+ MakeDynamicHuffmanCode(*hLengthLiteral, *hCodeLiteral, *hLit+257, *hLengthLiteral);
+ MakeDynamicHuffmanCode(*hLengthDist, *hCodeDist, *hDist+1, *hLengthDist);
+
+ DeleteHuffmanTree(lengthTree);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MakeHuffmanTree()
+//
+// Description: To create the huffman tree
+//
+// Input: unsigned n,unsigned hLength[],unsigned hCode[]
+//
+// Output: PngHuffmanTree
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+PngHuffmanTree *MakeHuffmanTree(unsigned n, unsigned *hLength, unsigned *hCode)
+{
+ unsigned i, j, mask;
+ PngHuffmanTree *root, *ptr;
+
+ root = EfiLibAllocateZeroPool(sizeof(PngHuffmanTree));
+ if (root == NULL) {
+ return (PngHuffmanTree *)NULL;
+ }
+
+ for (i = 0; i < n; i++)
+ {
+ if (hLength[i] > 0)
+ {
+ ptr = root;
+ mask = (1<<(hLength[i]-1));
+ for (j = 0; j < hLength[i]; j++)
+ {
+ if (hCode[i] & mask)
+ {
+ if (ptr->one == NULL)
+ {
+ ptr->one = EfiLibAllocateZeroPool(sizeof(PngHuffmanTree));
+ }
+ ptr = ptr->one;
+ }
+ else
+ {
+ if (ptr->zero == NULL)
+ {
+ ptr->zero = EfiLibAllocateZeroPool(sizeof(PngHuffmanTree));
+ }
+ ptr = ptr->zero;
+ }
+ mask >>= 1;
+ }
+ ptr->dat = i;
+ }
+ }
+
+ return root;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: DeleteHuffmanTree()
+//
+// Description: Deleting the created Trees
+//
+// Input: PngHuffmanTree *node
+//
+// Output: String size
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void DeleteHuffmanTree(PngHuffmanTree *node)
+{
+ if (node != NULL)
+ {
+ DeleteHuffmanTree(node->zero); //Delete the Huffman tree
+ DeleteHuffmanTree(node->one);
+ MemFreePointer( &node);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: GetCopyLength()
+//
+// Description: To Get the correct Copy Length
+//
+// Input: unsigned value,unsigned char dat[],unsigned &bytePtr,unsigned &bitPtr
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned GetCopyLength(unsigned value, unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr)
+{
+ unsigned copyLength;
+ unsigned base,offset,extBits;
+
+ if (value <= 264)
+ {
+ copyLength = 3 + (value - 257);
+ }
+ else if (value >= 285)
+ {
+ copyLength = 258;
+ }
+ else
+ {
+ extBits = 1 + (value-265) / 4;
+ base = (8 << ((value-265) / 4)) + 3;
+ offset = ((value-265) & 3) * (2 << ((value - 265) / 4));
+
+ copyLength = GetNextMultiBit(dat, bytePtr, bitPtr, extBits);
+ copyLength += base+offset;
+ }
+
+ return copyLength;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: GetBackwardDistance()
+//
+// Description: To get the Backward Distance
+//
+// Input: unsigned distCode,unsigned char dat[],unsigned &bytePtr,unsigned &bitPtr
+//
+// Output: unsigned int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+unsigned GetBackwardDistance
+ (unsigned distCode, unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr)
+{
+ unsigned backDist;
+ unsigned base, offset, extBits;
+
+ if (distCode <= 3)
+ {
+ backDist = distCode + 1;
+ }
+ else
+ {
+
+
+ base = (4 << ((distCode - 4) / 2)) + 1;
+ offset = (distCode&1) * (2 << ((distCode - 4) / 2));
+ extBits = (distCode - 2) / 2;
+
+ backDist = GetNextMultiBit(dat,bytePtr,bitPtr,extBits);
+ backDist += base + offset;
+ }
+
+ return backDist;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Uncompress()
+//
+// Description: Used to Uncompress the Image data and to convert the RGB format.
+//
+// Input: unsigned length,unsigned char dat[]
+//
+// Output: int
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS Uncompress(unsigned length, unsigned char dat[])
+{
+ unsigned windowUsed;
+ unsigned char *windowBuf;
+ unsigned nByteExtracted;
+ PngHuffmanTree *codeTree, *codeTreePtr;
+ PngHuffmanTree *distTree, *distTreePtr;
+ unsigned bytePtr, bitPtr;
+ unsigned char cmf, flg;
+ unsigned cm, cInfo, windowSize;
+ unsigned fDict;
+ unsigned *hLengthBuf = (unsigned *)NULL;
+ unsigned *hCodeBuf = (unsigned *)NULL;
+ unsigned *hLength = (unsigned *)NULL;
+ unsigned *hCode = (unsigned *)NULL;
+ unsigned value;
+ unsigned copyLength,distCode,backDist;
+ int i=0;
+ windowBuf = (unsigned char *)NULL;
+
+ codeTree = (PngHuffmanTree *)NULL;
+ distTree = (PngHuffmanTree *)NULL;
+ bytePtr = 0;
+ bitPtr = 1;
+ nByteExtracted = 0;
+
+ cmf = dat[bytePtr++];
+ flg = dat[bytePtr++];
+
+ cm = cmf&0x0f;
+ if (cm != 8)
+ {
+ goto ERREND;
+ }
+
+ cInfo = (cmf&0xf0)>>4;
+ windowSize = 1 << (cInfo + 8);
+
+ windowBuf = (unsigned char *)EfiLibAllocateZeroPool(windowSize);
+ windowUsed = 0;
+
+ fDict = (flg&32) >> 5;
+
+ if (fDict != 0)
+ {
+ goto ERREND;
+ }
+
+ while (1)
+ {
+ unsigned bFinal,bType;
+
+ bFinal = GetNextBit(dat, &bytePtr, &bitPtr);
+ bType = GetNextMultiBit(dat, &bytePtr, &bitPtr, 2);
+
+ if (bytePtr >= length)
+ {
+ goto ERREND;
+ }
+
+ if (bType == 0) // No Compression
+ {
+ unsigned len;
+ if (bitPtr != 1) //Skip the current byte.
+ {
+ bitPtr = 1;
+ bytePtr++;
+ }
+ if (bytePtr >= length)
+ {
+ goto ERREND;
+ }
+
+ len = dat[bytePtr] + dat[bytePtr + 1] * 256;
+ bytePtr += 4; //Skip bytes for length(2 bytes) and 1's complement of length(2 bytes).
+
+ for( i=0; i<(int)len; i++) //Feed the image data that is not compressed to output buffer.
+ {
+ Output(dat[bytePtr+i]);
+ }
+ bytePtr += len;
+ }
+ else if (bType == 1 || bType == 2)
+ {
+ codeTree = (PngHuffmanTree *)NULL;
+
+ if (bType == 1)
+ {
+ hLength = (unsigned *)EfiLibAllocateZeroPool(288 * sizeof(unsigned)); //Prefast issue fix - Exceeds stack size issue
+ hCode = (unsigned *)EfiLibAllocateZeroPool(288 * sizeof(unsigned));
+ if (!hLength || !hCode) {
+ goto ERREND;
+ }
+ MakeFixedHuffmanCode(hLength, hCode);
+ codeTree = MakeHuffmanTree(288, hLength, hCode);
+ distTree = (PngHuffmanTree *)NULL;
+ if (hLength) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hLength);
+ }
+ if (hCode) {
+ MemFreePointer( &hCode);
+ }
+ }
+ else
+ {
+ unsigned hLit, hDist, hCLen;
+ unsigned *hLengthLiteral, *hCodeLiteral;
+ unsigned *hLengthDist, *hCodeDist;
+
+ hLengthBuf = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned)); //Prefast issue fix - Exceeds stack size issue
+ hCodeBuf = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned));
+
+ /*Changes
+ hLengthLiteral = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned));
+ hCodeLiteral = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned));
+ hLengthDist = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned));
+ hCodeDist = (unsigned *)EfiLibAllocateZeroPool(322 * sizeof(unsigned));
+
+ */
+ if (!hLengthBuf || !hCodeBuf) {
+ goto ERREND;
+ }
+
+ if (DecodeDynamicHuffmanCode
+ (&hLit, &hDist, &hCLen,
+ &hLengthLiteral, &hCodeLiteral, &hLengthDist, &hCodeDist, hLengthBuf, hCodeBuf,
+ dat, &bytePtr, &bitPtr)) {
+ goto ERREND;
+ }
+
+ codeTree = MakeHuffmanTree(hLit+257, hLengthLiteral, hCodeLiteral);
+ if (codeTree == NULL) {
+ goto ERREND;
+ }
+ distTree = MakeHuffmanTree(hDist+1, hLengthDist, hCodeDist);
+ if (distTree == NULL) {
+ goto ERREND;
+ }
+ /*
+ if (hLengthLiteral) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hLengthLiteral);
+ }
+ if (hCodeLiteral) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hCodeLiteral);
+ }
+ if (hLengthDist) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hLengthDist);
+ }
+ if (hCodeDist) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hCodeDist);
+ }
+ */
+ if (hLengthBuf) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hLengthBuf);
+ }
+ if (hCodeBuf) {
+ MemFreePointer( &hCodeBuf);
+ }
+ }
+
+ codeTreePtr = codeTree;
+ if (codeTree != NULL)
+ {
+ while (1)
+ {
+ if (GetNextBit(dat, &bytePtr, &bitPtr))
+ {
+ codeTreePtr = codeTreePtr->one;
+ }
+ else
+ {
+ codeTreePtr = codeTreePtr->zero;
+ }
+
+ if (codeTreePtr == NULL)
+ {
+ goto ERREND;
+ }
+
+ if (codeTreePtr->zero == NULL && codeTreePtr->one == NULL)
+ {
+
+ value = codeTreePtr->dat;
+ if (value < 256)
+ {
+ windowBuf[windowUsed++] = (unsigned char)value;
+ windowUsed &= (windowSize - 1);
+ if (Output((unsigned char)value))
+ {
+ goto ERREND;
+ }
+ nByteExtracted++;
+ }
+ else if (value == 256)
+ {
+ break;
+ }
+ else if (value <= 285)
+ {
+
+ copyLength = GetCopyLength(value, dat, &bytePtr, &bitPtr);
+
+ if (bType == 1)
+ {
+ distCode = 16 * GetNextBit(dat, &bytePtr, &bitPtr); // 5 bits fixed
+ distCode += 8 * GetNextBit(dat, &bytePtr, &bitPtr); // Reversed order
+ distCode += 4 * GetNextBit(dat, &bytePtr, &bitPtr);
+ distCode += 2 * GetNextBit(dat, &bytePtr, &bitPtr);
+ distCode += GetNextBit(dat, &bytePtr, &bitPtr);
+ }
+ else
+ {
+ distTreePtr = distTree;
+ while (distTreePtr->zero != NULL || distTreePtr->one != NULL)
+ {
+ if (GetNextBit(dat,&bytePtr,&bitPtr))
+ {
+ if (distTreePtr->one) //Fix for Fortify issue - Null Dereference
+ distTreePtr = distTreePtr->one;
+ }
+ else
+ {
+ if (distTreePtr->zero) //Fix for Fortify issue - Null Dereference
+ distTreePtr = distTreePtr->zero;
+ }
+ }
+ distCode = distTreePtr->dat;
+ }
+ backDist = GetBackwardDistance(distCode,dat,&bytePtr,&bitPtr);
+
+
+ for(i=0; i < (int)copyLength; i++)
+ {
+ unsigned char dat;
+ dat = windowBuf[(windowUsed-backDist)&(windowSize-1)];
+ if (Output(dat))
+ {
+ goto ERREND;
+ }
+ nByteExtracted++;
+ windowBuf[windowUsed++] = dat;
+ windowUsed &= (windowSize-1);
+ }
+ }
+
+ codeTreePtr = codeTree;
+ }
+
+ if (length <= bytePtr)
+ {
+ goto ERREND;
+ }
+ }
+ }
+
+
+ DeleteHuffmanTree(codeTree);
+ DeleteHuffmanTree(distTree);
+ codeTree = (PngHuffmanTree *)NULL;
+ distTree = (PngHuffmanTree *)NULL;
+ }
+ else
+ {
+ goto ERREND;
+ }
+
+
+ if (bFinal != 0)
+ {
+ break;
+ }
+ }
+
+ MemFreePointer( &windowBuf);
+ windowBuf = (unsigned char *)NULL;
+
+ return EFI_SUCCESS;
+
+ERREND:
+ if (windowBuf != NULL)
+ {
+ MemFreePointer( &windowBuf);
+ }
+ if (codeTree != NULL)
+ {
+ DeleteHuffmanTree(codeTree);
+ codeTree = (PngHuffmanTree *)NULL;
+ }
+ if (distTree != NULL)
+ {
+ DeleteHuffmanTree(distTree);
+ distTree = (PngHuffmanTree *)NULL;
+ }
+ if (hLength) { //Prefast issue fix - Exceeds stack size issue
+ MemFreePointer( &hLength);
+ }
+ if (hCode) {
+ MemFreePointer( &hCode);
+ }
+ if (hLengthBuf) {
+ MemFreePointer( &hLengthBuf);
+ }
+ if (hCodeBuf) {
+ MemFreePointer( &hCodeBuf);
+ }
+ return EFI_ABORTED;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+
+
+ \ No newline at end of file
diff --git a/EDK/MiniSetup/TseAdvanced/special.c b/EDK/MiniSetup/TseAdvanced/special.c
new file mode 100644
index 0000000..1ab3ef6
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/special.c
@@ -0,0 +1,1898 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/special.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 47 $
+//
+// $Date: 8/28/14 11:49a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/special.c $
+//
+// 47 8/28/14 11:49a Premkumara
+// [TAG] EIP174031
+// [Category] Improvement
+// [Description] Removed TODO comments and added proper comments in those
+// places
+// [Files] commonoem.c, commonhelper.c, special.c, submenu.c,
+// minisetupext.c, uefi21wapper.c and legacy.c
+//
+// 46 5/02/14 12:55p Premkumara
+// [TAG] EIP131549
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] After adding boot/driver options and Loading defaults causes
+// crashing issue.
+// [Root Cause] While discarding boot/driver options the boot order get
+// corrupted by copying extra data because of wrong size.
+// [Solution] Handled proper size to copy boot/driver options while
+// loading defaults
+// [Files] AddBootOption.c, Special.c
+//
+// 45 2/11/14 7:47p Arunsb
+// [TAG] EIP140870
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] BBS EFI OS boot entry will not disappear after remove EFI OS
+// Hdd.
+// [Root Cause] Once EFI-HDD is removed still NVRAM is giving boot data
+// for
+// EFI-HDD(Windows BootManager) with the Active = 0x9(Active+Hidden).
+// But TSE is not checking this Active flag for BootOverride menu.
+// [Solution] Checked Boot option for Hidden or Active before creating
+// controlInfo
+// [Files] special.c
+//
+// 44 12/04/13 2:18p Premkumara
+// [TAG] EIP131549
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] After adding boot/driver options and Loading defaults causes
+// crashing issue.
+// [Root Cause] While discarding boot/driver options the boot order get
+// corrupted by copying extra data because of wrong size.
+// [Solution] Handled proper size to copy boot/driver options while
+// loading defaults
+// [Files] AddBootOption.c, Special.c
+//
+// 43 4/11/13 3:36a Arunsb
+// [TAG] EIP117538
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Boot override of BSU could not see the deivces
+// [RootCause] Hidden boot devices not handled properly
+// [Solution] Hidden boot devices included in all boot options display
+// related cases.
+// [Files] special.c
+//
+// 42 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 21 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 40 9/25/12 5:41a Arunsb
+// [TAG] EIP100099
+// [Category] Improvement
+// [Description] Added submenu icon for driver health options
+// [Files] special.c
+//
+// 39 9/21/12 9:43a Premkumara
+// [TAG] EIP 97704
+// [Category] Improvement
+// [Description] Support BootFFFF variable
+// [Files] Boot.h, Boot.c, Special.c
+//
+// 38 9/17/12 6:08a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 36 8/29/12 8:43a Premkumara
+// [TAG] EIP-91817
+// [Description] To avoid comparing garbage gBootData for
+// LoadOptionHidden when SETUP_SHOW_ALL_BBS_DEVICES = 1
+// [Files] Special.c
+//
+// 35 4/03/12 12:40a Premkumara
+// [TAG] EIP83704
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDD user password and Admin password entries are
+// disappeared.
+// [RootCause] When HDD is freeze VARIABLE_ID_IDE_SECURITY variable is
+// not updated while navigating to page by page
+// [Solution] Updated VARIABLE_ID_IDE_SECURITY variable when HDD is
+// freeze before navigate to pages.
+// [Files] Special.c
+//
+// 34 1/31/12 6:13a Premkumara
+// [TAG] EIP79955
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] GEOMETRICSHAPE_RIGHT_TRIANGLE Mark is missing for AddBoot
+// option in TSE advanced
+// [RootCause] Since AddBoot Option is a special control
+// GEOMETRICSHAPE_RIGHT_TRIANGLE is not drawn.
+// [Solution] Drawn GEOMETRICSHAPE_RIGHT_TRIANGLE for AddBoot Option
+// control
+// [Files] Special.c
+//
+// 33 1/13/12 1:24a Arunsb
+// [TAG] EIP80360
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDDSecurity module - Issue in login with TSE, Master
+// password disabled
+// [RootCause] Cache not updated
+// [Solution] Cache updated properly
+// [Files] Tseadvanced.c, special.c and uefi21wapper.c
+//
+// 32 1/04/12 4:10p Blaines
+// [TAG] EIP 78627
+// [Category] Sighting
+// [Symptom] SAS controller card items in the main list should begin
+// with an > (arrow/sideways triagle)
+// [RootCause] TSE dynamically creates submenu links (controls with the
+// SubMenuType = 2, draw without arrow ) to Dynamic Pages (Hii pages
+// published by offboard cards with UEFI Option Rom).
+// [Solution] For Dynamic pages, set the control's property submenu->
+// SubMenuType = 1, to draw the control text with an arrow.
+//
+// [Files Changed]
+// - special.c
+//
+// [Functions Changed]
+// - _SpecialControlExtras
+//
+// 31 12/08/11 9:11p Arunsb
+// Wrapper function added for GetFormSetTitleAndHelp fnc to resolve the
+// build error in 2.0
+//
+// 30 12/01/11 7:16p Blaines
+// Fix build errors in Uefi2.0
+//
+// 29 11/30/11 1:29p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 28 11/30/11 12:26a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 27 11/13/11 12:38p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 26 10/31/11 9:43a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 25 10/20/11 12:25p Blaines
+// Correct the comments.
+//
+// 24 10/20/11 11:48a Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab.
+//
+// [Files Changed]
+// - AMITSE.sdl, CommonHelper.c, special.c, Menu.c, minisetupext.h,
+// TseUefiHii.h, Uefi21Wapper.c
+//
+// 23 6/30/11 4:12a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Driver health special controls handled.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 22 6/28/11 4:37p Madhans
+// [TAG] EIP55290
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Keeping Different Default Language other then English will
+// cause Lanuage options to show same language repeated.
+// [RootCause] The Language name was not updated protperly.
+// [Solution] Fix to read to update token.
+// [Files] special.c
+//
+// 21 6/20/11 11:50a Rajashakerg
+// [TAG] EIP59417
+// [Category] New Feature
+// [Description] Spport LOAD_OPTION_HIDDEN option in TSE
+// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
+// minisetup.h, special.c, callback.c
+//
+// 20 6/01/11 4:14p Madhans
+// [TAG] EIP61588
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In Advanced page Iscsi page link disappears when any update
+// happens
+// [RootCause] When pages are updated dynamically we might have few
+// invalidated PageInfo. Dynamic page grouping special control want not
+// checking them
+// [Solution] Dynamic page grouping special control check if the page is
+// valid or not.
+// [Files] Special.c
+// Parse.c
+//
+// 19 4/29/11 4:31p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted
+//
+// 16 3/23/11 8:38p Blaines
+// [TAG] - EIP 23601
+// [Category]- Enhancement
+// [Symptom]- Add support for OEM special controls.
+// [Files] - AmiTse.sdl, CommonHelper.c, Setup.ini, UefiSetup.ini,
+// AmiVfr.h, minisetup.h, minisetup.sdl, variable.c, special.c
+//
+// 15 3/15/11 5:18a Rajashakerg
+// [TAG] EIP51671
+// [Category] New Feature
+// [Description] Boot overide menu devices are not disable
+// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl,
+// boot.h, CommonHelper.c
+//
+// 14 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 13 1/10/11 9:36a Mallikarjunanv
+// Updated the file with respect to new changes regarding EIP51619
+//
+// 12 1/07/11 12:28a Mallikarjunanv
+// [TAG] EIP51619
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Changing the option in the "HDD BBS Priority" option not
+// reflected in the boot options list.
+// [RootCause] Boot page is not updated properly with changes made by
+// BBS HDD BBS Priority
+// [Solution] Updated the boot page with changes made by BBS HDD BBS
+// Priority
+// [Files] special.c, variable.c
+//
+// 11 12/25/10 6:44a Mallikarjunanv
+// [TAG] EIP48391
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BOOT menu string disappeared, and BOOT page not displayed
+// properly while adding more than 100 boot options using "Add boot
+// option"
+// [RootCause] if the number of options exceeds the option limit which
+// is UINT16, it get crashed
+// [Solution] Added a new function GetSpecialBootoptionToken(), in which
+// by updating the strings in hii for those tokens which are previously
+// not updated. If for a token the string is already udpated, we will
+// skipt that token.
+// [Files] special.c
+//
+// 10 10/27/10 3:15p Madhans
+// [TAG] EIP45785
+// [Category] Defect
+// [Symptom] Grayingout the BBS priorities is not working. only supporess
+// the first one. for UEFI 2.0
+// [RootCause] The condition showing only one disabled option is not
+// affecting the original condition.
+// [Solution] The control condition will not be updated if it evaluates to
+// not COND_NONE.
+// [Files] Special.c
+//
+// 9 9/20/10 6:47p Madhans
+// [TAG] EIP44542
+// [Category] BUILD ISSUE FIX
+// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
+// when IdeSecurity and FastBoot modules added to the project
+// [RootCause] -
+// [Solution] Build issues resolved
+// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
+// bbs.c, special.c, Bds.c TseLitehelp
+//
+// 8 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 15 9/16/10 3:14p Madhans
+// To Avoid build issues with TSE_USE_EDK_LIBRARY Building.
+//
+// 14 8/27/10 5:04a Mallikarjunanv
+// EIP-39334: support to build TSE without the CSM module support
+//
+// 13 8/19/10 12:50p Mallikarjunanv
+// EIP-42520: Updated to get the BBS group type from the Board module in
+// case of a non standard type.
+//
+// 12 8/12/10 1:04p Blaines
+// Use of reference to gFrame.AddControl to allow option to customization
+// outside of
+//
+// 11 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 10 4/02/10 4:37p Madhans
+// To get ride of TSEOEM.H referance in TSE. Oem hearder files can be
+// refered only in Tse Binary.
+//
+// 9 3/23/10 5:10p Blaines
+// Add new style module hook
+//
+// 8 2/19/10 8:12a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/08/10 5:39a Mallikarjunanv
+// EIP-34679: Typo error fix
+//
+// 6 1/09/10 4:55a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 12/18/09 2:27p Madhans
+// EIP: 32350 To fix the Add/Delete Boot option issues with TSE 2.0.
+//
+// 4 9/15/09 9:37a Sudhirv
+// added support for SETUP_OEM_SPECIAL_CONTROL_SUPPORT and updated the
+// Handling of Add Del Boot Option related sources
+//
+// 3 8/13/09 7:37a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Special.c
+//
+// Description: This file contains code to handle special Operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include "Special.h"
+
+#define BOOT_OPTION_SIZE sizeof(UINT16)
+
+extern VOID UefiSetHelpField(VOID *IfrPtr,UINT16 Token);
+EFI_STATUS GetFormSetTitleAndHelpWrapper (VOID *Handle, UINT16 *Title, UINT16 *Help);
+extern BOOLEAN gSetupUpdated;//EIP:51619 Flag which represents the setup update
+VOID _SpecialControlExtras(CONTROL_DATA *ctrlData);
+VOID _SpecialFixupBootOrder( CONTROL_INFO *control , UINT16 value);
+VOID _SpecialFixupLanguages( CONTROL_INFO *control );
+VOID _SpecialFixupBBSOrder( CONTROL_INFO *control, UINT16 value );
+VOID _SpecialFixupBBSCondition(UINT16 ControlIndex,CONTROL_INFO *control,UINT16 PrevControlQuestionID);
+VOID _SpecialFixupBootCondition(UINT16 ControlIndex,CONTROL_INFO *control,UINT16 PrevControlQuestionID);
+
+UINT32 FindVarFromITKQuestionId(UINT16 QuestionId);
+VOID _SpecialFixupAddBootOption( CONTROL_INFO *control);
+UINT16 GetNoVarStoreBootCountOffset();
+
+UINT16 BBSGetNonStandardGroupType(UINT16 DeviceType); //EIP-42520
+
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+extern UINT16 OEMSpecialGetControlCount(CONTROL_INFO *controlInfo);
+extern VOID OEMSpecialOneOfFixup( CONTROL_INFO *control , UINT16 value );
+extern VOID OEMSpecialGotoFixup(CONTROL_INFO *control, UINT16 value );
+#endif //#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+extern STYLECOLORS Colors;
+
+//EIP 57661 Driver health support
+CHAR16 *FindDriverHealthDriverName (UINT16);
+CHAR16 *GetCtrlNameAndHealth (UINT16 ControllerEntry);
+//EIP 57661 Ends
+//EIP70421 Support for Driver Order starts
+VOID *gDriverPageHandle = NULL;
+UINTN gDriverOptionTokenCount;
+UINT16 *gDriverOptionTokenArray;
+BOOLEAN CheckForAddDelDriverOption (VOID);
+VOID _SpecialFixupDriverOrder (CONTROL_INFO *control, UINT16 value);
+//EIP70421 Support for Driver Order ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialGetIfrPtr
+//
+// Description: function to handle the operation of getting the Ifr Pointer.
+//
+// Input: VOID* conditional,
+// UINT32 variable,
+// GUID_INFO **guidInfo
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *_SpecialGetIfrPtr( CONTROL_INFO *controlInfo, UINT32 * variable, GUID_INFO **guidInfo )
+{
+ *variable = (UINT32)GetControlConditionVarId(controlInfo);
+ return UefiGetSpecialEqIDIfrPtr(controlInfo, variable, guidInfo);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialGetValue
+//
+// Description: function to handle the operation of getting the Ifr Value.
+//
+// Input: CONTROL_DATA *control,
+// GUID_INFO **guidInfo
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 SpecialGetValue( CONTROL_DATA *control, GUID_INFO **guidInfo )
+{
+ return UefiGetSpecialEqIDValue(&control->ControlData, guidInfo);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialGetValue
+//
+// Description: function to handle the operation of getting the Ifr Value.
+//
+// Input: CONTROL_INFO *controlinfo,
+// GUID_INFO **guidInfo
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _SpecialGetValue( CONTROL_INFO *controlinfo, GUID_INFO **guidInfo )
+{
+ return UefiGetSpecialEqIDValue(controlinfo, guidInfo);
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialAddControl
+//
+// Description: function to Handle adding a control.
+//
+// Input: FRAME_DATA *frame ,
+// CONTROL_INFO *controlinfo,
+// BOOLEAN *SetFocus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _SpecialAddControl(FRAME_DATA *frame , CONTROL_INFO *ControlInfo, BOOLEAN *SetFocus)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ STYLECOLORS saveColors ;
+
+
+ //Save original style colors
+ saveColors = Colors ;
+
+ //Special control color scheme...
+ StyleControlColor(frame, &Colors);
+
+ //Adds controls to this frame...
+ Status = gFrame.AddControl( frame, ControlInfo );
+
+ //Restore original style colors
+ Colors = saveColors;
+
+ if ( EFI_ERROR(Status) )
+ return Status;
+
+ if ( *SetFocus )
+ {
+ if ( _FrameSetControlFocus( frame, frame->ControlCount-1 ) )
+ {
+ frame->CurrentControl = frame->ControlCount-1;
+ *SetFocus = FALSE;
+ }
+ }
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoAddBootOptionFixup
+//
+// Description:
+//
+// Input: CONTROL_INFO *newControlInfo
+//
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoAddBootOptionFixup( CONTROL_INFO *newControlInfo )
+{
+ _SpecialFixupAddBootOption(newControlInfo);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialAddMultipleControls
+//
+// Description: Adds Multiple controls for special controls
+//
+// Input: FRAME_DATA *frame , CONTROL_INFO *controlInfo, GUID_INFO *guidInfo, BOOLEAN *SetFocus
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialAddMultipleControls( FRAME_DATA *frame , CONTROL_INFO *controlInfo, GUID_INFO *guidInfo, BOOLEAN *SetFocus )
+{
+ CONTROL_INFO *newControlInfo;
+ VARIABLE_INFO *varInfo = NULL;
+ UINT8 *dataPtr;
+ VOID *ifrPtr;
+ CHAR16 *name = NULL;
+
+ UINT16 count, max = 0, value = 0, HiddenBootOptionCount=0;//EIP : 59417 Declaration for the Hidden Boot option count
+ UINT16 PrevControlQuestionID=0;
+
+ UINT32 varnum=0;
+ UINTN condSize;
+
+ if ( frame == NULL )
+ return;
+
+ if ( guidInfo->GuidFlags.GuidLaunchCallbackUpdateTemplate )
+ {
+ UefiSpecialGuidCallback( controlInfo->ControlHandle, 0xFFFE, &guidInfo->GuidValue);
+ }
+
+ varnum = GetControlConditionVarId(controlInfo); //controlInfo->ControlConditionalVariable[0];
+ ifrPtr = _SpecialGetIfrPtr( controlInfo, &varnum, NULL ); // TO get the special variable.
+
+ if(NoVarStoreSupport())
+ {
+ //More info needed.
+ if(varnum == VARIABLE_ID_SETUP)
+ {
+ ifrPtr = _SpecialGetIfrPtr( controlInfo, &varnum, NULL );
+
+ //The variable supplied is setup find the right variable
+ varnum = FindVarFromITKQuestionId(UefiGetEqIDQuestionID(ifrPtr));
+ }
+ }
+
+ if( varnum == VARIABLE_ID_ERROR_MANAGER ) // if it is error manager variable, get the real updated nvram data.
+ VarUpdateVariable(varnum);
+
+ varInfo = ((VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[varnum]));
+ name = GetGUIDNameByID(VARIABLE_ID_LANGUAGE);
+ //The following is replaced by Name comparision
+ //if ( ((VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[varnum]))->VariableID == LANGUAGE_CODES_KEY_ID )
+ if(EfiStrCmp(varInfo->VariableName, name) == 0)
+ {
+ MemFreePointer(&name);
+ max = 1;
+ }
+ else if (
+ (
+ CheckForAddDelBootOption () &&
+ ((VARIABLE_ID_DEL_BOOT_OPTION == controlInfo->ControlVariable) || (VARIABLE_ID_ADD_BOOT_OPTION == controlInfo->ControlVariable))
+ ) ||
+ (
+ CheckForAddDelDriverOption () && //EIP70421 & 70422
+ ((VARIABLE_ID_DEL_DRIVER_OPTION == controlInfo->ControlVariable) || (VARIABLE_ID_ADD_DRIVER_OPTION == controlInfo->ControlVariable))
+ )
+ )
+ {
+ max = 1;
+ }
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+ else if(varnum == VARIABLE_ID_OEM_TSE_VAR )
+ {
+ max = OEMSpecialGetControlCount(controlInfo);
+ }
+#endif
+ else
+ {
+ VarGetValue( varnum, 0, sizeof(UINT16), &max );
+ }
+ for (count = 0; count < max; count++)
+ {
+ if ( ( controlInfo->ControlPtr == 0 ) || ( controlInfo->ControlConditionalPtr == 0 ) )
+ continue;
+ if (
+ (gLoadOptionHidden && ((VARIABLE_ID_BOOT_MANAGER == varnum) || (VARIABLE_ID_BOOT_NOW == varnum) || (VARIABLE_ID_DRIVER_MANAGER == varnum))) &&
+ (VARIABLE_ID_DEL_BOOT_OPTION != controlInfo->ControlVariable) && //For deleting the boot/driver option max is 1 so if first option is hidden nothing will proceed
+ (VARIABLE_ID_ADD_BOOT_OPTION != controlInfo->ControlVariable) &&
+ (VARIABLE_ID_DEL_DRIVER_OPTION != controlInfo->ControlVariable) &&
+ (VARIABLE_ID_ADD_DRIVER_OPTION != controlInfo->ControlVariable)
+ )
+ {
+ if (count < gBootOptionCount) //EIP-91817 To avoid comparing garbage gBootData for LoadOptionHidden when SETUP_SHOW_ALL_BBS_DEVICES = 1
+ {
+ if ((VARIABLE_ID_DRIVER_MANAGER == varnum) ? (LoadOptionhidden (count, DRIVER_ORDER_OPTION)) : (LoadOptionhidden (count, BOOT_ORDER_OPTION)))
+ {
+ HiddenBootOptionCount ++; // If the Boot option has the attribute Hidden increment the HiddenBootOptionCount
+ continue;
+ }
+ }
+ }
+ newControlInfo = EfiLibAllocatePool( sizeof( CONTROL_INFO ) );
+ if ( newControlInfo == NULL )
+ continue;
+
+ MemCopy( newControlInfo, controlInfo, sizeof( CONTROL_INFO ) );
+ condSize = (UINTN)controlInfo->ControlPtr - (UINTN)controlInfo->ControlConditionalPtr;
+
+ // 256 should be replaced by ControlDataLength, but HPKTool currently does not set it
+ dataPtr = EfiLibAllocateZeroPool( 256 + condSize );
+ if(dataPtr == NULL)
+ {
+ MemFreePointer((void**)&newControlInfo);
+ continue;
+ }
+
+ newControlInfo->ControlConditionalPtr = dataPtr;
+ MemCopy( dataPtr, (VOID *)controlInfo->ControlConditionalPtr, condSize );
+ dataPtr += condSize;
+ newControlInfo->ControlPtr = dataPtr;
+ MemCopy( dataPtr, (VOID *)controlInfo->ControlPtr, 256 );
+
+ ifrPtr = _SpecialGetIfrPtr( newControlInfo, &varnum, NULL );
+
+ if ( ifrPtr != NULL )
+ {
+ if ((UefiIsOneOfControl ((VOID *)dataPtr)) && ((VARIABLE_ID_BOOT_MANAGER == varnum) || (VARIABLE_ID_DRIVER_MANAGER == varnum)))
+ {
+ UefiSetEqIDValue (ifrPtr, count - HiddenBootOptionCount);
+ }
+ else
+ {
+ UefiSetEqIDValue (ifrPtr, count);
+ }
+ }
+ ifrPtr = (VOID *)dataPtr;
+
+ // EIP:51671 START
+ //Depending on the value of the token hide of the disabled boot options is done
+ if (gSetupHideDisableBootOptions)
+ {
+ if(((VARIABLE_ID_BOOT_MANAGER == varnum)||(VARIABLE_ID_BOOT_NOW == varnum))&&(!(UefiIsOneOfControl( ifrPtr ))))
+ {
+ if (IsBootDeviceEnabled (count, gShowAllBbsDev, BootNowInBootOrderSupport (), 1))
+ continue;
+ }
+ }
+ // EIP:51671 END
+ // EIP:59417 START
+ //Checking for the Bootmanger variable and the token for Load Option hidden
+
+ // EIP:59417 END
+ if (UefiIsOneOfControl (ifrPtr))
+ {
+ UINTN size;
+ CHAR16 *newText;
+ CHAR16 *text ;
+
+ text = HiiGetString( controlInfo->ControlHandle, UefiGetPromptField(ifrPtr) );
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == text) {
+ text = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!text)
+ return;
+ EfiStrCpy(text,L" ");
+ }
+
+ size = sizeof(CHAR16) * ( EfiStrLen( text ) + 10 );
+ newText = EfiLibAllocateZeroPool( size );
+
+ SPrint( newText, size, text, count + 1 - HiddenBootOptionCount );
+
+ value = _SpecialGetValue( newControlInfo, &guidInfo );
+ UefiSetPromptField(ifrPtr, HiiAddString( controlInfo->ControlHandle, newText ));
+
+ // update boot order , bbs and language tokens, prevent double initialization
+ // this code was part of AddControlExtras().
+ UefiUpdateControlVarOffset (newControlInfo->ControlPtr, value * sizeof(UINT16));
+
+ switch ( guidInfo->GuidKey )
+ {
+ case GUID_KEY_BOOT_NOW:
+ if (NoVarStoreSupport())
+ {
+ _SpecialFixupBootOrder (newControlInfo, value);
+ }
+ else
+ {
+ if (newControlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER)
+ {
+ _SpecialFixupBootOrder (newControlInfo, value);
+ //if count not eq to 0 and count-1 Control is Disabled then supress the current control.
+ _SpecialFixupBootCondition(count,newControlInfo,PrevControlQuestionID);
+ PrevControlQuestionID = UefiGetQuestionID(newControlInfo);
+ }
+ else if (newControlInfo->ControlVariable == VARIABLE_ID_DEL_BOOT_OPTION)
+ {
+ TSESpecialFixupDelBootOption (newControlInfo);
+ }
+ }
+ break;
+ case GUID_KEY_ADD_BOOT_OPTION:
+ if ((CheckForAddDelBootOption()) && (newControlInfo->ControlVariable == VARIABLE_ID_ADD_BOOT_OPTION))
+ {
+ UefiUpdateControlVarOffset(newControlInfo->ControlPtr, UefiGetQuestionOffset(controlInfo->ControlPtr));
+ TseDoAddBootOptionFixup( newControlInfo );
+ }
+ break;
+
+ case GUID_KEY_LANG_CODES:
+ if ( gLangCount > 0 )
+ _SpecialFixupLanguages( newControlInfo );
+ break;
+
+ case GUID_KEY_BBS_ORDER:
+ _SpecialFixupBBSOrder( newControlInfo, value);
+ if(!NoVarStoreSupport())
+ {
+ //if count not eq to 0 and count-1 Control is Disabled then supress the current control.
+ _SpecialFixupBBSCondition(count,newControlInfo,PrevControlQuestionID);
+ PrevControlQuestionID = UefiGetQuestionID(newControlInfo);
+ }
+ break;
+ case GUID_KEY_DRIVER_OPTION: //EIP70421 & 70422
+ if (VARIABLE_ID_DRIVER_ORDER == newControlInfo->ControlVariable)
+ {
+ _SpecialFixupDriverOrder (newControlInfo, value);
+ //if count not eq to 0 and count-1 Control is Disabled then supress the current control.
+ _SpecialFixupBootCondition (count, newControlInfo, PrevControlQuestionID);
+ PrevControlQuestionID = UefiGetQuestionID(newControlInfo);
+ }
+ else if (VARIABLE_ID_DEL_DRIVER_OPTION == newControlInfo->ControlVariable)
+ {
+ TSESpecialFixupDelDriverOption (newControlInfo);
+ }
+ break;
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+ case GUID_KEY_OEM_CONTROL:
+ // Do the OEM Special Control's OneOf Fixup
+ OEMSpecialOneOfFixup( newControlInfo, value);
+ break;
+#endif
+ default:
+ break;
+ }
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ _SpecialAddControl( frame, newControlInfo, SetFocus );
+ // update optional info specially for boot order controls
+ _SpecialControlExtras((frame->ControlList[frame->ControlCount-1]));
+ MemFreePointer( (VOID **)&newControlInfo );
+ }
+
+ gSetupUpdated = FALSE; //EIP:51619 Reset the SetupUpdated Flag here.
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupLanguages
+//
+// Description: function to fixup the languages
+//
+// Input: CONTROL_INFO *control
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupLanguages( CONTROL_INFO *control )
+{
+ VOID *ifrPtr, *templatePtr, *oneOf;
+ VOID *tempPtr;
+ UINTN i, length = 0;
+ BOOLEAN flag = FALSE;
+
+ ifrPtr = (VOID *)control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+
+ if(PlatformLangVerSupport())
+ UefiSetWidth(ifrPtr, 6);
+ else
+ UefiSetWidth(ifrPtr, 3);
+
+ tempPtr = UefiCreateOneOfWithOptionsTemplate( gLangCount, control );
+ if ( tempPtr == NULL )
+ return;
+
+ templatePtr = (UINT8*)ifrPtr + length;
+ oneOf = (UINT8*)tempPtr + length;
+ length = UefiGetIfrLength(templatePtr);
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ MemCopy( oneOf, templatePtr, length );
+ flag = 0;
+ gLanguages[i].Token = HiiChangeString( gHiiHandle, gLanguages[i].Token, gLanguages[i].LangString );
+ UefiSetOneOfOption(oneOf, i, BOOT_OPTION_SIZE, flag, gLanguages[i].Token);
+ oneOf = (UINT8*)oneOf +length;
+ }
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp(oneOf);
+
+ tempPtr = HiiGetString( control->ControlHandle, UefiGetPromptField(ifrPtr) );
+ UefiSetPromptField (control->ControlPtr,HiiAddString( gHiiHandle, tempPtr ));
+
+ MemFreePointer( (VOID **)&tempPtr );
+ tempPtr = HiiGetString( control->ControlHandle, UefiGetHelpField(ifrPtr) );
+
+ control->ControlHelp = HiiAddString( gHiiHandle, tempPtr );
+ control->ControlHandle = gHiiHandle;
+
+ MemFreePointer( (VOID **)&tempPtr );
+}
+
+//EIP-48391: Start
+
+static VOID *gBootPageHandle = NULL;
+static UINTN gBootOptionTokenCount;
+static UINT16 *gBootOptionTokenArray;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetSpecialBootoptionToken
+//
+// Description: function to get the boot option token properly when loading the boot page
+//
+// Input: VOID* handle, UINTN Index
+//
+// Output: TOKEN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetSpecialBootoptionToken(VOID* handle, UINTN Index)
+{
+ UINTN i;
+
+ // EIP:51619 TO make sure it is called by _SpecialFixupBootOrder() and Boot page not modified
+ if (gBootPageHandle == handle)
+ {
+ if(FALSE == gSetupUpdated)
+ {
+ if(!gBootOptionTokenCount)
+ {
+ // Create the gBootOptionTokenArray
+ gBootOptionTokenArray = EfiLibAllocateZeroPool (sizeof(UINT16) * gBootOptionCount);
+ gBootOptionTokenCount = gBootOptionCount;
+ for(i=0;i< gBootOptionTokenCount;i++)
+ {
+ gBootOptionTokenArray[i] = INVALID_TOKEN;
+ }
+ }
+ else if(gBootOptionTokenCount < gBootOptionCount)
+ { // Boot options added. Update gBootOptionTokenArray
+ gBootOptionTokenArray = MemReallocateZeroPool(gBootOptionTokenArray, (sizeof(UINT16) * gBootOptionTokenCount), (sizeof(UINT16) * gBootOptionCount));
+ for(i= gBootOptionTokenCount; i< gBootOptionCount ;i++)
+ {
+ gBootOptionTokenArray[i] = INVALID_TOKEN;
+ }
+ gBootOptionTokenCount = gBootOptionCount;
+ }
+
+ if(gBootOptionTokenArray[Index] == INVALID_TOKEN)
+ gBootOptionTokenArray[Index] = HiiAddString(handle, BootGetOptionName( &(gBootData[Index]) ) );
+ else
+ {
+ // Check if Update is needed
+ CHAR16 *text;
+ text = HiiGetString( handle, gBootOptionTokenArray[Index]);
+
+ if (NULL == text) //EIP-131549
+ return (UINT16)EFI_OUT_OF_RESOURCES;
+
+ if(EfiStrCmp(text, BootGetOptionName( &(gBootData[Index]) )) != 0)
+ {
+ // need to update the token with new BootoptionName.
+ UINT16 Token = HiiChangeString( handle, gBootOptionTokenArray[Index], BootGetOptionName( &(gBootData[Index]) ));
+ if(Token != gBootOptionTokenArray[Index])
+ gBootOptionTokenArray[Index] = Token;
+ }
+ MemFreePointer((VOID **)&text);
+ }
+ }
+ else {
+ //If the some control modified with respect to boot page..
+ gBootOptionTokenArray[Index] = HiiAddString(handle, BootGetOptionName( &(gBootData[Index]) ) );
+ }
+ return gBootOptionTokenArray[Index];
+
+ }
+ else
+ //If the call is not from _SpecialFixupBootOrder()
+ return HiiAddString(handle, BootGetOptionName( &(gBootData[Index]) ) );
+}
+//EIP-48391: End
+
+//EIP70421 & 70422 Support for Driver Order starts
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: _GetSpecialDriveroptionToken
+//
+// Description: function to get the boot option token properly when loading the boot page
+//
+// Input: VOID* handle, UINTN Index
+//
+// Output: TOKEN
+//
+//-------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetSpecialDriveroptionToken (VOID* handle, UINTN Index)
+{
+ UINTN i;
+
+ if (gDriverPageHandle == handle)
+ {
+ if(FALSE == gSetupUpdated)
+ {
+ if (!gDriverOptionTokenCount)
+ {
+ // Create the gDriverOptionTokenArray
+ gDriverOptionTokenArray = EfiLibAllocateZeroPool (sizeof(UINT16) * gDriverOptionCount);
+ gDriverOptionTokenCount = gDriverOptionCount;
+ for (i = 0; i < gDriverOptionTokenCount; i ++)
+ {
+ gDriverOptionTokenArray [i] = INVALID_TOKEN;
+ }
+ }
+ else if (gDriverOptionTokenCount < gDriverOptionCount)
+ { // Drivers options added. Update gDriverOptionTokenArray
+ gDriverOptionTokenArray = MemReallocateZeroPool (gDriverOptionTokenArray, (sizeof (UINT16) * gDriverOptionTokenCount), (sizeof (UINT16) * gDriverOptionCount) );
+ for (i = gDriverOptionTokenCount; i < gDriverOptionCount ; i ++)
+ {
+ gDriverOptionTokenArray [i] = INVALID_TOKEN;
+ }
+ gDriverOptionTokenCount = gDriverOptionCount;
+ }
+
+ if (gDriverOptionTokenArray [Index] == INVALID_TOKEN)
+ gDriverOptionTokenArray [Index] = HiiAddString (handle, DriverGetOptionName (&(gDriverData [Index]) ) );
+ else
+ {
+ // Check if Update is needed
+ CHAR16 *text;
+ text = HiiGetString( handle, gDriverOptionTokenArray [Index]);
+ if(EfiStrCmp(text, DriverGetOptionName ( &(gDriverData[Index]) )) != 0)
+ {
+ // need to update the token with new DriveroptionName.
+ UINT16 Token = HiiChangeString( handle, gDriverOptionTokenArray [Index], DriverGetOptionName( &(gDriverData[Index]) ));
+ if(Token != gDriverOptionTokenArray [Index])
+ gDriverOptionTokenArray [Index] = Token;
+ }
+ MemFreePointer((VOID **)&text);
+ }
+ }
+ else {
+ //If the some control modified with respect to boot page..
+ gDriverOptionTokenArray [Index] = HiiAddString (handle, DriverGetOptionName (&(gDriverData [Index]) ) );
+ }
+ return gDriverOptionTokenArray [Index];
+
+ }
+ else
+ //If the call is not from _SpecialFixupBootOrder()
+ return HiiAddString(handle, DriverGetOptionName (&(gDriverData [Index]) ) );
+}
+//EIP70421 & 70422 Support for Driver Order ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupBootOrder
+//
+// Description: function to fixup the Boot device order
+//
+// Input: CONTROL_INFO *control,
+// UINT16 value
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupBootOrder (CONTROL_INFO *control, UINT16 value)
+{
+ VOID *tempPtr, *ifrPtr;
+ VOID *templatePtr, *oneOf;
+ UINTN i;
+ CHAR16 *text;
+ UINT8 length = 0;
+ UINT16 option = 0;
+ UINT8 flag = 0;
+
+ ifrPtr = control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+ //Create one one_of_option for each boot option + 1 for Disable option
+ tempPtr = UefiCreateOneOfWithOptionsTemplate (gBootOptionCount+1, control);
+ if ( tempPtr == NULL )
+ return;
+
+ templatePtr = ((UINT8*)ifrPtr + length);
+ oneOf = ((UINT8*)tempPtr + length);
+ length = UefiGetIfrLength(templatePtr);
+
+//EIP-48391: Start
+ gBootPageHandle = control->ControlHandle; //++
+ for ( i = 0; i < gBootOptionCount; i++ ) {
+ flag = (i == value)? (UINT8)HiiGetDefaultMask() : 0;
+ //option = HiiAddString( control->ControlHandle, BootGetOptionName( &(gBootData[i]) ) ); // --
+ //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+ if (gLoadOptionHidden && (gBootData [i].Active & LOAD_OPTION_HIDDEN) )
+ continue;
+ option = GetSpecialBootoptionToken (control->ControlHandle, i);
+ MemCopy (oneOf, templatePtr, length);
+ // Add one of option
+ UefiSetOneOfOption (oneOf, gBootData[i].Option, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+ }
+//EIP-48391: End
+
+ //Create one of option for Disabled
+ flag = 0;
+ MemCopy (oneOf, templatePtr, length);
+ text = HiiGetString (gHiiHandle, STR_CTRL_CHKBOX_DISABLE);
+ option = HiiAddString (control->ControlHandle, text);
+
+ //UefiSetOneOfOption (oneOf, 0xFFFF, BOOT_OPTION_SIZE, flag, option); //EIP-97704 BootFFFF
+ UefiSetOneOfOption (oneOf, DISABLED_BOOT_OPTION, BOOT_OPTION_SIZE, flag, option);
+
+ MemFreePointer((VOID **)&text);
+ oneOf = (UINT8*)oneOf +length;
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp(oneOf);
+
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField(ifrPtr);
+
+ if(NoVarStoreSupport())
+ {
+ VOID *ifrPtr;
+ UINT16 QuestionId;
+
+ control->ControlVariable = VARIABLE_ID_BOOT_ORDER;
+ control->ControlConditionalVariable[0] = VARIABLE_ID_BOOT_MANAGER;
+
+ ifrPtr = _SpecialGetIfrPtr( control, VARIABLE_ID_SETUP, NULL);
+ QuestionId = UefiGetEqIDQuestionID(ifrPtr);
+ QuestionId = QuestionId - GetNoVarStoreBootCountOffset();
+ UefiSetEqIDQuestionID(ifrPtr, QuestionId);
+ }
+}
+
+//EIP70421 & 70422 Support for driver order starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupDriverOrder
+//
+// Description: Function to fixup the driver order
+//
+// Input: CONTROL_INFO *control,
+// UINT16 value
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupDriverOrder (CONTROL_INFO *control, UINT16 value)
+{
+ VOID *tempPtr, *ifrPtr;
+ VOID *templatePtr, *oneOf;
+ UINTN i;
+ CHAR16 *text;
+ UINT8 length = 0;
+ UINT16 option = 0;
+ UINT8 flag = 0;
+
+ ifrPtr = control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+ //Create one one_of_option for each driver option + 1 for Disable option
+ tempPtr = UefiCreateOneOfWithOptionsTemplate (gDriverOptionCount+1, control);
+ if (NULL == tempPtr)
+ return;
+ templatePtr = ((UINT8*)ifrPtr + length);
+ oneOf = ((UINT8*)tempPtr + length);
+ length = UefiGetIfrLength(templatePtr);
+ gDriverPageHandle = control->ControlHandle;
+
+ for ( i = 0; i < gDriverOptionCount; i++ )
+ {
+ flag = (i == value)? (UINT8)HiiGetDefaultMask() : 0;
+ if (gLoadOptionHidden && (gDriverData [i].Active & LOAD_OPTION_HIDDEN))
+ continue;
+ option = _GetSpecialDriveroptionToken (control->ControlHandle, i);
+ MemCopy (oneOf, templatePtr, length);
+ // Add one of option
+ UefiSetOneOfOption (oneOf, gDriverData [i].Option, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+ }
+ //Create one of option for Disabled
+ flag = 0;
+ MemCopy (oneOf, templatePtr, length);
+ text = HiiGetString (gHiiHandle, STR_CTRL_CHKBOX_DISABLE);
+ option = HiiAddString (control->ControlHandle, text);
+
+ //UefiSetOneOfOption (oneOf, 0xFFFF, BOOT_OPTION_SIZE, flag, option); //EIP-97704 DriverFFFF
+ UefiSetOneOfOption (oneOf, DISABLED_DRIVER_OPTION, BOOT_OPTION_SIZE, flag, option);
+
+ MemFreePointer((VOID **)&text);
+ oneOf = (UINT8*)oneOf +length;
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp(oneOf);
+
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField(ifrPtr);
+}
+//EIP70421 & 70422 Support for driver order ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupBootCondition
+//
+// Description: This function updates the Condition to avoid more then one
+// disabled option in Boot order.
+//
+// Input: ControlIndex, Control Info, PrevControlQuestionID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupBootCondition (UINT16 ControlIndex,CONTROL_INFO *control,UINT16 PrevControlQuestionID)
+{
+ // Don't Update the Condition for First option
+ if(!ControlIndex)
+ return;
+ else
+ {
+ UINT8 u8ChkResult = CheckControlCondition( control );
+ if(u8ChkResult == COND_NONE)
+ {
+ VARIABLE_INFO *VarInfo;
+ VarInfo = VarGetVariableInfoIndex(control->ControlVariable);
+ if(NULL != VarInfo){//EIP-75352 Suppress the warnings from static code analyzer
+ UefiCreateDynamicControlCondition(control,(UINT16)VarInfo->VariableID,PrevControlQuestionID,DISABLED_BOOT_OPTION);
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupBBSCondition
+//
+// Description: This function updates the Condition to avoid more then one
+// disabled option in BBS Dev order.
+//
+// Input: ControlIndex, Control Info, PrevControlQuestionID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupBBSCondition(UINT16 ControlIndex,CONTROL_INFO *control,UINT16 PrevControlQuestionID)
+{
+ // Don't Update the Condition for First option
+ if(!ControlIndex)
+ return;
+ else
+ {
+ UINT8 u8ChkResult = CheckControlCondition( control );
+ if(u8ChkResult == COND_NONE)
+ {
+ VARIABLE_INFO *VarInfo;
+ VarInfo = VarGetVariableInfoIndex(control->ControlVariable);
+ if(NULL != VarInfo){//EIP-75352 Suppress the warnings from static code analyzer
+ UefiCreateDynamicControlCondition(control,(UINT16)VarInfo->VariableID,PrevControlQuestionID,DISABLED_BOOT_OPTION);
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupBBSOrder
+//
+// Description: function to fixup the Legacy Boot device order
+//
+// Input: CONTROL_INFO *control,
+// UINT16 value
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupBBSOrder( CONTROL_INFO *control, UINT16 value )
+{
+ VOID *ifrPtr, *templatePtr, *oneOf, *tempPtr;
+ UINTN i;
+ UINT16 count,option;
+ UINT16 length = 0;
+ CHAR16 *text;
+ UINT8 flag;
+
+ count = gCurrLegacyBootData->LegacyDevCount;
+
+ ifrPtr = (VOID *)control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+ //Create one one_of_option for each device + 1 for Disable option
+ tempPtr = UefiCreateOneOfWithOptionsTemplate(count + 1, control);
+ if ( tempPtr == NULL )
+ return;
+
+
+ // set real offset into bbs variable for this control.
+ BBSUpdateControlOffset(control);
+
+ templatePtr = (UINT8*)ifrPtr + length;
+ oneOf = (UINT8*)tempPtr + length;
+ length = UefiGetIfrLength(templatePtr);
+
+ for ( i = 0; i < count; i++)
+ {
+ UINT16 bbsOptionVal = 0;
+
+ MemCopy( oneOf, templatePtr, length );
+ flag = (i == value)? (UINT8)HiiGetDefaultMask() : 0;
+ option = HiiAddString( control->ControlHandle, BBSGetOptionName( &bbsOptionVal,(UINT16)i ) );
+ MemCopy( oneOf, templatePtr, length );
+ // Add one of option
+ UefiSetOneOfOption(oneOf, bbsOptionVal, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+ }
+
+ //Create one of option for Disabled
+ flag = 0;
+ MemCopy( oneOf, templatePtr, length );
+ text = HiiGetString(gHiiHandle,STR_CTRL_CHKBOX_DISABLE);
+ option = HiiAddString( control->ControlHandle, text );
+
+ //UefiSetOneOfOption(oneOf, 0xFFFF, BOOT_OPTION_SIZE, flag, option); //EIP-97704 BootFFFF
+ UefiSetOneOfOption(oneOf, DISABLED_BOOT_OPTION, BOOT_OPTION_SIZE, flag, option);
+
+ MemFreePointer((VOID **)&text);
+ oneOf = (UINT8*)oneOf +length;
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp(oneOf);
+
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField(ifrPtr);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialFixupDelBootOption
+//
+// Description: function to fixup the deletion of a boot device option
+//
+// Input: CONTROL_INFO *control,
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SpecialFixupDelBootOption (CONTROL_INFO *control)
+{
+ VOID *ifrPtr, *templatePtr, *oneOf;
+ VOID *tempPtr;
+ UINTN i, length = 0;
+
+ ifrPtr = (VOID *)control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+ //Create one one_of_option for each boot option + 1 for Disable option
+ tempPtr = UefiCreateOneOfWithOptionsTemplate (gBootOptionCount + 1, control);
+ if ( tempPtr == NULL )
+ return;
+
+ templatePtr = (UINT8*)ifrPtr + length;
+ oneOf = (UINT8*)tempPtr + length;
+ length = UefiGetIfrLength (templatePtr);
+
+ //Copy the first option and skip to next
+ MemCopy( oneOf, templatePtr, length );
+ oneOf = (UINT8*)oneOf +length;
+
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if(
+ ((gBootData[i].DevicePath->Type == BBS_DEVICE_PATH) && (gBootData[i].DevicePath->SubType == BBS_BBS_DP)) ||
+ (gLoadOptionHidden && (gBootData [i].Active & LOAD_OPTION_HIDDEN))
+ )
+ {
+ continue;
+ }
+ else
+ {
+ UINT16 option = 0;
+ UINT8 flag = 0;
+
+ MemCopy( oneOf, templatePtr, length );
+ option = HiiAddString (control->ControlHandle, BootGetOptionName (&(gBootData[i])));
+ // Add one of option
+ UefiSetOneOfOption (oneOf, gBootData[i].Option, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+ }
+ }
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp (oneOf);
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField (ifrPtr);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialFixupAddBootOption
+//
+// Description: function to fixup the adding of a boot device option
+//
+// Input: CONTROL_INFO *control,
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialFixupAddBootOption( CONTROL_INFO *control)
+{
+ VOID *ifrPtr, *templatePtr, *oneOf;
+ VOID *tempPtr;
+ UINTN i, length = 0;
+
+ ifrPtr = (VOID *)control->ControlPtr;
+ length = UefiGetIfrLength(ifrPtr);
+ //Create one one_of_option for each file sys
+ tempPtr = UefiCreateOneOfWithOptionsTemplate( gFsCount, control );
+ if ( tempPtr == NULL )
+ return;
+
+ UefiUpdateControlVarOffset(control, STRUCT_OFFSET(NEW_BOOT_OPTION, SelFs));
+
+ templatePtr = (UINT8*)ifrPtr + length;
+ oneOf = (UINT8*)tempPtr + length;
+ length = UefiGetIfrLength(templatePtr);
+
+ for ( i = 0; i < gFsCount; i++)
+ {
+ UINT16 option = 0;
+ UINT8 flag = 0;
+
+ MemCopy( oneOf, templatePtr, length );
+ // Add one of option
+ option = HiiAddString( control->ControlHandle, gFsList[i].FsId);
+ UefiSetOneOfOption(oneOf, (UINT16)i, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+
+ }
+
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp(oneOf);
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField(ifrPtr);
+}
+
+//EIP70421 & 70422 Support for driver order starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialFixupDelDriverOption
+//
+// Description: Function to fixup the deletion of a driver option
+//
+// Input: CONTROL_INFO *control,
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SpecialFixupDelDriverOption (CONTROL_INFO *control)
+{
+ VOID *ifrPtr, *templatePtr, *oneOf;
+ VOID *tempPtr;
+ UINTN i, length = 0;
+
+ ifrPtr = (VOID *)control->ControlPtr;
+ length = UefiGetIfrLength (ifrPtr);
+ //Create one one_of_option for each driver option + 1 for Disable option
+ tempPtr = UefiCreateOneOfWithOptionsTemplate (gDriverOptionCount + 1, control);
+ if (NULL == tempPtr)
+ return;
+
+ templatePtr = (UINT8*)ifrPtr + length;
+ oneOf = (UINT8*)tempPtr + length;
+ length = UefiGetIfrLength (templatePtr);
+
+ //Copy the first option and skip to next
+ MemCopy (oneOf, templatePtr, length);
+ oneOf = (UINT8*)oneOf +length;
+
+ for (i = 0; i < gDriverOptionCount; i++)
+ {
+ if(
+ ((gDriverData [i].DevicePath->Type == BBS_DEVICE_PATH) && (gDriverData [i].DevicePath->SubType == BBS_BBS_DP)) ||
+ (gLoadOptionHidden && (gDriverData [i].Active & LOAD_OPTION_HIDDEN))
+ )
+ {
+ continue;
+ }
+ else
+ {
+ UINT16 option = 0;
+ UINT8 flag = 0;
+ MemCopy (oneOf, templatePtr, length);
+ option = HiiAddString (control->ControlHandle, DriverGetOptionName (&(gDriverData [i])));
+ // Add one of option
+ UefiSetOneOfOption (oneOf, gDriverData [i].Option, BOOT_OPTION_SIZE, flag, option);
+ oneOf = (UINT8*)oneOf +length;
+ }
+ }
+ // Add an End op to close scope of the One of control
+ UefiAddEndOp (oneOf);
+ ifrPtr = control->ControlPtr;
+ control->ControlHelp = UefiGetHelpField(ifrPtr);
+}
+//EIP70421 & 70422 Support for driver order ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialExplodeControl
+//
+// Description: function to explode a perticular contorller
+//
+// Input: FRAME_DATA *frame,
+// CONTROL_INFO *ctrlData,
+// BOOLEAN *SetFocus
+//
+// Output: control Value
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INT16 _SpecialExplodeControl( FRAME_DATA *frame, CONTROL_INFO *ctrlData, BOOLEAN *SetFocus )
+{
+ UINT16 value;
+ GUID_INFO *guidInfo;
+
+ value = _SpecialGetValue( ctrlData, &guidInfo );
+ if ( value == (UINT16)-1 )
+ _SpecialAddMultipleControls( frame,ctrlData, guidInfo, SetFocus );
+
+ return value;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SpecialControlExtras
+//
+// Description: special handling of extra operations
+//
+// Input: CONTROL_DATA *ctrlData
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _SpecialControlExtras(CONTROL_DATA *ctrlData)
+{
+ GUID_INFO *guidInfo = NULL;
+ UINT16 token = 0;
+
+ UINT16 value = _SpecialGetValue( &ctrlData->ControlData, &guidInfo );
+ if ( value != (UINT16)-2 )
+ {
+ switch(ctrlData->ControlData.ControlType)
+ {
+ case CONTROL_TYPE_SUBMENU:// submenu control
+ if (guidInfo->GuidKey != GUID_KEY_ADD_BOOT_OPTION)//EIP-79955 To draw GEOMETRICSHAPE_RIGHT_TRIANGLE for AddBootOption
+ ((SUBMENU_DATA*)ctrlData)->SubMenuType = 2;
+ if (guidInfo->GuidKey == GUID_KEY_BOOT_NOW)
+ {
+///EIP - 24971
+ token = HiiAddString( ctrlData->ControlData.ControlHandle, BootGetBootNowName(value,gShowAllBbsDev,BootNowInBootOrderSupport()));
+///EIP - 24971
+ //Update the submenu prompt field.
+ UefiSetPromptField(ctrlData->ControlData.ControlPtr, token);
+ }
+ else if ( guidInfo->GuidKey == GUID_KEY_ERROR_MANAGER )
+ {
+ UINTN size = 0;
+ ERROR_MANAGER *errManager = VarGetNvram( VARIABLE_ID_ERROR_MANAGER, &size );
+
+ if ( ( errManager != NULL ) && ( value < errManager->ErrorCount ) )
+ {
+ ERROR_LIST *errList = &(errManager->ErrorList[value]);
+
+ // Update the submenu prompt field.
+ UefiSetPromptField(ctrlData->ControlData.ControlPtr, errList->Summary);
+ ctrlData->ControlData.ControlHelp = errList->DetailInfo;
+ ctrlData->ControlData.ControlHandle = (VOID*)errList->Handle;
+ MemFreePointer( (VOID **)&errManager );
+ }
+ }
+ else if (guidInfo->GuidKey == GUID_KEY_DYNAMIC_PAGE)
+ {
+ UINTN i = 0,j;
+ UINTN Index=0;
+ PAGE_INFO *pageInfo;
+ PAGE_INFO *tmppageInfo;
+ PAGE_DATA **page;
+
+ //EIP 78627: To maintain consistency, show arrow when displaying submenu (SubMenuType=0).
+ ((SUBMENU_DATA*)ctrlData)->SubMenuType = 0;
+
+ //Scan for dynamic pages
+ for(i = 0; i < gPages->PageCount; i++)
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+
+
+ if((pageInfo->PageFlags.PageDynamic == TRUE) && (pageInfo->PageHandle != NULL))
+ {
+ if(Index == value)
+ {
+
+ CHAR16 *text;
+ UINT16 Title=0, Help=0 ;
+
+ // Get Formset Title and Help for Dynamic page
+ GetFormSetTitleAndHelpWrapper (pageInfo->PageHandle, &Title, &Help);
+
+ // Add the Prompt
+ text = HiiGetString( pageInfo->PageHandle, pageInfo->PageSubTitle);
+ token = HiiAddString( ctrlData->ControlData.ControlHandle, text);
+ UefiSetPromptField(ctrlData->ControlData.ControlPtr, token);
+
+ //EIP# 72333, Display Formset Help for Dynamic page
+ if(Help != 0)
+ {
+ MemFreePointer( (VOID **)&text );
+ text = HiiGetString( pageInfo->PageHandle, Help);
+ token = HiiAddString( ctrlData->ControlData.ControlHandle, text);
+ UefiSetHelpField(ctrlData->ControlData.ControlPtr, token);
+ ctrlData->ControlData.ControlHelp = token ;
+ }//EIP# 72333 End
+
+ // Fix the parent pageID
+ ctrlData->ControlData.ControlDestPageID = pageInfo->PageID ;
+ pageInfo->PageParentID = gApp->CurrentPage;
+ gDynamicParentPage = gApp->CurrentPage;
+ // Reinitilize the Page.
+ for(j = i; j < gPages->PageCount; j++)
+ {
+ tmppageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[j]);
+ if(pageInfo->PageHandle == tmppageInfo->PageHandle )
+ {
+ page = &gApp->PageList[tmppageInfo->PageID];
+ gPage.Destroy( *page, FALSE );
+ gPage.Initialize( *page, tmppageInfo );
+ }
+ }
+ MemFreePointer( (VOID **)&text );
+ }
+ Index++;
+ }
+ }
+
+ }
+ else if (guidInfo->GuidKey == GUID_KEY_IDE_SECURITY)
+ {
+ CHAR16 *text;
+ UINT16 IDEStrToken = TSEIDEPasswordGetName(value);
+
+
+ if(IDEStrToken)
+ {
+ UINTN size;
+ IDE_SECURITY_CONFIG *ideSecConfig;
+ size = 0;
+ //Update mem copy of the IDE sec variable
+ ideSecConfig = VarGetVariable( VARIABLE_ID_IDE_SECURITY, &size );
+ if (NULL == ideSecConfig) {
+ break;
+ }
+ TSEIDEUpdateConfig(ideSecConfig, value);
+ VarSetValue( VARIABLE_ID_IDE_SECURITY, 0, size, ideSecConfig ); //EIP-83704 to update VARIABLE_ID_IDE_SECURITY variable when HDD is frozen in setup
+ MemFreePointer((VOID **)&ideSecConfig);
+
+ //VarUpdateVariable (VARIABLE_ID_IDE_SECURITY);
+ text = HiiGetString( gHiiHandle, IDEStrToken);
+ token = HiiAddString( ctrlData->ControlData.ControlHandle, text);
+ //Update the submenu prompt field.
+ UefiSetPromptField(ctrlData->ControlData.ControlPtr, token);
+ MemFreePointer( (VOID **)&text );
+ }
+ }
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+ else if ( guidInfo->GuidKey == GUID_KEY_OEM_CONTROL )
+ {
+ OEMSpecialGotoFixup(&ctrlData->ControlData,value);
+ }
+#endif
+/**/
+ else if (guidInfo->GuidKey == GUID_KEY_BBS_ORDER)
+ {
+ CHAR16 *text = NULL;
+ UINTN i,j;
+ BOOT_DATA *bootData;
+
+ for(i=0,j=0; i<gBootOptionCount; i++)
+ {
+ bootData = &(gBootData[i]);
+ //EIP:59417 - Checking the LOAD_OPTION_HIDDEN for the boot option
+ if(gLoadOptionHidden && (bootData->Active & LOAD_OPTION_HIDDEN))
+ continue;
+
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ if(value == j)
+ {
+ BBS_BBS_DEVICE_PATH *DevPath = (BBS_BBS_DEVICE_PATH *)bootData->DevicePath;
+
+ switch(DevPath->DeviceType)
+ {
+ case BBS_TYPE_FLOPPY:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_FLOPPY_DISK_ORDER));
+ break;
+ case BBS_TYPE_HARDDRIVE:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_HARD_DISK_ORDER));
+ break;
+ case BBS_TYPE_CDROM:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_CDROM_ORDER));
+ break;
+
+ case BBS_TYPE_PCMCIA:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_PCMCIA_ORDER));
+ break;
+
+ case BBS_TYPE_USB:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_USB_ORDER));
+ break;
+
+ case BBS_TYPE_EMBEDDED_NETWORK:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_NETWORK_ORDER));
+ break;
+ case BBS_TYPE_DEV:
+ text = HiiGetString( gHiiHandle, STRING_TOKEN(STR_BEV_ORDER));
+ break;
+ default:
+ /// EIP-42520: Updated to get the BBS group type from the Board module in case of a non standard type.
+ text = HiiGetString( gHiiHandle, BBSGetNonStandardGroupType(DevPath->DeviceType));
+ break;
+ }
+
+ token = HiiAddString( ctrlData->ControlData.ControlHandle, text);
+ //Update the submenu prompt field.
+ UefiSetPromptField(ctrlData->ControlData.ControlPtr, token);
+
+ MemFreePointer( (VOID **)&text );
+
+ break;
+ }
+ j++;
+ }
+ }
+ }
+ else if (GUID_KEY_DRIVER_HEALTH == guidInfo->GuidKey)
+ {
+ CHAR16 *text;
+ ((SUBMENU_DATA*)ctrlData)->SubMenuType = 0; //EIP100099 showing submenu triangle
+ text = FindDriverHealthDriverName (value);
+ if (NULL != text)
+ {
+ token = HiiAddString (ctrlData->ControlData.ControlHandle, text);
+ UefiSetPromptField (ctrlData->ControlData.ControlPtr, token);
+ }
+ }
+ else if (GUID_KEY_DRV_HEALTH_CTRL_COUNT == guidInfo->GuidKey)
+ {
+ CHAR16 *text;
+ text = GetCtrlNameAndHealth (value);
+ if (NULL != text)
+ {
+ token = HiiAddString (ctrlData->ControlData.ControlHandle, text);
+ UefiSetPromptField (ctrlData->ControlData.ControlPtr, token);
+ }
+ }
+ else if (GUID_KEY_DRIVER_HEALTH_ENB == guidInfo->GuidKey)
+ {
+ ((SUBMENU_DATA*)ctrlData)->SubMenuType = 0; //EIP100099 showing submenu triangle
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialUpdatePageControls
+//
+// Description: special fucntion to update the page controls
+//
+// Input: UINT32 CurrentPage
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SpecialUpdatePageControls(UINT32 CurrentPage)
+{
+ PAGE_INFO *thisPage;
+ UINT16 i=MAIN_FRAME,j=0, k=0;
+ INT16 Value=0;
+ CONTROL_INFO *control;
+ CONTROL_DATA **ControlData;
+ CONTROL_INFO *ControlInfo;
+ GUID_INFO *guidInfo;
+ FRAME_DATA *fdata;
+ BOOLEAN ExitUpdate=FALSE, SetFocus =TRUE;
+//Fix EIP:18142 - start
+ UINT32 tmpControlCount,tmpCurrentControl,tmpFirstVisibleCtrl;
+//Fix EIP:18142 - end
+
+ i = (UINT16) StyleFrameIndexOf(MAIN_FRAME) ;
+ thisPage = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[CurrentPage]);
+ // find if controls in page need to be exploded
+ // i=0;
+ //while(i< thisPage->FrameCount )
+ //{
+ // for now search main frame only, if needed uncomment code above to do this for all frames in page
+ for(j=0;j < thisPage->PageControls.ControlCount;j++)
+ {
+ control = (CONTROL_INFO*)((UINT8 *)(gControlInfo) + thisPage->PageControls.ControlList[j]);
+
+ switch( _SpecialGetValue( control, &guidInfo ))
+ {
+ case (UINT16)-2:
+ break;
+ default:
+ // special case, need to reinitialize this frame
+ //pdata = (PAGE_DATA*)gApp->PageList[CurrentPage];
+ fdata = ((PAGE_DATA*)gApp->PageList[CurrentPage])->FrameList[i];
+ //clist = ((PAGE_DATA*)gApp->PageList[CurrentPage])->FrameList[i]->ControlList;
+ ControlData = ((PAGE_DATA*)gApp->PageList[CurrentPage])->FrameList[i]->ControlList;
+
+//Fix EIP:18142 - Start
+ tmpControlCount = fdata->ControlCount;
+ tmpCurrentControl = fdata->CurrentControl;
+ tmpFirstVisibleCtrl = fdata->FirstVisibleCtrl;
+//Fix EIP:18142 - End
+ for ( k = 0; k < fdata/*gApp->PageList[CurrentPage]->FrameList[i]*/->ControlCount; k++, ControlData++ )
+ (*ControlData)->Methods->Destroy( *ControlData, TRUE );
+
+ fdata/*gApp->PageList[CurrentPage]->FrameList[i]*/->ControlCount =0;
+ fdata/*gApp->PageList[CurrentPage]->FrameList[i]*/->CurrentControl =0;
+ fdata/*gApp->PageList[CurrentPage]->FrameList[i]*/->NullCount =0;
+ fdata->FirstVisibleCtrl = 0;
+
+ // loop for al acontrols to either add it "as is" or explode it
+ for ( k = 0; k < thisPage->PageControls.ControlCount; k++ )
+ {
+ ControlInfo = (CONTROL_INFO*)((UINT8 *)gControlInfo + (UINT32)thisPage->PageControls.ControlList[k]);
+ switch(Value=_SpecialExplodeControl(fdata,ControlInfo, &SetFocus))
+ {
+ case -1:
+ break;
+ default:
+ if( _SpecialAddControl(fdata,ControlInfo, &SetFocus ) == EFI_SUCCESS) //EIP-34679: Typo error fix
+ _SpecialControlExtras((fdata->ControlList[fdata->ControlCount-1]));
+ break;
+ }
+
+ }
+//Fix EIP:18142 - Start
+// To retains the Control Focues in page with has special control
+// If the control count is different the we will focus to first control as we don't know
+// What is added or missing.
+ if(fdata->ControlCount == tmpControlCount)
+ {
+ fdata->CurrentControl=tmpCurrentControl;
+ fdata->FirstVisibleCtrl=tmpFirstVisibleCtrl;
+ _FrameSetControlFocus( fdata, tmpCurrentControl );
+ }
+//Fix EIP:18142 - End
+
+ ExitUpdate =TRUE;
+ break;
+ }
+ if(ExitUpdate)
+ break;
+ }
+ //}
+}
+//#endif
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseAdvanced/special.h b/EDK/MiniSetup/TseAdvanced/special.h
new file mode 100644
index 0000000..ef54db3
--- /dev/null
+++ b/EDK/MiniSetup/TseAdvanced/special.h
@@ -0,0 +1,196 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/special.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 5:53a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced/special.h $
+//
+// 9 10/18/12 5:53a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:35p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 1/30/12 1:27a Arunsb
+// [TAG] EIP74676
+// [Category] Improvement
+// [Description] Setup.ini and Upfisetup.ini to reserve 3~5 variable and
+// GUID for porting purpose
+// [Files] Amivfr.h, special.h, variable.h, Uefisetup.ini and setup.ini
+//
+// 7 11/13/11 12:39p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 6 6/30/11 4:13a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Guid key added.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 5 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 4 2/19/10 1:02p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:12a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 9/15/09 9:38a Sudhirv
+// added definition GUID_KEY_OEM_CONTROL
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:43p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:16p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 10:27p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 11 10/24/07 11:23a Arunkumars
+// - Moved IDE security code to binary
+// - Fixed build errors under UGA draw support
+// - Added EFI key password support
+// - Added modifier hot key support
+// - Added popup support in From browser protocol
+//
+// 10 1/25/07 11:06a Arunkumars
+// Fixed StringWrapText function to consider words longer than width.
+// Added code to correct LegacyDevOrder upon entry.
+// BootOrder now has all the options and only enabled ones are booted by
+// boot manager
+//
+// 9 1/09/07 10:15a Arunkumars
+// Enable/Disable of boot/bbs option support
+// Add/Del of boot option support
+//
+// 8 10/03/06 11:26a Natalyak
+// IDE Security support
+//
+// 7 9/27/05 10:02p Franklynd
+// Updates to BBS order capability.
+//
+// 6 8/01/05 4:15p Franklynd
+// 1-Update boot manager and boot options pages at runtime. with latest
+// boot information.
+//
+// 2- PopupSel using less space.
+//
+//
+// 5 7/19/05 3:44p Jerryp
+// Language fixes
+//
+// 4 6/27/05 2:59p Jerryp
+// Support for dynamic expansion
+//
+// 3 6/24/05 7:35p Jerryp
+//
+// 2 6/24/05 10:17a Jerryp
+// Added ErrorManager handling
+//
+// 1 5/27/05 10:24a Jerryp
+// Special handling for OEM packs
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Special.h
+//
+// Description: Header file for TSE special controls like AMI callback controls
+//
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _SPECIAL_H_
+#define _SPECIAL_H_
+
+#define GUID_KEY_BOOT_NOW 0x0001
+#define GUID_KEY_AMI_CALLBACK 0x0002
+#define GUID_KEY_ERROR_MANAGER 0x0003
+#define GUID_KEY_LANG_CODES 0x0005
+#define GUID_KEY_BBS_ORDER 0x0007
+#define GUID_KEY_IDE_SECURITY 0x0008
+#define GUID_KEY_ADD_BOOT_OPTION 0x0009
+#define GUID_KEY_OEM_CONTROL 0x000A
+#define GUID_KEY_MODAL 0x000B
+#define GUID_KEY_REFRESH 0x000C
+#define GUID_KEY_NO_COMMIT 0x000D
+#define GUID_KEY_DYNAMIC_PAGE 0x000E
+#define GUID_KEY_DRIVER_HEALTH_ENB 0x000F
+#define GUID_KEY_DRIVER_HEALTH 0x0010
+#define GUID_KEY_DRV_HEALTH_CTRL_COUNT 0x0011
+#define GUID_KEY_DRIVER_OPTION 0x0012 //EIP70421 & 70422 Support for driver order
+#define GUID_KEY_OEMGUID1 0x0013 //EIP74676 guids for porting purpose
+#define GUID_KEY_OEMGUID2 0x0014
+
+
+UINT16 SpecialGetValue( CONTROL_DATA *control, GUID_INFO **guidInfo );
+VOID SpecialAddMultipleControls( CONTROL_INFO *controlInfo, GUID_INFO *guidInfo );
+VOID SpecialUpdatePageControls(UINT32 CurrentPage);
+
+#endif /* _SPECIAL_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Action.c b/EDK/MiniSetup/TseLite/Action.c
new file mode 100644
index 0000000..a73171c
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Action.c
@@ -0,0 +1,365 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Action.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Action.c $
+//
+// 9 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 9/21/12 12:34p Premkumara
+// [TAG] EIP99022
+// [Category] Improvement
+// [Description] Tokenize the feature of flushing keyboard after every
+// key read
+// [Files] AMITSE.sdl, CommonHelper.c, TseAdvanced.c, Action.c
+//
+// 6 1/20/12 4:09a Rajashakerg
+// [TAG] EIP78929, 77467
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Control selection using Mouse is not user friendly.
+// [RootCause] Updating the buffer with mouse click information provided
+// by mouse driver is improper.
+// [Solution] Updated the mouse click information properly to the buffer
+// which is used by tse to do action.
+// [Files] Action.c, frame.c ListBox.c
+//
+// 5 11/20/11 7:38a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 4 2/04/11 11:12a Mallikarjunanv
+// AmiKey structure data is initialized with zero to aviod garbage values.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Action.c
+//
+// Description: This file contains code to handle different actions.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+///////////////////////////////////
+//VARIABLES DECLARATION
+//////////////////////////////////
+ACTION_METHODS gAction =
+{
+ ActionCreate,
+ ActionDestroy,
+ ActionGetAction,
+ ActionClearAction
+};
+///////////////////////////////////
+//FUNCTIONS DECLARATION
+//////////////////////////////////
+EFI_STATUS _ActionReadMouse(MOUSE_INFO *MouseInfo);
+BOOLEAN FlushKeysAfterRead(void);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionCreate
+//
+// Description: Function to create an action.
+//
+// Input: ACTION_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionCreate( ACTION_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ *object = EfiLibAllocateZeroPool( sizeof(ACTION_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ (*object)->Methods = &gAction;
+
+ _ActionInstallTimer( *object, ONE_SEC / 10 );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionDestroy
+//
+// Description: Function to destroy an action.
+//
+// Input: ACTION_DATA *action, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionDestroy( ACTION_DATA *action, BOOLEAN freeMem )
+{
+ TimerStopTimer( &action->TimerEvent );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&action );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionGetAction
+//
+// Description: Function to get an action.
+//
+// Input: ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionGetAction( ACTION_DATA *action )
+{
+ EFI_STATUS Status;
+ AMI_EFI_KEY_DATA AmiKey;
+ MOUSE_INFO MouseInfo;
+
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ return EFI_SUCCESS;
+
+ if ( action->TimerCount > 0 )
+ {
+ action->Input.Type = ACTION_TYPE_TIMER;
+ action->Input.Data.TimerCount = action->TimerCount;
+ action->TimerCount = 0;
+ return EFI_SUCCESS;
+ }
+
+ MemSet(&AmiKey, sizeof(AMI_EFI_KEY_DATA), 0); //makesure AmiKey does not have any garbage data
+ Status = ActionReadKey( &AmiKey, TIMER_ONE_SECOND / 20 );
+
+ if ( ! EFI_ERROR( Status ) )
+ { //If Key press return that first.
+ action->Input.Type = ACTION_TYPE_KEY;
+ MemCopy( &action->Input.Data.AmiKey, &AmiKey, sizeof(AMI_EFI_KEY_DATA) );
+ return Status;
+ }
+
+ //Read the Mouse Movement Co-ordinates and the Mouse Click
+ Status = _ActionReadMouse(&MouseInfo);
+ if ( ! EFI_ERROR( Status ) )
+ {
+ //EIP77467 & 78929: Not updating the action data for TSEMOUSE_RIGHT_DOWN and TSEMOUSE_RIGHT_UP
+ if((MouseInfo.ButtonStatus!=TSEMOUSE_NULL_CLICK)&&(MouseInfo.ButtonStatus != TSEMOUSE_RIGHT_DOWN)&&(MouseInfo.ButtonStatus != TSEMOUSE_RIGHT_UP))
+ {
+ action->Input.Type = ACTION_TYPE_MOUSE;
+ MemCopy( &action->Input.Data.MouseInfo, &MouseInfo, sizeof(MOUSE_INFO) );
+ return Status;
+ }
+ }
+
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionClearAction
+//
+// Description: Function to clear actions
+//
+// Input: ACTION_DATA *action
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionClearAction( ACTION_DATA *action )
+{
+ MemSet( &action->Input, sizeof(ACTION_INPUT), 0 );
+ return EFI_SUCCESS;
+}
+
+//
+// Internal functions
+//
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ActionReadKey
+//
+// Description: Function to read a key.
+//
+// Input: AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ActionReadKey( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout )
+{
+ EFI_STATUS Status;
+ EFI_STATUS StatusFlush;
+ EFI_EVENT EventList[2] = { NULL, NULL };
+ UINTN Count = 1, Index = 1;
+ AMI_EFI_KEY_DATA KeyFlush;
+
+ if ( Timeout )
+ {
+ EventList[0] = gST->ConIn->WaitForKey;
+
+ Status = TimerCreateTimer( &EventList[1], NULL, NULL, TimerRelative, Timeout, EFI_TPL_CALLBACK );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Count++;
+
+ gBS->WaitForEvent( Count, EventList, &Index );
+
+ TimerStopTimer( &EventList[1] );
+
+ if ( Index == 1 )
+ return EFI_NOT_READY;
+ }
+
+ Status = gST->ConIn->ReadKeyStroke( gST->ConIn, (EFI_INPUT_KEY*)pAmiKey);
+
+ if ( ! EFI_ERROR( Status ) && FlushKeysAfterRead())//EIP 99022 :check for the FLUSH_KEYS_AFTER_READ token before flushing the keys
+ {
+ do
+ {
+ StatusFlush = gST->ConIn->ReadKeyStroke( gST->ConIn, &KeyFlush.Key );
+ } while ( ! EFI_ERROR( StatusFlush ) );
+
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ActionTimer
+//
+// Description: Function action timer
+//
+// Input: EFI_EVENT Event, VOID *Context
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _ActionTimer( EFI_EVENT Event, VOID *Context )
+{
+ (*(UINT32 *)Context)++;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ActionInstallTimer
+//
+// Description: Function to install action timer
+//
+// Input: ACTION_DATA *action, UINT64 TriggerTime
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _ActionInstallTimer( ACTION_DATA *action, UINT64 TriggerTime )
+{
+ TimerCreateTimer( &action->TimerEvent, _ActionTimer, &action->TimerCount, TimerPeriodic, TriggerTime, EFI_TPL_CALLBACK );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ActionReadMouse
+//
+// Description: Function to get mouse action
+//
+// Input: MOUSE_INFO *MouseInfo
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+//Function Which gets the Mouse action
+EFI_STATUS _ActionReadMouse(MOUSE_INFO *MouseInfo)
+{
+ return MouseReadInfo(MouseInfo);
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/AddBootOption.c b/EDK/MiniSetup/TseLite/AddBootOption.c
new file mode 100644
index 0000000..331bf33
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/AddBootOption.c
@@ -0,0 +1,2548 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/AddBootOption.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 29 $
+//
+// $Date: 5/21/14 6:28p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/AddBootOption.c $
+//
+// 29 5/21/14 6:28p Arunsb
+// [TAG] EIP170152
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Add boot option failed to add the boot option
+// [Root Cause] If boot order is not there then TSE not allowing to add
+// boot options
+// [Solution] If boot order not presents also allowing to add boot option
+// [Files] AddBootOption.c
+//
+// 28 5/02/14 12:56p Premkumara
+// [TAG] EIP131549
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] After adding boot/driver options and Loading defaults causes
+// crashing issue.
+// [Root Cause] While discarding boot/driver options the boot order get
+// corrupted by copying extra data because of wrong size.
+// [Solution] Handled proper size to copy boot/driver options while
+// loading defaults
+// [Files] AddBootOption.c, Special.c
+//
+// 27 2/11/14 8:46p Arunsb
+//
+// 26 1/30/14 10:58a Arunsb
+// [TAG] EIP132762
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Adding UEFI bootable RHEL OS(Bootx64.efi) from UEFI REHL6.4
+// DVD disk causes setup hang
+// [Root Cause] The DevicePath is not created properly while adding boot
+// options
+// [Solution] Added '\' before file path name e.g \EFI\Boot\Bootx64.efi
+// instead of EFI\Boot\Bootx64.efi
+// [Files] AddBootOption.c
+//
+// 25 12/04/13 2:22p Premkumara
+// [TAG] EIP131549
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] After adding boot/driver options and Loading defaults causes
+// crashing issue.
+// [Root Cause] While discarding boot/driver options the boot order get
+// corrupted by copying extra data because of wrong size.
+// [Solution] Handled proper size to copy boot/driver options while
+// loading defaults
+// [Files] AddBootOption.c, Special.c
+//
+// 24 5/22/13 10:56a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c
+//
+// 23 5/22/13 10:51a Arunsb
+// EfiLibAllocateCopyPool leads to memory crash so changed it to
+// EfiLibAllocateZeroPool
+//
+// 22 4/16/13 12:59p Arunsb
+// [TAG] EIP113590
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Can't load default boot priorities if enable token
+// "SETUP_SUPPORT_ADD_BOOT_OPTION"
+// [RootCause] Size calculated wrongly
+// [Solution] Defaults will be formed only if size is 0, otherwise
+// current buffer will be overwritten.
+// [Files] AddBootOption.c
+//
+// 21 3/29/13 12:23p Premkumara
+// [TAG] EIP97611
+// [Category] New Feature
+// [Description] PrintScreen Support in TSE
+// [Files] AMITSE.sdl, CommonHelper.c, HotKeyBin.h, AddBootOption.c,
+// Page.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 20 12/01/12 6:46a Premkumara
+// [TAG] EIP105725
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup hangs on BBS Menu having string more than 200
+// characters
+// [RootCause] File path string is not handled properly
+// [Solution] Handled FilePath strings based on length of string and
+// allocate memory based on length dynamically
+// [Files] AddBootOption.c, AMIVfr.h
+//
+// 19 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 15 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 18 5/29/12 4:37a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 17 1/24/12 4:37a Arunsb
+// [TAG] EIP81581
+// [Category] Improvement
+// [Description] Default driver order support
+// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and
+// variable.c
+//
+// 16 1/19/12 10:49a Arunsb
+// [TAG] EIP79956
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Two boot option entries displayed with the single name
+// value
+// [RootCause] If defaults are loaded then boot order is trying to load
+// the improper boot order due to add boot option feature
+// [Solution] Boot order formed properly for add boot option case.
+// If no tsedefaultbootorder module present then gOptimalDefaults
+// [VARIABLE_ID_BOOT_ORDER] are saved properly in SaveAddDelBootOptions at
+// first time.
+// At first time optimal buffer is empty so it was filled with some junk
+// value so it is changed to fill the current variable list at first time
+// of saving with add boot option feature.
+// [Files] Addbootoption.c and callback.c
+//
+// 15 1/09/12 1:50a Arunsb
+// [TAG] EIP79952
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Add driver option displays select boot option as title
+// [RootCause] Title problem
+// [Solution] Title changes
+// [Files] Faketokens.c, amitsestr.uni, addbootoption.c,
+// uefi2.0\hiicallback.c and uefi21wapper.c
+//
+// 14 11/30/11 1:34p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 13 11/13/11 12:54p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 12 1/10/11 3:55p Mallikarjunanv
+// Updated to work with respect to EDK Libraries
+//
+// 11 1/07/11 12:09a Mallikarjunanv
+// [TAG] EIP51378
+// [Description] Global variable gHandleBuffer changed to
+// gSmplFileSysHndlBuf because of the conflict with HddSecurity module,
+// which already using gHandleBuffer.
+//
+// 10 1/06/11 11:14p Mallikarjunanv
+// [TAG] EIP41615
+// [Description] Updated the files with respect to File Browser support.
+//
+// 9 12/28/10 6:20p Mallikarjunanv
+// [TAG] EIP41615
+// [Description] Added the file browser support for the Add boot option
+// reated controls
+// [Files] AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c,
+// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c,
+// AddBootOption.c
+//
+// 8 3/26/10 5:25p Madhans
+// EIP 35562: Support To create Boot option in Capital letters.
+//
+// 7 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 11 2/25/10 8:04a Mallikarjunanv
+// Updated the memory corruptions in case of add delete boot options
+//
+// 10 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 1/28/10 1:10p Mallikarjunanv
+// //EIP:34119 - Fix to solve issues, if the boot option name is set with
+// max number of characters allowed.
+//
+// 8 1/09/10 7:12a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 1/04/10 10:40a Mallikarjunanv
+// EIPs 27161/29095 - Added support for reserved boot option names and
+// added support not to create empty boot option names
+//
+// 6 12/18/09 2:27p Madhans
+// EIP: 32350/32445 To fix the Add/Delete Boot option issues with TSE 2.0.
+//
+// 5 8/18/09 5:34p Madhans
+// EIP 25367: To resolve the build issue and to avoid redefinition.
+//
+// 4 8/13/09 7:39a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 9:39p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: AddBootOption.c
+//
+// Description: This file contains code to handle the Add boot option operation.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+///////////////////////////////////////////////////////
+/// MACRO DEFINITIONS
+///////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////
+/// VARIABLE DECLARATIONS
+///////////////////////////////////////////////////////
+
+typedef struct// EIP-41615: Start
+{
+ UINT64 Type;
+ UINTN Size;
+ CHAR16 *Name;
+ STRING_REF Token;
+} FILE_TYPE;
+EFI_FILE_PROTOCOL *gFs = NULL;
+EFI_GUID gSimpleFileSystemGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
+AMI_POST_MANAGER_PROTOCOL *mPostMgr = NULL;
+static EFI_HANDLE *gSmplFileSysHndlBuf = NULL; //EIP:51378 Global variable gHandleBuffer changed to gSmplFileSysHndlBuf because of the conflict with HddSecurity module, which already using gHandleBuffer.
+BOOLEAN gValidOption = FALSE;
+UINT16 gSelIdx = 0;/// EIP-41615: End
+UINTN gDelOptionCount;
+BOOT_DATA *gDelBootData;
+UINTN gFsCount;
+FS_DATA *gFsList;
+UINTN gDriverDelOptionCount; //EIP70421 & 70422 Support for driver order
+BOOT_DATA *gDelDriverData; //EIP70421 & 70422 Support for driver order
+///////////////////////////////////////////////////////
+/// EXTERN VARIABLES
+///////////////////////////////////////////////////////
+extern UINTN gDelBootOptionReserved;
+extern UINTN gAddBootOptionEmpty;
+extern UINTN gAddDriverOptionEmpty;
+///////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS
+///////////////////////////////////////////////////////
+EFI_DEVICE_PATH_PROTOCOL *_BootBuildFileDevicePath( UINT32 *index, CHAR16 *fileName );
+VOID BbsStrnCpy ( CHAR16 *Dst, CHAR16 *Src, UINTN Length );
+VOID _GetFsLists (VOID);
+UINT16 *_DevicePathToStr(EFI_DEVICE_PATH_PROTOCOL *Path);
+VOID FixHiddenOptions (BOOLEAN, UINT16 **, UINTN);
+UINT16 _BootSetBootNowCount(VOID);
+EFI_STATUS ShowPostMsgBox(IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection);//EIP:41615
+EFI_STATUS FileBrowserLaunchFilePath(UINT32 Variable);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseUpdateAddDeleteBootVar
+//
+// Description: Function to update add and delete boot variables
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void TseUpdateAddDeleteBootVar(void)
+{
+ UINT16 u16DelOption;
+ EFI_GUID DelBootOptionGuid = DEL_BOOT_OPTION_GUID;
+ EFI_GUID AddBootOptionGuid = ADD_BOOT_OPTION_GUID;
+ NEW_BOOT_OPTION AddBootOption;
+
+ //Set del boot option var
+ u16DelOption = DISABLED_BOOT_OPTION;
+ VarSetNvramName( L"DelBootOption", &DelBootOptionGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &u16DelOption, sizeof(UINT16) );
+
+ //Set AddBootOption variable
+ _GetFsLists ();
+ MemSet(&AddBootOption, sizeof(NEW_BOOT_OPTION),0);
+ AddBootOption.FsCount = (UINT16)gFsCount;
+ VarSetNvramName( L"AddBootOption", &AddBootOptionGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &AddBootOption, sizeof(NEW_BOOT_OPTION) );
+
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseUpdateAddDeleteDriverVar
+//
+// Description: Function to update add and delete driver variables
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void TseUpdateAddDeleteDriverVar (void)
+{
+ UINT16 u16DelOption;
+ EFI_GUID DelDriverOptionGuid = DEL_DRIVER_OPTION_GUID;
+ EFI_GUID AddDriverOptionGuid = ADD_DRIVER_OPTION_GUID;
+ NEW_DRIVER_OPTION AddDriverOption;
+
+ //Set del driver option var
+ u16DelOption = DISABLED_DRIVER_OPTION;
+ VarSetNvramName (L"DelDriverOption", &DelDriverOptionGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &u16DelOption, sizeof (UINT16));
+
+ //Set AddDriverOption variable
+ _GetFsLists();
+ MemSet (&AddDriverOption, sizeof (NEW_DRIVER_OPTION), 0);
+ AddDriverOption.FsCount = (UINT16)gFsCount;
+ VarSetNvramName (L"AddDriverOption", &AddDriverOptionGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &AddDriverOption, sizeof (NEW_DRIVER_OPTION));
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _GetFsLists
+//
+// Description: function to get the file system details
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _GetFsLists (VOID)
+{
+ UINTN Count,i;
+ EFI_HANDLE *HandleBuffer;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ CHAR16 *Str;
+ EFI_STATUS Status;
+
+ //Find all handles supporting Simple File Sys Protocol
+ if (0 == gFsCount) //EIP70421 Support for driver order; No need of calling continuously boot then driver, one call is enough to set gFsCount
+ {
+ Status = gBS->LocateHandleBuffer(
+ ByProtocol,
+ &gEfiSimpleFileSystemProtocolGuid,
+ NULL,
+ &Count,
+ &HandleBuffer
+ );
+ if(EFI_ERROR(Status))
+ return;
+
+ for(i=0;i<Count;i++)
+ {
+ DevicePath = NULL;
+ Status = gBS->OpenProtocol (
+ HandleBuffer[i],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &DevicePath,
+ NULL,
+ HandleBuffer[i],
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if(EFI_ERROR(Status))
+ continue;
+ if(!DevicePath)
+ continue;
+ Str = NULL;
+ Str = _DevicePathToStr(DevicePath);
+
+ gFsList = MemReallocateZeroPool(gFsList, gFsCount * sizeof(FS_DATA), (gFsCount + 1) * sizeof(FS_DATA));
+ gFsList[gFsCount].FsId = Str ? Str : StrDup(L"Unknown");
+ gFsList[gFsCount].FsPath = DevicePath;
+
+ gFsCount++;
+ }
+ }
+}
+
+static UINT16 DefaultDevicePath[]=L"DevicePath(Type %x, SubType %x)";
+
+static UINT16 *HWDP[] = {
+ L"PCI(%X|%X)\\", //HW_PCI_DP
+ L"Pccard(Socket %x)\\", //HW_PCCARD_DP
+ L"VenHw(%g)\\" //HW_VENDOR_DP
+};
+
+/*Uncomment if ACPI details are necessary
+static UINT16 *ACPIDP[] = {
+ L"Acpi(%x, %x)\\" //ACPI_DP
+};*/
+
+static UINT16 *MSGDP[] = {
+ L"ATA(%s,%s)\\", //MSG_ATAPI_DP
+ L"SCSI(%x,%x)\\", //MSG_SCSI_DP
+ L"VenMsg(%g)\\" //MSG_VENDOR_DP
+};
+
+static UINT16 *MEDIADP[] = {
+ L"CDROM(Entry%x)\\", //MEDIA_CDROM_DP
+ L"VenMedia(%g)\\", //MEDIA_VENDOR_DP
+ L"%g\\" //MEDIA_FILEPATH_DP
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HWToStr
+//
+// Description: Convert Device Path of type to string.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+// OUT UINT16 *Str - String form of device path.
+//
+// Output:
+// int - number of characters not including \0 or -1 if error.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _HWToStr(
+ EFI_DEVICE_PATH_PROTOCOL *Path,
+ UINT16 *Str
+ )
+{
+ switch(Path->SubType)
+ {
+ case HW_PCI_DP:
+ return SPrint(Str,0,HWDP[0],((PCI_DEVICE_PATH*)Path)->Device,((PCI_DEVICE_PATH*)Path)->Function);
+ case HW_PCCARD_DP:
+ return SPrint(Str,0,HWDP[1],((AMITSE_PCCARD_DEVICE_PATH*)Path)->FunctionNumber);
+ case HW_VENDOR_DP:
+ return SPrint(Str,0,HWDP[2],&((VENDOR_DEVICE_PATH*)Path)->Guid);
+ }
+
+ return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ACPIToStr
+//
+// Description: Convert Device Path of type to string.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+// OUT UINT16 *Str - String form of device path.
+//
+// Output:
+// int - number of characters not including \0 or -1 if error.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+/*
+Uncomment below code if ACPI details are necessary.
+CAUTION: If ACPI details are included then the string becomes too big
+to display
+*/
+/*
+UINTN ACPIToStr(
+ EFI_DEVICE_PATH_PROTOCOL *Path,
+ UINT16 *Str
+ )
+{
+ switch(Path->SubType)
+ {
+ case ACPI_DP:
+ return SPrint(Str,0,ACPIDP[0], ((ACPI_HID_DEVICE_PATH*)Path)->HID, ((ACPI_HID_DEVICE_PATH*)Path)->UID);
+ }
+ return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType);
+}
+*/
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MSGToStr
+//
+// Description: Convert Device Path of type to string.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+// OUT UINT16 *Str - String form of device path.
+//
+// Output:
+// int - number of characters not including \0 or -1 if error.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _MSGToStr(
+ EFI_DEVICE_PATH_PROTOCOL *Path,
+ UINT16 *Str
+ )
+{
+ switch(Path->SubType)
+ {
+ case MSG_ATAPI_DP:
+ return SPrint(Str,0,MSGDP[0],
+ ((ATAPI_DEVICE_PATH*)Path)->PrimarySecondary ? L"Sec" : L"Pri",
+ ((ATAPI_DEVICE_PATH*)Path)->SlaveMaster ? L"Sl" :L"Ma");
+ case MSG_SCSI_DP:
+ return SPrint(Str,0,MSGDP[1], ((SCSI_DEVICE_PATH*)Path)->Pun, ((SCSI_DEVICE_PATH*)Path)->Lun);
+ case MSG_VENDOR_DP:
+ return SPrint(Str,0,MSGDP[2], ((VENDOR_DEVICE_PATH*)Path)->Guid);
+ case MSG_USB_DP:
+ return SPrint(Str,0,L"USB(%x,%x)\\",
+ ((USB_DEVICE_PATH*)Path)->ParentPortNumber,((USB_DEVICE_PATH*)Path)->InterfaceNumber);
+
+ }
+ return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MEDIAToStr
+//
+// Description: Convert Device Path of type to string.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+// OUT UINT16 *Str - String form of device path.
+//
+// Output:
+// int - number of characters not including \0 or -1 if error.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _MEDIAToStr(
+ EFI_DEVICE_PATH_PROTOCOL *Path,
+ UINT16 *Str
+ )
+{
+ switch(Path->SubType)
+ {
+ case MEDIA_HARDDRIVE_DP:
+ {
+ HARDDRIVE_DEVICE_PATH *Hd = (HARDDRIVE_DEVICE_PATH *)Path;
+ switch(Hd->SignatureType)
+ {
+ case SIGNATURE_TYPE_MBR:
+ return SPrint(Str,0,L"HD(Part%d,Sig%08X)", Hd->PartitionNumber, *((UINT32 *)(&(Hd->Signature[0]))));
+ case SIGNATURE_TYPE_GUID:
+ return SPrint(Str,0, L"HD(Part%d,Sig%g)", Hd->PartitionNumber, (EFI_GUID *) &(Hd->Signature[0]));
+ default:
+ return SPrint(Str,0,L"HD(Part%d,MBRType=%02x,SigType=%02x)",
+ Hd->PartitionNumber,
+ Hd->MBRType,
+ Hd->SignatureType
+ );
+ }
+ }
+ case MEDIA_CDROM_DP:
+ return SPrint(Str,0,MEDIADP[0], ((CDROM_DEVICE_PATH*)Path)->BootEntry);
+ case MEDIA_VENDOR_DP:
+ return SPrint(Str,0,MEDIADP[1], ((VENDOR_DEVICE_PATH*)Path)->Guid);
+ case MEDIA_FILEPATH_DP:
+ return SPrint(Str,0,MEDIADP[2], &((AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)Path)->FvFileName);
+ }
+ return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _UnknownToStr
+//
+// Description: Convert Device Path of type to string.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+// OUT UINT16 *Str - String form of device path.
+//
+// Output:
+// int - number of characters not including \0 or -1 if error.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _UnknownToStr(
+ EFI_DEVICE_PATH_PROTOCOL *Path,
+ UINT16 *Str
+ )
+{
+ return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType);
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DevicePathToStr
+//
+// Description: Convert Device Path of type to string. Str is allocated by
+// this routine. It must be freed by the caller.
+//
+// Input:
+// IN EFI_DEVICE_PATH_PROTOCOL *Path - Device Path
+//
+//
+// Output:
+// OUT UINT16 *Str - String form of device path.
+//
+// Notes:
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 *_DevicePathToStr(EFI_DEVICE_PATH_PROTOCOL *Path)
+{
+ CHAR16 Buffer[512];
+ CHAR16 *p = Buffer, *Str = NULL;
+ UINTN Count = 0;
+ UINTN Length;
+
+ MemSet(Buffer,sizeof(Buffer),0);
+ for(;;)
+ {
+ switch(Path->Type)
+ {
+ case HARDWARE_DEVICE_PATH:
+ Count = _HWToStr(Path, p);
+ break;
+ case ACPI_DEVICE_PATH:
+/*
+Uncomment below code if ACPI details are necessary.
+CAUTION: If ACPI details are included then the string becomes too big
+to display
+*/
+/*
+ Count = SPrint(p,0,L"Acpi\\");
+ ACPIToStr(Path, p);
+*/
+ break;
+ case MESSAGING_DEVICE_PATH:
+ Count = _MSGToStr(Path, p);
+ break;
+ case MEDIA_DEVICE_PATH:
+ Count = _MEDIAToStr(Path, p);
+ break;
+ case END_DEVICE_PATH_TYPE:
+ Count = 0;
+ break;
+ case END_ENTIRE_DEVICE_PATH_SUBTYPE:
+ *p = L'|';
+ *(p+1) = L'\0';
+ Count = 1;
+ break;
+ default:
+ Count = _UnknownToStr(Path, p);
+ }
+
+ p += EfiStrLen(p);
+
+ if (Count == -1) return NULL;
+ if (IsDevicePathEnd(Path)) break;
+
+ Path = NextDevicePathNode(Path);
+ }
+
+ Length = (UINTN)p - (UINTN)Buffer;
+
+ Str = (UINT16 *)EfiLibAllocateZeroPool(Length+sizeof(UINT16));
+
+ MemCopy(Str, Buffer, Length);
+
+ return Str;
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------------------------
+// Procedure: _DisableRestorePrevOptions
+//
+// Description: Function to make the boot/driver option as disable in bootorder/driverorder
+// if it is inactive and non hidden
+//
+//
+// Input: BOOLEAN , UINT16 **, UINTN
+//
+// Output: VOID
+//
+//-------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DisableRestorePrevOptions (BOOLEAN Option, UINT16 **Order, UINTN OptionCount)
+{
+ UINTN iIndex = 0;
+ BOOT_DATA *pBootData;
+
+ if (0 == OptionCount)
+ {
+ return;
+ }
+ for (iIndex = 0; iIndex < OptionCount; iIndex ++)
+ {
+ if (BOOT_ORDER_OPTION == Option)
+ {
+ pBootData = BootGetBootData ((*Order) [iIndex]);
+ }
+ else
+ {
+ pBootData = DriverGetDriverData ((*Order) [iIndex]);
+ }
+ if (pBootData)
+ {
+ if ( (!(pBootData->Active & LOAD_OPTION_ACTIVE)) && (!(pBootData->Active & LOAD_OPTION_HIDDEN)) )
+ {
+ (*Order) [iIndex] = DISABLED_BOOT_OPTION;
+ }
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootAddBootOption
+//
+// Description: Function to add boot option
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BootAddBootOption( VOID )
+{
+ UINTN i,size;
+ UINT16 u16Option;
+ NEW_BOOT_OPTION *newBoot = NULL, *tmpPtr;
+ CHAR16 *fileName;
+ UINT32 index;
+ EFI_DEVICE_PATH_PROTOCOL *devicePath;
+ UINT16 *NewBootOrder = NULL, *CurrBootOrder = NULL;
+ UINT16 BootCountVal;
+ CHAR16 *BootNameBuf = NULL; //EIP:34119
+ EFI_STATUS Status;
+ //Get input
+ size = 0;
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &mPostMgr);
+ if(Status != EFI_SUCCESS)
+ return;
+ newBoot = VarGetVariable( VARIABLE_ID_ADD_BOOT_OPTION, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == newBoot){
+ return;
+ }
+
+//EIP:34119 - Start
+ //Fix EIP:29095 - not to create boot option with out a name
+ if (( EfiStrLen( newBoot->Path ) == 0 ) || ( EfiStrLen(newBoot->Label) == 0 ))
+ {
+ // CallbackShowMessageBox( (UINTN)gAddBootOptionEmpty, MSGBOX_TYPE_OK );
+
+ mPostMgr->DisplayMsgBox( L"WARNING", L"Please set Boot Option Name and File Path", MSGBOX_TYPE_OK,NULL);
+ return;
+ }
+ BootNameBuf = EfiLibAllocateZeroPool( sizeof(newBoot->Label)+2 );
+ BbsStrnCpy( BootNameBuf, newBoot->Label, (sizeof(newBoot->Label))/2 );
+//EIP:34119 - End
+
+ // cleanup old data
+ tmpPtr = EfiLibAllocateZeroPool( size );
+ tmpPtr->FsCount = (UINT16)gFsCount;
+ VarSetValue( VARIABLE_ID_ADD_BOOT_OPTION, 0, size, tmpPtr );
+ MemFreePointer( (VOID **)&tmpPtr );
+
+ fileName = newBoot->Path;
+
+ index = newBoot->SelFs;
+
+ devicePath = _BootBuildFileDevicePath( &index, fileName );
+ if ( devicePath != NULL )
+ {
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevPath, *HddMediaPath;
+
+ //Find a free option number
+ for ( u16Option = 0; u16Option < MAX_BOOT_OPTIONS; u16Option++ )
+ {
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(gBootData[i].Option == u16Option)
+ break;
+ }
+ if(i<gBootOptionCount)
+ continue;
+ for(i=0;i<gDelOptionCount;i++)
+ {
+ if(gDelBootData[i].Option == u16Option)
+ break;
+ }
+ if(i<gDelOptionCount)
+ continue;
+
+ break;//The desired option number is in u16Option
+ }
+
+ if ( u16Option == MAX_BOOT_OPTIONS ) //Not possible
+ return;
+
+ gBootData = MemReallocateZeroPool(gBootData, gBootOptionCount * sizeof(BOOT_DATA), (gBootOptionCount + 1) * sizeof(BOOT_DATA) );
+
+ gBootData[gBootOptionCount].Option = u16Option;
+ gBootData[gBootOptionCount].Active |= LOAD_OPTION_ACTIVE;
+//EIP:34119 - Fix to solve issues, if the boot option name is set with max number of characters allowed.
+ //gBootData[gBootOptionCount].Name = StrDup( newBoot->Label );
+ gBootData[gBootOptionCount].Name = BootNameBuf;
+//EIP:34119 - End
+
+ //For a hard drive start the dev path from the partition
+ for( TmpDevPath = devicePath;
+ !IsDevicePathEndType(TmpDevPath);
+ TmpDevPath=NextDevicePathNode(TmpDevPath)
+ )
+ {
+ if(TmpDevPath->Type==MEDIA_DEVICE_PATH && TmpDevPath->SubType==MEDIA_HARDDRIVE_DP)
+ {
+ HddMediaPath = EfiLibAllocateZeroPool(EfiDevicePathSize(TmpDevPath));
+ MemCopy(HddMediaPath, TmpDevPath, EfiDevicePathSize(TmpDevPath));
+ MemFreePointer((VOID **)&devicePath);
+ devicePath = HddMediaPath;
+ break;
+ }
+ }
+ gBootData[gBootOptionCount].DevicePath = devicePath;
+ gBootData[gBootOptionCount].bNewOption = TRUE;
+
+ size = 0;
+ CurrBootOrder = VarGetVariable(VARIABLE_ID_BOOT_ORDER, &size);
+ //EIP-75352 Suppress the warnings from static code analyzer
+/* if (NULL == CurrBootOrder){ //If file system available and no boot option presents then add boot option always fails so commenting it.
+ return;
+ }*/
+ NewBootOrder = EfiLibAllocateZeroPool((gBootOptionCount+1) * sizeof(UINT16));
+
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(DISABLED_BOOT_OPTION == CurrBootOrder[i])
+ break;
+ NewBootOrder[i] = CurrBootOrder[i];
+ }
+ if (i < gBootOptionCount) //Preserve the hidden options at last
+ {
+ MemCpy (NewBootOrder+i+1, CurrBootOrder+i, (gBootOptionCount-i)*2);
+ }
+ NewBootOrder [i] = u16Option;
+ //i ++;
+ MemFreePointer ((VOID **) &CurrBootOrder);
+ gBootOptionCount ++;
+ MemFreePointer ((VOID **)&newBoot);
+
+ //Update boot manager vars in memory
+ //1. TSE Boot order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer);
+ if (gLoadOptionHidden) //Move hidden options to last
+ {
+ FixHiddenOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount);
+ }
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer = (UINT8 *)NewBootOrder;
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Size = gBootOptionCount * sizeof(UINT16);
+
+ //2. BootManager
+ BootCountVal = (UINT16)gBootOptionCount;
+ VarSetValue(VARIABLE_ID_BOOT_MANAGER, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+
+ //3. Set Boot now count
+ if(gShowAllBbsDev)
+ BootCountVal = _BootSetBootNowCount();
+
+ Status = VarSetValue(VARIABLE_ID_BOOT_NOW, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+ if(Status == EFI_SUCCESS)
+ mPostMgr->DisplayMsgBox( L"SUCCESS", L"Boot Option Created Successfully", MSGBOX_TYPE_OK,NULL);
+ }
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DriverAddDriverOption
+//
+// Description: Function to add driver options
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DriverAddDriverOption(VOID)
+{
+ UINTN i,size;
+ UINT16 u16Option;
+ NEW_DRIVER_OPTION *newDriver = NULL, *tmpPtr;
+ CHAR16 *fileName;
+ UINT32 index;
+ EFI_DEVICE_PATH_PROTOCOL *devicePath;
+ UINT16 *NewDriverOrder = NULL, *CurrDriverOrder = NULL;
+ UINT16 DriverCountVal;
+ CHAR16 *BootNameBuf = NULL;
+ EFI_STATUS Status;
+ //Get input
+ size = 0;
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &mPostMgr);
+ if(Status != EFI_SUCCESS)
+ return;
+ newDriver = VarGetVariable( VARIABLE_ID_ADD_DRIVER_OPTION, &size );
+ if (( EfiStrLen (newDriver->DriverPath) == 0 ) || (EfiStrLen (newDriver->Label) == 0))
+ {
+ //CallbackShowMessageBox( (UINTN)gAddDriverOptionEmpty, MSGBOX_TYPE_OK );
+
+ mPostMgr->DisplayMsgBox( L"WARNING", L"Please set Driver Option Name and File Path", MSGBOX_TYPE_OK,NULL);
+ return;
+ }
+
+ BootNameBuf = EfiLibAllocateZeroPool( sizeof(newDriver->Label)+2 );
+ BbsStrnCpy( BootNameBuf, newDriver->Label, (sizeof(newDriver->Label))/2 );
+
+ // cleanup old data
+ tmpPtr = EfiLibAllocateZeroPool( size );
+ tmpPtr->FsCount = (UINT16)gFsCount;
+ VarSetValue( VARIABLE_ID_ADD_DRIVER_OPTION, 0, size, tmpPtr );
+ MemFreePointer( (VOID **)&tmpPtr );
+
+ fileName = newDriver->DriverPath;
+
+ index = newDriver->SelFs;
+
+ devicePath = _BootBuildFileDevicePath( &index, fileName );
+
+ if ( devicePath != NULL )
+ {
+// EFI_DEVICE_PATH_PROTOCOL *TmpDevPath, *HddMediaPath;
+
+ //Find a free option number
+ for ( u16Option = 0; u16Option < MAX_BOOT_OPTIONS; u16Option++ )
+ {
+ for(i=0;i<gDriverOptionCount;i++)
+ {
+ if(gDriverData[i].Option == u16Option)
+ break;
+ }
+ if(i<gDriverOptionCount)
+ continue;
+ for(i=0;i<gDriverDelOptionCount;i++)
+ {
+ if(gDelDriverData[i].Option == u16Option)
+ break;
+ }
+ if(i<gDriverDelOptionCount)
+ continue;
+
+ break;//The desired option number is in u16Option
+ }
+
+ if ( u16Option == MAX_BOOT_OPTIONS ) //Not possible
+ return;
+
+ gDriverData = MemReallocateZeroPool(gDriverData, gDriverOptionCount * sizeof(BOOT_DATA), (gDriverOptionCount + 1) * sizeof(BOOT_DATA) );
+
+ gDriverData[gDriverOptionCount].Option = u16Option;
+ gDriverData[gDriverOptionCount].Active |= LOAD_OPTION_ACTIVE;
+//EIP:34119 - Fix to solve issues, if the boot option name is set with max number of characters allowed.
+ //gBootData[gBootOptionCount].Name = StrDup( newDriver->Label );
+ gDriverData[gDriverOptionCount].Name = BootNameBuf;
+//EIP:34119 - End
+
+ /*
+ //TSE will append hard drive device path at front if it is MEDIA_DEVICE_PATH but core needs fullpath so commented below
+ //For a hard drive start the dev path from the partition
+ for( TmpDevPath = devicePath;
+ !IsDevicePathEndType(TmpDevPath);
+ TmpDevPath=NextDevicePathNode(TmpDevPath)
+ )
+ {
+ if(TmpDevPath->Type==MEDIA_DEVICE_PATH && TmpDevPath->SubType==MEDIA_HARDDRIVE_DP)
+ {
+ HddMediaPath = EfiLibAllocateZeroPool(EfiDevicePathSize(TmpDevPath));
+ MemCopy(HddMediaPath, TmpDevPath, EfiDevicePathSize(TmpDevPath));
+ MemFreePointer((VOID **)&devicePath);
+ devicePath = HddMediaPath;
+ break;
+ }
+ }*/
+
+ gDriverData[gDriverOptionCount].DevicePath = devicePath;
+ gDriverData[gDriverOptionCount].bNewOption = TRUE;
+
+ size = 0;
+ CurrDriverOrder = VarGetVariable(VARIABLE_ID_DRIVER_ORDER, &size);
+ NewDriverOrder = EfiLibAllocateZeroPool((gDriverOptionCount+1) * sizeof(UINT16));
+
+ for(i=0;i<gDriverOptionCount;i++)
+ {
+ if(DISABLED_DRIVER_OPTION == CurrDriverOrder[i])
+ break;
+ NewDriverOrder[i] = CurrDriverOrder[i];
+ }
+ if (i < gDriverOptionCount) //Preserve the hidden options at last
+ {
+ MemCpy (NewDriverOrder+i+1, CurrDriverOrder+i, (gDriverOptionCount-i)*2);
+ }
+
+ NewDriverOrder[i] = u16Option;
+ //i++;
+
+ MemFreePointer((VOID **) &CurrDriverOrder);
+
+ gDriverOptionCount ++;
+
+ MemFreePointer( (VOID **)&newDriver );
+
+ //Update boot manager vars in memory
+ //1. TSE driver order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer);
+ if (gLoadOptionHidden) //Move the hidden options to last
+ {
+ FixHiddenOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount);
+ }
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer = (UINT8 *)NewDriverOrder;
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Size = gDriverOptionCount * sizeof(UINT16);
+
+ //2. DriverManager
+ DriverCountVal = (UINT16)gDriverOptionCount;
+ Status = VarSetValue(VARIABLE_ID_DRIVER_MANAGER, 0, sizeof(UINT16), (VOID *)(&DriverCountVal));
+ if(Status == EFI_SUCCESS)
+ mPostMgr->DisplayMsgBox( L"SUCCESS", L"Driver Option Created Successfully", MSGBOX_TYPE_OK,NULL);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootDelBootOption
+//
+// Description: Function to handle the del boot option
+//
+// Input: UINT16 index
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BootDelBootOption( UINT16 index )
+{
+ UINTN i,j,k, size;
+ BOOT_DATA *pBootData = NULL;
+ UINT16 BootCountVal;
+ UINT16 *NewBootOrder = NULL, *CurrBootOrder = NULL;
+ EFI_STATUS Status=EFI_UNSUPPORTED;
+ VOID * UnicodeInterface;
+ CHAR16 *ResStr = NULL;
+ CHAR16 *TmpStr = NULL;
+
+ // If it BBS device we should not delete it.
+ // FIX......to check for the correct Boot option.
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &mPostMgr);
+ if(Status != EFI_SUCCESS)
+ return;
+ for(i=0; i<gBootOptionCount; i++)
+ {
+ if(index == gBootData[i].Option)
+ {
+ if(gBootData[i].DevicePath->Type == BBS_DEVICE_PATH && gBootData[i].DevicePath->SubType == BBS_BBS_DP)
+ return;
+
+ ///Fix: Eip-27161 - not to allow Reserved boot options to delete
+ if( ( IsReservedBootOptionNamesEnable() ) &&
+ ( gBootData[i].Name ) )
+ {
+ ResStr = CONVERT_TO_WSTRING(RESERVED_ADD_DEL_BOOT_OPTION_NAME);
+ TmpStr = EfiLibAllocateZeroPool( EfiStrLen(ResStr)+1 );
+ BbsStrnCpy(TmpStr, gBootData[i].Name, (EfiStrLen(ResStr)+1) );
+ TmpStr[EfiStrLen(ResStr)]= L'\0';
+ Status = InitUnicodeCollectionProtocol(&UnicodeInterface);
+ if(!EFI_ERROR(Status)) {
+ if( StringColl( UnicodeInterface, TmpStr, ResStr) == 0 )
+ {
+ //CallbackShowMessageBox( (UINTN)gDelBootOptionReserved, MSGBOX_TYPE_OK );
+ mPostMgr->DisplayMsgBox( L"WARNING", L"Reserved Boot Option, can not be Deleted", MSGBOX_TYPE_OK,NULL);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ //Remove option from gBootData and add to gDelBootData
+ //Remove option from BootOrder
+ if(gBootOptionCount - 1)
+ {
+ pBootData = EfiLibAllocateZeroPool(sizeof(BOOT_DATA) * (gBootOptionCount - 1));
+ NewBootOrder = EfiLibAllocateZeroPool(sizeof(UINT16) * (gBootOptionCount - 1));
+ }
+
+ size = 0;
+ CurrBootOrder = VarGetVariable(VARIABLE_ID_BOOT_ORDER, &size);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == CurrBootOrder){
+ return;
+ }
+
+ gDelBootData = MemReallocateZeroPool(gDelBootData, sizeof(BOOT_DATA) * gDelOptionCount, sizeof(BOOT_DATA) * (gDelOptionCount + 1));
+
+ for(i=0,j=0,k=0; i<gBootOptionCount; i++)
+ {
+ if(index == gBootData[i].Option)
+ {
+ MemCopy(gDelBootData + gDelOptionCount, gBootData + i, sizeof(BOOT_DATA));
+ }
+ else
+ {
+ MemCopy(pBootData + j, gBootData + i, sizeof(BOOT_DATA));
+ j++;
+ }
+
+ if(index != CurrBootOrder[i])
+ {
+ if(k<(gBootOptionCount-1))
+ {
+ NewBootOrder[k] = CurrBootOrder[i];
+ k++;
+ }
+ }
+ }
+
+ gDelOptionCount++;
+ gBootOptionCount--;
+
+ MemFreePointer((VOID **)&gBootData);
+ gBootData = pBootData;
+
+ MemFreePointer((VOID **)&CurrBootOrder);
+
+ //Update boot manager vars in memory
+ //1. TSE Boot order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer);
+ if (gLoadOptionHidden) //Move the hidden options to last
+ {
+ FixHiddenOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount);
+ }
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer = (UINT8 *)NewBootOrder;
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Size = gBootOptionCount * sizeof(UINT16);
+
+ //2. BootManager
+ BootCountVal = (UINT16)gBootOptionCount;
+ VarSetValue(VARIABLE_ID_BOOT_MANAGER,0,sizeof(UINT16),(VOID *)(&BootCountVal));
+
+ //3. Set Boot now count
+ if(gShowAllBbsDev)
+ BootCountVal = _BootSetBootNowCount();
+
+ Status = VarSetValue(VARIABLE_ID_BOOT_NOW,0,sizeof(UINT16),(VOID *)(&BootCountVal));
+ if(EFI_SUCCESS == Status)
+ mPostMgr->DisplayMsgBox( L"SUCCESS", L"Boot Option Deleted Successfully", MSGBOX_TYPE_OK,NULL);
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DriverDelDriverOption
+//
+// Description: Function to handle the del Driver option
+//
+// Input: UINT16 index
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DriverDelDriverOption( UINT16 index )
+{
+ UINTN i,j,k, size;
+ BOOT_DATA *pDriverData = NULL;
+ UINT16 DriverCountVal;
+ UINT16 *NewDriverOrder = NULL, *CurrDriverOrder = NULL;
+ EFI_STATUS Status=EFI_UNSUPPORTED;
+// VOID * UnicodeInterface;
+ CHAR16 *ResStr = NULL;
+ CHAR16 *TmpStr = NULL;
+
+ if ((NULL == gDriverData) || (0 == gDriverOptionCount))
+ return;
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &mPostMgr);
+ if(Status != EFI_SUCCESS)
+ return;
+ for(i=0; i<gDriverOptionCount; i++)
+ {
+ if(index == gDriverData[i].Option)
+ {
+ if(gDriverData[i].DevicePath->Type == BBS_DEVICE_PATH && gDriverData[i].DevicePath->SubType == BBS_BBS_DP)
+ return;
+ break;
+ }
+ }
+
+ //Remove option from gDriverData and add to gDelDriverData
+ //Remove option from DriverOrder
+ if(gDriverOptionCount - 1)
+ {
+ pDriverData = EfiLibAllocateZeroPool(sizeof(BOOT_DATA) * (gDriverOptionCount - 1));
+ NewDriverOrder = EfiLibAllocateZeroPool(sizeof(UINT16) * (gDriverOptionCount - 1));
+ }
+
+ size = 0;
+ CurrDriverOrder = VarGetVariable(VARIABLE_ID_DRIVER_ORDER, &size);
+
+ gDelDriverData = MemReallocateZeroPool(gDelDriverData, sizeof(BOOT_DATA) * gDriverDelOptionCount, sizeof(BOOT_DATA) * (gDriverDelOptionCount + 1));
+
+ for(i=0,j=0,k=0; i<gDriverOptionCount; i++)
+ {
+ if(index == gDriverData[i].Option)
+ {
+ MemCopy(gDelDriverData + gDriverDelOptionCount, gDriverData + i, sizeof(BOOT_DATA));
+ }
+ else
+ {
+ MemCopy(pDriverData + j, gDriverData + i, sizeof(BOOT_DATA));
+ j++;
+ }
+
+ if(index != CurrDriverOrder[i])
+ {
+ if(k<(gDriverOptionCount-1))
+ {
+ NewDriverOrder[k] = CurrDriverOrder[i];
+ k++;
+ }
+ }
+ }
+
+ gDriverDelOptionCount++;
+ gDriverOptionCount--;
+
+ MemFreePointer((VOID **)&gDriverData);
+ gDriverData = pDriverData;
+
+ MemFreePointer((VOID **)&CurrDriverOrder);
+
+ //Update boot manager vars in memory
+ //1. TSE Driver Order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer);
+ if (gLoadOptionHidden)
+ {
+ FixHiddenOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount);
+ }
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer = (UINT8 *)NewDriverOrder;
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Size = gDriverOptionCount * sizeof(UINT16);
+
+ //2. DriverManager
+ DriverCountVal = (UINT16)gDriverOptionCount;
+ Status = VarSetValue(VARIABLE_ID_DRIVER_MANAGER,0,sizeof(UINT16),(VOID *)(&DriverCountVal));
+ if(EFI_SUCCESS == Status)
+ mPostMgr->DisplayMsgBox( L"SUCCESS", L"Driver Deleted Successfully", MSGBOX_TYPE_OK,NULL);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DiscardAddDelBootOptions
+//
+// Description: Function to discarding the add/del boot option
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DiscardAddDelBootOptions(VOID)
+{
+ UINTN count,i,j;
+ BOOT_DATA *pBootData;
+ UINT16 *AddOptionList=NULL,*DelOptionList=NULL;
+ UINTN AddOptionListCount=0, DelOptionListCount=0;
+ UINT16 *NewBootOrder = NULL, *CurrBootOrder = NULL;
+ UINTN size, tempsize = 0;
+
+ //find no. of boot options
+ count = 0;
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(!gBootData[i].bNewOption)
+ count++;
+ else
+ AddOptionListCount++;
+ }
+ for(i=0;i<gDelOptionCount;i++)
+ {
+ if(!gDelBootData[i].bNewOption)
+ count++;
+ else
+ DelOptionListCount++;
+ }
+
+ //Allocate for boot options
+ pBootData = NULL;
+ if(count)
+ pBootData = EfiLibAllocateZeroPool(count * sizeof(BOOT_DATA));
+ if(AddOptionListCount)
+ AddOptionList=EfiLibAllocateZeroPool(AddOptionListCount * sizeof(UINT16));
+ if(DelOptionListCount)
+ DelOptionList=EfiLibAllocateZeroPool(DelOptionListCount * sizeof(UINT16));
+
+ count = 0;
+ AddOptionListCount=0;
+ DelOptionListCount=0;
+
+ //Copy old options
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(!gBootData[i].bNewOption)
+ {
+ MemCopy(pBootData+count, gBootData+i, sizeof(BOOT_DATA));
+ count++;
+ }
+ else
+ { // Newly added option that need to removed.
+ AddOptionList[AddOptionListCount++] = gBootData[i].Option;
+ }
+ }
+
+ for(i=0;i<gDelOptionCount;i++)
+ {
+ if(!gDelBootData[i].bNewOption)
+ {
+ MemCopy(pBootData+count, gDelBootData+i, sizeof(BOOT_DATA));
+ count++;
+
+ // deleted option that need to added.
+ DelOptionList[DelOptionListCount++] = gDelBootData[i].Option;
+ }
+ }
+
+ MemFreePointer((VOID **) &gBootData);
+ gBootData = pBootData;
+ gBootOptionCount = count;
+
+ MemFreePointer((VOID **) &gDelBootData);
+ gDelOptionCount = 0;
+
+// EIP 32445
+// Update BootOrderVar Cache after discarding the changes.
+// If newly add/Del option discorded.
+ if(AddOptionListCount || DelOptionListCount)
+ {
+ CurrBootOrder = VarGetVariable(VARIABLE_ID_BOOT_ORDER, &size);
+ NewBootOrder = EfiLibAllocateZeroPool((gBootOptionCount) * sizeof(UINT16));
+ count = size/2;
+
+ // Defaults might be load Move the disabled boot option to the end
+ for(j=0;j<count;j++)
+ {
+ if(DISABLED_BOOT_OPTION == CurrBootOrder[j])
+ {
+ if (size < ((j+1)*sizeof(UINT16))) //EIP-131549
+ tempsize = ((j+1)*sizeof(UINT16)) - size;
+ else
+ tempsize = size - ((j+1)*sizeof(UINT16));
+
+ MemCopy(&CurrBootOrder[j], &CurrBootOrder[j+1], tempsize);
+ size-=sizeof(UINT16);
+ }
+ }
+
+ // remove the Newly added boot options
+ count = size/2;
+ for(i=0;i<AddOptionListCount;i++)
+ {
+ for(j=0;j<count;j++)
+ {
+ if(CurrBootOrder[j] == AddOptionList[i])
+ {
+ if (size < ((j+1)*sizeof(UINT16))) //EIP-131549
+ tempsize = ((j+1)*sizeof(UINT16)) - size;
+ else
+ tempsize = size - ((j+1)*sizeof(UINT16));
+
+ MemCopy(&CurrBootOrder[j], &CurrBootOrder[j+1], tempsize);
+ size-=sizeof(UINT16);
+ }
+ }
+ }
+ count = size/2;
+ // Add the DelOptions
+ MemCopy(NewBootOrder, CurrBootOrder, size);
+ MemCopy(&NewBootOrder[count],DelOptionList,DelOptionListCount*sizeof(UINT16) );
+
+ // Make the remailing options as disabled.
+ for(i=count+DelOptionListCount;i<gBootOptionCount;i++)
+ NewBootOrder[i] = DISABLED_BOOT_OPTION;
+
+ MemFreePointer((VOID **) &CurrBootOrder);
+ MemFreePointer((VOID **) &DelOptionList);
+ MemFreePointer((VOID **) &AddOptionList);
+
+ //Update boot manager vars in memory
+ //1. TSE Boot order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer);
+ if (gLoadOptionHidden)
+ {
+ FixHiddenOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount);
+ }
+ _DisableRestorePrevOptions (BOOT_ORDER_OPTION, &NewBootOrder, gBootOptionCount); //Disable options after discarding changes to active so fixed it
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Buffer = (UINT8 *)NewBootOrder;
+ gVariableList[VARIABLE_ID_BOOT_ORDER].Size = gBootOptionCount * sizeof(UINT16);
+ }
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DiscardAddDelDriverOptions
+//
+// Description: Function to discarding the add/del driver option
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DiscardAddDelDriverOptions(VOID)
+{
+ UINTN count,i,j;
+ BOOT_DATA *pDriverData;
+ UINT16 *AddOptionList=NULL,*DelOptionList=NULL;
+ UINTN AddOptionListCount=0, DelOptionListCount=0;
+ UINT16 *NewDriverOrder = NULL, *CurrDriverOrder = NULL;
+ UINTN size = 0, tempsize = 0;
+
+ //find no. of boot options
+ count = 0;
+ for(i=0;i<gDriverOptionCount;i++)
+ {
+ if(!gDriverData[i].bNewOption)
+ count++;
+ else
+ AddOptionListCount++;
+ }
+ for(i=0;i<gDriverDelOptionCount;i++)
+ {
+ if(!gDelDriverData[i].bNewOption)
+ count++;
+ else
+ DelOptionListCount++;
+ }
+
+ //Allocate for boot options
+ pDriverData = NULL;
+ if(count)
+ pDriverData = EfiLibAllocateZeroPool(count * sizeof(BOOT_DATA));
+ if(AddOptionListCount)
+ AddOptionList=EfiLibAllocateZeroPool(AddOptionListCount * sizeof(UINT16));
+ if(DelOptionListCount)
+ DelOptionList=EfiLibAllocateZeroPool(DelOptionListCount * sizeof(UINT16));
+
+ count = 0;
+ AddOptionListCount=0;
+ DelOptionListCount=0;
+
+ //Copy old options
+ for(i=0;i<gDriverOptionCount;i++)
+ {
+ if(!gDriverData[i].bNewOption)
+ {
+ MemCopy(pDriverData+count, gDriverData+i, sizeof(BOOT_DATA));
+ count++;
+ }
+ else
+ { // Newly added option that need to removed.
+ AddOptionList[AddOptionListCount++] = gDriverData[i].Option;
+ }
+ }
+
+ for(i=0;i<gDriverDelOptionCount;i++)
+ {
+ if(!gDelDriverData[i].bNewOption)
+ {
+ MemCopy(pDriverData+count, gDelDriverData+i, sizeof(BOOT_DATA));
+ count++;
+
+ // deleted option that need to added.
+ DelOptionList[DelOptionListCount++] = gDelDriverData[i].Option;
+ }
+ }
+
+ MemFreePointer((VOID **) &gDriverData);
+ gDriverData = pDriverData;
+ gDriverOptionCount = count;
+
+ MemFreePointer((VOID **) &gDelDriverData);
+ gDriverDelOptionCount = 0;
+
+// Update DriverOrderVar Cache after discarding the changes.
+// If newly add/Del option discorded.
+ if(AddOptionListCount || DelOptionListCount)
+ {
+ CurrDriverOrder = VarGetVariable(VARIABLE_ID_DRIVER_ORDER, &size);
+ NewDriverOrder = EfiLibAllocateZeroPool((gDriverOptionCount) * sizeof(UINT16));
+ count = size/2;
+
+ // Defaults might be load Move the disabled driver option to the end
+ for(j=0;j<count;j++)
+ {
+ if(DISABLED_BOOT_OPTION == CurrDriverOrder[j])
+ {
+ if (size > ((j+1)*sizeof(UINT16))) //EIP-131549
+ tempsize = size - ((j+1)*sizeof(UINT16));
+ else
+ tempsize = ((j+1)*sizeof(UINT16)) - size;
+
+ MemCopy(&CurrDriverOrder[j], &CurrDriverOrder[j+1], tempsize );
+ size-=sizeof(UINT16);
+ }
+ }
+
+ // remove the Newly added driver options
+ count = size/2;
+ for(i=0;i<AddOptionListCount;i++)
+ {
+ for(j=0;j<count;j++)
+ {
+ if(CurrDriverOrder[j] == AddOptionList[i])
+ {
+ if ((UINTN)size >= ((j+1)*sizeof (UINT16)) ) //Check added bcoz, If only added driver presents and loading defaults will lead to crash
+ {
+ if (size > ((j+1)*sizeof(UINT16))) //EIP-131549
+ tempsize = size - ((j+1)*sizeof(UINT16));
+ else
+ tempsize = ((j+1)*sizeof(UINT16)) - size;
+
+ MemCopy (&CurrDriverOrder [j], &CurrDriverOrder[j+1], tempsize );
+ size-=sizeof(UINT16);
+ }
+ }
+ }
+ }
+
+ count = size/2;
+ // Add the DelOptions
+ MemCopy(NewDriverOrder, CurrDriverOrder, size);
+ MemCopy(&NewDriverOrder[count],DelOptionList,DelOptionListCount*sizeof(UINT16) );
+
+ // Make the remaining options as disabled.
+ for(i=count+DelOptionListCount;i<gDriverOptionCount;i++)
+ NewDriverOrder[i] = DISABLED_BOOT_OPTION;
+
+ MemFreePointer((VOID **) &CurrDriverOrder);
+ MemFreePointer((VOID **) &DelOptionList);
+ MemFreePointer((VOID **) &AddOptionList);
+
+ //Update driver manager vars in memory
+ //1. TSE Driver Order
+ MemFreePointer((VOID **) &gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer);
+ if (gLoadOptionHidden)
+ {
+ FixHiddenOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount);
+ }
+ _DisableRestorePrevOptions (DRIVER_ORDER_OPTION, &NewDriverOrder, gDriverOptionCount);
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Buffer = (UINT8 *)NewDriverOrder;
+ gVariableList[VARIABLE_ID_DRIVER_ORDER].Size = gDriverOptionCount * sizeof(UINT16);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveAddDelBootOptions
+//
+// Description: function to save the added/deleted boot option
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveAddDelBootOptions(VOID)
+{
+ UINTN i,OptimalIndex,FailsafeIndex,size;
+ UINT16 dpLength,*pNewOptimal, *pOldOptimal, *pNewFailsafe, *pOldFailsafe;
+ BOOT_OPTION *pOption;
+ CHAR16 *varName = L"BootXXXX";
+ UINT16 BootCountVal;
+
+ //Old Boot order defaults are not valid any more. Form the new
+ //defaults by removing deleted options and adding the new options at the end.
+ pNewOptimal = EfiLibAllocateZeroPool( gBootOptionCount * sizeof(UINT16) );
+ pNewFailsafe = EfiLibAllocateZeroPool( gBootOptionCount * sizeof(UINT16) );
+ pOldOptimal = (UINT16 *)gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer;
+ pOldFailsafe = (UINT16 *)gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer;
+ size = gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Size;
+ OptimalIndex = FailsafeIndex = 0;
+
+ //Add existing options first
+ for(i=0;i<size/sizeof(UINT16);i++)
+ {
+ if(BootGetBootData(pOldOptimal[i]))
+ {
+ pNewOptimal[OptimalIndex] = pOldOptimal[i];
+ OptimalIndex++;
+ }
+ if(BootGetBootData(pOldFailsafe[i]))
+ {
+ pNewFailsafe[FailsafeIndex] = pOldFailsafe[i];
+ FailsafeIndex++;
+ }
+ }
+ //Save New boot options
+ for(i=0;i<gBootOptionCount;i++)
+ {
+ if(gBootData[i].bNewOption)
+ {
+ dpLength = (UINT16)EfiDevicePathSize( gBootData[i].DevicePath );
+ size = sizeof(BOOT_OPTION) + sizeof(CHAR16)*EfiStrLen(gBootData[i].Name) + dpLength;
+ pOption = EfiLibAllocateZeroPool( size );
+ pOption->Active = gBootData[i].Active;
+ pOption->PathLength = dpLength;
+ EfiStrCpy( pOption->Name, gBootData[i].Name );
+ MemCopy( (UINT8 *)pOption + size - dpLength, gBootData[i].DevicePath, dpLength );
+
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1), gBootFormarSpecifier, gBootData[i].Option );
+ VarSetNvramName( varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ pOption,
+ size );
+
+ gBootData[i].bNewOption = 0;
+
+ //Append this option in defaults
+ pNewOptimal[OptimalIndex] = gBootData[i].Option;
+ pNewFailsafe[FailsafeIndex] = gBootData[i].Option;
+ OptimalIndex++;
+ FailsafeIndex++;
+ }
+ }
+
+ //Put new defaults in global default repository
+ //If Default order is not found in first time then will take current order.
+ //If any boot options added after that then new boot option always follow the first saved optimized buffer
+ //Removed EIP81581 fixes All the time changing the default buffer is not good
+ if (0 == gOptimalDefaults [VARIABLE_ID_BOOT_ORDER].Size) //EIP79956 Defaults not loading properly
+ {
+ UINT8 *pOptWithOutDefaultBootOrder = EfiLibAllocateZeroPool (gVariableList [VARIABLE_ID_BOOT_ORDER].Size);
+ if (NULL != pOptWithOutDefaultBootOrder)
+ {
+ MemCopy (pOptWithOutDefaultBootOrder, gVariableList [VARIABLE_ID_BOOT_ORDER].Buffer, gVariableList [VARIABLE_ID_BOOT_ORDER].Size);
+ gOptimalDefaults [VARIABLE_ID_BOOT_ORDER].Buffer = pOptWithOutDefaultBootOrder;
+ gOptimalDefaults [VARIABLE_ID_BOOT_ORDER].Size = gVariableList [VARIABLE_ID_BOOT_ORDER].Size;
+ }
+ }
+ else
+ {
+ MemFreePointer( (VOID **) &gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer );
+ gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer = (UINT8 *)pNewOptimal;
+ gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Size = OptimalIndex * sizeof(UINT16);
+ }
+
+ MemFreePointer( (VOID **) &gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer );
+ gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer = (UINT8 *)pNewFailsafe;
+ gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Size = FailsafeIndex * sizeof(UINT16);
+
+ //Delete removed options
+ for(i=0;i<gDelOptionCount;i++)
+ {
+ if(!gDelBootData[i].bNewOption)
+ {
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1), gBootFormarSpecifier, gDelBootData[i].Option );
+ VarSetNvramName( varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ varName,
+ 0);
+ }
+ }
+ MemFreePointer((VOID **)&gDelBootData);
+ gDelOptionCount = 0;
+
+ //Update default value for Boot Manager and Boot Now count
+ BootCountVal = (UINT16) gBootOptionCount;
+ _VarGetSetValue (VAR_COMMAND_SET_VALUE, gOptimalDefaults, VARIABLE_ID_BOOT_MANAGER, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+ _VarGetSetValue (VAR_COMMAND_SET_VALUE, gFailsafeDefaults, VARIABLE_ID_BOOT_MANAGER, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+
+ if (gShowAllBbsDev)
+ BootCountVal = _BootSetBootNowCount ();
+
+ _VarGetSetValue (VAR_COMMAND_SET_VALUE, gOptimalDefaults, VARIABLE_ID_BOOT_NOW, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+ _VarGetSetValue (VAR_COMMAND_SET_VALUE, gFailsafeDefaults, VARIABLE_ID_BOOT_NOW, 0, sizeof(UINT16), (VOID *)(&BootCountVal));
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveAddDelDriverOptions
+//
+// Description: Function to save the added/deleted Driver option
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveAddDelDriverOptions(VOID)
+{
+ UINTN i,OptimalIndex,FailsafeIndex,size;
+ UINT16 dpLength,*pNewOptimal, *pOldOptimal, *pNewFailsafe, *pOldFailsafe;
+ BOOT_OPTION *pOption;
+ CHAR16 *varName = L"DriverXXXX";
+ UINT16 DriverCountVal;
+
+ //Old Driver order defaults are not valid any more. Form the new
+ //defaults by removing deleted options and adding the new options at the end.
+ pNewOptimal = EfiLibAllocateZeroPool( gDriverOptionCount * sizeof(UINT16) );
+ pNewFailsafe = EfiLibAllocateZeroPool( gDriverOptionCount * sizeof(UINT16) );
+ pOldOptimal = (UINT16 *)gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer;
+ pOldFailsafe = (UINT16 *)gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer;
+ size = gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Size;
+ OptimalIndex = FailsafeIndex = 0;
+
+ //Add existing options first
+ for(i=0;i<size/sizeof(UINT16);i++)
+ {
+ if (DriverGetDriverData (pOldOptimal [i]))
+ {
+ pNewOptimal[OptimalIndex] = pOldOptimal[i];
+ OptimalIndex++;
+ }
+ if(DriverGetDriverData (pOldFailsafe[i]))
+ {
+ pNewFailsafe[FailsafeIndex] = pOldFailsafe[i];
+ FailsafeIndex++;
+ }
+ }
+ //Save New driver options
+ for(i=0;i<gDriverOptionCount;i++)
+ {
+ if(gDriverData[i].bNewOption)
+ {
+ dpLength = (UINT16)EfiDevicePathSize( gDriverData[i].DevicePath );
+ size = sizeof(BOOT_OPTION) + sizeof(CHAR16)*EfiStrLen(gDriverData[i].Name) + dpLength;
+ pOption = EfiLibAllocateZeroPool( size );
+ pOption->Active = gDriverData[i].Active;
+ pOption->PathLength = dpLength;
+ EfiStrCpy( pOption->Name, gDriverData[i].Name );
+ MemCopy( (UINT8 *)pOption + size - dpLength, gDriverData[i].DevicePath, dpLength );
+
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1), gDriverFormarSpecifier, gDriverData[i].Option );
+ VarSetNvramName( varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ pOption,
+ size );
+
+ gDriverData[i].bNewOption = 0;
+ //Append this option in defaults
+ pNewOptimal[OptimalIndex] = gDriverData[i].Option;
+ pNewFailsafe[FailsafeIndex] = gDriverData[i].Option;
+ OptimalIndex++;
+ FailsafeIndex++;
+ }
+ }
+
+ //Put new defaults in global default repository
+ //Default order is not found in first time then will take current order.
+ //If any driver options added after that then new driver option always follow the first saved optimized buffer
+ //Removed EIP81581 fixes All the time changing the default buffer is not good
+ if (0 == gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Size)
+ {
+ UINT8 *pOptWithOutDefaultDriverOrder = EfiLibAllocateZeroPool (gVariableList [VARIABLE_ID_DRIVER_ORDER].Size);
+ if (NULL != pOptWithOutDefaultDriverOrder)
+ {
+ MemCopy (pOptWithOutDefaultDriverOrder, gVariableList [VARIABLE_ID_DRIVER_ORDER].Buffer, gVariableList [VARIABLE_ID_DRIVER_ORDER].Size);
+ gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Buffer = pOptWithOutDefaultDriverOrder;
+ gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Size = gVariableList [VARIABLE_ID_DRIVER_ORDER].Size;
+ }
+ }
+ else
+ {
+ MemFreePointer( (VOID **) &gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer );
+ gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer = (UINT8 *)pNewOptimal;
+ gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Size = OptimalIndex * sizeof(UINT16);
+ }
+ MemFreePointer( (VOID **) &gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer );
+ gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer = (UINT8 *)pNewFailsafe;
+ gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Size = FailsafeIndex * sizeof(UINT16);
+
+ //Delete removed options
+ for(i=0;i<gDriverDelOptionCount;i++)
+ {
+ if(!gDelDriverData[i].bNewOption)
+ {
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1), gDriverFormarSpecifier, gDelDriverData[i].Option );
+ VarSetNvramName (varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ varName,
+ 0);
+ }
+ }
+ MemFreePointer((VOID **)&gDelDriverData);
+ gDriverDelOptionCount = 0;
+
+ //Update default value for Driver Manager
+ DriverCountVal = (UINT16) gDriverOptionCount;
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, VARIABLE_ID_DRIVER_MANAGER, 0, sizeof(UINT16), (VOID *)(&DriverCountVal) );
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, VARIABLE_ID_DRIVER_MANAGER, 0, sizeof(UINT16), (VOID *)(&DriverCountVal) );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSELiteFixAddBootOptionFileList
+//
+// Description: Function to fix Add Boot Option file list
+//
+// Input: CONTROL_DATA *ControlData
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TSELiteFixAddBootOptionFileList(CONTROL_DATA *ControlData)
+{
+ POPUPSEL_DATA *popupSel = (POPUPSEL_DATA *)ControlData;
+ UINT16 i=0;
+ if(gFsCount >= popupSel->ItemCount) // If the filesystem found
+ {
+ for(i=0;i<popupSel->ItemCount;i++)
+ {
+ popupSel->PtrTokens[i].Option = HiiAddString( popupSel->ControlData.ControlHandle, gFsList[i].FsId );
+ popupSel->PtrTokens[i].Value = i;
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSELiteFixAddBootOptionFileList
+//
+// Description: Function to fix Delete Boot option file list
+//
+// Input: CONTROL_DATA *ControlData
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TSELiteFixDelBootOptionFileList(CONTROL_DATA *ControlData)
+{
+ POPUPSEL_DATA *popupSel = (POPUPSEL_DATA *)ControlData;
+ UINT16 i=0;
+
+ for(i=0;i<popupSel->ItemCount;i++)
+ {
+ if((UINT16)popupSel->PtrTokens[i].Value != 0xFFFF)
+ {
+ popupSel->PtrTokens[i].Value = gBootData[i-1].Option;
+ popupSel->PtrTokens[i].Option = HiiAddString( popupSel->ControlData.ControlHandle, BootGetOptionName( &(gBootData[i-1]) ) );
+ }
+ }
+}
+
+/// EIP-41615: START - File Browser related functions for Add Boot Option..
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: CleanFileTypes
+//
+// Description: Frees all allocated memory associated with the FILE_TYPE structure
+// and resets the InternalString current strings next available string token
+// to be the first dynamically added string
+//
+// Input: FILE_TYPE **FileList - The array of FILE_TYPE structures found in
+// a directory
+// UINTN *FileCount - pointer to the number of entries in the FileList
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanFileTypes(FILE_TYPE **FileList, UINTN *FileCount)
+{
+ UINTN i;
+ for(i = 0; i<*FileCount; i++) gBS->FreePool((*FileList)[i].Name);
+ if(FileList!=NULL && (*FileList!=NULL) && (*FileCount>0)) gBS->FreePool(*FileList);
+ if(FileList!=NULL) *FileList = NULL;
+ *FileCount = 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: CheckDirectoryType
+//
+// Description: Checks if the EFI_FILE_INFO is a directory (and not the current directory)
+//
+// Input: EFI_FILE_INFO *File
+//
+// Output:
+//
+// Returns: BOOLEAN - TRUE - item is a directory, and not the current directory
+// FALSE - item is not a directory, or is the current directory
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckDirectoryType(EFI_FILE_INFO *File)
+{
+ BOOLEAN Status = FALSE;
+
+ if((File->Attribute & EFI_FILE_DIRECTORY) && (EfiStrCmp(File->FileName, L".") != 0)) {
+
+ Status = TRUE;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: CheckExtension
+//
+// Description: Check is the EFI_FILE_INFO has the same extension as the
+// extension passed in the second parameter
+//
+// Input: EFI_FILE_INFO *File - The file entry whose extension should be checked
+// CHAR16 *ExtensionEfi - the extension
+//
+// Output:
+//
+// Returns: BOOLEAN - TRUE - The extension matches
+// FALSE - the extension does not match
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckExtension(EFI_FILE_INFO *File, CHAR16 *ExtensionEfi)
+{
+ BOOLEAN Status = FALSE;
+ UINTN Length = EfiStrLen(File->FileName);
+
+ if((File->Attribute & EFI_FILE_DIRECTORY) != EFI_FILE_DIRECTORY && Length > 3)
+ if((((File->FileName[Length-1])&0xdf) == ((ExtensionEfi[2])&0xdf)) &&
+ (((File->FileName[Length-2])&0xdf) == ((ExtensionEfi[1])&0xdf)) &&
+ (((File->FileName[Length-3])&0xdf) == ((ExtensionEfi[0])&0xdf)))
+ Status = TRUE;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: FindInsertionIndex
+//
+// Description: Finds the inded where directories items turn into file items
+//
+// Input: FILE_TYPE *List - the current array of File Type structures
+// UINTN FileCount - the count of File Type structures in the array
+//
+// Output:
+//
+// Returns: the index to insert a new item
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN FindInsertionIndex(FILE_TYPE *List, UINTN FileCount)
+{
+ UINTN i = 0;
+
+ if(FileCount <= 1) return 0;
+
+ for(i = 1; i < (FileCount-1); i++)
+ {
+ if(List[i-1].Type != List[i].Type)
+ break;
+ }
+
+ return i;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: AddFileTypeEntry
+//
+// Description: Creates a new entry in the FILE_TYPE array and adds the current File into
+// the array.
+//
+// Input: FILE_TYPE **List - Array of FILE_TYPE structures alread found
+// UINTN *FileCount - number of entries in the FILE_TYPE array
+// EFI_FILE_INFO *FileInfo - file info of the file that should be added
+//
+// Output:
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+static VOID AddFileTypeEntry(FILE_TYPE **List, UINTN *FileCount, EFI_FILE_INFO *FileInfo)
+{
+ FILE_TYPE *NewList=NULL;
+ UINTN Length;
+ UINTN Index = 0;
+
+ Length = (EfiStrLen(FileInfo->FileName)+3)*sizeof(CHAR16);
+
+ // Allocate space for a new list entry plus all the previous list items
+ NewList = EfiLibAllocateZeroPool(sizeof(FILE_TYPE)*(++(*FileCount)));
+ if (NewList != NULL)
+ {
+ // Clear the memory of the entire list
+ MemSet(NewList, sizeof(FILE_TYPE)*(*FileCount), 0);
+
+ // Copy the old entries (if there are any old entries to copy)
+ if(*List != NULL)
+ {
+ Index = FindInsertionIndex(*List, *FileCount);
+
+ MemCopy(NewList, *List, sizeof(FILE_TYPE)*(Index));
+ MemCopy(&(NewList[Index+1]), &((*List)[Index]), sizeof(FILE_TYPE)*((*FileCount)-Index-1));
+
+ gBS->FreePool(*List);
+ }
+
+ // Store the type of this FILE_TYPE entry (non-zero is directory)
+ NewList[Index].Type = ((FileInfo->Attribute) & EFI_FILE_DIRECTORY);
+
+ // Store the size of the file
+ NewList[Index].Size = (UINTN)FileInfo->FileSize;
+
+ // Allocate space for the string
+ NewList[Index].Name = EfiLibAllocateZeroPool (Length);
+ if((NewList[Index].Name) != NULL )
+ {
+ // Clear the allocated memory
+ MemSet(NewList[Index].Name, Length, 0);
+
+ // Create either a Dir string or a File string for addition to the HiiDataBase
+ if(NewList[Index].Type == EFI_FILE_DIRECTORY)
+ SPrint(NewList[Index].Name, (sizeof(CHAR16)*EfiStrLen(FileInfo->FileName)+1), L"<%s>", FileInfo->FileName);
+ else
+ SPrint(NewList[Index].Name, (sizeof(CHAR16)*EfiStrLen(FileInfo->FileName)+1), L"%s", FileInfo->FileName);
+
+ // Add the string to the HiiDataBase
+ ///NewList[Index].Token = AddStringToHii(FileInfo->FileName, &gInternalStrings); ///Just by trying using the following line
+ NewList[Index].Token = HiiAddString(gHiiHandle, NewList[Index].Name );
+
+ // Clear the memory and create the string for the File Structure
+ MemSet(NewList[Index].Name, Length, 0);
+ SPrint(NewList[Index].Name, (sizeof(CHAR16)*EfiStrLen(FileInfo->FileName)+1), L"%s", FileInfo->FileName);
+ }
+ *List = NewList;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: CreateFileList
+//
+// Description: Parse all the files in the current directory and add valid files to the
+// FILE_TYPE list and update the filecount
+//
+// Input: EFI_FILE_PROTOCOL *FileProtocol - the current direcotry to parse
+//
+// Output: FILE_TYPE **FileList - pointer in which to return the array of FileType items
+// UINTN *FileCount - the count of filetype items discovered
+//
+// Returns: EFI_STATUS
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+static EFI_STATUS CreateFileList(EFI_FILE_PROTOCOL *FileProtocol, FILE_TYPE **FileList, UINTN *FileCount)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ UINTN BufferSize = 1;
+ EFI_FILE_INFO *File = NULL;
+
+ CHAR16 ExtensionEfi[] = L"EFI";
+
+ // Continue parsing the directory until we no longer read valid files
+ while(BufferSize != 0 && !EFI_ERROR(Status))
+ {
+ BufferSize = 0;
+ Status = FileProtocol->Read(FileProtocol, &BufferSize, NULL);
+
+ if(!EFI_ERROR(Status)) break;
+
+ if(Status == EFI_BUFFER_TOO_SMALL)
+ {
+ File = EfiLibAllocateZeroPool (BufferSize);
+ if(File != NULL) {
+ MemSet(File, BufferSize, 0);
+ }
+ }
+
+ Status = FileProtocol->Read(FileProtocol, &BufferSize, File);
+
+ // Check if a valid file was read
+ if(!EFI_ERROR(Status) && BufferSize != 0)
+ {
+ // check if the file read was a directory or a ".efi" extension
+ if(CheckDirectoryType(File) || CheckExtension(File, ExtensionEfi))
+ {
+ // the file was valid, add it to the file list
+ AddFileTypeEntry(FileList, FileCount, File);
+ }
+ }
+
+ // free the space allocated for readin the file info structure
+ gBS->FreePool(File);
+
+ // set the pointer to null to prevent the chance of memory corruption
+ File = NULL;
+ }
+
+ if(*FileCount == 0) Status = EFI_NOT_FOUND;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: DisplayFileListMenu
+//
+// Description: Display a menu of the FILE_TYPE items and return the selected item
+// in the Selection
+//
+// Input: FILE_TYPE *FileList - List of FILE_TYPE items to display in the menu
+// UINTN FileCount - the number of FILE_TYPE items in the list
+//
+// Output: UINT16 *Selection - The index of the selected FILE_TYPE item
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+static EFI_STATUS DisplayFileListMenu(FILE_TYPE *FileList, UINTN FileCount, UINT16 *Selection, UINT32 Variable)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ UINT16 i = 0;
+
+ POSTMENU_TEMPLATE *List = NULL;
+
+ // Check there are any files to display
+ if(FileCount != 0 && FileList != NULL)
+ {
+ // allocate space for the POSTMENU_TEMPLATE items
+ List = EfiLibAllocateZeroPool (sizeof(POSTMENU_TEMPLATE)*FileCount);
+ if(List != NULL)
+ {
+ // Clear the memory allocated
+ MemSet(List, sizeof(POSTMENU_TEMPLATE)*FileCount, 0);
+
+ // Add the STRING_REF tokens to the POSTMENU_TEMPLATE structures
+ for(i = 0; i < FileCount; i++)
+ List[i].ItemToken = FileList[i].Token;
+ }
+
+ // Call post manager to display the menu
+ Status = mPostMgr->DisplayPostMenu(gHiiHandle,
+ (VARIABLE_ID_ADD_BOOT_OPTION == Variable) ? STRING_TOKEN (STR_FILE_PATH) : STRING_TOKEN (STR_DRIVER_PATH),
+ 0,
+ List,
+ (UINT16)FileCount,
+ Selection);
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: UpdateFilePathString
+//
+// Description: To create the File Path string based on the file selected.
+//
+// Input: CHAR16 *FilePath - Buffer to fill with the file path
+// CHAR16 * CurFile - current file selected
+// UINT16 idx - Index of the file in the current directory
+//
+// Output: CHAR16 *FilePath - Updated File Path
+//
+// Returns:
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateFilePathString(CHAR16 *FilePath, CHAR16 * CurFile, UINT16 idx)
+{
+ UINTN Length=0;
+
+ if(EfiStrLen(FilePath))
+ {
+ if( idx==0 ) {
+ if(EfiStrCmp(CurFile,L"..")) {
+ EfiStrCat(FilePath,L"\\");
+ EfiStrCat(FilePath,CurFile);
+ }
+ else {
+
+ for ( Length = EfiStrLen(FilePath); ( Length!= 0 ) && (FilePath[Length-1] != L'\\') ; Length -- );
+ if ( Length )
+ FilePath[Length-1] = L'\0';
+ else
+ FilePath[Length] = L'\0';
+ }
+ }
+ else {
+ EfiStrCat(FilePath,L"\\");
+ EfiStrCat(FilePath,CurFile);
+ }
+ }
+ else {
+ EfiStrCpy(FilePath,L"\\");
+ EfiStrCat(FilePath,CurFile);
+ //EfiStrCpy(FilePath,CurFile);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: FileBrowserLaunchFileSystem
+//
+// Description: To select the File System for the new boot option with the help of file browser.
+//
+// Input: VOID
+//
+// Output: Selected File System Index
+//
+// Returns: EFI_STATUS
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FileBrowserLaunchFileSystem(UINT32 Variable)
+{
+ EFI_STATUS Status;
+ UINTN Count = 0;
+ UINT16 i = 0;
+
+ EFI_GUID DevicePathGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;
+ EFI_DEVICE_PATH_PROTOCOL *Dp = NULL;
+
+ POSTMENU_TEMPLATE *PossibleFileSystems = NULL;
+
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL, &mPostMgr);
+ if(EFI_ERROR(Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ // Locate all the simple file system devices in the system
+ Status = gBS->LocateHandleBuffer(ByProtocol, &gSimpleFileSystemGuid, NULL, &Count, &gSmplFileSysHndlBuf);
+ if(!EFI_ERROR(Status))
+ {
+ // allocate space to display all the simple file system devices
+ PossibleFileSystems = EfiLibAllocateZeroPool (sizeof(POSTMENU_TEMPLATE)*Count);
+ if(PossibleFileSystems != NULL)
+ {
+ // clear the allocated space
+ MemSet(PossibleFileSystems, sizeof(POSTMENU_TEMPLATE)*Count, 0);
+ for(i = 0; i < Count; i++)
+ {
+ // get the device path for each handle with a simple file system
+ Status = gBS->HandleProtocol(gSmplFileSysHndlBuf[i], &DevicePathGuid, &Dp);
+ if(!EFI_ERROR(Status))
+ {
+ CHAR16 *Name = NULL;
+
+ // Get the name of the driver installed on the handle
+ // GetControllerName(gHandleBuffer[i],&Name);
+
+ Name = NULL;
+ Name = _DevicePathToStr(Dp);
+
+ // Add the name to the Hii Database
+ ///PossibleFileSystems[i].ItemToken = AddStringToHii(Name);
+ PossibleFileSystems[i].ItemToken = HiiAddString(gHiiHandle, Name );
+
+ PossibleFileSystems[i].Attribute = AMI_POSTMENU_ATTRIB_FOCUS;
+ }
+ else
+ {
+ PossibleFileSystems[i].ItemToken = 0;
+ PossibleFileSystems[i].Attribute = AMI_POSTMENU_ATTRIB_HIDDEN;
+ }
+ }
+ // Reset the item selected to be the first item
+ gSelIdx = 0;
+
+ // Display the post menu and wait for user input
+ Status = mPostMgr->DisplayPostMenu(gHiiHandle,
+ (Variable != 0xffff)? STRING_TOKEN(STR_FILE_SYSTEM) : STRING_TOKEN(STR_FILE_SYSTEM_TO_SAVE_IMG),//EIP-123432
+ 0,
+ PossibleFileSystems,
+ (UINT16)Count,
+ &gSelIdx);
+
+
+ // A valid item was selected by the user
+ if(!EFI_ERROR(Status))
+ {
+ gValidOption = TRUE;
+ }
+ }
+ }
+
+ else {
+ ShowPostMsgBox( L"No Valid File System", L"No Valid File System Available", MSGBOX_TYPE_OK, NULL );//EIP:41615 To display Warning message when there is no file system connected.
+
+ }
+ // Free the allocated menu list space
+ if(PossibleFileSystems != NULL)
+ gBS->FreePool(PossibleFileSystems);
+ if(Variable == VARIABLE_ID_ADD_BOOT_OPTION)
+ {
+ // Set the File System Index for the new boot option added
+ VarSetValue(VARIABLE_ID_ADD_BOOT_OPTION, STRUCT_OFFSET(NEW_BOOT_OPTION,SelFs), sizeof(UINT16), (VOID*)&gSelIdx);
+ }
+ if(Variable == VARIABLE_ID_ADD_DRIVER_OPTION) //EIP70421 & 70422 Support for driver order
+ {
+ VarSetValue(VARIABLE_ID_ADD_DRIVER_OPTION, STRUCT_OFFSET(NEW_DRIVER_OPTION,SelFs), sizeof(UINT16), (VOID*)&gSelIdx);
+ }
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------
+// Procedure: FileBrowserLaunchFilePath
+//
+// Description: To select the Boot file for the new boot option with the help of file browser.
+//
+// Input: VOID
+//
+// Output: File Path string
+//
+// Returns: EFI_STATUS
+//
+//----------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FileBrowserLaunchFilePath(UINT32 Variable)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle = 0;
+
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs = NULL;
+ EFI_FILE_PROTOCOL *NewFs = NULL;
+ FILE_TYPE *FileList = NULL;
+ UINTN FileCount = 0;
+ UINT16 i = 0;
+ //CHAR16 FilePath[120];
+ CHAR16 *FilePath=NULL;
+ UINTN filenamelength = 0, Length = 0;
+
+ // Attempt to locate the post manager protocol
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL, &mPostMgr);
+ if(!EFI_ERROR(Status))
+ {
+ if( gValidOption == TRUE )
+ {
+ gValidOption = FALSE;
+
+ // Get the simple file system protocol
+ Status = gBS->HandleProtocol(gSmplFileSysHndlBuf[gSelIdx], &gSimpleFileSystemGuid, &SimpleFs);
+ if(!EFI_ERROR(Status))
+ {
+ // And open it and return the efi file protocol
+ Status = SimpleFs->OpenVolume(SimpleFs, &gFs);
+ }
+ }
+ else {
+ return EFI_UNSUPPORTED;
+ }
+
+ // Free handle buffer space (auto allocated by the called function)
+ if(gSmplFileSysHndlBuf != NULL)
+ gBS->FreePool(gSmplFileSysHndlBuf);
+
+ // clean up the file list and strings used in getting the file system
+ CleanFileTypes(&FileList, &FileCount);
+ }
+
+ //MemSet(FilePath, 120, 0);
+ if ( NULL == FilePath ) //EIP-105725
+ {
+ FilePath = (CHAR16*)EfiLibAllocateZeroPool(sizeof(CHAR16));
+ }
+
+ while(!EFI_ERROR(Status) && gFs != NULL)
+ {
+ i = 0;
+
+ // Create a list of the files in the current directory
+ Status = CreateFileList(gFs, &FileList, &FileCount);
+ if(!EFI_ERROR(Status))
+ {
+ // Display the list in a menu and allow the user to select
+ Status = DisplayFileListMenu(FileList, FileCount, &i, Variable);
+ if(!EFI_ERROR(Status))
+ {
+ // The user selected something, attempt to open it
+ Status = gFs->Open( gFs,
+ &NewFs,
+ FileList[i].Name,
+ EFI_FILE_MODE_READ,
+ 0);
+
+ // close the old file system protocol and set it to null
+ gFs->Close(gFs);
+ gFs = NULL;
+
+ Length = EfiStrLen(FilePath) + 3; // adding 2 more character for \ and null termination
+ filenamelength = EfiStrLen(FileList[i].Name);
+ if ( NULL != FilePath )
+ {
+ ////EIP-105725 Re-allocating based on filePath string length
+ FilePath = MemReallocateZeroPool( FilePath, (Length * sizeof (CHAR16)), ( (Length * sizeof (CHAR16)) + (filenamelength * sizeof (CHAR16)) ) );
+ }
+
+
+ // Create the File Path based on the file selected
+ UpdateFilePathString(FilePath, FileList[i].Name, i);
+
+ // the newly selected item was opened correctly
+ if(!EFI_ERROR(Status))
+ {
+ // check what type was opened
+ if(FileList[i].Type != EFI_FILE_DIRECTORY)
+ {
+ // the file was read, close the file system protocol and set it to null
+ NewFs->Close(NewFs);
+ NewFs = NULL;
+
+ //SPrint (FileName, 50, L"%s", FileList[i].Name);
+ //ShowPostMsgBox( L"Selected Boot File Name", FileName, MSGBOX_TYPE_OK, &SelOpt );
+ }
+ gFs = NewFs;
+ }
+ }
+ }
+
+ if(FileCount <= 0) {
+ ShowPostMsgBox( L"No Valid File", L"No Valid File Available in the Selected File System", MSGBOX_TYPE_OK, NULL );//EIP:41615 Warning message to show unavailability of the selected file
+ }
+ // clean the strings that were used and free allocated space
+ CleanFileTypes(&FileList, &FileCount);
+
+ if(Status == EFI_ABORTED) {
+ return Status;//EIP:41615 Returning the status if its aborted.
+ }
+ }
+ // Set the File path for the new boot option added.
+ if(!EFI_ERROR(Status))
+ {
+ if (VARIABLE_ID_ADD_BOOT_OPTION == Variable)
+ VarSetValue(VARIABLE_ID_ADD_BOOT_OPTION, STRUCT_OFFSET(NEW_BOOT_OPTION,Path), ((EfiStrLen(FilePath)+1)*sizeof(CHAR16)), FilePath);
+ if (VARIABLE_ID_ADD_DRIVER_OPTION == Variable) //EIP70421 & 70422 Support for driver order
+ VarSetValue(VARIABLE_ID_ADD_DRIVER_OPTION, STRUCT_OFFSET(NEW_DRIVER_OPTION,DriverPath), ((EfiStrLen(FilePath)+1)*sizeof(CHAR16)), FilePath);
+ }
+ MemFreePointer((VOID**)&FilePath);
+ return Status;
+}
+//EIP-41615: END..
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Date.c b/EDK/MiniSetup/TseLite/Date.c
new file mode 100644
index 0000000..812244f
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Date.c
@@ -0,0 +1,1397 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Date.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 32 $
+//
+// $Date: 5/01/14 3:39p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Date.c $
+//
+// 32 5/01/14 3:39p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 31 11/20/12 12:41a Arunsb
+// [TAG] EIP107049
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If set Token "STYLE_DATE_FORMAT" to change the date display
+// type to [yyyy/mm/dd], it can't key-in correct value to set the date
+// value, only use the +/- command to set the date value
+// [Files] Date.c
+//
+// 30 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 29 4/05/12 7:13a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 28 2/02/12 1:16p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 27 1/18/12 7:27a Rajashakerg
+// [TAG] EIPEIP 79487:
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Decreasing YEAR field displayed yearr with XX before 2005
+// and after 2098.
+// [RootCause] Improper handling of the date and year field of the date
+// control.
+// [Solution] Global variable DateTempNum is handled properly while
+// updating the date and year field of the date control.
+// [Files] Date.c
+//
+// 26 1/18/12 6:22a Rajashakerg
+// [TAG] EIP79961
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] "Non RTC date control - decreasing from year value 0001
+// displayed 65535 without closing bracket.
+// [RootCause] In date draw function we are providing only 4 digits for
+// year. But Tm.year value when decremented after least value its drawing
+// the 65535 which is the maximum.
+// [Solution] Restricted maximum value for year to 9999 such that it
+// wont erase the ']' when incremented over 9999.
+// When incremented over 9999 provided 0 to it.
+// [Files] Date.c
+//
+// 25 1/11/12 7:42a Arunsb
+// [TAG] EIP79965
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Unable to set the date and time with the soft keyboard and
+// mouse
+// [RootCause] Softkbd disabled even the control is active
+// [Solution] Disabled the softkbd only when control is inactive
+// [Files] Date.c and time.c
+//
+// 24 1/05/12 1:10p Blaines
+// [TAG] EIP 80092
+// [Category] Defect
+// [Symptom] Day of week is not properly calculated for 2012 in Setup
+// [RootCause] Local variables are declared type UINT.
+// [Solution] Change the local variable type from UINT to INTN.
+//
+// [Files Changed]
+// - date.c
+//
+// [Functions Changed]
+// - _DateGetWeekDay
+//
+// 23 12/07/11 9:02a Rajashakerg
+// TAG] EIP73231
+// [Category] Improvement
+// [Description] Moved the UefiPreControlUpdate function call in time.c
+// and date.c to the appropriate place.
+// [Files] time.c, date.c
+//
+// 22 11/30/11 11:51p Rajashakerg
+//
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 21 11/30/11 12:49a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 20 11/28/11 4:55a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 19 11/28/11 2:02a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 18 11/21/11 12:12p Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 17 11/20/11 7:44a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 16 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 15 8/26/11 6:34p Blaines
+// [TAG] EIP68354
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Callback was invoked during periodic update for time and
+// date controls without EFI_IFR_REFRESH_OP.
+// [Solution] Callback is only invoked for interactive controls.
+// [Files] TseLite: Time.c, Date.c,
+// Uefi21: Parese.c, Uefi21Wrapper.c
+//
+// 14 6/15/11 4:46p Arunsb
+// [TAG] EIP61650
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Cannot edit time field when using new "time" format
+// [RootCause] Default refresh interval set to all the time variables
+// [Solution] Control refreshed only if refresh flag set.
+// [Files] time.c, date.c, parse.c and uefihpktool.exe
+//
+// 13 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 12 12/02/10 2:34p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 11 11/30/10 2:07p Blaines
+// [TAG] - EIP 48979
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- Both Date & Time controls of setup menu do not display
+// gray-out color when the controls are in the gray-out state.
+//
+// [Rootcause] - Improper use of color variable for Date and Time controls
+// in the draw function.
+// [Solution] - Proper use of color variables to handle normal and
+// gray-out state for these controls.
+// [Files] - date.c and time.c
+//
+// 10 11/17/10 3:09p Madhans
+// [TAG] - EIP 48433
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- While editing Date and Time control pressing
+// Pageup/PageDown/Home keys
+// causes to leave Date&Time in the Edit state but changes foucs.
+// [Rootcause] - Default case of Action handling not done for Date and
+// Time controls.
+// [Solution] - Add the Default action handle caes for this controls.
+// [Files] - date.c and time.c
+//
+// 8 11/10/10 6:59p Blaines
+// Fix issue with date control not calling the proper uefi2.1 funtion to
+// set date.
+//
+// 7 6/04/10 12:53p Blaines
+// Add support for UEFI 2.1 date and time controls
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/17/10 7:03p Madhans
+// To suppor readonly control
+//
+// 5 1/09/10 6:48a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/18/09 6:35p Blaines
+// Support additional date styles
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/20/09 3:42p Blaines
+// Update support for date format
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 4:07p Madhans
+// Fix for EDK version
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Date.c
+//
+// Description: This file contains code to handle Date control operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+DATE_METHODS gDate =
+{
+ DateCreate,
+ DateDestroy,
+ DateInitialize,
+ DateDraw,
+ DateHandleAction,
+ DateSetCallback,
+ DateSetFocus,
+ DateSetPosition,
+ DateSetDimensions,
+ DateSetAttributes,
+ DateGetControlHeight
+
+};
+BOOLEAN CheckKeyinHotKeysList(AMI_EFI_KEY_DATA Key);
+VOID _DateUpdateEntry(DATE_DATA *time);
+EFI_STATUS _DateHandleActionKeyMouse(DATE_DATA *date, ACTION_DATA *Data);
+UINT16 DayNames[] =
+{
+ STRING_TOKEN(STR_DAY_SUNDAY),
+ STRING_TOKEN(STR_DAY_MONDAY),
+ STRING_TOKEN(STR_DAY_TUESDAY),
+ STRING_TOKEN(STR_DAY_WEDNESDAY),
+ STRING_TOKEN(STR_DAY_THURSDAY),
+ STRING_TOKEN(STR_DAY_FRIDAY),
+ STRING_TOKEN(STR_DAY_SATURDAY),
+};
+
+CHAR16 DateTempNum[5];
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateCreate
+//
+// Description: Function to create the date, which uses the Control fucntions.
+//
+// Input: DATE_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateCreate( DATE_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(DATE_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gDate;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateDestroy
+//
+// Description: Function to destroy the date, which uses the Control fucntions.
+//
+// Input: DATE_DATA *date, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateDestroy( DATE_DATA *date, BOOLEAN freeMem )
+{
+ if(NULL == date)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( date, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&date );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateInitialize
+//
+// Description: Function to initialize the date, which uses the Control fucntions.
+//
+// Input: DATE_DATA *date, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateInitialize( DATE_DATA *date, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( date, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ date->ControlData.ControlHelp = UefiGetHelpField(date->ControlData.ControlPtr);
+ date->Interval = (UINT8)date->ControlData.ControlFlags.ControlRefresh;
+ date->LabelMargin = (UINT8)gControlLeftMargin;
+ date->Sel = 0;
+ date->ControlFocus = FALSE;
+ date->ControlActive = FALSE;
+
+ SetControlColorsHook(NULL, NULL,
+ NULL, &(date->FGColor),
+ &(date->SelBGColor), &(date->SelFGColor),
+ &(date->BGColor), &(date->NSelFGColor),
+ NULL, &(date->LabelFGColor),
+ &(date->NSelLabelFGColor),
+ NULL, NULL,
+ NULL, NULL );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateInitialize
+//
+// Description: Function to draw the date.
+//
+// Input: DATE_DATA *date
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateDraw( DATE_DATA *date )
+{
+ CHAR16 *t,text[50],txt[5];
+ UINTN day;
+ EFI_TIME Tm;
+ UINTN nIndex,nDateLen,nEFIDateLen,i = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorDate = date->NSelFGColor /*date->FGColor*/ , NScolor,SColor;
+ UINT16 MarginLeft = date->Left + date->LabelMargin;
+ UINT8 ColorLabelDate = (date->ControlFocus) ? date->LabelFGColor:date->NSelLabelFGColor ;
+ BOOLEAN bShowDay = StyleShowDay() ;
+ UINTN dateFormat = StyleGetDateFormat() ;
+ //gRT->GetTime(&Tm,NULL);
+ UefiGetTime(&date->ControlData, &Tm);
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if ( date->ControlData.ControlConditionalPtr != 0x0 )
+ //{
+ switch( CheckControlCondition( &date->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorDate = ColorLabelDate = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ NScolor = date->BGColor | ColorDate;
+ SColor = date->SelBGColor | date->SelFGColor;
+
+ // label
+ t = HiiGetString( date->ControlData.ControlHandle, UefiGetPromptField(date->ControlData.ControlPtr));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == t){
+ t = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!t)
+ return EFI_NOT_FOUND;
+ EfiStrCpy(t,L" ");
+ }
+ // boundary overflow check
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(date->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( date->Left , date->Top,
+ (UINTN)(date->LabelMargin - date->Left ),(UINTN) date->Height,
+ t, date->BGColor | ColorLabelDate );
+ }
+ else
+ {
+ if ( (TestPrintLength(t) / (NG_SIZE)) > (UINTN)(date->LabelMargin - date->Left )/*21*/ )
+ t[date->LabelMargin - date->Left ] = L'\0';
+
+ DrawStringWithAttribute( date->Left , date->Top, (CHAR16*)t,
+ date->BGColor | ColorLabelDate );
+ }
+ MemFreePointer ((VOID **)&t);
+
+ day = _DateGetWeekDay( &Tm );
+
+ t = HiiGetString( gHiiHandle, (bShowDay)? DayNames[day]:STRING_TOKEN(STR_EMPTY_STRING));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == t){
+ t = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!t)
+ return EFI_NOT_FOUND;
+ EfiStrCpy(t,L" ");
+ }
+
+ nIndex = TestPrintLength(t) / (NG_SIZE);
+ nDateLen = TestPrintLength(t) / (NG_SIZE);
+ nEFIDateLen = EfiStrLen(t);
+
+ if ( t != NULL )
+ {
+ SPrint( text, sizeof(text), L"[%s ", t );
+ text[nEFIDateLen + 1] = L' ';
+ i = (bShowDay)? (nEFIDateLen + 2):(nEFIDateLen + 1);
+
+ if ((dateFormat == DATE_STYLE_MMDDYYYY) || (dateFormat == DATE_STYLE_DDMMYYYY))
+ EfiStrCpy(text+(i),L"XX/XX/XXXX]");
+ else
+ EfiStrCpy(text+(i),L"XXXX/XX/XX]");
+ }
+ MemFreePointer( (VOID **)&t );
+ i = (bShowDay)? (nDateLen + 2):(nDateLen + 1) ; //(StyleShowDay()==TRUE)?2:1;
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ , date->Top, (CHAR16*)text,
+ date->BGColor | ColorDate );
+
+ nIndex = i;
+
+ if ((dateFormat == DATE_STYLE_MMDDYYYY)||(dateFormat == DATE_STYLE_DDMMYYYY))
+ {
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==0) && (date->ControlActive == TRUE ) ) ? DateTempNum :StrZeroPad((dateFormat == DATE_STYLE_MMDDYYYY)?Tm.Month:Tm.Day,txt),
+ (UINT8)((((date->Sel == 0) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+
+ nIndex+=3;
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==1) && (date->ControlActive == TRUE ) ) ? DateTempNum :StrZeroPad((dateFormat == DATE_STYLE_MMDDYYYY)?Tm.Day:Tm.Month,txt),
+ (UINT8)( (((date->Sel == 1) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+
+ nIndex+=3;
+ if((Tm.Year < 1000) &&( atoi(DateTempNum, 10) < 1000))
+ SPrint(txt,sizeof(txt),L"%04d",Tm.Year); //Update the date string when year is ZERO.
+
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==2) && (date->ControlActive == TRUE ) ) ? DateTempNum :((Tm.Year < 1000) ? txt : StrZeroPad( Tm.Year,txt)),
+ (UINT8)( (((date->Sel == 2) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+ }
+ else
+ {
+
+ if((Tm.Year < 1000) &&( atoi(DateTempNum, 10) < 1000))
+ SPrint(txt,sizeof(txt),L"%04d",Tm.Year); //Update the date string when year is ZERO.
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==0) && (date->ControlActive == TRUE ) ) ? DateTempNum :((Tm.Year < 1000) ? txt : StrZeroPad( Tm.Year,txt)),
+ (UINT8)( (((date->Sel == 0) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+
+ nIndex+=5;
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==1) && (date->ControlActive == TRUE ) ) ? DateTempNum :StrZeroPad((dateFormat == DATE_STYLE_YYYYDDMM)?Tm.Day:Tm.Month,txt),
+ (UINT8)( (((date->Sel == 1) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+
+ nIndex+=3;
+ DrawStringWithAttribute( MarginLeft/*date->Left + date->LabelMargin*/ + nIndex , date->Top,
+ ( (date->Sel==2) && (date->ControlActive == TRUE ) ) ? DateTempNum :StrZeroPad((dateFormat == DATE_STYLE_YYYYDDMM)?Tm.Month:Tm.Day,txt),
+ (UINT8)((((date->Sel == 2) && (date->ControlFocus)) ?
+ SColor/*date->SelBGColor | date->SelFGColor*/ :
+ NScolor/*date->BGColor | ColorDate*/ )) );
+ }
+
+ FlushLines(date->Top, date->Top);
+ return Status;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateInitialize
+//
+// Description: Function to handle the date actions.
+//
+// Input: DATE_DATA *date, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateHandleAction( DATE_DATA *date, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if(date->ControlActive)
+ return Status;
+
+ if (0 == date->ControlData.ControlFlags.ControlRefresh) //EIP61650 If control not has refresh no need of proceeding
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if ( --(date->Interval) == 0 )
+ {
+ // initialize the interval
+ date->Interval = (UINT8)(date->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(date->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ if ( ! date->ControlFocus )
+ return Status;
+
+ if (( Data->Input.Type == ACTION_TYPE_KEY )||(Data->Input.Type == ACTION_TYPE_MOUSE))
+ return _DateHandleActionKeyMouse(date, Data);
+
+ return Status;
+}
+
+EFI_STATUS _DateHandleActionKeyMouse(DATE_DATA *date, ACTION_DATA *Data)
+{
+ CONTROL_ACTION Action;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_TIME Tm;
+ AMI_EFI_KEY_DATA key = Data->Input.Data.AmiKey;
+ UINTN dateFormat = StyleGetDateFormat() ;
+
+ if(date->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+ //Get time
+ //gRT->GetTime( &Tm, NULL );
+ UefiGetTime(&date->ControlData, &Tm);
+
+ //Get mapping
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ Action = MapControlKeysHook(key);
+ }
+ else if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ if(ControlActionSelect == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ {
+
+ //EIP-123727 check whether MouseTop is within the Height and Width of Date Control or not
+ if((Data->Input.Data.MouseInfo.Top >= (UINT32)date->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(date->Top+date->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)date->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(date->Left+date->Width)))//EIP-123727
+ {
+ Action = ControlActionSelect;
+ }
+ }
+ }
+
+ switch(Action)
+ {
+ case ControlActionNextLeft:
+#if SETUP_STYLE_AWARD
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+
+ if ( date->Sel == 0 )
+ date->Sel = 2;
+ else
+ date->Sel--;
+
+ Status = EFI_SUCCESS;
+ break;
+#endif
+
+ case ControlActionNextRight:
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+
+#if SETUP_STYLE_AWARD
+ if ( date->Sel == 2 )
+ date->Sel = 0;
+ else
+ date->Sel++;
+
+ Status = EFI_SUCCESS;
+#endif
+ break;
+
+ case ControlActionNextUp:
+ case ControlActionNextDown:
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+ break;
+
+ case ControlActionAbort:
+ if ( date->ControlActive )
+ {
+ date->ControlActive = FALSE;
+ Status = EFI_SUCCESS;
+ }
+ break;
+
+ case ControlActionSelect:
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ NumericSoftKbdInit();
+ _DateUpdateEntry(date);
+// for EZPORT: expressely to go to next entry in date control after hitting enter
+#if SETUP_STYLE_AWARD
+ break;
+#endif
+
+ case ControlActionNextSelection:
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+
+ if ( date->Sel == 2 )
+ date->Sel = 0;
+ else
+ date->Sel++;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionPrevSelection:
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+
+ if ( date->Sel == 0 )
+ date->Sel = 2;
+ else
+ date->Sel--;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionDecreament:
+ if(date->ControlActive)
+ {
+ _DateUpdateEntry(date);
+ }
+ _DateDecrease( date );
+ date->ControlActive = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionIncreament:
+ if(date->ControlActive)
+ {
+ _DateUpdateEntry(date);
+ }
+ _DateIncrease( date );
+ date->ControlActive = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionNumeric:
+ if( !(date->ControlActive) )
+ {
+ MemSet(DateTempNum, 10, 0x0);
+ date->ControlActive = TRUE;
+ switch(date->Sel)
+ {
+ case 0:
+ if((dateFormat == DATE_STYLE_YYYYDDMM) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year );
+ else if(dateFormat == DATE_STYLE_DDMMYYYY)
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Day);
+ else
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Month);
+ break;
+ case 1:
+ if((dateFormat == DATE_STYLE_DDMMYYYY) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Month);
+ else
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Day);
+ break;
+ case 2:
+ if(dateFormat == DATE_STYLE_YYYYDDMM)
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Month);
+ else if(dateFormat == DATE_STYLE_YYYYMMDD)
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%d",Tm.Day);
+ else
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year );
+ break;
+ }
+ }
+
+ if(EfiStrLen(DateTempNum)>1)
+ DateTempNum[0] =DateTempNum[1];
+
+ if (
+ ( (2 == date->Sel) && (DATE_STYLE_MMDDYYYY == dateFormat || DATE_STYLE_DDMMYYYY == dateFormat) ) ||
+ ( (0 == date->Sel) && (DATE_STYLE_YYYYDDMM == dateFormat || DATE_STYLE_YYYYMMDD == dateFormat) )
+ )
+ {
+ DateTempNum[1] =DateTempNum[2];
+ DateTempNum[2] =DateTempNum[3];
+ DateTempNum[3] = key.Key.UnicodeChar;
+ }else
+ DateTempNum[1] = key.Key.UnicodeChar;
+
+ Status = gDate.Draw(date);
+ break;
+
+ default:
+ if ( date->ControlActive )
+ _DateUpdateEntry(date);
+ break;
+ }
+
+ if( (((!date->ControlActive)||(!IsMouseClickedonSoftkbd())) && (TSEMouseIgnoreMouseActionHook() == TRUE) )&&
+ (((Data->Input.Type == ACTION_TYPE_KEY) &&
+ ((Action == ControlActionNextLeft) ||(Action == ControlActionNextRight) ||(Action == ControlActionNextUp) ||(Action == ControlActionNextDown) ||(Action == ControlActionPageUp) ||(Action == ControlActionPageDown) ||(Action == ControlActionAbort) ||(Action == ControlActionHome) ||(Action == ControlActionEnd) ||(CheckKeyinHotKeysList(key))) ) ||
+ ((Data->Input.Type == ACTION_TYPE_MOUSE)&&((!((Data->Input.Data.MouseInfo.Top >= (UINT32)date->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(date->Top+date->Height))&&(Data->Input.Data.MouseInfo.Left >= (UINT32)date->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(date->Left+date->Width))))||(Action == ControlActionAbort))))
+ )
+ {
+ NumericSoftKbdExit();//EIP62763 : Check for softkbd presence and existing the numeric softkbd
+ }
+
+ _DateUpdateHelp( date );
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: DATE_DATA *date, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateSetCallback( DATE_DATA *date, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateSetFocus
+//
+// Description: Function to set the Date focus.
+//
+// Input: DATE_DATA *date, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateSetFocus( DATE_DATA *date, BOOLEAN focus)
+{
+ if(focus != FALSE)
+ {
+ if ( CheckControlCondition( &date->ControlData ) )
+ return EFI_UNSUPPORTED;
+ }
+
+ if( !(date->ControlFocus && focus) )
+ {
+ date->ControlFocus = focus;
+
+ // set the selected field to Month
+ date->Sel = 0;
+ _DateUpdateHelp( date );
+ }
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateSetPosition
+//
+// Description: Function to set the date position.
+//
+// Input: DATE_DATA *date, UINT16 Left, UINT16 Top
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateSetPosition( DATE_DATA *date, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( date, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateSetDimensions
+//
+// Description: Function to set the date dimensions.
+//
+// Input: DATE_DATA *date, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateSetDimensions( DATE_DATA *date, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( date, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateSetAttributes
+//
+// Description: Function to set the date attributes.
+//
+// Input: DATE_DATA *date, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateSetAttributes( DATE_DATA *date, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( date, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DateGetControlHeight
+//
+// Description: Function to get the data label height.
+//
+// Input: DATE_DATA *date, frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DateGetControlHeight(DATE_DATA *date, VOID * frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ *height = 1;
+ Width = (UINT16)(date->LabelMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gControlLeftPad));
+
+ text = HiiGetString( date->ControlData.ControlHandle, UefiGetPromptField(date->ControlData.ControlPtr) );
+ newText = StringWrapText( text, Width, height );
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DateGetWeekDay
+//
+// Description: Function to get weekday.
+//
+// Input: EFI_TIME *tm
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _DateGetWeekDay( EFI_TIME *tm )
+{
+ //EIP-75384 Static Code
+ //EIP-80092
+ INTN d, m, y, c;
+ INTN w;
+
+ d = tm->Day;
+ m = tm->Month - 2;
+ y = tm->Year;
+
+ if ( m <= 0 )
+ {
+ m += 12;
+ y--;
+ }
+
+ c = y / 100;
+ y %= 100;
+
+ w = d + y + (5 * c) + ((13 * m - 1) / 5) + (y / 4) + (c / 4);
+
+ return w % 7;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DateDecrease
+//
+// Description: Function to decrement date.
+//
+// Input: DATE_DATA *date
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DateDecrease( DATE_DATA *date )
+{
+ EFI_TIME Tm;
+ BOOLEAN Case_day = FALSE;
+ UINTN dateFormat = StyleGetDateFormat() ;
+
+ //gRT->GetTime( &Tm, NULL );
+ UefiGetTime(&date->ControlData, &Tm);
+
+ switch ( date->Sel )
+ {
+ case 0:
+ if((dateFormat == DATE_STYLE_YYYYDDMM) || (dateFormat == DATE_STYLE_YYYYMMDD)){
+ Tm.Year--;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //Update the static date string
+ }else if(dateFormat == DATE_STYLE_DDMMYYYY)
+ {
+ if ( Tm.Day > 1 )
+ Tm.Day--;
+ else
+ Tm.Day = 31; // this is to find out wich is the highest day for the month.
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ }else{
+ if ( Tm.Month > 1 )
+ Tm.Month--;
+ else
+ Tm.Month = 12;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ }
+ break;
+ case 1:
+ if((dateFormat == DATE_STYLE_DDMMYYYY) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ {
+ if ( Tm.Month > 1 )
+ Tm.Month--;
+ else
+ Tm.Month = 12;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ }else{
+ if ( Tm.Day > 1 )
+ Tm.Day--;
+ else
+ Tm.Day = 31; // this is to find out wich is the highest day for the month.
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ }
+ break;
+ case 2:
+ if(dateFormat == DATE_STYLE_YYYYDDMM)
+ {
+ if ( Tm.Month > 1 )
+ Tm.Month--;
+ else
+ Tm.Month = 12;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ }else if(dateFormat == DATE_STYLE_YYYYMMDD){
+ if ( Tm.Day > 1 )
+ Tm.Day--;
+ else
+ Tm.Day = 31; // this is to find out wich is the highest day for the month.
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ }else{
+ Tm.Year--;
+ if(Tm.Year > 9999)
+ Tm.Year = 9999;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //Update the static date string
+ }
+ break;
+ }
+
+ while ( UefiSetTime(&date->ControlData, &Tm) != EFI_SUCCESS )
+ {
+ if(Tm.Day > 28){
+ Tm.Day--; //May be this month does not support days greater than 28
+ if(Case_day == TRUE)
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ } else{
+ //EIP 79487:SetTime failed due to year decremented beyound the range
+ Tm.Year++;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //Update the static date string
+ UefiSetTime(&date->ControlData, &Tm);
+ break; //SetTime failed due to some other error keep time unchanged.
+ }
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DateIncrease
+//
+// Description: Function to increment date.
+//
+// Input: DATE_DATA *date
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DateIncrease( DATE_DATA *date )
+{
+ EFI_TIME Tm;
+ UINTN dateFormat = StyleGetDateFormat() ;
+ BOOLEAN Case_day = FALSE;
+
+ //gRT->GetTime( &Tm, NULL );
+ UefiGetTime(&date->ControlData, &Tm);
+
+ switch ( date->Sel )
+ {
+ case 0:
+ if((dateFormat == DATE_STYLE_YYYYDDMM) || (dateFormat == DATE_STYLE_YYYYMMDD)){
+ Tm.Year++;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //Update the static date string
+ } else if(dateFormat == DATE_STYLE_DDMMYYYY){
+ if(Tm.Day < 31){
+ Tm.Day++;
+ } else{
+ Tm.Day = 1;
+ }
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ } else{
+ if ( Tm.Month < 12 )
+ Tm.Month++;
+ else
+ Tm.Month = 1;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ }
+ break;
+ case 1:
+ if((dateFormat == DATE_STYLE_DDMMYYYY) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ {
+ if ( Tm.Month < 12 )
+ Tm.Month++;
+ else
+ Tm.Month = 1;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ } else{
+ if(Tm.Day < 31){
+ Tm.Day++;
+ } else{
+ Tm.Day = 1;
+ }
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ }
+ break;
+ case 2:
+ if(dateFormat == DATE_STYLE_YYYYDDMM)
+ {
+ if ( Tm.Month < 12 )
+ Tm.Month++;
+ else
+ Tm.Month = 1;
+ StrZeroPad(Tm.Month, DateTempNum); //Update the static date string
+ }else if(dateFormat == DATE_STYLE_YYYYMMDD){
+ if(Tm.Day < 31){
+ Tm.Day++;
+ } else{
+ Tm.Day = 1;
+ }
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ Case_day = TRUE;
+ }else{
+ Tm.Year++;
+ if(Tm.Year > 9999)
+ Tm.Year = 0;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //Update the static date string
+ }
+ break;
+ }
+
+ //if ( gRT->SetTime( &Tm ) != EFI_SUCCESS )
+ if ( UefiSetTime(&date->ControlData, &Tm) != EFI_SUCCESS )
+ {
+ //SetTime may be failed because of invalid day try with
+ //day = 1
+ Tm.Day = 1;
+ if(Case_day == TRUE)//EIP 79487
+ StrZeroPad(Tm.Day, DateTempNum); //Update the static date string
+ if(UefiSetTime(&date->ControlData, &Tm) != EFI_SUCCESS)
+ {
+ Tm.Year--;
+ SPrint(DateTempNum,sizeof(DateTempNum),L"%04d",Tm.Year); //EIP 79487:Update the static date string
+ UefiSetTime(&date->ControlData, &Tm); //If this second SetTime also fails dont worry the time didnt change
+ }
+
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DateUpdateEntry
+//
+// Description: Function to update entry.
+//
+// Input: DATE_DATA *date
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DateUpdateEntry(DATE_DATA *date)
+{
+ EFI_TIME Tm = {0};
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN dateFormat = StyleGetDateFormat() ;
+
+ //gRT->GetTime( &Tm, NULL );
+ UefiGetTime(&date->ControlData, &Tm);
+
+ if(date->ControlActive)
+ {
+ // focus stays on the selection becuase we just edited it
+ switch(date->Sel)
+ {
+ case 0:
+ if((dateFormat == DATE_STYLE_YYYYDDMM) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ Tm.Year = (UINT16)atoi(DateTempNum, 10);
+ else if(dateFormat == DATE_STYLE_DDMMYYYY)
+ Tm.Day = (UINT8)atoi(DateTempNum, 10);
+ else
+ Tm.Month = (UINT8)atoi(DateTempNum, 10);
+ break;
+ case 1:
+ if((dateFormat == DATE_STYLE_DDMMYYYY) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ Tm.Month = (UINT8)atoi(DateTempNum, 10);
+ else
+ Tm.Day = (UINT8)atoi(DateTempNum, 10);
+ break;
+ case 2:
+ if(dateFormat == DATE_STYLE_YYYYDDMM)
+ Tm.Month = (UINT8)atoi(DateTempNum, 10);
+ else if(dateFormat == DATE_STYLE_YYYYMMDD)
+ Tm.Day = (UINT8)atoi(DateTempNum, 10);
+ else
+ Tm.Year = (UINT16)atoi(DateTempNum, 10);
+ break;
+ }
+
+ UefiPreControlUpdate(&(date->ControlData));
+ UefiSetTime(&date->ControlData, &Tm);
+ //For interactive date control invoke the formcallback functions
+ if(UefiIsInteractive(&date->ControlData)){
+ UINT8 Flags = UefiGetFlagsField(date->ControlData.ControlPtr) ;
+
+ if(CheckDateFlags(Flags))
+ {
+ //for storage type QF_DATE_STORAGE_NORMAL generate time in EFI_HII_DATE format
+
+ //Call the callbacks passing the generated input value and value size
+ Status = CallFormCallBack(&date->ControlData, UefiGetControlKey(&date->ControlData), 0, AMI_CALLBACK_CONTROL_UPDATE);
+ }// else {
+ //This case would be handled by UefiSetTime() outside using runtime services
+ //}
+ }
+
+ date->ControlActive = FALSE;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DateUpdateHelp
+//
+// Description: Function to update help.
+//
+// Input: DATE_DATA *date
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _DateUpdateHelp( DATE_DATA *date )
+{
+ UINT16 helpToken = date->ControlData.ControlHelp;
+ UINT16 Min,Max;
+ UINTN dateFormat = StyleGetDateFormat() ;
+
+ switch ( date->Sel )
+ {
+ case 0:
+ if((dateFormat == DATE_STYLE_YYYYDDMM) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_YEAR,&helpToken,&Min,&Max);
+ else if(dateFormat == DATE_STYLE_DDMMYYYY)
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_DAY,&helpToken,&Min,&Max);
+ else
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_MONTH,&helpToken,&Min,&Max);
+ break;
+ case 1:
+ if((dateFormat == DATE_STYLE_DDMMYYYY) || (dateFormat == DATE_STYLE_YYYYMMDD))
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_MONTH,&helpToken,&Min,&Max);
+ else
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_DAY,&helpToken,&Min,&Max);
+ break;
+ case 2:
+ if(dateFormat == DATE_STYLE_YYYYDDMM)
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_MONTH,&helpToken,&Min,&Max);
+ else if(dateFormat == DATE_STYLE_YYYYMMDD)
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_DAY,&helpToken,&Min,&Max);
+ else
+ UefiGetDateTimeDetails(date->ControlData.ControlPtr,AMI_DATE_YEAR,&helpToken,&Min,&Max);
+ break;
+ default:
+ break;
+ }
+
+ date->ControlData.ControlHelp = helpToken;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Date.h b/EDK/MiniSetup/TseLite/Date.h
new file mode 100644
index 0000000..d833eb8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Date.h
@@ -0,0 +1,181 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Date.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Date.h $
+//
+// 9 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 11/21/11 12:10p Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 7 6/04/10 12:53p Blaines
+// Add support for UEFI 2.1 date and time controls
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/20/09 3:42p Blaines
+// Update support for date format
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Date.h
+//
+// Description: Header file for Date controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _DATE_H_
+#define _DATE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+#define DATE_MEMBER_VARIABLES \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT8 LabelMargin; \
+ UINT8 Sel; \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT8 NSelFGColor; \
+ UINT16 Min; \
+ UINT16 Max; \
+ UINT8 Interval;
+
+typedef struct _DATE_METHODS DATE_METHODS;
+
+typedef struct _DATE_DATA
+{
+ DATE_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ DATE_MEMBER_VARIABLES
+
+}
+DATE_DATA;
+
+
+struct _DATE_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+};
+
+extern DATE_METHODS gDate;
+
+extern EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm);
+extern EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm);
+
+// Object Methods
+EFI_STATUS DateCreate( VOID **object );
+EFI_STATUS DateDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS DateInitialize( VOID *object, VOID *data );
+EFI_STATUS DateDraw( VOID *object );
+EFI_STATUS DateHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS DateSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS DateSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS DateSetPosition( VOID *object, UINT16 Left, UINT16 Top );
+EFI_STATUS DateSetDimensions( VOID *object, UINT16 Width, UINT16 Height );
+EFI_STATUS DateSetAttributes( VOID *object, UINT8 FGColor, UINT8 BGColor );
+EFI_STATUS DateGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+
+UINTN _DateGetWeekDay( EFI_TIME *tm );
+VOID _DateDecrease( DATE_DATA *date );
+VOID _DateIncrease( DATE_DATA *date );
+VOID _DateUpdateHelp( DATE_DATA *date );
+
+#define DATE_STYLE_MMDDYYYY 0
+#define DATE_STYLE_YYYYDDMM 1
+#endif /* _DATE_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Label.c b/EDK/MiniSetup/TseLite/Label.c
new file mode 100644
index 0000000..0b4c151
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Label.c
@@ -0,0 +1,523 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Label.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 15 $
+//
+// $Date: 9/05/14 6:25a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Label.c $
+//
+// 15 9/05/14 6:25a Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 14 5/02/14 9:32p Arunsb
+// EIP141986 changes reverted.
+//
+// 13 5/02/14 11:00a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 12 2/11/14 9:01p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 11 12/03/13 1:07p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 10 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 2/02/12 1:17p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 8 11/30/11 12:44a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 7 11/21/11 11:26a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 6 11/21/11 8:52a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 5 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Label.c
+//
+// Description: This file contains code to handle Label operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+LABEL_METHODS gLabel =
+{
+ LabelCreate,
+ LabelDestroy,
+ LabelInitialize,
+ LabelDraw,
+ LabelHandleAction,
+ LabelSetCallback,
+ LabelSetFocus,
+ LabelSetPosition,
+ LabelSetDimensions,
+ LabelSetAttributes,
+ LabelGetControlHeight
+
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelCreate
+//
+// Description: Function to create a Label, which uses the Control functions.
+//
+// Input: LABEL_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelCreate( LABEL_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(LABEL_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gLabel;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelDestroy
+//
+// Description: Function to destroy a Label, which uses the Control functions.
+//
+// Input: LABEL_DATA *label, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelDestroy( LABEL_DATA *label, BOOLEAN freeMem )
+{
+ if(NULL == label)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( label, FALSE );
+
+ MemFreePointer( (VOID **)&label->Text );
+
+ if( freeMem )
+ MemFreePointer( (VOID **)&label );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelInitialize
+//
+// Description: Function to Initialize a Label, which uses the Control functions.
+//
+// Input: LABEL_DATA *label, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelInitialize( LABEL_DATA *label, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( label, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ label->ControlData.ControlHelp = ((AMI_IFR_LABEL *)label->ControlData.ControlPtr)->Help;
+
+ SetControlColorsHook(NULL, NULL ,
+ NULL, NULL ,
+ &(label->SelBGColor), &(label->SelFGColor),
+ &(label->BGColor), &(label->FGColor),
+ NULL,NULL ,
+ NULL,NULL ,NULL,NULL,NULL );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelDraw
+//
+// Description: Function to draw a Label.
+//
+// Input: LABEL_DATA *label
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelDraw(LABEL_DATA *label )
+{
+ CHAR16 *text;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ UINT8 ColorLabel = label->FGColor;
+ // check conditional ptr if necessary
+
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( label->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &label->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text = HiiGetString( label->ControlData.ControlHandle, (UINT16)((AMI_IFR_LABEL*)(label->ControlData.ControlPtr))->Text );
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == text){
+ text = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!text)
+ return EFI_NOT_FOUND;
+ EfiStrCpy(text,L" ");
+ }
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(label->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( label->Left , label->Top,
+ (UINTN)(label->Width),(UINTN) label->Height,
+ text,(UINT8)( (label->ControlFocus) ?
+ label->SelBGColor | label->SelFGColor :
+ label->BGColor | ColorLabel ));
+ }
+ else
+ {
+ // use frame width minus margins as available space
+ // boundary overflow check
+ if ( (TestPrintLength( text) / (NG_SIZE)) > (UINTN)(label->Width))
+ text[HiiFindStrPrintBoundary(text,(UINTN)(label->Width))] = L'\0';
+
+ DrawStringWithAttribute( label->Left , label->Top, text,
+ (UINT8)( (label->ControlFocus) ?
+ label->SelBGColor | label->SelFGColor :
+ label->BGColor | ColorLabel /*label->FGColor*/ ));
+ }
+
+ MemFreePointer( (VOID **)&text );
+ FlushLines( label->Top , label->Top );
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: LABEL_DATA *label, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelSetCallback( LABEL_DATA *label, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( label, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelHandleAction
+//
+// Description: Function to handle the Label actions.
+//
+// Input: LABEL_DATA *label, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelHandleAction( LABEL_DATA *label, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ CONTROL_ACTION Action;
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ if(ControlActionSelect == Action)
+ {
+ // this notifies container to display a msgbox or boot, etc depending on cookie
+ if(label->Callback != NULL)
+ label->Callback( label->Container,label, label->Cookie );
+
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelSetFocus
+//
+// Description: Function to set the Label focus.
+//
+// Input: LABEL_DATA *label, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelSetFocus(LABEL_DATA *label, BOOLEAN focus)
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &label->ControlData );
+
+ //Setting focus to control which has no control-condtion and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to focus and selectable
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT))
+ ){
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+
+
+ if( !(label->ControlFocus && focus) )
+ label->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelSetPosition
+//
+// Description: Function to set position.
+//
+// Input: LABEL_DATA *label, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelSetPosition(LABEL_DATA *label, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( label, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: LABEL_DATA *label, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelSetDimensions(LABEL_DATA *label, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( label, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: LABEL_DATA *label, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelSetAttributes(LABEL_DATA *label, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( label, FGColor, BGColor );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LabelGetLabelHeight
+//
+// Description: Function to get label height.
+//
+// Input: LABEL_DATA *label, UINT16 Width, UINT16 *height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LabelGetControlHeight(LABEL_DATA *label, VOID * frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ *height = 1;
+ Width = ((FRAME_DATA*)frame)->FrameData.Width - 2;
+
+ text = HiiGetString( label->ControlData.ControlHandle, (UINT16)((AMI_IFR_LABEL*)(label->ControlData.ControlPtr))->Text );
+ newText = StringWrapText( text, Width, height );
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Label.h b/EDK/MiniSetup/TseLite/Label.h
new file mode 100644
index 0000000..6dffb0a
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Label.h
@@ -0,0 +1,160 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Label.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Label.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Label.h
+//
+// Description: Header file for Label controls.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _LABEL_H_
+#define _LABEL_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "action.h"
+#include "MessageBox.h"
+
+typedef struct _IFR_LABEL
+{
+ // this structure is, in some way, following EFI_IFR structures
+ UINT8 Opcode, Length;
+ UINT16 Text;
+ UINT16 Help;
+}
+AMI_IFR_LABEL;
+
+#define LABEL_MEMBER_VARIABLES \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ CHAR16 *Text;
+
+typedef struct _LABEL_METHODS LABEL_METHODS;
+
+typedef struct _LABEL_DATA
+{
+ LABEL_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ LABEL_MEMBER_VARIABLES
+
+}
+LABEL_DATA;
+
+#define LABEL_METHOD_FUNCTIONS
+
+struct _LABEL_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ LABEL_METHOD_FUNCTIONS
+
+};
+
+extern LABEL_METHODS gLabel;
+
+// Object Methods
+EFI_STATUS LabelCreate( VOID **object );
+EFI_STATUS LabelDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS LabelInitialize( VOID *object, VOID *data );
+EFI_STATUS LabelDraw( VOID *object );
+EFI_STATUS LabelHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS LabelSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS LabelSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS LabelSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS LabelSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS LabelSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS LabelGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+#endif /* _LABEL_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ListBox.c b/EDK/MiniSetup/TseLite/ListBox.c
new file mode 100644
index 0000000..fa7282c
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ListBox.c
@@ -0,0 +1,1436 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ListBox.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 32 $
+//
+// $Date: 5/03/14 3:11p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ListBox.c $
+//
+// 32 5/03/14 3:11p Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 31 5/02/14 3:54a Arunsb
+// [TAG] EIP155965
+// [Category] Improvement
+// [Description] MessageBox, ListBox cannot be canceled by Mouse
+// Right-Click
+// [Files] MessageBox.c, ListBox.c and minisetupext.c
+//
+// 30 2/11/14 9:03p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 29 12/05/13 1:25a Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 28 12/03/13 2:11p Premkumara
+// [TAG] EIP130420
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] String is getting truncated
+// [RootCause] The string for messagebox, Popup controls is getting
+// truncated
+// [Solution] Used temp variable to store original string and modify the
+// string temp and used to avoid changing org string.
+// [Files] String.c
+//
+// 27 1/22/13 12:21a Rajashakerg
+// [TAG] EIP103449
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In Setup click\Touch from navigation window, option are not
+// displayed properly
+// [RootCause] Latest mouse driver providing LEFT_DOWN when we hold the
+// mouse left down button.
+// [Solution] Provided fix resolves the issue.
+// [Files] ezport.c, PopupEdit.c, ListBox.c, MessageBox.c
+//
+// 26 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 26 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 24 9/21/12 8:40a Arunsb
+// Build error corrected
+//
+// 23 9/18/12 6:31a Arunsb
+// [TAG] EIP93686
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When string too long will hang on bbs menu
+// [RootCause] listbox->Width is not within the limit
+// [Solution] listbox->Width handled properly
+// [Files] ListBox.c
+//
+// 22 5/28/12 12:32p Premkumara
+// [TAG] EIP67049 & 90224
+// [Category] New Feature
+// [Description] Support mouse drag operation in frame and list box
+// [Files] CommonHelper.c, Frame.c, ListBox.c, Minisetupext.h
+//
+// 21 5/21/12 3:09a Arunsb
+// [TAG] EIP87658
+// [Category] Improvement
+// [Description] Baudrate 9600 refresh sreen twice. Removed screen
+// saving and restoring.
+// [Files] Listbox.c
+//
+// 20 1/20/12 4:11a Rajashakerg
+// [TAG] EIP78929
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Control selection using Mouse is not user friendly.
+// [RootCause] Updating the buffer with mouse click information provided
+// by mouse driver is improper.
+// [Solution] Updated the mouse click information properly to the buffer
+// which is used by tse to do action.
+// [Files] Action.c, frame.c ListBox.c
+//
+// 19 11/01/11 5:47a Arunsb
+// [Category] Improvement
+// [Description] To change the single click behaviour as like double
+// click
+// [Files] amitse.sdl, commonhelper.c, commonoem.c and listbox.c
+//
+// 18 10/19/11 1:00p Madhans
+// Fix to check for Listbox is NOT NULL before free the controls.
+//
+// 17 1/24/11 1:38p Blaines
+// [TAG] - EIP 48316
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- The keys "Caps Lock", "Scroll Lock" and "Num Lock" have
+// function and the function is the same as the key "Enter".
+// [Solution] - Check for valid listbox hot-keys before calling listbox
+// callback function.
+// [Function] - ListBoxHandleAction
+// [File] - listbox.c.
+//
+// 16 12/24/10 3:46p Mallikarjunanv
+// [TAG] EIP 45949
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS Setup hang when the control string length is long
+// [RootCause] List box title string is not truncated if it exceeds the
+// limit.
+// [Solution] Truncating the list box title string if it exceeds the
+// limit
+//
+// [Files] ListBox.c
+//
+// 15 12/24/10 11:38a Mallikarjunanv
+// [TAG] EIP48384
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Unable to select options in "Delete boot option", "Boot
+// [RootCause] In case of Listbox with scroll bar control is returned
+// without updating the selected control
+// [Solution] Fixed the issue with respect to List box selection using
+// mouse by commenting the return statement before selecting/highliting
+// the clicked control.
+// [Files] ListBox.c
+//
+// 14 11/18/10 7:24p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+//
+// [TAG] - EIP 48417
+// [Category]- Defect
+// [Symptom]- PostManagerDisplayMenu does not dynamically update Menu
+// Title on language change.
+//
+// [Solution]- Update listbox title string by calling HiiGetString
+// whenever a selection is made. redraws.
+// [Files] - listbox.c, minisetupext.c,
+//
+//
+//
+// 13 10/20/10 1:40p Mallikarjunanv
+// reverting back to v25
+//
+// 11 9/07/10 12:25a Mallikarjunanv
+// EIP-42124: Added Page up and Page down key in List box
+//
+// 10 8/12/10 11:30a Blaines
+// EIP-41614 : Change to allow DisplayPostMenu protocol to dynamically
+// update menu items modified from the callback functions.
+//
+// 9 6/15/10 10:47a Blaines
+// Fix issue where Listbox->PtrItems[] is refered in places even if the
+// style is not POPUP_STYLE_BBS.
+//
+// 8 6/04/10 12:58p Blaines
+// Add support for displaying menu list with (ALL) non-focusable items.
+//
+// 7 5/24/10 6:06p Blaines
+// Make sure selectable items are not hidden or non-focused in the
+// function ListBoxHandleAction.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 9 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 8 2/15/10 10:13p Madhans
+// To avoid warnings
+//
+// 7 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 6 1/09/10 6:51a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 8/26/09 4:11p Blaines
+// To fix issue with BBS popup when more then 20 bootoptions are present
+//
+// 4 8/19/09 12:54p Madhans
+// To return failure on invalid action.
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:08p Madhans
+// UefiGetOption Interface change..
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ListBox.c
+//
+// Description: This file contains code to handle Listbox controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//EIP-67049
+static INT32 lButtonVaryingPosition = 0;
+static INT32 lButtonInitialPosition = 0;
+BOOLEAN lButtonOnListBoxScroll = FALSE;
+BOOLEAN ScrollBarMoveAction = FALSE;
+static UINT32 gListBoxScrollBarTop = 0, gListBoxScrollBarBottom = 0;
+//EIP-67049 End
+LISTBOX_METHODS gListBox =
+{
+ ListBoxCreate,
+ ListBoxDestroy,
+ ListBoxInitialize,
+ ListBoxDraw,
+ ListBoxHandleAction,
+ ListBoxSetCallback,
+ ListBoxSetFocus,
+ ListBoxSetPosition,
+ ListBoxSetDimensions,
+ ListBoxSetAttributes,
+ ListBoxGetControlHight,
+ ListBoxInitializeBBSPopup
+};
+BOOLEAN SingleClickActivation (VOID); //EIP74141 providing select option for single click too
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxCreate
+//
+// Description: Function to create a List Box, which uses the popup controls.
+//
+// Input: LISTBOX_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxCreate( LISTBOX_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(LISTBOX_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gPopup.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gListBox;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxDestroy
+//
+// Description: Function to Destroy a List Box, which uses the popup controls.
+//
+// Input: LISTBOX_DATA *listbox, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxDestroy( LISTBOX_DATA *listbox, BOOLEAN freeMem )
+{
+ if(listbox == NULL)
+ return EFI_SUCCESS;
+
+ gPopup.Destroy( listbox, FALSE );
+
+ RestoreScreen( listbox->ScreenBuf );
+
+ if( freeMem )
+ {
+ MemFreePointer((VOID **)&listbox->Title);
+ MemFreePointer((VOID **)&listbox->PtrTokens);
+ MemFreePointer((VOID **)&listbox->PtrItems);
+ MemFreePointer((VOID **)&listbox->Help1);
+ MemFreePointer((VOID **)&listbox->Help2);
+ MemFreePointer((VOID **)&listbox->Help3);
+ MemFreePointer( (VOID **)&listbox );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetListBoxString
+//
+// Description: Function to set a string in List Box.
+//
+// Input: LISTBOX_DATA *listbox, CHAR16 **pStr,UINT16 Toke
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetListBoxString(LISTBOX_DATA *listbox, CHAR16 **pStr,UINT16 Token)
+{
+ CHAR16 *TempStr=NULL;
+ UINT16 TitleLength;
+
+ TempStr = HiiGetString( listbox->ControlData.ControlHandle, Token );
+
+ if ( TempStr != NULL )
+ {
+ TitleLength = (UINT16)((TestPrintLength( TempStr ) / (NG_SIZE)) + 3);
+
+ //EIP_45949 - Truncate the list box title if it exceeds the limit
+ if( TitleLength > gMaxCols-9 ){
+ TempStr[gMaxCols-9] = L'\0';
+ TitleLength = (UINT16)((TestPrintLength( TempStr ) / (NG_SIZE)) + 3);
+ }
+
+ if( listbox->Width < TitleLength + 4 )
+ listbox->Width = TitleLength + 4;
+ }
+ *pStr = TempStr;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetLineCount
+//
+// Description: function to get line count and max width.
+//
+// Input: CHAR16 *line, UINT8 *Width
+//
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN GetLineCount(CHAR16 *line, UINT8 *Width )
+{
+ CHAR16 * text;
+ UINTN i=1;
+ CHAR16 * String=line;
+ UINT8 length;
+
+ while(1)
+ {
+ CHAR16 save;
+
+ text = String;
+ if ( *String == L'\0' )
+ break;
+
+ while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) )
+ String++;
+
+ save = *String;
+ *String = L'\0';
+
+ length = 0 ;
+ length = (UINT8)((TestPrintLength(text) / (NG_SIZE))) ;
+ if(length > *Width)
+ *Width = length ;
+
+ if ( ( *String = save ) != L'\0' )
+ {
+ if ( *String == L'\r' )
+ { String++;
+ i--;
+ }
+ if ( *String == L'\n' )
+ {
+ String++;
+
+ if ( *(String - sizeof(CHAR16)) == L'\r' )
+ i++;
+ }
+ }
+ else
+ break;
+ i++;
+ }
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetListBoxHelpString
+//
+// Description: Function to set a string in List Box.
+//
+// Input: LISTBOX_DATA *listbox, CHAR16 **pStr,UINT16 Toke
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetListBoxHelpString(LISTBOX_DATA *listbox, CHAR16 **pStr,UINT16 Token)
+{
+ CHAR16 *TempStr=NULL;
+ UINT8 Width=0 ;
+
+ TempStr = HiiGetString( listbox->ControlData.ControlHandle, Token );
+
+ if ( TempStr != NULL )
+ {
+ GetLineCount(TempStr, &Width);
+
+ if( listbox->Width < Width + 4 )
+ listbox->Width = Width + 4;
+ }
+ *pStr = TempStr;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetListBoxString
+//
+// Description: Function to set the common fields in a List Box.
+//
+// Input: LISTBOX_DATA *listbox
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetListBoxCommonFields(LISTBOX_DATA *listbox)
+{
+
+ listbox->Width += 4;
+ listbox->Sel = 0;
+
+ // check if we need to use do srollbar
+ if(listbox->Height > MAX_VISIBLE_SELECTIONS )
+ {
+ listbox->Height = (UINT16)MAX_VISIBLE_SELECTIONS;
+ listbox->Width++; // ad space for the scrollbar.
+ listbox->FirstVisibleSel = 0;
+ listbox->LastVisibleSel = listbox->Height-3; // 2 for borders and 1 more because is zero based.
+
+ }
+ else
+ {
+ listbox->FirstVisibleSel = 0;
+ listbox->LastVisibleSel = listbox->Height-3;
+ }
+ SetControlColorsHook(NULL, NULL, NULL, NULL ,NULL, NULL,
+ NULL , NULL,NULL, NULL, NULL,NULL ,NULL,
+ &(listbox->FGColor),&(listbox->BGColor));
+
+ listbox->Border =TRUE;
+ listbox->Shadow = TRUE;
+ if(listbox->ScreenBuf == NULL)
+ listbox->ScreenBuf = SaveScreen();
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetListBoxString
+//
+// Description: Function to initialize a List Box, which uses the Popup controls.
+//
+// Input: LISTBOX_DATA *listbox, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxInitialize( LISTBOX_DATA *listbox, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 TempLength=0;
+ UINT16 TitleToken;
+ UINT16 Index= 0 ;
+
+ Status = gPopup.Initialize( listbox, data );
+ if (EFI_ERROR(Status))
+ return Status;
+ // add extra initialization here...
+ listbox->ControlData.ControlHelp = UefiGetHelpField(listbox->ControlData.ControlPtr);
+
+ listbox->ListHandle = listbox->ControlData.ControlHandle;
+ listbox->HiddenItemCount = 0;
+ Status = UefiGetOneOfOptions(&listbox->ControlData,&listbox->ListHandle,&listbox->PtrTokens, NULL, &listbox->ItemCount,NULL,NULL);
+
+ if ( ! EFI_ERROR(Status) )
+ {
+
+ for ( Index = 0; Index < listbox->ItemCount; Index++ )
+ {
+ TempLength = (UINT16)HiiMyGetStringLength( listbox->ListHandle, listbox->PtrTokens[Index] );
+
+ if ( TempLength > listbox->Width )
+ listbox->Width = TempLength;
+ }
+ if (listbox->Width > (gMaxCols-6))
+ listbox->Width = (UINT16)(gMaxCols-6);
+
+ listbox->ItemCount = Index;
+ listbox->Height = Index + 2;
+
+ //pad title
+ TitleToken = UefiGetPromptField(listbox->ControlData.ControlPtr);
+ SetListBoxString(listbox,&listbox->Title ,TitleToken);
+ SetListBoxCommonFields(listbox);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetListBoxString
+//
+// Description: Function to initialize the BBS Popup in a List Box.
+//
+// Input: LISTBOX_DATA *listbox, LISTBOX_BSS_POPUP_DATA *listboxBBSPopupData
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxInitializeBBSPopup( LISTBOX_DATA *listbox, LISTBOX_BSS_POPUP_DATA *listboxBBSPopupData )
+{
+ UINT16 Index= 0 ;
+ UINT16 TempLength=0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ listbox->Style = POPUP_STYLE_BBS;
+
+ if(listboxBBSPopupData->pControlData != NULL )
+ MemCopy( &listbox->ControlData, listboxBBSPopupData->pControlData, sizeof(CONTROL_INFO) );
+
+ listbox->ListHandle = listbox->ControlData.ControlHandle;
+ listbox->ItemCount = listboxBBSPopupData->ItemCount;
+ listbox->HiddenItemCount = listboxBBSPopupData->HiddenItemCount;
+ listbox->Height = listbox->ItemCount - listbox->HiddenItemCount + 2;
+
+ listbox->PtrItems = EfiLibAllocatePool( listbox->ItemCount * sizeof(POSTMENU_TEMPLATE) );
+ if ( listbox->PtrItems == NULL )
+ Status = EFI_OUT_OF_RESOURCES;
+ else
+ {
+ for ( Index = 0; Index < listbox->ItemCount; Index++ )
+ {
+ listbox->PtrItems[Index] = listboxBBSPopupData->PtrItems[Index] ;
+
+ if((listbox->PtrItems[Index].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (listbox->PtrItems[Index].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ TempLength = (UINT16)HiiMyGetStringLength( listbox->ListHandle, listbox->PtrItems[Index].ItemToken );
+
+ if ( TempLength > listbox->Width )
+ listbox->Width = TempLength;
+ }
+ }
+ if (listbox->Width > (gMaxCols-6))
+ listbox->Width = (UINT16)(gMaxCols-6);
+
+ if(listboxBBSPopupData->TitleToken)
+ SetListBoxString(listbox,&listbox->Title ,listboxBBSPopupData->TitleToken);
+ if(listboxBBSPopupData->Help1Token)
+ SetListBoxHelpString(listbox,&listbox->Help1 ,listboxBBSPopupData->Help1Token);
+ //SetListBoxString(listbox,&listbox->Help2 ,listboxBBSPopupData->Help2Token);
+ //SetListBoxString(listbox,&listbox->Help3 ,listboxBBSPopupData->Help3Token);
+ SetListBoxCommonFields(listbox);
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure : ListBoxDrawSeperator
+//
+// Description : function to draw the border
+//
+// Input : UINTN Left, UINTN Top, UINTN Width, UINTN Height
+//
+// Output : void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ListBoxDrawSeperator( LISTBOX_DATA *listbox, UINTN Left, UINTN Top, UINTN Width, UINTN Height )
+{
+ UINTN Index;
+ CHAR16 *Line;
+
+ UINTN Right, Bottom;
+
+ Line = EfiLibAllocateZeroPool( (Width + 6) * sizeof(CHAR16) );
+
+ if ( Line == NULL )
+ return;
+
+ Right = Left + Width - 1;
+ Bottom = Top + Height - 1;
+
+ for ( Index = 1; Index < Width - 1; Index++ )
+ Line[Index] = BOXDRAW_HORIZONTAL;
+
+ if(listbox->Border)
+ {
+ Line[0] = BOXDRAW_VERTICAL_RIGHT;
+
+ if(!listbox->UseScrollbar)
+ Line[Index] = BOXDRAW_VERTICAL_LEFT;
+
+ DrawString( Left, Top, Line );
+ }
+
+
+
+ MemFreePointer( (VOID **)&Line );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxDraw
+//
+// Description: Function to draw a List Box.
+//
+// Input: LISTBOX_DATA *listbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxDraw( LISTBOX_DATA *listbox )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN Index;
+ CHAR16 *text = NULL;
+ UINT32 FirstLine = 0, LastLine = 0;
+ CHAR16 ArrUp[2]={{GEOMETRICSHAPE_UP_TRIANGLE},{0x0000}},ArrDown[2]={{GEOMETRICSHAPE_DOWN_TRIANGLE},{0x0000}},ScrlSel[2]={{BLOCKELEMENT_FULL_BLOCK/*L'N'*/},{0x0000}},ScrlNSel[2]={{BLOCKELEMENT_LIGHT_SHADE/*L'S'*/},{0x0000}};
+ UINT16 BorderWidth = 4;
+ UINT8 FGColor = listbox->FGColor;
+ UINT8 BGColor = listbox->BGColor;
+
+
+ Status = gPopup.Draw( listbox );
+ if (Status != EFI_SUCCESS)
+ return Status;
+
+ listbox->UseScrollbar = FALSE;
+
+
+ // check if we need to use do scrollbar
+ if((listbox->ItemCount-listbox->HiddenItemCount) > (UINT16)(MAX_VISIBLE_SELECTIONS - 2))
+ {
+ listbox->UseScrollbar = TRUE ;
+ BorderWidth = 5;
+ //EIP-67049
+ if (!ScrollBarMoveAction)
+ {
+ if( listbox->Sel < listbox->FirstVisibleSel)
+ {
+ if((listbox->Sel != 0) && (listbox->Sel < listbox->LastVisibleSel -1))
+ {
+ listbox->FirstVisibleSel = listbox->Sel;
+ listbox->LastVisibleSel = listbox->Sel + listbox->Height -3 ;
+ }
+ else
+ {
+ if( listbox->Sel !=0)
+ {
+ listbox->FirstVisibleSel = listbox->Sel /*--*/;
+ listbox->LastVisibleSel = listbox->FirstVisibleSel + listbox->Height -3;
+ }
+ else
+ {
+ listbox->FirstVisibleSel = 0 ;
+ listbox->LastVisibleSel = listbox->Height -3;
+ }
+ }
+ }
+
+ if(listbox->Sel > listbox->LastVisibleSel )
+ {
+ if( (( listbox->Sel +listbox->Height-3) <= (listbox->ItemCount-listbox->HiddenItemCount-1) ) && (listbox->Sel > listbox->LastVisibleSel +1))
+ {
+ listbox->FirstVisibleSel = listbox->Sel;
+ listbox->LastVisibleSel = listbox->Sel + listbox->Height -3 ;
+ }
+ else
+ {
+ if( (listbox->Sel ) < (listbox->ItemCount-listbox->HiddenItemCount-1))
+ {
+ listbox->FirstVisibleSel = listbox->Sel - listbox->Height +3 /*--*/;
+ listbox->LastVisibleSel = listbox->Sel;
+ }
+ else
+ {
+ listbox->FirstVisibleSel = listbox->ItemCount-listbox->HiddenItemCount-1 - listbox->Height +3 ;
+ listbox->LastVisibleSel = listbox->ItemCount-listbox->HiddenItemCount-1;
+ }
+ }
+ }
+ }
+
+ // draw the scrollbar
+ DrawStringWithAttribute( listbox->Left + listbox->Width -2 , listbox->Top+1, ArrUp,
+ listbox->FGColor | listbox->BGColor );
+
+ DrawStringWithAttribute( listbox->Left+ listbox->Width -2, listbox->Top + listbox->Height-2, ArrDown,
+ listbox->FGColor | listbox->BGColor );
+
+ FirstLine = ((listbox->Height-2)* listbox->FirstVisibleSel/(listbox->ItemCount-listbox->HiddenItemCount) )+ listbox->Top+2;
+ LastLine = ((listbox->Height-2)* listbox->LastVisibleSel/(listbox->ItemCount-listbox->HiddenItemCount) )+ listbox->Top+2;
+
+ gListBoxScrollBarTop = FirstLine; //EIP-67049 To store Scrollbar Top positon
+ gListBoxScrollBarBottom = LastLine; //EIP-67049 To store Scrollbar Bottom positon
+
+ for(Index = (listbox->Top + 2); Index < (UINTN)(listbox->Top + listbox->Height -2) ;Index++)
+ {
+ if( (Index >= FirstLine) && (Index < LastLine))
+ DrawStringWithAttribute( listbox->Left+ listbox->Width-2, Index, ScrlSel,
+ listbox->FGColor | listbox->BGColor );
+ else
+ DrawStringWithAttribute( listbox->Left+ listbox->Width-2, Index, ScrlNSel,
+ listbox->FGColor | listbox->BGColor );
+ }
+
+ }
+
+
+ // highlight selected item
+ for ( Index = listbox->FirstVisibleSel/*0*/; Index <= listbox->LastVisibleSel/*listbox->ItemCount*/; Index++ )
+ {
+ if ( Index == listbox->Sel )
+ {
+ FGColor = EFI_WHITE ;
+ BGColor = EFI_BACKGROUND_BLACK ;
+
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+ text = HiiGetString( listbox->ListHandle, listbox->PtrItems[Index].ItemToken );
+
+ // Check condition if item is non-focusable
+ // This may occur if all menu items are set non-focusable
+ if( listbox->PtrItems[Index].Attribute == AMI_POSTMENU_ATTRIB_NON_FOCUS)
+ {
+ FGColor = EFI_LIGHTGRAY;
+ BGColor = listbox->BGColor;
+ }
+ }
+ else
+ text = HiiGetString( listbox->ListHandle, listbox->PtrTokens[Index]);
+
+ if(!text)
+ text = EfiLibAllocateZeroPool(2);
+ if((TestPrintLength( text) / (NG_SIZE)) >(UINTN) (listbox->Width - BorderWidth) )
+ text[HiiFindStrPrintBoundary(text ,listbox->Width - BorderWidth)] = L'\0';
+ DrawStringWithAttribute( listbox->Left + 2, listbox->Top + Index - listbox->FirstVisibleSel + 1,
+ text, BGColor | FGColor);
+ }
+ else
+ {
+ if(listbox->Style == POPUP_STYLE_BBS)
+ text = HiiGetString( listbox->ListHandle, listbox->PtrItems[Index].ItemToken );
+ else
+ text = HiiGetString( listbox->ListHandle, listbox->PtrTokens[Index] );
+
+
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+ if (listbox->PtrItems[Index].ItemToken)
+ {
+
+ //if(!text)
+ // text = EfiLibAllocateZeroPool(2);
+ if((TestPrintLength( text) / (NG_SIZE)) > (UINTN) (listbox->Width - BorderWidth) )
+ text[HiiFindStrPrintBoundary(text ,listbox->Width - BorderWidth)] = L'\0';
+
+ // check conditional ptr if necessary
+ if( listbox->PtrItems[Index].Attribute == AMI_POSTMENU_ATTRIB_NON_FOCUS)
+ FGColor = EFI_LIGHTGRAY;
+ else
+ FGColor = listbox->FGColor ;
+
+ DrawStringWithAttribute( listbox->Left + 2, listbox->Top + Index - listbox->FirstVisibleSel + 1,
+ text, listbox->BGColor | FGColor /*popupmenu->FGColor*/ );
+ }else
+ ListBoxDrawSeperator( listbox, listbox->Left , listbox->Top + Index - listbox->FirstVisibleSel + 1,
+ listbox->UseScrollbar?(listbox->Width-2):listbox->Width, 1);
+
+ }
+ else
+ {
+
+ if(!text)
+ text = EfiLibAllocateZeroPool(2);
+ if((TestPrintLength( text) / (NG_SIZE)) > (UINTN) (listbox->Width - BorderWidth) )
+ text[HiiFindStrPrintBoundary(text ,listbox->Width - BorderWidth)] = L'\0';
+ DrawStringWithAttribute( listbox->Left + 2, listbox->Top + Index - listbox->FirstVisibleSel + 1,
+ text, listbox->BGColor | listbox->FGColor );
+ }
+ }
+ MemFreePointer( (VOID **)&text );
+ }
+
+ FlushLines( listbox->Top-2, listbox->Top+listbox->Height/*PtrTokens[0]*/ + 1+2);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxHandleAction
+//
+// Description: Function to handle the List Box actions.
+//
+// Input: LISTBOX_DATA *listbox, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxHandleAction( LISTBOX_DATA *listbox, ACTION_DATA *Data)
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+ ACTION_DATA TempData;
+ UINT16 i, start, end ;
+ VOID *ScreenBuf = NULL;
+
+ if(Data->Input.Type == ACTION_TYPE_TIMER)
+ Status = EFI_UNSUPPORTED;
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ Status = MouseListBoxHandleAction( listbox, Data);
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ CONTROL_ACTION Action;
+
+ ScrollBarMoveAction = FALSE; //EIP-67049
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ switch(Action)
+ {
+ //EIP-42124: Add Page up and Page down key in List box
+ case ControlActionPageUp:
+ if(listbox->Style == POPUP_STYLE_NORMAL)
+ {
+ if (listbox->Sel < (listbox->Height-3))
+ listbox->Sel = 0;
+ else
+ listbox->Sel= listbox->Sel - (listbox->Height-3);
+ }
+ break;
+ case ControlActionPageDown:
+ if(listbox->Style == POPUP_STYLE_NORMAL)
+ {
+ if ((listbox->Sel+(listbox->Height-3)) > (listbox->ItemCount-1))
+ listbox->Sel = (listbox->ItemCount-1);
+ else
+ listbox->Sel= listbox->Sel + (listbox->Height-3);
+ }
+ break;
+ case ControlActionNextUp:
+ if ( listbox->Sel > 0 )
+ {
+ listbox->Sel--;
+
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+
+ if ( (listbox->PtrItems[listbox->Sel].ItemToken==0) || (listbox->PtrItems[listbox->Sel].Attribute == AMI_POSTMENU_ATTRIB_NON_FOCUS))
+ {
+ //Send Fake Action...
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Data.AmiKey.Key.ScanCode = SCAN_UP;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_NULL ;
+ gListBox.HandleAction(listbox, &TempData);
+ }
+ }
+ }
+ else
+ {
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+ //Rollover, find the first focusable item
+ for ( i = listbox->ItemCount-1; i > -1 ; i-- )
+ {
+ if((listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_NON_FOCUS)&&
+ (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY)&&
+ (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN))
+ {
+ listbox->Sel=i;
+ break;
+ }
+ }
+ }
+ else
+ listbox->Sel = listbox->ItemCount - 1;
+ }
+ break;
+
+ case ControlActionNextDown:
+ if ( (INTN)(listbox->Sel) < listbox->ItemCount-listbox->HiddenItemCount - 1 )
+ {
+ listbox->Sel++;
+
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+
+ if ( (listbox->PtrItems[listbox->Sel].ItemToken==0) || (listbox->PtrItems[listbox->Sel].Attribute == AMI_POSTMENU_ATTRIB_NON_FOCUS))
+ {
+ //Send Fake Action...
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Data.AmiKey.Key.ScanCode = SCAN_DOWN;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_NULL ;
+ gListBox.HandleAction(listbox, &TempData);
+ }
+ }
+
+ }
+ else
+ { //Rollover, find the first focusable item
+ listbox->Sel=0;
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+ for ( i = 0; i < listbox->ItemCount; i++ )
+ {
+ if((listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_NON_FOCUS)&&
+ (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY)&&
+ (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN))
+ {
+ listbox->Sel=i;
+ break;
+ }
+ }
+ }
+
+ }
+ break;
+
+ case ControlActionAbort:
+//EIP:47962 - Start
+// ScreenBuf = SaveScreen();
+ listbox->Callback( listbox->Container, listbox, NULL );
+// RestoreScreen( ScreenBuf );
+//EIP:47962 - End
+ break;
+
+ case ControlActionSelect:
+//EIP:47962 - Start
+// ScreenBuf = SaveScreen();
+ listbox->Callback( listbox->Container, listbox, &(listbox->Sel) );
+// RestoreScreen( ScreenBuf );
+//EIP:47962 - End
+ break;
+
+ default:
+ if(listbox->Style == POPUP_STYLE_BBS)
+ {
+ //Start from current selection
+ start = listbox->Sel ;
+ end = listbox->ItemCount ;
+
+ Search:
+ for ( i = start; i < end; i++ )
+ {
+ if( (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_NON_FOCUS)&&
+ (listbox->PtrItems[i].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+
+
+//EIP:48316 - Start
+ if( (listbox->PtrItems[i].Key.Key.ScanCode != 0) ||
+ (listbox->PtrItems[i].Key.Key.UnicodeChar != 0) ||
+ (listbox->PtrItems[i].Key.KeyShiftState != 0) )
+ {
+//EIP:48316 - End
+ if( (listbox->PtrItems[i].Key.Key.ScanCode == Data->Input.Data.AmiKey.Key.ScanCode) &&
+ (listbox->PtrItems[i].Key.Key.UnicodeChar == Data->Input.Data.AmiKey.Key.UnicodeChar) &&
+ TseCheckShiftState((Data->Input.Data.AmiKey), listbox->PtrItems[i].Key.KeyShiftState) )
+ {
+
+ if(listbox->PtrItems[i].Attribute == AMI_POSTMENU_ATTRIB_HIDDEN)
+ {
+ listbox->Callback( listbox->Container, listbox, &i );
+ }
+ else
+ {
+ listbox->Sel = i ;
+ listbox->Callback( listbox->Container, listbox, &(listbox->Sel) );
+ }
+
+ //Send Fake Action...
+ /*
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Data.AmiKey.Key.ScanCode = 0;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ gListBox.HandleAction(listbox, &TempData);
+ */
+
+ break;
+ }
+ }
+ }
+ }
+
+ //Wrap and Search remaining items for match
+ if(i==listbox->ItemCount && (start != 0))
+ {
+ start = 0 ;
+ end = listbox->Sel ;
+ goto Search ;
+ }
+ }
+ }
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: LISTBOX_DATA *listbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxSetCallback( LISTBOX_DATA *listbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( listbox, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: LISTBOX_DATA *listbox, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxSetFocus(LISTBOX_DATA *listbox, BOOLEAN focus)
+{
+ listbox->ControlFocus =focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxSetPosition
+//
+// Description: Function to set position.
+//
+// Input: LISTBOX_DATA *listbox, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxSetPosition(LISTBOX_DATA *listbox, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( listbox, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: LISTBOX_DATA *listbox, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxSetDimensions(LISTBOX_DATA *listbox, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( listbox, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: LISTBOX_DATA *listbox, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxSetAttributes(LISTBOX_DATA *listbox, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( listbox, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEMouseListBoxHandleAction
+//
+// Description: Function to hadnle List Box using mouse
+//
+// Input: LISTBOX_DATA *listbox,
+// ACTION_DATA *action,
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TSEMouseListBoxHandleAction( LISTBOX_DATA *listbox, ACTION_DATA *Data)
+{
+ UINT16 i;
+ UINT32 Action;
+
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ //Exit listbox if clicked outside listbox
+ //EIP 103449 : In Setup click\Touch from navigation window, option are not displayed properly
+ if( (
+ (Data->Input.Data.MouseInfo.Top < listbox->Top) ||
+ (Data->Input.Data.MouseInfo.Top > (UINT32)(listbox->Top + listbox->Height)) ||
+ (Data->Input.Data.MouseInfo.Left < listbox->Left) ||
+ (Data->Input.Data.MouseInfo.Left > (UINT32)(listbox->Left + listbox->Width))
+ ) && (!lButtonOnListBoxScroll) // Check for lButtonDown on ScrollBar
+ && ( (SingleClickActivation() && (ControlActionSelect ==Action)) || //If singleClickActivation is enabled/Disable
+ (ControlActionAbort == Action) || (ControlActionChoose ==Action ) //EIP-139608 Closing listbox whn mouse action happens outside listbox.
+ )
+ )
+ {
+ listbox->Callback( listbox->Container, listbox, NULL );
+ }
+ //Reset lbutton positions
+ if (ControlMouseActionLeftUp == Action
+ || ControlActionChoose == Action
+ || ControlActionSelect == Action)
+ {
+ lButtonOnListBoxScroll = FALSE;
+ lButtonInitialPosition = 0;
+ lButtonVaryingPosition = 0;
+ }
+ //If scrollbar present
+ if ( listbox->UseScrollbar )
+ {
+ //Check if clicked on scroll bar area
+ if( ( Data->Input.Data.MouseInfo.Top > (UINT32)listbox->Top && (Data->Input.Data.MouseInfo.Top < (UINT32)(listbox->Top + listbox->Height)) ) //Clicked inside listbox area
+ && (Data->Input.Data.MouseInfo.Left == (UINT32)(listbox->Left + listbox->Width - 2)) //Clicked on scrollbar area
+ )
+ {
+ //If clicked on UP_ARROW
+ if(((Data->Input.Data.MouseInfo.Top == (UINT32)(listbox->Top + 1)) &&(Data->Input.Data.MouseInfo.Left == (UINT32) (listbox->Left + listbox->Width -2))) //Clicked on UP_ARROW
+ &&((TSEMOUSE_LEFT_CLICK == Data->Input.Data.MouseInfo.ButtonStatus)||(TSEMOUSE_LEFT_DCLICK == Data->Input.Data.MouseInfo.ButtonStatus))//EIP 78929 : Check for left click and left double click to scroll the frame if click on arrow buttons of scroll bar.
+ )
+ {
+ ScrollBarMoveAction = TRUE;
+ MouseListBoxScrollBarMove( listbox, TRUE, 1 );
+ return EFI_SUCCESS;//EIP 78929 : Returning by consuming the click when the clicked on the arrow buttons of scroll bar
+ }
+ //If clicked on DOWN_ARROW
+ else if(((Data->Input.Data.MouseInfo.Top == (UINT32) (listbox->Top + listbox->Height-2)) &&(Data->Input.Data.MouseInfo.Left == (UINT32) (listbox->Left + listbox->Width-2))) //Clicked on DOWN_ARROW
+ &&((TSEMOUSE_LEFT_CLICK == Data->Input.Data.MouseInfo.ButtonStatus)||(TSEMOUSE_LEFT_DCLICK == Data->Input.Data.MouseInfo.ButtonStatus))//EIP 78929 : Check for left click and left double click to scroll the frame if click on arrow buttons of scroll bar.
+ )
+ {
+ ScrollBarMoveAction = TRUE;
+ MouseListBoxScrollBarMove( listbox, FALSE, 1 );
+ return EFI_SUCCESS;//EIP 78929 : Returning by consuming the click when the clicked on the arrow buttons of scroll bar
+ }
+ //If clicked on scrollbar
+ else if( ((Data->Input.Data.MouseInfo.Top < gListBoxScrollBarBottom) && (Data->Input.Data.MouseInfo.Top > gListBoxScrollBarTop)) //Scrollbar area
+ && (ControlMouseActionLeftDown == Action) //Mouse lbutton down
+ && ((ControlActionChoose != Action) || (ControlActionSelect != Action)) //Neglecting LEFT_DCLICK and LEFT_CLICK on scrollbar area
+ )
+ {
+ lButtonOnListBoxScroll = TRUE;
+ ScrollBarMoveAction = TRUE;
+ if ( lButtonInitialPosition == 0 )//To get initial lButtonDown position
+ {
+ lButtonInitialPosition = Data->Input.Data.MouseInfo.Top;
+ }
+ if ( lButtonInitialPosition != Data->Input.Data.MouseInfo.Top )
+ {
+ lButtonVaryingPosition = Data->Input.Data.MouseInfo.Top;
+ //Move scrollbar upwards
+ if( lButtonInitialPosition > lButtonVaryingPosition )
+ MouseListBoxScrollBarMove( listbox, TRUE, lButtonInitialPosition - lButtonVaryingPosition );
+
+ //Move scrollbar downwards
+ else
+ MouseListBoxScrollBarMove( listbox, FALSE, lButtonVaryingPosition - lButtonInitialPosition );
+ lButtonInitialPosition = lButtonVaryingPosition;
+ }
+ return EFI_SUCCESS;
+ }
+ //If mouse clicked above DOWN_ARROW and below ScrollBar
+ else if( (Data->Input.Data.MouseInfo.Top < (UINT32) (listbox->Top + listbox->Height-3)) //Clicked above DOWN_ARROW
+ && (Data->Input.Data.MouseInfo.Top >= gListBoxScrollBarBottom) //Clicked below ScrollBar
+ && (ControlMouseActionLeftDown == Action) //Action is LEFT_DOWN
+ )
+ {
+ ScrollBarMoveAction = TRUE;
+ MouseListBoxScrollBarMove( listbox, FALSE, Data->Input.Data.MouseInfo.Top - gListBoxScrollBarBottom );
+ return EFI_SUCCESS;
+ }
+ //If mouse clicked below UP_ARROW and above ScrollBar
+ else if( (Data->Input.Data.MouseInfo.Top > (UINT32)(listbox->Top + 1)) //Clicked below UP_ARROW
+ && (Data->Input.Data.MouseInfo.Top <= gListBoxScrollBarTop) //Clicked above ScrollBar
+ && (ControlMouseActionLeftDown == Action) //Action is LEFT_DOWN
+ )
+ {
+ ScrollBarMoveAction = TRUE;
+ MouseListBoxScrollBarMove( listbox, TRUE, gListBoxScrollBarTop - Data->Input.Data.MouseInfo.Top);
+ return EFI_SUCCESS;
+ }
+ return EFI_SUCCESS;
+ }
+ //If mouse button clicked on scrollbar and moved outside the scroll area
+ else if( ControlMouseActionLeftDown == Action //Action is LEFT_DOWN
+ && (lButtonInitialPosition != 0)
+ && ((ControlActionChoose != Action) || (ControlActionSelect != Action)) //Neglecting LEFT_CLICK and LEFT_DCLICK
+ )
+ {
+ lButtonVaryingPosition = Data->Input.Data.MouseInfo.Top;
+ //Move scrollbar upwards
+ if( lButtonInitialPosition > lButtonVaryingPosition )
+ MouseListBoxScrollBarMove( listbox, TRUE, lButtonInitialPosition - lButtonVaryingPosition );
+
+ //Move scrollbar downwards
+ else
+ MouseListBoxScrollBarMove( listbox, FALSE, lButtonVaryingPosition - lButtonInitialPosition );
+ lButtonInitialPosition = lButtonVaryingPosition;
+
+ //Reset lButtonDown position when lButton releases
+ if (ControlMouseActionLeftUp == Action)
+ {
+ lButtonInitialPosition = lButtonVaryingPosition = 0;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+ //If clicked Inside listbox area other than scroll area to handle highlight or selection of the option
+ if( ( Data->Input.Data.MouseInfo.Top > (UINT32)listbox->Top && (Data->Input.Data.MouseInfo.Top < (UINT32)(listbox->Top + listbox->Height)) ) //Clicked inside ListBox area
+ && ( (Data->Input.Data.MouseInfo.Left > listbox->Left) && (Data->Input.Data.MouseInfo.Left < (listbox->Left + (UINT32)(listbox->Width - 2))) ) //Width calculation
+ && (ControlActionChoose == Action || ControlActionSelect == Action) //check LEFT_DCLICK or LEFT_CLICK
+ )
+ {
+ for (i = listbox->FirstVisibleSel; i <= listbox->LastVisibleSel; i++ )
+ {
+ if(Data->Input.Data.MouseInfo.Top == (UINT32) (listbox->Top + i - listbox->FirstVisibleSel + 1))
+ {
+ switch( MapControlMouseActionHook(&Data->Input.Data.MouseInfo) )
+ {
+ case ControlActionChoose:
+ listbox->Sel=i;
+ break;
+
+ case ControlActionSelect:
+ if (SingleClickActivation ()) //EIP74141 providing select option for single click too
+ {
+ listbox->Sel=i;
+ }
+ listbox->Callback( listbox->Container, listbox, &(listbox->Sel) );
+ break;
+ }
+ }
+ }
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ListBoxGetControlHight
+//
+// Description: Function unsupported.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ListBoxGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+//EIP-67049 Start
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: TSEMouseListBoxScrollBarMove
+//
+// Description: Adds scroll bar functionality for frames with many controls
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// BOOLEAN bScrollUp - Go up is TRUE, else to down one control
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS TSEMouseListBoxScrollBarMove( LISTBOX_DATA *listbox, BOOLEAN bScrollUp, UINT16 Size )
+{
+ if ( listbox->ItemCount == 0 )
+ return EFI_UNSUPPORTED;
+
+ switch ( bScrollUp )
+ {
+ case TRUE:
+
+ if( Size >= listbox->FirstVisibleSel )
+ Size = listbox->FirstVisibleSel;
+
+ //If FirstVisibleCtrl is not equal to first control then move scrollbar till it reaches top
+ if(listbox->FirstVisibleSel > 0)
+ {
+ listbox->FirstVisibleSel = listbox->FirstVisibleSel - Size;
+ listbox->LastVisibleSel = listbox->LastVisibleSel - Size;
+ }
+ break;
+
+ case FALSE:
+ //If the size of scroll to move exceeds the remaining control count then change the size value based on the remaining control count
+ if( Size >= (listbox->ItemCount - listbox->LastVisibleSel) )
+ Size = listbox->ItemCount - listbox->LastVisibleSel - 1;
+
+ //If LastVisibleCtrl is not equal to last control then move scrollbar till it reaches bottom
+ if(listbox->LastVisibleSel < listbox->ItemCount - 1)
+ {
+ listbox->FirstVisibleSel = listbox->FirstVisibleSel + Size;
+ listbox->LastVisibleSel = listbox->LastVisibleSel + Size;
+ }
+ break;
+ }
+ return EFI_SUCCESS;
+}
+//EIP-67049 End
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ListBox.h b/EDK/MiniSetup/TseLite/ListBox.h
new file mode 100644
index 0000000..cbe2a06
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ListBox.h
@@ -0,0 +1,186 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ListBox.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ListBox.h $
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 8 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 10/28/09 5:38p Madhans
+//
+// 5 8/26/09 4:11p Blaines
+// To fix issue with BBS popup when more then 20 bootoptions are present
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ListBox.h
+//
+// Description: Header file for Listbox controls.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _LISTBOX_H_
+#define _LISTBOX_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "popup.h"
+
+#define MAX_VISIBLE_SELECTIONS (gMaxRows -10)
+
+#define LISTBOX_MEMBER_VARIABLES \
+ VOID *ScreenBuf; \
+ /*EFI_HII_HANDLE*/VOID *ListHandle; \
+ UINT16 Sel; \
+ UINT16 FirstVisibleSel; \
+ UINT16 LastVisibleSel ; \
+ UINT16 ItemCount; \
+ UINT16 *PtrTokens; \
+ POSTMENU_TEMPLATE *PtrItems; \
+ BOOLEAN UseScrollbar; \
+ UINT16 QuitPopupLoop ; \
+ UINT16 HiddenItemCount;
+
+typedef struct _LISTBOX_METHODS LISTBOX_METHODS;
+
+typedef struct _LISTBOX_DATA
+{
+ LISTBOX_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUP_MEMBER_VARIABLES
+ LISTBOX_MEMBER_VARIABLES
+
+}
+LISTBOX_DATA;
+
+
+typedef struct _LISTBOX_BSS_POPUP_DATA
+{
+ UINT16 TitleToken;
+ UINT16 ItemCount;
+ POSTMENU_TEMPLATE *PtrItems;
+ UINT16 Help1Token;
+ UINT16 Help2Token;
+ UINT16 Help3Token;
+ CONTROL_INFO *pControlData;
+ UINT16 HiddenItemCount;
+}
+LISTBOX_BSS_POPUP_DATA;
+
+typedef EFI_STATUS (*LISTBOX_METHOD_INITIALIZE_BBS_POPUP) ( VOID *object, VOID *data );
+
+// Don't Call Initialize if you call InitializeBBSPopup...
+#define LISTBOX_METHOD_FUNCTIONS \
+ LISTBOX_METHOD_INITIALIZE_BBS_POPUP InitializeBBSPopup;
+
+struct _LISTBOX_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ LISTBOX_METHOD_FUNCTIONS
+};
+
+extern LISTBOX_METHODS gListBox;
+
+// Object Methods
+EFI_STATUS ListBoxCreate( VOID **object );
+EFI_STATUS ListBoxDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS ListBoxInitialize( VOID *object, VOID *data );
+EFI_STATUS ListBoxDraw( VOID *object );
+EFI_STATUS ListBoxHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS ListBoxSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS ListBoxSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS ListBoxSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS ListBoxSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS ListBoxSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS ListBoxGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+
+//Listbox Methods
+EFI_STATUS ListBoxInitializeBBSPopup( LISTBOX_DATA *listbox, LISTBOX_BSS_POPUP_DATA *listboxBBSPopupData );
+
+#endif /* _LISTBOX_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Memo.c b/EDK/MiniSetup/TseLite/Memo.c
new file mode 100644
index 0000000..222f8f8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Memo.c
@@ -0,0 +1,764 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Memo.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 15 $
+//
+// $Date: 3/18/13 1:24a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Memo.c $
+//
+// 15 3/18/13 1:24a Arunsb
+// [TAG] EIP118306
+// [Category] Improvement
+// [Description] Support for grayout subtitle control
+// [Files] Memo.c
+//
+// 14 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 13 4/04/12 12:34a Rajashakerg
+// [TAG] EIP83705
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Help page scroll bar not moving till end for the "Setup
+// question completion timeout" control in "Advanced -> PCI Express GEN2
+// settings".
+// [RootCause] Scrollbar calculation for the help frame are improper.
+// [Solution] provided proper value for the scrollbar.
+// [Files] Memo.c
+//
+// 12 12/01/11 1:45a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 11 11/21/11 8:52a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 10 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 9 6/29/11 12:49p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 8 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 7 2/03/11 8:20p Madhans
+// [TAG] - EIP 50956
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- If we leave the Setup page for 2 or more days. The system
+// may hang/Crash.
+// [Rootcause] - Memory leaks
+// [Solution]- Memeory freed.
+// [Files] - ctrlcond.c, memo.c and expression.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 1/22/10 6:14p Blaines
+// EIP #33837 - Setup appearance corrupted if additional subtitles added
+// Fix - Prevent memo draw if supressed condition
+//
+// 5 1/09/10 6:40a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 10/28/09 5:38p Madhans
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 5 5/18/09 12:21p Blaines
+// Fix Help Frame (memo) text scroll
+//
+// 4 5/12/09 5:14p Blaines
+// Patch for help text scroll issue
+//
+// 3 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#include "minisetup.h"
+
+MEMO_METHODS gMemo =
+{
+ MemoCreate,
+ MemoDestroy,
+ MemoInitialize,
+ MemoDraw,
+ MemoHandleAction,
+ MemoSetCallback,
+ MemoSetFocus,
+ MemoSetPosition,
+ MemoSetDimensions,
+ MemoSetAttributes,
+ MemoGetControlHeight,
+ MemoSetJustify
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoCreate
+//
+// Description: Function to create a Memo, which uses the Control Functions.
+//
+// Input: MEMO_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoCreate( MEMO_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(MEMO_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gMemo;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoDestroy
+//
+// Description: Function to Destroy a Memo, which uses the Control Functions.
+//
+// Input: MEMO_DATA *memo, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoDestroy( MEMO_DATA *memo, BOOLEAN freeMem )
+{
+ if(NULL == memo)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( memo, FALSE );
+
+ if( freeMem ){
+ MemFreePointer( (VOID **)&memo->EmptyString ); //EIP-73236 Free the allocated memory for the EmptyString field
+ MemFreePointer( (VOID **)&memo );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoInitialize
+//
+// Description: Function to Initialize a Memo, which uses the Control Functions.
+//
+// Input: MEMO_DATA *memo, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoInitialize( MEMO_DATA *memo, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( memo, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ SetControlColorsHook( &(memo->BGColor), &(memo->FGColor), NULL, NULL ,NULL, NULL ,
+ NULL , NULL,
+ NULL, NULL ,
+ NULL,NULL ,NULL,NULL, NULL );
+ StyleGetSpecialColor( CONTROL_TYPE_MEMO, &(memo->FGColor)) ;
+ memo->Interval = (UINT8)(memo->ControlData.ControlFlags.ControlRefresh);
+
+ memo->Justify = JUSTIFY_LEFT;
+
+ //[EIP:19479]RB:<Add>
+ // initialization of ScrollBarPosition
+ memo->ScrollBarPosition = 0;
+ //[EIP:19479]RB:<Add>
+
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoDraw
+//
+// Description: Function to draw a Memo.
+//
+// Input: MEMO_DATA *memo
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoDraw( MEMO_DATA *memo )
+{
+ CHAR16 *text = NULL, *newText = NULL;
+ CHAR16 *line;
+ UINT16 pos, height = 0;
+
+ UINT16 TempPos = 0;
+ BOOLEAN bScrollBar = FALSE;
+
+ // check conditional ptr if necessary
+ //EIP #33837 - Setup appearance corrupted if additional subtitles added
+ // Fix - Prevent memo draw if supressed condition
+
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( memo->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &memo->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ //Status = EFI_WARN_WRITE_FAILURE;
+ memo->FGColor = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text = HiiGetString( memo->ControlData.ControlHandle,UefiGetTitleField( (VOID *)memo->ControlData.ControlPtr));
+
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ if ( EfiStrLen(text) == 0)
+ {
+ // String is empty but memory is allocated.
+ MemFreePointer( (VOID **)&text );
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // clear out old wrapped string
+ for ( pos = 0; pos < memo->Height; pos++ )
+ DrawStringWithAttribute( memo->Left, memo->Top + pos, memo->EmptyString, memo->FGColor | memo->BGColor );
+
+ // XXX: this wrapping code is probably not compatible with all languages
+ newText = StringWrapText( text, memo->Width, &height );
+ if(height == 0)
+ return EFI_OUT_OF_RESOURCES;
+
+
+ // where height is the total number of Lines if it is greater than memo->Height(14)
+ // then scroll bar need or not needed.
+
+ bScrollBar = ( (height > memo->Height) && (memo->ParentFrameType == HELP_FRAME /*memo->Top == MAIN_TOP*/) ) ? 1 : 0;
+
+ if( memo->ScrollBarPosition > (height - memo->Height) )
+ memo->ScrollBarPosition = (height - memo->Height);
+
+ if ( newText != text )
+ MemFreePointer( (VOID **)&text );
+
+ line = newText;
+
+ // Draw complete strings in a help frame. Limits upto height of the string.
+ for ( pos = 0; pos < height; pos++ )
+ {
+ CHAR16 save;
+
+ text = line;
+ if ( *line == L'\0' )
+ break;
+
+ while ( ( *line != L'\n' ) &&( *line != L'\r' ) && ( *line != L'\0' ) )
+ line++;
+
+ save = *line;
+ *line = L'\0';
+
+ if( (memo->ScrollBarPosition > pos) && ((height - memo->Height) > pos) )
+ {
+ TempPos++;
+ }
+ else
+ {
+ // If height exceeds memo->Height
+ // Drawing alternative 14 lines in help frame.
+ if( bScrollBar )
+ {
+ if( (pos-TempPos) < memo->Height )
+ {
+ DrawStringJustifiedWithAttribute( memo->Left, memo->Left + memo->Width, memo->Top + (pos-TempPos),
+ memo->Justify, text, memo->FGColor | memo->BGColor );
+
+ }
+ }
+ // If No of Lines is less than Memo->Height
+ // Drawing a string in a help frame
+ else
+ {
+ memo->ScrollBarPosition = 0;
+ DrawStringJustifiedWithAttribute( memo->Left, memo->Left + memo->Width, memo->Top + pos,
+ memo->Justify, text, memo->FGColor | memo->BGColor );
+ }
+
+ }
+
+ if ( ( *line = save ) != L'\0' )
+ {
+ line++;
+ if ( ( *line == L'\r' ) || ( *line == L'\n' ) )
+ line++;
+ }
+ }
+
+
+ // Drawing Scrollbar For Help Frame.
+ if( memo->ParentFrameType == HELP_FRAME )
+ {
+ // If scrollbar needed draw the scroll bar
+ if( bScrollBar )
+ StyleDrawHelpScrollBar(memo, height) ;
+ else
+ MemoEraseScrollBar(memo) ;
+ }
+
+ if ( pos < height )
+ height = pos;
+
+ memo->DisplayLines = height;
+
+ FlushLines( memo->Top, memo->Top + memo->Height -1 );
+ if( ( memo->ParentFrameType == HELP_FRAME ) && ( bScrollBar ))
+ DoRealFlushLines();
+ MemFreePointer( (VOID **)&newText );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoDrawScrollBar
+//
+// Description: Function to draw memo scrollbar
+//
+// Input: MEMO_DATA *memo, UINT16 height
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MemoDrawScrollBar( MEMO_DATA *memo, UINT16 height)
+{
+ #define VISIBLE_AREA_HEIGHT (memo->Height - 1)
+ #define SCROLLBAR_AREA_HEIGHT (memo->Height)
+
+ UINT16 pos=0 ;
+ UINT32 FirstLine=0,LastLine=0,ScrollbarHeight = 0,j = 0;
+ CHAR16 ArrUp[2]={{GEOMETRICSHAPE_UP_TRIANGLE},{0x0000}},ArrDown[2]={{GEOMETRICSHAPE_DOWN_TRIANGLE},{0x0000}},ScrlSel[2]={{BLOCKELEMENT_FULL_BLOCK/*L'N'*/},{0x0000}},ScrlNSel[2]={{BLOCKELEMENT_LIGHT_SHADE/*L'S'*/},{0x0000}};
+
+ // Calculated scrollbar length based upon the height of the Lines.
+ ScrollbarHeight = ( (SCROLLBAR_AREA_HEIGHT - 2) * VISIBLE_AREA_HEIGHT ) / height;
+
+ // Calculated the First line of the scroll bar and last line of the scrollbar.
+ FirstLine = memo->ScrollBarPosition * ( (SCROLLBAR_AREA_HEIGHT - 2) - ScrollbarHeight ) / ( height - VISIBLE_AREA_HEIGHT ) + memo->Top + 1;
+
+ LastLine = FirstLine + ScrollbarHeight;
+
+ for ( pos = 1,j = memo->Top; pos <= (UINT32)SCROLLBAR_AREA_HEIGHT ; pos++, j++ )
+ {
+ // Drawing Up Arrow
+ if (pos == 1){
+ DrawStringWithAttribute( memo->Left + memo->Width , memo->Top, ArrUp,
+ StyleGetScrollBarUpArrowColor() );
+ }
+ // Drawing Down Arrow
+ else if ( pos == (UINT32 )( SCROLLBAR_AREA_HEIGHT )){
+ DrawStringWithAttribute( memo->Left + memo->Width , memo->Top + (memo->Height-1), ArrDown,
+ StyleGetScrollBarDownArrowColor() );
+ }
+ // Drawing Scroll Bar(Scroll selector)
+ else if ( (j >= FirstLine) && (j <= LastLine) ){
+ DrawStringWithAttribute( memo->Left + memo->Width, j, ScrlSel,
+ StyleGetScrollBarColor() );
+ }
+ // Drawing scroll Not Selector bar
+ else{
+ DrawStringWithAttribute( memo->Left + memo->Width, j, ScrlNSel,
+ StyleGetScrollBarColor() );
+ }
+
+ }
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoEraseScrollBar
+//
+// Description: Function to erase memo scrollbar
+//
+// Input: MEMO_DATA *memo
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MemoEraseScrollBar( MEMO_DATA *memo)
+{
+ UINT16 pos=0 ;
+ UINT32 j=0 ;
+
+ for ( pos = 0,j = memo->Top; pos < memo->Height; pos++,j++ )
+ DrawStringWithAttribute( memo->Left + memo->Width, j , L" ",
+ memo->FGColor | memo->BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuHandleAction
+//
+// Description: Function to set callback.
+//
+// Input: MEMO_DATA *memo, ACTION_DATA *Data
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoHandleAction( MEMO_DATA *memo, ACTION_DATA *Data)
+{
+ //[EIP:19479]RB:<Add>
+ // Handling action for help frame.
+
+ CONTROL_ACTION Action;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if (memo->Interval == 0)
+ return Status;
+ if ( --(memo->Interval) == 0 )
+ {
+ // initialize the interval
+ memo->Interval = (UINT8)(memo->ControlData.ControlFlags.ControlRefresh);
+ return EFI_SUCCESS;
+ }
+ else
+ return Status;
+ }
+
+ if ( Data->Input.Type != ACTION_TYPE_KEY )
+ return EFI_UNSUPPORTED;
+
+ //Get Key
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+
+ switch ( Action )
+ {
+ case ControlActionHelpPageDown:
+
+ // Identify the help frame by identifying the height of the help frame
+ if( memo->ParentFrameType == HELP_FRAME)
+ {
+ // Incrementing the ScrollBarPosition.
+ memo->ScrollBarPosition++;
+ // Based upon ScrollBarPosition drawing the Memo again.
+ gMemo.Draw(memo);
+ }
+ break;
+
+ case ControlActionHelpPageUp:
+ if( memo->ParentFrameType == HELP_FRAME)
+ {
+ // Decrementing ScrollBarPosition
+ if( memo->ScrollBarPosition != 0 )
+ memo->ScrollBarPosition--;
+ else
+ memo->ScrollBarPosition = 0;
+ gMemo.Draw(memo);
+ }
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;
+ }
+
+
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: MEMO_DATA *memo, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetCallback( MEMO_DATA *memo, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: MEMO_DATA *memo, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetFocus(MEMO_DATA *memo, BOOLEAN focus)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetPosition
+//
+// Description: Function to set position.
+//
+// Input: MEMO_DATA *memo, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetPosition(MEMO_DATA *memo, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( memo, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: MEMO_DATA *memo, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetAttributes(MEMO_DATA *memo, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( memo, FGColor, BGColor );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: MEMO_DATA *memo, UINT16 width, UINT16 height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetDimensions( MEMO_DATA *memo, UINT16 width, UINT16 height )
+{
+ memo->Width = width;
+ memo->Height = height;
+
+ MemFreePointer( (VOID **)&memo->EmptyString );
+ memo->EmptyString = EfiLibAllocateZeroPool( (width + 1) * sizeof(CHAR16) );
+ if ( memo->EmptyString == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ MemFillUINT16Buffer( memo->EmptyString, width, L' ' );
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoSetJustify
+//
+// Description: Function to set justify.
+//
+// Input: MEMO_DATA *memo, UINT8 justify
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoSetJustify( MEMO_DATA *memo, UINT8 justify )
+{
+ if ( justify <= JUSTIFY_MAX )
+ {
+ memo->Justify = justify;
+ return EFI_SUCCESS;
+ }
+
+ return EFI_INVALID_PARAMETER;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemoGetControlHeight
+//
+// Description: Function to get the memo text height.
+//
+// Input: MEMO_DATA *memo, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MemoGetControlHeight( MEMO_DATA *memo, VOID *frame, UINT16 *height )
+{
+ CHAR16 *text = NULL, *newText = NULL;
+
+ if(frame != NULL)
+ { // Memo control from Frame
+ memo->Width = ((FRAME_DATA*)frame)->FrameData.Width - (UINT8)gLabelLeftMargin - 2;
+ }
+ // else messagebox memo
+
+ text = HiiGetString( memo->ControlData.ControlHandle,UefiGetTitleField( (VOID *)memo->ControlData.ControlPtr));
+
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ // XXX: this wrapping code is probably not compatible with all languages
+ newText = StringWrapText( text, memo->Width, height );
+ if ( newText != text )
+ MemFreePointer( (VOID **)&text );
+
+ MemFreePointer( (VOID **)&newText );
+
+ return EFI_SUCCESS;
+}
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Suite 200, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+
diff --git a/EDK/MiniSetup/TseLite/Memo.h b/EDK/MiniSetup/TseLite/Memo.h
new file mode 100644
index 0000000..90b6f1e
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Memo.h
@@ -0,0 +1,195 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Memo.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Memo.h $
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/18/09 12:21p Blaines
+// Fix Help Frame (memo) text scroll
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Memo.h
+//
+// Description: Header file for Memo controls.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _MEMO_H_
+#define _MEMO_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+#define MEMO_MEMBER_VARIABLES \
+ UINT8 Justify; \
+ UINT16 DisplayLines; \
+ CHAR16 *EmptyString; \
+ UINT16 ScrollBarPosition; \
+ UINT8 Interval;
+
+
+typedef struct _MEMO_METHODS MEMO_METHODS;
+
+typedef struct _MEMO_DATA
+{
+ MEMO_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ MEMO_MEMBER_VARIABLES
+
+}
+MEMO_DATA;
+
+typedef EFI_STATUS (*MEMO_METHOD_SET_JUSTIFY) ( VOID *object, UINT8 justify );
+typedef EFI_STATUS (*MEMO_METHOD_GET_TEXT_HEIGHT) ( MEMO_DATA *memo, UINT16 *height );
+
+#define MEMO_METHOD_FUNCTIONS \
+ MEMO_METHOD_SET_JUSTIFY SetJustify;
+
+
+struct _MEMO_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ MEMO_METHOD_FUNCTIONS
+};
+
+extern MEMO_METHODS gMemo;
+
+// Object Methods
+EFI_STATUS MemoCreate( VOID **object );
+EFI_STATUS MemoDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS MemoInitialize( VOID *object, VOID *data );
+EFI_STATUS MemoDraw( VOID *object );
+EFI_STATUS MemoHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS MemoSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS MemoSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS MemoSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS MemoSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS MemoGetControlHeight( VOID *object,VOID *frame, UINT16 *height );
+
+// Memo Methods
+EFI_STATUS MemoSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS MemoSetJustify( VOID *object, UINT8 justify );
+VOID MemoDrawScrollBar( MEMO_DATA *memo, UINT16 height);
+VOID MemoEraseScrollBar( MEMO_DATA *memo);
+#endif /* _MEMO_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Menu.c b/EDK/MiniSetup/TseLite/Menu.c
new file mode 100644
index 0000000..2220de8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Menu.c
@@ -0,0 +1,1069 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Menu.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 26 $
+//
+// $Date: 3/14/13 11:47a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Menu.c $
+//
+// 26 3/14/13 11:47a Premkumara
+// [TAG] EIP85745 & 109814
+// [Category] Improvement
+// [Description] Support for Modal Form Support as per UEFI 2.3.1
+// [Files] Parse.c, Page.c, Menu.c, Hotclick.c
+//
+// 25 10/19/12 5:06a Rajashakerg
+// Provided support for menu scroll for only action choose and select.
+//
+// 24 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 22 9/25/12 12:31p Rajashakerg
+// [TAG] EIP92053
+// [Category] Improvement
+// [Description] Need support define Root page order using elinks
+// [Files] AMITSE.sdl, Menu.c, AMIVfr.h, AMITSE.mak, commonoem.c
+//
+// 21 9/25/12 9:33a Rajashakerg
+// [TAG] EIP92053
+// [Category] Improvement
+// [Description] Need support define Root page order using elinks
+// [Files] AMITSE.sdl, Menu.c, AMIVfr.h, AMITSE.mak, commonoem.c
+//
+// 20 12/01/11 1:43a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 19 11/21/11 8:53a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 18 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 17 11/09/11 6:05p Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+//
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab. Fix the ASSERT seen in Menu.c when
+// serial redirection is enabled.
+//
+// [Files Changed] - AMITSE.sdl, CommonHelper.c, special.c, Menu.c,
+// minisetupext.h,TseUefiHii.h, Uefi21Wapper.c
+//
+// 16 10/31/11 2:44a Rajashakerg
+// [TAG] EIP73377
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup page Menu tab gets selected even when the click is
+// below the menu separator line
+// [RootCause] Menu tab selection was not handled properly using mouse.
+// [Solution] Provided exact menu tab co-ordinates for selection using
+// mouse
+// [Files] Menu.c
+//
+// 15 10/21/11 6:26p Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab.
+//
+// [Files Changed]
+// - AMITSE.sdl, CommonHelper.c, special.c, Menu.c, minisetupext.h,
+// TseUefiHii.h, Uefi21Wapper.c
+//
+// 14 10/20/11 12:03p Madhans
+// Checkin comments corrected.
+//
+// 12 10/04/11 5:28p Blaines
+// [TAG] EIP 68920
+// [Category] Defect
+// [Symptom] SOME SAS controller card HII menus hang when selecting "Clear
+// Configuration" when DEBUG_MODE=0
+// [RootCause] Menu is not re-initialize from SetupData after dynamic
+// page update. MenuInitialize enters an infinite loop on some SAS controller cards.
+//
+//
+// PopupSelGetControlHeight() causes an assert if popupSel has an item
+// with an invalid string token.
+//
+// [Solution] Due to dynamic updates, SetupData (most current data) is
+// given priority when re-initializing menu.
+// Check for invalid string token in PopupSelGetControlHeight.
+//
+// [Files Changed]
+// - Menu.c, Popupsel.c
+//
+// 11 9/19/11 11:50a Blaines
+// [TAG] EIP 68920
+// [Category] Defect
+// [Symptom] SOME SAS controller card menus hang when selecting "Clear
+// Configuration" when DEBUG_MODE=0
+// [RootCause] Menu is not re-initialize from SetupData after dynamic
+// page update.
+// PopupSelGetControlHeight() causes an assert if popupSel has an item
+// with an invalid string token.
+//
+// [Solution] Due to dynamic updates, SetupData (most current data) is
+// given priority when re-initializing menu.
+// Check for invalid string token in PopupSelGetControlHeight.
+//
+// [Files Changed]
+// - Menu.c, Popupsel.c
+//
+// 10 8/26/11 4:10p Blaines
+// [TAG] - EIP 68341
+// [Category]- Action Item
+// [Synopsis]- Dynamic Pages need to List FormSet title instead of Form
+// Title..
+// [Files] - Parse.c, Menu.c
+//
+// 9 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 8 6/15/10 10:49a Blaines
+// Fix for EIP:39570: Adding to length may create additional pages to
+// accommodate extra space.
+//
+// 7 5/24/10 11:11a Mallikarjunanv
+// EIP-38215: Fix for Setup corruption issue with mouse
+//
+// 6 5/24/10 11:02a Mallikarjunanv
+// EIP-38555 : Spacing issue in Menu display
+//
+// 5 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/15/10 10:15p Madhans
+// To support root page hiding based on page flag
+//
+// 5 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 4 1/09/10 6:38a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:09p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Menu.c
+//
+// Description: This file contains code to handle Menu operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+extern BOOLEAN gIsRootPageOrderPresent;
+
+MENU_METHODS gMenu =
+{
+ MenuCreate,
+ MenuDestroy,
+ MenuInitialize,
+ MenuDraw,
+ MenuHandleAction,
+ MenuSetCallback,
+ MenuSetFocus,
+ MenuSetPosition,
+ MenuSetDimensions,
+ MenuSetAttributes,
+ MenuGetControlHight,
+ MenuSetWidth
+
+};
+
+#define ItemPerPage 6
+typedef struct _HII_FORM_ADDRESS
+{
+ EFI_GUID formsetGuid; // Required
+ UINT16 formId; // Required
+ VOID * Handle; // Optional
+}HII_FORM_ADDRESS;
+extern UINT16 gRootPageOrderIndex;
+extern HII_FORM_ADDRESS *gRootPageOrder;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuCreate
+//
+// Description: Function to create Menu, Which uses the control functions.
+//
+// Input: MENU_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuCreate( MENU_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(MENU_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gMenu;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuDestroy
+//
+// Description: Function to Destroy Menu, Which uses the control functions.
+//
+// Input: MENU_DATA *menu, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuDestroy( MENU_DATA *menu, BOOLEAN freeMem )
+{
+ if(NULL == menu)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( menu, FALSE );
+
+ if( freeMem ){
+ MemFreePointer( (VOID **)&menu->Entries);//EIP-73236
+ MemFreePointer( (VOID **)&menu );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuInitialize
+//
+// Description: Function to Initialize Menu, Which uses the control functions.
+//
+// Input: MENU_DATA *menu, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuInitialize( MENU_DATA *menu, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 i,j=0,k=0;
+ PAGE_INFO *info,*tempPage=NULL;
+ UINT32 count = 0 ,PageCount=0;
+
+ // data is NULL when only reinitialization of the menu entries is needed.
+ // this assumes the control was initialized before.
+ if(data !=NULL)
+ {
+ Status = gControl.Initialize( menu, data );
+ if (EFI_ERROR(Status))
+ return Status;
+ }
+ menu->IsSubMenu = 0;
+ // add extra initialization here...
+ if(menu->Entries !=NULL)
+ {
+ gBS->FreePool(menu->Entries);
+ menu->Entries =NULL;
+ menu->NumEntries=menu->CurrEntry=0;
+ }
+
+ menu->Entries = EfiLibAllocateZeroPool( sizeof(AMI_MENU_ENTRY) *(gPages->PageCount) );
+ count = ( gPages->PageCount > gApp->PageCount ) ? gPages->PageCount : gApp->PageCount ;
+
+ if(gIsRootPageOrderPresent)
+ {
+ //for( k=0 ; (gRootPageOrder[k] != 0); k++ );
+ for( j=0 ; j < gRootPageOrderIndex ; j++ )
+ {
+ for ( i = 0; i < (UINT16)count; i++ )
+ {
+ if(i > gPages->PageCount )
+ {
+ if(gApp->PageList[i] == NULL)
+ continue;
+ info = (PAGE_INFO*)&( gApp->PageList[i]->PageData);
+ PageCount = gApp->PageCount;
+ }
+ else
+ {
+ info = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[i]);
+ PageCount = gPages->PageCount;
+ }
+
+ if( (info->PageHandle == NULL ) || (info->PageHandle == (VOID*)(UINTN)0xffff ))
+ continue;
+
+ if (!( info->PageID == 0) && (info->PageParentID == 0) &&
+ (gRootPageOrder[j].formId == info->PageFormID) )
+ {
+ PAGE_ID_INFO *pageIdInfo;
+ pageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[info->PageIdIndex]);
+
+ if(gRootPageOrder[j].Handle)
+ if(gRootPageOrder[j].Handle != info->PageHandle)
+ continue;
+
+ if(!EfiCompareGuid(&pageIdInfo->PageGuid, &gRootPageOrder[j].formsetGuid) )//Compare Guid
+ {
+ continue;
+ }
+
+ if(info->PageFlags.PageVisible)
+ continue; //To Control the root page not to show.
+
+ menu->Entries[menu->NumEntries].PageHandle = info->PageHandle;
+ menu->Entries[menu->NumEntries].PageID = info->PageID;
+ menu->Entries[menu->NumEntries].StringToken = info->PageSubTitle;
+
+ if( menu->ControlData.ControlPageID == info->PageID )
+ menu->CurrEntry = menu->NumEntries;
+
+ if(menu->Entries[menu->NumEntries].PageHandle != 0)
+ menu->NumEntries++;
+ }
+
+
+ }
+ }
+ }
+
+ for ( i = 0; i < (UINT16)count; i++ )
+ {
+ // EIP 68920: Due to dynamic updates, SetupData (most current data)
+ // is given priority when re-initializing menu.
+ if(i > gPages->PageCount )
+ {
+ if(gApp->PageList[i] == NULL)
+ continue;
+ info = (PAGE_INFO*)&( gApp->PageList[i]->PageData);
+ PageCount = gApp->PageCount;
+ }
+ else
+ {
+ info = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[i]);
+ PageCount = gPages->PageCount;
+ }
+
+ if( (info->PageHandle == NULL ) || (info->PageHandle == (VOID*)(UINTN)0xffff ))
+ continue;
+
+ if( info->PageID == 0)
+ {
+ }
+ else
+ {
+ if((info->PageParentID ==0) /*&& (info->PageFlags.PageVisible)*/)
+ {
+ if(info->PageFlags.PageVisible || gIsRootPageOrderPresent)
+ continue; //To Control the root page not to show.
+
+ menu->Entries[menu->NumEntries].PageHandle = info->PageHandle;
+ menu->Entries[menu->NumEntries].PageID = info->PageID;
+ menu->Entries[menu->NumEntries].StringToken = info->PageSubTitle;
+
+ if( menu->ControlData.ControlPageID == info->PageID )
+ menu->CurrEntry = menu->NumEntries;
+
+ if(menu->Entries[menu->NumEntries].PageHandle != 0)
+ menu->NumEntries++;
+
+ }
+ else
+ {
+ if( menu->ControlData.ControlPageID == info->PageID )
+ {
+ tempPage =info;
+ while(tempPage->PageParentID!=0)
+ {
+ for(j=0;j < PageCount;j++)
+ {
+
+ // EIP 68920: Due to dynamic updates, SetupData (most current data)
+ // is given priority when re-initializing menu.
+ if(j < gPages->PageCount)
+ {
+ if( tempPage->PageParentID == ((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[j]))->PageID)
+ {
+ menu->IsSubMenu = 1;
+ tempPage =((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[j]));
+ j=0;
+ if(tempPage->PageParentID ==0)
+ break;
+
+ }
+
+ }
+ else
+ {
+ if(gApp->PageList[j] == NULL)
+ continue;
+
+ if( tempPage->PageParentID == gApp->PageList[j]->PageData.PageID)
+ {
+ menu->IsSubMenu = 1;
+ tempPage =&(gApp->PageList[j]->PageData);
+ j=0;
+ if(tempPage->PageParentID ==0)
+ break;
+
+ }
+
+ }
+ }
+ }
+
+ // find the item number for the parent in the menu
+ for(j=0;j<menu->NumEntries;j++)
+ {
+ if( (tempPage !=NULL) && ( tempPage->PageID == menu->Entries[j].PageID) )
+ {
+ menu->CurrEntry = j;
+ break;
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+ menu->ControlData.ControlHelp = UefiGetHelpField((VOID *)menu->ControlData.ControlPtr);
+ menu->ControlFocus = FALSE;
+
+ // initialize default colors
+ SetControlColorsHook(NULL, NULL,
+ &(menu->SelFGColor),&(menu->SelBGColor),
+ NULL, NULL,
+ NULL, NULL,
+ NULL,NULL,
+ NULL,
+ NULL ,NULL,
+ &(menu->FGColor),&(menu->BGColor));
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuDraw
+//
+// Description: Function to draw a Menu.
+//
+// Input: MENU_DATA *menu
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuDraw( MENU_DATA *menu )
+{
+ CHAR16 *text=NULL, *tmp=NULL;
+ UINTN offset=0,length;
+ UINT16 StartItem=0,PageNum=0,ActualPage=0,ItemsInPage=0,ItemFound=0,k=0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorMenu = menu->FGColor;
+ UINT8 Pos=(UINT8) menu->Left;
+ UINT16 i=0,j=0;
+ PAGE_DATA *Page ;
+ BOOLEAN Overflow = FALSE ;
+
+ Page = gApp->PageList[gApp->CurrentPage];
+
+
+ //erase menu line
+ for(i=1;i <= /*MAX_COLS*/menu->MenuWidth; i++, Pos++ )
+ DrawStringWithAttribute( Pos , menu->Top,L" ",menu->BGColor | menu->FGColor );
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( menu->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &menu->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorMenu = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ tmp = EfiLibAllocateZeroPool( 256 );
+ if ( tmp == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ Pos = (UINT8)menu->Left;
+
+ //loop to find which menu entries to draw
+ for( k = 0 ; k < menu->NumEntries ; k++ )
+ {
+ //get string from hii
+ text = HiiGetString(menu->Entries[k].PageHandle , menu->Entries[k].StringToken );
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ length = (UINT16)((TestPrintLength( text ) / (NG_SIZE)) + 2); // take in account added space on either side of menu below.
+
+ //EIP:68341 Dynamic pages may contain lengthy FormSet Title strings, truncate if necessary.
+ //EIP# 72333, Display page title of submenu pages in the menu tab.
+ if(length >(UINTN) (menu->MenuWidth-2) )
+ {
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(menu->MenuWidth-5))],L"...");
+ length = menu->MenuWidth-2 ;
+ }
+
+ //EIP:39570 Adding to length may create additional pages to accommodate extra space.
+ if ((offset + length /*+2*/) >= /*MAX_COLS*/(UINTN)(menu->MenuWidth-2))
+ {
+ PageNum ++;
+ if(!ItemFound)
+ {
+ ActualPage++;
+ StartItem = k;
+ ItemsInPage=0;
+ offset=length+2;
+ }
+ else
+ {
+ MemFreePointer( (VOID **)&text );
+ break;
+ }
+ }
+ else
+ offset += length /*+2*/;
+
+ if(k == menu->CurrEntry)
+ ItemFound=1;
+
+ ItemsInPage++;
+ MemFreePointer( (VOID **)&text );
+ }
+
+ menu->StartItem = StartItem;
+ menu->ActualPage = ActualPage;
+ menu->PageNum = PageNum;
+ menu->ItemsInPage = ItemsInPage;
+
+ if(ActualPage > 0 )
+ {
+ if(!( menu->IsSubMenu ))
+ {
+ SPrint( tmp, 6, L"%c ", GEOMETRICSHAPE_LEFT_TRIANGLE );
+ DrawStringWithAttribute( menu->Left, menu->Top ,tmp, menu->BGColor | menu->FGColor );
+ }
+ //Pos += 2;
+ }
+ Pos += 1; // always leave space for the arrow even if it is not drawn
+ j = (UINT16)StartItem;
+
+ for(i=0;(i < ItemsInPage) && ( i+j < menu->NumEntries) ;i++)
+ {
+ UINTN StrPrntLen=0; //to fill with the length of the string to draw.
+
+ //get string from hii
+
+ //EIP# 72333, Display page title of submenu pages in the menu tab.
+ if ( i+j == menu->CurrEntry && menu->IsSubMenu && IsSubMenuDisplayTitle())
+ {
+ text = HiiGetString(Page->PageData.PageHandle, Page->PageData.PageSubTitle );
+ }
+ else
+ {
+ text = HiiGetString(menu->Entries[i+j].PageHandle , menu->Entries[i+j].StringToken );
+ }
+
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ length = (UINT16)(TestPrintLength( text ) / (NG_SIZE));
+
+ //EIP:68341 Dynamic pages may contain lengthy FormSet Title strings, truncate if necessary.
+ //EIP# 72333, Display page title of submenu pages in the menu tab.
+ if( (Pos-2+length) >(UINTN) (menu->MenuWidth-2) )
+ {
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(menu->MenuWidth-5-Pos-2))],L"...");
+ length = menu->MenuWidth-2 ;
+ Overflow = TRUE ;
+ }
+
+ // the size of the string plus additional characters(2 spaces + Null character)
+ StrPrntLen = length+3;
+ // The Menu title length should be less than Max display size.
+ if(length >= gMaxCols) {
+ StrPrntLen = gMaxCols-2;
+ }
+
+ // print the string for the lenth uptained
+ SPrint( tmp, StrPrntLen*sizeof(CHAR16), L" %s ", text );
+ if ( i+j == menu->CurrEntry )
+ {
+ DrawStringWithAttribute( Pos , menu->Top , tmp, menu->SelFGColor | menu->SelBGColor);
+ Pos += 2+(UINT8)length;
+ }
+ else
+ {
+ if( !(menu->IsSubMenu))
+ DrawStringWithAttribute( Pos , menu->Top, tmp, menu->BGColor | menu->FGColor );
+ Pos += 2+(UINT8)length;
+ }
+ MemFreePointer( (VOID **)&text );
+
+ if(Overflow)
+ break ;
+ }
+
+ if( (ActualPage < PageNum) && !(menu->IsSubMenu))
+ {
+ SPrint( tmp, 6, L"%c",GEOMETRICSHAPE_RIGHT_TRIANGLE );
+ DrawStringWithAttribute( gMaxCols-1, menu->Top ,tmp, menu->BGColor | menu->FGColor );
+ }
+
+ MemFreePointer( (VOID **)&tmp );
+ FlushLines( menu->Top, menu->Top );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MenuCallCallback
+//
+// Description: Internal Helper Function to Call the callback
+//
+// Input: MENU_DATA *menu, UINT8 MenuEntry
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _MenuCallCallback(MENU_DATA *menu,UINT16 MenuEntry)
+{
+ if ( ( menu->Callback != NULL ) && (menu->Cookie != NULL) )
+ {
+ CALLBACK_MENU *callbackData = (CALLBACK_MENU *)menu->Cookie;
+ callbackData->DestPage = menu->Entries[MenuEntry].PageID;
+ menu->Callback( menu->Container, menu, menu->Cookie );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuHandleAction
+//
+// Description: Function to handle actions.
+//
+// Input: MENU_DATA *menu, ACTION_DATA *Data
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuHandleAction( MENU_DATA *menu, ACTION_DATA *Data)
+{
+ // control is in separate frame for ezport.
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 TempEntry;
+ PAGE_DATA *page = NULL ;
+ page = gApp->PageList[gApp->CurrentPage];
+
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ return Status;
+ if(!page){
+ return Status;
+ }
+ if(page->PageData.PageFlags.PageModal){
+ return Status;
+ }
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ Status = MouseMenuHandleAction( menu, Data );
+ }
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ CONTROL_ACTION Action;
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ switch(Action)
+ {
+ case ControlActionNextLeft:
+ if(!(menu->IsSubMenu))
+ {
+ if ( menu->CurrEntry > 0 )
+ TempEntry = menu->CurrEntry - 1;
+ else
+ TempEntry = menu->NumEntries - 1;
+
+ _MenuCallCallback(menu,TempEntry);
+ }
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionNextRight:
+ if(!(menu->IsSubMenu))
+ {
+ if ( menu->CurrEntry < menu->NumEntries - 1 )
+ TempEntry = menu->CurrEntry + 1;
+ else
+ TempEntry = 0;
+
+ _MenuCallCallback(menu,TempEntry);
+ }
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: MENU_DATA *menu, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetCallback( MENU_DATA *menu, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( menu, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: MENU_DATA *menu, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetFocus(MENU_DATA *menu, BOOLEAN focus)
+{
+
+ if( !(menu->ControlFocus && focus) )
+ menu->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetPosition
+//
+// Description: Function to set position.
+//
+// Input: MENU_DATA *menu, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetPosition(MENU_DATA *menu, UINT16 Left, UINT16 Top )
+{
+ // Width -> is the container frame width the menu width is that minus 2 spaces.
+ // Left and rigth menu spaces will contain arrows in case that there are multiple pages for the menu.
+ return gControl.SetPosition( menu, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: MENU_DATA *menu, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetDimensions(MENU_DATA *menu, UINT16 Width, UINT16 Height )
+{
+ MenuSetWidth(menu, (UINT8)Width);
+ return gControl.SetDimensions( menu, Width-2, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: MENU_DATA *menu, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetAttributes(MENU_DATA *menu, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( menu, FGColor, BGColor );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuSetWidth
+//
+// Description: Function to set width.
+//
+// Input: VOID *menu, UINT8 Width
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuSetWidth(VOID *menu, UINT8 Width)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Width -> is the container frame width the menu width is that minus 2 spaces.
+ // Left and rigth menu spaces will contain arrows in case that there are multiple pages for the menu.
+ ((MENU_DATA*)menu)->MenuWidth = Width-2;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEMouseMenuHandleAction
+//
+// Description: Function to hadnle Menu using mouse
+//
+// Input: MENU_DATA *menu,
+// ACTION_DATA *Data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TSEMouseMenuHandleAction( MENU_DATA *menu, ACTION_DATA *Data )
+{
+ // control is in separate frame for ezport.
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 TempEntry;
+ UINTN i;
+ UINTN Pos = menu->Left, StartPos, StrLen;
+ CHAR16 *text=NULL;
+ CONTROL_ACTION Action;
+ //If a sub menu is being displayed no need to handle action
+ if(menu->IsSubMenu)
+ return EFI_UNSUPPORTED;
+
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+
+
+ //Check if left arrow is displayed
+ if(menu->ActualPage > 0)
+ {
+ //Check if left arrow clicked
+ if(
+ (Data->Input.Data.MouseInfo.Left == menu->Left) &&
+ (Data->Input.Data.MouseInfo.Top == menu->Top) &&
+ ( (Action == ControlActionChoose ) || (Action == ControlActionSelect) )//Performing menu scroll for only action choose and select
+ )
+ {
+ //Handle left arrow click
+ if ( menu->CurrEntry > 0 )
+ TempEntry = menu->CurrEntry - 1;
+ else
+ TempEntry = menu->NumEntries - 1;
+
+ _MenuCallCallback(menu,TempEntry);
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ //Check if right arrow is displayed
+ if(menu->ActualPage < menu->PageNum)
+ {
+ //Check if right arrow clicked
+ if(
+ (Data->Input.Data.MouseInfo.Left == gMaxCols-1) &&
+ (Data->Input.Data.MouseInfo.Top == menu->Top) &&
+ ( (Action == ControlActionChoose ) || (Action == ControlActionSelect) )//Performing menu scroll for only action choose and select
+ )
+ {
+ //Handle right arrow click
+ if ( menu->CurrEntry < menu->NumEntries - 1 )
+ TempEntry = menu->CurrEntry + 1;
+ else
+ TempEntry = 0;
+
+ _MenuCallCallback(menu,TempEntry);
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ //Handle individual Page selections
+ Pos++;
+ for(i = menu->StartItem; i < (UINTN)(menu->StartItem + menu->ItemsInPage); i++)
+ {
+ StartPos = Pos;
+ text = HiiGetString(menu->Entries[i].PageHandle , menu->Entries[ i ].StringToken );
+ StrLen = (TestPrintLength( text ) / (NG_SIZE));
+ MemFreePointer( (VOID **)&text );
+ Pos = StartPos + StrLen + 2;
+
+ if(
+ (Data->Input.Data.MouseInfo.Left >= StartPos) &&
+ (Data->Input.Data.MouseInfo.Left < Pos) &&
+ (Data->Input.Data.MouseInfo.Top == (UINT32)(menu->Top)) //EIP-73377: Check for the exact menu tab co-ordinates.
+ )
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ if( (Action == ControlActionChoose ) || (Action == ControlActionSelect) )
+ {
+ if(i != menu->CurrEntry)
+ {
+ _MenuCallCallback(menu,(UINT16)i);
+ }
+ Status=EFI_SUCCESS;
+ }
+ break;
+ }
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MenuGetControlHight
+//
+// Description: Function unsupported.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MenuGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Suite 200, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+
diff --git a/EDK/MiniSetup/TseLite/Menu.h b/EDK/MiniSetup/TseLite/Menu.h
new file mode 100644
index 0000000..d8b21bc
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Menu.h
@@ -0,0 +1,179 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Menu.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Menu.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 7 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:39a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Menu.h
+//
+// Description: Header file for Menu controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _MENU_H_
+#define _MENU_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+typedef struct _IFR_MENU
+{ // this structure is, in some way, following EFI_IFR structures
+ UINT8 Opcode, Length;
+}AMI_IFR_MENU;
+
+typedef struct _MENU_ENTRY
+{
+ /*EFI_HII_HANDLE*/VOID* PageHandle;
+ UINT16 PageID;
+ UINT16 StringToken; // page title to use in menu
+}AMI_MENU_ENTRY;
+
+
+#define MENU_MEMBER_VARIABLES \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT16 NumEntries; \
+ UINT16 CurrEntry; \
+ UINT8 IsSubMenu; \
+ UINT8 MenuWidth; \
+ UINT16 StartItem; \
+ UINT16 ActualPage; \
+ UINT16 PageNum; \
+ UINT16 ItemsInPage; \
+ AMI_MENU_ENTRY *Entries;
+
+
+typedef struct _MENU_METHODS MENU_METHODS;
+
+typedef struct _MENU_DATA
+{
+ MENU_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ MENU_MEMBER_VARIABLES
+
+}
+MENU_DATA;
+
+typedef EFI_STATUS (*MENU_METHOD_SET_WIDTH) ( VOID *object, UINT8 Width );
+
+#define MENU_METHOD_FUNCTIONS \
+ MENU_METHOD_SET_WIDTH SetWidth;
+
+struct _MENU_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ MENU_METHOD_FUNCTIONS
+};
+
+extern MENU_METHODS gMenu;
+
+// Object Methods
+EFI_STATUS MenuCreate( VOID **object );
+EFI_STATUS MenuDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS MenuInitialize( VOID *object, VOID *data );
+EFI_STATUS MenuDraw( VOID *object );
+EFI_STATUS MenuHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS MenuSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS MenuSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS MenuSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS MenuSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS MenuSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS MenuGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+//menu methods
+EFI_STATUS MenuSetWidth(VOID *menu,UINT8 Width);
+
+#endif /* _MENU_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/MessageBox.c b/EDK/MiniSetup/TseLite/MessageBox.c
new file mode 100644
index 0000000..22a5014
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/MessageBox.c
@@ -0,0 +1,1192 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/MessageBox.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 31 $
+//
+// $Date: 8/28/14 8:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/MessageBox.c $
+//
+// 31 8/28/14 8:02a Premkumara
+// [TAG] EIP107833, 125388
+// [Category] Improvement
+// [Symptom:] Setting best text and GOP mode while using TSEPostinterfaces
+// before TSE or after TSE.
+// [Files] Protocol.c, AMITSE.sdl, CommonHelper.c, MiniSetup.sdl,
+// PostMgmtc, PostmgmtExt.c, MessagBox.c
+//
+// 30 5/03/14 3:13p Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 29 5/02/14 3:51a Arunsb
+// [TAG] EIP155965
+// [Category] Improvement
+// [Description] MessageBox, ListBox cannot be canceled by Mouse
+// Right-Click
+// [Files] MessageBox.c, ListBox.c and minisetupext.c
+//
+// 28 2/11/14 8:35p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 27 12/05/13 1:29a Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 26 5/22/13 10:59a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c
+//
+// 25 1/22/13 12:20a Rajashakerg
+// [TAG] EIP103449
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In Setup click\Touch from navigation window, option are not
+// displayed properly
+// [RootCause] Latest mouse driver providing LEFT_DOWN when we hold the
+// mouse left down button.
+// [Solution] Provided fix resolves the issue.
+// [Files] ezport.c, PopupEdit.c, ListBox.c, MessageBox.c
+//
+// 24 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 22 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 23 5/24/12 9:02a Arunsb
+// [TAG] EIP90379
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] UefiBootFailHook asserts when it is trying to call
+// MsgBoxDestroy
+// [RootCause] Tried to free the NULL pointer
+// [Solution] Checked NULL before freeing
+// [Files] TseAdvanced.c and MessageBox.c
+//
+// 22 5/24/12 7:31a Rajashakerg
+// [TAG] EIP88811
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When pop-up window is invoked in setup and Click on ESC
+// icon or ESC/Right Click, it will respond as two times ESC is clicked
+// [RootCause] ESC functionality provided for left click on the ESC
+// sting navigation frame .
+// [Solution] Now providing the ESC sequence for left down and double
+// click
+// [Files] ezport.c, numeric.c, MessageBox.c
+//
+// 21 2/02/12 1:17p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 20 12/01/11 5:43a Rajashakerg
+// [TAG] EIP74963
+// [Category] Improvement
+// [Description] MAX_MSGBOX_WIDTH cannot be overridden
+// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
+// MessageBox.c, MessageBox.h, FormBrowser.c
+//
+// 19 12/01/11 1:42a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 18 11/30/11 12:42a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 17 11/20/11 7:50a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 16 11/10/11 8:30a Rajashakerg
+// [TAG] EIP74965
+// [Category] Improvement
+// [Description] Progress bar in MSGBOX_TYPE_PROGRESS never displays the
+// full 100%
+// [Files] MessageBox.c
+//
+// 15 12/28/10 9:06a Mallikarjunanv
+// Removing the changes of EIP:48381 which are not required.
+//
+// 14 12/24/10 12:50p Mallikarjunanv
+//
+// 13 12/24/10 12:48p Mallikarjunanv
+// [TAG] EIP 46143
+// [Category] Bug Fix
+// [Severity]- Medium
+// [Symptom]- In Boot tab, "Add boot option" -> "Add boot option" option,
+// adding string displayed "invalid string" message , on clicking OK in
+// the message box using mouse not closing msg box.
+// [RootCause] In case of message box selection with mouse the
+// coordinates are improper.
+// [Solution] Message box coordinates are updated with respect to
+// selection with mouse.
+// [Files] MessageBox.c
+//
+// 12 12/24/10 10:49a Mallikarjunanv
+// [TAG] EIP48381
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse click operation not working properly in the warning
+// [RootCause] In TSEMouseMsgBoxHandleAction function coordinates for
+// mouse click are improper
+// [Solution] Fixed the issue by updating the coordinates for mouse
+// click
+// operation
+// [Files] MessageBox.c
+//
+// 11 10/20/10 1:42p Mallikarjunanv
+// reverting back to v25
+//
+// 9 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 16 7/07/10 7:37p Madhans
+// To avoid Warning.
+//
+// 15 5/19/10 4:13p Blaines
+// Added length boundry check for legend string
+//
+// 14 4/22/10 6:23p Blaines
+// Adjust Messagebox width if required to display legend string.
+//
+// 13 4/20/10 7:02p Blaines
+// Add mouse support for custom messagebox type
+//
+// 12 4/20/10 6:20p Blaines
+// Support custom messagebox type in MsgBoxHandleAction
+//
+// 11 4/09/10 12:26p Madhans
+// To freeup the strings
+//
+// 10 3/26/10 6:53p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 9 3/24/10 12:00p Blaines
+// Message box color can be configured based on message box type
+// (help, error, etc)
+//
+// This change corrects the selected button FG/BG color.
+//
+// 8 3/23/10 5:20p Blaines
+// Extend Message Box support
+// Adds Custom Type
+// Adds Progress Bar Type
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/15/10 10:13p Madhans
+// To avoid warnings
+//
+// 5 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 4 1/09/10 6:39a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MessageBox.c
+//
+// Description: This file contains code to handle Message Box operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+MSGBOX_METHODS gMsgBox =
+{
+ MsgBoxCreate,
+ MsgBoxDestroy,
+ MsgBoxInitialize,
+ MsgBoxDraw,
+ MsgBoxHandleAction,
+ MsgBoxSetCallback,
+ MsgBoxSetFocus,
+ MsgBoxSetPosition,
+ MsgBoxSetDimensions,
+ MsgBoxSetAttributes,
+ MsgBoxGetControlHight,
+ MsgBoxSetType
+};
+
+/////////////////////////////////////////////////
+///// Extern variables and functions
+/////////////////////////////////////////////////
+void ClearGrphxScreen (void);
+BOOLEAN SingleClickActivation (VOID); //EIP-139608
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxCreate
+//
+// Description: Function to Create Message Box, which uses the Popup functions.
+//
+// Input: MSGBOX_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxCreate( MSGBOX_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(MSGBOX_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gPopup.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gMsgBox;
+
+ // create the memo
+ gMemo.Create(&((*object)->Memo));
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxDestroy
+//
+// Description: Function to Destroy Message Box, which uses the Popup functions.
+//
+// Input: MSGBOX_DATA *msgbox, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxDestroy( MSGBOX_DATA *msgbox, BOOLEAN freeMem )
+{
+ EFI_STATUS Status;
+
+ if(NULL == msgbox)
+ return EFI_SUCCESS;
+
+ Status = gPopup.Destroy( msgbox, FALSE );
+ MemFreePointer( (VOID **)&(msgbox->Memo->ControlData.ControlPtr) );
+ Status = gMemo.Destroy( msgbox->Memo, FALSE );
+
+ if(msgbox->Title)
+ MemFreePointer( (VOID **)&msgbox->Title );
+
+ //Restore saved screen only inside TSE
+ if (TSE_POST_STATUS_IN_TSE == gPostStatus)
+ {
+ if (msgbox->ScreenBuf) //Restore If it has valid data
+ RestoreScreen( msgbox->ScreenBuf );
+ }
+
+ if (freeMem)
+ {
+ if (NULL != msgbox->Legend) //EIP 90379
+ {
+ MemFreePointer ((VOID **)&msgbox->Legend);//EIP-73236
+ }
+ if (NULL != msgbox->PtrTokens)
+ {
+ MemFreePointer ((VOID **)&msgbox->PtrTokens);
+ }
+ // MemFreePointer( (VOID **)&msgbox->HotKeyList );
+ // MemFreePointer( (VOID **)&msgbox->OutKey );
+ MemFreePointer( (VOID **)&msgbox );
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxInitialize
+//
+// Description: Function to Initialize Message Box, which uses the Popup functions.
+//
+// Input: MSGBOX_DATA *msgbox, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxInitialize( MSGBOX_DATA *msgbox, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Length =0 ;
+ VOID *buff;
+ CONTROL_INFO MemoCtrlData;
+ MEMO_DATA *memo;
+ UINT8 Color ;
+
+ UINT16 titleToken;
+ VOID* TextHandle =((AMI_IFR_MSGBOX*)(((CONTROL_INFO*)data)->ControlPtr))->TextHandle;
+
+ // initializes the heigth and width
+ Status = gPopup.Initialize( msgbox, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ Status = StyleGetMessageboxColor(msgbox->MsgBoxCatagory, &Color) ;
+
+ if ( EFI_ERROR( Status ) == EFI_SUCCESS)
+ {
+ msgbox->FGColor = Color & 0x0f ;
+ msgbox->BGColor = Color & 0xf0 ;
+ }else
+ // add extra initialization here...
+ SetControlColorsHook( NULL, NULL, NULL , NULL, NULL , NULL, NULL ,
+ NULL , NULL, NULL,NULL ,
+ NULL,NULL ,&(msgbox->FGColor),&(msgbox->BGColor) );
+
+
+ msgbox->Container = NULL;
+
+ msgbox->Border =TRUE;
+
+ titleToken = (UINT16)(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Title);
+ if ( titleToken != 0 ) {
+ msgbox->Title = HiiGetString(msgbox->ControlData.ControlHandle, titleToken);
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if(NULL == msgbox->Title){
+ msgbox->Title = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!msgbox->Title)
+ return EFI_OUT_OF_RESOURCES;
+ EfiStrCpy(msgbox->Title,L" ");
+ }
+ }
+
+ Length = (UINT16)HiiMyGetMultiLineStringLength(msgbox->ControlData.ControlHandle, (UINT16)(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Text));
+
+ if ( ( msgbox->Title != NULL) && ( Length < (TestPrintLength( msgbox->Title )/ (NG_SIZE)) ) )
+ Length = (UINT16)(TestPrintLength( msgbox->Title ) / (NG_SIZE));
+
+ msgbox->Width = (UINT16)(Length + 4);
+
+ if(( msgbox->MsgBoxType == MSGBOX_TYPE_NULL ) && ( msgbox->Legend != NULL ))
+ {
+ if ( msgbox->Width < (UINT16)(TestPrintLength( msgbox->Legend )/ (NG_SIZE)) )
+ msgbox->Width = (UINT16)(TestPrintLength( msgbox->Legend ) / (NG_SIZE)) + 8;
+ }
+//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
+ if ( msgbox->Width > GetMsgboxWidth())
+ msgbox->Width = GetMsgboxWidth();
+
+ //Save the screen only insied TSE not for PostInterfaces outside TSE
+ if (TSE_POST_STATUS_IN_TSE == gPostStatus)
+ msgbox->ScreenBuf = SaveScreen();
+
+ //Clear screen before displaying msgbox when PROCEED_TO_BOOT not inside TSE
+ if (TSE_POST_STATUS_PROCEED_TO_BOOT == gPostStatus)
+ {
+ ClearGrphxScreen(); //Clearing full screen when image is drawn in quietBoot mode
+ ClearScreen(EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY);
+ }
+
+ // initialize memo control
+ memo = msgbox->Memo;
+
+ buff = UefiCreateSubTitleTemplate(((AMI_IFR_MSGBOX*)(msgbox->ControlData.ControlPtr))->Text );
+
+
+ MemSet( &MemoCtrlData, sizeof(MemoCtrlData), 0 );
+ MemoCtrlData.ControlPtr = (VOID*)buff;
+ MemoCtrlData.ControlHandle = TextHandle;
+ MemoCtrlData.ControlFlags.ControlVisible = TRUE;
+ gMemo.Initialize(memo,(VOID *)&(MemoCtrlData));
+ memo->Width = msgbox->Width - 2;
+ gMemo.GetControlHeight( memo, NULL, &msgbox->Height );
+ msgbox->Height += 4;
+
+ gMemo.SetAttributes(memo,msgbox->FGColor ,msgbox->BGColor);
+ gMemo.SetDimensions( memo, msgbox->Width-2 , msgbox->Height-3 );
+ gMemo.SetJustify( memo, JUSTIFY_CENTER );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MsgBoxOptSize
+//
+// Description: Function returns and fix the option string
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _MsgBoxOptSize(CHAR16 *txt)
+{
+ UINTN Size = (TestPrintLength( txt ) / (NG_SIZE));
+ if( Size > 10)
+ {
+ txt[HiiFindStrPrintBoundary(txt,10)] = L'\0';
+ Size = (TestPrintLength( txt ) / (NG_SIZE)); // Need to do this. instead of assigning 10;
+ }
+ return Size;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MsgBoxDrawOpts
+//
+// Description: Function to Draw Message box options
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _MsgBoxDrawOpts(MSGBOX_DATA *msgbox)
+{
+ UINT16 Index, W;
+ CHAR16 Line[MAX_COLS] ,*txt;
+ UINTN printLength, pos ;
+
+ if ( msgbox->MsgBoxType != MSGBOX_TYPE_NULL )
+ {
+ for ( Index = 1; Index < msgbox->Width -1 ; Index++ )
+ Line[Index] = BOXDRAW_HORIZONTAL;
+
+ Line[0] = BOXDRAW_VERTICAL_RIGHT;
+ Line[Index] = BOXDRAW_VERTICAL_LEFT;
+ Line[Index+1] = 0x0;
+
+ DrawString( msgbox->Left, msgbox->Top + msgbox->Height - 3, Line );
+
+ // draw the buttons
+ switch ( msgbox->MsgBoxType & MSGBOX_TYPE_MASK )
+ {
+
+ case MSGBOX_TYPE_YESNO:
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, STRING_TOKEN(STR_CTRL_YES));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+
+ msgbox->Button1Len = (UINT8)_MsgBoxOptSize(txt );
+ DrawStringWithAttribute((UINTN) (msgbox->Left + msgbox->Width/3 -2) , (UINTN)(msgbox->Top + msgbox->Height -2), txt, (UINT8) (((msgbox->MsgboxSel==0)? EFI_BACKGROUND_BLACK|EFI_WHITE : msgbox->BGColor|msgbox->FGColor)));
+ MemFreePointer( (VOID **)&txt);
+
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, STRING_TOKEN(STR_CTRL_NO));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+
+ msgbox->Button2Len = (UINT8)_MsgBoxOptSize(txt );
+
+ DrawStringWithAttribute((UINTN)( msgbox->Left + 2*(msgbox->Width/3) -2) ,(UINTN)(msgbox->Top + msgbox->Height -2), txt, (UINT8) (((msgbox->MsgboxSel==1)? EFI_BACKGROUND_BLACK|EFI_WHITE : msgbox->BGColor|msgbox->FGColor)));
+ MemFreePointer( (VOID **)&txt);
+
+ break;
+ case MSGBOX_TYPE_OKCANCEL:
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, STRING_TOKEN(STR_CTRL_OK));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+ msgbox->Button1Len = (UINT8)_MsgBoxOptSize(txt );
+ DrawStringWithAttribute((UINTN) (msgbox->Left + msgbox->Width/3 -2) , (UINTN)(msgbox->Top + msgbox->Height -2), txt, (UINT8) (((msgbox->MsgboxSel==0)? EFI_BACKGROUND_BLACK|EFI_WHITE : msgbox->BGColor|msgbox->FGColor)));
+ MemFreePointer( (VOID **)&txt);
+
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, STRING_TOKEN(STR_CTRL_CANCEL));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+ msgbox->Button2Len = (UINT8)_MsgBoxOptSize(txt );
+ DrawStringWithAttribute((UINTN)( msgbox->Left + 2*(msgbox->Width/3) -2) ,(UINTN)(msgbox->Top + msgbox->Height -2), txt, (UINT8) (((msgbox->MsgboxSel==1)? EFI_BACKGROUND_BLACK|EFI_WHITE : msgbox->BGColor|msgbox->FGColor)));
+ MemFreePointer( (VOID **)&txt);
+ break;
+
+ case MSGBOX_TYPE_CUSTOM:
+
+ if ( (msgbox->OptionCount != 0) && (msgbox->PtrTokens != NULL ))
+ {
+ W = ( msgbox->Width)/(msgbox->OptionCount) ;
+
+
+ for ( Index = 0; Index < msgbox->OptionCount ; Index++ )
+ {
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, msgbox->PtrTokens[Index]);
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+ pos = (UINTN) (msgbox->Left + (Index * W) ) ;
+
+ printLength = (TestPrintLength( txt ) / (NG_SIZE));
+
+ if( printLength > W)
+ {
+ txt[HiiFindStrPrintBoundary(txt, W)] = L'\0';
+ printLength = (TestPrintLength( txt ) / (NG_SIZE));
+ }
+
+ DrawStringWithAttribute(pos + (W-printLength)/2 , (UINTN)(msgbox->Top + msgbox->Height -2 ), txt, (UINT8) (((msgbox->MsgboxSel==Index)? EFI_BACKGROUND_BLACK|EFI_WHITE : msgbox->BGColor|msgbox->FGColor)));
+ MemFreePointer( (VOID **)&txt);
+ }
+ }
+
+ break;
+
+ case MSGBOX_TYPE_PROGRESS:
+ //Draw the progress bar based on percent complete, for example
+
+ //----------------------- Title ------------------------//
+ // //
+ // Message Body will be printerd here //
+ // //
+ //------------------------------------------------------//
+ // ##################### 10% #### // <--- This section is where to use DrawStringWithAttribute
+ //--------------------- Legend -------------------------//
+
+ {
+ CHAR16 Box[2] = {0};
+ CHAR16 PercentStr[5] = {0};
+ UINT16 Index = 0;
+ UINT16 ChrIdx=msgbox->Left;
+ UINT16 ProgPos=0;
+
+ //symbol character to show during progress update
+ Box[0] = (CHAR16)BLOCKELEMENT_FULL_BLOCK ; //L'#';
+ Box[1] = (CHAR16)L'\0';
+
+
+ //max percentage should be 100
+ if( msgbox->Percent > 100) {
+ msgbox->Percent = 100;
+ }
+
+ //percentage to update on the progress bar
+ if( msgbox->Percent / 100)
+ {
+ PercentStr[Index++] = (CHAR16)(msgbox->Percent / 100) + L'0';
+ PercentStr[Index++] = (CHAR16)((msgbox->Percent % 100) / 10) + L'0';
+
+ }
+ if( (msgbox->Percent % 100) / 10)
+ PercentStr[Index++] = (CHAR16)((msgbox->Percent % 100) / 10) + L'0';
+
+ PercentStr[Index++] = (CHAR16)((msgbox->Percent % 100) % 10) + L'0';
+ PercentStr[Index] = L'%';
+
+ /// some sample logic to fill the progress bar symbol character properly without hard coded values...
+ ProgPos = msgbox->Width - 2;
+ while ( ProgPos < 100 )
+ {
+ if ( 100 % ProgPos != 0){
+ if ( 99 % ProgPos != 0){
+ if ( 98 % ProgPos != 0) {
+ ProgPos--;
+ }
+ else
+ break;//EIP74965 : Progress bar now can show the 100% status
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ ProgPos = 100/ProgPos;
+
+
+ //Fill progress bar for the given percentage
+ for( Index = 0; Index < msgbox->Percent; Index++ ) {
+ //fill the symbol character based on the segment value for the given percentage
+ if( ( msgbox->Percent != 0 ) && ( Index % ProgPos == 0 ) && (ChrIdx < msgbox->Left+msgbox->Width-2) )
+ DrawStringWithAttribute((UINTN) ++ChrIdx, (UINTN)(msgbox->Top + msgbox->Height - 2), Box, (UINT8) msgbox->BGColor|EFI_CYAN/*| msgbox->FGColor*/);
+ }
+
+ if( msgbox->Percent == 100 ) {
+ //to fill the progress bar completely for the box width in case of 100 percentage.
+ for( ; (ChrIdx - msgbox->Left) < (msgbox->Width - 2); )
+ DrawStringWithAttribute((UINTN) ++ChrIdx, (UINTN)(msgbox->Top + msgbox->Height - 2), Box, (UINT8) msgbox->BGColor|EFI_CYAN/*| msgbox->FGColor*/);
+ }
+
+ //draw percentage string on the progress bar
+ DrawStringWithAttribute( msgbox->Left + msgbox->Width / 2 - EfiStrLen(PercentStr)/2, msgbox->Top + msgbox->Height - 3,PercentStr, (UINT8) /*msgbox->BGColor|EFI_RED */msgbox->BGColor | msgbox->FGColor);
+
+ //Draw the given legend
+ DrawStringWithAttribute( msgbox->Left + msgbox->Width / 2 - EfiStrLen(msgbox->Legend)/2, msgbox->Top + msgbox->Height - 1,msgbox->Legend, (UINT8) msgbox->BGColor | msgbox->FGColor);
+ }
+
+ break;
+
+ case MSGBOX_TYPE_OK:
+
+ default:
+ txt = HiiGetString(msgbox->ControlData.ControlHandle, STRING_TOKEN(STR_CTRL_OK));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == txt){
+ break;
+ }
+
+ msgbox->Button1Len = (UINT8)_MsgBoxOptSize(txt );
+ msgbox->Button2Len = 0;
+ DrawStringWithAttribute( msgbox->Left + msgbox->Width/2 , msgbox->Top + msgbox->Height -2, txt, EFI_BACKGROUND_BLACK|EFI_WHITE );
+ MemFreePointer( (VOID **)&txt);
+ break;
+ }
+
+ FlushLines( msgbox->Top + msgbox->Height -3, msgbox->Top + msgbox->Height);
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxDraw
+//
+// Description: Function to Draw Message box
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxDraw( MSGBOX_DATA *msgbox )
+{
+ EFI_STATUS Status;
+ CHAR16 *PadTitle = NULL, *Str = NULL;
+ Str = msgbox->Legend ;
+
+ MouseFreeze();
+
+ Status = gPopup.Draw( msgbox );
+ if(EFI_ERROR(Status))
+ return Status;
+
+ _MsgBoxDrawOpts(msgbox);
+
+ // draw memo
+ gMemo.SetPosition( msgbox->Memo, msgbox->Left + 1, msgbox->Top + 2 );
+ gMemo.SetJustify( msgbox->Memo, (msgbox->MsgBoxType & MSGBOX_STYLE_MASK) >> 4 );
+ gMemo.Draw( msgbox->Memo );
+
+
+
+ if ((Str != NULL) && ( msgbox->MsgBoxType == MSGBOX_TYPE_NULL ) )
+ {
+ PadTitle = EfiLibAllocateZeroPool( (msgbox->Width + 3) * sizeof(CHAR16) );
+
+ if( (UINT16)(TestPrintLength( Str ) / (NG_SIZE)) > (UINT16)(msgbox->Width-2))
+ EfiStrCpy( &Str[HiiFindStrPrintBoundary(Str,(msgbox->Width-5))],L"...");
+
+ if ( PadTitle != NULL )
+ SPrint( PadTitle, msgbox->Width * sizeof(CHAR16), L" %s ",Str );
+ }
+
+ if ( PadTitle )
+ {
+ DrawStringJustified( 0, gMaxCols, msgbox->Top+msgbox->Height-1, JUSTIFY_CENTER, PadTitle );
+ //DrawStringJustified( msgbox->Left+1, msgbox->Left+msgbox->Width-1, msgbox->Top+msgbox->Height, JUSTIFY_CENTER, PadTitle );
+ MemFreePointer((VOID **)&PadTitle);
+ }
+
+ FlushLines( msgbox->Top, msgbox->Top + msgbox->Height );
+ DoRealFlushLines();
+
+ MouseRefresh();
+
+ return EFI_SUCCESS;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _MsgBoxCallCallback
+//
+// Description: Internal Helper Function to Call the callback
+//
+// Input: MENU_DATA *menu, UINT8 MenuEntry
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _MsgBoxCallCallback(MSGBOX_DATA *msgbox,UINT8 MsgboxSel)
+{
+ if ( ( msgbox->Callback != NULL ) && (msgbox->Cookie != NULL) )
+ {
+ CALLBACK_MESSAGEBOX *callbackData = (CALLBACK_MESSAGEBOX *)msgbox->Cookie;
+ callbackData->Result = MsgboxSel;
+ msgbox->Callback( msgbox->Container, msgbox, msgbox->Cookie );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxHandleAction
+//
+// Description: Function to Handle the Message Box Actions.
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxHandleAction( MSGBOX_DATA *msgbox, ACTION_DATA *Data)
+{
+ EFI_STATUS Status;
+ BOOLEAN Redraw = FALSE;
+ //Always return success to consume the message, the messagebox is always modal.
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ return EFI_UNSUPPORTED;
+
+ if ( Data->Input.Type == ACTION_TYPE_MOUSE )
+ {
+ Status = MouseMsgBoxHandleAction( msgbox, Data,&Redraw);
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ CONTROL_ACTION Action;
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ if( TsePrintScreenEventSupport(Data->Input.Data.AmiKey.Key.ScanCode))
+ {
+ gApplication.HandleAction( gApp, Data );
+ return EFI_UNSUPPORTED;//EIP-123432
+ }
+
+ switch(Action)
+ {
+ case ControlActionSelect:
+ // EIP 34545 : If MSGBOX_TYPE_NULL, nothing to select Only Esc can control
+ if (msgbox->MsgBoxType == MSGBOX_TYPE_NULL)
+ break;
+ _MsgBoxCallCallback(msgbox,msgbox->MsgboxSel);
+ break;
+
+ case ControlActionNextLeft:
+ if( ( (msgbox->MsgBoxType & MSGBOX_TYPE_MASK) != MSGBOX_TYPE_OK )&&
+ ( (msgbox->MsgBoxType & MSGBOX_TYPE_MASK) != MSGBOX_TYPE_CUSTOM ))
+ {
+ if ( msgbox->MsgboxSel == 1 )
+ msgbox->MsgboxSel = 0;
+
+ }
+ else if((msgbox->MsgBoxType & MSGBOX_TYPE_MASK) == MSGBOX_TYPE_CUSTOM )
+ {
+ if ( msgbox->MsgboxSel > 0 )
+ msgbox->MsgboxSel--;
+
+ }
+
+ Redraw = TRUE;
+ break;
+
+ case ControlActionNextRight:
+ if( ( (msgbox->MsgBoxType & MSGBOX_TYPE_MASK) != MSGBOX_TYPE_OK )&&
+ ( (msgbox->MsgBoxType & MSGBOX_TYPE_MASK) != MSGBOX_TYPE_CUSTOM ))
+ {
+ if ( msgbox->MsgboxSel == 0 )
+ msgbox->MsgboxSel = 1;
+
+ }
+ else if((msgbox->MsgBoxType & MSGBOX_TYPE_MASK) == MSGBOX_TYPE_CUSTOM )
+ {
+ if ( msgbox->MsgboxSel < msgbox->OptionCount-1 )
+ msgbox->MsgboxSel++;
+ }
+
+ Redraw = TRUE;
+ break;
+
+ case ControlActionAbort:
+ msgbox->MsgboxSel = MSGBOX_CANCEL;
+ _MsgBoxCallCallback(msgbox,msgbox->MsgboxSel);
+ gAction.ClearAction( Data );
+ break;
+ }
+ }
+
+ if ( Redraw == TRUE )
+ gMsgBox.Draw( msgbox );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: MSGBOX_DATA *msgbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetCallback( MSGBOX_DATA *msgbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( msgbox, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetType
+//
+// Description: Function to set message box type.
+//
+// Input: MSGBOX_DATA *msgbox, UINT8 Type
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetType( MSGBOX_DATA *msgbox, UINT8 Type )
+{
+ msgbox->MsgBoxType = Type;
+ if ( (Type & MSGBOX_TYPE_MASK) != MSGBOX_TYPE_NULL )
+ msgbox->Height += 2;
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: MSGBOX_DATA *msgbox, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetFocus(MSGBOX_DATA *msgbox, BOOLEAN focus)
+{
+ msgbox->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetPosition
+//
+// Description: Function to set position.
+//
+// Input: MSGBOX_DATA *msgbox, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetPosition(MSGBOX_DATA *msgbox, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( msgbox, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetDimensions
+//
+// Description: Function to set dimensions.
+//
+// Input: MSGBOX_DATA *msgbox, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetDimensions(MSGBOX_DATA *msgbox, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( msgbox, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxSetAttributes
+//
+// Description: Function to set attrinutes.
+//
+// Input: MSGBOX_DATA *msgbox, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxSetAttributes(MSGBOX_DATA *msgbox, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( msgbox, FGColor, BGColor );
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEMouseMsgBoxHandleAction
+//
+// Description: Function to hadnle Message Box using mouse
+//
+// Input: MSGBOX_DATA *msgbox,
+// ACTION_DATA *action,
+// BOOLEAN * pRedraw
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TSEMouseMsgBoxHandleAction( MSGBOX_DATA *msgbox, ACTION_DATA *Data,BOOLEAN * pRedraw)
+{
+ BOOLEAN ButtonClicked = FALSE;
+ CONTROL_ACTION Action;
+
+ UINT16 Index, W;
+ CHAR16 *txt=NULL;
+ UINTN printLength, pos ;
+
+ //EIP 103449 : In Setup click\Touch from navigation window, option are not displayed properly
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+
+ if((
+ (Data->Input.Data.MouseInfo.Top < msgbox->Top) ||
+ (Data->Input.Data.MouseInfo.Top > (UINT32)(msgbox->Top + msgbox->Height)) ||
+ (Data->Input.Data.MouseInfo.Left < msgbox->Left) ||
+ (Data->Input.Data.MouseInfo.Left > (UINT32)(msgbox->Left + msgbox->Width))
+ )&&( (SingleClickActivation() && (ControlActionSelect ==Action)) || //If singleClickActivation is enabled/Disable
+ (ControlActionAbort == Action) || (ControlActionChoose ==Action ) //EIP-139608 Closing listbox whn mouse action happens outside listbox
+ )
+ )
+ {
+ msgbox->MsgboxSel = MSGBOX_CANCEL;
+ _MsgBoxCallCallback(msgbox,msgbox->MsgboxSel);
+ gAction.ClearAction( Data );
+ return EFI_SUCCESS;
+ }
+
+
+ if( (Action == ControlActionChoose ) || (Action == ControlActionSelect) )
+ {
+ if(Data->Input.Data.MouseInfo.Top == (UINT32)(msgbox->Top + msgbox->Height -2))
+ {
+ switch(msgbox->MsgBoxType & MSGBOX_TYPE_MASK)
+ {
+ case MSGBOX_TYPE_CUSTOM:
+
+ if ( (msgbox->OptionCount != 0) && (msgbox->PtrTokens != NULL ))
+ {
+ W = ( msgbox->Width)/(msgbox->OptionCount) ;
+
+ for ( Index = 0; Index < msgbox->OptionCount ; Index++ )
+ {
+ txt = HiiGetString( msgbox->ControlData.ControlHandle, msgbox->PtrTokens[Index]);
+ pos = (UINTN) (msgbox->Left + (Index * W) ) ;
+
+ printLength = (TestPrintLength( txt ) / (NG_SIZE));
+
+ if( printLength > W)
+ {
+ txt[HiiFindStrPrintBoundary(txt, W)] = L'\0';
+ printLength = (TestPrintLength( txt ) / (NG_SIZE));
+ }
+
+ MemFreePointer( (VOID **)&txt);
+
+ if( (Data->Input.Data.MouseInfo.Left)>=(UINT32)(pos + (W-printLength)/2 -2) &&
+ (Data->Input.Data.MouseInfo.Left)<=(UINT32)((pos + (W-printLength)/2 -2)+printLength))
+ {
+ msgbox->MsgboxSel = (UINT8)Index;
+ ButtonClicked = TRUE;
+ break;
+ }
+ }
+ }
+
+ break;
+
+ case MSGBOX_TYPE_YESNO:
+ case MSGBOX_TYPE_OKCANCEL:
+
+ if( (Data->Input.Data.MouseInfo.Left)>=(UINT32)(msgbox->Left + msgbox->Width/3 -2) &&
+ (Data->Input.Data.MouseInfo.Left)<=(UINT32)((msgbox->Left + msgbox->Width/3 -2)+msgbox->Button1Len))
+ {
+ msgbox->MsgboxSel = 0;
+ ButtonClicked = TRUE;
+ }
+
+ if( (Data->Input.Data.MouseInfo.Left)>=(UINT32)( msgbox->Left + 2*(msgbox->Width/3) -2) &&
+ (Data->Input.Data.MouseInfo.Left)<=(UINT32)(( msgbox->Left + 2*(msgbox->Width/3) -2)+msgbox->Button2Len) )
+ {
+ msgbox->MsgboxSel = 1;
+ ButtonClicked = TRUE;
+ }
+ break;
+ case MSGBOX_TYPE_OK:
+ default:
+ // EIP 46143 - Updated the msg box position to slect with click properly
+ if( (Data->Input.Data.MouseInfo.Left)>=(UINT32)(msgbox->Left + msgbox->Width/2 -1) &&
+ (Data->Input.Data.MouseInfo.Left)<=(UINT32)((msgbox->Left + msgbox->Width/2 -1)+msgbox->Button1Len) )
+ {
+ msgbox->MsgboxSel = 0;
+ ButtonClicked = TRUE;
+ }
+ break;
+ }
+
+ if(ButtonClicked)
+ {
+ if(ControlActionChoose == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ *pRedraw = TRUE;
+ else
+ _MsgBoxCallCallback(msgbox,msgbox->MsgboxSel);
+ }
+ }
+ }
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MsgBoxGetControlHight
+//
+// Description: Function unsupported.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MsgBoxGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Suite 200, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+
diff --git a/EDK/MiniSetup/TseLite/MessageBox.h b/EDK/MiniSetup/TseLite/MessageBox.h
new file mode 100644
index 0000000..7e5781a
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/MessageBox.h
@@ -0,0 +1,207 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/MessageBox.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 10 $
+//
+// $Date: 8/28/14 6:05a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/MessageBox.h $
+//
+// 10 8/28/14 6:05a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 9 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 12/01/11 5:42a Rajashakerg
+// [TAG] EIP74963
+// [Category] Improvement
+// [Description] MAX_MSGBOX_WIDTH cannot be overridden
+// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
+// MessageBox.c, MessageBox.h, FormBrowser.c
+//
+// 7 4/21/10 12:01p Madhans
+// Tse 2.02
+//
+// 9 4/20/10 6:22p Blaines
+// Define MSGBOX_MAX_OPTIONS
+//
+// 8 3/26/10 6:53p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 7 3/23/10 5:20p Blaines
+// Extend Message Box support
+// Adds Custom Type
+// Adds Progress Bar Type
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 3 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#ifndef _MSGBOX_H_
+#define _MSGBOX_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "popup.h"
+#include "Memo.h"
+
+//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
+//#define MAX_MSGBOX_WIDTH 45
+// messagebox constants
+#define MSGBOX_TYPE_NULL 0
+#define MSGBOX_TYPE_OK 1
+#define MSGBOX_TYPE_OKCANCEL 2
+#define MSGBOX_TYPE_YESNO 3
+#define MSGBOX_TYPE_CUSTOM 4
+#define MSGBOX_TYPE_PROGRESS 5 // internal use only (NOT PUBLISHED)
+#define MSGBOX_TYPE_MASK 0x0F
+#define MSGBOX_TYPE_MAXTYPE MSGBOX_TYPE_MASK
+#define MSGBOX_STYLE_CENTER (UINT8)(JUSTIFY_CENTER << 4)
+#define MSGBOX_STYLE_RIGHT (UINT8)(JUSTIFY_RIGHT << 4)
+#define MSGBOX_STYLE_LEFT (UINT8)(JUSTIFY_LEFT << 4)
+#define MSGBOX_STYLE_MASK 0xF0
+#define MSGBOX_OK 0
+#define MSGBOX_CANCEL 1
+#define MSGBOX_YES 0
+#define MSGBOX_NO 1
+
+#define MSGBOX_MAX_OPTIONS 4
+typedef struct _IFR_MSGBOX
+{ // this structure is, in some way, following EFI_IFR structures
+ UINT8 Opcode, Length;
+ UINT16 Title;
+ /*EFI_HII_HANDLE*/VOID * TextHandle;
+ UINT16 Text;
+}AMI_IFR_MSGBOX;
+
+#define MSGBOX_MEMBER_VARIABLES \
+ VOID *ScreenBuf; \
+ MEMO_DATA *Memo; \
+ UINT8 MsgBoxType; \
+ UINT8 MsgboxSel; \
+ UINT8 Button1Len; \
+ UINT8 Button2Len; \
+ CHAR16 *Legend; \
+ MSGBOX_EX_CATAGORY MsgBoxCatagory; \
+ UINT16 *PtrTokens; \
+ UINT16 OptionCount; \
+ AMI_POST_MGR_KEY *HotKeyList; \
+ UINT16 HotKeyListCount; \
+ AMI_POST_MGR_KEY *OutKey; \
+ UINTN Percent; // 0 - 100
+
+
+typedef struct _MSGBOX_METHODS MSGBOX_METHODS;
+
+typedef struct _MSGBOX_DATA
+{
+ MSGBOX_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUP_MEMBER_VARIABLES
+ MSGBOX_MEMBER_VARIABLES
+}
+MSGBOX_DATA;
+
+typedef EFI_STATUS (*MSGBOX_METHOD_SET_TYPE) ( VOID *object, UINT8 Type );
+
+#define MSGBOX_METHOD_FUNCTIONS \
+ MSGBOX_METHOD_SET_TYPE SetType;
+
+struct _MSGBOX_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ MSGBOX_METHOD_FUNCTIONS
+};
+
+extern MSGBOX_METHODS gMsgBox;
+
+
+// Object Methods
+EFI_STATUS MsgBoxCreate( VOID **object );
+EFI_STATUS MsgBoxDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS MsgBoxInitialize( VOID *object, VOID *data );
+EFI_STATUS MsgBoxDraw( VOID *object );
+EFI_STATUS MsgBoxHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS MsgBoxSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+EFI_STATUS MsgBoxSetType(VOID *object, UINT8 Type );
+
+// Control Methods
+EFI_STATUS MsgBoxSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS MsgBoxSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS MsgBoxSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS MsgBoxSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS MsgBoxGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+
+#endif /* _MSGBOX_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupEdit.c b/EDK/MiniSetup/TseLite/PopupEdit.c
new file mode 100644
index 0000000..071cbb9
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupEdit.c
@@ -0,0 +1,890 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupEdit.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 28 $
+//
+// $Date: 5/03/14 4:02p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupEdit.c $
+//
+// 28 5/03/14 4:02p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 27 5/01/14 3:53p Premkumara
+// [TAG] EIP158293
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Closing Password popup window displaying invalid password
+// msg box, when SINGLE_CLICK_ACTIVATION token is enabled.
+// [RootCause] Once clicked outside password popup window,
+// ControlActionAbort action is not setting so it returning EFFI_SUCCESS
+// status. If status is not success invalid password will display.
+// [Solution] When mouse is clicked outside password/string popup
+// window, ControlActionAbort action will be set so finally it will return
+// EFI_SUCCESS and "invalid password" msg box will not display.
+// [Files] PopupEdit.c
+//
+// 26 2/11/14 8:40p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 25 12/03/13 8:57a Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 24 5/15/13 4:06a Premkumara
+// [TAG] EIP123311
+// [Issue Faced] Popup string control accepts ENTER character while
+// pressing CTRL+ENTER. So causing page corruption
+// [Root Cause] When CTRL+ENTER is pressed valid shift key is set and
+// unicode char set with carriage return. But action get as unknown so for
+// unknow case we are simply filling text with unicode char value. So this
+// cause issue.
+// [Solution] Accepting character other than carriage return in popup
+// edit for string controls
+// [Modified files] PopupEdit.c
+//
+// 23 1/22/13 12:23a Rajashakerg
+// [TAG] EIP103449
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In Setup click\Touch from navigation window, option are not
+// displayed properly
+// [RootCause] Latest mouse driver providing LEFT_DOWN when we hold the
+// mouse left down button.
+// [Solution] Provided fix resolves the issue.
+// [Files] ezport.c, PopupEdit.c, ListBox.c, MessageBox.c
+//
+// 22 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 18 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 21 4/27/12 2:02p Arunsb
+// Build error rectified
+//
+// 20 4/27/12 2:40a Rajashakerg
+// [TAG] EIP86346
+// [Category] Improvement
+// [Description] Cursor visibility is not proper in multiline string
+// controls
+// [Files] PopupEdit.c, PopupString.c
+//
+// 19 4/05/12 7:19a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 18 2/02/12 1:18p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 17 12/27/11 12:37p Arunsb
+// [TAG] EIP79486
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Cursor is not blinking when "Softkbd" support enabled
+// [RootCause] Unknown action also consumed
+// [Solution] Unknow action not consumed.
+// Mouse stopped instead of freezing when the mouse pointer is over the
+// cursor.
+// [Files] popupedit.c and popuppassword.c
+//
+// 16 12/01/11 1:38a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 15 11/30/11 12:38a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 14 11/28/11 1:42a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 13 11/20/11 8:08a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 12 11/10/11 12:49a Arunsb
+// [TAG] EIP67735
+// [Category] Improvement
+// [Description] Zeroing password buffers before freeing
+// [Files] mem.c, mem.h, popupedit.c, popuppassword.c and tseadvanced.c
+//
+// 11 10/19/11 3:52p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry. Add cursor
+// support.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c,
+// uefi20Wapper.c, PopupEdit.c
+//
+// 10 12/24/10 12:37p Mallikarjunanv
+// [TAG] EIP 46144
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] String exceeds the msg dialog boundry in "Path for boot
+// [RootCause] The width coordinate of the popup edit is not handled
+// propely.
+// [Solution] Updated the width to write the string with in the
+// boundary.
+// [Files] PopupEdit.c
+//
+// 9 10/20/10 1:44p Mallikarjunanv
+// reverting back to v25
+//
+// 7 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 6 5/07/10 6:40p Madhans
+// EIP: 38197 To make the Scan code support work correctly with 9 and =
+// Keys.
+//
+// 5 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 6 1/09/10 7:01a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 8/19/09 6:34p Madhans
+// InValidActionHook Added. for PopupEdit case
+//
+// 4 7/20/09 1:22p Mallikarjunanv
+// updated the code with token PASSWORD_WITH_SPECIAL_CHAR_SUPPORT
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupEdit.c
+//
+// Description: This file contains code to handle Popup Edit operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+extern UINTN gCursorLeft,gCursorTop ;
+
+POPUPEDIT_METHODS gPopupEdit =
+{
+ PopupEditCreate,
+ PopupEditDestroy,
+ PopupEditInitialize,
+ PopupEditDraw,
+ PopupEditHandleAction,
+ PopupEditSetCallback,
+ PopupEditSetFocus,
+ PopupEditSetPosition,
+ PopupEditSetDimensions,
+ PopupEditSetAttributes,
+ PopupEditGetControlHight,
+ PopupEditSetType,
+ PopupEditSetText
+};
+
+BOOLEAN CheckIsAllowedPasswordChar(CHAR16 Char);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditCreate
+//
+// Description: this function uses the create function of control
+// and creates the Popup Edit
+//
+// Input: POPUPEDIT_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditCreate( POPUPEDIT_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(POPUPEDIT_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gPopup.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gPopupEdit;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the Popup Edit
+//
+// Input: POPUPEDIT_DATA **object, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditDestroy( POPUPEDIT_DATA *PopupEdit, BOOLEAN freeMem )
+{
+ EFI_STATUS Status;
+
+ if(NULL == PopupEdit)
+ return EFI_SUCCESS;
+
+ Status = gPopup.Destroy( PopupEdit, FALSE );
+
+ if(PopupEdit->Title)
+ MemFreePointer( (VOID **)&PopupEdit->Title);
+
+ RestoreScreen( PopupEdit->ScreenBuf );
+ if (freeMem)
+ {
+ if (POPUPEDIT_TYPE_PASSWORD == PopupEdit->PopupEditType)
+ {
+ gBS->SetMem (PopupEdit->Text, EfiStrLen (PopupEdit->Text) * sizeof (CHAR16), 0); //EIP67735 zeroing the password prompt memories
+ }
+ MemFreePointer( (VOID **)&PopupEdit->Text );//EIP-73236 Memory leak
+ MemFreePointer( (VOID **)&PopupEdit->TempText );
+ MemFreePointer( (VOID **)&PopupEdit->EmptyString ); //Free the allocated memory for the EmptyString field
+ MemFreePointer( (VOID **)&PopupEdit );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditInitialize
+//
+// Description: this function uses the Initialize function of control
+// and initializes the Popup Edit
+//
+// Input: POPUPEDIT_DATA *PopupEdit, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditInitialize( POPUPEDIT_DATA *PopupEdit, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Length =0/*,height=0*/, Size =0;
+ CHAR16 *TempText;
+
+ // initializes the heigth and width
+ Status = gPopup.Initialize( PopupEdit, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ SetControlColorsHook( NULL, NULL , NULL, NULL , NULL, NULL ,
+ NULL , NULL, NULL,NULL ,
+ NULL,NULL ,NULL,&(PopupEdit->FGColor),&(PopupEdit->BGColor) );
+
+
+ PopupEdit->Container = NULL;
+
+ PopupEdit->Border =TRUE;
+ PopupEdit->Shadow = TRUE;
+ PopupEdit->Title = HiiGetString(PopupEdit->ControlData.ControlHandle, UefiGetPromptField(PopupEdit->ControlData.ControlPtr));
+
+ if ( Length < (TestPrintLength( PopupEdit->Title ) / (NG_SIZE)))
+ Length = (UINT16)TestPrintLength( PopupEdit->Title ) / (NG_SIZE);
+
+ if ( Length < (UINT16)UefiGetMaxValue(PopupEdit->ControlData.ControlPtr) )
+ Length = (UINT16)UefiGetMaxValue(PopupEdit->ControlData.ControlPtr);
+
+ PopupEdit->Width = (UINT16)(Length + 4);
+ if ( PopupEdit->Width > MAX_POPUPEDIT_WIDTH )
+ {
+ //EIP-135665 If multiline is supported
+ if ( IsTSEMultilineControlSupported() )
+ PopupEdit->Height += (UINT16)(PopupEdit->Width / MAX_POPUPEDIT_WIDTH )+(((PopupEdit->Width % MAX_POPUPEDIT_WIDTH) > 0)?1:0)-1;
+ PopupEdit->Width = (UINT16)MAX_POPUPEDIT_WIDTH;
+ }
+ PopupEdit->TextWidth = (UINT16)UefiGetMaxValue(((CONTROL_INFO *)data)->ControlPtr);
+
+
+ // create text memory area with max available size
+ TempText = EfiLibAllocateZeroPool(PopupEdit->TextWidth*2+2);
+ EfiStrCpy(TempText,PopupEdit->Text);
+ MemFreePointer((CHAR16**)&PopupEdit->Text);
+ PopupEdit->Text =TempText;
+
+ PopupEdit->ScreenBuf = SaveScreen();
+
+ PopupEdit->TempText = EfiLibAllocateZeroPool( PopupEdit->TextWidth*2 +2 );
+
+ PopupEdit->Height += 2+ (PopupEdit->TextWidth/PopupEdit->Width +1)/*height*/;
+ gPopupEdit.SetDimensions( PopupEdit, PopupEdit->Width , PopupEdit->Height );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditDraw
+//
+// Description: function to draw the popup to edit with attributes
+//
+// Input: POPUPEDIT_DATA *PopupEdit
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditDraw( POPUPEDIT_DATA *PopupEdit )
+{
+ EFI_STATUS Status;
+ CHAR16 *text = NULL, *newText = NULL;
+ CHAR16 *line;
+ UINT16 pos, height=1,i;
+ UINTN Wrappedtextlen= 0;
+
+ text = StrDup(PopupEdit->Text);
+
+ Status = gPopup.Draw( PopupEdit );
+ if(EFI_ERROR(Status))
+ {
+ //EIP-75384 Static code
+ MemFreePointer( (VOID **)&text );
+ return Status;
+ }
+
+ // clear out old wrapped string
+ for ( pos = PopupEdit->Height- (2+ (PopupEdit->TextWidth/PopupEdit->Width +1))+1; pos < PopupEdit->Height-2; pos++ )
+ DrawStringWithAttribute( PopupEdit->Left+1, PopupEdit->Top + pos, PopupEdit->EmptyString, PopupEdit->FGColor | PopupEdit->BGColor );
+
+ if(PopupEdit->PopupEditType != POPUPEDIT_TYPE_PASSWORD ) {
+ //EIP_46144 - Updated the width to write the string with in the boundary.
+ newText = StringWrapText( text, PopupEdit->Width-2, &height );
+ }
+ else {
+ newText = text;
+ }
+
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (newText == NULL)
+ {
+ MemFreePointer( (VOID **)&text );
+ return EFI_NOT_FOUND;
+ }
+
+ if ( newText != text )
+ MemFreePointer( (VOID **)&text );
+
+ line = newText;
+
+ for ( pos = PopupEdit->Height- (2+ (PopupEdit->TextWidth/PopupEdit->Width +1))+1; pos < PopupEdit->Height; pos++ )
+ {
+ CHAR16 save;
+
+ text = line;
+ if ( *line == L'\0' )
+ break;
+
+ if(PopupEdit->PopupEditType != POPUPEDIT_TYPE_PASSWORD )
+ {
+ while ( ( *line != L'\n' ) &&( *line != L'\r' ) && ( *line != L'\0' ) )
+ line++;
+ }
+ else
+ {
+ while ( *line != L'\0' )
+ line++;
+ }
+
+ save = *line;
+ *line = L'\0';
+ i=0;
+ while( (text[i] != L'\0') && (PopupEdit->Chr !=0x0 ) )
+ {
+// if(text[i] != L' ') //all chars should be treated the same
+ text[i] = PopupEdit->Chr;
+ i++;
+ }
+
+ DrawStringWithAttribute( PopupEdit->Left+1, PopupEdit->Top + pos, text, PopupEdit->FGColor | PopupEdit->BGColor );
+
+ if ( ( *line = save ) != L'\0' )
+ {
+ line++;
+ if ( ( *line == L'\r' ) || ( *line == L'\n' ) )
+ line++;
+ }
+
+ if(L'\0' == *line)
+ Wrappedtextlen = EfiStrLen(text);//EIP 86346 : Getting the wrapped text length
+
+ }
+ MemFreePointer( (VOID **)&newText );
+
+ if ( pos < height )
+ height = pos;
+
+ gCursorLeft = PopupEdit->Left + Wrappedtextlen;
+ gCursorTop = PopupEdit->Top + (pos-1);//EIP 86346 : Providing the Cursor Postion depending on the lenght of string
+ if((Wrappedtextlen == 0)||(((UINT16)Wrappedtextlen) > (PopupEdit->Width-2)))
+ {
+ gCursorLeft = PopupEdit->Left+1;
+ gCursorTop++;
+ }
+ PopupEdit->DisplayLines = height;
+ FlushLines( PopupEdit->Top, PopupEdit->Top + PopupEdit->Height );
+ return EFI_SUCCESS;
+
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditHandleAction
+//
+// Description: function to handle the Popup Edit actions
+//
+// Input: POPUPEDIT_DATA *PopupEdit, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditHandleAction( POPUPEDIT_DATA *PopupEdit, ACTION_DATA *Data)
+{
+ UINT8 Redraw =0;
+ //Always return success to consume the message, the popupedit is always modal.
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_ACTION Action=ControlActionUnknown;
+
+ if ( (Data->Input.Type == ACTION_TYPE_TIMER) || (Data->Input.Type == ACTION_TYPE_NULL) ) //EIP79486 cursor not blinking when mouse driver presents
+ return Status;
+
+ if ( Data->Input.Type == ACTION_TYPE_MOUSE )
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+
+ //EIP 103449 : In Setup click\Touch from navigation window, option are not displayed properly
+ if( (
+ (Data->Input.Data.MouseInfo.Top < PopupEdit->Top) ||
+ (Data->Input.Data.MouseInfo.Top > (UINT32)(PopupEdit->Top + PopupEdit->Height)) ||
+ (Data->Input.Data.MouseInfo.Left < PopupEdit->Left) ||
+ (Data->Input.Data.MouseInfo.Left > (UINT32)(PopupEdit->Left + PopupEdit->Width)) )
+ && ( (ControlActionChoose == Action) || (ControlActionSelect == Action) )
+ )
+ { // Any action outside the popupedit about
+ Action = ControlActionAbort;
+ }
+
+ }
+
+ if (Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+ }
+
+ switch(Action)
+ {
+ case ControlActionNextUp:
+ case ControlActionNextDown:
+ case ControlActionNextLeft:
+ case ControlActionNextRight:
+ case ControlActionNextSelection:
+ Redraw = TRUE;
+ break;
+
+ case ControlActionAbort:
+ if(PopupEdit->ControlActive == TRUE)
+ {
+ MemCopy(PopupEdit->Text,PopupEdit->TempText,PopupEdit->TextWidth*sizeof(UINT16)); //UNICODE CHARS
+ }
+ if(PopupEdit->Callback != NULL)
+ {
+ if ( PopupEdit->Cookie != NULL )
+ {
+ VOID *ifrData = (VOID *)PopupEdit->ControlData.ControlPtr;
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)PopupEdit->Cookie;
+
+ callbackData->Variable = PopupEdit->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetWidth(ifrData);
+ callbackData->Data = (VOID *)PopupEdit->Text;
+
+ PopupEdit->Callback( PopupEdit->Container,PopupEdit, NULL );
+ }
+ }
+
+ PopupEdit->ControlActive = FALSE;
+ Redraw = 1;
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionSelect:
+ if(PopupEdit->Callback != NULL)
+ {
+ if ( PopupEdit->Cookie != NULL )
+ {
+ VOID *ifrData = PopupEdit->ControlData.ControlPtr;
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)PopupEdit->Cookie;
+
+ callbackData->Variable = PopupEdit->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetWidth(ifrData);
+ callbackData->Data = (VOID *)PopupEdit->Text;
+
+ PopupEdit->Callback( PopupEdit->Container,PopupEdit, PopupEdit->Cookie );
+ }
+
+ }
+
+ Redraw =1;
+ PopupEdit->ControlActive =FALSE;
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionBackSpace:
+ if(EfiStrLen(PopupEdit->Text)>0)
+ {
+ if(PopupEdit->ControlActive ==FALSE)
+ {
+ MemCopy(PopupEdit->TempText,PopupEdit->Text,PopupEdit->TextWidth * sizeof(UINT16)); //UNICODE CHARS
+ PopupEdit->ControlActive = TRUE;
+ }
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)-1] = 0x0;
+ Redraw =1;
+ }
+ break;
+
+ default:
+ if ( Data->Input.Type == ACTION_TYPE_MOUSE )
+ break;
+
+ if(PopupEditHandlePassword( PopupEdit, Data) == EFI_SUCCESS)
+ Redraw =1;
+ else
+ {
+ if ((Data->Input.Data.AmiKey.Key.UnicodeChar) && (CHAR_CARRIAGE_RETURN != Data->Input.Data.AmiKey.Key.UnicodeChar)) //EIP-123306 Avoid carriage return when press CTRL+ENTER in popupedit controls.
+ {
+ if ( ( CheckIsAllowedPasswordChar(Data->Input.Data.AmiKey.Key.UnicodeChar) || ( PopupEdit->PopupEditType != POPUPEDIT_TYPE_PASSWORD ) ) &&
+ ( EfiStrLen(PopupEdit->Text) < PopupEdit->TextWidth ) )
+ {
+ if(PopupEdit->ControlActive ==FALSE)
+ {
+ MemCopy(PopupEdit->TempText,PopupEdit->Text,PopupEdit->TextWidth* sizeof(UINT16));
+ PopupEdit->ControlActive = TRUE;
+ }
+
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)] = Data->Input.Data.AmiKey.Key.UnicodeChar ;
+ PopupEdit->Text[EfiStrLen(PopupEdit->Text)] = 0x0 ;
+ Redraw =1;
+ }
+ else {
+ InvalidActionHookHook(); ///
+ }
+ }
+ else if(!IsToggleStateKey(Data))
+ {
+ InvalidActionHookHook();
+ }
+
+ }
+ break;
+ }
+
+ if ( Redraw == TRUE )
+ {
+ MouseFreeze();
+
+ gPopupEdit.Draw( PopupEdit );
+
+ MouseRefresh();
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetCallback
+//
+// Description: Function to set the PopupSel callback
+//
+// Input: POPUPEDIT_DATA *PopupEdit, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetCallback( POPUPEDIT_DATA *PopupEdit, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( PopupEdit, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetType
+//
+// Description: Function to set the PopupEdit type
+//
+// Input: POPUPEDIT_DATA *PopupEdit, UINT8 Type
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetType( POPUPEDIT_DATA *PopupEdit, UINT8 Type )
+{
+ PopupEdit->PopupEditType = Type;
+ if ( Type == POPUPEDIT_TYPE_PASSWORD )
+ PopupEdit->Chr = PASSWORD_CHAR;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetText
+//
+// Description: Function to set the PopupEdit text
+//
+// Input: POPUPEDIT_DATA *PopupEdit, CHAR16 *String
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetText(POPUPEDIT_DATA *PopupEdit, CHAR16 *String )
+{
+ if(PopupEdit->Text==NULL)
+ {
+ if(String != NULL)
+ {
+ PopupEdit->Text = EfiLibAllocateZeroPool( (EfiStrLen(String )+1) * sizeof(CHAR16) );
+ EfiStrCpy(PopupEdit->Text, String);
+ }
+ else
+ {
+ PopupEdit->Text = EfiLibAllocateZeroPool( (2) * sizeof(CHAR16) );
+ EfiStrCpy(PopupEdit->Text, L"");
+ }
+ }
+ else
+ {
+ if(String != NULL)
+ EfiStrCpy(PopupEdit->Text,String);
+ else
+ EfiStrCpy(PopupEdit->Text, L"");
+
+ }
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetFocus
+//
+// Description: Function to set focus
+//
+// Input: POPUPEDIT_DATA *PopupEdit, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetFocus(POPUPEDIT_DATA *PopupEdit, BOOLEAN focus)
+{
+ PopupEdit->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetPosition
+//
+// Description: Function to set focus
+//
+// Input: POPUPEDIT_DATA *PopupEdit, UINT16 Left, UINT16 Top
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetPosition(POPUPEDIT_DATA *PopupEdit, UINT16 Left, UINT16 Top )
+{
+ return gPopup.SetPosition( PopupEdit, Left, Top );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetDimensions
+//
+// Description: function to set the dimentions of the editable popup menu
+//
+// Input: POPUPEDIT_DATA *PopupEdit, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetDimensions(POPUPEDIT_DATA *PopupEdit, UINT16 Width, UINT16 Height )
+{
+ EFI_STATUS Status= EFI_SUCCESS;
+
+ // dimensions include top, bottom, left and right lines for popup
+ Status = gPopup.SetDimensions( PopupEdit, Width, Height );
+
+ MemFreePointer( (VOID **)&PopupEdit->EmptyString );
+ PopupEdit->EmptyString = EfiLibAllocateZeroPool( (Width-1 ) * sizeof(CHAR16) );
+ if ( PopupEdit->EmptyString == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ MemFillUINT16Buffer( PopupEdit->EmptyString, Width-2, L' ' );
+
+ return(Status);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditSetAttributes
+//
+// Description: Function to set the dimentions of the editable popup menu
+//
+// Input: POPUPEDIT_DATA *PopupEdit, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditSetAttributes(POPUPEDIT_DATA *PopupEdit, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( PopupEdit, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditGetControlHight
+//
+// Description: Function unsuppored.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Suite 200, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+
diff --git a/EDK/MiniSetup/TseLite/PopupEdit.h b/EDK/MiniSetup/TseLite/PopupEdit.h
new file mode 100644
index 0000000..93221df
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupEdit.h
@@ -0,0 +1,192 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupEdit.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupEdit.h $
+//
+// 9 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 4/05/12 7:25a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 7 11/20/11 8:10a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 5 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupEdit.h
+//
+// Description: This file contains definitions to handle Popup Edit operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _POPUPEDIT_H_
+#define _POPUPEDIT_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "popup.h"
+//#include "memo.h"
+
+#define PASSWORD_CHAR L'*'
+// popupedit constants
+#define MAX_POPUPEDIT_WIDTH (gMaxCols - 10)
+#define POPUPEDIT_TYPE_STRING 0
+#define POPUPEDIT_TYPE_PASSWORD 1
+#define POPUPEDIT_CANCEL 1
+
+#define POPUPEDIT_MEMBER_VARIABLES \
+ VOID *ScreenBuf; \
+ UINT8 PopupEditType; \
+ UINT8 Justify; \
+ UINT16 DisplayLines; \
+ CHAR16 *EmptyString; \
+ UINT16 MinSize; \
+ UINT16 MaxSize; \
+ UINT16 TextWidth; \
+ CHAR16 *Text; \
+ CHAR16 *TempText; \
+ CHAR16 Chr; /* character used to display instead of real chars */
+ /* mainly used for password entry.*/
+
+typedef struct _POPUPEDIT_METHODS POPUPEDIT_METHODS;
+
+typedef struct _POPUPEDIT_DATA
+{
+ POPUPEDIT_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUP_MEMBER_VARIABLES
+ POPUPEDIT_MEMBER_VARIABLES
+}
+POPUPEDIT_DATA;
+
+typedef EFI_STATUS (*POPUPEDIT_METHOD_SET_TEXT) ( VOID *object, CHAR16 *String);
+typedef EFI_STATUS (*POPUPEDIT_METHOD_SET_TYPE) ( VOID *object, UINT8 Type);
+
+#define POPUPEDIT_METHOD_FUNCTIONS \
+ POPUPEDIT_METHOD_SET_TYPE SetType; \
+ POPUPEDIT_METHOD_SET_TEXT SetText;
+
+struct _POPUPEDIT_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ POPUPEDIT_METHOD_FUNCTIONS
+};
+
+extern POPUPEDIT_METHODS gPopupEdit;
+
+
+// Object Methods
+EFI_STATUS PopupEditCreate( VOID **object );
+EFI_STATUS PopupEditDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PopupEditInitialize( VOID *object, VOID *data );
+EFI_STATUS PopupEditDraw( VOID *object );
+EFI_STATUS PopupEditHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS PopupEditSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+EFI_STATUS PopupEditSetType(VOID *object, UINT8 Type );
+//EFI_STATUS PopupEditSetTitle(VOID *object, CHAR16 *String );
+EFI_STATUS PopupEditSetText(VOID *object, CHAR16 *String );
+
+// Control Methods
+EFI_STATUS PopupEditSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS PopupEditSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS PopupEditSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS PopupEditSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS PopupEditGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+
+#endif /* _POPUPEDIT_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupPassword.c b/EDK/MiniSetup/TseLite/PopupPassword.c
new file mode 100644
index 0000000..8914766
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupPassword.c
@@ -0,0 +1,1377 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupPassword.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 43 $
+//
+// $Date: 8/28/14 3:08p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupPassword.c $
+//
+// 43 8/28/14 3:08p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 42 5/03/14 4:03p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 41 5/02/14 9:35p Arunsb
+// EIP141986 changes reverted.
+//
+// 40 5/02/14 10:56a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 39 5/02/14 6:49a Premkumara
+// [TAG] EIP164232
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] When password keyboard is launched and mouse pointer is
+// placed on softkbd mouse will flickers continously.
+// [RootCause] MouseRefresh and MouseStop is calling contiously in loop
+// so mouse pointer get flickers
+// [Solution] When mouse pointer is on softkbd and is static then stop
+// calling MouseRefresh and MouseFreeze
+// [Files] PopupPassword.c, CommonHelper.c, Mouse.c
+//
+// 38 5/01/14 3:44p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 37 2/11/14 8:37p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 32 7/01/13 6:15a Premkumara
+// [TAG] EIP127023
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Empty password causes setup crashing
+// [RootCause] After entering empty password in first attempt and no
+// confirm password is given so the variable ConfirmNewPswd is NULL. Since
+// ConfirmNewPswd is NULL TSE is trying to compare and find length for
+// this NULL string and so it caused this issue.
+// [Solution] Handled NULL check for ConfirmNewPswd variable before and
+// after getting password
+// [Files] PopupPassword.c
+//
+// 31 3/25/13 8:38a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\UefiWapper20.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 30 3/08/13 1:34a Rajashakerg
+// [TAG] EIP113085
+// [Category] Improvement
+// [Description] Modify callback function behavior to match UEFI SPEC.
+// [Files] HiiCallback.c, PopupPassword.c, SubMenu.c
+//
+// 29 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 17 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 27 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 25 8/29/12 8:31a Premkumara
+// [TAG] EIP 91364
+// [Category] Improvement
+// [Description] Token to disable the Cursor of TSE Password Dialog
+// [Files] AMITSE.sdl, CommonHelper.c, Postmgmtext.c, PopupPassword.c,
+// PopupString.c
+//
+// 24 5/28/12 11:35a Premkumara
+// [TAG] EIP88912
+// [Category] Improvement
+// [Description] On password window display the softkbd with only with
+// valid key's
+// [Files] CommonHelper.c, Postmgmtext.c, Mouse.c, PopupPassword.c
+//
+// 23 1/02/12 11:49a Arunsb
+// EIP79486
+// Build error resolved for 32 bit.
+//
+// 22 12/27/11 12:41p Arunsb
+// [TAG] EIP79486
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Cursor is not blinking when "Softkbd" support enabled
+// [RootCause] Unknown action also consumed
+// [Solution] Unknow action not consumed.
+// Mouse stopped instead of freezing when the mouse pointer is over the
+// cursor.
+// [Files] popupedit.c and popuppassword.c
+//
+// 21 12/14/11 12:43p Arunsb
+// EIP63190 => Moving password support from TSELite to BootOnly
+//
+// 20 12/01/11 5:13a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+// ,PopupPassword.c
+//
+// 19 11/30/11 12:20p Premkumara
+// Updated with review comments.
+//
+// 18 11/30/11 11:57a Premkumara
+// [TAG] EIP75521
+// [Category] Improvement
+// [Description] Need to support interactive password controls
+// [Files] PopupPassword.c, PopupPassword.h, TsetAdvanced.c
+//
+// 17 11/30/11 11:32a Premkumara
+// [TAG] EIP67695
+// [Category] Improvement
+// [Description] No cursor visible in setup, while editing text input
+// box
+// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c
+//
+// 16 11/21/11 11:15a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 15 11/20/11 8:12a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 14 11/20/11 7:40a Premkumara
+// [TAG] EIP73226
+// [Category] New Feature
+// [Description] Extended support for password prompt
+// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c,
+//
+// 13 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 12 11/10/11 12:48a Arunsb
+// [TAG] EIP67735
+// [Category] Improvement
+// [Description] Zeroing password buffers before freeing
+// [Files] mem.c, mem.h, popupedit.c, popuppassword.c and tseadvanced.c
+//
+// 11 3/28/11 9:25p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 10 12/02/10 2:34p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 9 10/04/10 4:26p Blaines
+// In the function _DoPopupEdit, call gPopupEdit.SetType before calling
+// gPopupEdit.Initialize. This is useful in case the function
+// gPopupEdit.Initialize is overriden.
+//
+// 8 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 13 8/27/10 4:43a Mallikarjunanv
+// EIP-39764: Setup password non-case sensitive support and password
+// encode support updated
+//
+// 12 4/09/10 12:26p Madhans
+//
+// 11 3/26/10 6:53p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 10 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/05/10 6:05p Madhans
+// To fix the Screen corruption if mouse pointer is on the popup.
+//
+// 8 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 7 1/09/10 6:54a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 6 8/13/09 1:20p Blaines
+// Fix color initialization
+//
+// 5 7/09/09 12:29p Mallikarjunanv
+// updated the password encoding fix
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupPassword.c
+//
+// Description: This file contains code to handle Popup Passwords
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+////////////////////////////////////////////////////////////////
+//// Extern Variables
+////////////////////////////////////////////////////////////////
+extern UINTN gInvalidPasswordFailMsgBox;
+//EIP-73226 Extended Password support
+extern UINTN gClearPasswordMsgBox;
+extern UINTN gInvalidRangeFailMsgBox;
+extern UINTN gClearLabelPasswordMsgBox;
+
+CALLBACK_VARIABLE gPopupEditCb = { { CALLBACK_TYPE_VARIABLE, sizeof(CALLBACK_VARIABLE) }, 0,0,0,NULL };
+UINT8 res = (UINT8)-1;
+
+POPUP_PASSWORD_METHODS gPopupPassword =
+{
+ PopupPasswordCreate,
+ PopupPasswordDestroy,
+ PopupPasswordInitialize,
+ PopupPasswordDraw,
+ PopupPasswordHandleAction,
+ PopupPasswordSetCallback,
+ PopupPasswordSetFocus,
+ PopupPasswordSetPosition,
+ PopupPasswordSetDimensions,
+ PopupPasswordSetAttributes,
+ PopupPasswordGetControlHeight
+
+};
+VOID GetCoordinates(INT32 *x, INT32 *y, INT32 *z);
+VOID SetPwdKeyboardLayout(VOID);//EIP-88912
+VOID ResetPwdKeyboardLayout(VOID);//EIP-88912
+BOOLEAN IsTSECursorSupport(); //EIP-91364
+VOID SavePswdString (CONTROL_INFO *ControlData, CHAR16 *String);
+BOOLEAN IsPasswordSupportNonCaseSensitive();
+BOOLEAN IsShowPromptStringAsTitle(VOID);//EIP-116315 password string
+BOOLEAN IsMouseOnSoftkbd(VOID); //EIP-164232
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordCreate
+//
+// Description: this function uses the create function of control
+// and creates the popup password
+//
+// Input: POPUP_PASSWORD_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordCreate( POPUP_PASSWORD_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(POPUP_PASSWORD_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gPopupPassword;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the popup password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordDestroy( POPUP_PASSWORD_DATA *popuppassword, BOOLEAN freeMem )
+{
+ if(NULL == popuppassword)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( popuppassword, FALSE );
+
+ MemFreePointer( (VOID **)&popuppassword->Text );
+
+ if( freeMem )
+ MemFreePointer( (VOID **)&popuppassword );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordInitialize
+//
+// Description: this function uses the initialize function of control
+// and initializes the popup password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordInitialize( POPUP_PASSWORD_DATA *popuppassword, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( popuppassword, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ SetControlColorsHook(NULL, NULL,
+ NULL, NULL,
+ &(popuppassword->SelBGColor), &(popuppassword->SelFGColor),
+ &(popuppassword->BGColor), &(popuppassword->FGColor),
+ NULL, NULL,
+ NULL,
+ NULL ,NULL,
+ NULL,NULL );
+
+ popuppassword->ControlData.ControlHelp = UefiGetHelpField(popuppassword->ControlData.ControlPtr);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordDraw
+//
+// Description: function to draw the popup password with attributes
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordDraw(POPUP_PASSWORD_DATA *popuppassword )
+{
+ CHAR16 *text;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ UINT8 ColorLabel = popuppassword->FGColor;
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( popuppassword->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &popuppassword->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text = HiiGetString( popuppassword->ControlData.ControlHandle, UefiGetPromptField(popuppassword->ControlData.ControlPtr));
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(popuppassword->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( popuppassword->Left , popuppassword->Top,
+ (UINTN)(popuppassword->Width),(UINTN) popuppassword->Height,
+ text,(UINT8)( (popuppassword->ControlFocus) ?
+ popuppassword->SelBGColor | popuppassword->SelFGColor :
+ popuppassword->BGColor | ColorLabel));
+ }
+ else
+ {
+ // use frame width minus margins as available space
+ // boundary overflow check
+ if ( (TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(popuppassword->Width ))
+ text[HiiFindStrPrintBoundary(text,(UINTN)(popuppassword->Width ))] = L'\0';
+
+ DrawStringWithAttribute( popuppassword->Left , popuppassword->Top, text,
+ (UINT8)( (popuppassword->ControlFocus) ?
+ popuppassword->SelBGColor | popuppassword->SelFGColor :
+ popuppassword->BGColor | ColorLabel ));
+ }
+
+ MemFreePointer( (VOID **)&text );
+ FlushLines( popuppassword->Top , popuppassword->Top );
+
+ return Status;
+}
+
+EFI_STATUS PopupPasswordSetCallback( POPUP_PASSWORD_DATA *popuppassword, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( popuppassword, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordCheckInstalledLocal
+//
+// Description: function to check the local installation of popup password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword
+//
+// Output: True/False
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 PopupPasswordCheckInstalledLocal(POPUP_PASSWORD_DATA *popuppassword)
+{
+ VOID *data = popuppassword->ControlData.ControlPtr;
+ CHAR16 *RealPassword=NULL;
+ UINT32 Installed=0;
+ // read real password from nvram
+ RealPassword = EfiLibAllocateZeroPool( ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16) );
+ if ( RealPassword == NULL )
+ return Installed;
+ MemSet( RealPassword, ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16), 0 );
+
+ VarGetValue( popuppassword->ControlData.ControlVariable,
+ UefiGetQuestionOffset(data),
+ (UINT8)UefiGetMaxValue(data)*2, RealPassword );
+
+ if ( RealPassword[0] != L'\0' )
+ Installed = 1;
+ MemFreePointer( (VOID **)&RealPassword );
+
+ return Installed;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordAuthenticateLocal
+//
+// Description: function to check authentication of the password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, CHAR16 *Password
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN PopupPasswordAuthenticateLocal( POPUP_PASSWORD_DATA *popuppassword, CHAR16 *Password )
+{
+ VOID *data = popuppassword->ControlData.ControlPtr;
+ CHAR16 *RealPassword=NULL,*TempEncoded=NULL;
+ BOOLEAN AuthenticateStatus=FALSE;
+ UINTN ii;
+
+ // read real password from nvram
+ RealPassword = EfiLibAllocateZeroPool( ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16) );
+ if ( RealPassword == NULL )
+ return AuthenticateStatus;
+ MemSet( RealPassword, ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16), 0 );
+
+ VarGetValue( popuppassword->ControlData.ControlVariable,
+ UefiGetQuestionOffset(data),
+ (UINT8)UefiGetMaxValue(data)*2, RealPassword );
+
+ TempEncoded = EfiLibAllocateZeroPool( ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16) );
+ if ( TempEncoded == NULL )
+ return AuthenticateStatus;
+
+ MemSet( TempEncoded, ((UINT8)UefiGetMaxValue(data)+1) * sizeof(CHAR16), 0 );
+ EfiStrCpy(TempEncoded,Password);
+
+//EIP106950
+ if (
+ (IsPasswordSupportNonCaseSensitive ()) &&
+ ( (VARIABLE_ID_AMITSESETUP == popuppassword->ControlData.ControlVariable) || (VARIABLE_ID_IDE_SECURITY == popuppassword->ControlData.ControlVariable) )
+ )
+ {
+ for (ii = 0; ii < (UefiGetMaxValue(data)); ii++)
+ TempEncoded [ii] = ((TempEncoded [ii]>=L'a')&&(TempEncoded [ii]<=L'z'))?(TempEncoded [ii]+L'A'-L'a'):TempEncoded [ii];
+ }
+//EIP106950
+//EIP 23354 : Start
+ //PasswordEncodeHook( TempEncoded, (UINT8)UefiGetMaxValue(data) * sizeof(CHAR16));
+ if( IsPasswordEncodeEnabled( &popuppassword->ControlData )){
+ PasswordEncodeHook( TempEncoded, (UINT8)UefiGetMaxValue(data) * sizeof(CHAR16));
+ }
+//EIP 23354 : END
+ if( EfiCompareMem(TempEncoded,RealPassword,(UINT8)UefiGetMaxValue(data) * sizeof(CHAR16)))
+ AuthenticateStatus = FALSE;
+ else
+ AuthenticateStatus = TRUE;
+
+ MemFreePointer( (VOID **)&RealPassword );
+ MemFreePointer( (VOID **)&TempEncoded );
+
+ return AuthenticateStatus;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdatePasswordToNonCaseSensitive
+//
+// Description: function to update the given password to non case sensitive
+//
+// Input: CHAR16 *Password, UINTN PwdLength
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdatePasswordToNonCaseSensitive(CHAR16 *Password, UINTN PwdLength)
+{
+ UINTN Idx;
+ for ( Idx = 0; Idx < PwdLength; Idx++ )
+ Password[Idx] = ((Password[Idx]>=L'a')&&(Password[Idx]<=L'z'))?(Password[Idx]+L'A'-L'a'):Password[Idx];
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupPasswordActivate
+//
+// Description: function to set and activate a password
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PopupPasswordActivate(POPUP_PASSWORD_DATA *popuppassword)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ BOOLEAN AbortUpdate = FALSE;
+ CHAR16 *Text=NULL,*NewPswd=NULL,*ConfirmNewPswd=NULL;
+ VOID *data = popuppassword->ControlData.ControlPtr;
+ UINTN NewPwLen = 0;
+ UINT16 orgtext = 0;
+ UINT16 newtoken = 0;
+
+ if( PopupPwdAuthenticateIDEPwd(popuppassword,&AbortUpdate,data) != EFI_SUCCESS)
+ {
+ AbortUpdate = FALSE;
+
+ if(PopupPasswordCheckInstalled(popuppassword))
+ {
+ // ask for old password (popupedit)
+ Status = _DoPopupEdit( popuppassword, (IsShowPromptStringAsTitle() ? STRING_TOKEN(STR_OLD_PSWD_LABEL): STRING_TOKEN(STR_OLD_PSWD)), &Text);
+ if( Status )
+ AbortUpdate = TRUE;
+ else
+ {
+ if(!PopupPasswordAuthenticate( popuppassword, Text ))
+ {
+ // optional message to user: "wrong password" and exit
+ CallbackShowMessageBox( (UINTN)gInvalidPasswordFailMsgBox, MSGBOX_TYPE_OK );
+ AbortUpdate = TRUE;
+ }
+ }
+ }
+ }
+ if(AbortUpdate == FALSE)
+ {
+Password:
+ //ask for new password(1)
+ Status = _DoPopupEdit( popuppassword, (IsShowPromptStringAsTitle() ? STRING_TOKEN(STR_NEW_PSWD_LABEL): STRING_TOKEN(STR_NEW_PSWD)), &NewPswd);
+
+ if(!Status)
+ {
+ NewPwLen = EfiStrLen(NewPswd);
+ //EIP-39764 : non case sensitive support during setting password
+ //EIP106950
+ if (
+ (IsPasswordSupportNonCaseSensitive ()) &&
+ (NewPwLen != 0) &&
+ ( (VARIABLE_ID_AMITSESETUP == popuppassword->ControlData.ControlVariable) || (VARIABLE_ID_IDE_SECURITY == popuppassword->ControlData.ControlVariable) )
+ )
+ {
+ UpdatePasswordToNonCaseSensitive (NewPswd, NewPwLen);
+ }
+ if (VARIABLE_ID_IDE_SECURITY != popuppassword->ControlData.ControlVariable)
+ {
+ if (PopupPasswordCheckInstalled (popuppassword))
+ {
+ // Override the minmax validation for password clearing
+ if(NewPwLen == 0)
+ {
+ //EIP-116315 password string Starts
+ if ( IsShowPromptStringAsTitle() )
+ {
+ CHAR16 *temptext = NULL, *tText = NULL;
+ CHAR16 *tempTitle = NULL;
+ UINTN strlen = 0;
+
+ //Taking backup of original StringID
+ orgtext = ((AMI_IFR_MSGBOX*)(gClearLabelPasswordMsgBox))->Text;
+
+ //Get TSE string
+ temptext = HiiGetString( (VOID*)(UINTN)INVALID_HANDLE, orgtext);
+ strlen = EfiStrLen(temptext);
+
+ tempTitle = EfiLibAllocateZeroPool((strlen+2)*sizeof(CHAR16));
+
+ if (NULL == tempTitle)
+ return EFI_OUT_OF_RESOURCES;
+
+ EfiStrCpy (tempTitle,temptext);
+ strlen = EfiStrLen(tempTitle);
+
+ MemFreePointer( (VOID **)&temptext );
+
+ //Get prompt string from controlptr
+ temptext = HiiGetString( popuppassword->ControlData.ControlHandle, UefiGetPromptField(popuppassword->ControlData.ControlPtr));
+ strlen = EfiStrLen(temptext+2);
+
+ tempTitle = MemReallocateZeroPool (
+ tempTitle,
+ ( (EfiStrLen (tempTitle) + 2) * sizeof (CHAR16) ),
+ ( ((EfiStrLen (tempTitle) + 2) * sizeof (CHAR16)) + ((EfiStrLen (temptext) + 2) * sizeof (CHAR16)) ) //2 for /n and NULL character
+ );
+
+ if (NULL == tempTitle)
+ return EFI_OUT_OF_RESOURCES;
+
+ //Eliminate white space character if any precedes
+ tText = temptext;
+ while(*temptext == L' ')
+ {
+ temptext++;
+ }
+
+ //Appending tse string with controlptr prompt string
+ EfiStrCat (tempTitle,temptext);
+ EfiStrCat (tempTitle,L"?");
+
+ //Adding string to hiistring
+ newtoken = HiiAddString( gHiiHandle, tempTitle );
+
+ //Setting new stringID as current stringID
+ ((AMI_IFR_MSGBOX*)(gClearLabelPasswordMsgBox))->Text = newtoken;
+
+ MemFreePointer( (VOID **)&tText );
+ MemFreePointer( (VOID **)&tempTitle );
+ }
+ //EIP-116315 password string. Ends
+
+ //Report Message box for Clearing Old password
+ if(CallbackShowMessageBox( (IsShowPromptStringAsTitle() ? (UINTN)gClearLabelPasswordMsgBox : (UINTN)gClearPasswordMsgBox), MSGBOX_TYPE_YESNO )!= MSGBOX_YES)
+ {
+ if ( IsShowPromptStringAsTitle() )
+ {
+ //Resetting original token
+ ((AMI_IFR_MSGBOX*)(gClearLabelPasswordMsgBox))->Text = orgtext;
+ //Delete created token
+ HiiRemoveString(gHiiHandle, newtoken);
+ }
+
+ goto Password;
+ //Status = EFI_UNSUPPORTED; //Do not clear the password
+ }
+ else
+ {
+ if ( IsShowPromptStringAsTitle() )
+ {
+ //Resetting original token
+ ((AMI_IFR_MSGBOX*)(gClearLabelPasswordMsgBox))->Text = orgtext;
+ //Delete created token
+ HiiRemoveString(gHiiHandle, newtoken);
+ }
+
+ ConfirmNewPswd = EfiLibAllocateZeroPool( sizeof(CHAR16) );
+
+ if(ConfirmNewPswd)
+ {
+ *ConfirmNewPswd = L'\0'; //Set confirmation password to null string
+ }
+ else
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
+ }
+ }
+ }
+ if(
+ NewPwLen &&
+ ( (NewPwLen < (UINT8)UefiGetMinValue (popuppassword->ControlData.ControlPtr)) ||
+ (NewPwLen > (UINT8)UefiGetMaxValue (popuppassword->ControlData.ControlPtr)) )
+ )
+ {
+ //Report Message box
+ CallbackShowMessageBox( (UINTN)gInvalidRangeFailMsgBox, MSGBOX_TYPE_OK );
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ // ask for new password(2)again
+ if ( ((!Status) && (NewPwLen != 0)) || ((VARIABLE_ID_IDE_SECURITY == popuppassword->ControlData.ControlVariable) && (!Status)) )
+ {
+ Status = _DoPopupEdit( popuppassword, (IsShowPromptStringAsTitle() ? STRING_TOKEN(STR_CONFIRM_NEW_PSWD_LABEL) : STRING_TOKEN(STR_CONFIRM_NEW_PSWD)), &ConfirmNewPswd);
+ }
+
+ if ( !Status )
+ {
+ //EIP-39764 : non case sensitive support during setting password
+ //EIP106950
+ if (
+ (IsPasswordSupportNonCaseSensitive ()) &&
+ ( NULL!=ConfirmNewPswd ) && (EfiStrLen (ConfirmNewPswd)) && //EIP-127023 Avoid crashing when give empty password
+ ( (VARIABLE_ID_AMITSESETUP == popuppassword->ControlData.ControlVariable) || (VARIABLE_ID_IDE_SECURITY == popuppassword->ControlData.ControlVariable) )
+ )
+ {
+ NewPwLen = EfiStrLen (ConfirmNewPswd);
+ UpdatePasswordToNonCaseSensitive (ConfirmNewPswd, NewPwLen);
+ }
+ if ( ( NULL!=ConfirmNewPswd ) && EfiStrCmp(NewPswd, ConfirmNewPswd)==0 ) //EIP-127023 Avoid crashing when give empty password
+ {
+ //EIP-75521 Support for Interactive Password control
+ if(popuppassword->Text != NULL){
+ MemFreePointer( (VOID **)&popuppassword->Text );
+ }
+ popuppassword->Text = (CHAR16 *) EfiLibAllocateZeroPool((NewPwLen + 1) * sizeof(CHAR16));
+ EfiStrCpy(popuppassword->Text, NewPswd);
+
+ //save new password
+ if ( ( popuppassword->Callback != NULL ) && ( popuppassword->Cookie != NULL ) )
+ {
+ VOID *ifrData = popuppassword->ControlData.ControlPtr;
+ CALLBACK_PASSWORD *callbackData = (CALLBACK_PASSWORD *)popuppassword->Cookie;
+
+ callbackData->Variable = popuppassword->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = (UINT8)UefiGetMaxValue(ifrData) * sizeof(CHAR16);
+ callbackData->Data = (VOID *)NewPswd;
+ SavePswdString(&(popuppassword->ControlData),NewPswd);
+ UefiPreControlUpdate(&(popuppassword->ControlData));
+ popuppassword->Callback( popuppassword->Container,popuppassword, popuppassword->Cookie );
+
+ PopupPwdUpdateIDEPwd ();
+ }
+
+
+ //For interactive control invoke the formcallback function.
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ {
+ VOID *Handle = popuppassword->ControlData.ControlHandle;
+ UINT16 Key = UefiGetControlKey(&(popuppassword->ControlData));
+ CONTROL_DATA *Control = (CONTROL_DATA *)NULL;
+
+ //Call the callback passing the input value and value size.
+ Status = CallFormCallBack( &(popuppassword->ControlData),Key,0,AMI_CALLBACK_CONTROL_UPDATE);
+
+ Control = GetUpdatedControlData((CONTROL_DATA*)popuppassword, CONTROL_TYPE_PASSWORD, Handle, Key);
+ if(Control == NULL){ //Control deleted.
+ return EFI_SUCCESS;
+ }
+ if(Control != (CONTROL_DATA *)popuppassword){
+ popuppassword = (POPUP_PASSWORD_DATA *)Control; //Control Updated.
+ }
+ }
+
+ popuppassword->ControlActive = FALSE;
+ }
+ else
+ {
+ CallbackShowMessageBox( (UINTN)gInvalidPasswordFailMsgBox, MSGBOX_TYPE_OK );
+ }
+ }
+ }
+ StringZeroFreeMemory ((VOID **)&Text); //EIP67735 zeroing the password prompt memories
+ StringZeroFreeMemory ((VOID **)&NewPswd);
+ StringZeroFreeMemory ((VOID **)&ConfirmNewPswd);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupPasswordHandleAction
+//
+// Description: function to handle the password actions
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, , ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PopupPasswordHandleAction( POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 u8ChkResult;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ return Status;
+
+ u8ChkResult = CheckControlCondition( &popuppassword->ControlData );
+
+ //Not to perform action for control when token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( IsGrayoutSelectable() && (COND_GRAYOUT == u8ChkResult) ) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ CONTROL_ACTION Action;
+
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ if(ControlActionSelect == Action)
+ {
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ if(PopupPasswordFormCallback(&(popuppassword->ControlData),UefiGetControlKey(&(popuppassword->ControlData)),0) == EFI_SUCCESS)
+ return EFI_SUCCESS;
+
+ return _PopupPasswordActivate(popuppassword);
+ }
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ if(ControlActionSelect == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ {
+
+ //EIP-123727 check whether MouseTop is within the Height and Width of Password Control or not
+ if((Data->Input.Data.MouseInfo.Top >= (UINT32)popuppassword->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(popuppassword->Top+popuppassword->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)popuppassword->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(popuppassword->Left+popuppassword->Width))
+ )
+ {
+ if(UefiIsInteractive(&popuppassword->ControlData))
+ if(PopupPasswordFormCallback(&(popuppassword->ControlData),UefiGetControlKey(&(popuppassword->ControlData)),0) == EFI_SUCCESS)
+ return EFI_SUCCESS;
+
+ return _PopupPasswordActivate(popuppassword);
+ }
+ }
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordHandleAction
+//
+// Description: Function to handle the PopupPassword Actions
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordHandleAction( POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = PopupPwdHandleActionOverRide(popuppassword, Data);
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordSetFocus
+//
+// Description: Function to set focus
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordSetFocus(POPUP_PASSWORD_DATA *popuppassword, BOOLEAN focus)
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &popuppassword->ControlData );
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT)) )
+ return EFI_UNSUPPORTED;
+ }
+
+ if( !(popuppassword->ControlFocus && focus) )
+ popuppassword->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordSetPosition
+//
+// Description: Function to set position.
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordSetPosition(POPUP_PASSWORD_DATA *popuppassword, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( popuppassword, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordSetDimensions(POPUP_PASSWORD_DATA *popuppassword, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( popuppassword, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordSetAttributes(POPUP_PASSWORD_DATA *popuppassword, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( popuppassword, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordGetControlHeight
+//
+// Description: function to get the height of the label
+//
+// Input: POPUP_PASSWORD_DATA *popuppassword, frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordGetControlHeight(POPUP_PASSWORD_DATA *popuppassword, VOID *frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ Width = ((FRAME_DATA*)frame)->FrameData.Width - 2;
+
+ text = HiiGetString( popuppassword->ControlData.ControlHandle, UefiGetPromptField(popuppassword->ControlData.ControlPtr));
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ newText = StringWrapText( text, Width, height );
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _CBPopupEdit
+//
+// Description: Function for PopupEdit callback.
+//
+// Input: VOID *container, VOID *object, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _CBPopupEdit(VOID *container, VOID *object, VOID *cookie)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ if(cookie!=NULL)
+ {
+
+ res=0;
+ }
+ else
+ res=1; // exit with no changes to string
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupEditGetValue
+//
+// Description: Function to get edit value.
+//
+// Input: POPUPEDIT_DATA *popupedit
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _PopupEditGetValue( POPUPEDIT_DATA *popupedit )
+{
+ ACTION_DATA *action = gApp->Action;
+ EFI_STATUS Status = EFI_SUCCESS;//EIP:67695
+ BOOLEAN DrawCursor = TRUE;//EIP:67695
+ UINT32 MousePointerX = 0,MousePointerY = 0,MousePointerZ = 0;
+
+ gPopupEdit.SetCallback( popupedit, NULL, _CBPopupEdit, &gPopupEditCb );
+ gPopupEdit.SetDimensions( popupedit, popupedit->Width , popupedit->Height );
+ res = (UINT8)-1;
+
+ SetPwdKeyboardLayout();//EIP-88912
+ TSEStringReadLoopEntryHook();
+
+ while ( res == (UINT8)-1 )
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ GetCoordinates (&MousePointerX, &MousePointerY, &MousePointerZ);
+ if (gST->ConOut)
+ {
+ if (
+ ( ((MousePointerX/HiiGetGlyphWidth ()) <= (UINT32)gST->ConOut->Mode->CursorColumn+1) && ((MousePointerX/HiiGetGlyphWidth ()) >= (UINT32)gST->ConOut->Mode->CursorColumn-1) ) &&
+ ( ((MousePointerY/HiiGetGlyphHeight ()) <= (UINT32)gST->ConOut->Mode->CursorRow+1) && ((MousePointerY/HiiGetGlyphHeight ()) >= (UINT32)gST->ConOut->Mode->CursorRow-1) ) //EIP79486 Stop the mouse if mouse poiner is over the text cursor useful for avoiding corruption
+ )
+ MouseStop ();
+ else
+ {
+ if ( !IsMouseOnSoftkbd() ) //EIP-164232 checking for mouse pointer position
+ MouseFreeze ();
+ }
+ }
+
+ gPopupEdit.Draw( popupedit );
+ DoRealFlushLines();
+
+ if (IsTSECursorSupport())//EIP-91364
+ {
+ if (TRUE == DrawCursor) //EIP:67695 Enabling at valid times
+ {
+ gST->ConOut->SetAttribute (gST->ConOut, popupedit->FGColor | popupedit->BGColor);
+ gST->ConOut->SetCursorPosition (gST->ConOut, popupedit->Left + EfiStrLen (popupedit->Text)+1, popupedit->Height- (2+ (popupedit->TextWidth/popupedit->Width +1))+popupedit->Top+1);
+ gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ DrawCursor = FALSE;
+ }
+ }
+ if ( !IsMouseOnSoftkbd() ) //EIP-164232 Avoid mouse flickers If mouse pointer is on softkbd area
+ MouseRefresh();
+
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+ Status = gPopupEdit.HandleAction( popupedit, action );
+ if (IsTSECursorSupport() && !(EFI_ERROR (Status)))//EIP:67695
+ {
+ DrawCursor = TRUE; //EIP:67695 If any valid action performed then draw the cursor, usefull for blinking
+ }
+ }
+ TSEStringReadLoopExitHook();
+ ResetPwdKeyboardLayout();//EIP-88912
+
+ return res;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DoPopupEdit
+//
+// Description: function to perform the edit operations on popup
+//
+// Input: POPUP_PASSWORD_DATA *PopupPassword, UINT16 Title, CHAR16 **Text
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _DoPopupEdit( POPUP_PASSWORD_DATA *PopupPassword, UINT16 Title, CHAR16 **Text)
+{
+ static UINT8 gIFRPopupEdit[50];
+ EFI_STATUS Status= EFI_SUCCESS;
+ UINT8 retValue = (UINT8)-1;
+ UINT16 newtoken = 0;
+
+ POPUPEDIT_DATA *popupedit = NULL;
+
+ CONTROL_INFO dummy;
+ BOOLEAN PreviousCursorState = gST->ConOut->Mode->CursorVisible;//EIP:67695
+
+ Status = gPopupEdit.Create( &popupedit );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+
+ MemCopy( &gIFRPopupEdit, (VOID*)PopupPassword->ControlData.ControlPtr, UefiGetIfrLength(PopupPassword->ControlData.ControlPtr) );
+
+ //EIP-116315 password string. Starts
+ //To show Control prompt string as PopupPassword String instead from AMITSEStr.uni file
+ if (IsShowPromptStringAsTitle())
+ {
+ UINTN strlen = 0;
+ CHAR16 *temptext, *tempTitle = NULL, *tText = NULL;
+ dummy.ControlHandle = PopupPassword->ControlData.ControlHandle;
+
+ //Get TSE string
+ temptext = HiiGetString( (VOID*)(UINTN)INVALID_HANDLE, Title);
+ strlen = EfiStrLen(temptext);
+
+ tempTitle = EfiLibAllocateZeroPool((strlen+2)*sizeof(CHAR16));
+
+ if (NULL == tempTitle)
+ return EFI_OUT_OF_RESOURCES;
+
+ EfiStrCpy (tempTitle,temptext);
+ strlen = EfiStrLen(tempTitle);
+
+ MemFreePointer( (VOID **)&temptext );
+
+ //Get Prompt String from ControlPtr
+ temptext = HiiGetString( PopupPassword->ControlData.ControlHandle, UefiGetPromptField(PopupPassword->ControlData.ControlPtr));
+ strlen = EfiStrLen(temptext+2);
+
+ tempTitle = MemReallocateZeroPool (
+ tempTitle,
+ ( (EfiStrLen (tempTitle) + 2) * sizeof (CHAR16) ),
+ ( ((EfiStrLen (tempTitle) + 2) * sizeof (CHAR16)) + ((EfiStrLen (temptext) + 2) * sizeof (CHAR16)) ) //2 for /n and NULL character
+ );
+
+ if (NULL == tempTitle)
+ return EFI_OUT_OF_RESOURCES;
+
+ //Eliminate white space character if any precedes
+ tText = temptext;
+ while(*temptext == L' ')
+ {
+ temptext++;
+ }
+
+ //Appending TSE string with controlptr string
+ EfiStrCat (tempTitle,temptext);
+
+ //Create new token for newly created string
+ newtoken = HiiAddString( PopupPassword->ControlData.ControlHandle, tempTitle );
+
+ //Set control prompt with newly created token
+ UefiSetPromptField ((VOID*)&gIFRPopupEdit,newtoken);
+
+ MemFreePointer( (VOID **)&tText );
+ MemFreePointer( (VOID **)&tempTitle );
+ }
+ else
+ {
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+ UefiSetPromptField ((VOID*)&gIFRPopupEdit,Title);
+ }
+ //EIP-116315 password string. Ends
+
+ dummy.ControlPtr = (VOID*)&gIFRPopupEdit;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ //gPopupEdit.SetTitle(popupedit,Title);
+ gPopupEdit.SetText(popupedit,*Text);
+ gPopupEdit.SetType( popupedit, POPUPEDIT_TYPE_PASSWORD );
+ Status = gPopupEdit.Initialize( popupedit, &dummy );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ //gPopupEdit.SetType( popupedit, POPUPEDIT_TYPE_PASSWORD );
+ retValue = (UINT8)_PopupEditGetValue( popupedit );
+ if (IsTSECursorSupport())//EIP-91364
+ {
+ gST->ConOut->EnableCursor (gST->ConOut, PreviousCursorState);//EIP:67695
+ }
+ if(retValue ==0)
+ {
+ // string changed, save to nvram or do whatever needs to be done
+ MemFreePointer( (VOID **)Text );
+ *Text = EfiLibAllocateZeroPool( (gPopupEditCb.Length+1) * sizeof(CHAR16) );
+ if ( Text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ EfiStrCpy( *Text, gPopupEditCb.Data );
+
+ }
+ else
+ Status = EFI_UNSUPPORTED;
+Done:
+ gPopupEdit.Destroy( popupedit, TRUE );
+ if ( IsShowPromptStringAsTitle() )
+ HiiRemoveString(gHiiHandle, newtoken);//Delete created token
+ return Status;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupPassword.h b/EDK/MiniSetup/TseLite/PopupPassword.h
new file mode 100644
index 0000000..2987967
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupPassword.h
@@ -0,0 +1,178 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupPassword.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 10 $
+//
+// $Date: 8/28/14 6:07a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupPassword.h $
+//
+// 10 8/28/14 6:07a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 9 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 5/18/12 6:56a Rajashakerg
+// [TAG] EIP85220
+// [Category] Improvement
+// [Description] TSE - Extend Popup password customization options
+// [Files] Popuppassword.h
+//
+// 7 11/30/11 11:58a Premkumara
+// [TAG] EIP75521
+// [Category] Improvement
+// [Description] Need to support interactive password controls
+// [Files] PopupPassword.c, PopupPassword.h, TsetAdvanced.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 7 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:53a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupPassword.h
+//
+// Description: Header file for Popup Passwords
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _POPUP_PASSWORD_H_
+#define _POPUP_PASSWORD_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "action.h"
+#include "Label.h"
+#include "PopupEdit.h"
+
+
+#define POPUP_PASSWORD_MEMBER_VARIABLES \
+UINT16 TextMargin; \
+UINT16 TextWidth; \
+UINT16 TextAreaWidth;
+
+
+typedef struct _POPUP_PASSWORD_METHODS POPUP_PASSWORD_METHODS;
+
+typedef struct _POPUP_PASSWORD_DATA
+{
+ POPUP_PASSWORD_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ LABEL_MEMBER_VARIABLES
+ POPUP_PASSWORD_MEMBER_VARIABLES
+
+}
+POPUP_PASSWORD_DATA;
+
+#define POPUP_PASSWORD_METHOD_FUNCTIONS
+
+
+struct _POPUP_PASSWORD_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ POPUP_PASSWORD_METHOD_FUNCTIONS
+
+};
+
+extern POPUP_PASSWORD_METHODS gPopupPassword;
+
+// Object Methods
+EFI_STATUS PopupPasswordCreate( VOID **object );
+EFI_STATUS PopupPasswordDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PopupPasswordInitialize( VOID *object, VOID *data );
+EFI_STATUS PopupPasswordDraw( VOID *object );
+EFI_STATUS PopupPasswordHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS PopupPasswordSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS PopupPasswordSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS PopupPasswordSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS PopupPasswordSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS PopupPasswordSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS PopupPasswordGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+
+EFI_STATUS _DoPopupEdit( POPUP_PASSWORD_DATA *PopupPassword, UINT16 Title, CHAR16 **Text);//EIP-75521 Support Interactive Password control
+
+#endif /* _POPUP_PASSWORD_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupSel.c b/EDK/MiniSetup/TseLite/PopupSel.c
new file mode 100644
index 0000000..dd81c20
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupSel.c
@@ -0,0 +1,1646 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupSel.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 40 $
+//
+// $Date: 8/28/14 3:09p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupSel.c $
+//
+// 40 8/28/14 3:09p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 39 5/02/14 9:36p Arunsb
+// EIP141986 changes reverted.
+//
+// 38 5/02/14 10:54a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 37 5/01/14 3:45p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 36 2/11/14 8:37p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 35 12/03/13 1:12p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 34 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 17 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 32 9/25/12 11:44a Blaines
+// [TAG] - EIP 101903
+// [Category] - Defect
+// [Synopsis] - Enabling Multiline in TSE cause a crash when entering in
+// TSE
+// [Root cause] If SPrint is called with a string that exceeds the
+// buffersize, overflow occurs and exception happens.
+// [Solution] Call Sprint using only the printable length copy of the
+// original string.
+// [Files] - Popupsel.c
+// [Function] - PopupSelGetControlHeight
+//
+// 31 9/18/12 5:08a Arunsb
+// [TAG] EIP95139
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] BootOrder and DriverOrder cases are not handled preoperly
+// in _PopupSelGetSelection() function
+// [Files] PopupSel.c
+//
+// 30 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 28 9/06/12 1:02a Rajashakerg
+// [TAG] EIP91410
+// [Category] Improvement
+// [Description] TSE_MULTILINE_CONTROLS=1 makes one of option with max
+// string looks not good.
+// [Files] PopupSel.c, COmmonHelper.c, AMITSE.sdl
+//
+// 27 2/01/12 8:05p Blaines
+// [TAG] - EIP 81631
+// [Category]- Sighting
+// [Synopsis]- In some SAS cards, HII Adapter Settings screen is not
+// wrapping the text correctly
+// [Solution] - Use the proper control width calculation to determine
+// control height in PopupSelGetControlHeight.
+// The string length calculation used to determine control height in
+// SubMenuGetControlHeight needs to be consistent with the same in
+// SubMenuDraw.
+//
+// [Files]
+// Submenu.c, PopupSel.c,
+//
+// 26 2/01/12 3:33a Arunsb
+// [TAG] EIP81603
+// [Category] Improvement
+// [Description] If any option is not obtained then default option is
+// used
+// [Files] PopupSel.c
+//
+// 25 1/31/12 7:04p Blaines
+// [TAG] - EIP 81631
+// [Category]- Sighting
+// [Synopsis]- In some SAS cards, HII Adapter Settings screen is not
+// wrapping the text correctly
+// [Solution] - Allow max space when creating controls in the functions
+// FrameAddControl, FrameDraw.
+// Allow max space for computing height in PopupSelGetControlHeight,
+// TextGetControlHeight PopupSelDraw, TextDraw.
+//
+// [Files]
+// Text.c, PopupSel.c, frame.c
+//
+// 24 1/18/12 6:37a Rajashakerg
+// [TAG] EIP79949
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Text srting is not wrapped in "Advanced -> Super IO config.
+// -> Floppy disk controller config. -> Change settings" option when
+// TSE_MULTILINE_CONTROLS token enabled.
+// [RootCause] The calculation was not proper to show maximum string in
+// the left control area for popupsel control.
+// [Solution] Adjusted the cordinates to show maximum string in control
+// left area
+// [Files] PopupSel.c
+//
+// 23 1/05/12 12:27a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupString.c, SubMenu.c, Text.c,PopupSel.c.
+//
+// 22 12/07/11 8:18a Rajashakerg
+// [TAG] EIP75118
+// [Category] Improvement
+// [Description] xtractConfig() fail since BrowserCallback() cannot find
+// the variable to process
+// [Files] FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
+// Uefi21Wapper.c, PopupSel.c
+//
+// 21 12/05/11 7:05p Blaines
+// [TAG] - EIP 77040
+// [Category]- Sighting
+// [Synopsis]- Setup: Boot Option Priority list items truncated, until you
+// move within the tab.
+// [Solution] - In the function PopupSelGetControlHeight, call the
+// function _PopupSelGetSelection to get the current selection before
+// computing the control height.
+//
+// [Files]
+// PopupSel.c
+//
+// 20 11/30/11 1:33p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 19 11/21/11 11:12a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 18 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 17 11/13/11 1:05p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 16 10/20/11 12:03p Madhans
+// Check in comment corrected.
+//
+// 15 9/19/11 11:50a Blaines
+// [TAG] EIP 68920
+// [Category] Defect
+// [Symptom] SOME SAS controller card HII menus hang when selecting "Clear
+// Configuration" when DEBUG_MODE=0
+// [RootCause] Menu is not re-initialize from SetupData after dynamic
+// page update.
+// PopupSelGetControlHeight() causes an assert if popupSel has an item
+// with an invalid string token.
+//
+// [Solution] Due to dynamic updates, SetupData (most current data) is
+// given priority when re-initializing menu.
+// Check for invalid string token in PopupSelGetControlHeight.
+//
+// [Files Changed]
+// - Menu.c, Popupsel.c
+//
+// 14 8/26/11 2:10p Blaines
+// [TAG] EIP 67487
+// [Category] Defect
+// [Symptom] TSE_MULTILINE_CONTROLS does not work for all control types
+// [RootCause] The controls (PopupSel, PopupString) ONLY check for
+// string wrapping in the label value (control prompt) when calling the
+// methods GetControlHeight and Draw.
+// [Solution] The controls (PopupSel, PopupString) should check for
+// string wrapping in the label (control prompt) and the control's value
+// when calling the methods GetControlHeight and Draw. For Dynamic pages,
+// adjust the width calculation for Submenu in the function
+// GetControlHeight.
+// [Files] PopupSel.c, PopupString.c, Submenu.c
+//
+// 13 3/28/11 11:40p Madhans
+// [TAG] EIP50878
+// [Category] Improvement
+// [Description] Support to move the Control With Boot Order Change.
+// [Files] AMITSE.sdl
+// commonoem.c
+// minisetup.h
+// popupsel.c
+//
+// 12 3/21/11 12:40a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 11 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 10 12/02/10 6:08p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 9 12/02/10 2:34p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 8 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 3/26/10 5:06p Madhans
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 11 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 10 2/17/10 7:03p Madhans
+// To suppor readonly control
+//
+// 9 2/15/10 10:15p Madhans
+// To avoid warnings
+//
+// 8 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 7 1/09/10 6:57a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 6 9/15/09 9:48a Sudhirv
+// updated the Add Del Boot Option support
+//
+// 5 8/13/09 1:20p Blaines
+// EIP #24980 Fix to properly display right area text
+//
+// 4 8/13/09 7:40a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:12p Madhans
+// TSE Lite Special control support
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupSel.c
+//
+// Description: This file contains code to handle Popup selections
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+BOOLEAN OneofMultilineDisable(POPUPSEL_DATA *popupSel);
+VOID _PopupSelGetSelection( POPUPSEL_DATA *popupSel );
+static BOOLEAN bSelectionChanged = FALSE;
+
+extern EFI_STATUS _FrameScroll( FRAME_DATA *frame, BOOLEAN bScrollUp );
+extern UINT16 _gHDOrderPageID;
+extern UINT16 _gCDOrderPageID;
+extern UINT16 _gFDOrderPageID;
+extern UINT16 _gNetOrderPageID;
+extern UINT16 _gBevOrderPageID;
+
+POPUPSEL_METHODS gPopupSel =
+{
+ PopupSelCreate,
+ PopupSelDestroy,
+ PopupSelInitialize,
+ PopupSelDraw,
+ PopupSelHandleAction,
+ PopupSelSetCallback,
+ PopupSelSetFocus,
+ PopupSelSetPosition,
+ PopupSelSetDimensions,
+ PopupSelSetAttributes,
+ PopupSelGetControlHeight
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelCreate
+//
+// Description: this function uses the create function of control
+// and creates the Popup Selected
+//
+// Input: POPUPSEL_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelCreate( POPUPSEL_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(POPUPSEL_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gPopupSel;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the Popup Selected
+//
+// Input: POPUPSEL_DATA *popupSel, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelDestroy( POPUPSEL_DATA *popupSel, BOOLEAN freeMem )
+{
+ if(NULL == popupSel)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( popupSel, FALSE );
+
+ if ( popupSel->ListBoxCtrl )
+ gListBox.Destroy( popupSel->ListBoxCtrl, TRUE );
+
+ popupSel->ListBoxCtrl = NULL;
+
+ if( freeMem )
+ {
+ MemFreePointer( (VOID **)&(popupSel->PtrTokens) );
+ MemFreePointer( (VOID **)&popupSel );
+
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelInitialize
+//
+// Description: this function uses the initialize function of control
+// and initializes the Popup Selected
+//
+// Input: POPUPSEL_DATA *popupSel, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelInitialize( POPUPSEL_DATA *popupSel, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Index = 0;
+ UINT16 *OptionList=NULL;
+ UINT64 *ValueList=NULL;
+
+
+ Status = gControl.Initialize( popupSel, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ popupSel->PopupSelHandle = popupSel->ControlData.ControlHandle;
+ popupSel->Title = UefiGetPromptField(popupSel->ControlData.ControlPtr);
+
+ // add extra initialization here...
+ Status = UefiGetOneOfOptions(&popupSel->ControlData,&popupSel->PopupSelHandle,
+ &OptionList, &ValueList, &popupSel->ItemCount,&popupSel->bInteractive,&popupSel->CallBackKey);
+
+ if (EFI_ERROR(Status))
+ return Status;
+
+ popupSel->Interval = (UINT8)(popupSel->ControlData.ControlFlags.ControlRefresh);
+
+ if( popupSel->PtrTokens != NULL )
+ MemFreePointer( (VOID **)&(popupSel->PtrTokens));
+ popupSel->PtrTokens = EfiLibAllocatePool( popupSel->ItemCount * sizeof(PTRTOKENS) );
+ if ( popupSel->PtrTokens == NULL )
+ Status = EFI_OUT_OF_RESOURCES;
+ else
+ {
+ 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));
+
+ if(popupSel->ControlData.ControlFlags.ControlInteractive)
+ {
+ popupSel->bInteractive = TRUE;
+ popupSel->CallBackKey = popupSel->ControlData.ControlKey;
+ }
+
+ // boundary overflow check
+
+ popupSel->ListBoxCtrl = NULL;
+ popupSel->ListBoxEnd = FALSE;
+ popupSel->LabelMargin = (UINT8)gControlLeftMargin;
+
+ // We dont have to do Get selection here it is done before we draw a page
+ //_PopupSelGetSelection( popupSel );
+
+ SetControlColorsHook(&(popupSel->BGColor), &(popupSel->FGColor), NULL, NULL ,&(popupSel->SelBGColor), &(popupSel->SelFGColor),
+ NULL , &(popupSel->NSelFGColor),NULL,&(popupSel->LabelFGColor) ,
+ &(popupSel->NSelLabelFGColor),NULL ,NULL,NULL, NULL );
+
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelDraw
+//
+// Description: function to draw the specific popup window
+//
+// Input: POPUPSEL_DATA *popupSel
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelDraw( POPUPSEL_DATA *popupSel )
+{
+ CHAR16 *text=NULL,*text1=NULL;
+ UINTN i=0,Len=0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 Index = 0, TempHeight=0;
+ UINT16 *OptionList=NULL;
+ UINT64 *ValueList=NULL;
+
+ UINT16 tmpHeight=0;
+
+ UINT8 ColorNSel = popupSel->NSelFGColor;
+ UINT8 ColorLabel = (popupSel->ControlFocus) ? popupSel->LabelFGColor : popupSel->NSelLabelFGColor ;
+
+ if( popupSel->ListBoxCtrl != NULL)
+ {
+ gListBox.Draw( popupSel->ListBoxCtrl );
+ }
+ else
+ {
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //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 )
+ {
+ //Eip TSE_MULTILINE_CONTROLS moved to binary
+ if(popupSel->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( (UINTN)popupSel->Left, (UINTN) popupSel->Top,
+ (UINTN)(popupSel->LabelMargin - popupSel->Left),(UINTN) popupSel->Height,
+ text1, popupSel->BGColor | ColorLabel );
+ }
+ else
+ {
+ // 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);
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(popupSel->Height>1 && OneofMultilineDisable(popupSel))
+ {
+ TempHeight = popupSel->Height;
+ popupSel->Height = 1;
+ }
+
+ if(popupSel->Height>1 && IsTSEMultilineControlSupported())
+ {
+ Len = TestPrintLength( text1 ) / (NG_SIZE);
+ text = EfiLibAllocateZeroPool( (Len+3)*2 );
+ SPrint( text,(UINTN)( (Len+3)*2 )/*(popupSel->Width - popupSel->Left - popupSel->LabelMargin +2)*/, L"[%s]", text1 );
+ MemFreePointer( (VOID **)&text1 );
+
+ text1 = StringWrapText( (CHAR16*)text, (popupSel->Width - popupSel->LabelMargin ), &tmpHeight );
+
+ if(tmpHeight == 1)
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin , popupSel->Top, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus) ? popupSel->SelBGColor | popupSel->SelFGColor : popupSel->BGColor | ColorNSel ));
+ else
+ DrawMultiLineStringWithAttribute( (UINTN)popupSel->Left + (UINTN)popupSel->LabelMargin, (UINTN) popupSel->Top,
+ (UINTN)(popupSel->Width - popupSel->LabelMargin ),(UINTN)&tmpHeight/*popupSel->Height*/, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus)? popupSel->SelBGColor | popupSel->SelFGColor :
+ popupSel->BGColor | ColorNSel ));
+
+ MemFreePointer( (VOID **)&text1 );
+
+ }
+ else
+ {
+
+ if(!text1)
+ text1 = EfiLibAllocateZeroPool(2);
+
+ //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->Left - popupSel->LabelMargin -4)/*gControlRightAreaWidth*/ ) //EIP 79949 : Adjusted the cordinates to show maximum string in control left area
+ EfiStrCpy(&text1[HiiFindStrPrintBoundary(text1 ,(UINTN)(popupSel->Width + popupSel->Left - popupSel->LabelMargin /*gControlRightAreaWidth*/-7/*16*/))],L"..." );
+
+
+ text = EfiLibAllocateZeroPool( (Len+3)*2 );
+ SPrint( text,(UINTN)( (Len+3)*2 )/*(popupSel->Width - popupSel->Left - popupSel->LabelMargin +2)*/, L"[%s]", text1 );
+ MemFreePointer( (VOID **)&text1 );
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin , popupSel->Top, (CHAR16*)text,
+ (UINT8)( (popupSel->ControlFocus) ?
+ popupSel->SelBGColor | popupSel->SelFGColor :
+ popupSel->BGColor | ColorNSel ));
+
+ }
+
+ if((TempHeight > 0) && OneofMultilineDisable(popupSel))
+ {
+ popupSel->Height = TempHeight;
+ }
+ 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;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelSetCallback
+//
+// Description: Function to handle the PopupString actions
+//
+// Input: POPUPSEL_DATA *popupSel, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelSetCallback( POPUPSEL_DATA *popupSel, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( popupSel, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoBootDelBootOption
+//
+// Description: Function to delete the boot option
+//
+// Input: POPUPSEL_DATA *
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN DoBootDelBootOption (POPUPSEL_DATA *popupSel)
+{
+ if( popupSel->ControlData.ControlVariable == VARIABLE_ID_DEL_BOOT_OPTION )
+ {
+ //delete selected option
+ BootDelBootOption( (UINT16) popupSel->PtrTokens[popupSel->Sel].Value );
+
+ //Complete redraw
+ gApp->CompleteRedraw = TRUE;
+
+ //Variable should not be set so return
+ return 1;
+ }
+ return 0;
+}
+
+//EIP70421 & 70422 Support for driver order
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoDriverDelDriverOption
+//
+// Description: Function to delete the driver option
+//
+// Input: POPUPSEL_DATA *
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN DoDriverDelDriverOption(POPUPSEL_DATA * popupSel)
+{
+ if (VARIABLE_ID_DEL_DRIVER_OPTION == popupSel->ControlData.ControlVariable)
+ {
+ //delete selected option
+ DriverDelDriverOption ((UINT16) popupSel->PtrTokens[popupSel->Sel].Value);
+
+ //Complete redraw
+ gApp->CompleteRedraw = TRUE;
+
+ //Variable should not be set so return
+ return 1;
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoPopupSelCallBack
+//
+// Description: Callback function of the PopupSel
+//
+// Input: POPUPSEL_DATA *popupSel
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoPopupSelCallBack(POPUPSEL_DATA **popupSel)
+{
+//#if SETUP_SUPPORT_ADD_BOOT_OPTION
+ if( TseDoBootDelBootOption(*popupSel) )
+ return;
+//#endif
+
+ if( TseDoDriverDelDriverOption(*popupSel) ) //EIP70421 & 70422 Support for driver order
+ return;
+
+ if ( (*popupSel)->Cookie != NULL )
+ {
+ VOID *ifrData = (VOID *)(*popupSel)->ControlData.ControlPtr;
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)(*popupSel)->Cookie;
+
+ callbackData->Variable = (*popupSel)->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetWidth(ifrData);
+ callbackData->Data = (VOID*)&((*popupSel)->PtrTokens[(*popupSel)->Sel].Value);
+ }
+ // To support UEFI 2.1.C spec to Not to update the control when Callback fails.
+ UefiPreControlUpdate(&((*popupSel)->ControlData));
+ (*popupSel)->Callback( (*popupSel)->Container, (*popupSel), (*popupSel)->Cookie );
+
+ if((*popupSel)->bInteractive)
+ {
+ EFI_STATUS Status;
+ VOID * Handle=(*popupSel)->ControlData.ControlHandle;
+ UINT16 Key = (*popupSel)->CallBackKey;
+ CONTROL_DATA *Control;
+
+ Status = CallFormCallBack(&((*popupSel)->ControlData),(*popupSel)->CallBackKey,0, AMI_CALLBACK_CONTROL_UPDATE);//EIP-53480: Updated the action to AMI_CALLBACK_CONTROL_UPDATE
+ Control = GetUpdatedControlData((CONTROL_DATA*)(*popupSel),(*popupSel)->ControlData.ControlType,Handle,Key);
+
+
+ if(Control == NULL){ // Control deleted ?
+ *popupSel = NULL;
+ return;
+ }
+ if(Control != (CONTROL_DATA*)(*popupSel))
+ *popupSel = (POPUPSEL_DATA*)Control; //control Updated
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupSelHandleActionKey
+//
+// Description: function to handle the PopupSel Action keys
+//
+// Input: POPUPSEL_DATA *popupSel, AMI_EFI_KEY_DATA key
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _PopupSelHandleActionKeyMouse(POPUPSEL_DATA *popupSel, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_ACTION Action=ControlActionUnknown;
+ AMI_EFI_KEY_DATA key=Data->Input.Data.AmiKey;
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ //EIP-123727 check whether MouseTop is within the Height and Width of PopupSel or not
+ if((Data->Input.Data.MouseInfo.Top >= (UINT32)popupSel->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(popupSel->Top+popupSel->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)popupSel->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(popupSel->Left+popupSel->Width))
+ )
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ }
+
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ Action = MapControlKeysHook(key);
+
+ switch(Action)
+ {
+ case ControlActionDecreament:
+ //Handle special case for boot order & Legacy dev order
+ if (
+ (VARIABLE_ID_BOOT_ORDER == popupSel->ControlData.ControlVariable) ||
+ (VARIABLE_ID_BBS_ORDER == popupSel->ControlData.ControlVariable) ||
+ (VARIABLE_ID_DRIVER_ORDER == popupSel->ControlData.ControlVariable) //EIP70421 & 70422 Support for driver order
+ )
+ {
+ RearrangeBootDriverOrderVariable (popupSel, FALSE);
+ }
+ else if( ( CheckForAddDelBootOption() ) &&
+ (popupSel->ControlData.ControlVariable == VARIABLE_ID_DEL_BOOT_OPTION ) )
+ {
+ }
+ else
+ {
+ if ( popupSel->Sel > 0 )
+ popupSel->Sel--;
+ else
+ popupSel->Sel = popupSel->ItemCount - 1;
+ DoPopupSelCallBack(&popupSel);
+ if(popupSel == NULL)
+ return EFI_SUCCESS;
+ }
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionIncreament:
+ //Handle special case for boot order & Legacy dev order
+ if (
+ (VARIABLE_ID_BOOT_ORDER == popupSel->ControlData.ControlVariable) ||
+ (VARIABLE_ID_BBS_ORDER == popupSel->ControlData.ControlVariable) ||
+ (VARIABLE_ID_DRIVER_ORDER == popupSel->ControlData.ControlVariable) //EIP70421 & 70422 Support for driver order
+ )
+ {
+ RearrangeBootDriverOrderVariable (popupSel, TRUE);
+ }
+ else if( ( CheckForAddDelBootOption() ) &&
+ (popupSel->ControlData.ControlVariable == VARIABLE_ID_DEL_BOOT_OPTION ) )
+ {
+ }
+ else
+ {
+ if ( popupSel->Sel < (UINTN)(popupSel->ItemCount - 1) )
+ popupSel->Sel++;
+ else
+ popupSel->Sel = 0;
+ DoPopupSelCallBack(&popupSel);
+ if(popupSel == NULL)
+ return EFI_SUCCESS;
+ }
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionSelect:
+ if ( gListBox.Create( &(popupSel->ListBoxCtrl) ) == EFI_SUCCESS )
+ {
+ popupSel->ControlActive = TRUE;
+ gListBox.Initialize( popupSel->ListBoxCtrl, &(popupSel->ControlData) );
+ if(TseLiteIsSpecialOptionList((CONTROL_DATA *)popupSel) == TRUE)
+ {
+ UINT16 TempLength=0, i;
+ //Need fix the ListBox options
+ for( i = 0 ; i < popupSel->ItemCount; i++ )
+ {
+ popupSel->ListBoxCtrl->PtrTokens[i] = popupSel->PtrTokens[i].Option;
+ TempLength = (UINT16)HiiMyGetStringLength( popupSel->ListBoxCtrl->ListHandle, popupSel->ListBoxCtrl->PtrTokens[i] );
+ TempLength+=5; // to included barders
+ if ( TempLength > popupSel->ListBoxCtrl->Width )
+ popupSel->ListBoxCtrl->Width = TempLength;
+ }
+
+ }
+
+ if(popupSel->ListBoxCtrl->Width > (UINT16)(gMaxCols-5))
+ popupSel->ListBoxCtrl->Width = (UINT16)(gMaxCols-5);
+ popupSel->ListBoxCtrl->Sel = popupSel->Sel;
+ gListBox.SetCallback(popupSel->ListBoxCtrl, popupSel, _PopupSelCallback, NULL);
+
+ MouseStop();
+
+ gListBox.Draw( popupSel->ListBoxCtrl );
+
+ MouseRefresh();
+ }
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ break;
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelHandleAction
+//
+// Description: function to handle the PopupSel Actions
+//
+// Input: POPUPSEL_DATA *popupSel, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelHandleAction( POPUPSEL_DATA *popupSel, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 u8ChkResult;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ // List box is active don't refresh
+ if ( popupSel->ListBoxCtrl != NULL )
+ return Status;
+
+ if (popupSel->Interval == 0)
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if ( --(popupSel->Interval) == 0 )
+ {
+ // initialize the interval
+ popupSel->Interval = (UINT8)(popupSel->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(popupSel->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ u8ChkResult = CheckControlCondition( &popupSel->ControlData );
+
+ //Not to perform action for control when token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( IsGrayoutSelectable() && (COND_GRAYOUT == u8ChkResult) ) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if(popupSel->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+ if(!popupSel->ControlFocus)
+ return Status;
+
+ if ( popupSel->ListBoxCtrl != NULL )
+ {
+ Status = gListBox.HandleAction(popupSel->ListBoxCtrl,Data);
+ if ( popupSel->ListBoxEnd )
+ {
+ if(bSelectionChanged)
+ {
+ if(popupSel->Sel != popupSel->ListBoxCtrl->Sel)
+ {
+ popupSel->Sel = popupSel->ListBoxCtrl->Sel;
+ DoPopupSelCallBack(&popupSel);
+ if(popupSel == NULL)
+ return EFI_SUCCESS;
+
+ }
+ bSelectionChanged = FALSE;
+ }
+
+ gListBox.Destroy(popupSel->ListBoxCtrl,TRUE);
+ popupSel->ListBoxCtrl = NULL;
+ popupSel->ListBoxEnd = FALSE;
+ popupSel->ControlActive = FALSE;
+ }
+ }
+ else
+ {
+ if((Data->Input.Type == ACTION_TYPE_KEY) || (Data->Input.Type == ACTION_TYPE_MOUSE))
+ {
+ return _PopupSelHandleActionKeyMouse(popupSel, Data);
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelSetFocus
+//
+// Description: Function to set focus
+//
+// Input: POPUPSEL_DATA *popupSel, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelSetFocus(POPUPSEL_DATA *popupSel, BOOLEAN focus)
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &popupSel->ControlData );
+
+ //Setting focus to control which has no condtion and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to focus and selectable
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT))
+ ){
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ if( !(popupSel->ControlFocus && focus) )
+ popupSel->ControlFocus = focus;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelSetPosition
+//
+// Description: Function to set position.
+//
+// Input: POPUPSEL_DATA *popupSel, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelSetPosition(POPUPSEL_DATA *popupSel, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( popupSel, Left, Top );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: POPUPSEL_DATA *popupSel, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelSetDimensions(POPUPSEL_DATA *popupSel, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( popupSel, Width, Height );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: POPUPSEL_DATA *popupSel, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelSetAttributes(POPUPSEL_DATA *popupSel, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( popupSel, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupSelCallback
+//
+// Description: PopupSel callback function.
+//
+// Input: POPUPSEL_DATA *container, CONTROL_DATA *popupSel, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PopupSelCallback( POPUPSEL_DATA *container, CONTROL_DATA *popupSel, VOID *cookie )
+{
+ container->ListBoxEnd = TRUE;
+ if ( cookie != NULL )
+ {
+ bSelectionChanged = TRUE;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelHandleAction
+//
+// Description: function to handle the PopupSel set and get operations
+//
+// Input: POPUPSEL_DATA *popupSel
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PopupSelGetSelection( POPUPSEL_DATA *popupSel )
+{
+ VOID *temp;
+ VOID *ifrData = popupSel->ControlData.ControlPtr;
+ int i=0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ popupSel->Sel = 0;
+ temp = EfiLibAllocateZeroPool( 8 * 2 );
+ if ( temp == NULL )
+ return;
+
+ if ( VarGetValue( popupSel->ControlData.ControlVariable, UefiGetQuestionOffset(ifrData), UefiGetWidth(ifrData), temp ) == EFI_SUCCESS )
+ {
+ while( i< popupSel->ItemCount)
+ {
+ if(popupSel->PtrTokens[i].Value == *(UINT64 *)temp)
+ {
+ popupSel->Sel = (UINT16)i;
+ break;
+ }
+ i++;
+ }
+ if( i == popupSel->ItemCount)
+ {
+ //EIP92783 Boot order and driver order are special controls, so TSE is forming the one of with the current boot/driver options.
+ //So no need of checking error case.
+ if ( (VARIABLE_ID_BOOT_ORDER == popupSel->ControlData.ControlVariable) || (VARIABLE_ID_DRIVER_ORDER == popupSel->ControlData.ControlVariable) )
+ {
+ popupSel->Sel = 0;
+ }
+ else
+ {
+ // The data does not correspond to the available selections
+ if(popupSel->ControlData.ControlDataWidth != 0) //Uncommented for EIP81603 One-of forced to new value but new value not passed to RouteConfig
+ {
+ //Try to set selection to the default option
+ VarGetDefaults( popupSel->ControlData.ControlVariable,
+ UefiGetQuestionOffset(popupSel->ControlData.ControlPtr),
+ popupSel->ControlData.ControlDataWidth, temp );
+
+ i=0;
+ while( i< popupSel->ItemCount)
+ {
+ if(popupSel->PtrTokens[i].Value == *(UINT16 *)temp)
+ {
+ popupSel->Sel = (UINT16)i;
+ Status = VarSetValue( popupSel->ControlData.ControlVariable,
+ UefiGetQuestionOffset(popupSel->ControlData.ControlPtr),
+ (UefiGetWidth(popupSel->ControlData.ControlPtr) > sizeof(UINT16) )?sizeof(UINT16):UefiGetWidth(popupSel->ControlData.ControlPtr),
+ temp );
+ break;
+ }
+ i++;
+ }
+ }
+ if( (i == popupSel->ItemCount) || (EFI_ERROR(Status)) )
+ {
+ //Try to set selection to the option with smallest value
+ UINT16 TempoptIndex = 0; //holds index of option with smalleset value
+ i = 0;
+ while (i< popupSel->ItemCount) //Trying for least option
+ {
+ if (popupSel->PtrTokens [i].Value < popupSel->PtrTokens [TempoptIndex].Value)
+ {
+ TempoptIndex = (UINT16)i;
+ }
+ i++;
+ }
+ popupSel->Sel = (UINT16)TempoptIndex; // if nothing else works, revert to the option with smallest value
+ Status = VarSetValue (popupSel->ControlData.ControlVariable,
+ UefiGetQuestionOffset (popupSel->ControlData.ControlPtr),
+ (UefiGetWidth (popupSel->ControlData.ControlPtr) > sizeof (UINT16)) ? sizeof (UINT16) : UefiGetWidth (popupSel->ControlData.ControlPtr),
+ &(popupSel->PtrTokens[TempoptIndex].Value) );
+ }
+ // either case (found default, reverted to first value)we have changed the variable so notify application
+ }
+ }
+ }
+ MemFreePointer( (VOID **)&temp );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RearrangeBootDriverOrderVariable
+//
+// Description: Function to rearrange the boot/driver order variables
+//
+// Input: POPUPSEL_DATA *popupSel, UINT8 bIncrease
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RearrangeBootDriverOrderVariable (POPUPSEL_DATA *popupSel, UINT8 bIncrease)
+{
+ UINTN optionNumber,size;
+ UINT16 newOption, *optionList = NULL;
+ VOID *ifrData = popupSel->ControlData.ControlPtr;
+ FRAME_DATA *MainFrame = NULL ;
+ UINTN OptionCount = 0;
+
+ MainFrame = gApp->PageList[gApp->CurrentPage]->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ //Find newOption
+ if (
+ (VARIABLE_ID_BOOT_ORDER == popupSel->ControlData.ControlVariable) ||
+ (VARIABLE_ID_DRIVER_ORDER == popupSel->ControlData.ControlVariable) //EIP70421 & 70422 Support for driver order
+ )
+ {
+ (VARIABLE_ID_BOOT_ORDER == popupSel->ControlData.ControlVariable) ? (OptionCount = gBootOptionCount) : (OptionCount = gDriverOptionCount);
+ optionNumber = UefiGetQuestionOffset (ifrData) / sizeof(UINT16);
+ size = 0;
+ optionList = (UINT16 *)VarGetVariable (popupSel->ControlData.ControlVariable, &size);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == optionList){
+ return;
+ }
+
+ if(optionList[optionNumber] == DISABLED_BOOT_OPTION)
+ newOption = DISABLED_BOOT_OPTION;
+ else
+ {
+ if(bIncrease)
+ {
+ if(0 == optionNumber)
+ {
+ //MAY CHANGE: cant increase priority further
+ newOption = optionList [optionNumber];
+ }
+ else
+ {
+ newOption = optionList [optionNumber - 1];
+ //EIP:50878
+ if (IsUpdateBootOrderCursor ())
+ _FrameScroll (MainFrame, TRUE);
+ }
+ }
+ else
+ {
+ if ( (optionNumber+1) >= OptionCount )
+ {
+ //MAY CHANGE: cant decrease priority further
+ newOption = optionList [optionNumber];
+ }
+ else if ( DISABLED_BOOT_OPTION == optionList[optionNumber+1] )
+ {
+ //MAY CHANGE: cant decrease priority further
+ newOption = optionList [optionNumber];
+ }
+ else
+ {
+ newOption = optionList [optionNumber + 1];
+ //EIP:50878
+ if (IsUpdateBootOrderCursor ())
+ _FrameScroll ( MainFrame, FALSE);
+ }
+ }
+ }
+
+ //Free Optionlist
+ MemFreePointer((VOID **) &optionList);
+ }
+//#if TSE_CSM_SUPPORT
+ else if(popupSel->ControlData.ControlVariable == VARIABLE_ID_BBS_ORDER)
+ {
+ CsmRearrangeBBSOrderVariable(popupSel, bIncrease, &newOption);
+ }
+//#endif //TSE_CSM_SUPPORT
+
+ //Call callback to the container to record this change in gVariableList(cached copy)
+ if ( popupSel->Cookie != NULL )
+ {
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)popupSel->Cookie;
+
+ callbackData->Variable = popupSel->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetWidth(ifrData);
+ callbackData->Data = (VOID *)&newOption;
+
+ popupSel->Callback( popupSel->Container, popupSel, popupSel->Cookie );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RearrangeBBSOrderVariable
+//
+// Description: Function to reorder the BBS order variable
+//
+// Input: POPUPSEL_DATA *popupSel, UINT8 bIncrease,UINT16 *newOption
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RearrangeBBSOrderVariable(POPUPSEL_DATA *popupSel, UINT8 bIncrease,UINT16 *newOption)
+{
+ UINTN optionNumber,size;
+ UINT16 *optionList = NULL;
+ VOID *ifrData = popupSel->ControlData.ControlPtr;
+ UINT8 *pDevOrder;
+ UINT16 count = 0;
+ UINTN offset = UefiGetQuestionOffset(ifrData);
+ FRAME_DATA *MainFrame = NULL ;
+ MainFrame = gApp->PageList[gApp->CurrentPage]->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+
+ size = 0;
+ pDevOrder = VarGetVariable( VARIABLE_ID_BBS_ORDER, &size );
+
+ offset -= (sizeof(UINT32) + sizeof(UINT16));
+
+ count = gCurrLegacyBootData->LegacyDevCount;
+ offset -= gCurrLegacyBootData->LegacyEntryOffset;
+ optionList = (UINT16 *)(pDevOrder + gCurrLegacyBootData->LegacyEntryOffset + sizeof(UINT32) + sizeof(UINT16));
+
+ optionNumber = offset / sizeof(UINT16);
+
+ if(optionList[optionNumber] == DISABLED_BOOT_OPTION)
+ *newOption = DISABLED_BOOT_OPTION;
+ else
+ {
+ if(bIncrease)
+ {
+ if(0 == optionNumber)
+ {
+ //MAY CHANGE: cant increase priority further
+ *newOption = optionList[optionNumber];
+ }
+ else
+ {
+ *newOption = optionList[optionNumber - 1];
+ //EIP:50878
+ if(IsUpdateBootOrderCursor())
+ _FrameScroll( MainFrame, TRUE);
+ }
+
+ }
+ else
+ {
+ if( (optionNumber+1) >= count )
+ {
+ //MAY CHANGE: cant decrease priority further
+ *newOption = optionList[optionNumber];
+ }
+ else if( DISABLED_BOOT_OPTION == optionList[optionNumber+1] )
+ {
+ //MAY CHANGE: cant decrease priority further
+ *newOption = optionList[optionNumber];
+ }
+ else
+ {
+ *newOption = optionList[optionNumber + 1];
+ //EIP:50878
+ if(IsUpdateBootOrderCursor())
+ _FrameScroll( MainFrame, FALSE);
+ }
+ }
+ }
+ //Free Order
+ MemFreePointer((VOID **) &pDevOrder);
+}
+
+//EIP81603 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------------------------------------
+// Procedure: _GetPopUpSelectionFromVariable
+//
+// Description: Fucntion to return the current selection based on the variable. If not matched with variable value
+// Selection will be 0
+//
+// Input: POPUPSEL_DATA *
+//
+// Output: VOID
+//
+//-----------------------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _GetPopUpSelectionFromVariable (POPUPSEL_DATA *popupSel)
+{
+ VOID *temp;
+ VOID *ifrData = popupSel->ControlData.ControlPtr;
+ int i = 0;
+
+ popupSel->Sel = 0;
+ temp = EfiLibAllocateZeroPool (8 * 2);
+ if (NULL == temp)
+ return;
+
+ if (VarGetValue (popupSel->ControlData.ControlVariable, UefiGetQuestionOffset (ifrData), UefiGetWidth (ifrData), temp) == EFI_SUCCESS)
+ {
+ while (i< popupSel->ItemCount)
+ {
+ if (popupSel->PtrTokens [i].Value == *(UINT64 *)temp)
+ {
+ popupSel->Sel = (UINT16)i;
+ break;
+ }
+ i++;
+ }
+ }
+}
+//EIP81603 Ends
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSelGetControlHeight
+//
+// Description: function to get the height of the label
+//
+// Input: POPUPSEL_DATA *popupSel,Frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSelGetControlHeight(POPUPSEL_DATA *popupSel,VOID * frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *text=NULL, *text1=NULL, *newtext=NULL ;
+ UINT16 Width ;
+ UINT16 tmpHeight=0;
+ UINTN Len=0;
+
+ UINT16 Index = 0;
+ UINT16 *OptionList=NULL;
+ UINT64 *ValueList=NULL;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ 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));
+ }
+
+ Width = (UINT16)(popupSel->LabelMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gLabelLeftMargin));
+
+ *height = 1 ;
+
+// _PopupSelGetSelection( popupSel ); //EIP81603 One-of forced to new value but new value not passed to RouteConfig
+ _GetPopUpSelectionFromVariable (popupSel); //In _PopupSelGetSelection fnc, boot manager variable behaving wrongly so introduced _GetPopUpSelectionFromVariable fnc
+ //to read simply value from variable and set the option and not setting any value to variable
+
+ text1 = HiiGetString( popupSel->PopupSelHandle, popupSel->PtrTokens[popupSel->Sel].Option);
+
+ //EIP 68920: Check for invalid string token
+ if (text1 != NULL)
+ {
+ //Len = TestPrintLength( text1 ) / (NG_SIZE);
+ Len = (3 + (TestPrintLength( text1 ) / (NG_SIZE))) * sizeof(CHAR16);
+
+ text = EfiLibAllocateZeroPool(Len);
+ newtext = EfiLibAllocateZeroPool(Len);
+
+ if ( text == NULL || newtext == NULL)
+ return EFI_OUT_OF_RESOURCES;
+
+ MemCpy(newtext, text1, Len);
+
+ SPrint( text,(UINTN)( Len ), L"[%s]", newtext );
+
+ MemFreePointer( (VOID **)&text1 );
+ MemFreePointer( (VOID **)&newtext );
+
+ text1 = StringWrapText( (CHAR16*)text, (UINT16)(((FRAME_DATA *)frame)->FrameData.Width - gLabelLeftMargin - 2 - popupSel->LabelMargin), &tmpHeight );
+ MemFreePointer( (VOID **)&text1 );
+
+ *height = tmpHeight;
+
+ MemFreePointer( (VOID **)&text );
+ }
+
+ text = HiiGetString( popupSel->ControlData.ControlHandle, popupSel->Title ) ;
+
+ if(text == NULL)
+ return EFI_OUT_OF_RESOURCES;
+
+ text1 = StringWrapText(text, Width, &tmpHeight );
+
+ if ((tmpHeight >= 1) && ( OneofMultilineDisable(popupSel)))
+ {
+ *height = tmpHeight;
+ }
+ else if(tmpHeight > *height)
+ *height = tmpHeight;
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&text );
+ MemFreePointer( (VOID **)&text1 );
+ }
+
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+BOOLEAN TseSuppressOneofMultilineSupport(VOID);
+BOOLEAN OneofMultilineDisable(POPUPSEL_DATA *popupSel)
+{
+ if((UefiIsOneOfControl(popupSel->ControlData.ControlPtr))&&(TseSuppressOneofMultilineSupport()))
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupSel.h b/EDK/MiniSetup/TseLite/PopupSel.h
new file mode 100644
index 0000000..7b4050d
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupSel.h
@@ -0,0 +1,229 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupSel.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 11 $
+//
+// $Date: 8/28/14 6:08a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupSel.h $
+//
+// 11 8/28/14 6:08a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 10 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 11/21/11 11:10a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 8 11/13/11 1:06p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupSel.h
+//
+// Description: Header file for Popup selections
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _POPUPSEL_H_
+#define _POPUPSEL_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "ListBox.h"
+
+#define POPUPSEL_VALUE_BASE UINT64
+#define POPUPSEL_MAX_WIDTH (gControlRightAreaWidth)
+typedef struct _PTRTOKENS
+{
+ UINT16 Option;
+ POPUPSEL_VALUE_BASE Value;
+}PTRTOKENS;
+
+#define POPUPSEL_MEMBER_VARIABLES \
+ UINT16 Title; \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT16 LabelMargin; \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT8 NSelFGColor; \
+ LISTBOX_DATA *ListBoxCtrl; \
+ BOOLEAN ListBoxEnd; \
+ /*EFI_HII_HANDLE*/VOID * PopupSelHandle; \
+ UINT16 Sel; \
+ UINT16 ItemCount; \
+ UINT16 bInteractive; \
+ UINT16 CallBackKey; \
+ PTRTOKENS *PtrTokens; \
+ UINT8 Interval;
+
+
+typedef struct _POPUPSEL_METHODS POPUPSEL_METHODS;
+
+typedef struct _POPUPSEL_DATA
+{
+ POPUPSEL_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUPSEL_MEMBER_VARIABLES
+
+}
+POPUPSEL_DATA;
+
+
+struct _POPUPSEL_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+};
+
+extern POPUPSEL_METHODS gPopupSel;
+
+// Object Methods
+EFI_STATUS PopupSelCreate( VOID **object );
+EFI_STATUS PopupSelDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PopupSelInitialize( VOID *object, VOID *data );
+EFI_STATUS PopupSelDraw( VOID *object );
+EFI_STATUS PopupSelHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS PopupSelSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS PopupSelSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS PopupSelSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS PopupSelSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS PopupSelSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS PopupSelGetControlHeight( VOID *object,VOID *frame, UINT16 *height );
+
+VOID _PopupSelCallback( POPUPSEL_DATA *container, CONTROL_DATA *popupSel, VOID *cookie );
+VOID RearrangeBootDriverOrderVariable (POPUPSEL_DATA *popupSel, UINT8 bIncrease); //EIP70421 & 70422 Support for driver order
+
+#endif /* _POPUPSEL_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupString.c b/EDK/MiniSetup/TseLite/PopupString.c
new file mode 100644
index 0000000..35fb02e
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupString.c
@@ -0,0 +1,1283 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupString.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 42 $
+//
+// $Date: 8/28/14 3:04p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupString.c $
+//
+// 42 8/28/14 3:04p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 41 8/28/14 12:44p Premkumara
+// [TAG] EIP177886
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Mouse pointer flicker continuously when softkbd is launched
+// for string control
+// [Root Cause] MouseRefresh() function is been called continuously when
+// popupedit is launched
+// [Solution] Calling MouseRefresh() function only when mouse pointer is
+// on Edit area or over cursor
+// [Files] PopupString.c
+//
+// 40 5/02/14 9:41p Arunsb
+// EIP141986 changes reverted.
+//
+// 39 5/02/14 10:52a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 38 5/01/14 3:45p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 37 2/11/14 8:39p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 36 12/03/13 2:15p Premkumara
+// [TAG] EIP130420
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] String is getting truncated
+// [RootCause] The string for messagebox, Popup controls is getting
+// truncated
+// [Solution] Used temp variable to store original string and modify the
+// string temp and used to avoid changing org string.
+// [Files] String.c
+//
+// 35 12/03/13 1:13p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 34 7/01/13 9:41a Premkumara
+// [TAG] EIP127021
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Clearing string in interactive String control causes setup
+// crash
+// [RootCause] Memory for PopupString->Text is allocated with length of
+// typed string and trying to get current string using PopupString max
+// value size in VarGetValue() function
+// [Solution] Allocating PopupString->Text properly based on popupstring
+// max value once string is cleared
+// [Files] PopupString.c
+//
+// 33 5/22/13 11:03a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c
+//
+// 32 4/17/13 12:04p Arunsb
+// EIP118949; Commented error messagebox in interactive callback failure
+// case.
+//
+// 31 2/22/13 12:46p Blaines
+// [TAG] - EIP 115724
+// [Category]- Defect
+// [Symptom]- Multiline support for Hii String control does not wrap the
+// string in some cases issues.
+//
+// [Root cause]
+// In the functions PopupStringGetControlHeight and PopupStringDraw,
+// the computed width of the right column is incorrect,
+// causing the height to be 1, defaulting to string truncation.
+//
+// [Files]
+// - PopupString.c
+//
+// [Functions]
+// - PopupStringDraw
+// - PopupStringGetControlHeight
+//
+// 30 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 19 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 28 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 26 8/29/12 8:32a Premkumara
+// [TAG] EIP 91364
+// [Category] Improvement
+// [Description] Token to disable the Cursor of TSE Password Dialog
+// [Files] AMITSE.sdl, CommonHelper.c, Postmgmtext.c, PopupPassword.c,
+// PopupString.c
+//
+// 25 5/25/12 2:42a Premkumara
+// [TAG] EIP90894
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Assert happening in Add/Del Boot/Driver option
+// [RootCause] PopupString->Textwidth is not handled properly when empty
+// string is entered
+// [Solution] Handled PopupString->Textwidth properly
+// [Files] PopupString.c
+//
+// 24 4/27/12 2:42a Rajashakerg
+// [TAG] EIP86346
+// [Category] Improvement
+// [Description] Cursor visibility is not proper in multiline string
+// controls
+// [Files] PopupEdit.c, PopupString.c
+//
+// 23 11/30/11 11:28a Premkumara
+// [TAG] EIP67695
+// [Category] Improvement
+// [Description] No cursor visible in setup, while editing text input
+// box
+// [Files] Buffer.c, Postmgmtext.c, PopupString.c, PopupPassword.c
+//
+// 22 11/21/11 11:08a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 21 11/21/11 8:58a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 20 11/16/11 7:58a Premkumara
+// [TAG] EIP75522 & 75517
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Accepts invalid String for string control, mismatch in
+// string length
+// [RootCause] Invalid strings are not validated using
+// CallbackShowMessageBox() function.
+// Improper in PopupString->textwidth before and after string entered.
+// Previous string is not retained.
+// [Solution] - Displaying Invalid error message for invalid string by
+// calling CallbackShowMessageBox() function
+// - PopupString->Textwidth is handled proper
+//
+// [Files] PopupString.c
+//
+// 19 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 18 8/26/11 2:10p Blaines
+// [TAG] EIP 67487
+// [Category] Defect
+// [Symptom] TSE_MULTILINE_CONTROLS does not work for all control types
+// [RootCause] The controls (PopupSel, PopupString) ONLY check for
+// string wrapping in the label value (control prompt) when calling the
+// methods GetControlHeight and Draw.
+// [Solution] The controls (PopupSel, PopupString) should check for
+// string wrapping in the label (control prompt) and the control's value
+// when calling the methods GetControlHeight and Draw. For Dynamic pages,
+// adjust the width calculation for Submenu in the function
+// GetControlHeight.
+// [Files] PopupSel.c, PopupString.c, Submenu.c
+//
+// 17 6/23/11 3:52p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 16 3/28/11 9:25p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 15 3/21/11 12:42a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 14 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 13 12/29/10 9:40a Mallikarjunanv
+// [TAG] EIP51143
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] popup string value field is not grayed out even if the
+// grayoutif condition satisfies.
+// [RootCause] Not handled the color selection for grayout control in
+// case of popupstring.
+// [Solution] Fixed the issue by setting the color to grayout in case of
+// a grayout popupsting control.
+//
+// [Files] PopupString.c
+//
+// 11 12/26/10 4:16p Mallikarjunanv
+// [TAG] EIP48387
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Displayed message as "Invalid input range" for the
+// specified string as boot option name (for eg., "aaaa").
+// [RootCause] In case of pressing ECS key the string length of Popup
+// string is not considered.
+// [Solution] Fixed the issue by handling Report message box display
+// with
+// respect to Popup string text.
+// [Files] PopupString.c
+//
+// 10 12/02/10 6:08p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 9 12/02/10 2:34p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 8 10/04/10 4:24p Blaines
+// In the function _DoPopupStringEdit, call gPopupEdit.SetType before
+// calling gPopupEdit.Initialize. This is useful in case the function
+// gPopupEdit.Initialize is overriden.
+//
+// 7 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 11 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 10 2/17/10 7:03p Madhans
+// To suppor readonly control
+//
+// 9 2/15/10 10:15p Madhans
+// To avoid warnings
+//
+// 8 2/05/10 6:05p Madhans
+// To fix the Screen corruption if mouse pointer is on the popup.
+//
+// 7 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 6 1/09/10 6:58a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 1/04/10 10:40a Mallikarjunanv
+// EIPs 27161/29095 - Added support for reserved boot option names and
+// added support not to create empty boot option names
+//
+// 4 8/13/09 1:20p Blaines
+// EIP #24980 Fix to properly display right area text
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PopupStirng.c
+//
+// Description: This file contains code to handle Popup Stirngs
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+UINTN gCursorLeft,gCursorTop ;
+POPUP_STRING_METHODS gPopupString =
+{
+ PopupStringCreate,
+ PopupStringDestroy,
+ PopupStringInitialize,
+ PopupStringDraw,
+ PopupStringHandleAction,
+ PopupStringSetCallback,
+ PopupStringSetFocus,
+ PopupStringSetPosition,
+ PopupStringSetDimensions,
+ PopupStringSetAttributes,
+ PopupStringGetControlHeight
+
+};
+extern UINTN gInvalidRangeFailMsgBox;
+extern UINTN gAddBootOptionReserved;
+extern CALLBACK_VARIABLE gPopupEditCb ;
+extern UINT8 res ;
+
+VOID BbsStrnCpy ( CHAR16 *Dst, CHAR16 *Src, UINTN Length );
+BOOLEAN IsTSECursorSupport(); //EIP-91364
+BOOLEAN IsMouseOnSoftkbd(VOID); //EIP-177886
+VOID GetCoordinates(INT32 *x, INT32 *y, INT32 *z);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringCreate
+//
+// Description: this function uses the create function of control
+// and creates popup strings
+//
+// Input: TPOPUP_STRING_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringCreate( POPUP_STRING_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(POPUP_STRING_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gPopupString;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys popup strings
+//
+// Input: POPUP_STRING_DATA *popupstring, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringDestroy( POPUP_STRING_DATA *popupstring, BOOLEAN freeMem )
+{
+ if(NULL == popupstring)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( popupstring, FALSE );
+
+ MemFreePointer( (VOID **)&popupstring->Text );
+
+ if( freeMem )
+ MemFreePointer( (VOID **)&popupstring );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringDestroy
+//
+// Description: this function uses the Initialize function of control
+// and initializes popup strings
+//
+// Input: POPUP_STRING_DATA *popupstring, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringInitialize( POPUP_STRING_DATA *popupstring, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( popupstring, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ SetControlColorsHook(NULL, NULL,
+ NULL, NULL,
+ &(popupstring->SelBGColor), &(popupstring->SelFGColor),
+ &(popupstring->BGColor), &(popupstring->FGColor),
+ NULL,&(popupstring->LabelFGColor),
+ &(popupstring->NSelLabelFGColor),
+ NULL,NULL,
+ NULL,NULL );
+
+ popupstring->ControlData.ControlHelp = UefiGetHelpField(popupstring->ControlData.ControlPtr);
+ popupstring->Interval = (UINT8)popupstring->ControlData.ControlFlags.ControlRefresh;
+
+ popupstring->TextMargin = (UINT8)gControlLeftMargin;
+ if ( popupstring->TextWidth == 0 )
+ popupstring->TextWidth = UefiGetWidth(((CONTROL_INFO *)data)->ControlPtr) /2;
+
+ popupstring->TextAreaWidth = (popupstring->TextWidth </*10*/(UINT16)(popupstring->Width - popupstring->TextMargin -2) ) ? popupstring->TextWidth:/*10*/(UINT16)(popupstring->Width - popupstring->TextMargin -2);
+
+ popupstring->Text = EfiLibAllocateZeroPool((popupstring->TextWidth +1)* sizeof(CHAR16));
+ MemSet( popupstring->Text, (popupstring->TextWidth +1)* sizeof(CHAR16), 0 );
+
+
+ popupstring->TempText = EfiLibAllocateZeroPool((popupstring->TextWidth +1)* sizeof(CHAR16));
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringDraw
+//
+// Description: this function is to draw the popup strings
+//
+// Input: POPUP_STRING_DATA *popupstring
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringDraw(POPUP_STRING_DATA *popupstring )
+{
+ CHAR16 *text, *text1=NULL;
+ UINT16 tmpHeight=0;
+ UINTN Len = 0;
+ UINT8 BGClr,FGClr;
+ EFI_STATUS Status = EFI_SUCCESS;
+ //UINT8 ColorNSel = popupstring->FGColor;
+ UINT8 ColorLabel = (popupstring->ControlFocus) ? popupstring->LabelFGColor : popupstring->NSelLabelFGColor ;
+ VOID *ifrData = popupstring->ControlData.ControlPtr;
+
+ if(popupstring->ControlFocus)
+ {
+ BGClr = popupstring->SelBGColor;
+ FGClr = popupstring->SelFGColor;
+ }
+ else
+ {
+ BGClr = popupstring->BGColor;
+ FGClr = popupstring->FGColor;
+ }
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( popupstring->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &popupstring->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ FGClr = ColorLabel = CONTROL_GRAYOUT_COLOR; //EIP_51143 - to display the control value in grayout color
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text = HiiGetString( popupstring->ControlData.ControlHandle, UefiGetPromptField(popupstring->ControlData.ControlPtr));
+
+ if ( text != NULL )
+ {
+ CHAR16 *temptxt = NULL;
+
+ temptxt = (CHAR16 *)EfiLibAllocateZeroPool( (UefiGetWidth(ifrData)+1) * sizeof(CHAR16) );
+
+ //get the string value to check for string length
+ VarGetValue( popupstring->ControlData.ControlVariable, UefiGetQuestionOffset(ifrData), UefiGetWidth(ifrData), (VOID *)temptxt );
+ if (temptxt){
+ Len = TestPrintLength( temptxt ) / (NG_SIZE);
+ MemFreePointer( (VOID **)&temptxt );
+ }
+
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(popupstring->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( popupstring->Left , popupstring->Top,
+ (UINTN)(popupstring->TextMargin - popupstring->Left),(UINTN) popupstring->Height, text,
+ (UINT8)( (!Len && popupstring->ControlFocus) ? (popupstring->SelBGColor | popupstring->SelFGColor) : (popupstring->BGColor | ColorLabel) ) //make it to focus when no string is given
+ );
+ }
+ else
+ {
+ // use frame width minus margins as available space
+ // boundary overflow check
+ if (( TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(popupstring->TextMargin - popupstring->Left) )
+ //EfiStrCpy(&text[HiiFindStrPrintBoundary(text,(UINTN)(popupstring->Width - 5))],L"...");
+ text[HiiFindStrPrintBoundary(text,(UINTN)(popupstring->TextMargin - popupstring->Left ))] = L'\0';
+
+ DrawStringWithAttribute( popupstring->Left ,
+ popupstring->Top, text,
+ (UINT8)( (!Len && popupstring->ControlFocus) ? (popupstring->SelBGColor | popupstring->SelFGColor) : (popupstring->BGColor | ColorLabel) ) //Make it to focus when no string is given
+ );
+ }
+ //PopUpString has to display the string besides the title; need not fill with space here
+ //for(i=(UINT16)(popupstring->Left + EfiStrLen( text )/*popupstring->TextWidth*/); i < popupstring->Width; i++)
+ // DrawStringWithAttribute( i, popupstring->Top, L" ", BGClr | FGClr );
+
+ MemFreePointer( (VOID **)&text );
+ }
+
+ if(ifrData)
+ {
+ //get the string value
+ VarGetValue( popupstring->ControlData.ControlVariable, UefiGetQuestionOffset(ifrData), UefiGetWidth(ifrData), (VOID *)popupstring->Text );
+
+ Len = TestPrintLength( popupstring->Text ) / (NG_SIZE);
+
+ if(Len)
+ {
+ text = EfiLibAllocateZeroPool((Len+1)*2);
+ EfiStrCpy(text, popupstring->Text);
+
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(popupstring->Height>1 && IsTSEMultilineControlSupported())
+ {
+ text1 = StringWrapText( (CHAR16*)text, (popupstring->Width - popupstring->TextMargin ), &tmpHeight );
+
+ if(tmpHeight > 1)
+ {
+ DrawMultiLineStringWithAttribute( (UINTN)popupstring->Left + (UINTN)popupstring->TextMargin,
+ (UINTN) popupstring->Top,
+ (UINTN)(popupstring->Width - popupstring->TextMargin ),
+ (UINTN)popupstring->Height, (CHAR16*)text,
+ (UINT8) (popupstring->ControlFocus ? (popupstring->SelBGColor | popupstring->SelFGColor) : (popupstring->BGColor | ColorLabel) )
+ );
+ }
+ else
+ {
+ DrawStringWithAttribute( popupstring->Left + popupstring->TextMargin,
+ popupstring->Top, text,
+ (UINT8) (popupstring->ControlFocus ? (popupstring->SelBGColor | popupstring->SelFGColor) : (popupstring->BGColor | ColorLabel) )
+ );
+ }
+
+ MemFreePointer( (VOID **)&text1 );
+ MemFreePointer( (VOID **)&text );
+
+ }
+ else
+ {
+ if ( Len > (UINTN)(popupstring->Width - popupstring->TextMargin) )
+ {
+ Len = popupstring->Width - popupstring->TextMargin;
+ EfiStrCpy( &(text[Len-3 /*3 for "..."*/]), L"..." );
+ }
+
+ DrawStringWithAttribute ( popupstring->Left + popupstring->TextMargin , popupstring->Top, text,
+ (UINT8) (popupstring->ControlFocus ? (popupstring->SelBGColor | popupstring->SelFGColor) : (popupstring->BGColor | ColorLabel) )
+ );
+
+ MemFreePointer( (VOID **)&text );
+ }
+
+ }
+
+
+ // erase extra spaces if neccessary
+ //for(;(UINT16)(popupstring->Left + popupstring->TextMargin + Len) < (popupstring->Width);Len++)
+ // DrawStringWithAttribute( popupstring->Left + popupstring->TextMargin +Len , popupstring->Top, L" ",
+ // BGClr | FGClr);
+ }
+
+ FlushLines( popupstring->Top , popupstring->Top );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringSetCallback
+//
+// Description: function to handle the PopupString actions
+//
+// Input: POPUP_STRING_DATA *popupstring, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringSetCallback( POPUP_STRING_DATA *popupstring, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( popupstring, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringHandleAction
+//
+// Description: function to handle the Popup string actions.
+//
+// Input: POPUP_STRING_DATA *popupstring, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringHandleAction( POPUP_STRING_DATA *popupstring, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_ACTION Action=ControlActionUnknown;
+ VOID * UnicodeInterface;
+ CHAR16 *TmpStr = NULL;
+ CHAR16 *ResStr = NULL;
+ CHAR16 *TmpPopupStringText = NULL;
+ UINT16 TmpPopupStringTextWidth = 0;
+ UINT8 u8ChkResult;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if (popupstring->Interval == 0)
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if ( --(popupstring->Interval) == 0 )
+ {
+ // initialize the interval
+ popupstring->Interval = (UINT8)(popupstring->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(popupstring->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ u8ChkResult = CheckControlCondition( &popupstring->ControlData );
+
+ //Not to perform action for grayoutif-control when token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT) ) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if(popupstring->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+ if ( Data->Input.Type == ACTION_TYPE_MOUSE )
+ {
+ //Get mapping
+
+ //EIP-123727 check whether MouseTop is within the Height and Width of popupstring or not
+ if( (Data->Input.Data.MouseInfo.Top >= (UINT32)popupstring->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(popupstring->Top+popupstring->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)popupstring->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(popupstring->Left+popupstring->Width))
+ )
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ }
+ }
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ //Get mapping
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+ }
+
+ if(ControlActionSelect == Action)
+ {
+ //Taking backup of original string.
+ TmpPopupStringText = EfiLibAllocateZeroPool((popupstring->TextWidth + 1) * sizeof(CHAR16));
+ if(NULL == TmpPopupStringText){
+ return EFI_OUT_OF_RESOURCES;
+ }
+ EfiStrCpy(TmpPopupStringText, popupstring->Text);
+
+ //Taking backup of initial string length EIP-75522
+ TmpPopupStringTextWidth = popupstring->TextWidth; //EIP-90894
+
+ // Reading string
+ if(_DoPopupStringEdit( popupstring,UefiGetPromptField(popupstring->ControlData.ControlPtr), &(popupstring->Text)) == EFI_SUCCESS)
+ {
+ UINTN MinVal=0, MaxVal=0;
+ MinVal = (UINTN)UefiGetMinValue(popupstring->ControlData.ControlPtr);
+ MaxVal = (UINTN)UefiGetMaxValue(popupstring->ControlData.ControlPtr);
+
+ //Find length of entered string EIP-75522
+ popupstring->TextWidth = (UINT16)EfiStrLen(popupstring->Text);
+
+ // Check for Range. If its a valid string annd not between min and max report invalid error msg
+ if((popupstring->Text) &&((popupstring->TextWidth < MinVal) || (popupstring->TextWidth > MaxVal)))
+ {
+ //Reset popupstring->Text with initial string EIP-75522
+ if(TmpPopupStringText) {
+ MemFreePointer((VOID **)&popupstring->Text);
+ popupstring->Text = EfiLibAllocateZeroPool((MaxVal + 1) * sizeof(CHAR16)); //EIP-127021 Allocating PopupString->Text based on max size of control
+ if(NULL == popupstring->Text){
+ MemFreePointer((VOID **)&TmpPopupStringText);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ EfiStrCpy(popupstring->Text, TmpPopupStringText);
+ MemFreePointer((VOID **)&TmpPopupStringText);
+ popupstring->TextWidth = TmpPopupStringTextWidth; ////EIP-90894 Resetting width with old one
+ }
+ //Report Message box EIP-75522
+ CallbackShowMessageBox( (UINTN)gInvalidRangeFailMsgBox, MSGBOX_TYPE_OK );
+ return EFI_ABORTED;
+ }
+
+ ///Fix: Eip-27161 - not to allow Reserved boot options to delete
+ if( (popupstring->Text) && (IsReservedBootOptionNamesEnable()) )
+ {
+ ResStr = CONVERT_TO_WSTRING(RESERVED_ADD_DEL_BOOT_OPTION_NAME);
+ TmpStr = EfiLibAllocateZeroPool( EfiStrLen(ResStr)+1);
+ BbsStrnCpy(TmpStr, popupstring->Text, (EfiStrLen(ResStr)+1));
+ TmpStr[EfiStrLen(ResStr)]= L'\0';
+
+ Status = InitUnicodeCollectionProtocol(&UnicodeInterface);
+ if(!EFI_ERROR(Status))
+ {
+ if( StringColl( UnicodeInterface, TmpStr, ResStr) == 0 )
+ {
+ CallbackShowMessageBox( (UINTN)gAddBootOptionReserved, MSGBOX_TYPE_OK );
+ return EFI_ABORTED;
+
+ }
+ }
+ }
+
+ if(popupstring->Callback != NULL)
+ {
+ if ( popupstring->Cookie != NULL )
+ {
+ VOID *ifrData = popupstring->ControlData.ControlPtr;
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)popupstring->Cookie;
+
+ callbackData->Variable = popupstring->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetWidth(ifrData);
+ callbackData->Data = (VOID *)popupstring->Text;
+
+ // To support UEFI 2.1.C spec to Not to update the control when Callback fails.
+ UefiPreControlUpdate(&(popupstring->ControlData));
+ popupstring->Callback( popupstring->Container,popupstring, popupstring->Cookie );
+ }
+ }
+ if ( UefiIsInteractive(&popupstring->ControlData) )
+ {
+ VOID * Handle=popupstring->ControlData.ControlHandle;
+ UINT16 Key = UefiGetControlKey(&(popupstring->ControlData));
+ CONTROL_DATA *Control;
+
+ Status = CallFormCallBack(&(popupstring->ControlData),Key,0,AMI_CALLBACK_CONTROL_UPDATE);//EIP-53480: Updated the action to AMI_CALLBACK_CONTROL_UPDATE
+ Control = GetUpdatedControlData((CONTROL_DATA*)popupstring,CONTROL_TYPE_POPUP_STRING,Handle,Key);
+
+ if(Control == NULL) // Control deleted ?
+ return EFI_SUCCESS;
+ if(Control != (CONTROL_DATA*)popupstring)
+ popupstring = (POPUP_STRING_DATA*)Control; //control Updated
+
+ //If error status returned by CallFormCallBack(), reset popupstring->Text with the old string.
+ if(EFI_ERROR(Status))
+ {
+ if(popupstring->Text)
+ MemFreePointer((VOID **)&popupstring->Text);
+ popupstring->Text = EfiLibAllocateZeroPool((TmpPopupStringTextWidth + 1) * sizeof(CHAR16));
+ if(popupstring->Text == NULL){
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if(TmpPopupStringText) {
+ //Resetting old PopupstringText with TmpPopupStringText EIP-75522
+ EfiStrCpy(popupstring->Text, TmpPopupStringText);
+ }
+
+ //Reset string length to initial string TmpPopupStringTextWidth length EIP-75522
+ popupstring->TextWidth = TmpPopupStringTextWidth;
+
+ //Report Message box and return without proceeding further. EIP-75522
+ //CallbackShowMessageBox( (UINTN)gInvalidRangeFailMsgBox, MSGBOX_TYPE_OK ); //All other callback not poping up msg box so commented
+ MemFreePointer((VOID **)&TmpPopupStringText);
+ return EFI_ABORTED;
+
+ }
+
+ }
+ }
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringSetFocus
+//
+// Description: Function to handle the PopupString actions
+//
+// Input: POPUP_STRING_DATA *popuppassword, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringSetFocus(POPUP_STRING_DATA *popuppassword, BOOLEAN focus)
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &popuppassword->ControlData );
+
+ //Setting focus to control which has no control-condtion and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to focus and selectable
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT))
+ ){
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ if( !(popuppassword->ControlFocus && focus) )
+ popuppassword->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringSetPosition
+//
+// Description: Function to set position.
+//
+// Input: POPUP_STRING_DATA *popuppassword, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringSetPosition(POPUP_STRING_DATA *popuppassword, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( popuppassword, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: POPUP_STRING_DATA *popuppassword, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringSetDimensions(POPUP_STRING_DATA *popuppassword, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( popuppassword, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: POPUP_STRING_DATA *popuppassword, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringSetAttributes(POPUP_STRING_DATA *popuppassword, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( popuppassword, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupStringGetControlHeight
+//
+// Description: Function to get the lable height of the PopupString
+//
+// Input: POPUP_STRING_DATA *popupstring, frame, UINT16 *height
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupStringGetControlHeight(POPUP_STRING_DATA *popupstring, VOID * frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width=0, tmpHeight=0;
+ VOID *ifrData = popupstring->ControlData.ControlPtr;
+
+ if(ifrData)
+ {
+ //get the string value
+ VarGetValue( popupstring->ControlData.ControlVariable, UefiGetQuestionOffset(ifrData), UefiGetWidth(ifrData), (VOID *)popupstring->Text );
+ newText = StringWrapText( popupstring->Text,
+ (UINT16)(((FRAME_DATA *)frame)->FrameData.Width - gLabelLeftMargin - popupstring->TextMargin - 2 ), &tmpHeight );
+
+ *height = tmpHeight;
+ MemFreePointer( (VOID **)&newText );
+ }
+
+ Width = (UINT16)(popupstring->TextMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gControlLeftPad));
+ text = HiiGetString( popupstring->ControlData.ControlHandle, UefiGetPromptField(popupstring->ControlData.ControlPtr));
+
+ newText = StringWrapText( text, Width, &tmpHeight );
+
+ if(tmpHeight > *height)
+ *height = tmpHeight;
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1 ;
+ }
+ return EFI_SUCCESS;
+}
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _CBPopupStringEdit
+//
+// Description: Function for PopupStringEdit callback.
+//
+// Input: VOID *container, VOID *object, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _CBPopupStringEdit(VOID *container, VOID *object, VOID *cookie)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ if(cookie!=NULL)
+ {
+
+ res=0;
+ }
+ else
+ res=1; // exit with no changes to string
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PopupStringEditGetValue
+//
+// Description: function to get values for popup menu using edit functions.
+//
+// Input: POPUP_STRING_DATA *popupedit
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _PopupStringEditGetValue( POPUPEDIT_DATA *popupedit )
+{
+ ACTION_DATA *action = gApp->Action;
+ BOOLEAN DrawCursor = TRUE;//EIP:67695
+ EFI_STATUS Status = EFI_SUCCESS;//EIP:67695
+ INT32 MousePointerX = 0,MousePointerY = 0,MousePointerZ = 0;
+
+ gPopupEdit.SetCallback( popupedit, NULL, _CBPopupStringEdit, &gPopupEditCb );
+ gPopupEdit.SetDimensions( popupedit, popupedit->Width , popupedit->Height );
+ res = (UINT8)-1;
+
+ TSEStringReadLoopEntryHook();
+
+ while ( res == (UINT8)-1 )
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ GetCoordinates (&MousePointerX, &MousePointerY, &MousePointerZ); //EIP-177886
+ if (gST->ConOut)
+ {
+ if (
+ ( ((MousePointerX/HiiGetGlyphWidth ()) <= (UINT32)gST->ConOut->Mode->CursorColumn+1) && ((MousePointerX/HiiGetGlyphWidth ()) >= (UINT32)gST->ConOut->Mode->CursorColumn-1) ) &&
+ ( ((MousePointerY/HiiGetGlyphHeight ()) <= (UINT32)gST->ConOut->Mode->CursorRow+1) && ((MousePointerY/HiiGetGlyphHeight ()) >= (UINT32)gST->ConOut->Mode->CursorRow-1) ) //EIP79486 Stop the mouse if mouse poiner is over the text cursor useful for avoiding corruption
+ )
+ MouseStop ();
+ else
+ {
+ if ( !IsMouseOnSoftkbd() )
+ MouseFreeze ();
+ }
+ }
+
+ gPopupEdit.Draw( popupedit );
+ DoRealFlushLines();
+
+ if (IsTSECursorSupport()) //EIP-91364
+ {
+ if (TRUE == DrawCursor) //EIP:67695 Enabling at valid times
+ {
+ gST->ConOut->SetAttribute (gST->ConOut, popupedit->FGColor | popupedit->BGColor);
+ gST->ConOut->SetCursorPosition (gST->ConOut, gCursorLeft, gCursorTop);//EIP 86346 : Providing the calculated Cursor position values.
+ gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ DrawCursor = FALSE;
+ }
+ }
+ if ( !IsMouseOnSoftkbd() )
+ MouseRefresh();
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ if( ( action->Input.Type == ACTION_TYPE_KEY ) &&
+ (TsePrintScreenEventSupport(action->Input.Data.AmiKey.Key.ScanCode) ) )
+ {
+ gApplication.HandleAction( gApp, action );
+ DrawCursor = TRUE; //EIP-123432 If print screen is taken then Drawcursor is made true.
+ continue;
+ }
+ Status = gPopupEdit.HandleAction( popupedit, action );
+ if (IsTSECursorSupport() && !((EFI_ERROR (Status))))//EIP:67695
+ {
+ DrawCursor = TRUE; //EIP:67695 If any valid action performed then draw the cursor, useful for blinking
+ }
+ }
+ TSEStringReadLoopExitHook();
+
+ return res;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DoPopupStringEdit
+//
+// Description: Function to initiate PopupString editing
+//
+// Input: POPUP_STRING_DATA PopupString, UINT16 Title, CHAR16 **Text
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _DoPopupStringEdit( POPUP_STRING_DATA *PopupString, UINT16 Title, CHAR16 **Text)
+{
+ static UINT8 gIFRPopupEdit[50];
+ EFI_STATUS Status= EFI_SUCCESS;
+
+ UINT8 retValue = (UINT8)-1;
+
+ POPUPEDIT_DATA *popupedit = NULL;
+
+ CONTROL_INFO dummy;
+ BOOLEAN PreviousCursorState = gST->ConOut->Mode->CursorVisible;//EIP:67695
+
+ Status = gPopupEdit.Create( &popupedit );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = PopupString->ControlData.ControlHandle;
+ MemCopy( &gIFRPopupEdit, (VOID*)PopupString->ControlData.ControlPtr, UefiGetIfrLength(PopupString->ControlData.ControlPtr));
+
+ // gIFRPopupEdit.Prompt = Title;
+ UefiSetPromptField ((VOID*)&gIFRPopupEdit,Title);
+
+ dummy.ControlPtr = (VOID*)&gIFRPopupEdit;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ //gPopupEdit.SetTitle(popupedit,Title);
+ gPopupEdit.SetText(popupedit,*Text);
+ gPopupEdit.SetType( popupedit, POPUPEDIT_TYPE_STRING );
+ Status = gPopupEdit.Initialize( popupedit, &dummy );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ //gPopupEdit.SetType( popupedit, POPUPEDIT_TYPE_STRING );
+ retValue = (UINT8)_PopupStringEditGetValue( popupedit );
+ if (IsTSECursorSupport()) //EIP-91364
+ {
+ gST->ConOut->EnableCursor(gST->ConOut, PreviousCursorState);//EIP:67695
+ }
+ if(retValue ==0)
+ {
+ // string changed, save to nvram or do whatever needs to be done
+ MemFreePointer( (VOID **)Text );
+ *Text = EfiLibAllocateZeroPool( (gPopupEditCb.Length+1) * sizeof(CHAR16) );
+ if ( Text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ EfiStrCpy( *Text, gPopupEditCb.Data );
+ }
+Done:
+ gPopupEdit.Destroy( popupedit, TRUE );
+ return Status;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/PopupString.h b/EDK/MiniSetup/TseLite/PopupString.h
new file mode 100644
index 0000000..404ac6b
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/PopupString.h
@@ -0,0 +1,200 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupString.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 9 $
+//
+// $Date: 8/28/14 6:08a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/PopupString.h $
+//
+// 9 8/28/14 6:08a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 7 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/15/10 10:15p Madhans
+// To avoid warnings
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: popupstring.h
+//
+// Description: Header file for popupstring control
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _POPUP_STRING_H_
+#define _POPUP_STRING_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "action.h"
+#include "Label.h"
+#include "PopupEdit.h"
+
+#define POPUP_STRING_MEMBER_VARIABLES \
+ CHAR16 *TempText; \
+ UINT16 TextMargin; \
+ UINT16 MinSize; \
+ UINT16 MaxSize; \
+ UINT16 TextWidth; \
+ UINT16 TextAreaWidth; \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT8 LabelMargin; \
+ UINT8 Interval;
+
+typedef struct _POPUP_STRING_METHODS POPUP_STRING_METHODS;
+
+typedef struct _POPUP_STRING_DATA
+{
+ POPUP_STRING_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ LABEL_MEMBER_VARIABLES
+ POPUP_STRING_MEMBER_VARIABLES
+
+}
+POPUP_STRING_DATA;
+
+#define POPUP_STRING_METHOD_FUNCTIONS
+
+
+struct _POPUP_STRING_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ POPUP_STRING_METHOD_FUNCTIONS
+
+};
+
+extern POPUP_STRING_METHODS gPopupString;
+
+// Object Methods
+EFI_STATUS PopupStringCreate( VOID **object );
+EFI_STATUS PopupStringDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PopupStringInitialize( VOID *object, VOID *data );
+EFI_STATUS PopupStringDraw( VOID *object );
+EFI_STATUS PopupStringHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS PopupStringSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS PopupStringSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS PopupStringSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS PopupStringSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS PopupStringSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS PopupStringGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+
+EFI_STATUS _DoPopupStringEdit( POPUP_STRING_DATA *PopupString, UINT16 Title, CHAR16 **Text);
+
+#endif /* _POPUP_STRING_H_ */
+
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ResetButton.c b/EDK/MiniSetup/TseLite/ResetButton.c
new file mode 100644
index 0000000..4849c48
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ResetButton.c
@@ -0,0 +1,297 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ResetButton.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:03a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ResetButton.c $
+//
+// 5 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 11/21/11 11:06a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 3 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 2 5/18/11 11:58a Madhans
+// To Avoid Build issue when Multiline support is enabled.
+//
+// 1 3/28/11 4:02p Rajashakerg
+// Added to support reset opcode.
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ResetButton.c
+//
+// Description: This file contains code to handle the uefi actions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "Minisetup.h"
+
+RESET_BUTTON_METHODS gResetButton =
+{
+ ResetButtonCreate,
+ LabelDestroy,
+ ResetButtonInitialize,
+ ResetButtonDraw,
+ ResetButtonHandleAction,
+ LabelSetCallback,
+ LabelSetFocus,
+ LabelSetPosition,
+ LabelSetDimensions,
+ LabelSetAttributes,
+ LabelGetControlHeight
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetButtonCreate
+//
+// Description: Function to create an ResetButton Control.
+//
+// Input: VOID **object
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ResetButtonCreate( VOID **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(RESET_BUTTON_DATA) );
+
+ if ( *object == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ ((RESET_BUTTON_DATA*)(*object))->Methods = &gResetButton;
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetButtonInitialize
+//
+// Description: Function to Initialize an Action Control.
+//
+// Input: VOID *object, VOID *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ResetButtonInitialize( VOID *object, VOID *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ RESET_BUTTON_DATA *ResetButton = (RESET_BUTTON_DATA*) object;
+
+ Status = gControl.Initialize( ResetButton, data );
+ if (EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ // add extra initialization here...
+ ResetButton->ControlData.ControlHelp = ResetButton->ControlData.ControlHelp? ResetButton->ControlData.ControlHelp :
+ UefiGetHelpField(ResetButton->ControlData.ControlPtr);
+
+ SetControlColorsHook(NULL, NULL, NULL, NULL, &(ResetButton->SelBGColor), &(ResetButton->SelFGColor),
+ &(ResetButton->BGColor), &(ResetButton->FGColor), NULL, NULL, NULL, NULL, NULL, NULL, NULL );
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetButtonDraw
+//
+// Description: Function to draw ResetButton.
+//
+// Input: VOID *object
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ResetButtonDraw( VOID *object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ RESET_BUTTON_DATA *ResetButton = (RESET_BUTTON_DATA*) object;
+
+ CHAR16 *text;
+ UINT16 token = 0;
+ UINT8 ColorLabel = ResetButton->FGColor;
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( ResetButton->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &ResetButton->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ break;
+ }
+ //}
+
+ token = UefiGetPromptField(ResetButton->ControlData.ControlPtr);
+ text = HiiGetString( ResetButton->ControlData.ControlHandle, token);
+
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(ResetButton->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( ResetButton->Left , ResetButton->Top,
+ (UINTN)(ResetButton->Width),(UINTN) ResetButton->Height,
+ text,(UINT8)( (ResetButton->ControlFocus) ?
+ ResetButton->SelBGColor | ResetButton->SelFGColor :
+ ResetButton->BGColor | ColorLabel ));
+
+
+ }
+ else
+ {
+ // use frame width minus margins as available space
+ // boundary overflow check
+ if ( (TestPrintLength( text) / (NG_SIZE)) > (UINTN)(ResetButton->Width))
+ text[HiiFindStrPrintBoundary(text,(UINTN)(ResetButton->Width))] = L'\0';
+
+ DrawStringWithAttribute( ResetButton->Left , ResetButton->Top, text,
+ (UINT8)( (ResetButton->ControlFocus) ?
+ ResetButton->SelBGColor | ResetButton->SelFGColor :
+ ResetButton->BGColor | ColorLabel /*Action->FGColor*/ ));
+ }
+
+ MemFreePointer( (VOID **)&text );
+ FlushLines( ResetButton->Top , ResetButton->Top );
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetButtonHandleAction
+//
+// Description: Function to handle the ResetButton.
+//
+// Input: VOID *object, ACTION_DATA *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ResetButtonHandleAction(VOID *object, ACTION_DATA *data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ RESET_BUTTON_DATA *ResetButton = (RESET_BUTTON_DATA*) object;
+ CONTROL_ACTION CtrlAction;
+ UINT16 DefaultId = 0;
+
+ if (( data->Input.Type == ACTION_TYPE_KEY )|| (data->Input.Type == ACTION_TYPE_MOUSE))
+ {
+ if( data->Input.Type == ACTION_TYPE_KEY )
+ CtrlAction = MapControlKeysHook(data->Input.Data.AmiKey);
+ else
+ {
+ CtrlAction = MapControlMouseActionHook(&data->Input.Data.MouseInfo);
+ }
+ switch(CtrlAction)
+ {
+ case ControlActionSelect:
+ //call a wapper function to update the Default vaule
+ DefaultId = UefiGetResetButtonDefaultid( ResetButton->ControlData.ControlPtr );
+
+ if(0xFFFF == DefaultId)
+ return EFI_UNSUPPORTED;
+
+ Status = UefiupdateResetButtonDefault(ResetButton->ControlData,DefaultId);
+ break;
+
+ default:
+ break;
+ }
+ }
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ResetButton.h b/EDK/MiniSetup/TseLite/ResetButton.h
new file mode 100644
index 0000000..99e1cc4
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ResetButton.h
@@ -0,0 +1,106 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ResetButton.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:03a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ResetButton.h $
+//
+// 2 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 3/28/11 4:02p Rajashakerg
+// Added to support reset opcode.
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ResetButton.h
+//
+// Description: Header file for ResetButton data
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _RESET_BUTTON_H_
+#define _RESET_BUTTON_H_
+
+#include "minisetup.h"
+
+#include "control.h"
+#include "action.h"
+
+typedef struct _RESET_BUTTON_METHODS RESET_BUTTON_METHODS;
+
+#define RESET_BUTTON_MEMBER_VARIABLES \
+ LABEL_MEMBER_VARIABLES
+
+typedef struct _RESET_BUTTON_DATA
+{
+ RESET_BUTTON_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ RESET_BUTTON_MEMBER_VARIABLES
+}
+RESET_BUTTON_DATA;
+
+#define RESET_BUTTON_METHOD_FUNCTIONS
+
+struct _RESET_BUTTON_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ RESET_BUTTON_METHOD_FUNCTIONS
+};
+
+extern RESET_BUTTON_METHODS gResetButton;
+
+// Object Methods
+EFI_STATUS ResetButtonCreate( VOID **object );
+EFI_STATUS ResetButtonInitialize( VOID *object, VOID *data );
+EFI_STATUS ResetButtonDraw( VOID *object );
+EFI_STATUS ResetButtonHandleAction(VOID *object, ACTION_DATA *Data);
+
+#endif
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif
new file mode 100644
index 0000000..6c20309
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif
@@ -0,0 +1,49 @@
+<component>
+ name = "TSE Sources - StyleHook"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\TseLite\StyleHook\"
+ RefName = "StyleHook"
+[files]
+"StyleHook.sdl"
+"StyleHook.mak"
+"StyleHook.h"
+"styleHook1.c"
+"styleHook2.c"
+"styleHook3.c"
+"styleHook4.c"
+"styleHook5.c"
+"styleHook6.c"
+"styleHook7.c"
+"styleHook8.c"
+"styleHook9.c"
+"styleHook10.c"
+"styleHook11.c"
+"styleHook12.c"
+"styleHook13.c"
+"styleHook14.c"
+"styleHook15.c"
+"styleHook16.c"
+"styleHook17.c"
+"styleHook18.c"
+"styleHook19.c"
+"styleHook20.c"
+"styleHook21.c"
+"styleHook22.c"
+"styleHook23.c"
+"styleHook24.c"
+"styleHook25.c"
+"styleHook26.c"
+"styleHook27.c"
+"styleHook28.c"
+"styleHook29.c"
+"styleHook30.c"
+"styleHook31.c"
+"styleHook32.c"
+"styleHook33.c"
+"styleHook34.c"
+"styleHook35.c"
+"styleHook36.c"
+"styleHook37.c"
+"styleHook38.c"
+"styleHook39.c"
+<endComponent>
diff --git a/EDK/MiniSetup/TseLite/StyleHook/StyleHook.h b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.h
new file mode 100644
index 0000000..01f1024
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.h
@@ -0,0 +1,147 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/StyleHook.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 3 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/StyleHook.h $
+//
+// 3 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 11/09/11 10:07a Premkumara
+// [TAG] EIP74375
+// [Category] Improvement
+// [Description] Control STYLE_HELP_AREA_SCROLLBAR from binary
+// [Files] CommonHelper.c, AMITSE.sdl, StyleHook.h,
+// Legacy\StyleCommon.c, Legacy.sdl,
+// EzportPlus\StyleCommon.c, EzportPlus.sdl, Ezport\StyleCommon.c,
+// Ezport.sdl
+//
+// 1 1/06/11 7:34p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook.h
+//
+// Description: Style Hook List.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "page.h"
+#include "frame.h"
+
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType) ;
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color);
+VOID NewStyleHook1(VOID);
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+EFI_STATUS OverRideControlColor(FRAME_DATA *frame, STYLECOLORS *Colors);
+VOID StyleInit( VOID );
+VOID StyleExit( VOID );
+VOID StyleDrawPageBorder( UINT32 page );
+UINT32 StyleGetPageFrames( UINT32 page );
+UINT32 StyleFrameIndexOf( UINT32 frameType );
+VOID StyleBeforeFrame( FRAME_DATA *frame ) ;
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame );
+VOID StyleUpdateFrameStrings(PAGE_DATA *page);
+VOID * StyleGetFrameInitData( UINT32 page, UINT32 frame );
+
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo);
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action );
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key );
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count );
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+UINT16 StyleGetNavToken( UINT32 page );
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus );
+
+//EFI_STATUS StyleMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, CALLBACK_MENU *data );
+VOID StyleLabelCallback( FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie );
+
+EFI_STATUS _StyleAddControl( FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *number, BOOLEAN *focus );
+UINT16 StyleLanguagePage( SUBMENU_DATA *submenu );
+UINT16 StyleBootManagerPage( SUBMENU_DATA *submenu );
+BOOLEAN StyleHelpAreaScrollable(VOID);
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame );
+BOOLEAN StyleGetShadowSupport(VOID);
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height);
+BOOLEAN IsHelpAreaScrollBarSupport (void);
+
+
+VOID StyleSelectFirstDisplayPage( VOID );
+VOID StyleAddExtraPagesData( VOID );
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color);
+UINTN StyleGetDateFormat(VOID);
+BOOLEAN StyleShowDay(VOID);
+BOOLEAN StyleGetScrollBehavior(VOID) ;
+
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd);
+extern HOTKEY_TEMPLATE gHotKeyInfo[];
+extern UINT32 gHotKeyCount;
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy );
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak
new file mode 100644
index 0000000..cbc2a14
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak
@@ -0,0 +1,114 @@
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2010, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
+
+#*************************************************************************
+# $Header: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/StyleHook.mak 2 10/18/12 6:20a Arunsb $
+#
+# $Revision: 2 $
+#
+# $Date: 10/18/12 6:20a $
+#*************************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/StyleHook.mak $
+#
+# 2 10/18/12 6:20a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 3 10/10/12 12:40p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 1 1/06/11 7:24p Madhans
+# [TAG] - EIP 51678
+# [Category]- Enhancment
+# [Severity]- Mordarate
+# [Symptom]- If OEMs override the style module parts, If new tse adds
+# new style hook then
+# if the OEM has different style module, even if they don't need use the
+# hook to avoid
+# compilation issue they need touch their style module to add the new
+# hook.
+# [RootCause] - The Original Style Hooks are part of Style module itself.
+# [Solution]- To create Empty style Hook List in TSE core. This will
+# allows the OEM not
+# to change their style module to update newer TSE.
+# [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+# StyleHookx64.lib tselitebin.sdl
+#
+#
+#*************************************************************************
+#<AMI_FHDR_START>
+#
+# Name: StyleHook.mak
+#
+# Description:
+# Empty Style Hooks Module part makefile
+#
+#<AMI_FHDR_END>
+#*************************************************************************
+
+STYLEHOOK_INCLUDES = \
+ -I $(TSESRC_DIR) \
+!if "$(TSE_STYLE_SOURCES_SUPPORT)" == "1"
+ -I $(TSE_STYLE_DIR) \
+!endif
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(UEFISRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\StyleHook.lib : StyleHook
+
+StyleHook : $(BUILD_DIR)\StyleHook.mak StyleHookBin
+
+$(BUILD_DIR)\StyleHook.mak : $(TSESTYLEHOOK_DIR)\$(@B).cif $(TSESTYLEHOOK_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSESTYLEHOOK_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+StyleHookBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\StyleHook.mak all\
+ "MY_INCLUDES=$(STYLEHOOK_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\StyleHook.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+#*************************************************************************
+#*************************************************************************
+#** **
+#** (C)Copyright 1985-2010, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#*************************************************************************
+#*************************************************************************
diff --git a/EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl
new file mode 100644
index 0000000..cb3cf40
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl
@@ -0,0 +1,24 @@
+TOKEN
+ Name = StyleHook_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable StyleHook support in Project"
+End
+
+MODULE
+ Help = "Includes StyleHook.mak to Project"
+ File = "StyleHook.mak"
+End
+
+PATH
+ Name = "TSESTYLEHOOK_DIR"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\StyleHook.lib"
+ Parent = "$(TSELITESRC_DIR)\StyleHook\StyleHook$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook1.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook1.c
new file mode 100644
index 0000000..f076ff5
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook1.c
@@ -0,0 +1,99 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook1.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook1.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:34p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook1.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetPageFrames
+//
+// Description: Function to number of frames
+//
+// Input: UINT32 page
+//
+// Output: UINT32 number of frames
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleGetPageFrames( UINT32 page )
+{
+ return 1;
+}
+
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook10.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook10.c
new file mode 100644
index 0000000..2bc80d3
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook10.c
@@ -0,0 +1,97 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook10.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook10.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook10.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInit
+//
+// Description: Function to initialize style
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleInit( VOID )
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook11.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook11.c
new file mode 100644
index 0000000..61c01f7
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook11.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook11.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook11.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook11.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawPageBorder
+//
+// Description: Function to draw the page border
+//
+// Input: UINT32 page number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawPageBorder( UINT32 page )
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook12.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook12.c
new file mode 100644
index 0000000..f2b7b6c
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook12.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook12.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook12.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook12.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSelectFirstDisplayPage
+//
+// Description: Function to set the first display page
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSelectFirstDisplayPage( VOID )
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook13.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook13.c
new file mode 100644
index 0000000..2aff526
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook13.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook13.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook13.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook13.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddExtraPagesData
+//
+// Description: Function to add extra pages
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleAddExtraPagesData(VOID)
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook14.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook14.c
new file mode 100644
index 0000000..62ce22b
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook14.c
@@ -0,0 +1,99 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook14.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook14.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook14.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetWindowColor
+//
+// Description: Function to get window color
+//
+// Input: UINT8 *Color - Window Color
+// INTN Level - Window Level
+// UINT8 Type - Window Type (0->Setup, 1->PostMenu)
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType)
+{
+ return EFI_UNSUPPORTED ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook15.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook15.c
new file mode 100644
index 0000000..4d36a59
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook15.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook15.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook15.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook15.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleInitializeFrame
+//
+// Description: Function to Initialize frame
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleInitializeFrame( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ return EFI_UNSUPPORTED;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook16.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook16.c
new file mode 100644
index 0000000..6539cdb
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook16.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook16.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook16.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook16.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetMessageboxColor
+//
+// Description: Function to get control Messagebox color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetMessageboxColor( UINT8 MessageBoxType, UINT8 *Color)
+{
+ return EFI_UNSUPPORTED;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook17.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook17.c
new file mode 100644
index 0000000..116aed7
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook17.c
@@ -0,0 +1,99 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook17.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook17.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook17.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawScrollBar
+//
+// Description: Function to draw the frame scrollbar
+//
+// Input: FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawScrollBar(FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal,
+ UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook18.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook18.c
new file mode 100644
index 0000000..ebcca35
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook18.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook18.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook18.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook18.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameDrawable
+//
+// Description: Function to determine if frame is drawable
+//
+// Input: FRAME_DATA *frame
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameDrawable( FRAME_DATA *frame )
+{
+ return EFI_SUCCESS ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook19.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook19.c
new file mode 100644
index 0000000..ba9e219
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook19.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook19.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook19.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook19.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarColor
+//
+// Description: Function to get scrollbar color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarColor(VOID)
+{
+ return (EFI_BACKGROUND_BLUE|EFI_WHITE);
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook2.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook2.c
new file mode 100644
index 0000000..4645163
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook2.c
@@ -0,0 +1,102 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook2.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook2.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook2.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: StyleControlColor
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// STYLECOLORS Colors - Color scheme
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleControlColor(FRAME_DATA *frame, STYLECOLORS *Colors)
+{
+ return EFI_SUCCESS;
+}
+
+
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook20.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook20.c
new file mode 100644
index 0000000..2ccef5a
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook20.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook20.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook20.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook20.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarDownArrowColor
+//
+// Description: Function to get scrollbar downarrow color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarDownArrowColor(VOID)
+{
+ return (EFI_BACKGROUND_BLUE|EFI_WHITE);
+// return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook21.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook21.c
new file mode 100644
index 0000000..dc629d8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook21.c
@@ -0,0 +1,100 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook21.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook21.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook21.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleHandleControlOverflow
+//
+// Description: Function to handle control overflow
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleHandleControlOverflow( FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count )
+{
+
+ return EFI_OUT_OF_RESOURCES ;
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook22.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook22.c
new file mode 100644
index 0000000..f41e90b
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook22.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook22.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook22.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook22.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameSetControlPositions
+//
+// Description: Function to set control positioning in a frame
+//
+// Input: FRAME_DATA *frame, UINT32 *pOtherEnd
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleFrameSetControlPositions(FRAME_DATA *frame, UINT32 *pOtherEnd)
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook23.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook23.c
new file mode 100644
index 0000000..ad5c878
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook23.c
@@ -0,0 +1,95 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook23.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook23.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook23.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBehavior
+//
+// Description: Function to get scroll behavior
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetScrollBehavior(VOID)
+{
+ return 1 ;
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook24.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook24.c
new file mode 100644
index 0000000..fbf8be4
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook24.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook24.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook24.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook24.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleTimer
+//
+// Description: Function to handle frame timer action
+//
+// Input: FRAME_DATA *frame, ACTION_DATA *action
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleTimer( FRAME_DATA *frame, ACTION_DATA *action )
+{
+ return EFI_UNSUPPORTED ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook25.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook25.c
new file mode 100644
index 0000000..867a0a8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook25.c
@@ -0,0 +1,94 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook25.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook25.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook25.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleMouse
+//
+// Description: Function to handle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// MOUSE_INFO MouseInfo
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleMouse( FRAME_DATA *frame, MOUSE_INFO MouseInfo)
+{
+ return EFI_UNSUPPORTED ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook26.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook26.c
new file mode 100644
index 0000000..bf7dc8b
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook26.c
@@ -0,0 +1,94 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook26.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook26.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook26.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameHandleKey
+//
+// Description: Function to handle frame action keys
+//
+// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameHandleKey( FRAME_DATA *frame, EFI_INPUT_KEY Key )
+{
+ return EFI_UNSUPPORTED ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook27.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook27.c
new file mode 100644
index 0000000..6067aa0
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook27.c
@@ -0,0 +1,95 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook27.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook27.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook27.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetFrameInitData
+//
+// Description: Function to get frame initialization data
+//
+// Input: UINT32 page number, UINT32 frame number
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *StyleGetFrameInitData( UINT32 page, UINT32 frame )
+{
+ return NULL;
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook28.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook28.c
new file mode 100644
index 0000000..d7ac5ed
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook28.c
@@ -0,0 +1,94 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook28.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook28.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook28.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetNavToken
+//
+// Description: Function to get navigation token
+//
+// Input: UINT32 page
+//
+// Output: UINT16 token number
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 StyleGetNavToken( UINT32 page )
+{
+
+ return 0 ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook29.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook29.c
new file mode 100644
index 0000000..8e60ae3
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook29.c
@@ -0,0 +1,94 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook29.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook29.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook29.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateFrameStrings
+//
+// Description: Function to update frame strings
+//
+// Input: PAGE_DATA *page
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateFrameStrings( PAGE_DATA *page )
+{
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook3.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook3.c
new file mode 100644
index 0000000..195cbb2
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook3.c
@@ -0,0 +1,101 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook3.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook3.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook3.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetClearScreenColor
+//
+// Description: Function to Get Clear Screen Color
+//
+// Input: VOID
+//
+// Output: STYLE_CLEAR_SCREEN_COLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetClearScreenColor(VOID)
+{
+ return (EFI_BACKGROUND_BLUE|EFI_WHITE);
+}
+
+
+
+
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook30.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook30.c
new file mode 100644
index 0000000..30410a3
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook30.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook30.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook30.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook30.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleAddAdditionalControls
+//
+// Description: Function to add additinal controls
+//
+// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleAddAdditionalControls( FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus )
+{
+ return EFI_SUCCESS ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook31.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook31.c
new file mode 100644
index 0000000..4fe0f84
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook31.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook31.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook31.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook31.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleSubPageItemFocus
+//
+// Description: This function is called whenever a user returns (or navigates back)
+// from a submenu page causing a complete page redraw. OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleSubPageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook32.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook32.c
new file mode 100644
index 0000000..7ba48e1
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook32.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook32.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook32.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook32.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StylePageItemFocus
+//
+// Description: This function is called whenever a user navigates to a new page.
+// OEMs may use this hook to set item focus.
+// The default behavior sets focus to the previously focused page item.
+//
+// Input: PAGE_DATA *page, FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StylePageItemFocus(PAGE_DATA *page, FRAME_DATA *frame )
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook33.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook33.c
new file mode 100644
index 0000000..cea7ffa
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook33.c
@@ -0,0 +1,97 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook33.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook33.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook33.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleBeforeFrame
+//
+// Description: Function to alter frame styling before frame is drawn
+//
+// Input: FRAME_DATA *frame
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleBeforeFrame( FRAME_DATA *frame )
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook34.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook34.c
new file mode 100644
index 0000000..aa8960a
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook34.c
@@ -0,0 +1,97 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook34.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook34.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook34.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetSpecialColor
+//
+// Description: Function to get control special color
+//
+// Input: UINT16 ControlType, UINT8 *Color
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleGetSpecialColor( UINT16 ControlType, UINT8 *Color)
+{
+ return EFI_UNSUPPORTED ;
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook35.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook35.c
new file mode 100644
index 0000000..40d05dd
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook35.c
@@ -0,0 +1,93 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook35.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook35.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook35.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleDrawHelpScrollBar
+//
+// Description: Function to draw the help frame scrollbar
+//
+// Input: MEMO_DATA *memo, UINT16 height
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleDrawHelpScrollBar( MEMO_DATA *memo, UINT16 height)
+{
+
+}
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook36.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook36.c
new file mode 100644
index 0000000..a3e50fc
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook36.c
@@ -0,0 +1,97 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook36.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook36.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook36.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetShadowSupport
+//
+// Description: Function to get shadow support
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN StyleGetShadowSupport(VOID)
+{
+ return FALSE;
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook37.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook37.c
new file mode 100644
index 0000000..0039684
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook37.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook37.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook37.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook37.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameIndexOf
+//
+// Description: Function to get frame index
+//
+// Input: UINT32 frameType
+//
+// Output: UINT32 index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 StyleFrameIndexOf( UINT32 frameType )
+{
+ return 0 ;
+}
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook38.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook38.c
new file mode 100644
index 0000000..8a4e0db
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook38.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook38.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook38.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook38.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleFrameAddTitle
+//
+// Description: Function to add frame title
+//
+// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook39.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook39.c
new file mode 100644
index 0000000..71ed804
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook39.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook39.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:21a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook39.c $
+//
+// 2 10/18/12 6:21a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:36p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook39.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetScrollBarUpArrowColor
+//
+// Description: Function to get scrollbar UpArrow Color
+//
+// Input: VOID
+//
+// Output: FGCOLOR|BGCOLOR
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 StyleGetScrollBarUpArrowColor(VOID)
+{
+ return (EFI_BACKGROUND_BLUE|EFI_WHITE);
+ //return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ;
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook4.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook4.c
new file mode 100644
index 0000000..3fddbc2
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook4.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook4.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook4.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook4.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleOverRideComponent
+//
+// Description: Function to override component or control functionality
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleOverRideComponent(VOID)
+{
+
+}
+
+
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook5.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook5.c
new file mode 100644
index 0000000..8193683
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook5.c
@@ -0,0 +1,99 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook5.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook5.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook5.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleUpdateVersionString
+//
+// Description: Function to set the version string
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleUpdateVersionString( VOID )
+{
+
+}
+
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook6.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook6.c
new file mode 100644
index 0000000..1ea79a5
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook6.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook6.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook6.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook6.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxCols
+//
+// Description: Function to get max number of rows
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_COLS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxCols(VOID)
+{
+ return 80;
+}
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook7.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook7.c
new file mode 100644
index 0000000..e8b2234
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook7.c
@@ -0,0 +1,98 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook7.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook7.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook7.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetStdMaxRows
+//
+// Description: Function to max number of columns
+//
+// Input: VOID
+//
+// Output: STYLE_STD_MAX_ROWS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetStdMaxRows(VOID)
+{
+ return 24;
+}
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook8.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook8.c
new file mode 100644
index 0000000..5a0071b
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook8.c
@@ -0,0 +1,97 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook8.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook8.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook9.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleGetTextMode
+//
+// Description: Function to get text mode
+//
+// Input: UINTN Rows, UINTN Cols
+//
+// Output: UNNTN mode
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN StyleGetTextMode( UINTN Rows, UINTN Cols )
+{
+ return 0;
+}
+
+
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/StyleHook/styleHook9.c b/EDK/MiniSetup/TseLite/StyleHook/styleHook9.c
new file mode 100644
index 0000000..0143163
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/StyleHook/styleHook9.c
@@ -0,0 +1,96 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook9.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:20a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/StyleHook/styleHook9.c $
+//
+// 2 10/18/12 6:20a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 3 10/10/12 12:40p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 1/06/11 7:35p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: StyleHook9.c
+//
+// Description: Contains generic or default style functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+#include "minisetup.h"
+
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: StyleExit
+//
+// Description: Function to do style initialization on exit
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StyleExit( VOID )
+{
+}
+
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy , Norcross, GA 30071 **//
+//** **//
+//** Phone: (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
diff --git a/EDK/MiniSetup/TseLite/SubMenu.c b/EDK/MiniSetup/TseLite/SubMenu.c
new file mode 100644
index 0000000..d843ea0
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/SubMenu.c
@@ -0,0 +1,876 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/SubMenu.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 34 $
+//
+// $Date: 8/28/14 2:50p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/SubMenu.c $
+//
+// 34 8/28/14 2:50p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 33 8/28/14 11:52a Premkumara
+// [TAG] EIP174031
+// [Category] Improvement
+// [Description] Removed TODO comments and added proper comments in those
+// places
+// [Files] commonoem.c, commonhelper.c, special.c, submenu.c,
+// minisetupext.c, uefi21wapper.c and legacy.c
+//
+// 32 5/02/14 9:31p Arunsb
+// EIP141986 changes reverted.
+//
+// 31 5/02/14 10:50a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 30 5/01/14 3:46p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 29 2/11/14 8:33p Arunsb
+// [TAG] EIP146858
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] When both MINISETUP_MOUSE_SUPPORT and TSE_MULTILINE_CONTROLS
+// are enabled, only the first line of wrapped controls are clickable
+// [Root Cause] The function SubMenuHandleAction doesn't consider the
+// control’s height when checking mouse select actions.
+// [Solution] The function SubMenuHandleAction includes the controls
+// height when checking mouse select actions
+// [Files] SubMenu.c
+//
+// 28 12/03/13 1:14p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 27 3/12/13 12:28p Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 26 3/08/13 1:35a Rajashakerg
+// [TAG] EIP113085
+// [Category] Improvement
+// [Description] Modify callback function behavior to match UEFI SPEC.
+// [Files] HiiCallback.c, PopupPassword.c, SubMenu.c
+//
+// 25 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 23 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 21 9/06/12 2:18a Rajashakerg
+// [TAG] EIP97333
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Update TSE to V1227, there is a redundant blank line.
+// [RootCause] Co-ordinates calculation was not proper for submenu
+// control
+// [Solution] Provided proper co-ordinates for sub menu control.
+// [Files] SubMenu.c
+//
+// 20 4/19/12 6:09p Blaines
+// [TAG] - EIP 88031
+// [Category]- Defect
+// [Synopsis]- Hii Callbacks may enter infinite loop on
+// BROWSER_ACTION_RETRIEVE
+// [Solution] - Only allow EFI_BROWSER_ACTION_RETRIEVE action for all
+// Interactive controls from MiniSetupEntry.
+// [Files] - Submenu.c, HiiCallback.c,
+//
+// 19 2/01/12 8:05p Blaines
+// [TAG] - EIP 81631
+// [Category]- Sighting
+// [Synopsis]- In some SAS cards, HII Adapter Settings screen is not
+// wrapping the text correctly
+// [Solution] - Use the proper control width calculation to determine
+// control height in PopupSelGetControlHeight.
+// The string length calculation used to determine control height in
+// SubMenuGetControlHeight needs to be consistent with the same in
+// SubMenuDraw.
+//
+// [Files]
+// Submenu.c, PopupSel.c,
+//
+// 18 12/07/11 6:52p Blaines
+// [TAG] - EIP 77046
+// [Category]- Sighting
+// [Synopsis]- In some SAS cards, UEFI Driver submenu entry text are
+// truncated, and do not properly wrap to the next line.
+// [Solution] - In the function SubMenuDraw, truncate string when the
+// length exceeds submenu->Width
+// (when submenu->SubMenuType == 2, and submenu->Height == 1 ).
+//
+// [Files]
+// SubMenu.c
+//
+// [Functions Changed]
+// - SubMenuDraw
+//
+//
+// 17 12/01/11 7:40a Rajashakerg
+// [TAG] EIP75464
+// [Category] Improvement
+// [Description] Improper handling of action controls
+// [Files] SubMenu.c, UefiAction.c, HiiCallback.c, Uefi21Wapper.c
+//
+// 16 11/28/11 4:58a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 15 11/21/11 11:04a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 14 11/21/11 8:58a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 13 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 12 11/08/11 5:10a Rajashakerg
+// Moved the CallFormCallBack() function with retrive action to
+// SubMenuInitialize() function as per the specification.
+//
+// 11 8/26/11 2:10p Blaines
+// [TAG] EIP 67487
+// [Category] Defect
+// [Symptom] TSE_MULTILINE_CONTROLS does not work for all control types
+// [RootCause] The controls (PopupSel, PopupString) ONLY check for
+// string wrapping in the label value (control prompt) when calling the
+// methods GetControlHeight and Draw.
+// [Solution] The controls (PopupSel, PopupString) should check for
+// string wrapping in the label (control prompt) and the control's value
+// when calling the methods GetControlHeight and Draw. For Dynamic pages,
+// adjust the width calculation for Submenu in the function
+// GetControlHeight.
+// [Files] PopupSel.c, PopupString.c, Submenu.c
+//
+// 10 3/21/11 12:44a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 9 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 8 12/02/10 6:08p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 7 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 2/15/10 10:15p Madhans
+// To avoid warnings
+//
+// 5 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 4 11/04/09 11:54a Blaines
+// EIP-28247
+//
+// Fix for grayout color menu string not being grayed out.
+//
+//
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Submenu.c
+//
+// Description: This file contains code to handle submenu operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+SUBMENU_METHODS gSubMenu =
+{
+ SubMenuCreate,
+ SubMenuDestroy,
+ SubMenuInitialize,
+ SubMenuDraw,
+ SubMenuHandleAction,
+ SubMenuSetCallback,
+ SubMenuSetFocus,
+ SubMenuSetPosition,
+ SubMenuSetDimensions,
+ SubMenuSetAttributes,
+ SubMenuGetControlHeight
+
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuCreate
+//
+// Description: this function uses the create function of control
+// and create submenu.
+//
+// Input: SUBMENU_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuCreate( SUBMENU_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(SUBMENU_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gSubMenu;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys submenu.
+//
+// Input: SUBMENU_DATA *submenu, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuDestroy( SUBMENU_DATA *submenu, BOOLEAN freeMem )
+{
+ if(NULL == submenu)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( submenu, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&submenu );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuDestroy
+//
+// Description: this function uses the initialize function of control
+// and initializes the submenu.
+//
+// Input: SUBMENU_DATA *submenu, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuInitialize( SUBMENU_DATA *submenu, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( submenu, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ if(UefiIsInteractive(&submenu->ControlData))
+ {
+ // EIP88031 : Invoking CallFormCallBackon with AMI_CALLBACK_RETRIEVE
+ // caused infinite loop on FormCallBack when UIUpdateCallback is called during pack update.
+ /*
+ UINT16 Key = UefiGetControlKey(&(submenu->ControlData));
+ UefiPreControlUpdate(NULL);//EIP45464 : Updating the gPrevControlValue buffer to NULLL before invoking CallFormCallBack
+ CallFormCallBack(&(submenu->ControlData),Key,0,AMI_CALLBACK_RETRIEVE);//EIP-53480: Updated the action to AMI_CALLBACK_RETRIEVE
+ */
+ }
+
+ // add extra initialization here...
+ submenu->ControlData.ControlHelp = UefiGetHelpField((VOID *)submenu->ControlData.ControlPtr); //refPtr->Help;
+ submenu->ControlFocus = FALSE;
+ submenu->Interval = (UINT8)submenu->ControlData.ControlFlags.ControlRefresh;
+ submenu->LabelMargin = (UINT8)gControlLeftMargin;
+
+ // initialize default colors
+ SetControlColorsHook(&(submenu->BGColor), &(submenu->FGColor),
+ NULL, NULL,
+ &(submenu->SelBGColor), &(submenu->SelFGColor),
+ &(submenu->NSelBGColor), &(submenu->NSelFGColor),
+ NULL,&(submenu->LabelFGColor) ,
+ &(submenu->NSelLabelFGColor),
+ NULL,NULL,
+ NULL,NULL );
+
+
+
+#if SETUP_STYLE_AWARD
+ submenu->SubMenuType = (UINT8)(submenu->ControlData.ControlPageID != 0);
+#endif
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuDraw
+//
+// Description: function to draw a sub-menu.
+//
+// Input: SUBMENU_DATA *submenu
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuDraw( SUBMENU_DATA *submenu )
+{
+ CHAR16 *text=NULL,*text1;
+ UINTN length;
+ EFI_STATUS Status = EFI_SUCCESS;
+// UINT8 ColorSubMenu = submenu->NSelFGColor;
+ UINT8 ColorLabel = (submenu->ControlFocus) ? submenu->LabelFGColor : submenu->NSelLabelFGColor ;
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( submenu->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &submenu->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ if (!submenu->ControlFocus)//setting grayoutif color for grayoutif control based on token TSE_SETUP_GRAYOUT_SELECTABLE
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ text1 = HiiGetString( submenu->ControlData.ControlHandle, UefiGetPromptField((VOID *)(submenu->ControlData.ControlPtr)));
+ if ( text1 == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ // XXX check to see if text1 is not NULL
+ length = (3 + (TestPrintLength( text1 ) / (NG_SIZE))) * sizeof(CHAR16);
+ text = EfiLibAllocateZeroPool( length );
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ SPrint( text, length, L"%c %s", (submenu->SubMenuType == 2)?L' ':GEOMETRICSHAPE_RIGHT_TRIANGLE, text1 );
+ MemFreePointer( (VOID **)&text1 );
+
+ if ( submenu->SubMenuType != 1 )
+ {
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(submenu->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( submenu->Left , submenu->Top,
+ (UINTN)(submenu->Width),(UINTN) submenu->Height,
+ &text[2], (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | ColorLabel /*submenu->SelFGColor*/ :
+ submenu->NSelBGColor | ColorLabel /*ColorSubMenu*/ ) );
+
+ if(submenu->SubMenuType != 2)
+ {
+ text[2]=0;
+ DrawStringWithAttribute( submenu->Left - 2, submenu->Top, (CHAR16*)text,
+ (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | ColorLabel /*submenu->SelFGColor*/ :
+ submenu->NSelBGColor | ColorLabel /*ColorSubMenu*/ ) );
+ }
+ }
+ else
+ {
+
+ if(submenu->SubMenuType==0 && !submenu->ControlFocus && ColorLabel != CONTROL_GRAYOUT_COLOR)
+ ColorLabel = StyleGetPageLinkColor();
+
+
+ if(((TestPrintLength( text ) / (NG_SIZE))-2) > (UINTN)(submenu->Width))//EIP 97333 : Check for width corrected since the text already include spaces in it.
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-2))],L"...");
+
+ DrawStringWithAttribute( submenu->Left - 2, submenu->Top, (CHAR16*)text,
+ (UINT8)( (submenu->ControlFocus) ?
+ submenu->SelBGColor | ColorLabel :
+ submenu->NSelBGColor | ColorLabel ) );
+ }
+ }
+ else
+ {
+ if((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(submenu->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-5))],L"...");
+
+ text1 = HiiGetString( gHiiHandle, STRING_TOKEN(STR_SUBMENU_OPTION) );
+ if ( text1 != NULL )
+ {
+ DrawStringWithAttribute( submenu->Left - 2, submenu->Top, (CHAR16*)text,
+ EFI_BACKGROUND_BLUE | EFI_WHITE );
+ MemFreePointer( (VOID **)&text );
+
+ length = (3 + (TestPrintLength( text1 ) / (NG_SIZE))) * sizeof(CHAR16);
+ text = EfiLibAllocatePool( length );
+ if ( text != NULL )
+ {
+ SPrint( text, length, L"[%s]", text1 );
+
+ if ((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(submenu->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(submenu->Width-5))],L"...");
+
+ DrawStringWithAttribute( submenu->Left + submenu->LabelMargin , submenu->Top, text,
+ (UINT8)(submenu->NSelBGColor | ColorLabel /*ColorSubMenu*/) );
+
+ if ( submenu->ControlFocus )
+ DrawStringWithAttribute( submenu->Left + submenu->LabelMargin + 1,
+ submenu->Top, text1, (UINT8)(submenu->SelBGColor | submenu->SelFGColor) );
+ }
+ }
+ }
+
+ MemFreePointer( (VOID **)&text );
+ MemFreePointer( (VOID **)&text1 );
+
+ FlushLines( submenu->Top, submenu->Top );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuHandleAction
+//
+// Description: function to handle the submenu actions
+//
+// Input: SUBMENU_DATA *submenu, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuHandleAction( SUBMENU_DATA *submenu, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ BOOLEAN Selected = FALSE;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if (submenu->Interval == 0)
+ return Status;
+
+ if ( --(submenu->Interval) == 0 )
+ {
+ // initialize the interval
+ submenu->Interval = (UINT8)(submenu->ControlData.ControlFlags.ControlRefresh);
+ return EFI_SUCCESS;
+ }
+ else
+ return Status;
+ }
+
+ if ( ! submenu->ControlFocus )
+ return Status;
+
+ if (Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ //Status = MouseSubMenuHandleAction( submenu, Data);
+ //if ( Data->Input.Data.MouseInfo.ButtonStatus==TSEMOUSE_LEFT_DCLICK )
+
+ if(ControlActionSelect == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ //check whether MouseTop is within the Height and Width of submenu or not
+ if( (Data->Input.Data.MouseInfo.Top >= (UINT32)submenu->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(submenu->Top+submenu->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)submenu->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(submenu->Left+submenu->Width))
+ )//EIP-123727
+ {
+ Selected = TRUE;
+ }
+ }
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ {
+ if ( ControlActionSelect == MapControlKeysHook(Data->Input.Data.AmiKey) )
+ Selected = TRUE;
+ }
+ if(Selected)
+ {
+ UINT8 u8ChkResult;
+
+ u8ChkResult = CheckControlCondition( &submenu->ControlData );
+
+ //Not to perform action for grayoutif-control when token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT) ) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MouseStop();
+
+ if ( submenu->Callback )
+ {
+ if ( submenu->Cookie != NULL )
+ {
+ CALLBACK_SUBMENU *callbackData = (CALLBACK_SUBMENU *)submenu->Cookie;
+ callbackData->DestPage = submenu->ControlData.ControlDestPageID;
+ }
+ UefiPreControlUpdate(NULL);
+ submenu->Callback( submenu->Container, submenu, submenu->Cookie );
+ }
+
+ if(UefiIsInteractive(&submenu->ControlData))
+ {
+ VOID * Handle=submenu->ControlData.ControlHandle;
+ UINT16 Key = UefiGetControlKey(&(submenu->ControlData));
+ CONTROL_DATA *Control;
+
+ Status = CallFormCallBack(&(submenu->ControlData),Key,0,AMI_CALLBACK_CONTROL_UPDATE);//EIP-53480: Updated the action to AMI_CALLBACK_CONTROL_UPDATE
+ // To support UEFI 2.1.C spec to Not to change page when Callback fails.
+ Status = UefiIsProceedWithPageChange(Status);
+ if(Status != EFI_SUCCESS)
+ {
+ if ( submenu->Callback )
+ {
+ if ( submenu->Cookie != NULL )
+ {
+ CALLBACK_SUBMENU *callbackData = (CALLBACK_SUBMENU *)submenu->Cookie;
+ callbackData->DestPage = submenu->ControlData.ControlPageID;
+ }
+ submenu->Callback( submenu->Container, submenu, submenu->Cookie );
+ }
+ // On Error Status Don't Change the Destination page. Skip the user action.
+ return EFI_SUCCESS;
+
+ }
+
+ Control = GetUpdatedControlData((CONTROL_DATA*)submenu,CONTROL_TYPE_SUBMENU,Handle,Key);
+
+ if(Control == NULL) // Control deleted ?
+ return EFI_SUCCESS;
+ if(Control != (CONTROL_DATA*)submenu)
+ submenu = (SUBMENU_DATA*)Control; //control Updated
+ }
+
+ _SubMenuHandleSpecialOp( submenu );
+
+ MouseStart();
+
+
+
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuSetCallback
+//
+// Description: function to handle the submenu actions
+//
+// Input: SUBMENU_DATA *submenu, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuSetCallback( SUBMENU_DATA *submenu, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( submenu, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuSetFocus
+//
+// Description: Function to handle the submenu actions
+//
+// Input: SUBMENU_DATA *submenu, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuSetFocus(SUBMENU_DATA *submenu, BOOLEAN focus)
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &submenu->ControlData );
+
+ //Setting focus to control which has no control-condtion and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to set focus and selectable
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT))
+ ){
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ if( !(submenu->ControlFocus && focus) )
+ submenu->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuSetPosition
+//
+// Description: Function to set position.
+//
+// Input: SUBMENU_DATA *submenu, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuSetPosition(SUBMENU_DATA *submenu, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( submenu, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuSetDimensions
+//
+// Description: Function to set dimension.
+//
+// Input: SUBMENU_DATA *submenu, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuSetDimensions(SUBMENU_DATA *submenu, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( submenu, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: SUBMENU_DATA *submenu, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuSetAttributes(SUBMENU_DATA *submenu, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( submenu, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SubMenuGetControlHeight
+//
+// Description: Function to get the label height of the submenu
+//
+// Input: SUBMENU_DATA *submenu, Frame Data, UINT16 *height
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SubMenuGetControlHeight(SUBMENU_DATA *submenu, VOID *frame, UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+ UINTN length=0;
+
+ Width = ((FRAME_DATA *)frame)->FrameData.Width - (UINT8)gLabelLeftMargin - 2 ;
+ text = HiiGetString( submenu->ControlData.ControlHandle, UefiGetPromptField((VOID *)submenu->ControlData.ControlPtr) );
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ length = (3 + (TestPrintLength( text ) / (NG_SIZE))) * sizeof(CHAR16);
+ newText = EfiLibAllocateZeroPool( length );
+
+ if ( newText == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ SPrint( newText, length, L"%c %s", (submenu->SubMenuType == 2)?L' ':GEOMETRICSHAPE_RIGHT_TRIANGLE, text );
+ MemFreePointer( (VOID **)&text);
+
+ text = StringWrapText( newText, Width+2, height );//EIP 97333 : Above we have appeneded the two spaces at begning of sub menu string, so providing proper widht for submenu
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/SubMenu.h b/EDK/MiniSetup/TseLite/SubMenu.h
new file mode 100644
index 0000000..491e0da
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/SubMenu.h
@@ -0,0 +1,197 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/SubMenu.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/SubMenu.h $
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: submenu.h
+//
+// Description: Header file for submenu related functionalities
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _SUBMENU_H_
+#define _SUBMENU_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+#define SUBMENU_MEMBER_VARIABLES \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT8 LabelMargin; \
+ UINT8 SubMenuType; \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT8 NSelFGColor; \
+ UINT8 NSelBGColor; \
+ UINT8 Interval;
+
+typedef struct _SUBMENU_METHODS SUBMENU_METHODS;
+
+typedef struct _SUBMENU_DATA
+{
+ SUBMENU_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ SUBMENU_MEMBER_VARIABLES
+
+}
+SUBMENU_DATA;
+
+#define SUBMENU_METHOD_FUNCTIONS
+
+struct _SUBMENU_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ SUBMENU_METHOD_FUNCTIONS
+};
+
+extern SUBMENU_METHODS gSubMenu;
+
+// Object Methods
+EFI_STATUS SubMenuCreate( VOID **object );
+EFI_STATUS SubMenuDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS SubMenuInitialize( VOID *object, VOID *data );
+EFI_STATUS SubMenuDraw( VOID *object );
+EFI_STATUS SubMenuHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS SubMenuSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS SubMenuSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS SubMenuSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS SubMenuSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS SubMenuSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS SubMenuGetControlHeight(SUBMENU_DATA *submenu, VOID *frame, UINT16 *height);
+
+UINT16 _SubMenuGetSpecialValue( SUBMENU_DATA *submenu );
+BOOLEAN _SubMenuHandleSpecialOp( SUBMENU_DATA *submenu );
+BOOLEAN _SubMenuAmiCallback( UINT16 value );
+
+// find a better place for these
+#define SAVE_AND_EXIT_VALUE 1
+#define DISCARD_AND_EXIT_VALUE 2
+#define SAVE_VALUE 3
+#define DISCARD_VALUE 4
+#define RESTORE_DEFAULTS_VALUE 5
+#define SAVE_USER_DEFAULTS_VALUE 6
+#define RESTORE_USER_DEFAULTS_VALUE 7
+
+
+#endif /* _SUBMENU_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Text.c b/EDK/MiniSetup/TseLite/Text.c
new file mode 100644
index 0000000..a597287
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Text.c
@@ -0,0 +1,587 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Text.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 15 $
+//
+// $Date: 2/11/14 8:34p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Text.c $
+//
+// 15 2/11/14 8:34p Arunsb
+// [TAG] EIP147142
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] text gets truncated
+// [Root Cause] The controls SetText function is called from the function
+// TextDraw to update the properties [text->Label and text->text] using
+// HiiGetString. However, FrameDraw will call each
+// controls->getControlHeight before calling each controls->draw function.
+// It is during this time when text->getControlHeight attempts to use the
+// properties [text->Label and text->text] to compute the height [for
+// multiline] which will be incorrect
+// [Solution] Call the controls SetText function from within the function
+// getControlHeight
+// to ensure the text controls properties [text->Label and text->text]
+// always has valid updated Hii text.
+// [Files] Text.c
+//
+// 14 6/10/13 10:02a Arunsb
+// String retrieval success check in TextInitialize is commented.
+//
+// 13 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 12 2/01/12 5:54p Blaines
+// Rollback to Revision 10
+//
+// 10 11/21/11 10:59a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 9 11/21/11 8:59a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 8 11/15/11 2:28a Rajashakerg
+// [TAG] EIP73391
+// [Category] Improvement
+// [Description] Information displayed in SETUP gets truncated.
+// [Files] Text.c
+//
+// 7 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 6 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 7 8/18/10 7:17p Madhans
+// [TAG] EIP42199
+// [Category] BUG FIX
+// [Symptom] Text Control does not disply the full string even with
+// multiline TSE support.
+// [RootCause] Bug in TextGetControlHeight()
+// [Solution] Take the Frame width in account instead if Text->Width.
+// [Files] text.c
+//
+// 6 3/26/10 6:53p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/13/09 1:21p Blaines
+// EIP #24980 Fix to properly display right area text
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: text.c
+//
+// Description: This file contains code to handle text operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+TEXT_METHODS gText =
+{
+ TextCreate,
+ TextDestroy,
+ TextInitialize,
+ TextDraw,
+ TextHandleAction,
+ TextSetCallback,
+ TextSetFocus,
+ TextSetPosition,
+ TextSetDimensions,
+ TextSetAttributes,
+ TextGetControlHeight,
+ TextSetText
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextCreate
+//
+// Description: this function uses the create function of control
+// and creates text
+//
+// Input: TEXT_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextCreate( TEXT_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(TEXT_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gText;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the text
+//
+// Input: TEXT_DATA *text, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextDestroy( TEXT_DATA *text, BOOLEAN freeMem )
+{
+ if(NULL == text)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( text, FALSE );
+
+ MemFreePointer( (VOID **)&text->LabelText );
+ MemFreePointer( (VOID **)&text->Text );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&text );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextDestroy
+//
+// Description: this function uses the initialize function of control
+// and initializes the text
+//
+// Input: TEXT_DATA *text, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextInitialize( TEXT_DATA *text, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( text, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ SetControlColorsHook(&(text->BGColor), &(text->FGColor),
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ NULL, NULL,
+ NULL,
+ NULL, NULL,
+ NULL,NULL);
+
+ // add extra initialization here...
+ text->ControlData.ControlHelp = UefiGetHelpField ((VOID*)text->ControlData.ControlPtr);
+ //text->FGColor= EFI_DARKGRAY;
+ StyleGetSpecialColor( CONTROL_TYPE_TEXT, &(text->FGColor)) ;
+
+ text->LabelMargin = (UINT8)gControlLeftMargin;
+
+
+ text->Interval = (UINT8)text->ControlData.ControlFlags.ControlRefresh;
+ text->LabelText = HiiGetString( text->ControlData.ControlHandle, UefiGetTextField((VOID*)text->ControlData.ControlPtr));
+// if ( text->LabelText == NULL ) //EIP122907 In some case in init hiigetstring is failing but in draw its passing so commented this check.
+// return EFI_OUT_OF_RESOURCES;
+
+ text->Text = HiiGetString( text->ControlData.ControlHandle, UefiGetTextTwoField((VOID *)text->ControlData.ControlPtr));
+// if ( text->Text == NULL )
+// return EFI_OUT_OF_RESOURCES;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextDraw
+//
+// Description: function to draw the text with attributes.
+//
+// Input: TEXT_DATA *text
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextDraw( TEXT_DATA *text )
+{
+ CHAR16 *txt =NULL, *txt2 = NULL;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorText = text->FGColor ;
+
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( text->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &text->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorText = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ txt = HiiGetString( text->ControlData.ControlHandle, UefiGetTextField((VOID*)text->ControlData.ControlPtr));
+ if ( txt == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ txt2 = HiiGetString( text->ControlData.ControlHandle, UefiGetTextTwoField((VOID*)text->ControlData.ControlPtr));
+ if ( txt2 == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ gText.SetText(text,txt,txt2);
+ MemFreePointer ((VOID **)&txt);
+ MemFreePointer ((VOID **)&txt2);
+
+ if ( text->LabelText == NULL )
+ {
+ Status = EFI_UNSUPPORTED;
+ return Status;
+ }
+
+ // labeltext boundary overflow check
+ if(text->Height>1 && IsTSEMultilineControlSupported())//EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ {
+ DrawMultiLineStringWithAttribute( (UINTN)text->Left, (UINTN) text->Top,
+ (UINTN)(text->LabelMargin - text->Left),(UINTN)text->Height,
+ text->LabelText, text->BGColor |ColorText );
+ }
+ else
+ {
+ if ( (TestPrintLength( text->LabelText ) / (NG_SIZE)) > (UINTN)(text->LabelMargin - text->Left )/*21*/ )
+ text->LabelText[HiiFindStrPrintBoundary(text->LabelText ,(UINTN)(text->LabelMargin - text->Left ))] = L'\0';
+
+ DrawStringWithAttribute( text->Left , text->Top, text->LabelText, text->BGColor | ColorText /*text->FGColor*/ );
+ }
+
+ if ( text->Text != NULL )
+ {
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(text->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( (UINTN)text->Left + text->LabelMargin, (UINTN) text->Top,
+ (UINTN)((text->Width + text->Left) - text->LabelMargin -2),(UINTN)text->Height,
+ text->Text, text->BGColor |ColorText );//EIP 73391 : Adjusted the cordinates to show maximum string in control left area
+
+
+ }
+ else
+ {
+ // text boundary overflow check
+ //EIP 73391 : Adjusted the cordinates to show maximum string in control left area
+ if ( (TestPrintLength( text->Text ) / (NG_SIZE)) >= (UINTN)((text->Width + text->Left) - text->LabelMargin -2) )
+ text->Text[HiiFindStrPrintBoundary(text->Text ,(UINTN)((text->Width + text->Left) - text->LabelMargin -2))] = L'\0';
+ DrawStringWithAttribute( text->Left + text->LabelMargin , text->Top, text->Text, text->BGColor |ColorText );
+ }
+ }
+
+ //EIP-72610 if TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ FlushLines(text->Top, text->Top + text->Height - 1);
+ }
+ else
+ {
+ FlushLines(text->Top, text->Top);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextHandleAction
+//
+// Description: function to handle the text actions
+//
+// Input: TEXT_DATA *text, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextHandleAction( TEXT_DATA *text, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( (Data->Input.Type == ACTION_TYPE_TIMER) && ((UINT8)text->ControlData.ControlFlags.ControlRefresh != 0))
+ {
+ Status = CallTextCallBack(text, Data);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: TEXT_DATA *text, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetCallback( TEXT_DATA *text, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( text, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: TEXT_DATA *text, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetFocus(TEXT_DATA *text, BOOLEAN focus)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetPosition
+//
+// Description: Function to set position.
+//
+// Input: TEXT_DATA *text, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetPosition(TEXT_DATA *text, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( text, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetDimensions
+//
+// Description: Function to set text dimension.
+//
+// Input: TEXT_DATA *text, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetDimensions(TEXT_DATA *text, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( text, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetAttributes
+//
+// Description: Function to set text attributes.
+//
+// Input: TEXT_DATA *text, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetAttributes(TEXT_DATA *text, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( text, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextSetText
+//
+// Description: function to set the text
+//
+// Input: TEXT_DATA *text, CHAR16 *label, CHAR16 *value
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextSetText( TEXT_DATA *text, CHAR16 *label, CHAR16 *value )
+{
+ if ( label != NULL )
+ {
+ MemFreePointer( &text->LabelText );
+ text->LabelText = StrDup( label );
+ }
+
+ if ( value != NULL )
+ {
+ MemFreePointer( &text->Text );
+ text->Text = StrDup( value );
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TextGetControlHeight
+//
+// Description: function to get the text height
+//
+// Input: TEXT_DATA *text, Frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TextGetControlHeight( TEXT_DATA *text, VOID* frame, UINT16 *height )
+{
+ //EIP-72610 if TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL;
+ UINT16 tmpHeight=0;
+ UINT16 Width;
+
+ //EIP-147142
+ //Make sure text->Label and text->text are updated before computing the control height
+ gText.SetText(text,
+ HiiGetString( text->ControlData.ControlHandle, UefiGetTextField((VOID*)text->ControlData.ControlPtr)),
+ HiiGetString( text->ControlData.ControlHandle, UefiGetTextTwoField((VOID*)text->ControlData.ControlPtr))
+ );
+
+ Width = (UINT16)(text->LabelMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gLabelLeftMargin));
+ newText = StringWrapText( text->Text, (UINT16)(((FRAME_DATA *)frame)->FrameData.Width - text->LabelMargin -2), &tmpHeight );
+ *height = tmpHeight;
+ MemFreePointer( (VOID **)&newText );
+
+ newText = StringWrapText( text->LabelText, Width, &tmpHeight );
+
+ if(tmpHeight > *height)
+ *height = tmpHeight;
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Text.h b/EDK/MiniSetup/TseLite/Text.h
new file mode 100644
index 0000000..8451485
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Text.h
@@ -0,0 +1,154 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Text.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Text.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: text.h
+//
+// Description: Header file for code to handle text operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _TEXT_H_
+#define _TEXT_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+#define TEXT_MEMBER_VARIABLES \
+ CHAR16 *LabelText; \
+ UINT16 LabelMargin; \
+ CHAR16 *Text; \
+ UINT8 Interval;
+
+typedef struct _TEXT_METHODS TEXT_METHODS;
+
+typedef struct _TEXT_DATA
+{
+ TEXT_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ TEXT_MEMBER_VARIABLES
+
+}
+TEXT_DATA;
+
+typedef EFI_STATUS (*TEXT_METHOD_SET_TEXT) ( VOID *object, CHAR16 *label, CHAR16 *value );
+#define TEXT_METHOD_FUNCTIONS \
+ TEXT_METHOD_SET_TEXT SetText;
+
+struct _TEXT_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ TEXT_METHOD_FUNCTIONS
+};
+
+extern TEXT_METHODS gText;
+
+// Object Methods
+EFI_STATUS TextCreate( VOID **object );
+EFI_STATUS TextDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS TextInitialize( VOID *object, VOID *data );
+EFI_STATUS TextDraw( VOID *object );
+EFI_STATUS TextHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS TextSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS TextSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS TextSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS TextSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS TextSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+
+// Text Methods
+EFI_STATUS TextSetText( VOID *object, CHAR16 *label, CHAR16 *value );
+EFI_STATUS TextGetControlHeight( VOID *text,VOID *frame, UINT16 *height );
+
+#endif /* _TEXT_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/Time.h b/EDK/MiniSetup/TseLite/Time.h
new file mode 100644
index 0000000..0191381
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/Time.h
@@ -0,0 +1,180 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Time.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/Time.h $
+//
+// 9 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 11/21/11 10:56a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 7 11/10/10 7:02p Blaines
+// EIP 47037: Add range checks to properly edit and update date/time.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:07p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Time.h
+//
+// Description: Header file for code to handle Time control operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _TIME_H_
+#define _TIME_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+typedef struct _TIME
+{
+ UINT8 Hour;
+ UINT8 Min;
+ UINT8 Sec;
+
+}
+TIME;
+
+#define TIME_MEMBER_VARIABLES \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT8 LabelMargin; \
+ UINT8 Sel; \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT8 NSelFGColor; \
+ UINT16 Min; \
+ UINT16 Max; \
+ UINT8 Interval; \
+ EFI_TIME *EditTime;
+
+typedef struct _TIME_METHODS TIME_METHODS;
+
+typedef struct _TIME_DATA
+{
+ TIME_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ TIME_MEMBER_VARIABLES
+
+}
+TIME_DATA;
+
+
+
+struct _TIME_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+};
+
+extern TIME_METHODS gTime;
+
+// Object Methods
+EFI_STATUS TimeCreate( VOID **object );
+EFI_STATUS TimeDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS TimeInitialize( VOID *object, VOID *data );
+EFI_STATUS TimeDraw( VOID *object );
+EFI_STATUS TimeHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS TimeSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS TimeSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS TimeSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS TimeSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS TimeSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS TimeGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+VOID _TimeUpdateHelp( TIME_DATA *time );
+#endif /* _TIME_H_ */
+
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/TseLite.cif b/EDK/MiniSetup/TseLite/TseLite.cif
new file mode 100644
index 0000000..d666012
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/TseLite.cif
@@ -0,0 +1,73 @@
+<component>
+ name = "TSE Sources - TSE Lite"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\TseLite"
+ RefName = "TseLite"
+[files]
+"TseLite.sdl"
+"TseLite.mak"
+"minisetupext.h"
+"application.h"
+"Action.c"
+"action.h"
+"application.c"
+"object.c"
+"object.h"
+"page.c"
+"page.h"
+"control.c"
+"control.h"
+"callback.c"
+"callback.h"
+"hotkey.h"
+"frame.c"
+"frame.h"
+"hotkey.c"
+"SubMenu.h"
+"SubMenu.c"
+"Text.c"
+"Text.h"
+"Menu.c"
+"Menu.h"
+"MessageBox.h"
+"MessageBox.c"
+"Memo.c"
+"Memo.h"
+"popup.c"
+"popup.h"
+"Label.h"
+"Label.c"
+"numeric.c"
+"numeric.h"
+"time.c"
+"Time.h"
+"Date.c"
+"Date.h"
+"edit.c"
+"edit.h"
+"ListBox.c"
+"ListBox.h"
+"PopupPassword.c"
+"PopupPassword.h"
+"PopupSel.c"
+"PopupSel.h"
+"PopupString.c"
+"PopupString.h"
+"PopupEdit.h"
+"PopupEdit.c"
+"ordlistbox.h"
+"ordlistbox.c"
+"TseLitehelper.c"
+"minisetupext.c"
+"variable.c"
+"AddBootOption.c"
+"TseLiteCommon.c"
+"UefiAction.c"
+"UefiAction.h"
+"ResetButton.h"
+"ResetButton.c"
+"hotclick.h"
+"hotclick.c"
+[parts]
+"StyleHook"
+<endComponent>
diff --git a/EDK/MiniSetup/TseLite/TseLite.mak b/EDK/MiniSetup/TseLite/TseLite.mak
new file mode 100644
index 0000000..1feb3d7
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/TseLite.mak
@@ -0,0 +1,124 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLite.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 7 $
+##
+## $Date: 10/18/12 6:01a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLite.mak $
+#
+# 7 10/18/12 6:01a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 8 10/10/12 12:38p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 6 4/23/10 6:05p Madhans
+#
+# 5 2/19/10 1:04p Madhans
+# Updated for TSE 2.01. Refer Changelog.log for File change history.
+##
+## 5 2/19/10 8:18a Mallikarjunanv
+## updated year in copyright message
+##
+## 4 8/17/09 12:27p Presannar
+## Removed include path to Core dir
+##
+## 3 6/24/09 6:11p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 7:44p Presannar
+## Initial implementation of coding standards for AMITSE2.0
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:07p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 3 4/28/09 9:40p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 2 2/05/09 10:15a Madhans
+## Style Module created.
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+TSELITE_INCLUDES = \
+ -I $(UEFISRC_DIR) \
+ -I $(TSE_STYLE_DIR) \
+ -I $(TSESRC_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\TseLiteLocal.lib : TseLiteLib
+
+TseLiteLib : $(BUILD_DIR)\TseLite.mak TseLiteLibBin
+
+$(BUILD_DIR)\TseLite.mak : $(TSELITESRC_DIR)\$(@B).cif $(TSELITESRC_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(TSELITESRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+TseLiteLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\TseLite.mak all\
+ "MY_INCLUDES=$(TSELITE_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\TseLiteLocal.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/TseLite/TseLite.sdl b/EDK/MiniSetup/TseLite/TseLite.sdl
new file mode 100644
index 0000000..95d74c1
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/TseLite.sdl
@@ -0,0 +1,40 @@
+TOKEN
+ Name = "TseLite_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable TseLite sources support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "TSE_LITE_SOURCES_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "POPUP_MENU_ENTER_SETUP"
+ Value = "1"
+ Help = "1 => Allows to enter setup from BBS popup"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+PATH
+ Name = "TSELITESRC_DIR"
+End
+
+MODULE
+ Help = "Includes TseLite.mak to Project"
+ File = "TseLite.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\TseLiteLocal.lib"
+ Parent = "$(TSELITESRC_DIR)\TseLiteLocal$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
diff --git a/EDK/MiniSetup/TseLite/TseLiteCommon.c b/EDK/MiniSetup/TseLite/TseLiteCommon.c
new file mode 100644
index 0000000..ac72ff3
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/TseLiteCommon.c
@@ -0,0 +1,433 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLiteCommon.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 16 $
+//
+// $Date: 8/28/14 9:11a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLiteCommon.c $
+//
+// 16 8/28/14 9:11a Premkumara
+// [TAG] EIP168489
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] System will display blue screen after use OEM command to
+// boot to BIOS Setup Utility from Built-in EFI Shell
+// [Files] TseliteCommon.c
+//
+// 15 2/11/14 8:47p Arunsb
+// [TAG] EIP148693
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Slowness in shell performance
+// [Root Cause] Memory fragmentation
+// [Solution] Controlled the TSE destructor with token from sdl file
+// [Files] amitse.sdl, tselitecommon.c
+//
+// 14 6/10/13 10:03a Arunsb
+// gRefreshIdCount made as 0 bcoz exiting from setup and coming back wont
+// reinit it
+//
+// 13 4/18/13 9:31a Arunsb
+// Function moved to avoid build error in 2.0
+//
+// 12 4/15/13 5:40a Arunsb
+// gRefreshIdInfo check added
+//
+// 11 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 9/14/12 12:59p Madhans
+// [TAG] EIP101218
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] If Sendform is called more than once from DHP
+// (DriverHealthprotocol Module). It does not enter.
+// [RootCause] SendForm called before postmanagerhandsake was not
+// cleaned gApp correctly.
+// [Solution] Fix to do the cleanup
+// [Files] tselitecommon.c
+//
+// 8 5/28/12 7:29a Rajashakerg
+// [TAG] EIP85564
+// [Category] Improvement
+// [Description] UefiHiiTestPrintLength function needs optimization
+// [Files] TseLiteCommon.c, hiistring21.c
+//
+// 7 4/27/12 7:28a Arunsb
+// [TAG] EIP88449
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] SUT hangs when "Exit Without Saving" prompt is select as
+// 'yes' in setup.
+// [RootCause] gVariablelist freed before calling callback
+// [Solution] gVariablelist freed after calling callback
+// [Files] TseLiteCommon.c
+//
+// 6 3/28/11 9:25p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 5 3/21/11 12:46a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 7:13a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/13/09 1:21p Blaines
+// EIP #24980 Fix to properly display right area text
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:07p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: TseLiteCommon.c
+//
+// Description: This file contains code for the TSE Lite common functions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+SETUP_PKG *gSetupPkg;
+SCREEN_INFO *gScreen;
+PAGE_LIST *gToolPages;
+PAGE_LIST *gPages;
+CONTROL_INFO *gToolControlInfo;
+CONTROL_INFO *gControlInfo;
+VARIABLE_LIST *gToolVariables;
+VARIABLE_LIST *gVariables;
+HPK_INFO *gHpkInfo;
+GUID_LIST *gGuidList;
+PAGE_ID_LIST *gPageIdList;
+PAGE_ID_LIST *gToolPageIdList;
+PAGE_ID_INFO *gPageIdInfo;
+PAGE_ID_INFO *gToolPageIdInfo;
+FRAME_DATA *gActiveFrame = NULL;
+
+UINT16 gCheckboxTokens[] =
+{
+ STRING_TOKEN(STR_CTRL_CHKBOX_DISABLE),
+ STRING_TOKEN(STR_CTRL_CHKBOX_ENABLE)
+};
+
+UINTN gLabelLeftMargin = 2 ;
+UINTN gControlLeftMargin = 24;
+UINTN gControlLeftPad = 2 ;
+UINTN gControlRightAreaWidth = 27 ;
+BOOLEAN gVariableChanged = FALSE;
+BOOLEAN gResetRequired = FALSE;
+UINT32 gStartPage = 0;
+
+APPLICATION_DATA *gApp = NULL;
+UINTN gHpkInfoLength;
+UINT32 GetControlConditionVarId(CONTROL_INFO *control);
+
+extern CHAR8 *GlyphWidthCache;//EIP 85564 : UefiHiiTestPrintLength function needs optimization
+extern UINT32 gRefreshIdCount;
+extern REFRESH_ID_INFO *gRefreshIdInfo;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MiniSetupUIExit
+//
+// Description: Freesup UI related resources.
+//
+// Input: none
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN TseDebugDisableApplicationDestructor (VOID);
+VOID MiniSetupUIExit(VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN index;
+
+ // Don't do the MiniSetupExit if it is not a first call to PostManagerHandshake.
+ if(gPostManagerHandshakeCallIndex>2) //gApp should be preserved when it is not freed.
+ {
+ // to Let Next call not quit.
+ gApp->Quit=FALSE;
+ goto Done;
+ }
+
+ if ( gApp != NULL )
+ {
+ if (!TseDebugDisableApplicationDestructor ())
+ {
+ gApplication.Destroy( gApp, TRUE );
+ }
+ gApp = NULL;
+
+ MouseDestroy();
+ }
+
+Done:
+ //Close the Event and Free the NotifyContext created for Controls with Refresh Id.
+ if(gRefreshIdInfo) {
+ for(index = 0; index < gRefreshIdCount; index++)
+ {
+ if(gRefreshIdInfo[index].pEvent)//Close the event
+ {
+ Status = gBS->CloseEvent(gRefreshIdInfo[index].pEvent);
+ if(Status == EFI_SUCCESS)
+ {
+ gRefreshIdInfo[index].pEvent = NULL;
+ }
+ }
+
+ MemFreePointer( (VOID **)&gRefreshIdInfo[index].pNotifyContext );
+ }
+ MemFreePointer( (VOID **)&gRefreshIdInfo );
+ gRefreshIdCount = 0;
+ }
+
+ UEFICallSetupFormCallBack(AMI_CALLBACK_FORM_CLOSE);//EIP-53480: Calling the Wrapper function with AMI_CALLBACK_FORM_CLOSE action before HiiExit()
+ if ( gVariableList != NULL )
+ {
+ for ( index = 0; index < gVariables->VariableCount; index++ )
+ MemFreePointer( (VOID **)&gVariableList[index] );
+
+ MemFreePointer( (VOID **)&gVariableList );
+ }
+ //Commented and moved above for EIP88449
+ //UEFICallSetupFormCallBack(AMI_CALLBACK_FORM_CLOSE);//EIP-53480: Calling the Wrapper function with AMI_CALLBACK_FORM_CLOSE action before HiiExit()
+ HiiExit( );
+
+
+ if(GlyphWidthCache) {
+ MemFreePointer((VOID **)&GlyphWidthCache);// EIP 85564 :free the memory which was used to store the widths of each possible CHAR16 glyph.
+ }
+
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBootTimeOut
+//
+// Description: Timeout value from the variable.
+//
+// Input: DefaultValue
+//
+// Output: Timeout value
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetBootTimeOutLocal(UINT16 DefaultValue)
+{
+ UINT16 *TimeOut=NULL, Value = 0;
+ UINTN size = 0;
+
+ // Install boot timeout
+ TimeOut = VarGetNvram( VARIABLE_ID_BOOT_TIMEOUT, &size );
+
+ if ( TimeOut != NULL )
+ {
+ Value = *TimeOut;
+ }
+ else
+ {
+ Value = DefaultValue;
+ VarSetNvram( VARIABLE_ID_BOOT_TIMEOUT, &Value, sizeof(UINT16) );
+ }
+
+ return Value;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _GetControlVariable
+//
+// Description: Function to get control variable.
+//
+// Input: CONTROL_INFO *control
+//
+// Output: UINT32
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 _GetControlVariable(CONTROL_INFO *control)
+{
+ return control->ControlVariable;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _GetPageInfo
+//
+// Description: Returns pointer to the PAGE_INFO struct of given PgIndex
+//
+// Input: UINT32 PgIndex - Page index
+// PAGE_INFO **PageInfo - Pointer to the page information struct
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetPageInfo(UINT32 PgIndex, PAGE_INFO **PageInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ if((gApplicationData == NULL) || (gPages == NULL))
+ {
+ status = EFI_NOT_READY;
+ goto DONE;
+ }
+
+ if(PgIndex > gPages->PageCount)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ *PageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[PgIndex]);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsPageModal
+//
+// Description: Is this a modal page
+//
+// Parameter: IN UINT32 PgIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#define ASSERT_ERROR_STATUS(assertion) if(EFI_ERROR(assertion)) goto DONE
+BOOLEAN IsPageModal(UINT32 PgIndex)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN isTrue = FALSE;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+ isTrue = pageInfo->PageFlags.PageModal ? TRUE : FALSE;
+
+DONE:
+ return isTrue;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageSubTitle
+//
+// Description: Get the Page Subtitle String Index
+//
+// Parameter: IN UINTN PgIndex
+// OUT UINT16 *subtitleToken
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageSubTitle(UINT32 PgIndex, UINT16 *SubtitleToken)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *SubtitleToken = pageInfo->PageSubTitle;
+
+DONE:
+ return status;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/TseLitehelper.c b/EDK/MiniSetup/TseLite/TseLitehelper.c
new file mode 100644
index 0000000..9bb1325
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/TseLitehelper.c
@@ -0,0 +1,1310 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLitehelper.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 18 $
+//
+// $Date: 7/02/13 10:09a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/TseLitehelper.c $
+//
+// 18 7/02/13 10:09a Premkumara
+// [TAG] EIP120011
+// [Category] Improvement
+// [Description] Variable BootOrder and LegacyDevOrder need
+// fool-proofing function when TSE load variabled
+// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c
+//
+// 17 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 22 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 16 2/03/12 8:43a Arunsb
+// While booting to shell it appears on different colors other than black
+// so setting the background attribute with black color.
+//
+// 15 12/07/11 11:26p Arunsb
+// [TAG] EIP77493
+// [Category] New Feature
+// [Description] Provide the alternative way for _ActionReadKey
+// [Files] AMITSE.sdl and TseLitehelper.c
+//
+// 14 11/30/11 1:32p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 13 11/13/11 1:07p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 12 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 11 2/04/11 4:38p Mallikarjunanv
+// Added dummy function for UpdateBootVariables()
+//
+// 10 2/01/11 7:35p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 9 10/05/10 12:20p Mallikarjunanv
+// added ShowPostProgress function for TSE Lite
+//
+// 8 9/20/10 6:47p Madhans
+// [TAG] EIP44542
+// [Category] BUILD ISSUE FIX
+// [Symptom] Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
+// when IdeSecurity and FastBoot modules added to the project
+// [RootCause] -
+// [Solution] Build issues resolved
+// [Files] CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
+// bbs.c, special.c, Bds.c TseLitehelp
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 15 9/16/10 3:13p Madhans
+// To Avoid build issues with TSE_USE_EDK_LIBRARY Building.
+//
+// 14 8/27/10 5:05a Mallikarjunanv
+// EIP-39334: support to build TSE without the CSM module support
+//
+// 13 6/14/10 7:10p Madhans
+// Nt32 build support.
+//
+// 12 3/23/10 5:24p Blaines
+// Add support for PostManager Extentions
+//
+// 11 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 10 1/29/10 4:38p Madhans
+// To iniltize it properly
+//
+// 9 1/09/10 7:05a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 8 9/15/09 9:50a Sudhirv
+// updated the handling of Add Del Boot option
+//
+// 7 8/19/09 6:33p Madhans
+// IsToggleStateKey Function added to findout invalid action keys
+// correctly.
+//
+// 6 8/13/09 7:40a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 5 7/20/09 1:22p Mallikarjunanv
+// updated the code with token PASSWORD_WITH_SPECIAL_CHAR_SUPPORT
+//
+// 4 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 3 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 2 6/08/09 5:36p Madhans
+// Fix for SetupHang issue in TSE Lite.
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:07p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:13p Madhans
+// Add/del boot option and other fixes.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: TSELiteHelper.c
+//
+// Description: This file contains code specific to TSE Lite flavor
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+extern BOOLEAN gQuietBoot;
+
+UINT32 GetControlConditionVarId(CONTROL_INFO *control);
+BOOLEAN CheckIsAllowedPasswordChar(CHAR16 Char);
+extern APPLICATION_DATA *gApp;
+
+// TSELiteMinisetup
+#define SETUP_VARIABLE_GUID \
+ { 0xEC87D643, 0xEBA4, 0x4BB5, { 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 } }
+
+
+static SETUP_PKG _SetupPackageTemplate = {
+ {'$', 'S', 'P', 'F'}, //PackageSignature[4];
+ 0x0102, //StructureRevision;
+ 0x100, //PackageVersion;
+ {0,0,0,0,0,0}, //Reserved[6];
+ SETUP_VARIABLE_GUID, //PackageGuid;
+ 0, //PackageVariable;
+ 0, //PackageScreen;
+ 0, //PackagePageList;
+ 0, //PackageControlOffset;
+ 0, //PackageVariableList;
+ 0, //PackageHpkData;
+ 0, //PackageGuidList;
+ 0, //PackagePageIdList;
+ 0 //PackageIfrData;
+};
+
+static SCREEN_INFO _SetupPackageScreen = {
+ {0}, //MainHandle;
+ STR_MAIN_TITLE, //MainTitle;
+ STR_MAIN_COPYRIGHT, //MainCopyright;
+ STR_EVAL_MSG, //MainHelpTitle;
+ 0, //MainMenuCount;
+ 0 //MainNavCount;
+};
+
+
+static PAGE_INFO _SetupPageInfo =
+{
+ {0}, // PageHandle;
+ 0, // PageIdIndex;
+ 0, // PageFormID;
+ 0, // PageTitle;
+ 0, // PageSubTitle;
+ 0, // PageID;
+ 0, // PageParentID;
+ {0}, // PAGE_FLAGS PageFlags;
+ 0, // PageVariable;
+ {0}, // PageControls;
+};
+
+static CONTROL_INFO _SetupControlInfo_N_N = {
+ {0}, // EFI_HII_HANDLE ControlHandle;
+ 0, // UINT32 ControlVariable;
+ {0}, // UINT32 ControlConditionalVariable[2];
+ 0, // UINT16 ControlType;
+ 0, // UINT16 ControlPageID;
+ 0xFFFF, // UINT16 ControlDestPageID;
+ {0}, // CONTROL_FLAGS ControlFlags;
+ 0, // UINT16 ControlHelp;
+ 0, // UINT16 ControlLabel;
+ 0, // UINT16 ControlIndex;
+ 0, // UINT16 ControlLabelCount;
+ {0}, // union {
+ // UINTN ControlPtr;
+ // UINT64 res1;
+ // };
+ {0}, // union {
+ // INTN ControlConditionalPtr;
+ // UINT64 res2;
+ // };A
+ 0, // UINT16 ControlDataLength;
+ 0, // UINT16 ControlDataWidth;
+ 0 // UINT16 QuestionId;
+};
+
+#define _VARIABLE_COUNT 17
+#define _GUID_COUNT 5
+
+static VARIABLE_INFO _SetupVariableInfo[_VARIABLE_COUNT] = {
+ {SETUP_VARIABLE_GUID , L"Setup", 0x07,0},
+ {EFI_GLOBAL_VARIABLE_GUID , L"Dummy", 0x17,0},
+ {EFI_GLOBAL_VARIABLE_GUID , L"Timeout", 0x07,0},
+ {USER_DEFAULTS_GUID , L"UserDefaults", 0x07,0},
+ {ERROR_MANAGER_GUID , L"ErrorManager", 0x07,0},
+ {AMITSESETUP_GUID , L"AMITSESetup", 0x07,0},
+ {IDE_SECURITY_CONFIG_GUID , L"IDESecDev", 0x07,0},
+ {EFI_GLOBAL_VARIABLE_GUID , L"BootOrder", 0x17,0},
+ {LEGACY_DEV_ORDER_GUID , L"LegacyDevOrder", 0x17,0},
+ {DEL_BOOT_OPTION_GUID , L"DelBootOption", 0x17,0},
+ {ADD_BOOT_OPTION_GUID , L"AddBootOption", 0x17,0},
+ {BOOT_MANAGER_GUID , L"BootManager", 0x07,0},
+ {BOOT_NOW_COUNT_GUID , L"BootNowCount", 0x07,0},
+ {LEGACY_DEV_ORDER_GUID , L"LegacyDev", 0x01,0},
+ {AMI_CALLBACK_GUID , L"AMICallback", 0x01,0},
+ {LEGACY_DEV_ORDER_GUID , L"LegacyGroup", 0x01,0},
+ {BOOT_NOW_COUNT_GUID , L"SetupSaveState", 0x02,0},
+};
+
+static GUID_INFO _SetupGUIDInfo[_GUID_COUNT] = {
+ // Needs to be first on List for patching up later.
+ {EFI_GLOBAL_VARIABLE_GUID , L"Dummy", {1},5}, // For lang codes/platformlangcode
+ {BOOT_MANAGER_GUID , L"BootManager", {1},1},
+ {BOOT_NOW_COUNT_GUID , L"BootNowCount", {1},1},
+ {AMI_CALLBACK_GUID , L"AMICallback", {1},2},
+ {ADD_BOOT_OPTION_GUID , L"AddBootOption", {0},9}
+};
+
+#pragma pack(8)
+typedef struct _TSE_SETUP_PACKAGE
+{
+ SETUP_PKG SetupPkg;
+ SCREEN_INFO ScreenInfo;
+ PAGE_LIST PageList;
+ UINT32 PageOffset[1]; // Increase if you have more pages - Dummy
+ PAGE_INFO PageInfo[1]; // Increase if you have more pages - Dummy
+
+ CONTROL_INFO ControlInfo[1];// Increase if controls - Dummy
+
+ VARIABLE_LIST VariableList;
+ UINT32 VariableOffset[_VARIABLE_COUNT]; // Increase if you have more Variable
+ VARIABLE_INFO VariableInfo[_VARIABLE_COUNT];
+ HPK_INFO HpkInfo[1]; //- Dummy
+ GUID_LIST GuidList;
+ UINT32 GuidOffset[_GUID_COUNT]; // Increase if you have more GUID
+ GUID_INFO GuidInfo[_GUID_COUNT];
+ PAGE_ID_LIST PageIdList;
+ UINT32 PageIdOffset[1]; // Increase if you have more Page - Dummy
+ PAGE_ID_INFO PageIdInfo[1]; // Increase if you have more Page - Dummy
+}TSE_SETUP_PACKAGE;
+
+#pragma pack()
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitApplicationData
+//
+// Description: Initlizes the TSE Lite Setupdata.
+//
+// Input: ImageHandle
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitApplicationData(EFI_HANDLE ImageHandle)
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+// UINTN FillSize = 0;
+ UINTN i;
+ CHAR16 *name = NULL;
+
+ //TODO
+ // Init the Application data
+ // Hardcoded Application data for the TSE Lite
+ gApplicationData = EfiLibAllocateZeroPool( 0x1000 ); // Allocate more of you add more
+
+ // SETUP_PKG
+ MemCopy(gApplicationData,&_SetupPackageTemplate, sizeof(_SetupPackageTemplate) );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageVariable = 0;
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageScreen = STRUCT_OFFSET( TSE_SETUP_PACKAGE, ScreenInfo );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackagePageList = STRUCT_OFFSET( TSE_SETUP_PACKAGE, PageList );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageControlOffset = STRUCT_OFFSET( TSE_SETUP_PACKAGE, ControlInfo );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageVariableList = STRUCT_OFFSET( TSE_SETUP_PACKAGE, VariableList );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageHpkData = STRUCT_OFFSET( TSE_SETUP_PACKAGE, HpkInfo );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageGuidList = STRUCT_OFFSET( TSE_SETUP_PACKAGE, GuidList );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackagePageIdList = STRUCT_OFFSET( TSE_SETUP_PACKAGE, PageIdList );
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->SetupPkg.PackageIfrData = sizeof(TSE_SETUP_PACKAGE);
+
+ //SCREEN_INFO
+ MemCopy(&((TSE_SETUP_PACKAGE *)gApplicationData)->ScreenInfo,&_SetupPackageScreen,sizeof(SCREEN_INFO));
+
+ //PAGE_INFO
+ MemSet(&_SetupPageInfo,sizeof(_SetupPageInfo),0);
+ MemCopy(&((TSE_SETUP_PACKAGE *)gApplicationData)->PageInfo,&_SetupPageInfo,sizeof(_SetupPageInfo));
+
+ //PAGE_LIST
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->PageList.PageCount = 1;
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->PageList.PageList[0] = (UINT32)((UINTN)(&((TSE_SETUP_PACKAGE *)gApplicationData)->PageInfo[0])-(UINTN)(gApplicationData));
+
+ //CONTROL_INFO
+ MemCopy(&((TSE_SETUP_PACKAGE *)gApplicationData)->ControlInfo,&_SetupControlInfo_N_N,sizeof(CONTROL_INFO));
+
+ //VARIABLE_INFO
+ name = GetVariableNameByID(VARIABLE_ID_LANGUAGE);
+ EfiStrCpy(_SetupVariableInfo[VARIABLE_ID_LANGUAGE].VariableName, name);
+ MemFreePointer(&name);
+ MemCopy(&((TSE_SETUP_PACKAGE *)gApplicationData)->VariableInfo,&_SetupVariableInfo,sizeof(_SetupVariableInfo));
+
+ //VARIABLE_LIST
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->VariableList.VariableCount = _VARIABLE_COUNT;
+ for(i=0;i<_VARIABLE_COUNT;i++)
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->VariableList.VariableList[i] = (UINT32)((UINTN)(&((TSE_SETUP_PACKAGE *)gApplicationData)->VariableInfo[i])-(UINTN)(&((TSE_SETUP_PACKAGE *)gApplicationData)->VariableList));
+
+ //GUID_INFO
+ name = GetGUIDNameByID(VARIABLE_ID_LANGUAGE);
+ EfiStrCpy(_SetupGUIDInfo[0].GuidName , name);
+ MemFreePointer(&name);
+ MemCopy(&((TSE_SETUP_PACKAGE *)gApplicationData)->GuidInfo,_SetupGUIDInfo,sizeof(_SetupGUIDInfo));
+
+ //GUID_LIST
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->GuidList.GuidCount = _GUID_COUNT;
+ for(i=0;i<_GUID_COUNT;i++)
+ ((TSE_SETUP_PACKAGE *)gApplicationData)->GuidList.GuidList[i] = (UINT32)((UINTN)(&((TSE_SETUP_PACKAGE *)gApplicationData)->GuidInfo[i])-(UINTN)(&((TSE_SETUP_PACKAGE *)gApplicationData)->GuidList));
+
+ return Status;
+}
+
+VOID TSELiteFixBootOrder(CONTROL_DATA *ControlData);
+VOID TSELiteFixBBSOrder(CONTROL_DATA *ControlData);
+VOID TSELiteFixBootOrderRide(CONTROL_DATA *ControlData);
+VOID TSELiteFixAddBootOptionFileList(CONTROL_DATA *ControlData);
+VOID TSELiteFixDelBootOptionFileList(CONTROL_DATA *ControlData);
+#ifdef TSE_FOR_APTIO_4_50
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialUpdatePageControls
+//
+// Description: Fix the Boot Order, BBS Order and Boot Override controls.
+//
+// Input: CurrentPage
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SpecialUpdatePageControls(UINT32 CurrentPage)
+{
+ UINT16 j=0;
+ UINT32 CtrlCondVariable=0xFFFF, CtrlVariable=0xFFFF;
+ CONTROL_INFO *control;
+
+ CONTROL_DATA **ControlData;
+ FRAME_DATA *fdata;
+
+ fdata = ((PAGE_DATA*)gApp->PageList[CurrentPage])->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ ControlData = ((PAGE_DATA*)gApp->PageList[CurrentPage])->FrameList[StyleFrameIndexOf(MAIN_FRAME)]->ControlList;
+
+ for(j=0;j < fdata->ControlCount;j++,ControlData++)
+ {
+ control = &(*ControlData)->ControlData;
+
+ if( CheckControlCondition( control ) != COND_NONE)
+ continue;
+
+ CtrlCondVariable = GetControlConditionVarId(control);
+ CtrlVariable = _GetControlVariable(control);
+
+ switch( CtrlCondVariable)
+ {
+ case VARIABLE_ID_BOOT_MANAGER:
+ // For Boot Order Case
+ if(( CtrlVariable == VARIABLE_ID_BOOT_ORDER) &&
+ ((control->ControlType == CONTROL_TYPE_ORDERED_LIST)||(control->ControlType == CONTROL_TYPE_POPUPSEL)))
+ TSELiteFixBootOrder(*ControlData);
+
+ // For Boot Override Case
+ if( (control->ControlType == CONTROL_TYPE_SUBMENU) &&
+ (control->ControlPageID == control->ControlDestPageID) )
+ {
+ ((SUBMENU_DATA*)(*ControlData))->SubMenuType = 2;
+ TSELiteFixBootOrderRide(*ControlData);
+ }
+ if(( CtrlVariable == VARIABLE_ID_DEL_BOOT_OPTION) && (control->ControlType == CONTROL_TYPE_POPUPSEL))
+ TSELiteFixDelBootOptionFileList(*ControlData);
+ break;
+ case VARIABLE_ID_LEGACY_DEV_INFO:
+ if(( CtrlVariable == VARIABLE_ID_BBS_ORDER) &&
+ ((control->ControlType == CONTROL_TYPE_ORDERED_LIST)||(control->ControlType == CONTROL_TYPE_POPUPSEL)))
+ TSELiteFixBBSOrder(*ControlData);
+ break;
+ case VARIABLE_ID_AMI_CALLBACK:
+ if( (control->ControlType == CONTROL_TYPE_SUBMENU) &&
+ (control->ControlPageID == control->ControlDestPageID) )
+ ((SUBMENU_DATA*)(*ControlData))->SubMenuType = 2;
+ break;
+ case VARIABLE_ID_ADD_BOOT_OPTION:
+ if( (control->ControlType == CONTROL_TYPE_POPUPSEL) )
+ TSELiteFixAddBootOptionFileList(*ControlData);
+ break;
+ default:
+ break;
+ }
+ }
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSELiteFixBootOrder
+//
+// Description: Fixes the Boot Order OrderList.
+//
+// Input: ControlData
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TSELiteFixBootOrder(CONTROL_DATA *ControlData)
+{
+ POPUPSEL_DATA *popupSel = (POPUPSEL_DATA *)ControlData;
+ UINT16 i=0;
+ CHAR16 *BootStr;
+ UINT16 *BootOrder=NULL;
+ UINTN size = 0;
+
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+
+ if (NULL != BootOrder)//EIP-75352 Suppress the warnings from static code analyzer
+ {
+ for(i=0;i<popupSel->ItemCount;i++)
+ {
+ BootStr = BootGetBootNowName(i,0,1);
+ popupSel->PtrTokens[i].Option = HiiAddString( popupSel->ControlData.ControlHandle, BootStr );
+ popupSel->PtrTokens[i].Value = BootOrder[i];
+ }
+ MemFreePointer((VOID **) &BootOrder);
+ }
+}
+
+// Fixes the BBS Order Name and Value
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSELiteFixBBSOrder
+//
+// Description: Fixes the BBS Order Orderlist.
+//
+// Input: ControlData
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TSELiteFixBBSOrder(CONTROL_DATA *ControlData)
+{
+ POPUPSEL_DATA *popupSel = (POPUPSEL_DATA *)ControlData;
+ CONTROL_INFO *control;
+ PAGE_INFO * pageInfo;
+ UINT16 DevType;
+ BBS_ORDER_TABLE *devOrder=NULL,*TempDevOrder=NULL;
+ UINTN size = 0,i,j;
+ BOOT_DATA * bootData=NULL;
+ UINT16 *BootOrder=NULL;
+ UINT16 Count;
+
+
+ control = &(ControlData)->ControlData;
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[control->ControlPageID]);
+
+ // to find the Devicetype based on the FORM ID
+ switch(pageInfo->PageFormID)
+ {
+ case HARD_DISK_ORDER_FORM:
+ DevType = BBS_TYPE_HARDDRIVE;break;
+ case CDROM_ORDER_FORM:
+ DevType = BBS_TYPE_CDROM;
+ break;
+ case FLOPPY_DISK_ORDER_FORM:
+ DevType = BBS_TYPE_FLOPPY;
+ break;
+ case NETWORK_ORDER_FORM:
+ DevType = BBS_TYPE_EMBEDDED_NETWORK;
+ break;
+ case BEV_ORDER_FORM:
+ DevType = BBS_TYPE_BEV;
+ break;
+ default:
+ return;
+ }
+
+ devOrder = VarGetVariable( VARIABLE_ID_BBS_ORDER, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == devOrder)
+ return;
+
+ for(i=0;i<size;)
+ {
+ TempDevOrder = (BBS_ORDER_TABLE *)(((UINT8*)devOrder)+i);
+
+ if ( (TempDevOrder->Length >= size) || (0 == TempDevOrder->Length) ) //EIP-120011
+ {
+ return;
+ }
+
+ if(TempDevOrder->Type == DevType)
+ break;
+ i = i+ sizeof(UINT32)+ TempDevOrder->Length;
+ }
+ if(i<size) // If Device type found in LegacydevOrder.
+ {
+ Count = (TempDevOrder->Length/sizeof(UINT16))-1;
+ if(Count==popupSel->ItemCount)
+ {
+ // Find the BOOT data of DevType
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &size );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == BootOrder)
+ {
+ MemFreePointer((VOID **) &devOrder);
+ return;
+ }
+ for(i=0;i<size/2;i++)
+ {
+ bootData = BootGetBootData(BootOrder[i]);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == bootData)
+ {
+ MemFreePointer((VOID **) &BootOrder);
+ MemFreePointer((VOID **) &devOrder);
+ return;
+ }
+ if ( BBSValidDevicePath(bootData->DevicePath) )
+ {
+ BBS_BBS_DEVICE_PATH *DevPath = (BBS_BBS_DEVICE_PATH *)bootData->DevicePath;
+ if((DevPath->DeviceType == DevType) && (bootData->LegacyDevCount == Count))
+ break;
+ }
+ }
+ if(i<size/2) //if BootData Found Found
+ {
+ for(i=0;i<popupSel->ItemCount;i++)
+ {
+ for(j=0;j<popupSel->ItemCount;j++)
+ {
+ if(TempDevOrder->Data[i]==bootData->OrderList[j].Index)
+ {
+ popupSel->PtrTokens[i].Option = HiiAddString( popupSel->ControlData.ControlHandle, bootData->OrderList[j].Name );
+ popupSel->PtrTokens[i].Value = bootData->OrderList[j].Index;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ MemFreePointer((VOID **) &BootOrder);
+ MemFreePointer((VOID **) &devOrder);
+
+}
+
+#ifdef TSE_FOR_APTIO_4_50
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateLegacyDevVariable
+//
+// Description: Update the LegacyDev variable with Device count in each BBS type
+//
+// Input: NoOfLegacyGroups
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups)
+{
+ extern EFI_GUID gLegacyDevGuid;
+ LEGACY_DEV_LIST BBSCount = { 0, 0, 0, 0, 0 };
+ BBS_ORDER_TABLE *devOrder,*TempDevOrder;
+ UINTN i;
+ UINTN size = 0;
+ UINT16 Count;
+
+ devOrder = VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &size );
+
+ for(i=0;i<size;)
+ {
+ TempDevOrder = (BBS_ORDER_TABLE *)(((UINT8*)devOrder)+i);
+
+ if ( (TempDevOrder->Length >= size) || (0 == TempDevOrder->Length) ) //EIP-120011
+ {
+ return;
+ }
+
+ Count = (TempDevOrder->Length/sizeof(UINT16))-1;
+
+ switch(TempDevOrder->Type)
+ {
+ case BBS_TYPE_FLOPPY:
+ BBSCount.FloppyCount = Count ;
+ break;
+ case BBS_TYPE_HARDDRIVE:
+ BBSCount.HardDiskCount = Count ;
+ break;
+ case BBS_TYPE_CDROM:
+ BBSCount.CDROMCount = Count ;
+ break;
+ case BBS_TYPE_EMBEDDED_NETWORK:
+ BBSCount.NetworkCount = Count ;
+ break;
+ case BBS_TYPE_BEV:
+ BBSCount.BevCount = Count ;
+ break;
+ default:
+ break;
+ }
+ i = i+ sizeof(UINT32)+ TempDevOrder->Length;
+ }
+
+ MemFreePointer( (VOID **)&devOrder );
+ VarSetNvramName( L"LegacyDev", &gLegacyDevGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &BBSCount, sizeof(BBSCount) );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSUpdateOrder
+//
+// Description: Updates the Legacydevorder variable base on the user input
+//
+// Input: UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSUpdateOrder(UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer)
+{
+ UINTN i,j,k,l;
+ UINTN varsize = 0;
+ BBS_ORDER_TABLE *devOrder=NULL,*TempDevOrder;
+ UINT16 DevCount;
+
+ // TODO
+ // Rearrange the legacy dev order Based on the new option
+ devOrder = VarGetVariable( VARIABLE_ID_BBS_ORDER, &varsize );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == devOrder)
+ return;
+
+ for(i=0;i<varsize ;)
+ {
+ TempDevOrder = (BBS_ORDER_TABLE *)(((UINT8*)devOrder)+i);
+
+ if ( (TempDevOrder->Length >= varsize) || (0 == TempDevOrder->Length) ) //EIP-120011
+ {
+ return;
+ }
+
+ DevCount = ((TempDevOrder->Length/sizeof(UINT16))-1);
+ for(j=0;j<DevCount;j++)
+ {
+ if(*newOption == TempDevOrder->Data[j]) // Need to update Order for this device type
+ {
+ // Place the Options in the specific Order.
+ for(l=0;l<(*size/sizeof(UINT16));l++)
+ {
+ for(k=0;k<DevCount;k++)
+ {
+ if(TempDevOrder->Data[k] == newOption[l])
+ {
+ TempDevOrder->Data[k] = TempDevOrder->Data[l];
+ TempDevOrder->Data[l] = newOption[l];
+ break;
+ }
+ }
+ }
+ *buffer = devOrder; // return the Real buffer that will be updated.
+ *size = varsize;
+ return;
+ }
+ }
+ i = i+ sizeof(UINT32)+ TempDevOrder->Length;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BootUpdateOrder
+//
+// Description: Updates the boot order variable
+//
+// Input: New options, offset, size and Outbuffer
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BootUpdateOrder(UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **realBuffer)
+{
+ UINTN varsize = 0;
+ UINTN i,j;
+ UINT16 * BootOrder;
+
+ BootOrder = HelperGetVariable(VARIABLE_ID_BOOT_ORDER, L"BootOrder", &gEfiGlobalVariableGuid, NULL, &varsize );
+
+ for(i=0;i<*size/2;i++)
+ {
+ for(j=0;j<varsize/2;j++)
+ {
+ // update the New boot order one by one
+ if(BootOrder[j]==newOption[i])
+ {
+ BootOrder[j]=BootOrder[i];
+ BootOrder[i] = newOption[i];
+ break;
+ }
+ }
+ }
+ *realBuffer = BootOrder;
+ *size = varsize;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DriverUpdateOrder
+//
+// Description: Updates the driver order variable
+//
+// Input: New options, offset, size and Outbuffer
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DriverUpdateOrder (UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **realBuffer)
+{
+ //TSE lite currently not supports driver options
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSELiteFixBootOrderRide
+//
+// Description: Function to fix boot override
+//
+// Input: CONTROL_DATA *ControlData
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID TSELiteFixBootOrderRide(CONTROL_DATA *ControlData)
+{
+ CONTROL_INFO *control;
+ UINT16 Index;
+ CHAR16 *BootStr;
+
+ control = &(ControlData)->ControlData;
+
+ // Find Boot override Device Index.
+ Index = UefiTseLiteGetBootOverRideIndex(control->ControlConditionalPtr);
+ if(Index != 0xFFFF)
+ {
+///EIP - 24971
+ BootStr = BootGetBootNowName(Index,(BOOLEAN)gShowAllBbsDev,(BOOLEAN)BootNowInBootOrderSupport());
+///EIP - 24971
+ UefiSetPromptField(control->ControlPtr,HiiAddString( control->ControlHandle, BootStr ));
+ control->ControlHelp = UefiGetPromptField(control->ControlPtr);
+ }
+}
+
+#ifdef TSE_FOR_APTIO_4_50
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SubMenuHandleSpecialOp
+//
+// Description: Sub menu handle for Special operations.
+//
+// Input: Submenu data
+//
+// Output: Bool - Interpreted by the Caller.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _SubMenuHandleSpecialOp( SUBMENU_DATA *submenu )
+{
+ BOOLEAN status = FALSE;
+ UINT32 CtrlCondVariable=0xFFFF, CtrlVariable=0xFFFF;
+ CONTROL_INFO *control;
+ UINT16 Index;
+
+ control = &submenu->ControlData;
+
+ CtrlCondVariable = GetControlConditionVarId(control);
+ CtrlVariable = _GetControlVariable(control);
+
+ switch( CtrlCondVariable)
+ {
+ case VARIABLE_ID_BOOT_MANAGER:
+ // For Boot Override Case
+ if( (control->ControlType == CONTROL_TYPE_SUBMENU) &&
+ (control->ControlPageID == control->ControlDestPageID) )
+ {
+ // YES it is boot Over Ride.
+ // Find the Index and Try to Boot to it
+ Index = UefiTseLiteGetBootOverRideIndex(control->ControlConditionalPtr);
+ if(Index != 0xFFFF)
+ {
+ if(!gResetRequired)
+ {
+ if(!gDoNotBoot)
+ {
+ gApp->ClearScreen = TRUE;
+ gST->ConOut->SetAttribute (gST->ConOut, (EFI_BACKGROUND_BLACK | EFI_WHITE));
+ BootLaunchBootNow( Index,(BOOLEAN)gShowAllBbsDev );
+ }
+ }
+ else
+ {
+ gApp->Quit = SaveAndReset();
+ }
+ status = TRUE;
+ }
+ }
+
+ break;
+ case VARIABLE_ID_AMI_CALLBACK:
+ if( (control->ControlType == CONTROL_TYPE_SUBMENU) &&
+ (control->ControlPageID == control->ControlDestPageID) )
+ {
+ Index = UefiTseLiteGetAmiCallbackIndex(control->ControlConditionalPtr, control->ControlPtr);
+ if(Index != 0xFFFF)
+ {
+ status = _SubMenuAmiCallback( Index );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SubMenuAmiCallback
+//
+// Description: Function to handle the exit page options.
+//
+// Input: UINT16 value
+//
+// Output: TRUE/FALSE.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _SubMenuAmiCallback( UINT16 value )
+{
+ BOOLEAN status = TRUE;
+
+ gApp->Fixed = TRUE;
+ switch ( value )
+ {
+ case SAVE_AND_EXIT_VALUE:
+ gApp->Quit = SaveAndExit();
+ break;
+ case DISCARD_AND_EXIT_VALUE:
+ gApp->Quit = ExitApplication();
+ break;
+ case SAVE_AND_RESET_VALUE:
+ gApp->Quit = SaveAndReset();
+ break;
+ case DISCARD_AND_RESET_VALUE:
+ gApp->Quit = ResetSys();
+ break;
+ case SAVE_VALUE:
+ SaveWithoutExit();
+ break;
+ case DISCARD_VALUE:
+ LoadPreviousValues( TRUE );
+ break;
+ case RESTORE_DEFAULTS_VALUE:
+ LoadOptimalDefaults();
+ break;
+ case SAVE_BOOT_OPTION:
+ TseBootAddBootOption();
+ break;
+
+ default:
+ status = FALSE;
+ break;
+ }
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupPasswordFormCallback
+//
+// Description: Function to handle PopupPassword form callbacks.
+//
+// Input: CONTROL_INFO * pControlData, UINT16 Key, UINT8 Flags
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupPasswordFormCallback(CONTROL_INFO * pControlData, UINT16 Key, UINT8 Flags)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupEditHandlePassword
+//
+// Description: Function to handle PopupEdit password.
+//
+// Input: VOID *pPopupEdit, VOID *pData
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupEditHandlePassword( VOID *pPopupEdit, VOID *pData)
+{
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TseLiteIsSpecialOptionList
+//
+// Description: Function that decided to re evaluate the option list/Name from the Vfr.
+// For TSE Special Controls it should return TRUE. for other controls it may return FALSE.
+// For UEFI 2.0 it may return TRUE by default.
+//
+// Input: NONE
+//
+// Output: Boolean
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN TseLiteIsSpecialOptionList(CONTROL_DATA *ControlData)
+{
+ UINT32 CtrlCondVariable=0xFFFF, CtrlVariable=0xFFFF;
+ CONTROL_INFO *control;
+
+ control = &(ControlData)->ControlData;
+ CtrlCondVariable = GetControlConditionVarId(control);
+ CtrlVariable = _GetControlVariable(control);
+
+ switch( CtrlCondVariable)
+ {
+ case VARIABLE_ID_ADD_BOOT_OPTION:
+ if( ( CheckForAddDelBootOption() ) && (control->ControlType == CONTROL_TYPE_POPUPSEL) )
+ return TRUE;
+ break;
+ case VARIABLE_ID_BOOT_MANAGER:
+ // For Boot Order Case
+ if(( CtrlVariable == VARIABLE_ID_BOOT_ORDER) &&
+ ((control->ControlType == CONTROL_TYPE_ORDERED_LIST)||(control->ControlType == CONTROL_TYPE_POPUPSEL)))
+ return TRUE;
+
+ if( ( CheckForAddDelBootOption() ) &&
+ ( CtrlVariable == VARIABLE_ID_DEL_BOOT_OPTION ) &&
+ ( control->ControlType == CONTROL_TYPE_POPUPSEL ) )
+ return TRUE;
+ break;
+ case VARIABLE_ID_LEGACY_DEV_INFO:
+ if(( CtrlVariable == VARIABLE_ID_BBS_ORDER) &&
+ ((control->ControlType == CONTROL_TYPE_ORDERED_LIST)||(control->ControlType == CONTROL_TYPE_POPUPSEL)))
+ return TRUE;
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMsgBoxEx
+//
+// Description: Function to show messagebox
+//
+// Input: IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostMsgBoxEx(
+IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN MSGBOX_EX_CATAGORY MsgBoxExCatagory,
+ IN UINT8 MsgBoxType,
+ IN UINT16 *OptionPtrTokens,
+ IN UINT16 OptionCount,
+ IN AMI_POST_MGR_KEY *HotKeyList,
+ IN UINT16 HotKeyListCount,
+ OUT UINT8 *MsgBoxSel,
+ OUT AMI_POST_MGR_KEY *OutKey
+)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMsgBox
+//
+// Description: Function to show messagebox
+//
+// Input: IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostMsgBox(IN CHAR16 *MsgBoxTitle,IN CHAR16 *Message,IN UINT8 MsgBoxType, UINT8 *pSelection)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: ShowPostTextBox
+//
+// Description: Function to display text entry interface
+//
+//
+// Input: IN VOID *HiiHandle,
+// IN UINT16 TitleToken,
+// IN TEXT_INPUT_TEMPLATE *InputData,
+// IN UINT16 ItemCount,
+// IN DISPLAY_TEXT_KEY_VALIDATE ValidateKeyFunc
+//
+// Output: EFI_STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostTextBox(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN TEXT_INPUT_TEMPLATE *InputData,
+ IN UINT16 ItemCount,
+ IN DISPLAY_TEXT_KEY_VALIDATE FilterKeyFunc
+)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMsgBox
+//
+// Description: Function to show InfoBox
+//
+// Input: IN CHAR16 *InfoBoxTitle, IN CHAR16 *Message, IN UINTN TimeLimit, EFI_EVENT *RetEvent
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowInfoBox(IN CHAR16 *InfoBoxTitle, IN CHAR16 *Message, IN UINTN TimeLimit, EFI_EVENT *RetEvent)
+{
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostProgress
+//
+// Description: Function to display the progress bar
+//
+// Input: IN UINT8 ProgressBoxState - Progress bar state
+// IN CHAR16 *Title - Progress bar title
+// IN CHAR16 *Message, - Progress bar message string
+// IN CHAR16 *Legend, - Progress bar legend string
+// IN UINTN Percent, - Percent Complete (0 - 100)
+// IN OUT VOID **Handle, - HANDLE. Valid Handle for update and close
+// OUT AMI_POST_MGR_KEY *OutKey - Out Key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostProgress(
+ IN UINT8 ProgressBoxState,
+ IN CHAR16 *Title,
+ IN CHAR16 *Message,
+ IN CHAR16 *Legend,
+ IN UINTN Percent,
+ IN OUT VOID **Handle,
+ OUT AMI_POST_MGR_KEY *OutKey
+)
+{
+ return EFI_UNSUPPORTED;
+}
+
+///AMIKeyCode protocol based...
+EFI_STATUS _ActionReadKey( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout );
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ActionReadKey
+//
+// Description: Function to read action key
+//
+// Input: AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ActionReadKey (AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout)
+{
+#if TSE_USE_OEM_ACTION_READ_KEY
+ return _OemActionReadKey (pAmiKey, Timeout);
+#else
+ return _ActionReadKey (pAmiKey, Timeout);
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AMIReadKeyStroke
+//
+// Description: Function to read key strokes
+//
+// Input: EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData)
+{
+ return gST->ConIn->ReadKeyStroke( gST->ConIn, Key );
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HelperIsPasswordCharValid
+//
+// Description: Function to check for valid password character
+//
+// Input: EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar)
+{
+ if ( CheckIsAllowedPasswordChar(Key->UnicodeChar) && ( StrIndex < PasswordLength ) )
+ {
+ *OutChar = Key->UnicodeChar;
+ return EFI_SUCCESS;
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsToggleStateKey
+//
+// Description: function to check Is any of ToggleStateKey (CapsLock,Numlock ScrollLock) Keys pressed.
+//
+// Input: ACTION_DATA *Data
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsToggleStateKey(ACTION_DATA *Data)
+{
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ // Normal EFI_KEY will return ScanCode and Unicode as 0 for this toggleStateKeys.
+ if(Data->Input.Data.AmiKey.Key.ScanCode || Data->Input.Data.AmiKey.Key.UnicodeChar)
+ return FALSE;
+ else
+ return TRUE;
+ }
+ else
+ return FALSE;
+
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateBootVariables
+//
+// Description: Dummy function for UpdateBootVariables
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateBootVariables ()
+{
+ // There is some issue with TSE Lite with bellow calls. So adding as a dummy function.
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateDriverVariables
+//
+// Description: Dummy function for UpdateDriverVariables
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdateDriverVariables () //EIP70421 & 70422 Support for driver order
+{
+ // There is some issue with TSE Lite with bellow calls. So adding as a dummy function.
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/UefiAction.c b/EDK/MiniSetup/TseLite/UefiAction.c
new file mode 100644
index 0000000..5f822a7
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/UefiAction.c
@@ -0,0 +1,498 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/UefiAction.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 17 $
+//
+// $Date: 5/01/14 3:46p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/UefiAction.c $
+//
+// 17 5/01/14 3:46p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 16 4/23/14 2:55a Premkumara
+// [TAG] EIP153045
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] After selecting UEFI action control either by mouse/key and
+// try to exit application, TSE is not prompting "Save and Reset" message
+// to reset the system
+// [RootCause] When RESET_REQUIRED flag is set for text control TSE is
+// not setting gResetRequired flag for Interactive Text control(Action
+// type control).
+// [Solution] Setting gResetRequired flag for action type controls when
+// action type controls is selected or modified either using mouse/Key.
+// [Files] UefiAction.c
+//
+// 15 2/11/14 8:48p Arunsb
+// [TAG] EIP147140
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] UefiActionHandleAction() doesnt handle mouse clicks
+// [Root Cause] The function UefiActionHandleAction doesnt handle mouse
+// actions
+// [Solution] Added mouse action handling support to the function
+// UefiActionHandleAction
+// [Files] UefiAction.c
+//
+// 14 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 13 12/01/11 7:42a Rajashakerg
+// [TAG] EIP75464
+// [Category] Improvement
+// [Description] Improper handling of action controls
+// [Files] SubMenu.c, UefiAction.c, HiiCallback.c, Uefi21Wapper.c
+//
+// 12 11/30/11 12:29a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 11 11/28/11 5:01a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 10 11/21/11 10:47a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 9 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 8 3/21/11 12:48a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 2/01/11 7:34p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 5 12/02/10 5:21p Madhans
+// [TAG] - EIP 49557
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- UEFIAction controls does not work correctly.
+// [Rootcause] - Action controls does not Process the QuestionResp
+// correctly.
+// [Solution]- Fix done UEFIAction to check for QuestionResp and call the
+// callback
+// [Files] - uefiaction.c and uefi21wapper.c
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: UefiAction.c
+//
+// Description: This file contains code to handle the uefi actions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "Minisetup.h"
+
+UEFI_ACTION_METHODS gUefiAction =
+{
+ UefiActionCreate,
+ LabelDestroy,
+ UefiActionInitialize,
+ UefiActionDraw,
+ UefiActionHandleAction,
+ LabelSetCallback,
+ LabelSetFocus,
+ LabelSetPosition,
+ LabelSetDimensions,
+ LabelSetAttributes,
+ LabelGetControlHeight
+};
+
+EFI_STATUS _ProcessActionCallback(CONTROL_INFO * ControlData, BOOLEAN InteractiveText);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiActionCreate
+//
+// Description: Function to create an Action Control.
+//
+// Input: VOID **object
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiActionCreate( VOID **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(UEFI_ACTION_DATA) );
+
+ if ( *object == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ ((UEFI_ACTION_DATA*)(*object))->Methods = &gUefiAction;
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiActionInitialize
+//
+// Description: Function to Initialize an Action Control.
+//
+// Input: VOID *object, VOID *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiActionInitialize( VOID *object, VOID *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UEFI_ACTION_DATA *Action = (UEFI_ACTION_DATA*) object;
+
+ Status = gControl.Initialize( Action, data );
+ if (EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ // add extra initialization here...
+ Action->Interval = (UINT8)Action->ControlData.ControlFlags.ControlRefresh;
+ Action->ControlData.ControlHelp = Action->ControlData.ControlHelp? Action->ControlData.ControlHelp :
+ UefiGetHelpField(Action->ControlData.ControlPtr);
+
+ SetControlColorsHook(NULL, NULL, NULL, NULL, &(Action->SelBGColor), &(Action->SelFGColor),
+ &(Action->BGColor), &(Action->FGColor), NULL, NULL, NULL, NULL, NULL, NULL, NULL );
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiActionDraw
+//
+// Description: Function to draw an Action Control.
+//
+// Input: VOID *object
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiActionDraw( VOID *object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UEFI_ACTION_DATA *Action = (UEFI_ACTION_DATA*) object;
+
+ CHAR16 *text;
+ UINT16 token = 0;
+ UINT8 ColorLabel = Action->FGColor;
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( Action->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &Action->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ break;
+ }
+ //}
+
+ token = UefiGetPromptField(Action->ControlData.ControlPtr);
+ text = HiiGetString( Action->ControlData.ControlHandle, token);
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == text){
+ text = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!text)
+ return EFI_NOT_FOUND;
+ EfiStrCpy(text,L" ");
+ }
+
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(Action->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( Action->Left , Action->Top,
+ (UINTN)(Action->Width),(UINTN) Action->Height,
+ text,(UINT8)( (Action->ControlFocus) ?
+ Action->SelBGColor | Action->SelFGColor :
+ Action->BGColor | ColorLabel ));
+ }
+ else
+ {
+ // use frame width minus margins as available space
+ // boundary overflow check
+ if ( (TestPrintLength( text) / (NG_SIZE)) > (UINTN)(Action->Width))
+ text[HiiFindStrPrintBoundary(text,(UINTN)(Action->Width))] = L'\0';
+
+ DrawStringWithAttribute( Action->Left , Action->Top, text,
+ (UINT8)( (Action->ControlFocus) ?
+ Action->SelBGColor | Action->SelFGColor :
+ Action->BGColor | ColorLabel /*Action->FGColor*/ ));
+ }
+
+ MemFreePointer( (VOID **)&text );
+ FlushLines( Action->Top , Action->Top );
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiActionHandleAction
+//
+// Description: Function to handle the Label actions.
+//
+// Input: VOID *object, ACTION_DATA *data
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiActionHandleAction(VOID *object, ACTION_DATA *data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UEFI_ACTION_DATA *Action = (UEFI_ACTION_DATA*) object;
+ UINT16 Value = 0;
+ BOOLEAN Selected = FALSE;
+
+ if (data->Input.Type == ACTION_TYPE_MOUSE) //EIP-147140
+ {
+ if(ControlActionSelect == MapControlMouseActionHook(&data->Input.Data.MouseInfo))
+ //EIP-123727 check whether MouseTop is within the Height and Width of Interactive Text Control or not
+ if((data->Input.Data.MouseInfo.Top >= (UINT32)Action->Top) && (data->Input.Data.MouseInfo.Top < (UINT32)(Action->Top+Action->Height)) &&
+ (data->Input.Data.MouseInfo.Left >= (UINT32)Action->Left) && (data->Input.Data.MouseInfo.Left < (UINT32)(Action->Left+Action->Width))
+ )
+ {
+ Selected = TRUE;
+ }
+ }
+
+ if ( data->Input.Type == ACTION_TYPE_KEY )
+ {
+ if ( ControlActionSelect == MapControlKeysHook(data->Input.Data.AmiKey) )
+ Selected = TRUE;
+ }
+
+ if (Selected )
+ {
+ MouseStop();
+
+ if (Action->ControlData.ControlFlags.ControlReset) //EIP-153045 Showing Save & Reset when Interactive text control is selected and try to exit TSE
+ gResetRequired = TRUE;
+
+ //Process UefiAction QuestionConfig
+ Status = ProcessActionQuestionConfiguration(&Action->ControlData);
+
+ if(EFI_ERROR(Status))
+ {
+ //goto DONE;
+ }
+ //Process UefiAction Callback if any
+ Status = _ProcessActionCallback(&Action->ControlData, FALSE);
+ return EFI_SUCCESS; //EIP75464 :Status from previous functions are already been handled. So return EFI_SUCCESS
+ }
+
+ if ( data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if(--Action->Interval == 0)
+ {
+ Action->Interval = (UINT8)Action->ControlData.ControlFlags.ControlRefresh;
+ Value = UefiTseLiteGetAmiCallbackIndex(Action->ControlData.ControlConditionalPtr,Action->ControlData.ControlPtr );
+ if(Value == INTERACTIVE_TEXT_VALUE)
+ {
+ //Process UefiAction Callback if any
+ Status = _ProcessActionCallback(&Action->ControlData, TRUE);
+ }
+ else
+ return EFI_SUCCESS; // If it is not Interactive Test just do the Redraw
+ }
+ }
+
+//DONE:
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ProcessActionCallback
+//
+// Description: Function process action callbacks
+//
+// Input: CONTROL_INFO * ControlData, BOOLEAN InteractiveText
+//
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ProcessActionCallback(CONTROL_INFO * ControlData, BOOLEAN InteractiveText)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if(UefiIsInteractive(ControlData))
+ {
+ if(InteractiveText)
+ {
+ Status = SpecialActionCallBack(ControlData, UefiGetControlKey(ControlData));
+ }else
+ {
+ UefiPreControlUpdate(NULL);
+ Status = CallFormCallBack(ControlData, UefiGetControlKey(ControlData), FALSE, AMI_CALLBACK_CONTROL_UPDATE);////EIP-53480: Implementation of FormBrowser with actions support
+ }
+ }
+
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/UefiAction.h b/EDK/MiniSetup/TseLite/UefiAction.h
new file mode 100644
index 0000000..a0f067f
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/UefiAction.h
@@ -0,0 +1,119 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/UefiAction.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:03a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/UefiAction.h $
+//
+// 5 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 7/31/09 6:35p Presannar
+// Remove Include Tiano.h and instead include Minisetup.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: UefiAction.h
+//
+// Description: Header file for UefiAction data
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _UEFI_ACTION_H_
+#define _UEFI_ACTION_H_
+
+#include "minisetup.h"
+
+#include "control.h"
+#include "action.h"
+
+typedef struct _UEFI_ACTION_METHODS UEFI_ACTION_METHODS;
+
+#define UEFI_ACTION_MEMBER_VARIABLES \
+ LABEL_MEMBER_VARIABLES \
+ UINT8 Interval;
+
+typedef struct _UEFI_ACTION_DATA
+{
+ UEFI_ACTION_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ UEFI_ACTION_MEMBER_VARIABLES
+}
+UEFI_ACTION_DATA;
+
+#define UEFI_ACTION_METHOD_FUNCTIONS
+
+struct _UEFI_ACTION_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ LABEL_METHOD_FUNCTIONS
+ UEFI_ACTION_METHOD_FUNCTIONS
+};
+
+extern UEFI_ACTION_METHODS gUefiAction;
+
+// Object Methods
+EFI_STATUS UefiActionCreate( VOID **object );
+EFI_STATUS UefiActionInitialize( VOID *object, VOID *data );
+EFI_STATUS UefiActionDraw( VOID *object );
+EFI_STATUS UefiActionHandleAction(VOID *object, ACTION_DATA *Data);
+
+#endif /*#ifndef _UEFI_ACTION_H_*/
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/action.h b/EDK/MiniSetup/TseLite/action.h
new file mode 100644
index 0000000..313f9fd
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/action.h
@@ -0,0 +1,163 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/action.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/action.h $
+//
+// 5 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Action.h
+//
+// Description: Header file for code to handle different actions.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _ACTION_H_
+#define _ACTION_H_
+
+#include "Minisetup.h"
+#include "commonoem.h"
+#define ACTION_TYPE_NULL 0
+#define ACTION_TYPE_KEY 1
+#define ACTION_TYPE_TIMER 2
+#define ACTION_TYPE_MOUSE 3
+
+// In terms of 100ns units
+#define ONE_SEC 10000000
+
+typedef struct _ACTION_INPUT
+{
+ UINT16 Type;
+ union
+ {
+ AMI_EFI_KEY_DATA AmiKey;
+ UINT32 TimerCount;
+ MOUSE_INFO MouseInfo;
+ }
+ Data;
+}
+ACTION_INPUT;
+
+#define ACTION_MEMBER_VARIABLES \
+ ACTION_INPUT Input; \
+ UINT32 TimerCount; \
+ EFI_EVENT TimerEvent;
+
+typedef struct _ACTION_METHODS ACTION_METHODS;
+
+typedef struct _ACTION_DATA
+{
+ ACTION_METHODS *Methods;
+
+ ACTION_MEMBER_VARIABLES
+
+}
+ACTION_DATA;
+
+typedef EFI_STATUS (*ACTION_METHOD_CREATE) ( ACTION_DATA **object );
+typedef EFI_STATUS (*ACTION_METHOD_DESTROY) ( ACTION_DATA *object, BOOLEAN freeMem );
+typedef EFI_STATUS (*ACTION_METHOD_GET_ACTION) ( ACTION_DATA *object );
+typedef EFI_STATUS (*ACTION_METHOD_CLEAR_ACTION) ( ACTION_DATA *object );
+
+#define ACTION_METHOD_FUNCTIONS \
+ ACTION_METHOD_CREATE Create; \
+ ACTION_METHOD_DESTROY Destroy; \
+ ACTION_METHOD_GET_ACTION GetAction; \
+ ACTION_METHOD_CLEAR_ACTION ClearAction;
+
+struct _ACTION_METHODS
+{
+ ACTION_METHOD_FUNCTIONS
+};
+
+extern ACTION_METHODS gAction;
+
+// Action Methods
+EFI_STATUS ActionCreate( ACTION_DATA **object );
+EFI_STATUS ActionDestroy( ACTION_DATA *object, BOOLEAN freeMem );
+EFI_STATUS ActionGetAction( ACTION_DATA *object );
+EFI_STATUS ActionClearAction( ACTION_DATA *object );
+
+//
+// Internal functions
+//
+
+EFI_STATUS _ActionReadKey( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout );
+VOID _ActionTimer( EFI_EVENT Event, VOID *Context );
+VOID _ActionInstallTimer( ACTION_DATA *object, UINT64 TriggerTime );
+
+#endif /* _ACTION_H_ */
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/application.c b/EDK/MiniSetup/TseLite/application.c
new file mode 100644
index 0000000..0ede072
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/application.c
@@ -0,0 +1,436 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/application.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 12 $
+//
+// $Date: 5/03/14 4:33p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/application.c $
+//
+// 12 5/03/14 4:33p Arunsb
+// Build error rectified
+//
+// 11 5/03/14 3:38p Arunsb
+// [TAG] EIP154569
+// [Category] Improvement
+// [Description] Handling clicks in application level for 80*25 mode also.
+// [Files] LegacyBin.sdl. EzportBin.sdl, EzportPlusBin.sdl and
+// application.c
+//
+// 10 9/19/13 8:01a Arunsb
+// [TAG] EIP127375
+// [Category] Bug Fix
+// [Severity:] Critical
+// [Symptom:] Legacy boot doesn't work after UEFI Shell is launched from
+// LaunchAppHotkey menu. The system hangs
+// [Root Cause] If ShowPostMsgBoxEx is invoked through postmgr protcol
+// then gMsgBoxAction will be NULL initially,
+// so this time action is assigned and used.
+// ACTION_DATA *action = gMsgBoxAction; so accessing NULL pointer leads to
+// hang.
+// [Solution] gMsgBoxAction is created again inside ShowPostMsgBoxEx,
+// reassign gMsgBoxAction to action.
+// [Files] TseAdvanced.c
+//
+// 9 5/22/13 10:40a Arunsb
+// [TAG] EIP122907
+// [Category] Improvement
+// [Description] For getting name value offset preserving page number
+// then it will be easy to find handle of the hii which published name
+// value.
+//
+// 8 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 6/29/11 6:21p Rajashakerg
+// Updated the file for Hotkey and hotclicks to return their exact status
+//
+// 6 6/29/11 12:52p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 5 3/26/10 5:06p Madhans
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:25a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/19/09 12:58p Madhans
+// To handle ToggleStateKeys
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Application.c
+//
+// Description: This file contains code to handle Application.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+APPLICATION_METHODS gApplication =
+{
+ ApplicationCreate,
+ ApplicationDestroy,
+ ApplicationInitialize,
+ ApplicationEmptyMethod,
+ ApplicationHandleAction,
+ ApplicationSetCallback,
+ ApplicationAddPage
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ApplicationCreate
+//
+// Description: Function to create an application, which uses the Object functions.
+//
+// Input: APPLICATION_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ApplicationCreate( APPLICATION_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(APPLICATION_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+ if ( EFI_ERROR( Status ) )
+ {
+ MemFreePointer( (VOID **)object );
+ return Status;
+ }
+
+ (*object)->Methods = &gApplication;
+ (*object)->CompleteRedraw = TRUE;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ApplicationDestroy
+//
+// Description: Function to destroy an application, which uses the Object functions.
+//
+// Input: APPLICATION_DATA *app, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ApplicationDestroy( APPLICATION_DATA *app, BOOLEAN freeMem )
+{
+ UINT32 i;
+
+ if ( app->Action )
+ gAction.Destroy( app->Action, TRUE );
+
+ app->Action = NULL;
+ gMsgBoxAction = NULL; //EIP127375, if not made NULL here, then TSE will try to use the freed memory in above step.
+
+ for ( i = 0; i < app->PageCount; i++ )
+ if(app->PageList[i] !=NULL)
+ gPage.Destroy( app->PageList[i], TRUE );
+
+ if ( app->PageList )
+ MemFreePointer( (VOID **)&app->PageList );
+
+ for ( i = 0; i < app->HotKeyCount; i++ )
+ gHotKey.Destroy( app->HotKeyList[i], TRUE );
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ for ( i = 0; i < app->HotClickCount; i++ )
+ gHotClick.Destroy( app->HotClickList[i], TRUE );
+
+ if ( app->HotKeyList )
+ MemFreePointer( (VOID **)&app->HotKeyList );
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ if ( app->HotClickList )
+ MemFreePointer( (VOID **)&app->HotClickList );
+
+
+ gObject.Destroy( app, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&app );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS ApplicationEmptyMethod( APPLICATION_DATA *app )
+{
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ApplicationInitialize
+//
+// Description: Function to initialize an application, which uses the Object functions.
+//
+// Input: APPLICATION_DATA *app, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+extern UINT32 gtempCurrentPage;
+EFI_STATUS ApplicationInitialize( APPLICATION_DATA *app, VOID *data )
+{
+ EFI_STATUS Status;
+
+ UINT32 i;
+
+ Status = gAction.Create( &app->Action );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ if ( gPages->PageCount == 0 )
+ return EFI_OUT_OF_RESOURCES;
+
+ for ( i = 0; i < gPages->PageCount; i++ )
+ {
+ if (NULL == gApp)
+ {
+ gtempCurrentPage = i; //Will be used in UefiGetQuestionOffset. Since gApp will not be filled but we need handle to find name value variable so
+ } //saving current page
+ else
+ {
+ gApp->CurrentPage = i;
+ }
+ ApplicationAddPage( app, (UINT8 *)data + gPages->PageList[i] );
+ }
+
+ app->HotKeyList = EfiLibAllocateZeroPool( sizeof(HOTKEY_DATA *) * gHotKeyCount );
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ app->HotClickList = EfiLibAllocateZeroPool( sizeof(HOTCLICK_DATA *) * gHotClickCount );
+
+ if ( app->HotKeyList == NULL )
+ return Status;
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ if ( app->HotClickList == NULL )
+ return Status;
+
+ app->HotKeyCount = gHotKeyCount;
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ app->HotClickCount = gHotClickCount;
+
+ for ( i = 0; i < app->HotKeyCount; i++ )
+ {
+ if ( gHotKey.Create( &app->HotKeyList[i] ) != EFI_SUCCESS )
+ continue;
+
+ gHotKey.Initialize( app->HotKeyList[i], &gHotKeyInfo[i] );
+ gHotKey.SetCallback( app->HotKeyList[i], app, gHotKeyInfo[i].Callback, NULL );
+ }
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ for ( i = 0; i < app->HotClickCount; i++ )
+ {
+ if ( gHotClick.Create( &app->HotClickList[i] ) != EFI_SUCCESS )
+ continue;
+
+ gHotClick.Initialize( app->HotClickList[i], &gHotClickInfo[i] );
+ gHotClick.SetCallback( app->HotClickList[i], app, gHotClickInfo[i].Callback, NULL );
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ApplicationHandleAction
+//
+// Description: Function to handle the application actions.
+//
+// Input: APPLICATION_DATA *app, ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ApplicationHandleAction( APPLICATION_DATA *app, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT32 i;
+
+ for ( i = 0; i < app->HotKeyCount; i++ )
+ {
+ Status = gHotKey.HandleAction( app->HotKeyList[i], action );
+
+ if ( ! EFI_ERROR(Status) )
+ goto DONE;
+ }
+
+//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+ if ((31 == gMaxRows) && (100 == gMaxCols))
+ {
+ for ( i = 0; i < app->HotClickCount/2; i++ )
+ {
+ Status = gHotClick.HandleAction( app->HotClickList[i], action );
+
+ if ( ! EFI_ERROR(Status) )
+ return Status;
+ }
+ }
+ else if ((24 == gMaxRows) && (80 == gMaxCols))
+ {
+ for ( i = (UINT32)(app->HotClickCount/2); i < (app->HotClickCount-1); i++ )
+ {
+ Status = gHotClick.HandleAction( app->HotClickList[i], action );
+
+ if ( ! EFI_ERROR(Status) )
+ return Status;
+ }
+ }
+DONE:
+ if(Status!=EFI_SUCCESS && IsToggleStateKey(action))
+ Status = EFI_SUCCESS;
+
+ return Status;
+}
+
+EFI_STATUS ApplicationSetCallback( APPLICATION_DATA *app, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( app, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ApplicationAddPage
+//
+// Description: Function to add a page to the application.
+//
+// Input: APPLICATION_DATA *app, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ApplicationAddPage( APPLICATION_DATA *app, VOID *data )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+ PAGE_DATA **page;
+ UINT32 count = app->PageCount;
+
+ page = MemReallocateZeroPool( app->PageList, count * sizeof(PAGE_DATA *), (count + 1) * sizeof(PAGE_DATA *) );
+ if ( page == NULL )
+ return Status;
+
+ app->PageList = page;
+ page = &app->PageList[ count ];
+
+ if( ((PAGE_INFO*)data)->PageHandle == 0)
+ {
+ app->PageCount++;
+ //return EFI_SUCCESS , page space left , but no page to create.
+ return EFI_SUCCESS;
+ }
+
+ Status = gPage.Create( page );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ Status = gPage.Initialize( *page, data );
+ if ( ! EFI_ERROR( Status ) )
+ app->PageCount++;
+ else
+ {
+ gPage.Destroy( *page, TRUE );
+ *page = NULL;
+ }
+ }
+
+ return Status;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/application.h b/EDK/MiniSetup/TseLite/application.h
new file mode 100644
index 0000000..2ba7b07
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/application.h
@@ -0,0 +1,180 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/application.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/application.h $
+//
+// 7 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 6/29/11 12:54p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Application.h
+//
+// Description: Header file for code to handle Application.
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _APPLICATION_H_
+#define _APPLICATION_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "action.h"
+#include "page.h"
+#include "hotkey.h"
+#include "hotclick.h"//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
+
+#define APPLICATION_MEMBER_VARIABLES \
+ ACTION_DATA *Action; \
+ UINT32 CurrentPage; \
+ UINT32 PageCount; \
+ PAGE_DATA **PageList; \
+ UINTN HotKeyCount; \
+ HOTKEY_DATA **HotKeyList; \
+ UINTN HotClickCount; \
+ HOTCLICK_DATA **HotClickList;\
+ BOOLEAN CompleteRedraw; \
+ BOOLEAN ClearScreen; \
+ BOOLEAN Quit; \
+ UINT32 OnRedraw;\
+ BOOLEAN Fixed;
+
+typedef struct _APPLICATION_METHODS APPLICATION_METHODS;
+
+typedef struct _APPLICATION_INFO
+{
+ UINT32 PageCount;
+}
+APPLICATION_INFO;
+
+typedef struct _APPLICATION_DATA
+{
+ APPLICATION_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ APPLICATION_MEMBER_VARIABLES
+
+}
+APPLICATION_DATA;
+
+typedef EFI_STATUS (*APPLICATION_METHOD_ADD_PAGE) ( APPLICATION_DATA *app, VOID *data );
+
+#define APPLICATION_METHOD_FUNCTIONS \
+ APPLICATION_METHOD_ADD_PAGE AddPage;
+
+struct _APPLICATION_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ APPLICATION_METHOD_FUNCTIONS
+};
+
+extern APPLICATION_METHODS gApplication;
+extern APPLICATION_DATA *gApp;
+
+// Object Methods
+EFI_STATUS ApplicationCreate( VOID **object );
+EFI_STATUS ApplicationDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS ApplicationInitialize( VOID *object, VOID *data );
+EFI_STATUS ApplicationEmptyMethod( VOID *object );
+EFI_STATUS ApplicationHandleAction( VOID *object, ACTION_DATA *Data );
+EFI_STATUS ApplicationSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Application Methods
+EFI_STATUS ApplicationAddPage( APPLICATION_DATA *app, VOID *data );
+
+#endif /* _APPLICATION_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/callback.c b/EDK/MiniSetup/TseLite/callback.c
new file mode 100644
index 0000000..1bd6f91
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/callback.c
@@ -0,0 +1,1341 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/callback.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 39 $
+//
+// $Date: 5/14/14 11:58a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/callback.c $
+//
+// 39 5/14/14 11:58a Arunsb
+// [TAG] EIP168723
+// [Description] Removed RT attribute for LegacyDevOrder variable.
+// [Files] bbs.c and callback.c
+//
+// 38 5/01/14 10:36p Arunsb
+// [TAG] EIP165284
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System Abnormal when execute Load Default (F9) in BIOS
+// Setup
+// [RootCause] For QF_DATE_STORAGE_TIME and QF_TIME_STORAGE_TIME the
+// offset will be 0xFFFF so trying to load default it hung
+// [Solution] Checked the condition for 0xFFFF
+// [Files] callback.c
+//
+// 37 2/11/14 8:29p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 36 10/07/13 6:40a Premkumara
+// Checked-in proper changes
+//
+// 35 10/07/13 5:29a Premkumara
+// [TAG] EIP126466
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BBSOrdre is not saving when Customized SetupMenu is used
+// (FixedBootOrder)
+// [RootCause] gBootData is NULL so causing crashing
+// [Solution] Checked for NULL and proceed with next BootData instead of
+// iterating for next boot data
+// [Files] TseLite\Callback.c
+//
+// 34 10/04/13 4:35p Arunsb
+// [TAG] EIP136259
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Restore Optimized Defaults doesn't work with IntelRCSetup
+// Page on TSE Label 5.004_AmiTse_2_16_1242
+// [RootCause] Non interactive controls also tried to get the default
+// through callback
+// [Solution] Interactive controls alone tried to get the default
+// through callback
+// [Files] callback.c
+//
+// 33 8/06/13 11:27p Arunsb
+// [TAG] EIP76394
+// [Category] Improvement
+// [Description] Support TSE Load/SaveUserDefaults call without
+// MesageBox
+// [Files] callback.c
+//
+// 32 7/02/13 10:08a Premkumara
+// [TAG] EIP120011
+// [Category] Improvement
+// [Description] Variable BootOrder and LegacyDevOrder need
+// fool-proofing function when TSE load variabled
+// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c
+//
+// 31 7/02/13 3:49a Premkumara
+// [TAG] EIP127017
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] On loading optimal defaluts (F3 key) causing setup crash
+// [RootCause] NULL is not checked properly for gCurrLegacyBootData
+// value in LoadDefaults and LoadPreviousValues function
+// [Solution] Handle NULL check for gCurrLegacyBootData
+// [Files] Callback.c
+//
+// 29 6/10/13 10:48a Arunsb
+// Evaluating default in _LoadDefaults supported.
+// Callback as manufacturing changed to standard.
+// Inconsistent and submitif controls handled properly in _LoadDefaults
+//
+// 28 5/22/13 10:58a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c
+//
+// 27 3/12/13 12:27p Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 26 3/12/13 7:01a Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 25 2/12/13 8:38a Arunsb
+// [TAG] EIP114800
+// [Category] Improvement
+// [Description] _SaveValues without MessageBox. If data param passed as
+// NULL then message box wont be displayed.
+// [Files] TseLite\callback.c
+//
+// 24 2/06/13 9:02a Arunsb
+// Checked in properly
+//
+// 24 1/31/13 12:52p Arunsb
+// [TAG] EIP109382
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Boot Device name incorrect when load default
+// [RootCause] Legacy offset in gbootdata corrupted so names displayed
+// improperly.
+// [Solution] Legacy offsets re-calculated properly
+// [Files] CommonHelper.c, BootOnly\bbs.c and callback.c
+//
+// 23 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 18 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 22 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 20 9/10/12 5:02a Rajashakerg
+// [TAG] EIP93881 and 93873
+// [Category] Improvement
+// [Description] need keep system password after Load default and
+// Password saved into NVRAM immediately(not buffer) while it is installed
+// in TSE
+// [Files] frame.c, callback.c, AMITSE.sdl, CommonHelper.c
+//
+// 19 5/29/12 4:38a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 18 1/24/12 4:39a Arunsb
+// [TAG] EIP81581
+// [Category] Improvement
+// [Description] Default driver order support
+// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and
+// variable.c
+//
+// 17 1/19/12 10:52a Arunsb
+// [TAG] EIP79956
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Two boot option entries displayed with the single name
+// value
+// [RootCause] If defaults are loaded then boot order is trying to load
+// the improper boot order due to add boot option feature
+// [Solution] Boot order formed properly for add boot option case.
+// If no tsedefaultbootorder module present then gOptimalDefaults
+// [VARIABLE_ID_BOOT_ORDER] are saved properly in SaveAddDelBootOptions at
+// first time.
+// At first time optimal buffer is empty so it was filled with some junk
+// value so it is changed to fill the current variable list at first time
+// of saving with add boot option feature.
+// [Files] Addbootoption.c and callback.c
+//
+// 16 12/05/11 5:34a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 15 11/13/11 12:57p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 14 8/26/11 8:20a Arunsb
+// [TAG] EIP65859
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Default bootorder is not loading for loading defautls
+// [RootCause] Boot device count not updated after restart
+// [Solution] Boot device count updated after restart too
+// [Files] callback.c
+//
+// 13 6/22/11 9:33a Premkumara
+// [TAG] EIP57547
+// [Category] Improvement
+// [Description] TSE Feature to Silently Load Defaults, Including Boot
+// Order Defaults
+// [Files] Callback.c
+//
+// 12 6/20/11 11:52a Rajashakerg
+// [TAG] EIP59417
+// [Category] New Feature
+// [Description] Spport LOAD_OPTION_HIDDEN option in TSE
+// [Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
+// minisetup.h, special.c, callback.c
+//
+// 11 3/28/11 9:11p Premkumara
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+//
+//
+//
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 10 3/21/11 12:30a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 9 10/05/10 5:38p Madhans
+// [TAG] - EIP 45299
+// [Category]- Enhancment
+// [Severity]- Minor
+// [Symptom]- TSE by default saves the Disbaled BBS devices device path in
+// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on
+// this variable to consider the device as disabled inaddtion to
+// LegacyDevOrder.
+// Some BDS customized projects don't want this.
+// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to
+// control this option. Bydefault It is Enabled.
+// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl
+//
+// 8 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 7 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 6 3/26/10 5:25p Madhans
+// EIP 35562: Support To create Boot option in Capital letters.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 10 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 1/09/10 6:30a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 8 12/18/09 2:29p Madhans
+// EIP: 32350/32445 To fix the Add/Delete Boot option issues with TSE 2.0.
+// To load the boot manager variable when defaults are loaded.
+//
+// 7 10/09/09 10:21a Mallikarjunanv
+// updated by removing the PreSystemResetHook, this hook is moved to
+// MinisetupExt.c
+//
+// 6 10/07/09 11:20a Mallikarjunanv
+// Fix to EIP-25987(Load Optimized Defaults(F3) hangs with an empty page):
+// Added a condition to check whether the frame has any controls before
+// doing any operations on a control.
+//
+// 5 9/15/09 9:43a Sudhirv
+// updated the support of handling Add Del boot option and added hook
+// function call during reset
+//
+// 4 8/13/09 7:39a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:07p Madhans
+// 2.1 language support.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: callback.c
+//
+// Description: This file contains code to handle callbacks
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+ACTION_DATA *gMsgBoxAction;
+
+UINTN _CallbackGetValue( MSGBOX_DATA *msgbox );
+VOID _CallbackMsgbox( VOID *container, VOID *object, VOID *cookie );
+VOID _LoadDefaults( NVRAM_VARIABLE *defaults, UINTN data );
+BOOLEAN _SaveValues( UINTN data );
+BOOLEAN LoadDefaultsFromDefaultBuffer( VOID );
+
+extern UINTN gPreviousMsgBox;
+extern UINTN gFailsafeMsgBox;
+extern UINTN gOptimalMsgBox;
+extern UINTN gSaveMsgBox;
+extern UINTN gSaveExitMsgBox;
+extern UINTN gExitMsgBox;
+extern UINTN gSaveResetMsgBox;
+extern UINTN gResetMsgBox;
+extern UINTN gHelpMsgBox;
+extern UINTN gSaveUserMsgBox;
+extern UINTN gLoadUserMsgBox;
+extern BOOLEAN gBrowserCallbackEnabled;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadPreviousValues
+//
+// Description: Callback function for LoadPreviousValue.
+//
+// Input: Bool ShowMsgBox.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadPreviousValues( BOOLEAN showMsgBox )
+{
+ UINT8 result = MSGBOX_YES;
+ UINT16 CurrentBootOption=0;
+
+//- Fix for Screen corruption while editing Date/edit controls.
+ FRAME_DATA *MainFrame=NULL;
+//-
+
+ if ( showMsgBox )
+ result = CallbackShowMessageBox( (UINTN)gPreviousMsgBox, MSGBOX_TYPE_YESNO );
+
+ if ( result == MSGBOX_YES )
+ {
+ if(gCurrLegacyBootData)
+ {
+ UINT16 CurLegBootDataValid = 0;
+ UINT32 i;
+
+ // Check is gCurrLegacyBootData valid one
+ for (i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( &gBootData[i] == gCurrLegacyBootData )
+ CurLegBootDataValid = 1;
+ }
+ // If valid
+ if(CurLegBootDataValid)
+ CurrentBootOption = gCurrLegacyBootData->Option;
+ else
+ gCurrLegacyBootData = NULL;
+ }
+
+ CleanTempNvramVariableList(); //EIP 76381 : Reset to read the variable from NVRAM
+ VarLoadVariables( (VOID **)&gVariableList, NULL );
+
+ // special provisions needed for language
+ //VarSetValue( VARIABLE_ID_LANGUAGE, 0, 3, gPrevLanguage );
+ VarSetNvram ( VARIABLE_ID_LANGUAGE, gPrevLanguage,gPrevLangSize );
+
+ ///Hook to Load previous saved values
+ LoadedPreviousValuesHook();
+
+ PasswordCommitChanges( FALSE );
+
+ TseDiscardAddDelBootOptions();
+ TseDiscardAddDelDriverOptions(); //EIP70421 & 70422 Support for driver order
+ // reinit the gCurrLegacyBootData
+ //if(gCurrLegacyBootData)
+ //{
+ gCurrLegacyBootData = BootGetBootData(CurrentBootOption);
+ if(gCurrLegacyBootData) //EIP-127017 Avoid crashing when press F3 to load previous values
+ VarSetValue(VARIABLE_ID_LEGACY_GROUP_INFO, 0, sizeof(UINT16), &(gCurrLegacyBootData->LegacyDevCount));
+ //}
+
+ if ( ! gVariableChanged )
+ gResetRequired = FALSE;
+
+ UEFICallSetupFormCallBack(AMI_CALLBACK_RETRIEVE);//EIP-53480: Calling the Wraper function with action AMI_CALLBACK_RETRIEVE
+
+ //EIP-126057
+ if(gApp!=NULL)
+ {
+ //Recreate the special controls to reflect changes
+ gApp->CompleteRedraw = TRUE;
+
+ //- Fix for Screen corruption while editing Date/edit controls.
+ MainFrame = gApp->PageList[gApp->CurrentPage]->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ if(MainFrame->ControlCount)
+ if(MainFrame->CurrentControl != FRAME_NONE_FOCUSED)
+ if(MainFrame->ControlList[MainFrame->CurrentControl]->ControlActive == TRUE)
+ MainFrame->ControlList[MainFrame->CurrentControl]->ControlActive = FALSE;
+ // -
+ }
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadOptimalDefaults
+//
+// Description: Loads the optimal defaults.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadOptimalDefaults( VOID )
+{
+ ///Load optimal defaults modified as a hook
+ LoadSetupDefaultsHook( gOptimalDefaults, (UINTN)gOptimalMsgBox );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadFailsafeDefaults
+//
+// Description: Loads the failsafe defaults.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadFailsafeDefaults( VOID )
+{
+ ///Load Failsafe defaults modified as a hook
+ LoadSetupDefaultsHook( gFailsafeDefaults, (UINTN)gFailsafeMsgBox );
+}
+
+BOOLEAN TSEDonotLoadPasswordOnDefaults(VOID);//EIP 93881 & 93873 : Save pwd to nvram and not loading empty pwd on loading defaults.
+
+//EIP 105167 : START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _LoadDefaults
+//
+// Description: Loads the defaults with optimal or Failsafe data.
+//
+// Input: Bool ShowMsgBox.
+//
+// Output: none
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CsmRearrangeBBSOrder (VOID *nvPtr, VOID *DefaultBuffer);
+UINT16 EvaluateControlDefault (CONTROL_INFO *CtrlInfo, UINT64 *Defaults);
+VOID _LoadDefaults( NVRAM_VARIABLE *defaults, UINTN data )
+{
+ UINT32 i;
+ UINT16 CurrentBootOption=0;
+ EFI_STATUS Status;
+//- Fix for Screen corruption while editing Date/edit controls.
+ FRAME_DATA *MainFrame;
+//-
+
+ if ( data == (UINTN)NULL ?1:(CallbackShowMessageBox( data, MSGBOX_TYPE_YESNO ) == MSGBOX_YES) ) //EIP:57547 To avoid draw MessageBox when data is passed as NULL to load Defaults silently
+ {
+ UINT32 page, control;
+ gBrowserCallbackEnabled = TRUE;
+ if(gCurrLegacyBootData)
+ {
+ UINT16 CurLegBootDataValid = 0;
+
+ // Check is gCurrLegacyBootData valid one
+ for ( i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( &gBootData[i] == gCurrLegacyBootData )
+ CurLegBootDataValid = 1;
+ }
+ // If valid
+ if(CurLegBootDataValid)
+ CurrentBootOption = gCurrLegacyBootData->Option;
+ else
+ gCurrLegacyBootData = NULL;
+ }
+
+
+
+ for ( page = 0; page < gPages->PageCount; page++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+ UINTN Action;
+
+ if ( (NULL != pageInfo) && (0 == pageInfo->PageHandle) )
+ continue;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if( NULL == controlInfo || NULL == controlInfo->ControlPtr) //Suppressing inconsistent and nosubmit controls so added check for ControlPtr
+ continue;
+
+ Status = EFI_SUCCESS;
+ if (UefiIsInteractive (controlInfo))
+ {
+ Action = UefiGetActionWapper (AMI_CALLBACK_FORM_DEFAULT_STANDARD);
+ Status = CallFormCallBack (controlInfo, UefiGetControlKey (controlInfo), FALSE, Action);
+ }
+ if (
+ (!UefiIsInteractive (controlInfo) || (EFI_UNSUPPORTED == Status)) && //if interactive control returned unsupported then load defaults from buffer
+ (!controlInfo->ControlFlags.ControlEvaluateDefault) &&
+ (defaults[controlInfo->ControlVariable].Size > 0)
+ )
+ {
+ UINT32 offset = 0, size = 0;
+
+ if ((!LoadDefaultsFromDefaultBuffer ()) && (controlInfo->ControlDataWidth == 0)) //If defaults not present for a control but if the offset present
+ { //in the variable which has atleast default then
+ continue; //try to load it if TSE_LOAD_DEFAULTS_FROM_DEFAULTS_BUFFER
+ } //is enabled.
+ if (CONTROL_TYPE_ORDERED_LIST != controlInfo->ControlType)
+ {
+ size = UefiGetWidth(controlInfo->ControlPtr);
+ }
+ else
+ {
+ size = controlInfo->ControlDataWidth;
+ }
+ if (0 == size) //For text and submenu skip loading defaults
+ {
+ continue;
+ }
+ offset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+ if ((0xFFFF == offset) || ((offset + size) > defaults [controlInfo->ControlVariable].Size)) //QF_DATE_STORAGE_TIME and QF_TIME_STORAGE_TIME offsets will be 0xFFFF so we need to skip it
+ {
+ continue;
+ }
+ if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_DEL_BOOT_OPTION) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_ADD_BOOT_OPTION) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_USER_DEFAULTS) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_IDE_SECURITY) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_LEGACY_DEV_INFO) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_LEGACY_GROUP_INFO) ||
+ ( controlInfo->ControlVariable == VARIABLE_ID_ADD_DRIVER_OPTION) || //EIP70421 & 70422 Support for driver order
+ (controlInfo->ControlVariable == VARIABLE_ID_DEL_DRIVER_OPTION) ||
+ ( (TSEDonotLoadPasswordOnDefaults()) && (controlInfo->ControlVariable == VARIABLE_ID_AMITSESETUP) ) ) //EIP 93881 & 93873 : Save pwd to nvram and not loading empty pwd on loading defaults.
+ continue;
+ else if( ((defaults[controlInfo->ControlVariable].Buffer != NULL) && (defaults[controlInfo->ControlVariable].Size))
+ &&((VARIABLE_ID_BOOT_ORDER == controlInfo->ControlVariable) || (VARIABLE_ID_DRIVER_ORDER == controlInfo->ControlVariable))
+ )
+ {
+ MemCopy (gVariableList[controlInfo->ControlVariable].Buffer, defaults[controlInfo->ControlVariable].Buffer, defaults[controlInfo->ControlVariable].Size);
+ gVariableList[controlInfo->ControlVariable].Size = defaults[controlInfo->ControlVariable].Size;
+ }
+ else if (VARIABLE_ID_BBS_ORDER == controlInfo->ControlVariable) //EIP109382: Since boot order loads first legacydevorder corrupted so restructuring with gbootdata
+ {
+ if((defaults[controlInfo->ControlVariable].Buffer != NULL) && (defaults[controlInfo->ControlVariable].Size))
+ CsmRearrangeBBSOrder (&(gVariableList [controlInfo->ControlVariable]), &(defaults[controlInfo->ControlVariable]));
+ }
+ else
+ {
+ if((defaults[controlInfo->ControlVariable].Buffer != NULL) && (defaults[controlInfo->ControlVariable].Size))
+ MemCopy (gVariableList [controlInfo->ControlVariable].Buffer + offset, defaults[controlInfo->ControlVariable].Buffer + offset, size);
+ }
+ }
+ if(controlInfo->ControlFlags.ControlEvaluateDefault)
+ {
+ UINT64 Defaults = 0 ;
+ UINT16 size = 0;
+ UINT32 offset = 0;
+
+ offset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+
+ //EIP: 57402 Evaluating the Control Default
+ size = EvaluateControlDefault(controlInfo,&Defaults);
+ VarSetValue(controlInfo->ControlVariable, offset, size, &Defaults );
+ // EIP: 57402 Setiing the Evaluated value to the gOptimalDefaults
+ //if(DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING)
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, offset, size, &Defaults );
+ }
+ }
+ }
+
+ gBrowserCallbackEnabled = FALSE;
+ PasswordCommitChanges( FALSE );
+
+ TseDiscardAddDelBootOptions();
+ TseDiscardAddDelDriverOptions(); //EIP70421 & 70422 Support for driver order
+
+ // reinit the gCurrLegacyBootData
+// if(gCurrLegacyBootData) //(EIP61172) If defaults is loaded, boot order defaults is not loading after a restart. So commented.
+// { //(EIP61172)
+ gCurrLegacyBootData = BootGetBootData(CurrentBootOption);
+ if(gCurrLegacyBootData) //EIP-127017 Avoid crashing when press F3 to load defaults
+ VarSetValue(VARIABLE_ID_LEGACY_GROUP_INFO, 0, sizeof(UINT16), &(gCurrLegacyBootData->LegacyDevCount));
+// } //(EIP61172)
+
+ gResetRequired = TRUE;
+
+ LoadedConfigDefaultsHook();
+
+ //EIP-126057
+ if(gApp!=NULL)
+ {
+ //Recreate the special controls to reflect changes
+ gApp->CompleteRedraw = TRUE;
+
+ //- Fix for Screen corruption while editing Date/edit controls.
+ MainFrame = gApp->PageList[gApp->CurrentPage]->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+
+ //EIP-25987: Load Optimized Defaults(F3)hangs in a empty page || Fix: Check whether the frame has any controls before doing any operation on a control.
+ if(MainFrame->ControlCount)
+ if(MainFrame->CurrentControl != FRAME_NONE_FOCUSED)
+ if(MainFrame->ControlList[MainFrame->CurrentControl]->ControlActive == TRUE)
+ MainFrame->ControlList[MainFrame->CurrentControl]->ControlActive = FALSE;
+ // -
+ }
+ }
+}
+//EIP 105167 : END
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveAndExit
+//
+// Description: Function to save and exit
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN SaveAndExit( VOID )
+{
+ if ( _SaveValues( (UINTN)gSaveExitMsgBox ) )
+ {
+ gVariableChanged = TRUE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveWithoutExit
+//
+// Description: Function to save without exit
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveWithoutExit( VOID )
+{
+ if ( _SaveValues( (UINTN)gSaveMsgBox ) )
+ gVariableChanged = TRUE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveAndReset
+//
+// Description: Function to save and reset
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN SaveAndReset( VOID )
+{
+ if ( _SaveValues( (UINTN)gSaveResetMsgBox ) )
+ {
+ gVariableChanged = TRUE;
+ gResetRequired = TRUE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetSys
+//
+// Description: Function to reset
+//
+// Input: VOID
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN ResetSys( VOID )
+{
+ if ( CallbackShowMessageBox( (UINTN)gResetMsgBox, MSGBOX_TYPE_YESNO ) == MSGBOX_YES )
+ {
+ gResetRequired = TRUE; // force a reset
+ gVariableChanged = FALSE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SaveValues
+//
+// Description: Function to save the given values
+//
+// Input: UINTN data
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _SaveValues( UINTN data )
+{
+ UINT32 i;
+ NVRAM_VARIABLE *nvPtr;
+ EFI_GUID AmitseNvramUpdateGuid = AMITSE_NVRAM_UPDATE_GUID;
+ EFI_GUID AmitseBootOrderChangeGuid = AMITSE_BOOT_ORDER_CHANGE_GUID;
+
+ if (data == (UINTN)NULL ? 1 : (CallbackShowMessageBox (data, MSGBOX_TYPE_YESNO) == MSGBOX_YES) ) //To avoid draw MessageBox when data is passed as NULL to save data silently EIP114800
+ {
+ //Check for NO_SUBMIT_IF before saving data in every page
+ if(CheckNoSubmitIf())
+ {
+ return FALSE; //cant save Invalid Submit value
+ }
+ //EIP-126057
+ if(gApp!=NULL)
+ {
+ //Check for inconsistency before saving data
+ if(CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[gApp->CurrentPage])))
+ {
+ return FALSE; //cant save inconsistent value
+ }
+ }
+
+ if(gResetRequired)
+ { //Let's update the SaveState Variable
+ UINT32 SaveStateVarNum;
+ UINT16 SaveState=SETUP_SAVED_AND_RESET_REQUIRED;
+ if(VarGetVariableInfoId( SETUP_SAVE_STATE_INFO_KEY_ID, &SaveStateVarNum ))
+ VarSetValue(SaveStateVarNum,0,sizeof(UINT16),&SaveState);
+ }
+
+ nvPtr = gVariableList;
+ for ( i = 0; i < gVariables->VariableCount; i++, nvPtr++ )
+ {
+ if(VARIABLE_ID_BOOT_ORDER == i)
+ {
+ UINTN j,k=0,n=0, CurrSize = 0;
+ UINT16 *BootOrder = NULL, *CurrOrder = NULL;
+ BOOT_DATA *pBootData = NULL;
+
+ TseSaveAddDelBootOptions();
+
+ BootOrder = EfiLibAllocateZeroPool(nvPtr->Size);
+ MemCopy(BootOrder,nvPtr->Buffer,nvPtr->Size);
+
+ //Disable all options
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ if (!(gBootData[j].Active & LOAD_OPTION_HIDDEN)) //TSE will not do the option anything if it is hidden
+ {
+ gBootData[j].Active &= ~(LOAD_OPTION_ACTIVE);
+ }
+ }
+ //Enable options in BootOrder
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ pBootData = BootGetBootData(BootOrder[j]);
+ if(pBootData)
+ {
+ if (!(pBootData->Active & LOAD_OPTION_HIDDEN)) //TSE will not do the option anything if it is hidden
+ {
+ pBootData->Active |= LOAD_OPTION_ACTIVE;
+ }
+ }
+ }
+
+ //Save boot options
+ for(j=0;j<gBootOptionCount;j++)
+ {
+ CHAR16 varName[] = L"BootXXXX";
+ BOOT_OPTION *pOption;
+ UINTN OptionSize;
+
+ OptionSize = 0; pOption = NULL;
+ SPrint( varName, sizeof(CHAR16) * (EfiStrLen( varName )+1),gBootFormarSpecifier, gBootData[j].Option );
+ pOption = (BOOT_OPTION *)VarGetNvramName( varName, &gEfiGlobalVariableGuid, NULL, &OptionSize );
+
+ pOption->Active = gBootData[j].Active;
+
+ VarSetNvramName(varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ pOption,
+ OptionSize);
+
+ MemFreePointer((VOID **)&pOption);
+ }
+ n=0;
+ //Enabled options first
+ for(k=0;k<gBootOptionCount;k++)
+ {
+ if(DISABLED_BOOT_OPTION == BootOrder[k])
+ {
+ //add Disabled options
+ for(j=n; j < gBootOptionCount; j++ )
+ {
+ if ( (!(gBootData[j].Active & LOAD_OPTION_ACTIVE)) && (!(gBootData[j].Active & LOAD_OPTION_HIDDEN)) )
+ {
+ BootOrder[k] = gBootData[j].Option;
+ n=j;
+ n++;
+ break;
+ }
+ }
+ }
+
+ }
+
+ ASSERT(k==gBootOptionCount);
+
+ //Signal TPM if Boot order has changed
+ CurrOrder = VarGetNvramName(L"BootOrder", &gEfiGlobalVariableGuid, NULL, &CurrSize);
+
+ if( CurrSize != (k*sizeof(UINT16)) )
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+ else if(CurrOrder)
+ {
+ if (MemCmp((UINT8 *)CurrOrder, (UINT8 *)BootOrder, CurrSize))
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+ }
+
+ MemFreePointer((VOID **)&CurrOrder);
+
+ //Save boot order
+ VarSetNvramName(L"BootOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ BootOrder,
+ k * sizeof(UINT16));
+
+ MemFreePointer((VOID **) &BootOrder);
+
+ //Continue to next variable
+ continue;
+ }
+ //EIP70421 & 70422 Support for driver order starts
+ if(VARIABLE_ID_DRIVER_ORDER == i)
+ {
+ UINTN j, k=0, n=0;
+ UINT16 *DriverOrder = NULL;
+ BOOT_DATA *pDriverData = NULL;
+
+ TseSaveAddDelDriverOptions ();
+
+ DriverOrder = EfiLibAllocateZeroPool (nvPtr->Size);
+ MemCopy (DriverOrder,nvPtr->Buffer,nvPtr->Size);
+
+ //Disable all options
+ for (j = 0; j < gDriverOptionCount; j ++)
+ {
+ if (!(gDriverData [j].Active & LOAD_OPTION_HIDDEN)) //TSE will not do the option anything if it is hidden
+ {
+ gDriverData [j].Active &= ~(LOAD_OPTION_ACTIVE);
+ }
+ }
+ //Enable options in DriverOrder
+ for (j = 0; j < gDriverOptionCount; j ++)
+ {
+ pDriverData = DriverGetDriverData (DriverOrder [j]);
+ if(pDriverData)
+ {
+ if (!(pDriverData->Active & LOAD_OPTION_HIDDEN)) //TSE will not do the option anything if it is hidden
+ {
+ pDriverData->Active |= LOAD_OPTION_ACTIVE;
+ }
+ }
+ }
+ //Save driver options
+ for (j = 0; j < gDriverOptionCount; j ++)
+ {
+ CHAR16 varName[] = L"DriverXXXX";
+ BOOT_OPTION *pOption;
+ UINTN OptionSize;
+
+ OptionSize = 0; pOption = NULL;
+ SPrint (varName, sizeof (CHAR16) * (EfiStrLen (varName) + 1), gDriverFormarSpecifier, gDriverData [j].Option );
+ pOption = (BOOT_OPTION *)VarGetNvramName (varName, &gEfiGlobalVariableGuid, NULL, &OptionSize );
+
+ pOption->Active = gDriverData [j].Active;
+
+ VarSetNvramName (varName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ pOption,
+ OptionSize);
+
+ MemFreePointer((VOID **)&pOption);
+ }
+ n=0;
+ //Enabled options first
+ for (k = 0; k < gDriverOptionCount; k ++)
+ {
+ if(DISABLED_BOOT_OPTION == DriverOrder [k])
+ {
+ //add Disabled options
+ for (j = n; j < gDriverOptionCount; j++ )
+ {
+ if ( (!(gDriverData [j].Active & LOAD_OPTION_ACTIVE)) && (!(gDriverData [j].Active & LOAD_OPTION_HIDDEN)) )
+ {
+ DriverOrder [k] = gDriverData [j].Option;
+ n = j;
+ n ++;
+ break;
+ }
+ }
+ }
+
+ }
+
+ ASSERT (k == gDriverOptionCount);
+
+ //Signal TPM if Boot order has changed //No need of signalling the event for driver order change
+/* CurrOrder = VarGetNvramName (L"DriverOrder", &gEfiGlobalVariableGuid, NULL, &CurrSize);
+
+ if (CurrSize != (k*sizeof(UINT16)))
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+ else if (CurrOrder)
+ {
+ if (MemCmp ((UINT8 *)CurrOrder, (UINT8 *)DriverOrder, CurrSize) )
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+ }
+
+ MemFreePointer((VOID **)&CurrOrder);*/
+
+ //Save boot order
+ VarSetNvramName(L"DriverOrder",
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ DriverOrder,
+ k * sizeof(UINT16));
+
+ MemFreePointer((VOID **) &DriverOrder);
+
+ //Continue to next variable
+ continue;
+ }
+ //EIP70421 & 70422 Support for driver order ends
+
+ if(VARIABLE_ID_BBS_ORDER == i)
+ {
+ CsmSaveBBSOrder(nvPtr);
+ //Continue to Next variable
+ continue;
+ }
+
+ VarSetNvram( i, nvPtr->Buffer, nvPtr->Size );
+ }
+
+ PasswordCommitChanges( TRUE );
+
+ TSESetHDDPassword();
+
+ SavedConfigChangesHook();
+
+ EfiLibNamedEventSignal (&AmitseNvramUpdateGuid);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SaveBBSOrder
+//
+// Description: Function to save the bbs device order
+//
+// Input: NVRAM_VARIABLE *nvPtr
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SaveBBSOrder(NVRAM_VARIABLE *nvPtr)
+{
+ UINT16 *BootOrder;
+ UINTN BootOrderSize,p;
+ BBS_ORDER_TABLE *NewLegacyOrder, *NewDevEntry, *BufferDevEntry;
+ UINT8 *NewBuffer, *NewBuffEntry;
+ BOOT_DATA *pBootData;
+ BBS_ORDER_LIST *BBSList = NULL;
+ UINT16 count,r,s;
+ UINT8 *CurrOrder = NULL;
+ UINTN CurrSize = 0;
+ UINTN DPSize = 0;
+ VOID *DisDPs = NULL;
+ EFI_GUID BootManGuid = BOOT_MANAGER_GUID;
+ EFI_GUID AmitseBootOrderChangeGuid = AMITSE_BOOT_ORDER_CHANGE_GUID;
+ UINT32 LegDevOrderAttribute = 7;
+
+ BootOrderSize = 0;
+ BootOrder = VarGetNvramName(L"BootOrder", &gEfiGlobalVariableGuid, NULL, &BootOrderSize);
+
+ if (0 == BootOrderSize)
+ return; //continue;
+
+ NewLegacyOrder = EfiLibAllocateZeroPool(nvPtr->Size);
+ NewBuffer = EfiLibAllocateZeroPool(nvPtr->Size);
+
+ //NOTE: Taking advantage of the fact that
+ //VARIABLE_ID_BBS_ORDER is after
+ //VARIABLE_ID_BOOT_ORDER
+ NewDevEntry = NewLegacyOrder;
+ NewBuffEntry = NewBuffer;
+ for(p=0; p<(BootOrderSize/sizeof(UINT16)); p++)
+ {
+ pBootData = BootGetBootData(BootOrder[p]);
+ //EIP:59417 - Error Handling in case of pBootData is NULL. If its NULL the setupgets a CRASH
+ if(pBootData == NULL)
+ goto DONE;
+
+ if(BBSValidDevicePath(pBootData->DevicePath))
+ {
+ BufferDevEntry = (BBS_ORDER_TABLE *)(nvPtr->Buffer + pBootData->LegacyEntryOffset);
+
+ if ( (BufferDevEntry->Length >= nvPtr->Size) || (0 == BufferDevEntry->Length) ) //EIP-120011
+ {
+ goto DONE;
+ }
+
+ BBSList = pBootData->OrderList;
+
+ count = pBootData->LegacyDevCount;
+
+ MemCopy(NewDevEntry, BufferDevEntry, sizeof(UINT32)+(count+1)*sizeof(UINT16));
+ MemCopy(NewBuffEntry, BufferDevEntry, sizeof(UINT32)+(count+1)*sizeof(UINT16));
+
+ //----------------------------------------------------------------------------------//
+ // EIP-35863: This block considers the case of legacy devices being positioned //
+ // anywhere in the LegacyDevOrder (whether enabled or disabled) //
+ //----------------------------------------------------------------------------------//
+ if(count>0) //Disabled boot options exist
+ {
+ for(r=0;r<count;r++)
+ {
+ //See if a given index in BBSList exist in TypeEntry
+ for(s=0;s<count;s++)
+ {
+ if(BBSList[r].Index == NewDevEntry->Data[s])
+ {
+ break;
+ }
+ }
+
+ if(s>=count) //Index Not present
+ {
+ //Find the first disabled slot
+ for(s=0;s<count;s++)
+ {
+ if(NewDevEntry->Data[s] == DISABLED_BOOT_OPTION)
+ {
+ //Add device path to Nvram variable
+ if(gIsSaveDisabledBBSDevicePath)
+ CsmBBSSetDisabled(BBSList[r].Index, &DisDPs, &DPSize);
+ NewDevEntry->Data[s] = BBSList[r].Index;
+ NewDevEntry->Data[s] |= BBS_ORDER_DISABLE_MASK;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder;
+
+ NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + sizeof(UINT32)+(count+1)*sizeof(UINT16));
+ NewBuffEntry = NewBuffEntry + sizeof(UINT32)+(count+1)*sizeof(UINT16);
+ }
+ }
+
+DONE:
+ //Update the nv buffer with the re ordered list
+ MemFreePointer((VOID **) &(nvPtr->Buffer));
+ nvPtr->Buffer = NewBuffer;
+
+ //Signal TPM if BBS order has changed
+ CurrOrder = VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, &LegDevOrderAttribute, &CurrSize );
+
+ if(CurrOrder)
+ {
+ if(MemCmp((UINT8 *)CurrOrder, (UINT8 *)NewLegacyOrder, CurrSize))
+ EfiLibNamedEventSignal (&AmitseBootOrderChangeGuid);
+
+ MemFreePointer((VOID **) &CurrOrder);
+ }
+
+ //Save BBS order
+ VarSetNvramName(L"LegacyDevOrder",
+ &gLegacyDevGuid,
+ LegDevOrderAttribute,
+ NewLegacyOrder,
+ nvPtr->Size);
+
+ if(gIsSaveDisabledBBSDevicePath)
+ {
+ //Save disabled device paths
+ VarSetNvramName(L"DisabledDevs",
+ &BootManGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ DisDPs,
+ DPSize);
+
+ MemFreePointer((VOID **) &DisDPs);
+ MemFreePointer((VOID **) &BootOrder);
+ }
+ MemFreePointer((VOID **) &NewLegacyOrder);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ExitApplication
+//
+// Description: Function to exit form the setup application
+//
+// Input: None
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN ExitApplication( VOID )
+{
+ if ( CallbackShowMessageBox( (UINTN)gExitMsgBox, MSGBOX_TYPE_YESNO ) == MSGBOX_YES )
+ {
+ if ( ! gVariableChanged )
+ gResetRequired = FALSE;
+
+ LoadPreviousValues( FALSE );
+ gVariableChanged = FALSE;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowHelpMessageBox
+//
+// Description: Function to Display the help message box
+//
+// Input: None
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ShowHelpMessageBox( VOID )
+{
+ CallbackShowMessageBox( (UINTN)gHelpMsgBox, MSGBOX_TYPE_OK | MSGBOX_STYLE_LEFT );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CallbackShowMessageBox
+//
+// Description: Callback function to Display the message box
+//
+// Input : UINTN data,
+// UINT8 type
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CallbackShowMessageBox( UINTN data, UINT8 type )
+{
+ EFI_STATUS Status;
+ UINT8 retValue = (UINT8)-1;
+ MSGBOX_DATA *msgbox = NULL;
+
+ CONTROL_INFO dummy;
+
+ Status = gMsgBox.Create( &msgbox );
+ if ( EFI_ERROR( Status ) )
+ return retValue;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+ dummy.ControlPtr = (VOID*)data;
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gMsgBox.Initialize( msgbox, &dummy );
+ if ( EFI_ERROR( Status ) )
+ goto Done;
+
+ gMsgBox.SetType( msgbox, type );
+ retValue = (UINT8)_CallbackGetValue( msgbox );
+
+Done:
+ gMsgBox.Destroy( msgbox, TRUE );
+
+ return retValue;
+}
+
+static UINT8 result = (UINT8)-1;
+static CALLBACK_MESSAGEBOX gCbMsgBox = { { CALLBACK_TYPE_MESSAGEBOX, sizeof(CALLBACK_MESSAGEBOX) }, 0 };
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _CallbackGetValue
+//
+// Description: Callback function to get the message box return value
+//
+// Input: MSGBOX_DATA *msgbox
+//
+// Output: Message box return value
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _CallbackGetValue( MSGBOX_DATA *msgbox )
+{
+ ACTION_DATA *action = gMsgBoxAction;
+ EFI_STATUS Status = EFI_SUCCESS;
+ result = (UINT8)-1;
+ gMsgBox.SetCallback( msgbox, NULL, _CallbackMsgbox, &gCbMsgBox );
+
+ while ( result == (UINT8)-1 )
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gMsgBox.Draw( msgbox );
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ Status = gMsgBox.HandleAction( msgbox, action );
+
+ if (EFI_ERROR(Status))//EIP-123432
+ result = 0xff;
+
+ DoRealFlushLines();
+ }
+
+ return result;
+}
+
+VOID _CallbackMsgbox( VOID *container, VOID *object, VOID *cookie )
+{
+ if ( (cookie != NULL) && ( ((CALLBACK_MESSAGEBOX*)cookie)->Header.Type == CALLBACK_TYPE_MESSAGEBOX) )
+ result = (UINT8)(((CALLBACK_MESSAGEBOX*)cookie)->Result);
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/callback.h b/EDK/MiniSetup/TseLite/callback.h
new file mode 100644
index 0000000..cf589b2
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/callback.h
@@ -0,0 +1,189 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/callback.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/callback.h $
+//
+// 6 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:30a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 6/24/09 6:10p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: callback.h
+//
+// Description: Header file for code to handle callbacks
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _CALLBACK_H_
+#define _CALLBACK_H_
+
+
+#include "Minisetup.h"
+
+#define CALLBACK_TYPE_UNKNOWN 0
+#define CALLBACK_TYPE_SUBMENU 1
+#define CALLBACK_TYPE_VARIABLE 2
+#define CALLBACK_TYPE_MESSAGEBOX 3
+#define CALLBACK_TYPE_NVRAM 4
+#define CALLBACK_TYPE_DEFAULTS 5
+#define CALLBACK_TYPE_LABEL 6
+#define CALLBACK_TYPE_PASSWORD 7
+#define CALLBACK_TYPE_MENU 8
+#define CALLBACK_TYPE_USER -1
+
+typedef struct _CALLBACK_HEADER
+{
+ UINT32 Type;
+ UINT32 Length;
+}
+CALLBACK_HEADER;
+
+typedef struct _CALLBACK_SUBMENU
+{
+ CALLBACK_HEADER Header;
+ UINT16 DestPage;
+}
+CALLBACK_SUBMENU;
+
+typedef struct _CALLBACK_MENU
+{
+ CALLBACK_HEADER Header;
+ UINT16 DestPage;
+}
+CALLBACK_MENU;
+
+typedef struct _CALLBACK_VARIABLE
+{
+ CALLBACK_HEADER Header;
+ UINT32 Variable;
+ UINT32 Offset;
+ UINT32 Length;
+ VOID *Data;
+}
+CALLBACK_VARIABLE;
+
+typedef struct _CALLBACK_PASSWORD
+{
+ CALLBACK_HEADER Header;
+ UINT32 Variable;
+ UINT32 Offset;
+ UINT32 Length;
+ VOID *Data;
+ BOOLEAN Encoded;
+}
+CALLBACK_PASSWORD;
+
+typedef struct _CALLBACK_MESSAGEBOX
+{
+ CALLBACK_HEADER Header;
+ UINTN Result;
+}
+CALLBACK_MESSAGEBOX;
+
+typedef struct _CALLBACK_NVRAM
+{
+ CALLBACK_HEADER Header;
+ // I can't remember what this type was for
+}
+CALLBACK_NVRAM;
+
+#define DEFAULT_TYPE_UNKNOWN 0
+#define DEFAULT_TYPE_FAILSAFE 1
+#define DEFAULT_TYPE_OPTIMAL 2
+
+typedef struct _CALLBACK_DEFAULTS
+{
+ CALLBACK_HEADER Header;
+ UINT32 Type;
+}
+CALLBACK_DEFAULTS;
+
+typedef struct _CALLBACK_LABEL
+{
+ CALLBACK_HEADER Header;
+ UINT32 Key;
+}
+CALLBACK_LABEL;
+
+typedef struct _CALLBACK_USER
+{
+ CALLBACK_HEADER Header;
+ VOID *UserData;
+}
+CALLBACK_USER;
+
+#endif /* _CALLBACK_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/control.c b/EDK/MiniSetup/TseLite/control.c
new file mode 100644
index 0000000..c5ee5cf
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/control.c
@@ -0,0 +1,337 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/control.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/control.c $
+//
+// 5 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 6 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 11/21/11 8:49a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: contorl.c
+//
+// Description: This file contains code to handle controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+CONTROL_METHODS gControl =
+{
+ ControlCreate,
+ ControlDestroy,
+ ControlInitialize,
+ ControlEmptyMethod,
+ ControlHandleAction,
+ ControlSetCallback,
+ ControlSetFocus,
+ ControlSetPosition,
+ ControlSetDimensions,
+ ControlSetAttributes
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlCreate
+//
+// Description: Function to create the cotrol options using object functions.
+//
+// Input: CONTROL_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlCreate( CONTROL_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(CONTROL_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gControl;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlDestroy
+//
+// Description: Function to destroy the cotrol options using object functions.
+//
+// Input: CONTROL_DATA *control, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlDestroy( CONTROL_DATA *control, BOOLEAN freeMem )
+{
+ if(NULL == control)
+ return EFI_SUCCESS;
+
+ gObject.Destroy( control, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&control );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlInitialize
+//
+// Description: Function to Initialize the cotrol options using object functions.
+//
+// Input: CONTROL_DATA *control, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlInitialize( CONTROL_DATA *control, VOID *data )
+{
+ EFI_STATUS Status;
+
+ Status = gObject.Initialize( control, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ if ( ((CONTROL_INFO *)data)->ControlPtr == (UINTN)NULL )
+ return EFI_UNSUPPORTED;
+
+ if ( ! ((CONTROL_INFO *)data)->ControlFlags.ControlVisible )
+ Status = EFI_UNSUPPORTED;
+ else
+ MemCopy( &control->ControlData, data, sizeof(CONTROL_INFO) );
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlInitialize
+//
+// Description: Function to draw control.
+//
+// Input: CONTROL_DATA *control
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlDraw( CONTROL_DATA *control )
+{
+ return gObject.Draw( control );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlEmptyMethod
+//
+// Description: Empty control method.
+//
+// Input: CONTROL_DATA *control
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlEmptyMethod( CONTROL_DATA *control )
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: CONTROL_DATA *control, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlSetCallback( CONTROL_DATA *control, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( control, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlHandleAction
+//
+// Description: Function to handle action.
+//
+// Input: CONTROL_DATA *control, ACTION_DATA *Data
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlHandleAction( CONTROL_DATA *control, ACTION_DATA *Data )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: CONTROL_DATA *control, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlSetFocus( CONTROL_DATA *control, BOOLEAN focus )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlSetPosition
+//
+// Description: Function to set the position.
+//
+// Input: CONTROL_DATA *control, UINT16 Left, UINT16 Top
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlSetPosition( CONTROL_DATA *control, UINT16 Left, UINT16 Top )
+{
+ control->Left = Left;
+ control->Top = Top;
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlSetDimensions
+//
+// Description: Function to set dimensions.
+//
+// Input: CONTROL_DATA *control, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlSetDimensions(CONTROL_DATA *control, UINT16 Width, UINT16 Height)
+{
+ control->Width = Width;
+ control->Height = Height;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ControlSetAttributes
+//
+// Description: Function to set the control attributes
+//
+// Input: CONTROL_DATA *control, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ControlSetAttributes( CONTROL_DATA *control, UINT8 FGColor, UINT8 BGColor )
+{
+ if ( FGColor != 0 )
+ control->FGColor = FGColor;
+
+ if ( BGColor != 0 )
+ control->BGColor = BGColor;
+
+ return EFI_SUCCESS;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/control.h b/EDK/MiniSetup/TseLite/control.h
new file mode 100644
index 0000000..b7111d0
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/control.h
@@ -0,0 +1,171 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/control.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/control.h $
+//
+// 8 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 5 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+#ifndef _CONTROL_H_
+#define _CONTROL_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "setupdata.h"
+#include "action.h"
+#if UEFI_SOURCES_SUPPORT
+#include "ctrlcond.h"
+#endif
+
+#define CONTROL_GRAYOUT_COLOR STYLE_COLOR_GRAYOUT
+
+#define CONTROL_MEMBER_VARIABLES \
+ CONTROL_INFO ControlData; \
+ UINT16 Left; \
+ UINT16 Top; \
+ UINT16 Width; \
+ UINT16 Height; \
+ UINT8 FGColor; \
+ UINT8 BGColor; \
+ BOOLEAN ControlFocus; \
+ BOOLEAN ControlActive; \
+ UINT32 ParentFrameType;
+
+typedef struct _CONTROL_METHODS CONTROL_METHODS;
+
+typedef struct _CONTROL_DATA
+{
+ CONTROL_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+
+}
+CONTROL_DATA;
+
+typedef EFI_STATUS (*CONTROL_METHOD_SET_FOCUS) ( VOID *object, BOOLEAN focus );
+typedef EFI_STATUS (*CONTROL_METHOD_SET_POSITION) ( VOID *object, UINT16 Left, UINT16 Top );
+typedef EFI_STATUS (*CONTROL_METHOD_SET_DIMENSIONS) ( VOID *object, UINT16 Width, UINT16 Height );
+typedef EFI_STATUS (*CONTROL_METHOD_SET_ATTRIBUTES)( VOID *object, UINT8 FGColor, UINT8 BGColor );
+typedef EFI_STATUS (*CONTROL_METHOD_GET_CONTROL_HIGHT)( VOID *object, VOID *frame, UINT16 *height );
+
+#define CONTROL_METHOD_FUNCTIONS \
+ CONTROL_METHOD_SET_FOCUS SetFocus; \
+ CONTROL_METHOD_SET_POSITION SetPosition; \
+ CONTROL_METHOD_SET_DIMENSIONS SetDimensions; \
+ CONTROL_METHOD_SET_ATTRIBUTES SetAttributes; \
+ CONTROL_METHOD_GET_CONTROL_HIGHT GetControlHeight;
+
+struct _CONTROL_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+};
+
+extern CONTROL_METHODS gControl;
+
+// Object Methods
+EFI_STATUS ControlCreate( VOID **object );
+EFI_STATUS ControlDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS ControlInitialize( VOID *object, VOID *data );
+EFI_STATUS ControlEmptyMethod( VOID *object );
+EFI_STATUS ControlDraw( VOID *object );
+EFI_STATUS ControlHandleAction( VOID *object, ACTION_DATA *Data );
+EFI_STATUS ControlSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS ControlSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS ControlSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS ControlSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS ControlSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+CONTROL_DATA * GetUpdatedControlData(CONTROL_DATA * ControlData,UINT16 ControlType,VOID *Handle,UINT16 Key);
+
+
+#endif /* _CONTROL_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/edit.c b/EDK/MiniSetup/TseLite/edit.c
new file mode 100644
index 0000000..d8646e4
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/edit.c
@@ -0,0 +1,636 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/edit.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 12 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/edit.c $
+//
+// 12 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 11 4/05/12 7:14a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 10 11/30/11 12:46a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 9 11/21/11 12:09p Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 8 11/21/11 8:50a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 7 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:50a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 8/13/09 1:17p Blaines
+// EIP #24980 Fix to properly display right area text
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:08p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Edit.c
+//
+// Description: This file contains code to handle Edit control operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+
+EDIT_METHODS gEdit =
+{
+ EditCreate,
+ EditDestroy,
+ EditInitialize,
+ EditDraw,
+ EditHandleAction,
+ EditSetCallback,
+ EditSetFocus,
+ EditSetPosition,
+ EditSetDimensions,
+ EditSetAttributes,
+ EditGetControlHight
+
+};
+
+EFI_STATUS _EditHandleActionKey(EDIT_DATA *edit, AMI_EFI_KEY_DATA key);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditCreate
+//
+// Description: Function to create Edit Controls, which uses the control functions.
+//
+// Input: EDIT_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditCreate( EDIT_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(EDIT_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gEdit;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditDestroy
+//
+// Description: Function to Destroy Edit Controls, which uses the control functions.
+//
+// Input: EDIT_DATA *edit, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditDestroy( EDIT_DATA *edit, BOOLEAN freeMem )
+{
+ if(NULL == edit)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( edit, FALSE );
+
+ MemFreePointer( (VOID **)&edit->Text );
+ MemFreePointer( (VOID **)&edit->TempText );
+
+ if( freeMem )
+ MemFreePointer( (VOID **)&edit );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditInitialize
+//
+// Description: Function to Initialize Edit Controls, which uses the control functions.
+//
+// Input: EDIT_DATA *edit, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditInitialize( EDIT_DATA *edit, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( edit, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ SetControlColorsHook(NULL, NULL,
+ NULL,NULL,
+ NULL /*&(edit->SelBGColor )*/, &(edit->SelFGColor),
+ &(edit->BGColor), &(edit->FGColor),
+ NULL /*UINT8 *LabelBGColor*/,&(edit->LabelFGColor) /*UINT8 *LabelFGColor*/,
+ &(edit->NSelLabelFGColor)/*UINT8 *NSelLabelFGColor*/,
+ &(edit->SelBGColor )/*EditBGColor*/,&(edit->EditFGColor),
+ NULL, NULL );
+
+
+ // add extra initialization here...
+ edit->TextMargin = (UINT8)gControlLeftMargin;
+ if ( edit->TextWidth == 0 )
+ {
+ edit->TextWidth = UefiGetWidth(((CONTROL_INFO *)data)->ControlPtr);
+ edit->TextWidth = (edit->TextWidth>1)?(3 * (UINT16)edit->TextWidth):4;
+ }
+
+ edit->TextAreaWidth = (edit->TextWidth </*10*/(UINT16)(edit->Width - edit->TextMargin - 2)) ? edit->TextWidth:/*10*/(UINT16)(edit->Width - edit->TextMargin - 2);
+ edit->Text = EfiLibAllocateZeroPool((edit->TextWidth +1)* sizeof(CHAR16));
+ MemSet( edit->Text, (edit->TextWidth +1)* sizeof(CHAR16), 0 );
+
+ if( *((UINT8*)((CONTROL_INFO *)data)->ControlPtr) == IFR_PASSWORD_OP)
+ edit->Chr = L'*';
+
+ if ( edit->Text != NULL )
+ {
+ VarGetValue( edit->ControlData.ControlVariable,
+ UefiGetQuestionOffset(((CONTROL_INFO *)data)->ControlPtr),
+ UefiGetWidth(((CONTROL_INFO *)data)->ControlPtr), edit->Text );
+
+ }
+ edit->TempText = EfiLibAllocateZeroPool((edit->TextWidth +1)* sizeof(CHAR16));
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditDraw
+//
+// Description: Function to draw Edit Controls.
+//
+// Input: EDIT_DATA *edit
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditDraw(EDIT_DATA *edit )
+{
+ CHAR16 *text,*text2;
+ UINT16 i;
+ UINT8 BGClr,FGClr;
+
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorNSel = edit->FGColor;
+ UINT8 ColorLabel = (edit->ControlFocus) ? edit->LabelFGColor : edit->NSelLabelFGColor ;
+
+
+ if(edit->ControlFocus)
+ {
+ BGClr = edit->SelBGColor;
+ if(edit->ControlActive)
+ FGClr = edit->EditFGColor;
+ else
+ FGClr = edit->SelFGColor;
+ }
+ else
+ {
+ BGClr = edit->BGColor;
+ FGClr = /*ColorLabel;*/ edit->FGColor;
+ }
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( edit->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &edit->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ FGClr = ColorNSel = ColorLabel = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+
+ text = HiiGetString( edit->ControlData.ControlHandle, UefiGetPromptField(edit->ControlData.ControlPtr));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == text){
+ text = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!text)
+ return EFI_NOT_FOUND;
+ EfiStrCpy(text,L" ");
+ }
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(edit->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( edit->Left , edit->Top,
+ (UINTN)(edit->TextMargin - edit->Left),(UINTN) edit->Height,
+ text, edit->BGColor | ColorLabel );
+ }
+ else
+ {
+ // boundary overflow check
+ if ((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(edit->TextMargin - edit->Left )/*21*/ )
+ text[HiiFindStrPrintBoundary(text,(UINTN)(edit->TextMargin - edit->Left ))] = L'\0';
+
+ DrawStringWithAttribute( edit->Left , edit->Top, (CHAR16*)text,
+ edit->BGColor | ColorLabel/*((edit->ControlFocus)? edit->LabelFGColor : edit->NSelLabelFGColor )*/ );
+
+ }
+
+ for(i=0; i < edit->TextAreaWidth; i++)
+ DrawStringWithAttribute( edit->Left + edit->TextMargin + i , edit->Top, L" ",
+ BGClr | FGClr );
+
+ if(edit->Chr != 0x0)
+ {
+ text2 = EfiLibAllocateZeroPool( ((TestPrintLength( edit->Text ) / (NG_SIZE))+1) * sizeof(CHAR16));
+ for(i = 0; (i < (TestPrintLength( edit->Text ) / (NG_SIZE))) && (i < edit->TextAreaWidth); i++ )
+ text2[i] = edit->Chr;
+
+ DrawStringWithAttribute( edit->Left + edit->TextMargin, edit->Top, text2,
+ BGClr | FGClr );
+ MemFreePointer((VOID **)&text2);
+ }
+ else
+ DrawStringWithAttribute( edit->Left + edit->TextMargin , edit->Top , edit->Text,
+ BGClr | FGClr );
+
+
+ MemFreePointer((VOID **)&text);
+
+ FlushLines( edit->Top, edit->Top );
+ DoRealFlushLines();
+ MouseRefresh();
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: EDIT_DATA *edit, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditSetCallback( EDIT_DATA *edit, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( edit, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditHandleAction
+//
+// Description: Function to handle Edit actions.
+//
+// Input: EDIT_DATA *edit, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditHandleAction( EDIT_DATA *edit, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ if ( Data->Input.Type == ACTION_TYPE_KEY )
+ return _EditHandleActionKey(edit, Data->Input.Data.AmiKey);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _EditHandleActionKey
+//
+// Description: Function to handle Edit actions.
+//
+// Input: EDIT_DATA *edit, AMI_EFI_KEY_DATA key
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _EditHandleActionKey(EDIT_DATA *edit, AMI_EFI_KEY_DATA key)
+{
+ UINT8 Redraw =0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINTN i;
+ CONTROL_ACTION Action;
+
+
+ //Get mapping
+ Action = MapControlKeysHook(key);
+
+ switch(Action)
+ {
+ case ControlActionAbort:
+ if(edit->ControlActive == TRUE)
+ Status = EFI_SUCCESS;
+ case ControlActionNextUp:
+ case ControlActionNextDown:
+ if(edit->ControlActive == TRUE)
+ {
+ MemCopy(edit->Text,edit->TempText,edit->TextWidth*sizeof(UINT16)); //UNICODE CHARS
+ edit->ControlActive = FALSE;
+ Redraw = 1;
+ }
+ break;
+
+ case ControlActionNextLeft:
+ case ControlActionNextRight:
+ if(edit->ControlActive == TRUE)
+ Status = EFI_SUCCESS; // cosume the action if editing
+ break;
+
+ case ControlActionSelect:
+ if(edit->Callback != NULL)
+ {
+ if ( edit->Cookie != NULL )
+ {
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)edit->Cookie;
+
+ callbackData->Variable = edit->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(edit->ControlData.ControlPtr);
+ callbackData->Length = UefiGetWidth(edit->ControlData.ControlPtr);
+ callbackData->Data = (VOID *)edit->Text;
+
+ edit->Callback( edit->Container,edit, edit->Cookie );
+ }
+ }
+
+ Redraw =1;
+ edit->ControlActive = FALSE;
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionBackSpace:
+ if(EfiStrLen(edit->Text)>0)
+ {
+ if(edit->ControlActive == FALSE)
+ {
+ MemCopy(edit->TempText,edit->Text,edit->TextWidth * sizeof(UINT16)); //UNICODE CHARS
+ edit->ControlActive = TRUE;
+ }
+ edit->Text[EfiStrLen(edit->Text)-1] = 0x0;
+ Redraw =1;
+ }
+ break;
+
+ default:
+ if(SCAN_NULL == key.Key.ScanCode)
+ {
+ if((EfiStrLen(edit->Text) < edit->TextWidth) |
+ ( (edit->ControlActive == FALSE) ) && (edit->ControlData.ControlType == CONTROL_TYPE_NUMERIC) )
+ {
+ if(edit->ControlActive ==FALSE)
+ {
+ MemCopy(edit->TempText,edit->Text,edit->TextWidth* sizeof(UINT16));
+ if(edit->ControlData.ControlType == CONTROL_TYPE_NUMERIC)
+ {
+ i = edit->TextWidth;
+ do {
+ edit->Text[i] = 0x0;
+ }while(i-- > 0 );
+ }
+ edit->ControlActive = TRUE;
+ }
+
+ i = EfiStrLen(edit->Text);
+ edit->Text[i] = key.Key.UnicodeChar ;
+ edit->Text[i+1] = 0x0 ;
+ Redraw =1;
+ }
+ }
+ break;
+ }
+
+ if(Redraw)
+ Status = gEdit.Draw(edit);
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditSetFocus
+//
+// Description: Function to set the edit focus.
+//
+// Input: EDIT_DATA *edit, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditSetFocus(EDIT_DATA *edit, BOOLEAN focus)
+{
+ if(focus != FALSE)
+ {
+ if ( CheckControlCondition( &edit->ControlData ) )
+ return EFI_UNSUPPORTED;
+ }
+
+ if( !(edit->ControlFocus && focus) )
+ edit->ControlFocus = focus;
+
+ if(!focus)
+ edit->ControlActive = 0;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditSetPosition
+//
+// Description: Function to set the edit position.
+//
+// Input: EDIT_DATA *edit, UINT16 Left, UINT16 Top
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditSetPosition(EDIT_DATA *edit, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( edit, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditSetDimensions
+//
+// Description: Function to set the edit dimensions.
+//
+// Input: EDIT_DATA *edit, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditSetDimensions(EDIT_DATA *edit, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( edit, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditSetAttributes
+//
+// Description: Function to set the edit attributes.
+//
+// Input: EDIT_DATA *edit, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditSetAttributes(EDIT_DATA *edit, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( edit, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EditGetControlHight
+//
+// Description: Function unsuppored.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EditGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/edit.h b/EDK/MiniSetup/TseLite/edit.h
new file mode 100644
index 0000000..5f51485
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/edit.h
@@ -0,0 +1,166 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/edit.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/edit.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 7 3/26/10 6:52p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Edit.h
+//
+// Description: Header file for Edit controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _EDIT_H_
+#define _EDIT_H_
+
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "action.h"
+
+#define EDIT_MEMBER_VARIABLES \
+ CHAR16 *Text; \
+ CHAR16 *TempText; \
+ UINT16 TextMargin; \
+ UINT16 MinSize; \
+ UINT16 MaxSize; \
+ UINT16 TextWidth; \
+ UINT16 TextAreaWidth; \
+ UINT8 LabelFGColor; \
+ UINT8 NSelLabelFGColor; \
+ UINT8 LabelMargin; \
+ UINT8 SelFGColor; \
+ UINT8 SelBGColor; \
+ UINT8 EditFGColor; \
+ CHAR16 Chr; /* character used to display instead of real chars from keyboard.*/
+ /* mainly used for password entry.*/
+
+typedef struct _EDIT_METHODS EDIT_METHODS;
+
+typedef struct _EDIT_DATA
+{
+ EDIT_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ EDIT_MEMBER_VARIABLES
+
+}
+EDIT_DATA;
+
+#define EDIT_METHOD_FUNCTIONS
+
+struct _EDIT_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ EDIT_METHOD_FUNCTIONS
+
+};
+
+extern EDIT_METHODS gEdit;
+
+// Object Methods
+EFI_STATUS EditCreate( VOID **object );
+EFI_STATUS EditDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS EditInitialize( VOID *object, VOID *data );
+EFI_STATUS EditDraw( VOID *object );
+EFI_STATUS EditHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS EditSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS EditSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS EditSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS EditSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS EditSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS EditGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+
+#endif /* _EDIT_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/frame.c b/EDK/MiniSetup/TseLite/frame.c
new file mode 100644
index 0000000..e196a84
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/frame.c
@@ -0,0 +1,2563 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/frame.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 63 $
+//
+// $Date: 9/05/14 6:27a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/frame.c $
+//
+// 63 9/05/14 6:27a Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 62 5/02/14 9:30p Arunsb
+// EIP141986 changes reverted.
+//
+// 61 5/02/14 11:01a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 60 5/02/14 2:55a Premkumara
+// [TAG] EIP131547
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] In CPU Config page, controls are going beyond the page
+// while clicking the down arrow in scroll bar in 80*25 mode [when
+// terminal redirection module enabled].
+// [RootCause] TSE was checking for LastVisibleCtrl with the total
+// number of frame ctrl count
+// and accordingly it was modifying FirstVisibleCtrl and LastVisibleCtrl
+// But there are some Suppressed controls at the end of the CPU Config
+// page
+// for which the above check was wrong.
+// [Solution] Added an extra condition to check whether LastVisibleCtrl
+// is equal to the LastNonSupressctrl in the Frame or not and
+// accordingly modify FirstVisibleCtrl and LastVisibleCtrl.
+// [Files] frame.c
+//
+// 59 5/01/14 3:42p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 58 2/11/14 8:32p Arunsb
+// [TAG] EIP131365
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE Help window flickers when Mouse\Touch device used under
+// boot page in Setup
+// [Root Cause] gActiveBuffer->Chars get flushed with EmptyString in
+// TSEMouseHelpFrameHandleAction() every time
+// [Solution] Handled gActiveBuffer properly
+// [Files] frame.c
+//
+// 57 12/03/13 1:07p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 56 12/02/13 12:32p Premkumara
+// [TAG] EIP131547
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Frame is scrolling beyond visible controls when mouse is
+// clicked on down arrow
+// [Root Cause] Frame is scrolling for suppressed controls which are not
+// visble in the frame
+// [Solution] Scrolling frame based on visible controls count.
+// [Files] frame.c
+//
+// 54 3/25/13 8:39a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\UefiWapper20.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 53 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 33 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 51 9/18/12 6:18a Arunsb
+// [TAG] EIP92972
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System hangs when submenu has no control in it
+// [RootCause] visibleControlHeight is 0, dividing by this causes system
+// hang
+// [Solution] visibleControlHeight handled properly
+// [Files] frame.c
+//
+// 50 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 48 9/10/12 5:02a Rajashakerg
+// [TAG] EIP93881 and 93873
+// [Category] Improvement
+// [Description] need keep system password after Load default and
+// Password saved into NVRAM immediately(not buffer) while it is installed
+// in TSE
+// [Files] frame.c, callback.c, AMITSE.sdl, CommonHelper.c
+//
+// 47 5/28/12 12:31p Premkumara
+// [TAG] EIP67049 & 90224
+// [Category] New Feature
+// [Description] Support mouse drag operation in frame and list box
+// [Files] CommonHelper.c, Frame.c, ListBox.c, Minisetupext.h
+//
+// 46 4/05/12 9:15a Arunsb
+// Unwanted code commented
+//
+// 45 4/05/12 7:15a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 44 2/01/12 6:09p Blaines
+// Rollback
+//
+// 42 1/31/12 6:33p Blaines
+// [TAG] - EIP 79963
+// [Category]- Defect
+// [Synopsis]- Scrollbar functionality with mouse was not working properly
+// and While Clicking the arrow buttons in scroll bar moves the entry up
+// not the scroll bar.
+// [Description]- 1. Build the BIOS project with GTSE and Mouse support,
+// 2. Goto Chipset->South bridge, click on the arrow keys or Move the
+// scrool bar and observe the behaviour.
+// [Root Cause] - Incorrect scrollbar size computed when total
+// lines/controls was 1 greater than a filled frame.
+// [Solution] - Check for special case and adjust visibleControlHeight
+// when total lines is 1 greater than a filled frame (visible controls).
+// [Files changed] - frame.c
+// [Functions changed] - FrameDraw
+//
+// 41 1/20/12 4:10a Rajashakerg
+// [TAG] EIP78929
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Control selection using Mouse is not user friendly.
+// [RootCause] Updating the buffer with mouse click information provided
+// by mouse driver is improper.
+// [Solution] Updated the mouse click information properly to the buffer
+// which is used by tse to do action.
+// [Files] Action.c, frame.c ListBox.c
+//
+// 40 12/07/11 3:32p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 39 12/07/11 2:10p Rajashakerg
+// [TAG] EIP76810
+// [Category] Improvement
+// [Description] EFI_IFR_INCONSISTENT_IF to follow 28.2.5.9.2 as per efi
+// spec 2.3.1
+// [Files] frame.c
+//
+// 38 11/21/11 12:07p Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 37 11/20/11 7:49a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 36 11/18/11 11:40a Blaines
+// [TAG] - EIP 72349
+// [Category]- Sighting
+// [Synopsis]- In some SAS cards the scroll bar does not function
+// correctly.
+//
+// [Description] - The scroll bar is not accurate, doesn't properly handle
+// multi-line controls. In some SAS cards with a large number of drives,
+// the scroll bar would move down the screen then disappear before
+// reaching the end, giving the appearance that no more items are viewable
+// or selectable.
+//
+// [Files]
+// Frame.c
+//
+// 35 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 34 7/21/11 1:07p Rajashakerg
+// Updated the file to close the popup window when left clicked on help
+// and navigation frame
+//
+// 33 7/21/11 11:24a Rajashakerg
+// Updated the file to restrict the control selection when cliked on help
+// frame with mouse
+//
+// 30 6/30/11 5:18a Rajashakerg
+// Updated the help frame scroll restricted for left click alone.
+//
+// 29 6/29/11 4:34p Rajashakerg
+// Updated for Help frame scroll changes
+//
+// 28 6/29/11 12:58p Rajashakerg
+// [TAG] EIP47086
+// [Category] New Feature
+// [Description] Right clicking from the Main page is not exiting from
+// BIOS setup.
+//
+// [Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
+// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
+// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
+// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
+// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
+// application.h, application.c, commonoem.h, CommonHelper.c
+//
+// 27 6/29/11 12:36p Rajashakerg
+// [TAG] EIP59657
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] [TSE] When change password status, sometimes will miss
+// first item.
+// [RootCause] The frame first visible control is not handled properly
+// [Solution] The first visible control is handled properly by making
+// first visible control as 0 in framescroll
+// [Files] Frame.c
+//
+// 26 6/28/11 2:42p Arunsb
+// Build error resolved by adding UpdateDestiantionQuestion function
+// declaration.
+//
+// 25 6/23/11 3:58p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 24 4/29/11 4:36p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted
+//
+// 22 3/29/11 12:15a Madhans
+// [TAG] EIP54968
+// [Category] Improvement
+// [Description] To Support different style modules in TSE generically
+// [Files] Ezport module updated. EzportPlus and Legacy Styles Modules
+// added.
+//
+// 21 12/28/10 9:37a Mallikarjunanv
+// updaed changes regarding EIP:48382
+//
+// 20 12/25/10 7:41a Mallikarjunanv
+// [TAG] EIP 49548 / 48377
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BIOS gui scroll bar fails to indicate that there are more
+// options available on the Advanced | CPU Configuration page
+// [RootCause] Scrollbar draw is not handled properly
+// [Solution] Updated the scrollbar draw depending on the controls of
+// the frame.
+// [Files] Frame.c
+//
+// 19 12/25/10 4:16a Mallikarjunanv
+// [TAG] EIP 48382
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Clicking somewhere in BIOS Setup selecting the control
+// strings.
+// [RootCause] Co-ordinates are not properly set for mouse click
+// operation
+// [Solution] Co-ordinates are updated properly for mouse click
+// operation
+// [Files] Frame.c
+//
+// 18 12/25/10 3:40a Mallikarjunanv
+// [TAG] EIP 47940
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Scrollbar disappeared while scrolling in the BOOT page
+// [RootCause] Scrollbar support is not handled properly depending on
+// the controls
+// [Solution] Updated the scrollbar support handling depending on the
+// controls.
+// [Files] Frame.c
+//
+// 17 12/02/10 2:44p Madhans
+// [TAG] - EIP 47608
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- If the String length is different in different languages,
+// Changing language causes
+// TSE multiline function to not work correctly.
+// [Rootcause] control dimension are set only with initial language and it
+// is not updated after that.
+// [Solution]- The Control dimentions need to updated when language
+// changes.
+// [Files] - frame.c
+//
+// 16 10/05/10 11:53a Blaines
+// In the function _FrameAddTitle, set the property ParentFrameType before
+// calling gMemo.Initialize. This is useful in case the function
+// gMemo.Initialize is overriden.
+//
+// 15 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 23 9/15/10 2:05p Madhans
+// If the Dynamic update happens while drawing the control (via Evalutate
+// Condition->VarGetValue->ExtractConfig).
+// The controls may be invalidated. In that case don't proceed with Frame
+// Draw.
+//
+// 22 8/12/10 1:06p Blaines
+// EIP-41817: Fix to allow Help Frame scroll support
+//
+// Use reference to gFrame.AddControl to allow option to customization
+// outside of frame.c.
+//
+// 21 6/17/10 2:46p Madhans
+// Mouse issue fix,
+//
+// 20 6/14/10 7:09p Madhans
+// Dynamic parsing support
+//
+// 19 3/30/10 4:50p Blaines
+// Remove the call to StyleFrameAddControl.
+//
+// 18 3/26/10 6:52p Madhans
+// Support to Map the do the Control Mapping from gTseControlMap Table. So
+// no changes need in Frame.c, With this feature gTseControlMap Can be
+// customized to add/customize the TSE controls.
+//
+// 17 3/23/10 5:13p Blaines
+// Add new style module hook
+//
+// 16 2/24/10 4:37p Madhans
+// EIP 35522 Fix to make Text interactive control to work. Need to send
+// the Timer action to all the controls.
+//
+// 15 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 14 2/15/10 10:13p Madhans
+// To avoid warnings
+//
+// 13 2/05/10 6:04p Madhans
+// Mouse action override from Style Module.
+//
+// 12 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 11 2/01/10 7:38p Madhans
+// EIP 32501 : Fix to handle the Conditional control Focusing , in the Sub
+// form
+//
+// 10 1/29/10 4:34p Madhans
+// To avoid compiler warnings.
+//
+// 9 1/09/10 6:34a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 8 12/04/09 8:49a Mallikarjunanv
+// EIP:31606 - Fix for hanging issue in case of no active controls in a
+// frame
+//
+// 7 8/13/09 1:18p Blaines
+// EIP #24980 Fix to properly display right area text;
+//
+// Properly initialize the control width
+//
+// 6 7/20/09 1:21p Mallikarjunanv
+// error fixed in multiline controls
+//
+// 5 7/09/09 12:28p Mallikarjunanv
+// updated the password encoded fix
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 5/20/09 3:44p Blaines
+// Update the way Scroll Behavior token is accessed
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:08p Madhans
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: frame.c
+//
+// Description: This file contains code to handle frame operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+EFI_STATUS _FrameHandleKey( FRAME_DATA *frame, AMI_EFI_KEY_DATA Key );
+EFI_STATUS _FrameScroll( FRAME_DATA *frame, BOOLEAN bScrollUp );
+BOOLEAN _FrameSetControlFocus( FRAME_DATA *frame, UINT32 index );
+EFI_STATUS _PreviousFrame (FRAME_DATA *frame);
+EFI_STATUS _NextFrame (FRAME_DATA *frame);
+EFI_STATUS _FocusFirst (FRAME_DATA *frame);
+EFI_STATUS _FocusLast (FRAME_DATA *frame);
+EFI_STATUS FrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar);
+EFI_STATUS UpdateDestiantionQuestion (UINT32, UINT32, UINT32 *);
+EFI_STATUS TSEMouseHelpFrameHandleAction( FRAME_DATA *frame, ACTION_DATA *action,CONTROL_DATA **control);
+VOID _HelpFrameScroll(MEMO_DATA *memo,BOOLEAN bScrollUp);
+BOOLEAN IsMouseSupported(VOID);
+//EIP-67049 Start
+INT32 lButtonDownVaringPosition = 0;
+INT32 lButtonDownInitialPosition = 0;
+static UINT32 gFrameScrollBarTop = 0, gFrameScrollBarBottom = 0;
+//EIP-67049 End
+//--------------------------------------------------------------------------
+
+//--------------------------------------------------------------------------
+FRAME_METHODS gFrame =
+{
+ FrameCreate,
+ FrameDestroy,
+ FrameInitialize,
+ FrameDraw,
+ FrameHandleAction,
+ FrameSetCallback,
+ FrameAddControl
+};
+//--------------------------------------------------------------------------
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameCreate
+//
+// Description: Allocated memory size and creates frame
+//
+// Input: FRAME_DATA **object
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS -
+// EFI_OUT_OF_RESOURCES - if the object is NULL
+// EFI_ERROR - If there are any the error in the object
+// creating process
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FrameCreate( FRAME_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(FRAME_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+
+ if (EFI_ERROR(Status))
+ {
+ MemFreePointer( (VOID **)object );
+ return Status;
+ }
+
+ (*object)->Methods = &gFrame;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameDestroy
+//
+// Description: Destroys an existing frame and frees memory
+//
+// Input: FRAME_DATA *frame - Frame to be destroyed
+// BOOLEAN freeMem - Frees frame memory if TRUE, ignores
+// otherwise
+//
+// Output: EFI_STATUS - EFI_SUCCESS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS FrameDestroy( FRAME_DATA *frame, BOOLEAN freeMem )
+{
+ CONTROL_DATA **control;
+ UINT32 i;
+
+ if(NULL == frame)
+ return EFI_SUCCESS;
+ control = frame->ControlList;
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ if (*control) //Destroy the controls if it is not NULL
+ (*control)->Methods->Destroy( *control, TRUE );
+ }
+
+ frame->ControlCount = 0;
+
+ MemFreePointer( (VOID **)&frame->ControlList );
+ MemFreePointer( (VOID **)&frame->BlankLine );
+ MemFreePointer( (VOID **)&frame->OrigPosition );
+ MemFreePointer( (VOID **)&frame->CurrPosition );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&frame );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameInitialize
+//
+// Description: Initializes the frame data
+//
+// Input: FRAME_DATA *frame - Frame to be intialized
+// FRAME_INFO *data - Related frame data
+//
+// Output: EFI_STATUS - EFI_SUCCESS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FrameInitialize( FRAME_DATA *frame, FRAME_INFO *data )
+{
+ if ( data != NULL )
+ {
+ MemCopy( &frame->FrameData, data, sizeof(FRAME_INFO) );
+ if ( frame->PageID != 0 )
+ {
+ frame->BlankLine = EfiLibAllocateZeroPool( sizeof(CHAR16) * (data->Width + 1) );
+ if ( frame->BlankLine != NULL )
+ MemFillUINT16Buffer( frame->BlankLine, data->Width, L' ' );
+ }
+ }
+
+ frame->FirstVisibleCtrl = 0;
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: IsScrollSupportRequired
+//
+// Description: To know whether the scroll supprot required befor drawing the frame
+//
+// Input: FRAME_DATA *frame - Frame information to get frame info
+//
+// Output: BOOLEAN - TRUE/FALSE
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsScrollSupportRequired(FRAME_DATA *frame )
+{
+ CONTROL_DATA **control;
+ UINT16 i, Height, Top;
+ UINT8 u8ChkResult;
+
+ control = frame->ControlList;
+ Height = frame->FrameData.Top;
+
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ Top = Height;
+
+ u8ChkResult = CheckControlCondition( &((*control)->ControlData) ); //Check conditional
+
+ if(u8ChkResult == COND_NONE || u8ChkResult == COND_GRAYOUT) {
+ // EIP47608 +>>
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ if(frame->FrameData.FrameType == MAIN_FRAME)
+ {
+ UINT16 height=0;
+ (*control)->Methods->GetControlHeight( *control, (VOID*)frame,&height);
+ height = height ? height:1;
+ (*control)->Methods->SetDimensions( *control,
+ frame->FrameData.Width - (UINT8)gLabelLeftMargin - 2,
+ height );
+ }
+ }
+ // EIP47608 <<+
+ Height = Height + (*control)->Height;
+ }
+ }
+
+ //check whether scroll support required.
+ if((frame->UseScrollbar) && ((frame->FrameData.Top + frame->FrameData.Height) >= Height+1))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameDraw
+//
+// Description: Draws the controls for the given frame
+//
+// Input: FRAME_DATA *frame - Frame information to draw controls
+//
+// Output: EFI_STATUS - EFI_SUCCESS if successful, else EFI_ERROR
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FrameDraw( FRAME_DATA *frame )
+{
+ CONTROL_DATA **control;
+ UINT32 i, j,FirstLine=0, LastLine=0, topPos=0, lastPos=0, count, visibleControlHeight=0, visibleControlCount = 0, modVal=0, sizeOfBar = 0, numOfBlocks = 0,CurrentvisibleControlCount = 0,CurrentFirstvisibleControlCount = 0,MltCnt=0,FrameLastVisibleControl=0;//EIP:48377/49548 Needed Local declarations for modification.
+ UINT16 CurrHeight, ControlTop;
+ UINT8 u8ChkResult;
+ UINT8 u8ChkMask;
+
+ BOOLEAN bCurrNotFocused = FALSE,bEraseScrollBar=FALSE;
+
+ if(StyleFrameDrawable(frame))
+ return EFI_UNSUPPORTED;
+
+ if ( frame->ControlCount == 0 )
+ return EFI_UNSUPPORTED;
+
+ //If there is an active control send draw only for that
+ if(frame->CurrentControl == FRAME_NONE_FOCUSED)
+ {
+ control = NULL;
+ bCurrNotFocused = TRUE; // Non is focused
+ }
+ else
+ control = &frame->ControlList[frame->CurrentControl];
+
+ if ( control != NULL )
+ {
+ //If a control is active only draw that
+ if( (*control)->ControlActive == TRUE )
+ {
+ (*control)->Methods->Draw( *control );
+ return EFI_SUCCESS;
+ }
+
+ u8ChkResult = CheckControlCondition( &((*control)->ControlData) );
+
+ //Setting focus to control if no control-condition is present and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to focus and selectable
+ if ( (COND_NONE == u8ChkResult) || (IsGrayoutSelectable() && (COND_GRAYOUT == u8ChkResult)) )
+ {
+ // Control might be dynamically updated. Get the actual control
+ if(*control == NULL)
+ {
+ gApp->CompleteRedraw = TRUE;
+ return EFI_UNSUPPORTED;
+ }
+
+ // Set the Focus to current control
+ if((*control)->Methods->SetFocus(*control,TRUE) != EFI_SUCCESS)
+ {
+
+ //EIP-41817: Fix to allow Help Frame scroll support
+ if(frame->FrameData.FrameType != HELP_FRAME)
+ {
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ bCurrNotFocused = TRUE; // Non is focused
+ }
+ }
+ }
+ }
+
+ //There is no active control we have to draw all in the view.
+
+ // First, clear the frame.
+ if ( frame->BlankLine != NULL )
+ {
+ j = frame->FrameData.Top;
+ for ( i = 1; i < frame->FrameData.Height; i++, j++ )
+ {
+ DrawStringWithAttribute( frame->FrameData.Left, j, frame->BlankLine, frame->FrameData.FGColor | frame->FrameData.BGColor );
+ }
+ }
+
+ //EIP:47940 - Check whether the scroll support required before proceeding.
+ if(!IsScrollSupportRequired( frame )) {
+ //If the scroll is not required, then reset the first visible control.
+ frame->FirstVisibleCtrl = 0;
+ }
+
+ //Set position for all controls begining from FirstVisibleControl.
+ //In the process calculate the correct LastVisibleControl.
+ control = frame->ControlList;
+ ControlTop = CurrHeight = 0;
+ control = control + frame->FirstVisibleCtrl;
+ CurrHeight = frame->FrameData.Top;
+ frame->LastVisibleCtrl = frame->FirstVisibleCtrl;
+
+ for ( i = frame->FirstVisibleCtrl; i < frame->ControlCount; i++, control++ )
+ {
+ ControlTop = CurrHeight;
+
+ //Check conditional
+ u8ChkResult = CheckControlCondition( &((*control)->ControlData) );
+
+ if(*control == NULL)
+ {
+ gApp->CompleteRedraw = TRUE;
+ return EFI_UNSUPPORTED;
+ }
+
+ if(u8ChkResult == COND_NONE || u8ChkResult == COND_GRAYOUT)
+ {
+// EIP47608 +>>
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ if(frame->FrameData.FrameType == MAIN_FRAME)
+ {
+ UINT16 height=0;
+ (*control)->Methods->GetControlHeight( *control, (VOID*)frame,&height);
+ height = height ? height:1;
+ (*control)->Methods->SetDimensions( *control,
+ frame->FrameData.Width - (UINT8)gLabelLeftMargin - 2,
+ height );
+ }
+ }
+// EIP47608 <<+
+
+ //Control is drawn increament height
+ CurrHeight = CurrHeight + (*control)->Height;
+ if((frame->ControlCount > 1) && ((frame->FrameData.Top +frame->FrameData.Height) < CurrHeight+1 ))
+ {
+ break;
+ }
+ else
+ {
+ frame->LastVisibleCtrl = i;
+ }
+ }
+
+ //If token TSE_SETUP_GRAYOUT_SELECTABLE is enable to make GrayoutIf control to focus and selectable
+ if (IsGrayoutSelectable())
+ u8ChkMask = COND_NONE | COND_GRAYOUT;
+ else
+ u8ChkMask = COND_NONE;
+
+ if ((u8ChkResult & ~u8ChkMask) != 0)
+ {
+ //Control grayed out or suppressed
+ if(frame->CurrentControl == i)
+ {
+ //Current control cant be focused
+ (*control)->Methods->SetFocus(*control,FALSE);
+ bCurrNotFocused = TRUE;
+ }
+ }
+
+ (*control)->Methods->SetPosition( *control, (*control)->Left, ControlTop);
+ }
+
+ //Current control can not be focused? Find another one to focus.
+ if(bCurrNotFocused)
+ {
+ control = frame->ControlList;
+ control = control+ frame->FirstVisibleCtrl;
+
+ for ( i = frame->FirstVisibleCtrl; i <= frame->LastVisibleCtrl; i++, control++ )
+ {
+ if ( (*control)->Methods->SetFocus( *control, TRUE ) == EFI_SUCCESS )
+ {
+ frame->CurrentControl = i;
+ break;
+ }
+ }
+
+ if(i > frame->LastVisibleCtrl)
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ }
+
+ //Draw controls in the set positions
+ control = frame->ControlList;
+ control = control + frame->FirstVisibleCtrl;
+ for ( i = frame->FirstVisibleCtrl; i <= frame->LastVisibleCtrl; i++, control++ )
+ {
+ (*control)->Methods->Draw( *control );
+ }
+
+ CurrHeight = frame->FrameData.Top;
+ for (count = 0; count < frame->ControlCount; count++)
+ {
+ u8ChkResult = COND_NONE;
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[count]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ visibleControlCount++ ;
+ CurrHeight = CurrHeight + frame->ControlList[count]->Height;
+
+ if(count <= frame->LastVisibleCtrl)//EIP:48377/49548 Calculating the actual vlaue of CurrentvisibleControl when suppressed controls are present
+ CurrentvisibleControlCount++;
+ if(count < frame->FirstVisibleCtrl)//EIP:48377/49548 Calculating the actual vlaue of FirstvisibleControl when suppressed controls are present
+ CurrentFirstvisibleControlCount++;
+ FrameLastVisibleControl = count;
+ }
+ }
+
+ //EIP:72349
+ if(frame->FrameData.FrameType == MAIN_FRAME)
+ {
+ // Total height of all drawable controls, takes care of multi-line issues
+ visibleControlHeight = (UINT32)(CurrHeight - frame->FrameData.Top);
+
+ // if already have a Scroll bar and due some changes (some controls may bedisabled) we don't need a scroll bar in this frame.
+ if((frame->UseScrollbar) && ((frame->FrameData.Top + frame->FrameData.Height) >= CurrHeight+1))
+ {
+ bEraseScrollBar = TRUE;
+ frame->UseScrollbar = FALSE;
+ }
+
+ // if we don't have a Scroll bar and due some changes (some controls may be enabled) we need a scroll bar in this frame.
+ if((frame->ControlCount > 1) && (!frame->UseScrollbar) && ((frame->FrameData.Top + frame->FrameData.Height) < CurrHeight+1))
+ {
+ frame->UseScrollbar = TRUE;
+ }
+
+ if(visibleControlCount==0)visibleControlCount=1;
+
+ //Scroll bar coordinates are updated based on the controls in the frame
+ numOfBlocks = frame->FrameData.Height - 2;
+
+ // Find the top position, considering multi-line controls may be present
+ for(count=0; count < frame->FirstVisibleCtrl; count++)
+ {
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[count]->ControlData) );
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ topPos += frame->ControlList[count]->Height;
+ }
+ }
+
+ // Find the last position, considering multi-line controls may be present
+ for(count=0; count < frame->LastVisibleCtrl; count++)
+ {
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[count]->ControlData) );
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ lastPos += frame->ControlList[count]->Height;
+ }
+ }
+
+ // EIP_79963 Start
+ //Special case, check if total lines is 1 greater than a filled frame (visible controls)
+ if( (visibleControlHeight > (UINT32)(frame->FrameData.Height-1)) &&
+ ((visibleControlHeight - (UINT32)(frame->FrameData.Height-1)) < 2) )
+ {
+ visibleControlHeight += 1 ;
+ MltCnt = 1 ;
+ }
+ //EIP_79963 End
+
+ if (visibleControlHeight)
+ {
+ FirstLine = (((frame->FrameData.Height - 1) * topPos)/visibleControlHeight )+ frame->FrameData.Top;
+ LastLine = (((frame->FrameData.Height - 1) * lastPos)/visibleControlHeight )+ frame->FrameData.Top;
+ sizeOfBar = ((frame->FrameData.Height - 1) * numOfBlocks) / visibleControlHeight;
+ modVal = ((((frame->FrameData.Height - 1) * numOfBlocks) % visibleControlHeight)* numOfBlocks) > (numOfBlocks/2) ? 1 : 0;
+ }
+
+ //EIP_79963 Start
+ if(((frame->LastVisibleCtrl < frame->ControlCount-1 )&&(FirstLine > (UINT32)(frame->FrameData.Height-2) )) || (frame->LastVisibleCtrl == FrameLastVisibleControl) ||
+ ((frame->FirstVisibleCtrl > 0) && (FirstLine == frame->FrameData.Top)) )
+ {
+ if( (frame->FrameData.Top+topPos) < (UINT16)(frame->FrameData.Height-2))
+ {
+ if(MltCnt)
+ {
+ FirstLine = frame->FrameData.Top+topPos; //Providing the top postion value for immediate scroll after the (frame->FrameData.Height-2) reached
+ LastLine = FirstLine + sizeOfBar+1;//Providing the appopriate lastline
+ }
+ }
+ }
+ //EIP_79963 End
+
+ // Minimum scrollbar size is 1
+ if( ((LastLine - FirstLine)< 2) || (sizeOfBar == 0) )
+ {
+ sizeOfBar = 1 ;
+ }
+
+ // Scrollbar size must remain constant
+ if((LastLine - FirstLine - 1) != sizeOfBar)
+ {
+ //Check the maximum scrollbar boundry
+ if((FirstLine + sizeOfBar + 1) > (UINT32)(frame->FrameData.Top + frame->FrameData.Height - 2))
+ {
+ //Set the maximum scrollbar boundry
+ FirstLine = frame->FrameData.Top + frame->FrameData.Height - 2 - sizeOfBar - 1 ;
+ }
+
+ LastLine = FirstLine + sizeOfBar + 1 ;
+ }
+
+ if(MAIN_FRAME == frame->FrameData.FrameType)//EIP-67049 To store Scrollbar Top and Bottom positon
+ {
+ gFrameScrollBarTop = FirstLine;
+ gFrameScrollBarBottom = LastLine;
+ }
+
+ // draw scrollbar if necessary
+ StyleDrawScrollBar(frame, FirstLine, LastLine, modVal, sizeOfBar, numOfBlocks, bEraseScrollBar);
+
+ }//EIP:72349
+
+ FlushLines( frame->FrameData.Top, frame->FrameData.Top + frame->FrameData.Height );
+
+// if((!TSEMouseIgnoreMouseActionHook())&&((frame->ControlList[frame->CurrentControl]->ControlData.ControlType == CONTROL_TYPE_DATE)||(frame->ControlList[frame->CurrentControl]->ControlData.ControlType == CONTROL_TYPE_TIME)))
+// if(MAIN_FRAME == frame->FrameData.FrameType)
+// NumericSoftKbdInit();
+
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameDrawScrollBar
+//
+// Description: Draws the scrollbar controls for the frame..
+//
+// Input: FRAME_DATA *frame - Pointer to the current frame
+// UINT32 FirstLine - FirstLine of the scrollbar
+// UINT32 LastLine - LastLine
+// UINT32 modVal - modVal
+// UINT32 sizeOfBar - Size of the Scrollbar
+// UINT32 numOfBlocks - Number of blocks
+// BOOLEAN bEraseScrollBar - flag to erase the scrollbar
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a next page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS FrameDrawScrollBar (FRAME_DATA *frame, UINT32 FirstLine, UINT32 LastLine, UINT32 modVal, UINT32 sizeOfBar, UINT32 numOfBlocks, BOOLEAN bEraseScrollBar)
+{
+ UINT32 i, j ;
+ CHAR16 ArrUp[2]={{GEOMETRICSHAPE_UP_TRIANGLE},{0x0000}} ;
+ CHAR16 ArrDown[2]={{GEOMETRICSHAPE_DOWN_TRIANGLE},{0x0000}};
+ CHAR16 ScrlSel[2]={{BLOCKELEMENT_FULL_BLOCK/*L'N'*/},{0x0000}};
+ CHAR16 ScrlNSel[2]={{BLOCKELEMENT_LIGHT_SHADE/*L'S'*/},{0x0000}};
+
+
+ // draw scrollbar if necessary
+ if ( frame->BlankLine != NULL )
+ {
+ j = frame->FrameData.Top;
+ for ( i = 1; i < frame->FrameData.Height; i++, j++ )
+ {
+ // use this loop to draw the scrollbar
+ if(frame->UseScrollbar)
+ {
+ if(i==1)
+ DrawStringWithAttribute( frame->FrameData.Left + frame->FrameData.Width , j, ArrUp,
+ StyleGetScrollBarUpArrowColor() );
+ else if(i==(UINT16)(frame->FrameData.Height - 1))
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width, j, ArrDown,
+ StyleGetScrollBarDownArrowColor() );
+ else
+ {
+ if( (j > FirstLine) && (j < LastLine) && ((sizeOfBar + modVal) != 0))////EIP:48377/49548 commented based on the draw of scrollbar.
+ {
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width, j, ScrlSel,
+ StyleGetScrollBarColor() );
+ sizeOfBar--;
+ }
+ else
+ {
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width, j, ScrlNSel,
+ StyleGetScrollBarColor() );
+ }
+ }
+ }
+ else if (bEraseScrollBar == TRUE)
+ DrawStringWithAttribute( frame->FrameData.Left+ frame->FrameData.Width, j, L" ",
+ StyleGetScrollBarColor() );
+
+ }
+ bEraseScrollBar = FALSE;
+ }
+
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: CheckKeyinHotKeysList
+//
+// Description: For Inconsistence condition checking for Hotkeys pressed to show the popup
+//
+// Input: AMI_EFI_KEY_DATA Key
+//
+// Output: BOOLEAN
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckKeyinHotKeysList(AMI_EFI_KEY_DATA Key)
+{
+ UINT16 index=0;
+ for(index=0; index <= gHotKeyCount; index++)
+ {
+ if( (!EfiCompareMem(&Key, &gHotKeyInfo[index], sizeof(EFI_INPUT_KEY)) ) &&
+ ( TseCheckShiftState( Key, gHotKeyInfo[index].KeySftSte ) ) )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameHandleAction
+//
+// Description: Action handler for specific frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// ACTION_DATA *action - Specific action for the frame
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS FrameHandleAction( 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];
+
+ 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 );
+
+ if (EFI_ERROR(Status))
+ Status = StyleFrameHandleKey( frame, action->Input.Data.AmiKey.Key );
+
+ //EIP76810 : Ckecking Inconsistence for the current control
+ if (EFI_ERROR(Status))
+ {
+ if(( ControlActionUnknown != MapControlKeysHook(action->Input.Data.AmiKey))||(CheckKeyinHotKeysList(action->Input.Data.AmiKey)))
+ {//If the control action is known and if its hot key only we are popuping up the ERROR popup
+ if( CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[gApp->CurrentPage])) )
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );//Clearing the action if it is valid key pressed
+ }
+ }
+
+ 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;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FrameSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: FRAME_DATA *frame, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FrameSetCallback( FRAME_DATA *frame, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( frame, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: FrameAddControl
+//
+// Description: Adds controls to the frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// CONTROL_INFO *controlData - Control date to be added
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FrameAddControl( FRAME_DATA *frame, CONTROL_INFO *controlData )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA **control;
+ POSITION_INFO *pos;
+ UINT16 count = (UINT16)frame->ControlCount;
+ UINT16 i;
+ BOOLEAN IsValidControl = FALSE;
+ gActiveFrame = frame;
+ control = MemReallocateZeroPool( frame->ControlList, count * sizeof(CONTROL_INFO *), (count + 1) * sizeof(CONTROL_INFO *) );
+
+ if ( control == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ frame->ControlList = control;
+ control = &frame->ControlList[ count ];
+
+ for(i=0;gTseControlMap[i].ControlType != CONTROL_TYPE_NULL;i++)
+ {
+ if(gTseControlMap[i].ControlType == controlData->ControlType)
+ {
+ Status = gTseControlMap[i].ControlMethods->Create(control);
+ if ( ! EFI_ERROR(Status) )
+ {
+ if(gTseControlMap[i].CallbackSuppored )
+ gTseControlMap[i].ControlMethods->SetCallback(*control, frame,
+ (OBJECT_CALLBACK)(UINTN)gTseControlMap[i].CallbackFunction,
+ (VOID*)gTseControlMap[i].CallbackContext);
+ }
+ IsValidControl = TRUE;
+ }
+ }
+
+ if(!IsValidControl)
+ {
+ if(controlData->ControlType == CONTROL_TYPE_NULL )
+ frame->NullCount++;
+ return Status;
+ }
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ Status = (*control)->Methods->Initialize( *control, controlData );
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ UINT16 height = 1;
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+
+ //EIP-127577 Start, commented in order to remove the delay before entering Setup.
+ // For Multi-line support, GetControlHeight is called again during the draw phase.
+ /*
+ if(IsTSEMultilineControlSupported())
+ {
+ Status = (*control)->Methods->GetControlHeight( *control, (VOID*)frame,&height);
+ height = height ? height:1;
+ }
+ */
+ //EIP-127577 End
+
+ if(frame->FrameData.FrameType == SUBTITLE_FRAME)
+ (*control)->Methods->SetDimensions( *control, frame->FrameData.Width , height );
+ else
+ (*control)->Methods->SetDimensions( *control, frame->FrameData.Width - (UINT8)gLabelLeftMargin - 2 , height );
+
+ (*control)->ParentFrameType = frame->FrameData.FrameType ;
+
+ frame->ControlCount++;
+ count++;
+
+ (*control)->Methods->SetPosition( *control, frame->FrameData.Left + (UINT8)gLabelLeftMargin, frame->FrameData.Top + count -1 );
+
+
+ if( EFI_ERROR( StyleHandleControlOverflow( frame, frame->ControlList[ count -1 ], (UINT16)frame->ControlCount )) )
+ {
+ frame->LastVisibleCtrl = frame->ControlCount-1;
+ }
+
+ // set position information
+ pos = MemReallocateZeroPool( frame->OrigPosition, (count-1) * sizeof(POSITION_INFO), (count ) * sizeof(POSITION_INFO) );
+ if ( pos != NULL )
+ {
+ pos[count-1].Left = (*control)->Left;
+ pos[count-1].Top = (*control)->Top;
+ frame->OrigPosition = pos;
+ }
+
+ MemFreePointer( (VOID **)&frame->CurrPosition );
+ frame->CurrPosition = EfiLibAllocateZeroPool( count * sizeof(POSITION_INFO) );
+
+ }
+
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FrameHandleKey
+//
+// Description: Controls Keyboard action for each frame
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// EFI_INPUT_KEY key - Key pressed in the keyboard
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _FrameHandleKey( FRAME_DATA *frame, AMI_EFI_KEY_DATA key )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_ACTION Action;
+
+
+ //Get mapping
+ Action = MapControlKeysHook(key);
+
+ switch (Action)
+ {
+ case ControlActionNextUp:
+ Status = _FrameScroll( frame, TRUE);
+ break;
+
+ case ControlActionNextDown:
+ Status = _FrameScroll( frame, FALSE);
+ break;
+
+ case ControlActionPageUp:
+ Status = _PreviousFrame(frame);
+ break;
+
+ case ControlActionPageDown:
+ Status = _NextFrame(frame);
+ break;
+
+ case ControlActionHome:
+ Status = _FocusFirst(frame);
+ break;
+
+ case ControlActionEnd:
+ Status = _FocusLast(frame);
+ break;
+
+ default:
+ Status = EFI_UNSUPPORTED;
+ break;
+ }
+
+// if ( ! EFI_ERROR( Status ) )
+// {
+// if((TSEMouseIgnoreMouseActionHook())&&((frame->ControlList[frame->CurrentControl]->ControlData.ControlType != CONTROL_TYPE_DATE)&&(frame->ControlList[frame->CurrentControl]->ControlData.ControlType != CONTROL_TYPE_TIME)))
+// NumericSoftKbdExit();
+// if((!TSEMouseIgnoreMouseActionHook())&&((frame->ControlList[frame->CurrentControl]->ControlData.ControlType == CONTROL_TYPE_DATE)||(frame->ControlList[frame->CurrentControl]->ControlData.ControlType == CONTROL_TYPE_TIME)))
+// NumericSoftKbdInit();
+// }
+ return Status;
+}
+
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FrameScroll
+//
+// Description: Adds scroll bar functionality for frames with many controls
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// BOOLEAN bScrollUp - Go up is TRUE, else to down one control
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _FrameScroll( FRAME_DATA *frame, BOOLEAN bScrollUp )
+{
+ UINT32 thisControl = frame->CurrentControl;
+ BOOLEAN bDone = FALSE;
+ UINT32 *pOtherEnd = NULL;
+ UINT8 u8ChkResult;
+
+ if ( frame->ControlCount == 0 )
+ return EFI_UNSUPPORTED;
+
+ switch ( bScrollUp )
+ {
+ case TRUE:
+ if (thisControl == FRAME_NONE_FOCUSED)
+ thisControl = frame->FirstVisibleCtrl;
+
+ if(thisControl < frame->FirstVisibleCtrl)
+ thisControl = frame->FirstVisibleCtrl;
+
+ //See if there are some controls that can be focused in the screen
+ while (thisControl != frame->FirstVisibleCtrl)
+ {
+ thisControl--;
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ bDone = TRUE;
+ break;
+ }
+ }
+
+ if (!bDone)
+ {
+ // No controls that can be focused is left move up til we find a unsuppressed control
+ while(thisControl)
+ {
+ thisControl--;
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[thisControl]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ frame->FirstVisibleCtrl = thisControl;
+ pOtherEnd = &(frame->LastVisibleCtrl);
+ _FrameSetControlFocus( frame, thisControl);
+ bDone = TRUE;
+ break;
+ }
+ }
+
+ // If no control can be found roll to last visible page
+ if (!bDone && StyleGetScrollBehavior())
+ {
+ thisControl = frame->LastVisibleCtrl = frame->ControlCount;
+ do
+ {
+ thisControl--;
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[thisControl]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ frame->LastVisibleCtrl = thisControl;
+ pOtherEnd = &(frame->FirstVisibleCtrl);
+ bDone = TRUE;
+ break;
+ }
+ }while(thisControl);
+ }
+
+ if(!bDone)
+ {
+ //No control can be shown in this whole frame
+ //Blaines EIP#13293
+ if(StyleGetScrollBehavior())
+ frame->FirstVisibleCtrl = frame->LastVisibleCtrl = 0;
+ return EFI_UNSUPPORTED;
+ }
+
+ // Calculate other end
+ StyleFrameSetControlPositions(frame, pOtherEnd);
+
+ if(pOtherEnd == &(frame->FirstVisibleCtrl))
+ {
+ //We rolled to last page; find if we can focus one
+ while (thisControl >= frame->FirstVisibleCtrl)
+ {
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ break;
+ }
+ if(thisControl == 0)
+ break;
+ thisControl--;
+ }
+ }
+
+ //De-focus if we have no control that can be focused in the screen
+ if(frame->CurrentControl != FRAME_NONE_FOCUSED)
+ {
+ if((frame->CurrentControl < frame->FirstVisibleCtrl) || (frame->CurrentControl > frame->LastVisibleCtrl))
+ {
+ (frame->ControlList[frame->CurrentControl])->Methods->SetFocus(frame->ControlList[frame->CurrentControl],FALSE);
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ }
+ }
+ }
+ break;
+
+ case FALSE:
+ if (thisControl == FRAME_NONE_FOCUSED)
+ thisControl = frame->LastVisibleCtrl;
+
+ if(thisControl > frame->LastVisibleCtrl)
+ thisControl = frame->LastVisibleCtrl;
+
+ //See if there are some controls that can be focused in the screen
+ while (thisControl != frame->LastVisibleCtrl)
+ {
+ thisControl++;
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ bDone = TRUE;
+ break;
+ }
+ }
+
+ if (!bDone)
+ {
+ // No controls that can be focused is left move down til we find an unsuppressed control
+ while((frame->ControlCount - 1) != thisControl)
+ {
+ thisControl++;
+
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[thisControl]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ frame->LastVisibleCtrl = thisControl;
+ pOtherEnd = &(frame->FirstVisibleCtrl);
+ _FrameSetControlFocus( frame, thisControl);
+ bDone = TRUE;
+ break;
+ }
+ }
+
+ // If no control can be found roll to First visible page
+ //EIP#13293
+ if (!bDone && StyleGetScrollBehavior())
+ {
+ thisControl = frame->FirstVisibleCtrl = 0;
+ while(thisControl < frame->ControlCount)
+ {
+ //EIP 75486 Support grayout condition for readonly controls
+ u8ChkResult = CheckControlCondition( &(frame->ControlList[thisControl]->ControlData) );
+
+ if((COND_NONE == u8ChkResult) || (COND_GRAYOUT == u8ChkResult))
+ {
+ //frame->FirstVisibleCtrl = thisControl;
+ pOtherEnd = &(frame->LastVisibleCtrl);
+ bDone = TRUE;
+ break;
+ }
+
+ if((thisControl + 1) == frame->ControlCount) //this while loop breaks here before while statement
+ break;
+ thisControl++;
+ }
+ }
+
+ if(!bDone)
+ {
+ //No control can be shown in this whole frame
+ //Blaines EIP#13293
+ if(StyleGetScrollBehavior())
+ frame->FirstVisibleCtrl = frame->LastVisibleCtrl = 0;
+ return EFI_UNSUPPORTED;
+ }
+
+ //Calculate other end
+ StyleFrameSetControlPositions(frame, pOtherEnd);
+
+ if(pOtherEnd == &(frame->LastVisibleCtrl))
+ {
+ //We rolled to First page; find if we can focus one
+ while (thisControl <= frame->LastVisibleCtrl)
+ {
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ break;
+ }
+ thisControl++;
+ }
+ }
+
+ //De-focus if we have no control that can be focused in the screen
+ if(frame->CurrentControl != FRAME_NONE_FOCUSED)
+ {
+ if((frame->CurrentControl < frame->FirstVisibleCtrl) || (frame->CurrentControl > frame->LastVisibleCtrl))
+ {
+ (frame->ControlList[frame->CurrentControl])->Methods->SetFocus(frame->ControlList[frame->CurrentControl],FALSE);
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+ }
+ }
+ }
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FrameSubmenuCallback
+//
+// Description: Function to set frame submenu callback.
+//
+// Input: FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _FrameSubmenuCallback( FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CALLBACK_SUBMENU *callbackData = (CALLBACK_SUBMENU *)cookie;
+
+ if ( ( callbackData == NULL ) || ( callbackData->Header.Type != CALLBACK_TYPE_SUBMENU ) )
+ return;
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ gApp->CurrentPage = callbackData->DestPage;
+//EIP: 55762 Start
+ if(submenu->ControlData.DestQuestionID != 0){
+ UINT32 FocusControlIndex = 0;
+
+ Status = UpdateDestiantionQuestion(gApp->CurrentPage, submenu->ControlData.DestQuestionID, &FocusControlIndex);
+ if(Status == EFI_SUCCESS){
+ UINT32 MainFrameIndex = 0;
+ FRAME_DATA *MainFrame = NULL;
+ PAGE_DATA *pageData = gApp->PageList[gApp->CurrentPage];
+ MainFrameIndex = StyleFrameIndexOf(MAIN_FRAME);
+ MainFrame = pageData->FrameList[MainFrameIndex];
+ _FrameSetControlFocus(MainFrame, FocusControlIndex);
+ }
+ }
+ }
+//EIP: 55762 End
+ gApp->CompleteRedraw = TRUE;
+ gApp->OnRedraw = SUBMENU_COMPLETE_REDRAW;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FrameMenuCallback
+//
+// Description: Function to set frame menu callback.
+//
+// Input: FRAME_DATA *frame, MENU_DATA *menu, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _FrameMenuCallback( FRAME_DATA *frame, MENU_DATA *menu, VOID *cookie )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CALLBACK_MENU *callbackData = (CALLBACK_MENU *)cookie;
+
+ if ( ( callbackData == NULL ) || ( callbackData->Header.Type != CALLBACK_TYPE_MENU ) )
+ return;
+
+ if ( ! EFI_ERROR( Status ) )
+ gApp->CurrentPage = callbackData->DestPage;
+ gApp->CompleteRedraw = TRUE;
+ gApp->OnRedraw = MENU_COMPLETE_REDRAW;
+//EIP: 58925 Start
+ if(IsLinkHistorySupport())
+ {
+ ResetNavStack();
+ }
+//EIP: 58925 End
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FrameVariableCallback
+//
+// Description: Function to set frame variable callback.
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _FrameVariableCallback( FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie )
+{
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)cookie;
+
+ if ( ( callbackData == NULL ) || ( callbackData->Header.Type != CALLBACK_TYPE_VARIABLE ) )
+ return;
+
+ if ( callbackData->Variable >= gVariables->VariableCount )
+ return;
+
+ VarSetValue( callbackData->Variable, callbackData->Offset, callbackData->Length, callbackData->Data );
+
+ if ( control->ControlData.ControlFlags.ControlReset )
+ gResetRequired = TRUE;
+
+}
+BOOLEAN TSEPwdSavetoNvram(VOID);//EIP 93881 & 93873 : Save pwd to nvram and not loading empty pwd on loading defaults.
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FramePasswordCallback
+//
+// Description: Function to set frame password callback.
+//
+// Input: FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _FramePasswordCallback( FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie )
+{
+ CALLBACK_PASSWORD *callbackData = (CALLBACK_PASSWORD *)cookie;
+ CHAR16 *saveData = NULL;
+
+ if ( ( callbackData == NULL ) || ( callbackData->Header.Type != CALLBACK_TYPE_PASSWORD ) )
+ return;
+
+ if ( callbackData->Variable >= gVariables->VariableCount )
+ return;
+
+ saveData = (CHAR16 *)callbackData->Data;
+
+ if(FramePwdCallbackIdePasswordUpdate ( control,saveData) != EFI_SUCCESS)
+ {
+//EIP 23354 : Start
+ if( IsPasswordEncodeEnabled(&control->ControlData) )
+ saveData = PasswordUpdate( callbackData->Data, callbackData->Length);
+//EIP 23354 : End
+
+ if ( saveData )
+ {
+//EIP 93881 & 93873 : Save pwd to nvram and not loading empty pwd on loading defaults.
+ if((TSEPwdSavetoNvram())&&( VARIABLE_ID_AMITSESETUP == callbackData->Variable ))
+ {
+ AMITSESETUP *TempSaveData = (AMITSESETUP *)NULL;
+ UINTN size=0;
+ TempSaveData = (AMITSESETUP *) EfiLibAllocateZeroPool(sizeof(AMITSESETUP));
+ size = sizeof(AMITSESETUP);
+
+ TempSaveData = VarGetNvram(VARIABLE_ID_AMITSESETUP, &size);
+ MemCopy( ((UINT8*)(TempSaveData))+(callbackData->Offset), saveData, callbackData->Length );
+ VarSetNvram( VARIABLE_ID_AMITSESETUP, TempSaveData, sizeof(AMITSESETUP));
+ MemFreePointer( (VOID **)&TempSaveData );
+ }
+ else
+ VarSetValue( callbackData->Variable, callbackData->Offset, callbackData->Length, saveData );
+
+ FramePasswordAdvancedCallback(callbackData,saveData);
+ }
+
+ if ( saveData != callbackData->Data )
+ MemFreePointer( (VOID **)&saveData );
+ }
+
+ if ( control->ControlData.ControlFlags.ControlReset )
+ gResetRequired = TRUE;
+
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FrameSetControlFocus
+//
+// Description: Sets focus on a defined control in the frame
+//
+// Input: FRAME_DATA *frame - Date for a specific frame
+// UINT32 index - Index of the control
+//
+// Output: BOOLEAN focusSet - TRUE if focus is set, FALSE otherwise
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+BOOLEAN _FrameSetControlFocus( FRAME_DATA *frame, UINT32 index )
+{
+ CONTROL_DATA *control;
+ BOOLEAN focusSet = FALSE;
+
+ if ( frame->ControlCount <= index )
+ return focusSet;
+
+ control = frame->ControlList[index];
+ focusSet = (BOOLEAN)(control->Methods->SetFocus( control, TRUE ) == EFI_SUCCESS);
+
+ // de-focus all other controls
+ if ( focusSet )
+ {
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( i == index )
+ continue;
+ control = frame->ControlList[i];
+ control->Methods->SetFocus( control, FALSE );
+ }
+
+ frame->CurrentControl = index;
+ }
+
+ return focusSet;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FrameAddControls
+//
+// Description: Function to add controls in the frame
+//
+// Input: FRAME_DATA *frame, PAGE_INFO *data
+//
+//
+// Output: STATUS
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _FrameAddControls( FRAME_DATA *frame, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ UINT32 i, controlNumber = 0;
+ BOOLEAN focusSet = FALSE;
+
+ for ( i = 0; i < data->PageControls.ControlCount; i++ )
+ {
+ Status = gFrame.AddControl( frame, (CONTROL_INFO *) ((UINT8 *)gControlInfo + data->PageControls.ControlList[i]) );
+ if ( EFI_ERROR(Status) )
+ continue;
+
+ if ( ! focusSet )
+ {
+ if ( _FrameSetControlFocus( frame, controlNumber ) )
+ {
+ frame->CurrentControl = controlNumber;
+ focusSet = TRUE;
+ }
+ }
+ controlNumber++;
+ }
+
+ Status = StyleAddAdditionalControls( frame, controlNumber, focusSet );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FrameAddTitle
+//
+// Description: Function to add tittle to a frame.
+//
+// Input: FRAME_DATA *frame, UINT32 frameNumber, PAGE_INFO *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _FrameAddTitle( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CONTROL_DATA **control;
+ CONTROL_INFO dummy;
+ UINT8 BORDER = (frame->FrameData.Border==TRUE)?1:0 ;
+
+ UINT8 SPACER = 0 ;
+
+
+ control = EfiLibAllocateZeroPool( sizeof(CONTROL_INFO *) );
+ if ( control == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ frame->ControlList = control;
+ Status = gMemo.Create( control );
+
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+ dummy.ControlFlags.ControlVisible = TRUE;
+ dummy.ControlType = CONTROL_TYPE_MEMO;
+
+ switch ( frameType )
+ {
+ case TITLE_FRAME:
+ dummy.ControlPtr = (VOID*)gTitle;
+ break;
+ case HELP_FRAME:
+ dummy.ControlPtr = (VOID*)gHelp;
+ SPACER = 1 ;
+ break;
+ case SUBTITLE_FRAME:
+ dummy.ControlPtr = (VOID*)gSubTitle;
+ break;
+ case HELPTITLE_FRAME:
+ dummy.ControlPtr = (VOID*)gHelpTitle;
+ break;
+ case NAV_FRAME:
+ dummy.ControlPtr = (VOID*)gNavStrings;
+ break;
+ default:
+ if(StyleFrameAddTitle(frame, frameType,&dummy) != EFI_SUCCESS)
+ {
+ gMemo.Destroy( *control, TRUE );
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ (*control)->ParentFrameType = frame->FrameData.FrameType ;
+ gMemo.Initialize( *control, &dummy );
+ gMemo.SetPosition( *control, frame->FrameData.Left+BORDER, frame->FrameData.Top+BORDER );
+ gMemo.SetDimensions( *control, frame->FrameData.Width-SPACER-2*BORDER, frame->FrameData.Height-2*BORDER );
+ gMemo.SetAttributes( *control, frame->FrameData.FGColor, frame->FrameData.BGColor );
+ if((IsMouseSupported()) && (frameType == NAV_FRAME))
+ {
+ (*control)->FGColor = FOCUS_COLOR;
+ }
+ frame->ControlCount++;
+
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _PreviousFrame
+//
+// Description: Loads the controls from the previous frame into the screen.
+//
+// Input: FRAME_DATA *frame = Pointer to the current frame
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a previous page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _PreviousFrame (FRAME_DATA *frame)
+{
+ UINT32 thisControl;
+ BOOLEAN bFocused;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if(frame->FirstVisibleCtrl > 0)
+ {
+ //return EFI_UNSUPPORTED;
+
+ frame->LastVisibleCtrl = frame->FirstVisibleCtrl-1;
+ StyleFrameSetControlPositions(frame, &(frame->FirstVisibleCtrl));
+
+
+ if(frame->FirstVisibleCtrl<=0)
+ {
+ StyleFrameSetControlPositions(frame, &(frame->LastVisibleCtrl));
+ }
+ }
+
+
+ //Focus a control if possible
+ thisControl = frame->FirstVisibleCtrl;
+ bFocused = FALSE;
+ while (thisControl <= frame->LastVisibleCtrl)
+ {
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ bFocused = TRUE;
+ break;
+ }
+ thisControl++;
+ }
+
+ if (!bFocused)
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+
+ Status = EFI_SUCCESS ;
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _NextFrame
+//
+// Description: Loads the controls from the next frame into the screen.
+//
+// Input: FRAME_DATA *frame = Pointer to the current frame
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a next page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _NextFrame (FRAME_DATA *frame)
+{
+ UINT32 thisControl;
+ BOOLEAN bFocused;
+
+ if(frame->LastVisibleCtrl < (frame->ControlCount-1))
+ {
+ //return EFI_UNSUPPORTED;
+ frame->FirstVisibleCtrl = frame->LastVisibleCtrl + 1;
+
+ StyleFrameSetControlPositions(frame, &(frame->LastVisibleCtrl));
+
+ if(frame->LastVisibleCtrl>=(frame->ControlCount-1))
+ {
+ StyleFrameSetControlPositions(frame, &(frame->FirstVisibleCtrl));
+ }
+ }
+
+
+ //Focus a control if possible
+ /*
+ thisControl = frame->FirstVisibleCtrl;
+ bFocused = FALSE;
+ while (thisControl <= frame->LastVisibleCtrl)
+ {
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ bFocused = TRUE;
+ break;
+ }
+ thisControl++;
+ }
+ */
+
+ //EIP#13118 Set Focus to bottom of page on PageDown
+ thisControl = frame->LastVisibleCtrl;
+ bFocused = FALSE;
+ while (thisControl >= frame->FirstVisibleCtrl)
+ {
+ if ( _FrameSetControlFocus( frame, thisControl ) )
+ {
+ bFocused = TRUE;
+ break;
+ }
+ //EIP:31606 - Fix for hanging issue in case of no active controls in a frame
+ if (thisControl == 0)
+ break;
+
+ thisControl--;
+ }
+
+ if (!bFocused)
+ frame->CurrentControl = FRAME_NONE_FOCUSED;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FocusFirst
+//
+// Description: Set focus to the first control in the frame (in the first page).
+//
+// Input: FRAME_DATA *frame = Pointer to the current frame
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a previous page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _FocusFirst (FRAME_DATA *frame)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ do
+ { //At least once in case there's less than a page
+ Status = _PreviousFrame(frame);
+
+ }while(frame->FirstVisibleCtrl > 0);
+
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: _FocusLast
+//
+// Description: Set focus to the last control in the frame.
+//
+// Input: FRAME_DATA *frame = Pointer to the current frame
+//
+// Output: EFI_STATUS status -
+// EFI_SUCCESS - If there exists a previous page and the
+// function successfully loads it
+// EFI_OUT_PF_RESOURCES - If there are know previous page
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _FocusLast (FRAME_DATA *frame)
+{
+
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ do
+ { //At least once in case there's less than a page
+ Status = _NextFrame(frame);
+
+ }while(frame->LastVisibleCtrl < (frame->ControlCount-1));
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FrameHandleMouse
+//
+// Description: Function to hadnle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// MOUSE_INFO MouseInfo
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _FrameHandleMouse( FRAME_DATA *frame,MOUSE_INFO MouseInfo)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT32 i, Action;
+
+ Action = MapControlMouseActionHook(&MouseInfo);
+ //if(TSEMOUSE_RIGHT_CLICK == MouseInfo.ButtonStatus)
+ if(ControlActionAbort == Action)
+ return Status;
+
+ if ( frame->ControlCount == 0 )
+ return Status;
+
+ //Reset lbutton positions
+ if (ControlMouseActionLeftUp == Action || ControlActionChoose == Action || ControlActionSelect == Action)
+ {
+ lButtonDownInitialPosition = 0;
+ lButtonDownVaringPosition = 0;
+ }
+
+ //For Handling Frame Scroll Bar using Mouse
+ if(frame->UseScrollbar)
+ {
+ //If clicked on scrollbar area
+ if(MouseInfo.Left == (UINT32) frame->FrameData.Left + frame->FrameData.Width)
+ {
+ //If clicked on UP_ARROW
+ if( (MouseInfo.Top == frame->FrameData.Top) /*Arrow Up*/
+ &&((TSEMOUSE_LEFT_CLICK == MouseInfo.ButtonStatus)||(TSEMOUSE_LEFT_DCLICK == MouseInfo.ButtonStatus))//EIP 78929 : Check for left click and left double click to scroll the frame if click on arrow buttons of scroll bar.
+ )
+ MouseScrollBarMove( frame, TRUE, 1 );
+
+ //If clicked on DOWN_ARROW
+ else if( ( MouseInfo.Top == (UINT32) (frame->FrameData.Top + frame->FrameData.Height -2) || MouseInfo.Top == (UINT32) (frame->FrameData.Top + frame->FrameData.Height -3) ) //EIP:48377 Coordinates of Mouse click down arrow operation are updated to work for GTSE and AMITSE.
+ &&((TSEMOUSE_LEFT_CLICK == MouseInfo.ButtonStatus)||(TSEMOUSE_LEFT_DCLICK == MouseInfo.ButtonStatus))//EIP 78929 : Check for left click and left double click to scroll the frame if click on arrow buttons of scroll bar.
+ )
+ MouseScrollBarMove( frame, FALSE, 1 );
+
+ //If mouse clicked below UP_ARROW and above ScrollBar
+ else if( (MouseInfo.Top <= gFrameScrollBarTop) //Clicked above scrollbar
+ && (MouseInfo.Top > frame->FrameData.Top) //Clicked below UP_ARROW
+ && (ControlMouseActionLeftDown == Action)
+ )
+ {
+ MouseScrollBarMove( frame, TRUE, gFrameScrollBarTop-MouseInfo.Top+1 );
+ }
+
+ //If mouse clicked on scrollbar
+ else if( (MouseInfo.Top < gFrameScrollBarBottom) && (MouseInfo.Top > gFrameScrollBarTop) //Clicked on ScrollBar area
+ && (ControlMouseActionLeftDown == Action) // Clicked lbutton down
+ && ((ControlActionChoose != Action) || (ControlActionSelect != Action)) //Neglecting LEFT_DCLICK and LEFT_CLICK on scrollbar area
+ )
+ {
+ if ( lButtonDownInitialPosition == 0 )//To get initial lButtonDown position
+ {
+ lButtonDownInitialPosition = MouseInfo.Top;
+ }
+ if ( lButtonDownInitialPosition != MouseInfo.Top )
+ {
+ lButtonDownVaringPosition = MouseInfo.Top;
+ //Move scrollbar upwards
+ if( lButtonDownInitialPosition > lButtonDownVaringPosition )
+ MouseScrollBarMove( frame, TRUE, lButtonDownInitialPosition - lButtonDownVaringPosition );
+
+ //Move scrollbar downwards
+ else
+ MouseScrollBarMove( frame, FALSE, lButtonDownVaringPosition - lButtonDownInitialPosition );
+ lButtonDownInitialPosition = lButtonDownVaringPosition;
+ }
+ return EFI_SUCCESS;
+ }
+
+ //If mouse clicked above DOWN_ARROW and below ScrollBar
+ else if( (MouseInfo.Top >= gFrameScrollBarBottom)
+ && (MouseInfo.Top < (UINT32) (frame->FrameData.Top + frame->FrameData.Height -2))
+ && (ControlMouseActionLeftDown == Action)
+ )
+ {
+ MouseScrollBarMove( frame, FALSE, MouseInfo.Top-gFrameScrollBarBottom + 1 );
+ }
+ return EFI_SUCCESS;
+ }
+ //If mouse button clicked on scrollbar and moved outside the scroll area
+ else if( ControlMouseActionLeftDown == Action
+ && (lButtonDownInitialPosition != 0)
+ && ((ControlActionChoose != Action) || (ControlActionSelect != Action))
+ )
+ {
+ lButtonDownVaringPosition = MouseInfo.Top;
+ //Move scrollbar upwards
+ if( lButtonDownInitialPosition > lButtonDownVaringPosition )
+ MouseScrollBarMove( frame, TRUE, lButtonDownInitialPosition - lButtonDownVaringPosition );
+
+ //Move scrollbar downwards
+ else
+ MouseScrollBarMove( frame, FALSE, lButtonDownVaringPosition - lButtonDownInitialPosition );
+ lButtonDownInitialPosition = lButtonDownVaringPosition;
+
+ //Reset lButtonDown position when lButton releases
+ if (ControlMouseActionLeftUp == Action)
+ {
+ lButtonDownInitialPosition = lButtonDownVaringPosition = 0;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+
+ //If mouse clicked on frame without scrollbar support
+ if(!((MouseInfo.Top >= (UINT32)frame->FrameData.Top) && (MouseInfo.Left > (UINT32)(frame->FrameData.Width+1) )) //Clicked other than scrollbar area
+ && (ControlMouseActionLeftUp != Action) //Neglecting LEFT_UP action
+ )
+ {
+ //Find control that was clicked
+ for(i=frame->FirstVisibleCtrl; i<=frame->LastVisibleCtrl; i++)
+ {
+ if( (MouseInfo.Top >= frame->ControlList[i]->Top) && (MouseInfo.Top < (UINT32)(frame->ControlList[i]->Top + frame->ControlList[i]->Height)) )
+ {
+ //This is the control; select it.
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ // if((TSEMouseIgnoreMouseActionHook())&&((frame->ControlList[i]->ControlData.ControlType != CONTROL_TYPE_DATE)&&(frame->ControlList[i]->ControlData.ControlType != CONTROL_TYPE_TIME)))
+ // NumericSoftKbdExit();
+ // if((!TSEMouseIgnoreMouseActionHook())&&((frame->ControlList[i]->ControlData.ControlType == CONTROL_TYPE_DATE)||(frame->ControlList[i]->ControlData.ControlType == CONTROL_TYPE_TIME)))
+ // NumericSoftKbdInit();
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEMouseFrameHandleAction
+//
+// Description: Function to hadnle frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// ACTION_DATA *action,
+// CONTROL_DATA **control
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TSEMouseFrameHandleAction( FRAME_DATA *frame, ACTION_DATA *action,CONTROL_DATA **control )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if( (action->Input.Data.MouseInfo.Top >= (UINT32)frame->FrameData.Top) && (action->Input.Data.MouseInfo.Left > (UINT32)(frame->FrameData.Width+1) ) )
+ {
+ TSEMouseHelpFrameHandleAction(frame, action, control);
+ }
+
+ //EIP-123727 check whether Current Control is with in the Visible Area or not.
+ if ( control != NULL && (frame->CurrentControl >= frame->FirstVisibleCtrl && frame->CurrentControl <= frame->LastVisibleCtrl))
+ Status = (*control)->Methods->HandleAction( *control, action );
+
+
+ if (EFI_ERROR(Status))
+ Status = StyleFrameHandleMouse( frame, action->Input.Data.MouseInfo );
+
+ //EIP76810 : Ckecking Inconsistence for the current control
+ if (EFI_ERROR(Status))
+ {
+ if( CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[gApp->CurrentPage])) )
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ }
+
+ if (EFI_ERROR(Status))
+ Status = _FrameHandleMouse( frame, action->Input.Data.MouseInfo);
+
+ return Status;
+}
+
+//EIP:62098 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TSEMouseHelpFrameHandleAction
+//
+// Description: Function to hadnle help frame using mouse
+//
+// Input: FRAME_DATA *frame,
+// ACTION_DATA *action,
+// CONTROL_DATA **control
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TSEMouseHelpFrameHandleAction( FRAME_DATA *frame, ACTION_DATA *action,CONTROL_DATA **control )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ MEMO_DATA *memo;
+ BOOLEAN bScrollBar = FALSE;
+ CHAR16 *text = NULL;
+ UINT16 height = 0;
+
+ control = frame->ControlList;
+ control = control+ frame->FirstVisibleCtrl;
+ memo = (MEMO_DATA *) *control;
+
+ if( memo->ParentFrameType != HELP_FRAME )
+ return Status;
+ else
+ {
+ text = HiiGetString( memo->ControlData.ControlHandle,UefiGetTitleField( (VOID *)memo->ControlData.ControlPtr));
+
+ if ( text == NULL )
+ return Status;
+
+ if ( EfiStrLen(text) == 0)
+ {
+ // String is empty but memory is allocated.
+ MemFreePointer( (VOID **)&text );
+ return Status;
+ }
+
+ // clear out old wrapped string
+ //EIP-131365 Here gActiveBuffer will update with EmptyString and clear HelpFrame characters. This causes help area flickers when mouse action happens.
+ //for ( pos = 0; pos < memo->Height; pos++ )
+ //DrawStringWithAttribute( memo->Left, memo->Top + pos, memo->EmptyString, memo->FGColor | memo->BGColor );
+
+ // XXX: this wrapping code is probably not compatible with all languages
+ StringWrapText( text, memo->Width, &height );
+ if(height == 0)
+ return Status;
+
+ bScrollBar = ( (height > memo->Height) && (memo->ParentFrameType == HELP_FRAME /*memo->Top == MAIN_TOP*/) ) ? 1 : 0;
+
+ if(bScrollBar && (action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_LEFT_CLICK))
+ {
+
+ if((action->Input.Data.MouseInfo.Top == (frame->FrameData.Top + frame->FrameData.Height -1))&&(action->Input.Data.MouseInfo.Left == frame->FrameData.Width + frame->FrameData.Left -1 ))
+ _HelpFrameScroll( memo, FALSE);
+
+ if(((action->Input.Data.MouseInfo.Top == frame->FrameData.Top) ||(action->Input.Data.MouseInfo.Top == frame->FrameData.Top -1))
+ && (action->Input.Data.MouseInfo.Left == frame->FrameData.Width + frame->FrameData.Left -1) )
+ _HelpFrameScroll( memo, TRUE);
+
+
+ }
+ else
+ return Status;
+ }
+
+ return Status;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HelpFrameScroll
+//
+// Description: Function to hadnle help frame scroll using mouse
+//
+// Input: FRAME_DATA *frame,
+// ACTION_DATA *action,
+// CONTROL_DATA **control
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _HelpFrameScroll(MEMO_DATA *memo,BOOLEAN bScrollUp)
+{
+ switch(bScrollUp)
+ {
+
+ case FALSE:
+ if( memo->ParentFrameType == HELP_FRAME)
+ {
+ // Incrementing the ScrollBarPosition.
+ memo->ScrollBarPosition++;
+ // Based upon ScrollBarPosition drawing the Memo again.
+ gMemo.Draw(memo);
+ }
+ break;
+
+ case TRUE:
+ if( memo->ParentFrameType == HELP_FRAME)
+ {
+ // Decrementing ScrollBarPosition
+ if( memo->ScrollBarPosition != 0 )
+ memo->ScrollBarPosition--;
+ else
+ memo->ScrollBarPosition = 0;
+ gMemo.Draw(memo);
+ }
+ break;
+ default:
+ return ;
+ }
+
+}
+//EIP:62098 END
+
+//EIP-67049 Start
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------
+//
+// Name: TSEMouseScrollBarMove
+//
+// Description: Adds scroll bar functionality for frames with many controls
+//
+// Input: FRAME_DATA *frame - Pointer to the frame data
+// BOOLEAN bScrollUp - Go up is TRUE, else to down one control
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else
+// EFI_UNSUPPORTED
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS TSEMouseScrollBarMove( FRAME_DATA *frame, BOOLEAN bScrollUp, UINT32 Size )
+{
+ CONTROL_DATA *control=NULL;
+ UINTN i=0,IndexOfLastNonSupressctrl=0;
+ UINT8 u8ChkResult;
+
+ if ( frame->ControlCount == 0 )
+ return EFI_UNSUPPORTED;
+
+ switch ( bScrollUp )
+ {
+ case TRUE:
+
+ if( Size >= frame->FirstVisibleCtrl )
+ Size = frame->FirstVisibleCtrl;
+ //If FirstVisibleCtrl is not equal to first control then move scrollbar till it reaches top
+ if(frame->FirstVisibleCtrl > 0)
+ {
+ frame->FirstVisibleCtrl = frame->FirstVisibleCtrl - Size;
+ frame->LastVisibleCtrl = frame->LastVisibleCtrl - Size;
+ }
+ break;
+
+ case FALSE:
+ //If the size of scroll to move exceeds the remaining control count then change the size value based on the remaining control count
+ if( Size >= (frame->ControlCount - frame->LastVisibleCtrl) )
+ Size = frame->ControlCount - frame->LastVisibleCtrl - 1;
+ //get the Index of the Last Non Supress Ctrl in the Frame
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+
+ control = frame->ControlList[i];
+ if(control != NULL)
+ {
+ //Check conditional
+ u8ChkResult = CheckControlCondition(&(control->ControlData ));
+ if(COND_SUPPRESS != u8ChkResult )
+ IndexOfLastNonSupressctrl=i;
+ else
+ continue;
+ }
+ }
+ //If LastVisibleCtrl is not equal to last control then move scrollbar till it reaches bottom
+ if(frame->LastVisibleCtrl < frame->ControlCount-1 && IndexOfLastNonSupressctrl != frame->LastVisibleCtrl)
+ {
+ frame->FirstVisibleCtrl = frame->FirstVisibleCtrl + Size;
+ frame->LastVisibleCtrl = frame->LastVisibleCtrl + Size;
+ }
+ break;
+ }
+ return EFI_SUCCESS;
+}
+//EIP-67049 End
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/frame.h b/EDK/MiniSetup/TseLite/frame.h
new file mode 100644
index 0000000..a33e4e9
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/frame.h
@@ -0,0 +1,221 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/frame.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/frame.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: frame.h
+//
+// Description: Header file for Frame control related functions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _FRAME_H_
+#define _FRAME_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "action.h"
+#include "control.h"
+
+#include "submenu.h"
+#include "menu.h"
+#include "text.h"
+
+#define MAIN_FRAME 0
+#define TITLE_FRAME (MAIN_FRAME + 1)
+#define HELP_FRAME (TITLE_FRAME + 1)
+#define NAV_FRAME (HELP_FRAME + 1)
+#define SUBTITLE_FRAME (NAV_FRAME + 1)
+#define HELPTITLE_FRAME (SUBTITLE_FRAME + 1)
+#define MAINTITLE_FRAME (HELPTITLE_FRAME + 1)
+#define SCROLLBAR_FRAME (MAINTITLE_FRAME + 1)
+
+typedef struct _FRAME_INFO
+{
+ UINT32 FrameType;
+ BOOLEAN Drawable;
+ BOOLEAN Border;
+ CHAR16 BorderType;
+ UINT8 Width;
+ UINT8 Height;
+ UINT8 Top;
+ UINT8 Left;
+ UINT8 FGColor;
+ UINT8 BGColor;
+ UINT8 ScrlFGColor;
+ UINT8 ScrlBGColor;
+ UINT8 ScrlUpFGColor;
+ UINT8 ScrlUpBGColor;
+ UINT8 ScrlDnFGColor;
+ UINT8 ScrlDnBGColor;
+
+}
+FRAME_INFO;
+
+typedef struct _AMITSE_CONTROL_MAP
+{
+ UINT16 ControlType;
+ CONTROL_METHODS *ControlMethods;
+ BOOLEAN CallbackSuppored;
+ VOID *CallbackFunction;
+ VOID *CallbackContext;
+}AMITSE_CONTROL_MAP;
+
+typedef struct _POSITION_INFO
+{
+ UINT16 Top;
+ UINT16 Left;
+}
+POSITION_INFO;
+
+#define FRAME_NONE_FOCUSED 0xFFFFFFFF
+
+#define FRAME_MEMBER_VARIABLES \
+ FRAME_INFO FrameData; \
+ UINT32 PageID; \
+ UINT32 ControlCount; \
+ UINT32 NullCount; \
+ UINT32 CurrentControl; \
+ CONTROL_DATA **ControlList; \
+ CHAR16 *BlankLine; \
+ BOOLEAN UseScrollbar; \
+ UINT32 FirstVisibleCtrl; \
+ UINT32 LastVisibleCtrl; \
+ POSITION_INFO *OrigPosition; \
+ POSITION_INFO *CurrPosition;
+
+typedef struct _FRAME_METHODS FRAME_METHODS;
+
+typedef struct _FRAME_DATA
+{
+ FRAME_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ FRAME_MEMBER_VARIABLES
+
+}
+FRAME_DATA;
+
+typedef EFI_STATUS (*FRAME_METHOD_ADD_CONTROL) ( VOID *object, VOID *data );
+
+
+#define FRAME_METHOD_FUNCTIONS \
+ FRAME_METHOD_ADD_CONTROL AddControl;
+
+struct _FRAME_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ FRAME_METHOD_FUNCTIONS
+};
+
+extern FRAME_METHODS gFrame;
+extern AMITSE_CONTROL_MAP gTseControlMap[];
+// Object Methods
+EFI_STATUS FrameCreate( VOID **object );
+EFI_STATUS FrameDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS FrameInitialize( VOID *object, VOID *data );
+EFI_STATUS FrameDraw( VOID *object );
+EFI_STATUS FrameHandleAction( VOID *object, ACTION_DATA *data );
+EFI_STATUS FrameSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Frame Methods
+EFI_STATUS FrameAddControl( VOID *object, VOID *data );
+
+
+VOID _FrameSubmenuCallback( FRAME_DATA *frame, SUBMENU_DATA *submenu, VOID *cookie );
+VOID _FrameVariableCallback( FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie );
+VOID _FramePasswordCallback( FRAME_DATA *frame, CONTROL_DATA *control, VOID *cookie );
+BOOLEAN _FrameSetControlFocus( FRAME_DATA *frame, UINT32 index );
+EFI_STATUS _FrameAddControls( FRAME_DATA *frame, PAGE_INFO *data );
+EFI_STATUS _FrameAddTitle( FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data );
+
+#endif /* _FRAME_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/hotclick.c b/EDK/MiniSetup/TseLite/hotclick.c
new file mode 100644
index 0000000..f8dd6b6
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/hotclick.c
@@ -0,0 +1,230 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotclick.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 3 $
+//
+// $Date: 3/14/13 11:47a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotclick.c $
+//
+// 3 3/14/13 11:47a Premkumara
+// [TAG] EIP85745 & 109814
+// [Category] Improvement
+// [Description] Support for Modal Form Support as per UEFI 2.3.1
+// [Files] Parse.c, Page.c, Menu.c, Hotclick.c
+//
+// 2 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 6/29/11 5:01a Rajashakerg
+// Added to support Hot clicks
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hotclick.c
+//
+// Description: This file contains code to handle hotclick operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+extern BOOLEAN IsPageModal(UINT32 PgIndex);
+
+HOTCLICK_METHODS gHotClick =
+{
+ HotClickCreate,
+ HotClickDestroy,
+ HotClickInitialize,
+ HotClickEmptyMethod,
+ HotClickHandleAction,
+ HotClickSetCallback
+};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotClickCreate
+//
+// Description: Function create a HotClick, which uses the Object functions.
+//
+// Input: HOTCLICK_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotClickCreate( HOTCLICK_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(HOTCLICK_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+
+ if (EFI_ERROR(Status))
+ {
+ MemFreePointer( (VOID **)object );
+ return Status;
+ }
+
+ (*object)->Methods = &gHotClick;
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotClickDestroy
+//
+// Description: Function destroy a HotClick, which uses the Object functions.
+//
+// Input: HOTCLICK_DATA *hotkey, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotClickDestroy( HOTCLICK_DATA *hotclick, BOOLEAN freeMem )
+{
+
+ gObject.Destroy( hotclick, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&hotclick );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotClickInitialize
+//
+// Description: Function Initialize a Hotclick, which uses the Object functions.
+//
+// Input: HOTCLICK_DATA *hotkey, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotClickInitialize( HOTCLICK_DATA *hotclick, VOID *data )
+{
+ HOTCLICK_TEMPLATE *template = (HOTCLICK_TEMPLATE *)data;
+
+// MemCopy( &hotclick->HotClickData.MouseInfo, &(template->MouseInfo), sizeof(MOUSE_INFO) );
+ hotclick->HotClickData.Xo = template->Xo;
+ hotclick->HotClickData.Yo = template->Yo;
+ hotclick->HotClickData.Xn = template->Xn;
+ hotclick->HotClickData.Yn = template->Yn;
+
+ hotclick->BasePage = template->BasePage;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS HotClickEmptyMethod( HOTCLICK_DATA *hotclick )
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotClickHandleAction
+//
+// Description: Function to handle the HotClick actions.
+//
+// Input: HOTCLICK_DATA *hotkey, ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotClickHandleAction( HOTCLICK_DATA *hotclick, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ PAGE_DATA *page=NULL;
+
+ if ( action->Input.Type != ACTION_TYPE_MOUSE )
+ return Status;
+
+ page = gApp->PageList[gApp->CurrentPage];
+ if(!page)
+ return Status;
+
+ if(IsPageModal(page->PageData.PageID)){
+ return Status;
+ }
+ if (
+ ((action->Input.Data.MouseInfo.Left >= hotclick->HotClickData.Xo) && (action->Input.Data.MouseInfo.Left <= hotclick->HotClickData.Xn)) &&
+ ((action->Input.Data.MouseInfo.Top >= hotclick->HotClickData.Yo) && (action->Input.Data.MouseInfo.Top <= hotclick->HotClickData.Yn))
+ )
+ {
+ if ( hotclick->Callback )
+ hotclick->Callback( hotclick->Container, hotclick, hotclick->Cookie );
+
+ gAction.ClearAction( action );
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotClickSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: HOTCLICK_DATA *hotkey, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotClickSetCallback( HOTCLICK_DATA *hotclick, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( hotclick, container, callback, cookie );
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/hotclick.h b/EDK/MiniSetup/TseLite/hotclick.h
new file mode 100644
index 0000000..988c353
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/hotclick.h
@@ -0,0 +1,120 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotclick.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 2 $
+//
+// $Date: 10/18/12 6:03a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotclick.h $
+//
+// 2 10/18/12 6:03a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 2 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 1 6/29/11 5:01a Rajashakerg
+// Added to support Hot clicks
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hotclick.h
+//
+// Description: Header file for hotclick code to handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _HOTCLICK_H_
+#define _HOTCLICK_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "action.h"
+
+
+typedef struct _HOTCLICK_INFO
+{
+ UINT32 Xo, Yo, Xn, Yn;
+}
+HOTCLICK_INFO;
+
+#define HOTCLICK_MEMBER_VARIABLES \
+ HOTCLICK_INFO HotClickData; \
+ UINT32 BasePage;
+
+typedef struct _HOTCLICK_METHODS HOTCLICK_METHODS;
+
+typedef struct _HOTCLICK_DATA
+{
+ HOTCLICK_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ HOTCLICK_MEMBER_VARIABLES
+
+}
+HOTCLICK_DATA;
+
+#define HOTCLICK_METHOD_FUNCTIONS
+
+struct _HOTCLICK_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ HOTCLICK_METHOD_FUNCTIONS
+};
+
+extern HOTCLICK_METHODS gHotClick;
+
+// Object Methods
+EFI_STATUS HotClickCreate( VOID **object );
+EFI_STATUS HotClickDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS HotClickInitialize( VOID *object, VOID *data );
+EFI_STATUS HotClickEmptyMethod( VOID *object );
+EFI_STATUS HotClickHandleAction( VOID *object, ACTION_DATA *data );
+EFI_STATUS HotClickSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+#endif /* _HOTCLICK_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/hotkey.c b/EDK/MiniSetup/TseLite/hotkey.c
new file mode 100644
index 0000000..3d54674
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/hotkey.c
@@ -0,0 +1,237 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotkey.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotkey.c $
+//
+// 5 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 1/09/10 6:34a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:04p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hotkey.c
+//
+// Description: This file contains code to handle hotkey operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+HOTKEY_METHODS gHotKey =
+{
+ HotKeyCreate,
+ HotKeyDestroy,
+ HotKeyInitialize,
+ HotKeyEmptyMethod,
+ HotKeyHandleAction,
+ HotKeySetCallback
+};
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotKeyCreate
+//
+// Description: Function create a Hotkey, which uses the Object functions.
+//
+// Input: HOTKEY_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotKeyCreate( HOTKEY_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(HOTKEY_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+
+ if (EFI_ERROR(Status))
+ {
+ MemFreePointer( (VOID **)object );
+ return Status;
+ }
+
+ (*object)->Methods = &gHotKey;
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotKeyDestroy
+//
+// Description: Function destroy a Hotkey, which uses the Object functions.
+//
+// Input: HOTKEY_DATA *hotkey, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotKeyDestroy( HOTKEY_DATA *hotkey, BOOLEAN freeMem )
+{
+
+ gObject.Destroy( hotkey, FALSE );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&hotkey );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotKeyInitialize
+//
+// Description: Function Initialize a Hotkey, which uses the Object functions.
+//
+// Input: HOTKEY_DATA *hotkey, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotKeyInitialize( HOTKEY_DATA *hotkey, VOID *data )
+{
+ HOTKEY_TEMPLATE *template = (HOTKEY_TEMPLATE *)data;
+
+ MemCopy( &hotkey->HotKeyData.Key, &(template->Key), sizeof(EFI_INPUT_KEY) );
+
+ hotkey->HotKeyData.KeySftSte=template->KeySftSte;
+
+ hotkey->BasePage = template->BasePage;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS HotKeyEmptyMethod( HOTKEY_DATA *hotkey )
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotKeyHandleAction
+//
+// Description: Function to handle the HotKey actions.
+//
+// Input: HOTKEY_DATA *hotkey, ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotKeyHandleAction( HOTKEY_DATA *hotkey, ACTION_DATA *action )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( action->Input.Type != ACTION_TYPE_KEY )
+ return Status;
+
+ if ( (! EfiCompareMem( &action->Input.Data.AmiKey.Key, &hotkey->HotKeyData.Key, sizeof(EFI_INPUT_KEY) ) )
+ && ( TseCheckShiftState( (action->Input.Data.AmiKey), (hotkey->HotKeyData.KeySftSte) ) ) )
+ {
+ if ( hotkey->Callback )
+ hotkey->Callback( hotkey->Container, hotkey, hotkey->Cookie );
+
+ gAction.ClearAction( action );
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotKeySetCallback
+//
+// Description: Function to set callback.
+//
+// Input: HOTKEY_DATA *hotkey, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HotKeySetCallback( HOTKEY_DATA *hotkey, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( hotkey, container, callback, cookie );
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/hotkey.h b/EDK/MiniSetup/TseLite/hotkey.h
new file mode 100644
index 0000000..dc7aa64
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/hotkey.h
@@ -0,0 +1,157 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotkey.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/hotkey.h $
+//
+// 6 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hotkey.h
+//
+// Description: Header file for hotkey code to handling
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _HOTKEY_H_
+#define _HOTKEY_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "action.h"
+
+/*
+typedef struct _HOTKEY_TEMPLATE
+{
+ EFI_INPUT_KEY Key;
+ UINT32 KeySftSte;
+ OBJECT_CALLBACK Callback;
+ UINT32 BasePage;
+}
+HOTKEY_TEMPLATE;
+*/
+typedef struct _HOTKEY_INFO
+{
+ EFI_INPUT_KEY Key;
+ UINT32 KeySftSte;
+}
+HOTKEY_INFO;
+
+#define HOTKEY_MEMBER_VARIABLES \
+ HOTKEY_INFO HotKeyData; \
+ UINT32 BasePage;
+
+typedef struct _HOTKEY_METHODS HOTKEY_METHODS;
+
+typedef struct _HOTKEY_DATA
+{
+ HOTKEY_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ HOTKEY_MEMBER_VARIABLES
+
+}
+HOTKEY_DATA;
+
+#define HOTKEY_METHOD_FUNCTIONS
+
+struct _HOTKEY_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ HOTKEY_METHOD_FUNCTIONS
+};
+
+extern HOTKEY_METHODS gHotKey;
+
+// Object Methods
+EFI_STATUS HotKeyCreate( VOID **object );
+EFI_STATUS HotKeyDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS HotKeyInitialize( VOID *object, VOID *data );
+EFI_STATUS HotKeyEmptyMethod( VOID *object );
+EFI_STATUS HotKeyHandleAction( VOID *object, ACTION_DATA *data );
+EFI_STATUS HotKeySetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+#endif /* _HOTKEY_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/minisetupext.c b/EDK/MiniSetup/TseLite/minisetupext.c
new file mode 100644
index 0000000..90e8256
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/minisetupext.c
@@ -0,0 +1,2378 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/minisetupext.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 79 $
+//
+// $Date: 8/28/14 11:52a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/minisetupext.c $
+//
+// 79 8/28/14 11:52a Premkumara
+// [TAG] EIP174031
+// [Category] Improvement
+// [Description] Removed TODO comments and added proper comments in those
+// places
+// [Files] commonoem.c, commonhelper.c, special.c, submenu.c,
+// minisetupext.c, uefi21wapper.c and legacy.c
+//
+// 78 8/28/14 6:50a Premkumara
+// [TAG] EIP93340
+// [Category] Improvement
+// [Description] - Defaults can be given to string type controls using tag
+// "Default = STRING_TOKEN(STR_DEFAULT_STRING)".
+// - New token TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL is introduced for
+// this support.
+// - Enabling this TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL token will
+// display default string mention in setup.
+// - On loading optimal defaults also string will load default mentioned
+// in default value tag.
+// [Files] AMITSE.sdl, HiiString21.c, TseAdvanced.c, MiniSetupExt.c, Hii.c
+//
+// 77 5/03/14 3:14p Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 76 5/02/14 1:06p Premkumara
+// [TAG] EIP128526
+// [Category] Improvement
+// [Description] Disable ESC action in BBS popup menu
+// [Files] AMITSE.sdl, CommonHelper.c, TseLite/MinisetupExt.c
+//
+// 75 5/02/14 4:27a Arunsb
+// [TAG] EIP155965
+// [Category] Improvement
+// [Description] MessageBox, ListBox cannot be canceled by Mouse
+// Right-Click
+// Checked for gpoststatus. On clicking outside of the postmenu should not
+// close it.
+// [Files] MessageBox.c, ListBox.c and minisetupext.c
+//
+// 74 5/02/14 3:48a Arunsb
+// [TAG] EIP155965
+// [Category] Improvement
+// [Description] MessageBox, ListBox cannot be canceled by Mouse
+// Right-Click
+// [Files] MessageBox.c, ListBox.c and minisetupext.c
+//
+// 73 5/02/14 12:42a Arunsb
+// [TAG] EIP150526
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE hangs on disconnecting and connecting the RAID driver
+// [Root Cause] Process pack updated on processing the existing pack
+// update
+// [Solution] First we getting remove and new pack. On getting this TSE
+// starts processing the pack(ProcessPackNotification) but on processing
+// the pack itself we getting notification again for remove and add. So
+// again process pack happens inside notification
+// itself(IFRChangeNotifyFn), this processing should not happen inside
+// notification so enabled flag gEnableProcessPack in PageHandleAction.
+// [Files] hii.c, minisetupext.c and page.c
+//
+// 72 2/11/14 8:43p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 71 12/05/13 1:32a Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 70 12/03/13 1:23p Premkumara
+// [TAG] EIP128526
+// [Category] Improvement
+// [Description] Disable ESC action in BBS popup menu
+// [Files] AMITSE.sdl, CommonHelper.c, TseLite/MinisetupExt.c
+//
+// 69 11/01/13 1:45p Arunsb
+// [TAG] EIP136371, 141870
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Menu ordering is not proper when entering into setup through
+// BBS popup menu
+// [Root Cause] Boot flow is not set to normal for after BBS popup, so in
+// root page ordering boot flow is not matched
+// [Solution] After existing from BBS popup menu boot flow set to
+// BOOT_FLOW_CONDITION_NORMAL
+// [Files] minisetupext.c
+//
+// 68 6/10/13 12:06p Premkumara
+// [Issue Faced] In DriverSample, REF setup get crashes after
+// selecting REF5 interactive control
+// [Root Cause] When gApp->CurrentPage is 0 gApp->PageList is
+// NULL
+// [Solution] Return NULL, when gApp->PageListis NULL
+// [Modified Files] Minisetupext.c
+//
+// 67 5/23/13 5:18a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c, minisetupext.c
+//
+// 66 5/22/13 11:02a Premkumara
+// [TAG] EIP123432
+// [Category] Bug Fix
+// [Issue Faced] Take print screen for save & Exit msg box. OK
+// of msg box is consumed by Save & Exit msg box.
+// - Cursor is missing after taking print screen of popupedit box in
+// string control
+// - Printscreen support is not given for Filebrowser feature
+// [RootCause] - When msg box for Save&Exit is popped and printscreen
+// event is called and displaying msg box over Save&Exit. Then msgbox
+// handleaction for printscreen event will change the result value in
+// _CallbackMsgbox() function so it will break the while loop in
+// _CallbackGetValue() function so destroy the next msg box in
+// CallbackShowMessageBox() function.
+// - DrawCursor variable is not set to TRUE after printscreen event
+// [Solution] - Returning EFI_UNSUPPORTED for printscreen event handling
+// function for messgebox and change the result value to 0xff
+// - Support given for file browser feature
+// [Files] Callback.c, MessageBox.c, Minisetupext.c, PopupString.c,
+// AddBootOption.c
+// AmiTSEStr.uni, FakeToken.c
+//
+// 65 5/22/13 10:45a Arunsb
+// [TAG] EIP122907
+// [Category] Improvement
+// [Description] For getting name value offset preserving page number
+// then it will be easy to find handle of the hii which published name
+// value. Additional general checks added.
+//
+// 64 3/12/13 7:18a Rajashakerg
+// [TAG] EIP116559
+// [Category] Bug Fix
+// [RootCause] A predicable problem of the ShowPostMenu function on
+// minisetupext.c
+// [Solution] Invoked ProcessProceedToBootHook() function at appropriate
+// place.
+// [Files] minisetupext.c
+//
+// 63 11/19/12 11:38p Arunsb
+// Checked in the source properly
+//
+// 62 10/18/12 11:39a Rajashakerg
+// [TAG] EIP 97951
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] Creation of TSE which does not access NVRAM during recovery
+// [RootCause] TSE get Platform lang every time using VarGetNvramName
+// [Solution] Moved the code accessing PlatformLang to uefi2.1.
+// [Files] hiistring21.c, minisetupext.c, hiistring20.c
+//
+// 58 9/21/12 1:05p Premkumara
+// [TAG] EIP 93639
+// [Category] Improvement
+// [Description] PostMenu called from inside of PostMenu callback will
+// cause both menus to exit
+// [Files] minisetupext.c
+//
+// 57 9/21/12 12:56p Premkumara
+// [TAG] EIP 92891
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] DisplayPostMenu always forces the system to boot
+// [RootCause] TSE is booting even gPostStatus is not
+// TSE_POST_STATUS_IN_BBS_POPUP
+// [Solution] Handled only to boot when gPostStatus is
+// TSE_POST_STATUS_IN_BBS_POPUP
+// [Files] Minisetupext.c
+//
+// 56 9/21/12 3:43a Premkumara
+// [TAG] EIP 97951
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] Creation of TSE which does not access NVRAM during recovery
+// [RootCause] TSE get Platform lang every time using VarGetNvramName
+// [Solution] Created cache to store Platform lang intially and using
+// cached value instead of
+// reading from NVRAM (VarGetNvramName ).
+// [Files] hiistring21.c, minisetupext.c
+//
+// 55 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 53 8/29/12 4:25p Arunsb
+// [TAG] EIP94702
+// [Description] Support for Native Resolution in POST/BOOT
+// [Files] amitse.sdl, commonhelper.c, commonoem.c, boot.c, logo.c,
+// notify.c, postmgmt.c, tselite\minisetupext.c, ezport/stylecommon.c,
+// ezportplus/stylecommon.c andlegacy/stylecommon.c
+//
+// 52 5/29/12 5:32a Premkumara
+// Replaced MouseDestroy() with MouseStop() since mouse destroy is
+// destroying mouse pointer
+//
+// 51 5/29/12 4:39a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 50 5/25/12 1:14a Arunsb
+// [TAG] EIP83105
+// [Category] Improvement
+// [Description] Inconsistency checked only for valid pages
+// [Files] minisetupext.c
+//
+// 49 5/24/12 1:28p Arunsb
+// Hooking MainSetupLoop for special case leads to not setting the
+// gPostStatus properly.
+// So gPostStatus is again set to TSE_POST_STATUS_ENTERING_TSE in
+// mainsetuploop.
+//
+// 48 5/17/12 12:58a Arunsb
+// [TAG] EIP90149
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] TSE 1224 never executes callbacks with
+// EFI_BROWSER_ACTION_FORM_CLOSE when reset is required
+// [RootCause] EFI_BROWSER_ACTION_FORM_CLOSE not invoked when reset is
+// required
+// [Solution] EFI_BROWSER_ACTION_FORM_CLOSE action invoked for reset
+// also
+// [Files] minisetupext.c
+//
+// 47 4/27/12 5:31a Rajashakerg
+// [TAG] EIP88435
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Touch does not have functionality at POST
+// [RootCause] Mouse is initialized after getting notification from
+// mousedriver. So mouse avaliable at post and if we click at post, then
+// the button status is not consumed by any other application and mouse
+// pointer stuck at post
+// [Solution] Provided the changes to init the mouse at setup in the
+// absence of softkbd.
+// [Files] notify.c, minisetupext.c
+//
+// 46 4/25/12 6:07a Rajashakerg
+// [TAG] EIP86827
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] "gBootFlow" variable should be changed to
+// BOOT_FLOW_CONDITION_NORMAL if we press ESC key from pop-pup menu
+// [RootCause] ProcessProceedToBootHook() is not invoked when we press
+// ESC key in the BBS popup Menu.
+// [Solution] Fixed the issue by calling ProcessProceedToBootHook() when
+// we press ESC key in the BBS popup Menu.
+// [Files] BootOlny/minisetupext.c, TseLite/minisetupext.c.
+//
+// 45 4/04/12 12:25a Rajashakerg
+// [TAG] EIP86253
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Mouse and SoftKbd does not work after displaying "No option
+// to boot to" in POST
+// [RootCause] Mouse timer cleared once after displaying the "No option
+// to boot to" in POST
+// [Solution] Mouse timer cleared only when its going to boot.
+// [Files] CommonHelper.c, commonoem.c, minisetupext.c, protocol.c
+//
+// 44 4/03/12 3:11a Premkumara
+// [TAG] EIP84150
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] All the timers for mouse drivers before exiting from setup
+// is not stopped
+// [RootCause] MouseDestroy() is not called StopPointingDevice()
+// function to stop Mouse device
+// [Solution] StopPointingDevice() function is called in MouseDestroy()
+// function
+// [Files] Mouse.c, Protocol.c, Ezport/StyleCommon.c,
+// EzportPlus/StyleCommon.c, Legacy/StyleCommon.c, Minisetupext.c
+//
+// 43 12/08/11 12:51p Rajashakerg
+// [TAG] EIP63190
+// [Category] New Feature
+// [Description] Security operations in BootOnly module instead of
+// TSELite. GetAMITSEVariableLocal moved to tselite.
+//
+// 42 12/08/11 5:17a Arunsb
+// EIP63190 => Moving password support from TSELite to BootOnly. QuietBoot
+// is defaultly enabled in BootOnly so moving CheckEnableQuietBoot
+// function to TSELite to avoid the conflict.
+//
+// 41 12/05/11 5:36a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 40 12/02/11 6:01a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Mouse is Initialized when mouse is notified so
+// refreshing the mouse.
+//
+// 39 11/30/11 6:40a Premkumara
+// [TAG] EIP71351
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup Crash when iSCSI is loaded
+// [RootCause] Aptio giving length as 0xe(matches size of
+// EFI_IFR_ONE_OF_OPTION) but in latest EDKII driver it is 0x1c.
+// [Solution] change the length as j += ((EFI_IFR_OP_HEADER*)(buff + i +
+// j))->Length;
+// [Files] Parse.c, Hii.c, Variable.c, Minisetupext.c
+//
+// 38 11/28/11 1:56a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 37 11/20/11 7:54a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 36 11/11/11 2:15a Arunsb
+// [TAG] EIP64387
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] In serial redirection set to 9600bps, the BBS Popup menu
+// goes away as soon as it appears.
+// [RootCause] MapControlKeysHook() is called on an action even if
+// gListBox.HandleAction() returns an error or a non-keyboard action.
+// [Solution] MapControlKeysHook() is called only if
+// gListBox.HandleAction() returns success and for keyboard action.
+// [Files] minisetupext.c
+//
+// 35 11/10/11 11:32a Arunsb
+// [TAG] EIP75028
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Pressing esc from main menu is not poping the exit msgbox
+// [RootCause] Navigation stack
+// [Solution] Navigation stack reordered
+// [Files] minisetupext.c
+//
+// 34 10/31/11 9:38a Rajashakerg
+// [TAG] EIP71120, 71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 33 6/23/11 3:56p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 32 6/20/11 10:35a Arunsb
+// [TAG] EIP54861
+// [Category] Improvement
+// [Description] Updating string token value dynamically for Title Bar
+// and Copyright messages.
+// [Files] minisetup.c and tselite\minisetupext.c
+//
+// 31 6/15/11 5:18p Arunsb
+// [TAG] EIP62185
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] The Main Page cannot hide when press F2 to enter setup
+// [RootCause] If pagevisible set to TRUE then it is not checked for not
+// showing it
+// [Solution] Pagevisible = TRUE is checked for not showing the page.
+// The next parent page will be shown instead of it.
+// [Files] minisetupext.c
+//
+// 30 5/17/11 6:37p Arunsb
+// StyleExit function added in DrawBbsPopupMenu function to clear the
+// screen after bbs popup menu vanishes.
+//
+// 29 3/28/11 9:25p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 28 3/21/11 12:34a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 27 3/15/11 5:16a Rajashakerg
+// [TAG] EIP51671
+// [Category] New Feature
+// [Description] Boot overide menu devices are not disable
+// [Files] boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl,
+// boot.h, CommonHelper.c
+//
+// 26 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 25 2/24/11 1:09p Blaines
+// [TAG] - EIP 54517
+// [Category]- Enhancement
+// [Symptom]- When navigating through a postmenu and hitting a seperator
+// item, the menu will exit. Processing of Post Menu Changes is done after
+// the decision to quit the post menu has been made.
+// [Solution] - Check for selected non-focus item immediately after
+// updating menu. Process Post Menu Change in the callback function.
+// [File] - Minisetupext.c
+//
+// 24 2/16/11 12:45p Blaines
+// [TAG] - EIP 52897
+// [Category]- Defect
+// [Symptom]- PostMenu exit from callback item is not correctly exiting
+// the PostMenu loop..
+// [Solution]- In ShowPostMenu, make sure pSelection is updated before
+// callback is handled, and check for menu change due to hotkey.
+// In _PostMenuCallback, allways check menu item callback for NULL to exit
+// properly.
+// [Files] - minisetupext.c,
+//
+// 23 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 22 2/07/11 7:23a Mallikarjunanv
+// [TAG] EIP51627
+// [Category] New Feature
+// [Description] Provide Mouse support to select file system device
+// entries during "Add boot option" in File browser support.
+// [Files] Minisetupext.c
+//
+// 21 1/24/11 1:10p Blaines
+// [TAG] - EIP 51425
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- "Esc" key and "Enter" key have same effect at BBS popup
+// menu..
+// [Solution] - Check for ABORT status and set default boot index.
+// [Function] - DrawBbsPopupMenu
+// [File] - minisetupext.c.
+//
+// 20 1/20/11 11:50a Blaines
+// [TAG] - EIP 52427
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- Possible memory leak when updating PostMenu title.
+// [Solution] - Check title and free memory before updating title string.
+// [Function] - ShowPostMenu
+//
+// 19 12/25/10 3:47a Mallikarjunanv
+// [TAG] EIP 47939
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Displaying blue screen for a moment and displaying BIOS
+// setup
+// [RootCause] Clear screen is done before style initialzation .
+// [Solution] Style initialization is before screen clear.
+// [Files] Minisetupext.c
+//
+// 18 12/02/10 2:55p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Then Dynamic page is updated the page cache is updated with
+// defaults. User change is lost.
+// [Rootcause] - UICallback is updated all the contols with default value
+// when page dynamicalled updated.
+// [Solution]- Take care to update the variable cache only to newly added
+// variables.
+// [Files] - tselite\minisetupext.c
+//
+// 17 11/18/10 7:24p Blaines
+// [TAG] - EIP 45374
+// [Category]- Function Request
+// [Synopsis]- Need method to configure Post Menu programmatically, Items
+// requested
+// - Exit Keys
+// - Font Colors
+// - Background Colors.
+// [Solution]
+// - Create hook to set window color,
+// - Add AMI_POSTMENU_ATTRIB_EXIT_KEY attribute to POSTMENU_TEMPLATE to
+// configure exit keys.
+// [Files] - stylecommon.c, style.h, listbox.c, minisetupext.c,
+// AMIPostMgr.h
+//
+//
+// [TAG] - EIP 48417
+// [Category]- Defect
+// [Symptom]- PostManagerDisplayMenu does not dynamically update Menu
+// Title on language change.
+//
+// [Solution]- Update listbox title string by calling HiiGetString
+// whenever a selection is made. redraws.
+// [Files] - listbox.c, minisetupext.c,
+//
+//
+//
+// 16 11/01/10 12:07p Blaines
+// Fix issue in DrawBbsPopupMenu which caused system hang when boot menu
+// ItemCount is zero.
+//
+// 15 10/05/10 12:19p Mallikarjunanv
+// EIP_38553 - corrected the name of the hook function
+// PreSystemResetHookHook
+//
+// 14 9/29/10 1:27p Blaines
+// Function ShowPostMenu was updated to do better error checking, and to
+// return the correct index into the post menu when an item is selected.
+// Since hidden items are moved to the end, ShowPostMenu should return the
+// matching index of the caller's menu.
+//
+// 13 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 24 8/18/10 6:16p Mallikarjunanv
+// EIP-38089: Hook after pressing F2 key and before showing setup menu.
+//
+// 23 8/12/10 1:08p Blaines
+// EIP-41614 : Change to allow DisplayPostMenu protocol to dynamically
+// update menu items modified from the callback functions.
+//
+// 21 7/07/10 7:47p Madhans
+// To fix the Variables when new forms dynamically added.
+//
+// 20 6/17/10 2:46p Madhans
+//
+// 19 6/14/10 7:09p Madhans
+// Dynamic parsing support
+//
+// 18 6/08/10 5:23p Blaines
+// - Support PostManagerDisplayMenu of menu list with ALL non-focusable
+// items.
+//
+// - Return error status in PostManagerDisplayMenu on <esc> key press.
+//
+// 17 5/24/10 5:57p Blaines
+// Set the correct default selection in function ShowPostMenu, make sure
+// it is not hidden or non-focused.
+//
+// 16 3/30/10 4:59p Blaines
+// Use PostManagerDisplayMenu to display BBS Popup Menu.
+//
+// 15 3/26/10 6:13p Madhans
+// EIP 36704 : Fix for Making sure to make the Variable to NULL after it
+// is Freed up.
+//
+// 14 3/23/10 5:23p Blaines
+// BBS Popup modifications to support new listbox functionality.
+//
+// 13 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 12 2/04/10 11:18p Madhans
+// SCAN_EFI reference removed.
+//
+// 11 1/09/10 7:07a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 10 12/04/09 7:12a Mallikarjunanv
+// Fix for EIP:30263 - Gif Logo Issue
+//
+// 9 10/28/09 5:38p Madhans
+//
+// 8 10/09/09 10:22a Mallikarjunanv
+// EIP:26409 - Added Hook function 'PreSystemResetHook' to update setup
+// before resetting the system
+//
+// 7 9/15/09 9:45a Sudhirv
+// added a flag to handle the FlushPause
+//
+// 6 8/19/09 12:56p Madhans
+// To call invalidkeyhook on BBS popup.
+//
+// 5 8/13/09 7:39a Mallikarjunanv
+// eip:24971 - supporting tse features without tse sources
+//
+// 4 6/24/09 6:11p Madhans
+// BBSpopup code should be there always and controlled by the TSE
+// binaries.
+// Fix in BBSpopup booting...
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 4:11p Madhans
+//
+// 3 2/05/09 5:19p Madhans
+// PostMgrStatus interface added.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MINISETUP.C
+//
+// Description: This file contains code for entrypoint and setup loop
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//Internal function definitions
+VOID MainSetupLoopInitHook(VOID);
+VOID InitGlobalPointers( VOID );
+UINT16 _BootSetBootNowCount(VOID);
+BOOLEAN IsSoftKbdSupported(VOID);
+CHAR16 *ReadPlatformLang( UINTN *Size );
+BOOLEAN IsDisableESCinBBSMenu (VOID);
+BOOLEAN SingleClickActivation (VOID); //EIP-139608
+extern BOOLEAN IsSupportDefaultForStringControl (VOID);
+POSTMENU_TEMPLATE *gPostMenuData = NULL ;
+
+UINT16 gPostMenuLevel = 0 ;
+UINT16 gDynamicParentPage=0;
+
+//EIP: 58925 Start
+//---------------------------------------------------------------------------
+// Variables
+//---------------------------------------------------------------------------
+BOOLEAN bSelectionChanged = FALSE;
+UINT32 gPageNavCount = 0;
+UINT32 gNavStartPage = 0;
+static UINT16 gDisplayPageId = 0; //PageId which is currently displaying
+
+#define MAX_NAVIGATION_DEPTH 20 //for breadcrumb trail
+//---------------------------------------------------------------------------
+// Type definitions
+//---------------------------------------------------------------------------
+typedef struct _NAV_PAGE_STACK{
+ VOID *PageHandle; //Varies, HII Handle to the formset that contains this control
+ UINT32 PageFormID; //Varies, Form ID within the formset for this page
+ VOID *ParentPageHandle; //Varies, HII Handle to the formset that contains Parent Page control
+ UINT32 PageParentFormID; //Varies, Pagent Form ID within the formset for this page
+} NAV_PAGE_STACK;
+
+NAV_PAGE_STACK *NavPageStack = (NAV_PAGE_STACK *)NULL;
+UINT32 NavPageStackSize = 0;
+EFI_STATUS GetParentFormID(UINT16 ChildID, UINT16 *ParentID, UINT32 *StackIndex);
+extern CHAR16 gPlatformLang [20]; //EIP97951
+
+//EIP: 58925 End
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MiniSetupEntry
+//
+// Description: This function prepares system so that setup can be
+// launched. Preparation mainly includes Setup data
+// fixup and variable details gathering.
+//
+// Input: VOID
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MiniSetupEntry(VOID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ AMITSESETUP *pSetupVariable = (AMITSESETUP *)NULL;
+ UINTN size = 0;
+
+ RUNTIME_DEBUG( L"nvram" );
+
+ // Update application data information to match that of HII
+ Status = HiiFixupData( );
+ if(EFI_ERROR(Status)){
+ goto DONE;//EIP 76381 : Reset to read the variable from NVRAM
+ }
+
+ UEFICallSetupFormCallBack(AMI_CALLBACK_FORM_OPEN);//EIP-53480: Calling the Wraper function with action AMI_CALLBACK_FORM_OPEN
+
+ Status = VarBuildDefaults();
+ if(EFI_ERROR(Status)){
+ goto DONE;//EIP 76381 : Reset to read the variable from NVRAM
+ }
+
+ Status = VarLoadVariables( (VOID **)&gVariableList, gOptimalDefaults );
+ if(EFI_ERROR(Status)){
+ goto DONE;//EIP 76381 : Reset to read the variable from NVRAM
+ }
+
+ //EIP-71351 Call Retrive callback after loading Current values to variable Cache.
+ UEFICallSetupFormCallBack(AMI_CALLBACK_RETRIEVE);//EIP-53480: Calling the Wraper function with action AMI_CALLBACK_RETRIEVE
+
+ if(!NoVarStoreSupport())
+ {
+ VarGetNvram( VARIABLE_ID_AMITSESETUP, &size );
+ if(size < sizeof(AMITSESETUP))
+ {
+ pSetupVariable = (AMITSESETUP *) EfiLibAllocateZeroPool(sizeof(AMITSESETUP));
+ if(gVariableList[VARIABLE_ID_AMITSESETUP].Buffer)
+ MemCopy( pSetupVariable, gVariableList[VARIABLE_ID_AMITSESETUP].Buffer, gVariableList[VARIABLE_ID_AMITSESETUP].Size );
+ VarSetNvram( VARIABLE_ID_AMITSESETUP, pSetupVariable, sizeof(AMITSESETUP));
+ VarUpdateDefaults(VARIABLE_ID_AMITSESETUP);
+ }
+ }
+
+ Status = EFI_SUCCESS;
+
+DONE:
+ CleanTempNvramVariableList();//EIP 76381 : Reset to read the variable from NVRAM
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MainSetupLoop
+//
+// Description: This function runs the loop for setup execution. This
+// function is responsible for creating the application
+// hierarchy. It also gathers actions and passes them
+// thru application hierarchy and initiates draw
+// sequence.
+//
+// Input: VOID
+//
+// Output: Return Status based on errors that occurred in library
+// functions.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS MainSetupLoop( VOID )
+{
+ EFI_STATUS Status;
+ ACTION_DATA *action = NULL;
+ BOOLEAN refresh = TRUE;
+ UINT32 ii;
+ UINT32 page,previouspage=1;
+ PAGE_DATA *thisPage;
+ UINT32 SaveStateVarNum;
+ UINT16 SaveState=SETUP_RESET_NOT_REQUIRED;
+ CHAR16 *Language = NULL;
+ UINTN Size = 0;
+
+ // Close the Image related events before loading the setup pages
+ gPostStatus = TSE_POST_STATUS_ENTERING_TSE; //Hooking MainSetupLoop for special case leads to not setting the gPostStatus properly
+ MouseStop (); //Stopping before clearing the screen
+ CleanUpLogo();
+ MouseRefresh (); //Refreshing after clearing the screen
+
+ gEnterSetup = FALSE;
+ MainSetupLoopInitHook();
+// StopClickEvent();//EIP 86253 : Invoking the StopClickEvent function in the mainsetuploophook function
+ Status = MiniSetupEntry();
+ if ( EFI_ERROR( Status ) )
+ return MiniSetupExit( Status );
+
+ //EIP-38089: Hook after pressing F2 key and before showing setup menu.
+ ProcessUIInitHookHook();
+
+ Status = gApplication.Create( &gApp );
+ if ( EFI_ERROR( Status ) )
+ return MiniSetupExit( Status );
+
+#if APTIO_4_00
+ gMaxRows = MAX_ROWS;
+ gMaxCols = MAX_COLS;
+#endif
+// SetDesiredTextMode(); //EIP94702 - StyleInit will set the desired text mode
+ MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0);
+
+ //EIP:47939 - Style initialization before screen clear
+ StyleInit();
+ MouseStop (); //Stopping before clearing the screen
+ ClearScreen (STYLE_CLEAR_SCREEN_COLOR);
+ MouseRefresh (); //Refreshing after clearing the screen
+
+ RUNTIME_DEBUG( L"init" );
+ Status = gApplication.Initialize( gApp, gApplicationData );
+ if (EFI_ERROR(Status))
+ return MiniSetupExit( Status );
+
+ gMsgBoxAction = gApp->Action;
+
+ // add boot manager and language pages
+ StyleAddExtraPagesData();
+
+ //Let's create the SaveState Variable
+ if(VarGetVariableInfoId( SETUP_SAVE_STATE_INFO_KEY_ID, &SaveStateVarNum ))
+ VarSetValue(SaveStateVarNum,0,sizeof(UINT16),&SaveState);
+
+ action = gApp->Action;
+
+ if ( gApp->PageList == NULL )
+ gApp->Quit = TRUE;
+
+ gApp->CurrentPage = gStartPage;
+ if ( gStartPage == 0 )
+ StyleSelectFirstDisplayPage();
+// EIP62185: Not to show the pages with PageVisible = TRUE as root page
+ thisPage = gApp->PageList[gApp->CurrentPage];
+ // Check current page is workable.
+ if (thisPage->PageData.PageFlags.PageVisible == TRUE)
+ {
+ // Find first workable page.
+ for ( ii = 0; ii < gApp->PageCount; ii++ )
+ {
+ thisPage = gApp->PageList[ii];
+ if(thisPage == NULL)
+ continue;
+ if ((thisPage->PageData.PageID != 0) && (thisPage->PageData.PageParentID == 0))
+ {
+ if (thisPage->PageData.PageFlags.PageVisible != TRUE)
+ {
+ gApp->CurrentPage = ii;
+ break;
+ }
+ }
+ }
+ }
+// EIP62185
+ if ( gApp->PageList != NULL )//EIP-75384 Static code
+ {
+ if ( gApp->PageList[gApp->CurrentPage] == NULL )
+ {
+ for ( ii = 0; ii < gApp->PageCount; ii++ )
+ {
+ if ( gApp->PageList[ii] != NULL )
+ {
+ gApp->CurrentPage = ii;
+ break;
+ }
+ }
+ }
+ }
+
+ page = gApp->CurrentPage;
+
+ // Report the Status code DXE_SETUP_INPUT_WAIT
+ EfiLibReportStatusCode(EFI_PROGRESS_CODE, DXE_SETUP_INPUT_WAIT,0,NULL,NULL);
+ gPostStatus = TSE_POST_STATUS_IN_TSE;
+
+ if (IsLinkHistorySupport ()) //EIP75028 Pressing esc from Main menu which has sub menu is entering into sub menu instead of poping the exit msgbox
+ SetParentFormID (0, (UINT16)gApp->CurrentPage);
+
+ while ( ! gApp->Quit )
+ {
+ if ( page != gApp->CurrentPage )
+ {
+ if ( gApp->PageList[gApp->CurrentPage] == NULL )
+ gApp->CurrentPage = page;
+ else
+ {
+ if(((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[page]))->PageHandle != NULL) //EIP 83105 When the page is removed, don't check for inconsistency
+ {
+ if( CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[page])) )
+ {
+ //There is inconsistence so do not move from this page
+ gApp->CurrentPage = page;
+ }
+ else
+ {
+ page = gApp->CurrentPage;
+ }
+ }
+ else
+ {
+ page = gApp->CurrentPage;
+ }
+ }
+ }
+
+ thisPage = gApp->PageList[page];
+
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ if ( gApp->CompleteRedraw )
+ refresh = TRUE ; //EIP101564: Do refresh in case Refresh Id Group requires redraw
+
+ if ( refresh )
+ {
+ //EIP97951-Start
+ if (NULL != Language)
+ {
+ MemFreePointer ((VOID **)&Language);
+ }
+ Size = 0;
+// Language = VarGetNvramName (L"PlatformLang", &gEfiGlobalVariableGuid, NULL, &Size);
+ Language = ReadPlatformLang(&Size);
+ if (NULL != Language)//EIP-75351 Suppress the warnings from static code analyzer
+ {
+ EfiZeroMem (gPlatformLang, sizeof (gPlatformLang));
+ EfiCopyMem (gPlatformLang, Language, Size);
+ }
+ //EIP97951-End
+ if(page == previouspage)
+ MouseFreeze();
+ else
+ MouseStop();
+
+ if ( gApp->ClearScreen )
+ {
+ gApp->CompleteRedraw = TRUE;
+ MemSet(gFlushBuffer, sizeof(SCREEN_BUFFER), 0);
+ ClearScreen( STYLE_CLEAR_SCREEN_COLOR );
+ gApp->ClearScreen = FALSE;
+ }
+
+ if ( gApp->CompleteRedraw )
+ {
+ StyleDrawPageBorder( page );
+ SpecialUpdatePageControls( page );
+ gPage.Draw( thisPage );
+ gApp->CompleteRedraw = FALSE;
+ }else
+ gPage.Draw( thisPage );
+ DoRealFlushLines();
+
+ previouspage = page;
+ MouseRefresh();
+
+ refresh = FALSE;
+ }
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ if ( gPage.HandleAction( thisPage, action ) != EFI_SUCCESS )
+ {
+ if ( action->Input.Type == ACTION_TYPE_KEY )
+ {
+ if ( (ControlActionAbort != MapControlKeysHook(action->Input.Data.AmiKey)) && ( thisPage->PageData.PageFlags.PageDisableHotKeys ) )
+ {
+ gAction.ClearAction( action );
+ continue;
+ }
+ }
+
+ if ( gApplication.HandleAction( gApp, action ) == EFI_SUCCESS )
+ {
+ refresh = TRUE;
+ }
+ else if ( action->Input.Type == ACTION_TYPE_KEY )
+ {
+ InvalidActionHookHook();
+ }
+ }
+ else
+ refresh = TRUE;
+
+ }
+ StyleExit();
+
+// MouseDestroy(); //EIP-84150
+
+ if ( gResetRequired ) {
+ MiniSetupExit (Status); //EIP90149; Invoking EFI_BROWSER_ACTION_FORM_CLOSE on reset also
+ ///EIP:26409 - Hook function to update setup before resetting the system
+ PreSystemResetHookHook();
+ gRT->ResetSystem( EfiResetCold, EFI_SUCCESS, 0, NULL );
+ }
+//EIP: 58925 Start
+ if(IsLinkHistorySupport())
+ {
+ ResetNavStack();
+ }
+//EIP: 58925 End
+ return MiniSetupExit( Status );
+}
+
+extern int gNumOfDev ;
+extern UINT16 gBBSPopupSel ;
+UINT16 gQuitBBSLoop=0;
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawBbsPopupMenu
+//
+// Description: function for the BBS Popup menu
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+extern UINT32 gBootFlow;
+EFI_STATUS DrawBbsPopupMenu( VOID )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 i=0, ItemCount=0, u16BootCount = (UINT16)gNumOfDev ;
+ CHAR16 *BootStr;
+ POSTMENU_TEMPLATE *BootMenu = NULL;
+ UINT16 Title, Legend, sel = 0 ;
+ EFI_GUID AmiPostManagerProtocolGuid = AMI_POST_MANAGER_PROTOCOL_GUID;
+ AMI_POST_MANAGER_PROTOCOL *pAmiPostMgr = NULL;
+
+ Status = gBS->LocateProtocol( (EFI_GUID *)&AmiPostManagerProtocolGuid,
+ (void*)NULL,
+ (void**)&pAmiPostMgr );
+
+ if(Status != EFI_SUCCESS)
+ return Status;
+// SetDesiredTextMode(); //EIP94702 - StyleInit will set the desired text mode
+ ClearScreen( EFI_BACKGROUND_BLACK | EFI_LIGHTGRAY );
+ StyleInit();
+
+ ItemCount = u16BootCount;
+
+#if POPUP_MENU_ENTER_SETUP
+ ItemCount++;
+#endif
+ BootMenu = EfiLibAllocateZeroPool( sizeof( POSTMENU_TEMPLATE ) * ItemCount);
+
+ for ( i = 0; i < u16BootCount; i++ )
+ {
+///EIP - 24971
+ BootStr = BootGetBootNowName(i, gPopupMenuShowAllBbsDev, BootNowInBootOrderSupport());
+///EIP - 24971
+ // EIP:51671 Start
+ //Depending on the value of the token hide of the disabled boot options is done
+ if((gPopupMenuHideDisableBootOptions && IsBootDeviceEnabled(i,gPopupMenuShowAllBbsDev,BootNowInBootOrderSupport(),0))||
+ (gLoadOptionHidden &&(NULL == BootStr)))
+ {
+
+
+ BootMenu[i].ItemToken = 1;
+ BootMenu[i].Callback = (VOID*)NULL ;
+ BootMenu[i].CallbackContext = (VOID*)NULL;
+ continue;
+ }
+
+ BootMenu[i].ItemToken = HiiAddString( gHiiHandle, BootStr );
+ BootMenu[i].Callback = (VOID*)NULL ;
+ BootMenu[i].CallbackContext = (VOID*)NULL ;
+ BootMenu[i].Attribute = AMI_POSTMENU_ATTRIB_FOCUS;
+ BootMenu[i].Key.Key.ScanCode = 0 ;
+ BootMenu[i].Key.Key.UnicodeChar = 0 ;
+ BootMenu[i].Key.KeyShiftState = 0 ;
+ }
+
+#if POPUP_MENU_ENTER_SETUP
+ BootMenu[u16BootCount].ItemToken = STRING_TOKEN(STR_POPUPMENU_ENTER_SETUP);
+ BootMenu[u16BootCount].Callback = (VOID*)NULL ;
+ BootMenu[u16BootCount].CallbackContext = (VOID*)NULL ;
+ BootMenu[u16BootCount].Attribute = AMI_POSTMENU_ATTRIB_FOCUS;
+ BootMenu[u16BootCount].Key.Key.ScanCode = 0 ;
+ BootMenu[u16BootCount].Key.Key.UnicodeChar = 0 ;
+ BootMenu[u16BootCount].Key.KeyShiftState = 0 ;
+#endif
+
+ Title = STRING_TOKEN(STR_BBS_POPUP_TITLE_STRING) ;
+ Legend = STRING_TOKEN(STR_BBS_POPUP_HELP_STRING) ;
+
+ gBBSPopupSel = 0 ;
+
+// EIP - 46314: Check ItemCount before displaying boot menu
+ if(ItemCount)
+ {
+
+ MouseRefresh();//Mouse is Initialized when mouse is notified so refreshing the mouse.
+ Status = pAmiPostMgr->DisplayPostMenu(gHiiHandle, Title, Legend, BootMenu, ItemCount, &sel);
+ MouseStop();
+
+ // EIP - 51425: Check ESC key before setting boot selection
+ if((Status == EFI_ABORTED)||(Status != EFI_SUCCESS))
+ {
+ if ( EFI_ABORTED == Status )
+ ProcessProceedToBootHook();//EIP 116559 : When ESC pressed in the BBS popup menu
+ gBBSPopupSel = 0 ;
+ goto DONE;
+ }
+
+#if POPUP_MENU_ENTER_SETUP
+ if(BootMenu[sel].ItemToken == STRING_TOKEN(STR_POPUPMENU_ENTER_SETUP))
+ {
+ gEnterSetup = TRUE;
+ }
+ else
+#endif
+ gBBSPopupSel = sel ;
+
+ }// EIP - 46314
+
+DONE:
+ gBootFlow = BOOT_FLOW_CONDITION_NORMAL; //EIP 136371, BBS popup flow also, should behave normally on entering into setup. Fixed for root page ordering
+ Status = pRS->SetVariable (L"BootFlow",
+ &_gBootFlowGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (gBootFlow),
+ &gBootFlow);
+ StyleExit (); //Added to clear the screen after bbs popup menu vanishes.
+ return Status;
+}
+
+
+
+
+
+#ifdef RUNTIME_DEBUG_SUPPORT
+BOOLEAN __RuntimeCheckDebugMode( CHAR16 *string )
+{
+ EFI_STATUS Status;
+ EFI_GUID env = ENVIRONMENT_VARIABLE_ID;
+
+ UINTN size = 0;
+ CHAR16 *buffer = NULL;
+ INTN result = 1;
+
+ Status = gRT->GetVariable(
+ L"debug",
+ &env,
+ NULL,
+ &size,
+ NULL);
+
+ if ( Status == EFI_BUFFER_TOO_SMALL )
+ {
+ buffer = EfiLibAllocateZeroPool( size );
+ if ( buffer != NULL )
+ {
+ Status = gRT->GetVariable(
+ L"debug",
+ &env,
+ NULL,
+ &size,
+ buffer);
+ }
+ }
+
+ if ( ! EFI_ERROR( Status ) )
+ result = EfiStrCmp( string, buffer );
+
+ MemFreePointer( (VOID **)&buffer );
+
+ return (BOOLEAN)( result == 0 );
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitGlobalPointers
+//
+// Description: function to Initialize all the global pointer declared.
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InitGlobalPointers( VOID )
+{
+ UINT8 *data;
+
+ gSetupPkg = (SETUP_PKG *)gApplicationData;
+ data = (UINT8 *)gSetupPkg;
+
+ gScreen = (SCREEN_INFO *)(data + gSetupPkg->PackageScreen);
+ gToolPages = gPages = (PAGE_LIST *)(data + gSetupPkg->PackagePageList);
+ gToolControlInfo = (CONTROL_INFO *) (data + gSetupPkg->PackageControlOffset);
+ gToolVariables = gVariables = (VARIABLE_LIST *)(data + gSetupPkg->PackageVariableList);
+ gHpkInfo = (HPK_INFO *)(data + gSetupPkg->PackageHpkData);
+ gHpkInfoLength = gSetupPkg->PackageGuidList - gSetupPkg->PackageHpkData;
+ gGuidList = (GUID_LIST *)(data + gSetupPkg->PackageGuidList);
+ gToolPageIdList = gPageIdList = (PAGE_ID_LIST *) (data + gSetupPkg->PackagePageIdList);
+ gToolPageIdInfo = gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gToolPageIdList) + gToolPageIdList->PageIdList[0]);
+ InitgProgress();
+}
+
+
+
+EFI_STATUS _PostMenuUpdate( LISTBOX_DATA *ListBox)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Index= 0, j=0 ;
+ LISTBOX_BSS_POPUP_DATA *listboxBBSPopupData=NULL;
+
+
+ listboxBBSPopupData = EfiLibAllocateZeroPool( sizeof( LISTBOX_BSS_POPUP_DATA ) );
+
+ if(listboxBBSPopupData==NULL)
+ return EFI_OUT_OF_RESOURCES;
+
+ listboxBBSPopupData->pControlData = NULL ;
+ listboxBBSPopupData->ItemCount = ListBox->ItemCount;
+ listboxBBSPopupData->PtrItems = EfiLibAllocateZeroPool( sizeof(POSTMENU_TEMPLATE)* listboxBBSPopupData->ItemCount);
+
+ if ( listboxBBSPopupData->PtrItems == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+
+ // MOVE the Hidden items to the end,
+ // First copy the printable list
+ for ( Index = 0,j=0; Index < listboxBBSPopupData->ItemCount; Index++ )
+ {
+ if( (gPostMenuData[Index].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (gPostMenuData[Index].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ listboxBBSPopupData->PtrItems[j] = gPostMenuData[Index] ;
+ j++;
+ }
+ }
+
+ listboxBBSPopupData->HiddenItemCount = Index - j;
+ // copy the hidden list
+ for ( Index = 0; Index < listboxBBSPopupData->ItemCount; Index++ )
+ {
+ if( (gPostMenuData[Index].Attribute == AMI_POSTMENU_ATTRIB_HIDDEN)||
+ (gPostMenuData[Index].Attribute == AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ listboxBBSPopupData->PtrItems[j] = gPostMenuData[Index] ;
+ j++;
+ }
+ }
+
+ MemFreePointer((VOID **)&ListBox->PtrTokens);
+ MemFreePointer((VOID **)&ListBox->PtrItems);
+ //RestoreScreen( ListBox->ScreenBuf );
+
+ ListBox->Width = 0 ;
+ ListBox->Height = 0 ;
+
+ Status = gListBox.InitializeBBSPopup( ListBox, listboxBBSPopupData );
+
+ // Free allocated init data
+ MemFreePointer((VOID**)&listboxBBSPopupData->PtrItems);
+ MemFreePointer((VOID**)&listboxBBSPopupData);
+
+ MemCopy( gActiveBuffer, ListBox->ScreenBuf, sizeof(SCREEN_BUFFER) );
+
+
+ return Status ;
+}
+
+EFI_STATUS _PostMenuItemChange( POSTMENU_TEMPLATE MenuItem, UINT16 Count )
+{
+ EFI_STATUS Status = EFI_SUCCESS ;
+ UINT16 Index= 0 ;
+
+ for ( Index = 0; Index < Count; Index++ )
+ {
+ if(gPostMenuData[Index].ItemToken == MenuItem.ItemToken)
+ {
+ if(gPostMenuData[Index].Attribute != MenuItem.Attribute)
+ break;
+
+ if(gPostMenuData[Index].Callback != MenuItem.Callback)
+ break;
+
+ if(gPostMenuData[Index].Key.Key.ScanCode != MenuItem.Key.Key.ScanCode)
+ break;
+
+ if(gPostMenuData[Index].Key.Key.UnicodeChar != MenuItem.Key.Key.UnicodeChar)
+ break;
+
+ if(gPostMenuData[Index].Key.KeyShiftState != MenuItem.Key.KeyShiftState)
+ break;
+
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ return Status ;
+}
+
+EFI_STATUS _PostMenuChange( LISTBOX_DATA *PopupMenu)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Index= 0 ;
+
+ for ( Index = 0; Index < PopupMenu->ItemCount; Index++ )
+ {
+ Status = _PostMenuItemChange(PopupMenu->PtrItems[Index], PopupMenu->ItemCount) ;
+
+ if(Status == EFI_SUCCESS)
+ return Status ;
+ }
+
+ return Status ;
+}
+
+VOID _ProcessPostMenuChange( LISTBOX_DATA *PopupMenu)
+{
+ ACTION_DATA *action=NULL;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Sel = PopupMenu->Sel ;
+
+ //Check if Menu has been dynamically changed
+ if(_PostMenuChange(PopupMenu )== EFI_SUCCESS)
+ {
+ //Update and initialize with new menu data
+ //Note: PopupMenu->Sel will be initialized to zero
+ _PostMenuUpdate(PopupMenu);
+
+ if(PopupMenu->PtrItems[Sel].Attribute == AMI_POSTMENU_ATTRIB_NON_FOCUS)
+ {
+ // item has been changed to non-focus
+ PopupMenu->Sel = Sel;
+
+ //Create and Send Fake Action...<Down-Arrow> Key
+ Status = gAction.Create( &action );
+ if ( !EFI_ERROR( Status ) )
+ {
+ action->Input.Type = ACTION_TYPE_KEY ;
+ action->Input.Data.AmiKey.Key.ScanCode = SCAN_DOWN;
+ action->Input.Data.AmiKey.Key.UnicodeChar = CHAR_NULL ;
+ gListBox.HandleAction(PopupMenu, action);
+
+ gAction.Destroy( action, TRUE );
+ }
+ }
+ else if( (PopupMenu->PtrItems[Sel].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (PopupMenu->PtrItems[Sel].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ PopupMenu->Sel = Sel;
+ }
+ //Exit if item callback has been changed to null
+ else if(PopupMenu->PtrItems[Sel].Callback == NULL)
+ {
+ PopupMenu->QuitPopupLoop = 1;
+ }
+ }
+}
+
+VOID _PostMenuCallback( LISTBOX_DATA *container, LISTBOX_DATA *PopupMenu, VOID *cookie )
+{
+ if ( cookie != NULL )
+ {
+ UINT16 Sel = *(UINT16 *) cookie;
+ POSTMENU_TEMPLATE *CurrentPostMenuData = NULL ;
+
+
+ if(PopupMenu->PtrItems[Sel].Callback != NULL)
+ {
+ CurrentPostMenuData = gPostMenuData; //EIP-93639
+ PopupMenu->PtrItems[Sel].Callback(PopupMenu->PtrItems[Sel].CallbackContext);
+ }
+
+ if( NULL != CurrentPostMenuData ) //EIP-93639
+ gPostMenuData = CurrentPostMenuData;
+ // EIP:54517
+ _ProcessPostMenuChange(PopupMenu);
+
+ //EIP:52897, Allways check for NULL to exit properly.
+ if(PopupMenu->PtrItems[Sel].Callback == NULL)
+ PopupMenu->QuitPopupLoop = 1;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ShowPostMenu
+//
+// Description: Function to show menu
+//
+// Input: IN CHAR16 *Title, IN POSTMENU_TEMPLATE *MenuData, IN UINT32 menucount, OUT UINT16 *pSelection
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ShowPostMenu(
+ IN VOID *HiiHandle,
+ IN UINT16 TitleToken,
+ IN UINT16 LegendToken,
+ IN POSTMENU_TEMPLATE *MenuData,
+ IN UINT16 MenuCount,
+ OUT UINT16 *pSelection)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT16 Index= 0, j, i, EXIT_KEY_PRESENT=0;
+ CONTROL_INFO *newControlInfo=NULL;
+ LISTBOX_BSS_POPUP_DATA *listboxBBSPopupData=NULL;
+ LISTBOX_DATA *ListBoxCtrl=NULL;
+ ACTION_DATA *action=NULL;
+ UINT8 Color, sel = 0 ;
+ CONTROL_ACTION Action ;
+
+
+ // Error check the input pointers (HiiHandle is allowed to be NULL)
+ if(pSelection == NULL || MenuData == NULL) return EFI_INVALID_PARAMETER;
+
+ newControlInfo = EfiLibAllocateZeroPool( sizeof( CONTROL_INFO ) );
+
+ if(newControlInfo==NULL) return EFI_OUT_OF_RESOURCES;
+
+ newControlInfo->ControlHandle = (HiiHandle!=NULL)?HiiHandle:gHiiHandle;
+ newControlInfo->ControlFlags.ControlVisible = TRUE;
+
+ listboxBBSPopupData = EfiLibAllocateZeroPool( sizeof( LISTBOX_BSS_POPUP_DATA ) );
+
+ if(listboxBBSPopupData==NULL) return EFI_OUT_OF_RESOURCES;
+
+ listboxBBSPopupData->TitleToken = TitleToken;
+ listboxBBSPopupData->Help1Token = LegendToken;
+ listboxBBSPopupData->pControlData = newControlInfo;
+
+ Status = gAction.Create( &action );
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ listboxBBSPopupData->ItemCount = MenuCount;
+ listboxBBSPopupData->PtrItems = EfiLibAllocateZeroPool( sizeof(POSTMENU_TEMPLATE)* listboxBBSPopupData->ItemCount);
+
+ if ( listboxBBSPopupData->PtrItems == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ gPostMenuData = MenuData;
+
+ // MOVE the Hidden items to the end,
+ // First copy the printable list
+ for ( Index = 0,j=0; Index < listboxBBSPopupData->ItemCount; Index++ )
+ {
+ if( (MenuData[Index].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (MenuData[Index].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ //EIP:51671 START
+ //Depending on the value of the token hide of the disabled boot options is done
+ if(gPopupMenuHideDisableBootOptions || gLoadOptionHidden)
+ {
+ if(MenuData[Index].ItemToken == 1)
+ {
+ MenuData[Index].Attribute = AMI_POSTMENU_ATTRIB_HIDDEN;
+ continue;
+ }
+ }
+ // EIP:51671 END
+ listboxBBSPopupData->PtrItems[j] = MenuData[Index] ;
+ j++;
+ }
+ }
+
+ listboxBBSPopupData->HiddenItemCount = Index - j;
+
+ // Then copy the hidden list
+ for ( Index = 0; Index < listboxBBSPopupData->ItemCount; Index++ )
+ {
+ if( (MenuData[Index].Attribute == AMI_POSTMENU_ATTRIB_HIDDEN)||
+ (MenuData[Index].Attribute == AMI_POSTMENU_ATTRIB_EXIT_KEY))
+ {
+ listboxBBSPopupData->PtrItems[j] = MenuData[Index] ;
+ j++;
+ }
+ }
+
+ // Create the list box item
+ if ( gListBox.Create( &ListBoxCtrl ) == EFI_SUCCESS )
+ {
+ Status = gListBox.InitializeBBSPopup( ListBoxCtrl, listboxBBSPopupData );
+ // Free allocated init data
+ MemFreePointer((VOID**)&newControlInfo);
+ MemFreePointer((VOID**)&listboxBBSPopupData->PtrItems);
+ MemFreePointer((VOID**)&listboxBBSPopupData);
+
+ if(Status == EFI_SUCCESS )
+ {
+ //Set default selection, make sure it is not hidden or non-focused
+ if( (ListBoxCtrl->PtrItems[*pSelection].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (ListBoxCtrl->PtrItems[*pSelection].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY)&&
+ (ListBoxCtrl->PtrItems[*pSelection].Attribute != AMI_POSTMENU_ATTRIB_NON_FOCUS))
+ {
+ ListBoxCtrl->Sel = *pSelection;
+ }
+ else
+ {
+ //Find the next selectable item...
+ for ( Index = 0; Index < ListBoxCtrl->ItemCount; Index++ )
+ {
+ if( (ListBoxCtrl->PtrItems[Index].Attribute != AMI_POSTMENU_ATTRIB_HIDDEN)&&
+ (ListBoxCtrl->PtrItems[Index].Attribute != AMI_POSTMENU_ATTRIB_EXIT_KEY)&&
+ (ListBoxCtrl->PtrItems[Index].Attribute != AMI_POSTMENU_ATTRIB_NON_FOCUS))
+ {
+ ListBoxCtrl->Sel = Index;
+ break;
+ }
+ }
+
+ // if the entire menuy is hidden, get out
+ if(ListBoxCtrl->HiddenItemCount == ListBoxCtrl->ItemCount)
+ {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ // If there are no selectable items, go out
+ if(Index == ListBoxCtrl->ItemCount)
+ {
+ //Status = EFI_INVALID_PARAMETER;
+ //goto Done;
+ }
+
+ }
+
+ gPostMenuLevel += 1 ;
+
+ Color = ListBoxCtrl->FGColor | ListBoxCtrl->BGColor ;
+ StyleGetWindowColor(&Color, gPostMenuLevel, TSE_WINDOW_TYPE_POSTMENU);
+ ListBoxCtrl->FGColor = (Color & 0x0F) ;
+ ListBoxCtrl->BGColor = (Color & 0xF0) ;
+
+
+ // Display everything to the internal screen buffer
+ ListBoxCtrl->QuitPopupLoop = 0 ;
+ gListBox.SetCallback(ListBoxCtrl, NULL, _PostMenuCallback, NULL);
+ gListBox.Draw( ListBoxCtrl );
+
+ MouseStop();
+ // Display everything to the screen
+ DoRealFlushLines();
+ MouseRefresh();//EIP:51627 -Provided the mouse support for Add boot option with File browser support
+
+
+ while(!ListBoxCtrl->QuitPopupLoop)
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gListBox.Draw( ListBoxCtrl );
+ MouseFreeze();
+ DoRealFlushLines();
+ MouseRefresh();
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ //EIP-123432 PrintScreen Support work only inside TSE not in post
+ if( (gPostStatus == TSE_POST_STATUS_IN_TSE) && ( action->Input.Type == ACTION_TYPE_KEY ) &&
+ (TsePrintScreenEventSupport(action->Input.Data.AmiKey.Key.ScanCode) ) )
+ {
+ gApplication.HandleAction( gApp, action );
+ continue;
+ }
+
+ //EIP:52897, Make sure pSelection is updated before callback is handled.
+ for(i=0; i < MenuCount; i++)
+ {
+ if( ListBoxCtrl->PtrItems[ListBoxCtrl->Sel].ItemToken == MenuData[i].ItemToken)
+ {
+ *pSelection = i;
+ break;
+ }
+ }
+
+ Status = gListBox.HandleAction( ListBoxCtrl, action );
+ if ( !EFI_ERROR (Status) )//EIP-123432
+ {
+ if (action->Input.Type == ACTION_TYPE_KEY)
+ Action = MapControlKeysHook (action->Input.Data.AmiKey);
+
+ else if( (gPostStatus == TSE_POST_STATUS_IN_TSE) && ( //If mouse is clicked outside menu inside setup
+ (action->Input.Data.MouseInfo.Top < (UINT32)(ListBoxCtrl->Top-2)) || //If clicked above menu title
+ (action->Input.Data.MouseInfo.Top >= (UINT32)(ListBoxCtrl->Top + ListBoxCtrl->Height)) || //if clicked below menu
+ (action->Input.Data.MouseInfo.Left < (UINT32)(ListBoxCtrl->Left)) || //if clicked left outside of menu
+ (action->Input.Data.MouseInfo.Left > (UINT32)(ListBoxCtrl->Left + ListBoxCtrl->Width)) //if clicked right outside of menu
+ ) &&( (SingleClickActivation() && (ControlActionSelect ==MapControlMouseActionHook(&action->Input.Data.MouseInfo))) || //If singleClickActivation is enabled
+ (ControlActionAbort == MapControlMouseActionHook(&action->Input.Data.MouseInfo)) || //If right clicked outside
+ (ControlActionChoose == MapControlMouseActionHook(&action->Input.Data.MouseInfo)) //EIP-139608 Closing postmenu when mouse action happens outside postmenu.
+ )
+ )
+ {
+ Action = ControlActionAbort;
+ }
+ }
+
+
+ //Menu may dynamically update, so init EXIT KEY flag here...
+ EXIT_KEY_PRESENT = 0 ;
+
+ //Since hidden items are moved to the end,
+ //we need to return the matching index of the caller's menu
+ for(i=0; i < MenuCount; i++)
+ {
+ if( ListBoxCtrl->PtrItems[ListBoxCtrl->Sel].ItemToken == MenuData[i].ItemToken)
+ *pSelection = i;
+
+ if(ListBoxCtrl->PtrItems[i].Attribute == AMI_POSTMENU_ATTRIB_EXIT_KEY)
+ {
+ EXIT_KEY_PRESENT = 1 ;
+
+ if( (ListBoxCtrl->PtrItems[i].Key.Key.ScanCode == action->Input.Data.AmiKey.Key.ScanCode ) &&
+ (ListBoxCtrl->PtrItems[i].Key.Key.UnicodeChar == action->Input.Data.AmiKey.Key.UnicodeChar) &&
+ (TseCheckShiftState( action->Input.Data.AmiKey, ListBoxCtrl->PtrItems[i].Key.KeyShiftState) ) )
+ {
+ ListBoxCtrl->QuitPopupLoop = 1;
+ Status = EFI_ABORTED ; //EIP:39415, return error status on esc key
+
+ }
+ }
+ }
+
+ if(ControlActionSelect == Action)
+ {
+
+ //EIP:52427 Start
+ if(TitleToken && ListBoxCtrl->Title != NULL)
+ {
+ //To avoid memory leak, free memory before updating...
+ MemFreePointer((VOID **)&ListBoxCtrl->Title);
+
+ //EIP:48417 Start
+ ListBoxCtrl->Title = HiiGetString( ListBoxCtrl->ListHandle, TitleToken );
+ //EIP:48417 End
+ }
+ //EIP:52427 End
+
+
+ gPostMenuData = MenuData;
+ _ProcessPostMenuChange(ListBoxCtrl) ;
+
+ }else if(!EXIT_KEY_PRESENT && ControlActionAbort == Action)
+ {
+ if (gPostStatus == TSE_POST_STATUS_IN_BBS_POPUP)
+ {
+ if (IsDisableESCinBBSMenu ())//EIP-128526 Disable ESC behaviour in BBS menu and retain till selecting any options
+ continue;
+ else //Enabling ESC key in BBS menu and exit BBS menu on pressing ESC key
+ {
+ ListBoxCtrl->QuitPopupLoop = 1;
+ Status = EFI_ABORTED ; //EIP:39415, return error status on esc key
+ }
+ }
+ else //Handling ESC other than BBSMenu
+ {
+ ListBoxCtrl->QuitPopupLoop = 1;
+ Status = EFI_ABORTED ;
+ }
+ }
+ }
+ }
+ }
+
+
+Done:
+
+ gPostMenuLevel -= 1 ;
+
+ gListBox.Destroy( ListBoxCtrl,TRUE );
+ ListBoxCtrl = NULL;
+
+ gAction.Destroy( action, TRUE );
+ MouseStop();//EIP:51627 -Provided the mouse support for Add boot option with File browser support
+
+ FlushLines( 0, gMaxRows - 1 );
+ DoRealFlushLines();
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _LoadPageDefaults
+//
+// Description: Function to updated defaults for specific page for both Optimal and FailSafe defaults
+//
+// Input: PAGE_INFO, UINT32
+//
+// Output: VOID
+//
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _LoadPageDefaults(PAGE_INFO *pageInfo, UINT32 OldVariableCount)
+{
+ UINT32 control;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE ) || ( controlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER ) || (controlInfo->ControlVariable == VARIABLE_ID_BBS_ORDER) )
+ continue;
+
+ if ( controlInfo->ControlDataWidth > 0 )
+ {
+ VOID *ifrData = controlInfo->ControlPtr;
+ UINT8 *failValue, *optValue;
+ UINT32 ControlVarOffset;
+
+ if ( ifrData == NULL )
+ continue;
+
+ failValue = (UINT8 *)controlInfo + sizeof(CONTROL_INFO);
+ optValue = failValue + controlInfo->ControlDataWidth;
+
+ ControlVarOffset = UefiGetQuestionOffset(ifrData);
+
+ //EIP-93340 Updating gOptimalDefaults and gFailSafeDefaults for stringType controls based on controlPtr
+ if (IsSupportDefaultForStringControl() && controlInfo->ControlType == CONTROL_TYPE_POPUP_STRING)
+ {
+ if (*(UINT16*)(failValue))
+ {
+ failValue = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(failValue));
+ if (NULL == failValue)
+ continue;
+
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen((CHAR16*)failValue) * sizeof(CHAR16), failValue );
+ }
+
+ if (*(UINT16*)(optValue))
+ {
+ optValue = (VOID*)HiiGetString( controlInfo->ControlHandle, *(UINT16*)(optValue));
+ if (NULL == optValue)
+ continue;
+
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen((CHAR16*)optValue) * sizeof(CHAR16), optValue );
+
+ if(controlInfo->ControlVariable > OldVariableCount)
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gVariableList, controlInfo->ControlVariable, ControlVarOffset, EfiStrLen((CHAR16*)optValue) * sizeof(CHAR16), optValue );
+
+ }
+
+ if (failValue)
+ MemFreePointer( (VOID **)&failValue );
+
+ if (optValue)
+ MemFreePointer( (VOID **)&optValue );
+ }
+ //EIP-93340 End
+ else
+ {
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gFailsafeDefaults, controlInfo->ControlVariable, ControlVarOffset, controlInfo->ControlDataWidth, failValue );
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, ControlVarOffset, controlInfo->ControlDataWidth, optValue );
+ // Dont' Update the cache of exsiting variable.
+ if(controlInfo->ControlVariable > OldVariableCount)
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gVariableList, controlInfo->ControlVariable, ControlVarOffset, controlInfo->ControlDataWidth, optValue );
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UIUpdateCallback
+//
+// Description: UI callback function for dynamic form updates.
+//
+// Input: IN Handle of Affected page
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+static AMI_IFR_MENU gMenuData = {CONTROL_TYPE_MENU,2};
+extern UINT32 gtempCurrentPage;
+VOID UIUpdateCallback(VOID * Handle, UINT32 OldVariableCount)
+{
+ UINT32 i,j, CurrentPage,Index;
+ PAGE_INFO *_gPageInfo,*_gappPageInfo,*_tmpPageInfo;
+ UINT32 tmpControlCount,tmpCurrentControl,tmpFirstVisibleCtrl;
+ FRAME_DATA *fdata;
+ PAGE_DATA *PageData;
+
+ if(gApp == NULL)
+ return; // Application data not initilized.
+
+ if(gVariables->VariableCount > OldVariableCount)
+ {
+ // NewVariables Added.
+ // Update the TSE catch and Defaults
+ // Reallocate
+ gVariableList = MemReallocateZeroPool( gVariableList, sizeof(NVRAM_VARIABLE) * OldVariableCount, gVariables->VariableCount * sizeof(NVRAM_VARIABLE));
+ gOptimalDefaults = MemReallocateZeroPool( gOptimalDefaults, sizeof(NVRAM_VARIABLE) * OldVariableCount, gVariables->VariableCount * sizeof(NVRAM_VARIABLE));
+ gFailsafeDefaults = MemReallocateZeroPool( gFailsafeDefaults, sizeof(NVRAM_VARIABLE) * OldVariableCount, gVariables->VariableCount * sizeof(NVRAM_VARIABLE));
+ ASSERT (gVariableList != NULL);
+ ASSERT (gOptimalDefaults != NULL);
+ ASSERT (gFailsafeDefaults != NULL);
+
+ for(Index = OldVariableCount; Index< gVariables->VariableCount; Index++)
+ {
+ gVariableList[Index].Buffer = VarGetNvram( Index, &(gVariableList[Index].Size) );
+ if (gVariableList[Index].Size)
+ {
+ // init std defautls
+ gOptimalDefaults[Index].Buffer = EfiLibAllocateZeroPool( gVariableList[Index].Size );
+ if (NULL == gOptimalDefaults[Index].Buffer)
+ {
+ continue;
+ }
+ if (NULL == gVariableList[Index].Buffer)
+ {
+ gVariableList[Index].Buffer = EfiLibAllocateZeroPool( gVariableList[Index].Size );
+ if (NULL == gVariableList[Index].Buffer)
+ {
+ continue;
+ }
+ }
+ MemCopy(gOptimalDefaults[Index].Buffer, gVariableList[Index].Buffer, gVariableList[Index].Size);
+
+ // init mfg defautls
+ gFailsafeDefaults[Index].Buffer = EfiLibAllocateZeroPool( gVariableList[Index].Size );
+ MemCopy(gFailsafeDefaults[Index].Buffer, gVariableList[Index].Buffer, gVariableList[Index].Size);
+ }
+ else
+ {
+ gFailsafeDefaults[Index].Buffer = NULL;
+ gOptimalDefaults[Index].Buffer = NULL;
+ }
+
+ gFailsafeDefaults[Index].Size = gVariableList[Index].Size;
+ gOptimalDefaults[Index].Size = gVariableList[Index].Size;
+ }
+ }
+
+ CurrentPage = gApp->CurrentPage;
+ fdata = ((PAGE_DATA*)gApp->PageList[gApp->CurrentPage])->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+
+ tmpControlCount = fdata->ControlCount;
+ tmpCurrentControl = fdata->CurrentControl;
+ tmpFirstVisibleCtrl = fdata->FirstVisibleCtrl;
+
+ // Fix gApp Pages
+ for ( i = 1; i < gPages->PageCount; i++ )
+ {
+ // Get the Setupdata's Page Info
+ _gPageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[i]);
+
+ // If page is updated
+ if( (_gPageInfo->PageHandle == Handle) || (_gPageInfo->PageHandle == (VOID *)(UINTN)0xFFFF))
+ {
+ for ( j = 1; j < gApp->PageCount; j++ )
+ {
+ _gappPageInfo = (PAGE_INFO*)&( gApp->PageList[j]->PageData);
+ // If updated handle ?
+ if(_gappPageInfo->PageHandle == Handle)
+ {
+ // Update page
+ if(_gPageInfo->PageFormID == _gappPageInfo->PageFormID)
+ {
+ gPage.Destroy( gApp->PageList[j], FALSE );
+ if(_gPageInfo->PageHandle != (VOID *)(UINTN)0xFFFF)
+ {
+ if((_gPageInfo->PageFlags.PageDynamic == TRUE) && (_gPageInfo->PageParentID == 0))
+ _gPageInfo->PageParentID = gDynamicParentPage;
+ gPage.Initialize( gApp->PageList[j], _gPageInfo );
+ _LoadPageDefaults(_gPageInfo,OldVariableCount);
+ }
+ else
+ _gappPageInfo->PageHandle = NULL;
+
+ break;
+ }
+ }
+ }
+ // New Page - Add Page
+ if(j == gApp->PageCount)
+ {
+ gtempCurrentPage = gApp->CurrentPage;
+ gApp->CurrentPage = j; //Change the current else in UefiGetQuestionOffset page handle will not be matched useful for name value
+ gApplication.AddPage( gApp, _gPageInfo );
+ gApp->CurrentPage = gtempCurrentPage;
+ _LoadPageDefaults(_gPageInfo,OldVariableCount);
+ }
+ }
+ }
+
+ // If Current Page removed ????
+ _gappPageInfo = (PAGE_INFO*)&( gApp->PageList[gApp->CurrentPage]->PageData);
+ if(_gappPageInfo->PageHandle == NULL)
+ {
+ UINT32 rootPage = 0, FirstPage=0;
+ for ( j = 1; j < gApp->PageCount; j++ )
+ {
+ _tmpPageInfo = (PAGE_INFO*)&( gApp->PageList[j]->PageData);
+ if(_tmpPageInfo->PageHandle == Handle)
+ {
+ if(_gappPageInfo->PageFormID == _tmpPageInfo->PageFormID)
+ {
+ //Current Page moved
+ CurrentPage = gApp->CurrentPage = j;
+ break;
+ }
+ if(_tmpPageInfo->PageParentID == 0)
+ rootPage = _tmpPageInfo->PageID;
+ }
+ if((_tmpPageInfo->PageHandle != NULL) && (FirstPage==0) && (!_tmpPageInfo->PageFlags.PageVisible))
+ FirstPage = j;
+ }
+ // Page permently removed.
+ if(j == gApp->PageCount)
+ {
+ if(rootPage)
+ {
+ // Try to go to Root page of Current handle
+ gApp->CurrentPage = rootPage;
+ }
+ else
+ {
+ if(FirstPage)
+ gApp->CurrentPage = FirstPage;
+ else
+ {
+ // NO Valid PAGE Found
+ // HANDLE ERRROR!!!!
+ }
+ }
+ }
+ gApp->CompleteRedraw = TRUE;
+ }
+
+ // Update the Menu control
+ i = StyleFrameIndexOf(SUBTITLE_FRAME);
+ for ( j = 1; j < gApp->PageCount; j++ )
+ {
+ PageData = (PAGE_DATA*)gApp->PageList[j];
+ if(PageData == NULL)
+ continue;
+ if(PageData->PageData.PageHandle != NULL)
+ {
+ gFrame.Destroy( PageData->FrameList[i], FALSE );
+ StyleInitializeFrame( PageData->FrameList[i], SUBTITLE_FRAME, &PageData->PageData );
+ }
+ }
+
+ // To Maintain the current control
+ if(CurrentPage == gApp->CurrentPage)
+ {
+ fdata = ((PAGE_DATA*)gApp->PageList[gApp->CurrentPage])->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ // Update Controls
+ if(fdata->ControlCount == tmpControlCount)
+ {
+ fdata->CurrentControl=tmpCurrentControl;
+ fdata->FirstVisibleCtrl=tmpFirstVisibleCtrl;
+ _FrameSetControlFocus( fdata, tmpCurrentControl );
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetUpdatedControlData
+//
+// Description: Try to get the updated control.
+//
+// Input: CONTROL_DATA * ControlData,UINT16 ControlType,VOID *Handle,UINT16 Key
+//
+// Output: controlData. Null if not found.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CONTROL_DATA * GetUpdatedControlData(CONTROL_DATA * ControlData,UINT16 ControlType,VOID *Handle,UINT16 Key)
+{
+ FRAME_DATA *frame;
+ UINT32 i;
+ CONTROL_DATA **control;
+
+ if ( NULL == ((PAGE_DATA*)gApp->PageList[gApp->CurrentPage]) )//Setup crashes on clicking submenu when PageList is NULL
+ return NULL;
+
+ frame = ((PAGE_DATA*)gApp->PageList[gApp->CurrentPage])->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+
+ control = frame->ControlList;
+ for ( i = 0; i < frame->ControlCount; i++, control++ )
+ {
+ if(((*control)->ControlData.ControlHandle == Handle) && ((*control)->ControlData.ControlType == ControlType))
+ {
+ if(UefiGetControlKey(&((*control)->ControlData)) == Key)
+ return *control;
+ }
+ }
+ return NULL;
+}
+
+BOOLEAN IsActiveControlPresent(PAGE_DATA *page)
+{
+ BOOLEAN ControlActive=FALSE;
+ CONTROL_DATA **control;
+ FRAME_DATA * pFrame;
+ UINTN i;
+
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ pFrame = page->FrameList[StyleFrameIndexOf((UINT32)i)];
+ if(pFrame->CurrentControl != FRAME_NONE_FOCUSED)
+ {
+ control = &pFrame->ControlList[pFrame->CurrentControl];
+ if((*control)->ControlActive == TRUE )
+ {
+ ControlActive = TRUE;
+ break;
+ }
+ }
+ }
+ return ControlActive;
+}
+
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------
+// Procedure: UpdategScreenParams
+//
+// Description: Verifies and corrects the gScreen params with the current uni strings
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//-----------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdategScreenParams (VOID)
+{
+ if (STR_MAIN_TITLE != gScreen->MainTitle)
+ {
+ gScreen->MainTitle = STR_MAIN_TITLE;
+ }
+ if (STR_MAIN_COPYRIGHT != gScreen->MainCopyright)
+ {
+ gScreen->MainCopyright = STR_MAIN_COPYRIGHT;
+ }
+ if (STR_EVAL_MSG != gScreen->MainHelpTitle)
+ {
+ gScreen->MainHelpTitle = STR_EVAL_MSG;
+ }
+}
+//EIP: 58925 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetParentFormID
+//
+// Description: Gets the parent page ID from given child page ID
+//
+// Input: UINT16 ChildID - Child page ID
+// UINT16 *ParentID - Parent page ID
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetParentFormID(UINT16 ChildID, UINT16 *ParentID, UINT32 *StackIndex)
+{
+ EFI_STATUS Status = EFI_NOT_FOUND;
+ UINT32 navCount = 0, gAppPageCount = 0;
+
+ *StackIndex = 0xFFFFFFFF;
+
+ if(gApp->PageList[ChildID] == NULL){
+ Status = EFI_ABORTED;
+ goto DONE;
+ }
+
+ Status = EFI_NOT_FOUND;
+ for(navCount = 0; navCount < gPageNavCount; navCount++){ //Check in the navigated page stack
+ if((NavPageStack[navCount].PageFormID == gApp->PageList[ChildID]->PageData.PageFormID)
+ && (NavPageStack[navCount].PageHandle == gApp->PageList[ChildID]->PageData.PageHandle))
+ {
+ if((NavPageStack[navCount].PageParentFormID == 0) && (NavPageStack[navCount].ParentPageHandle == NULL)){ //If the parent page and parent handle is invalid
+ *StackIndex = 0;
+ break;
+ }
+ for(gAppPageCount = gNavStartPage; gAppPageCount < gApp->PageCount; gAppPageCount++){ //Check against the application page list
+ if((gApp->PageList[gAppPageCount]->PageData.PageFormID == (UINT16)NavPageStack[navCount].PageParentFormID)
+ && (gApp->PageList[gAppPageCount]->PageData.PageHandle == NavPageStack[navCount].ParentPageHandle))
+ {
+ *ParentID = gApp->PageList[gAppPageCount]->PageData.PageID;
+ *StackIndex = navCount;
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+DONE:
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetParentFormID
+//
+// Description: Updated NAV_PAGE_STACK with current page and parent page info
+//
+// Input: UINT16 ParentID - Current/Parent Page ID
+// UINT16 TargetID - Target/child page ID
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS if successful, else EFI_ERROR
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetParentFormID(UINT16 ParentID, UINT16 TargetID)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 StackIndex = 0xFFFFFFFF;
+ UINT16 ParID = 0; //Temporary variable for finding the parent page ID of the target page
+
+ if(ParentID == TargetID){
+ return Status;
+ }
+
+ if(NavPageStack == NULL){
+ NavPageStackSize = gApp->PageCount + MAX_NAVIGATION_DEPTH;
+ NavPageStack = (NAV_PAGE_STACK *)EfiLibAllocateZeroPool(sizeof(NAV_PAGE_STACK) * (NavPageStackSize));
+ if(NavPageStack == NULL){
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ gNavStartPage = TargetID; //Sets the start page of the formset
+ }
+
+ Status = GetParentFormID(TargetID, &ParID, &StackIndex);
+ if(Status == EFI_ABORTED){
+ goto DONE;
+ }
+ if((Status == EFI_SUCCESS) && (StackIndex < NavPageStackSize)){
+ gPageNavCount = StackIndex + 1; //Decrement the total number of pages navigated
+ if(gPageNavCount < NavPageStackSize){
+ MemSet(&NavPageStack[gPageNavCount], (NavPageStackSize - gPageNavCount) * sizeof(NAV_PAGE_STACK), 0); //Remove the child page information from NAV_PAGE_STACK
+ }
+ goto DONE;
+ } else if((Status != EFI_SUCCESS) && (StackIndex < NavPageStackSize) && (ParID == 0)){
+ gPageNavCount = 1; //Because the navigation root is not found
+ if(gPageNavCount < NavPageStackSize){
+ MemSet(&NavPageStack[gPageNavCount], (NavPageStackSize - gPageNavCount) * sizeof(NAV_PAGE_STACK), 0); //Remove the child page information from NAV_PAGE_STACK
+ }
+ goto DONE;
+ }
+
+ //Adds the child page info in the NAV_PAGE_STACK
+ if(NavPageStackSize <= gPageNavCount)
+ {
+ NavPageStackSize += MAX_NAVIGATION_DEPTH;
+ NavPageStack = MemReallocateZeroPool( NavPageStack, NavPageStackSize-MAX_NAVIGATION_DEPTH, NavPageStackSize );
+ if(NavPageStack == NULL){
+ Status = EFI_OUT_OF_RESOURCES;
+ gPageNavCount=0;
+ goto DONE;
+ }
+ }
+
+ NavPageStack[gPageNavCount].PageHandle = gApp->PageList[TargetID]->PageData.PageHandle;
+ NavPageStack[gPageNavCount].PageFormID = gApp->PageList[TargetID]->PageData.PageFormID;
+ if(gPageNavCount){
+ NavPageStack[gPageNavCount].ParentPageHandle = NavPageStack[gPageNavCount - 1].PageHandle;
+ NavPageStack[gPageNavCount].PageParentFormID = NavPageStack[gPageNavCount - 1].PageFormID;
+ }
+ gPageNavCount++; //Increment the total number of pages navigated
+
+
+DONE:
+ return Status;
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: ResetNavStack
+//
+// Description: Resets the navigation stack
+//
+// Input: None
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ResetNavStack()
+{
+ if(NavPageStack){
+ MemFreePointer(&NavPageStack);
+ NavPageStack = (NAV_PAGE_STACK *)NULL; //Resets the navigated page info
+ }
+ gPageNavCount = 0; //Resets the navigated page count
+ gNavStartPage = 0; //Resets the start page of the formset
+ gDisplayPageId = 0; //Reset the displayed page ID
+}
+//EIP: 58925 End
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckEnableQuietBoot
+//
+// Description: Function to check the quick boot enable option
+//
+// Input: void
+//
+// Output: void
+//
+// Notes : if NVRAM variable field AMISilentBoot = 0, then disable silent
+// mode else enable In case of error reading the Setup variable,
+// then return as silent boot disable
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CheckEnableQuietBoot( VOID )
+{
+#ifndef STANDALONE_APPLICATION
+ if(ItkSupport())
+ gQuietBoot = TRUE;
+ else
+ {
+ UINT8 *setupvar=NULL;
+ UINT8 *setup=NULL;
+ UINTN size = 0;
+ UINTN offset;
+
+ GetAMITSEVariable((AMITSESETUP**)&setup,&setupvar,&size);
+
+ offset = STRUCT_OFFSET( AMITSESETUP, AMISilentBoot );
+ if ( ( setup == NULL ) || ( size < offset ) )
+ gQuietBoot = FALSE;
+ else
+ gQuietBoot = (BOOLEAN)setup[offset];
+
+ if(setupvar)
+ MemFreePointer( (VOID **)&setupvar );
+ else
+ MemFreePointer( (VOID **)&setup );
+ }
+#endif //#ifndef STANDALONE_APPLICATION
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetAMITSEVariableLocal
+//
+// Description: function to get the local NvRam variable
+//
+// Input: AMITSESETUP **mSysConf, UINT8 **setup, UINTN *VarSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetAMITSEVariableLocal(AMITSESETUP **mSysConf, UINT8 **setup, UINTN *VarSize)
+{
+ *mSysConf = VarGetVariable( VARIABLE_ID_AMITSESETUP, VarSize );
+ if ( ( *mSysConf == NULL ) || ( *VarSize != sizeof(AMITSESETUP) ) )
+ *mSysConf = VarGetNvram( VARIABLE_ID_AMITSESETUP, VarSize );
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/minisetupext.h b/EDK/MiniSetup/TseLite/minisetupext.h
new file mode 100644
index 0000000..d829aed
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/minisetupext.h
@@ -0,0 +1,537 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/minisetupext.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 30 $
+//
+// $Date: 8/28/14 3:07p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/minisetupext.h $
+//
+// 30 8/28/14 3:07p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 29 8/28/14 6:06a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 28 5/02/14 9:28p Arunsb
+// EIP141986 changes reverted.
+//
+// 27 5/02/14 10:59a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 26 2/11/14 8:23p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 24 3/12/13 7:02a Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 23 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 22 5/28/12 12:32p Premkumara
+// [TAG] EIP67049 & 90224
+// [Category] New Feature
+// [Description] Support mouse drag operation in frame and list box
+// [Files] CommonHelper.c, Frame.c, ListBox.c, Minisetupext.h
+//
+// 21 5/28/12 11:45a Premkumara
+// [TAG] EIP89272
+// [Category] Improvement
+// [Description] Change softkbd layout for numeric control
+// [Files] CommonHelper.c, Mouse.c, Minisetup.h, C, Numeric.c
+//
+// 20 4/05/12 7:16a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 19 1/24/12 4:40a Arunsb
+// [TAG] EIP81581
+// [Category] Improvement
+// [Description] Default driver order support
+// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and
+// variable.c
+//
+// 18 11/20/11 7:55a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 17 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 16 11/13/11 1:00p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 15 10/20/11 12:25p Blaines
+// Correct the comments.
+//
+// 14 10/20/11 11:48a Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab.
+//
+// [Files Changed]
+// - AMITSE.sdl, CommonHelper.c, special.c, Menu.c, minisetupext.h,
+// TseUefiHii.h, Uefi21Wapper.c
+//
+// 13 6/23/11 3:55p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 12 3/28/11 9:24p Madhans
+// [TAG] EIP41744
+// [Category] Improvement
+// [Description] SoftKeyBoard Support in TSE. and Support to Work with
+// new mouse driver(Label 07).
+// [Files] HookAnchor.h
+// AMITSE.sdl
+// CommonHelper.c
+// commonoem.c
+// commonoem.h
+// HookList.c
+// HookAnchor.c
+// Mouse.c
+// minisetupext.c
+// postmgmtext.c
+// minisetupext.h
+// PopupPassword.c
+// PopupString.c
+// TseLiteCommon.c
+//
+// 11 3/28/11 4:58p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 10 3/21/11 12:36a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 9 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 8 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 7 1/06/11 7:44p Madhans
+// [TAG] - EIP 51678
+// [Category]- Enhancment
+// [Severity]- Mordarate
+// [Symptom]- If OEMs override the style module parts, If new tse adds
+// new style hook then
+// if the OEM has different style module, even if they don't need use the
+// hook to avoid
+// compilation issue they need touch their style module to add the new
+// hook.
+// [RootCause] - The Original Style Hooks are part of Style module itself.
+// [Solution]- To create Empty style Hook List in TSE core. This will
+// allows the OEM not
+// to change their style module to update newer TSE.
+// [Files] - StyleHook Module Part under TSE lite sources. StyleHook.lib
+// StyleHookx64.lib tselitebin.sdl
+//
+// 6 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 10 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/15/10 10:14p Madhans
+// Uefi 2.1 support
+//
+// 8 1/09/10 6:23a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 10/28/09 5:38p Madhans
+//
+// 6 9/15/09 9:46a Sudhirv
+// added new definition VARIABLE_ID_OEM_TSE_VAR
+//
+// 5 8/20/09 6:43p Madhans
+// Fix for Mouse click crash issue.
+//
+// 4 8/19/09 12:58p Madhans
+// IsToggleStateKey() function added
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 4:11p Madhans
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: MINISETUPEXT.h
+//
+// Description: Header file for FULL TSE specific minisetup entery and exit funtionallies
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _MINISETUPEXT_H_
+#define _MINISETUPEXT_H_
+
+
+#define MINI_SETUP_HPK_DATA_GUID \
+ { 0xDCFBBCA4, 0x2498, 0x48DB, 0x91, 0x22, 0xFF, 0x7E, 0x96, 0x4B, 0xC5, 0x69 }
+//EIP:53480 Defining the Action requests for the callbacks
+#define AMI_CALLBACK_CONTROL_UPDATE 1
+#define AMI_CALLBACK_RETRIEVE 2
+#define AMI_CALLBACK_FORM_OPEN 3
+#define AMI_CALLBACK_FORM_CLOSE 4
+#define AMI_CALLBACK_FORM_DEFAULT_STANDARD 0x1000 //EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+#define AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING 0x1001
+
+#include "setupdata.h"
+#if EFI_SPECIFICATION_VERSION <= 0x20000
+#include "hii.h"
+#else
+#include "TseUefiHii.h"
+#endif /* #if EFI_SPECIFICATION_VERSION <= 0x20000 */
+#include "StyleHook\StyleHook.h"
+#if TSE_STYLE_SOURCES_SUPPORT
+#include "style.h"
+#endif
+#include "application.h"
+#include "action.h"
+#include "MessageBox.h"
+#include "hotkey.h"
+#include "Date.h"
+#include "Text.h"
+#include "edit.h"
+#include "Label.h"
+#include "ListBox.h"
+#include "Memo.h"
+#include "Menu.h" //
+#include "numeric.h"
+#include "popup.h"
+#include "PopupEdit.h"
+#include "PopupPassword.h"
+#include "PopupSel.h"
+#include "PopupString.h"
+#include "SubMenu.h"
+#include "Time.h"
+#include "password.h"
+#include "ordlistbox.h"
+#include "UefiAction.h"
+#include "ResetButton.h"//EIP:56413 Added reset button header file
+
+/*
+#include "special.h"
+*/
+
+extern SETUP_PKG *gSetupPkg;
+extern SCREEN_INFO *gScreen;
+extern PAGE_LIST *gPages;
+extern PAGE_LIST *gToolPages;
+extern CONTROL_INFO *gToolControlInfo;
+extern CONTROL_INFO *gControlInfo;
+extern VARIABLE_LIST *gToolVariables;
+extern VARIABLE_LIST *gVariables;
+extern PAGE_ID_LIST *gPageIdList;
+extern PAGE_ID_LIST *gToolPageIdList;
+extern PAGE_ID_INFO *gPageIdInfo;
+extern PAGE_ID_INFO *gToolPageIdInfo;
+
+extern NVRAM_VARIABLE *gVariableList;
+extern NVRAM_VARIABLE *gFailsafeDefaults;
+extern NVRAM_VARIABLE *gOptimalDefaults;
+
+extern HPK_INFO *gHpkInfo;
+
+extern GUID_LIST *gGuidList;
+
+extern FRAME_DATA *gActiveFrame;
+
+extern ACTION_DATA *gMsgBoxAction;
+extern UINT16 gDynamicParentPage;
+// callback.c
+VOID LoadPreviousValues( BOOLEAN showMsgBox );
+VOID LoadOptimalDefaults( VOID );
+VOID LoadFailsafeDefaults( VOID );
+BOOLEAN SaveAndExit( VOID );
+VOID SaveWithoutExit( VOID );
+BOOLEAN SaveAndReset( VOID );
+BOOLEAN ResetSys( VOID );
+BOOLEAN ExitApplication( VOID );
+VOID ShowHelpMessageBox( VOID );
+UINT8 CallbackShowMessageBox( UINTN data, UINT8 type );
+EFI_STATUS CallFormCallBack(CONTROL_INFO * pControlData, UINT16 Key, UINT8 Flags, UINTN Action);
+VOID UEFICallSetupFormCallBack(UINTN Action );
+
+// Helper
+extern CHAR8 *gPrevLanguage;
+extern UINTN gPrevLangSize;
+
+VARIABLE_INFO *VarGetVariableInfoIndex( UINT32 index );
+VARIABLE_INFO *VarGetVariableInfoId( UINT32 varId, UINT32 *index );
+// variable.h
+extern UINTN gSetupCount;
+VOID *BBSReOrderDefultLegacyDevOrder(BBS_ORDER_TABLE *DefaultLegDevOrder,UINTN DefaultLegDevOrderSize);
+extern EFI_GUID EfiDefaultLegacyDevOrderGuid;
+extern EFI_GUID EfiDefaultBootOrderGuid;
+extern EFI_GUID EfiDefaultDriverOrderGuid; //EIP81581
+//#define SETUP_PASSWORD_LENGTH 20
+extern const UINTN TsePasswordLength;
+VOID InitgProgress( VOID );
+VOID SetHDDPassword(VOID);
+VOID BBSUpdateOrder(UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer);
+VOID BootUpdateOrder (UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer);
+VOID DriverUpdateOrder (UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer); //EIP70421 & 70422 Support for driver order
+
+extern VOID MainSetupLoopInit(VOID) ;
+EFI_STATUS DoBbsPopupInit(VOID) ;
+EFI_STATUS DrawBbsPopupMenu( VOID );
+VOID DrawBootOnlyBbsPopupMenu( VOID ) ;
+VOID BbsBoot(VOID) ;
+
+EFI_STATUS VarBuildAMIDefaults(VOID);
+
+// Mouse Functions
+VOID NumericSoftKbdExit(VOID);
+VOID NumericSoftKbdInit(VOID);
+VOID PrintableKeysSoftKbdInit(VOID);
+VOID PrintableKeysSoftKbdExit(VOID);
+VOID MouseInit(VOID);
+VOID MouseStop(VOID);
+VOID MouseFreeze(VOID);
+VOID MouseRefresh(VOID);
+BOOLEAN IsMouseClickedonSoftkbd(VOID);
+VOID MouseStart(VOID);
+VOID MouseDestroy(VOID);
+EFI_STATUS MouseReadInfo(VOID *MouseInfo);
+EFI_STATUS MouseScrollBarMove(VOID *frame, BOOLEAN bScrollUp, UINT32 Size); //EIP-67049
+EFI_STATUS MouseListBoxScrollBarMove(VOID *listbox, BOOLEAN bScrollUp, UINT32 Size); //EIP-67049
+EFI_STATUS MouseFrameHandleAction( VOID *frame, VOID *action, VOID *control );
+EFI_STATUS MouseSubMenuHandleAction( VOID *submenu, VOID *Data);
+EFI_STATUS MouseMsgBoxHandleAction( VOID *msgbox, VOID *Data,BOOLEAN * pRedraw );
+EFI_STATUS MouseListBoxHandleAction( VOID *listbox, VOID *Data);
+EFI_STATUS MousePopupSelHandleAction( VOID *popupSel, VOID *Data);
+EFI_STATUS MousePopupEditHandleAction( VOID *PopupEdit, VOID *Data,BOOLEAN * pRedraw );
+EFI_STATUS MouseMenuHandleAction( VOID *menu, VOID *Data );
+
+
+VOID ReGroupOptions(UINT16 *optionList,UINT16 *OrgOptionList);
+EFI_STATUS PopupEditHandlePassword( VOID *PopupEdit, VOID *Data);
+EFI_STATUS ActionReadKey( AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout );
+EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData);
+EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar);
+VOID FramePasswordAdvancedCallback(CALLBACK_PASSWORD *callbackData,CHAR16 *saveData);
+EFI_STATUS FramePwdCallbackIdePasswordUpdate ( CONTROL_DATA *control,CHAR16 *saveData);
+EFI_STATUS PopupPwdAuthenticateIDEPwd(POPUP_PASSWORD_DATA *popuppassword, BOOLEAN *AbortUpdate,VOID *data);
+VOID PopupPwdUpdateIDEPwd (VOID);
+EFI_STATUS PopupPwdHandleActionOverRide(POPUP_PASSWORD_DATA *popuppassword, ACTION_DATA *Data);
+UINT32 PopupPasswordCheckInstalled(POPUP_PASSWORD_DATA *popuppassword);
+BOOLEAN PopupPasswordAuthenticate( POPUP_PASSWORD_DATA *popuppassword, CHAR16 *Password );
+EFI_STATUS FormBrowserLocateSetupHandles(/*EFI_HII_HANDLE*/VOID* **handleBuffer,UINT16 *count);
+BOOLEAN FormBrowserHandleValid(VOID);
+VOID GetAMITSEVariable(AMITSESETUP **mSysConf,UINT8 **setup,UINTN *VarSize);
+VOID NoVarStoreUpdateSystemAccess(UINT8 sysAccessValue);
+VOID SetSystemAccessValueItk(UINT8 sysAccessValue);
+VOID VarBuildItkDefaults(VOID);
+VOID SpecialUpdatePageControls(UINT32 CurrentPage);
+EFI_STATUS PopupPasswordFormCallback(CONTROL_INFO * pControlData,UINT16 Key,UINT8 Flags);
+BOOLEAN CheckSystemPasswordPolicy(UINT32 PasswordInstalled);
+
+extern UINTN gHpkInfoLength;
+BOOLEAN IsReadOnlyGrayout();
+BOOLEAN IsGrayoutSelectable();
+BOOLEAN IsGroupDynamicPages();
+BOOLEAN IsOrphanPagesAsRootPage();
+BOOLEAN IsLinkHistorySupport();
+BOOLEAN IsSubMenuDisplayTitle();
+
+VOID CsmSaveBBSOrder( VOID *);
+VOID CsmBBSSetDisabled(UINT16 Index, VOID **DisDPs, UINTN *DPSize);
+VOID CsmRearrangeBBSOrderVariable(VOID *popupSel, UINT8 bIncrease,UINT16 *newOption);
+VOID CsmLoadDefaultLegDevOrder(VOID);
+EFI_STATUS CsmBBSUpdateOrder(UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer);
+
+BOOLEAN TseLiteIsSpecialOptionList(CONTROL_DATA *);
+
+
+///IDE Password Hooks
+UINT16 TSEIDEPasswordGetName(UINT16 Index);
+EFI_STATUS TSEIDEPasswordAuthenticate(CHAR16 *Password, VOID* DataPtr, BOOLEAN bCheckUser);
+BOOLEAN TSEIDEPasswordUpdate( UINT32 DeviceIndex, CHAR16 *Password, BOOLEAN bCheckUser);
+VOID* TSEIDEPasswordGetDataPtr( UINTN Index);
+BOOLEAN TSEIDEPasswordGetLocked(UINTN Index);
+VOID TSEIDEPasswordCheck();
+VOID TSEIDEPasswordFreezeDevices();
+VOID TSEUnlockHDD(VOID);
+VOID TSESetHDDPassword(VOID);
+VOID TSEIDEUpdateConfig(VOID *ideSecConfig, UINTN value);
+
+
+UINTN TseGetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background);
+CHAR16 *TseSkipEscCode(CHAR16 *String);
+
+BOOLEAN TseCheckShiftState(AMI_EFI_KEY_DATA ActionKey, UINT32 HotkeyState);
+
+UINT32 _GetControlVariable(CONTROL_INFO *control);
+
+VOID TseHotkeyPrintScreenSupport();
+BOOLEAN TsePrintScreenEventSupport(UINT16 ScanCode);
+BOOLEAN IsToggleStateKey(ACTION_DATA *Data);
+BOOLEAN IsActiveControlPresent(PAGE_DATA *page);
+VOID TSEStringReadLoopEntryHook(VOID);
+VOID TSEStringReadLoopExitHook(VOID);
+BOOLEAN TSEMouseIgnoreMouseActionHook(VOID);
+VOID TSENumericSoftKbdExit(VOID);
+VOID TSENumericSoftKbdInit(VOID);
+#endif /* _MINISETUP_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/numeric.c b/EDK/MiniSetup/TseLite/numeric.c
new file mode 100644
index 0000000..4526b03
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/numeric.c
@@ -0,0 +1,1430 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/numeric.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 38 $
+//
+// $Date: 8/28/14 3:06p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/numeric.c $
+//
+// 38 8/28/14 3:06p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 37 5/03/14 8:04p Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 36 5/03/14 3:17p Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 35 5/02/14 9:33p Arunsb
+// EIP141986 changes reverted.
+//
+// 34 5/02/14 10:58a Premkumara
+// [TAG] EIP141986
+// [Category] New Feature
+// [Description] Made Grayed controls to focus-able when token
+// TSE_SETUP_GRAYOUT_SELECTABLE
+// is enabled and can't edit the values
+// [Files] AMITSE.sdl,CommonHelper.c,frame.c,Label.c,minisetupext.h,
+// numeric.c,PopupPassword.c,PopupSel.c,PopupString.c,SubMenu.c
+//
+// 33 5/01/14 3:43p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 32 2/11/14 9:02p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 31 12/05/13 1:37a Premkumara
+// [TAG] EIP139608
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] Not able to navigate to other page using Mouse/Clicks when
+// Numeric control is focused. Msgbox, Menu, Listbox is not closing using
+// touch/mouse.
+// [Root Cause] When token SINGLE_CLICK_ACTIVATION is enabled
+// numerichandle action is not returning unsupported. TSE isn't handled
+// ControlActionSelect to close msgbox, menu, listbox when token is
+// enable.
+// [Solution] Handled mouse action properly for numeric control. Handled
+// action properly to close msgbox, listbox, menu.
+// [Files] ListBox.c, Numeic.c, MessageBox.c, MinisetupExt.c
+//
+// 30 12/03/13 1:10p Premkumara
+// [TAG] EIP141986
+// [Category] Improvement
+// [Description] Make grayedout control focusable and this feature is
+// handled by token TSE_SETUP_GRAYOUT_SELECTABLE
+// [Files] AMITSE.sdl, CommonHelper.c, Frame.c, Label.c, Minisetupext.c,
+// Numeric.c, PopupPassword.c, PopupSel.c, PopupString. SubMenu.c
+//
+// 29 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 28 6/28/12 8:23p Arunsb
+// [TAG] EIP92407
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Shift + "+" key wont respond
+// [RootCause] Shift state not cleared
+// [Solution] Shift state cleared
+// [Files] numeric.c
+//
+// 27 5/29/12 2:41a Premkumara
+// Added missed EIP-88811 changes (TSEMouseIgnoreMouseActionHook()) in
+// numeric.c
+//
+// 26 5/28/12 11:52a Premkumara
+// [TAG] EIP89272
+// [Category] Improvement
+// [Description] Change softkbd layout for numeric control
+// [Files] CommonHelper.c, Mouse.c, Minisetup.h, C, Numeric.c
+//
+// 25 5/28/12 8:27a Arunsb
+// CallbackShowMessageBox commented in NumericDraw
+//
+// 24 5/24/12 7:30a Rajashakerg
+// [TAG] EIP88811
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] When pop-up window is invoked in setup and Click on ESC
+// icon or ESC/Right Click, it will respond as two times ESC is clicked
+// [RootCause] ESC functionality provided for left click on the ESC
+// sting navigation frame .
+// [Solution] Now providing the ESC sequence for left down and double
+// click
+// [Files] ezport.c, numeric.c, MessageBox.c
+//
+// 23 5/09/12 6:23p Premkumara
+// [TAG] EIP83703
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] TSE hangs while clicking on the "link training time out"
+// value [this is happening while trying the specified steps immediate
+// after bios flash
+// [RootCause] When invalid range input is provided for numeric control
+// ESC sequence is not provided if it is handled by the mouse.
+// [Solution] Provided the proper ESC sequence to the control such that
+// it close the Invalid Range Fail MsgBox when handled with the mouse and
+// key.
+// [Files] Numeric.c, CommonHelper.c
+//
+// $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/
+// - numeric.c (ver 22)
+//
+// $/Alaska/BIN/Modules/AMITSE2_0/AMITSE/
+// - CommonHelper.c (ver 88)
+//
+// 22 5/09/12 5:04p Premkumara
+// [TAG] EIP83703
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] TSE hangs while clicking on the "link training time out"
+// value [this is happening while trying the specified steps immediate
+// after bios flash
+// [RootCause] When invalid range input is provided for numeric control
+// ESC sequence is not provided if it is handled by the mouse.
+// [Solution] Provided the proper ESC sequence to the control such that
+// it close the Invalid Range Fail MsgBox when handled with the mouse and
+// key.
+// [Files] Numeric.c, CommonHelper.c
+//
+// 21 4/05/12 7:17a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 20 4/03/12 11:57p Rajashakerg
+// [TAG] EIP83703
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] TSE hangs while clicking on the "link training time out"
+// value [this is happening while trying the specified steps immediate
+// after bios flash]
+// [RootCause] Invalid message box handling with in the numeric is not
+// proper which is cauing the hang.
+// [Solution] Invalid message box is handled propely with mouse
+// selection.
+// [Files] numeric.c
+//
+// 19 12/08/11 12:28p Rajashakerg
+// Updated the file to overcome build errors when build for x32 mode.
+//
+// 18 11/21/11 11:23a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 17 11/21/11 12:23a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE.
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 16 11/20/11 8:01a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 15 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 14 10/21/11 2:54a Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Updating the file with fix for issue : maximum 8 byte
+// value shows negative number
+// [Files] numeric.c, numeric.h, string.c, string.h
+//
+// 13 10/10/11 1:32a Arunsb
+// [TAG] EIP66976
+// [Category] Improvement
+// [Description] Provision to change the Numeric string format
+// [Files] commonhelper.c, amitse.sdl and numeric.c
+//
+// 12 6/23/11 3:54p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description]
+// Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 11 6/20/11 12:22p Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Support for signed decimal value for
+// EFI_IFR_NUMERIC_OP.
+// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+//
+// 10 6/07/11 2:44p Madhans
+// [TAG] EIP61897
+// [Category] Improvement
+// [Description] To ignore the limit checking for the Suppressed
+// Controls in TSE
+// [Files] numeric.c
+//
+// 9 3/21/11 12:39a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 8 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 7 12/02/10 6:08p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 6 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 5 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 6:45a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 9/15/09 3:54p Madhans
+// // EIP: 26473 Fix To support uppercase Hex numbers
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 4/29/09 9:02p Madhans
+// Bug Fixes after unit Testing..
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: numeric.c
+//
+// Description: This file contains code to handle Label operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+NUMERIC_METHODS gNumeric =
+{
+ NumericCreate,
+ NumericDestroy,
+ NumericInitialize,
+ NumericDraw,
+ NumericHandleAction,
+ NumericSetCallback,
+ NumericSetFocus,
+ NumericSetPosition,
+ NumericSetDimensions,
+ NumericSetAttributes,
+ NumericGetControlHeight
+};
+BOOLEAN SingleClickActivation (VOID); //EIP-139608
+extern UINTN gInvalidRangeFailMsgBox;
+static BOOLEAN NumericIncDec = TRUE;
+BOOLEAN CheckKeyinHotKeysList(AMI_EFI_KEY_DATA Key);
+EFI_STATUS NumericHandleActionKeyMouse(NUMERIC_DATA *numeric, ACTION_DATA *Data);
+VOID NumSPrint(NUMERIC_DATA *numeric,NUMERIC_MIN_MAX_BASE Num);
+VOID UpdateNumericDisplayString (CHAR16 **, INT64, UINT8, UINT16, UINT16);
+VOID ClearNumericShiftState (AMI_EFI_KEY_DATA *);//EIP-83703
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericCreate
+//
+// Description: function used for Numeric control Create, which uses the Edit functions.
+//
+// Input: NUMERIC_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericCreate( NUMERIC_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(NUMERIC_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gEdit.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gNumeric;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericDestroy
+//
+// Description: function used to destroy Numeric controls, which uses the Edit functions.
+//
+// Input: NUMERIC_DATA **object, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericDestroy( NUMERIC_DATA *numeric, BOOLEAN freeMem )
+{
+ if(NULL == numeric )
+ return EFI_SUCCESS;
+
+ gEdit.Destroy( numeric, FALSE );
+
+ MemFreePointer( (VOID **)&numeric->Text );
+
+ if( freeMem )
+ MemFreePointer( (VOID **)&numeric );
+
+ return EFI_SUCCESS;
+}
+
+//EIP:60563 to support signed integers for NUMERIC opcode
+//EIP:60563 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckForRange
+//
+// Description: function used to check the range for the negative numbers and positive nubmers.
+//
+// Input: NUMERIC_DATA *numeric, NUMERIC_VALUE_BASE *Num
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckForRange(NUMERIC_DATA *numeric, NUMERIC_VALUE_BASE *Num)
+{
+ if(numeric->Base == 32)
+ {
+ if(numeric->ControlData.ControlDataWidth == 1)
+ {
+ if(((INT8)*Num < (INT8)numeric->MinValue) ||((INT8)*Num > (INT8)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 2)
+ {
+ if(((INT16)*Num < (INT16)numeric->MinValue) ||((INT16)*Num > (INT16)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 4)
+ {
+ if(((INT32)*Num < (INT32)numeric->MinValue) ||((INT32)*Num > (INT32)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 8)
+ {
+ if(((INT64)*Num < (INT64)numeric->MinValue) ||((INT64)*Num > (INT64)numeric->MaxValue))
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ {
+ if(((*Num) < numeric->MinValue) ||(*Num > numeric->MaxValue))
+ return TRUE;
+ else
+ return FALSE;
+ }
+return FALSE;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckForRangefromsetup
+//
+// Description: function used to check the range for the negative numbers and positive nubmers from setup.
+//
+// Input: NUMERIC_DATA *numeric, NUMERIC_VALUE_BASE *Num
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckForRangefromsetup(NUMERIC_DATA *numeric, NUMERIC_VALUE_BASE *Num)
+{
+ if(numeric->Base == 32)
+ {
+ if(numeric->ControlData.ControlDataWidth == 1)
+ {
+ if(((INT8)*Num >= (INT8)numeric->MinValue) &&((INT8)*Num <= (INT8)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 2)
+ {
+ if(((INT16)*Num >= (INT16)numeric->MinValue) &&((INT16)*Num <= (INT16)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 4)
+ {
+ if(((INT32)*Num >= (INT32)numeric->MinValue) &&((INT32)*Num <= (INT32)numeric->MaxValue))
+ return TRUE;
+ }
+ else if(numeric->ControlData.ControlDataWidth == 8)
+ {
+ if(((INT64)*Num >= (INT64)numeric->MinValue) &&((INT64)*Num <= (INT64)numeric->MaxValue))
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ {
+ if(((*Num) >= numeric->MinValue) &&(*Num <= numeric->MaxValue))
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ return FALSE;
+}
+//EIP:60563 END
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericInitialize
+//
+// Description: function used to Initialize the Numeric controls, which uses the Edit functions.
+//
+// Input: NUMERIC_DATA **object, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericInitialize( NUMERIC_DATA *numeric, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ NUMERIC_VALUE_BASE *Num;
+ VOID * ControlPtr = ((CONTROL_INFO *)data)->ControlPtr;
+ UINT16 Size = UefiGetWidth(ControlPtr);
+
+ // If the size 1 (it can hold upto 3 Decimal data +1 for null, is more then one the size * 3 is ok
+ numeric->TextWidth = (Size>1)?(3 * (UINT16)Size):4;
+
+ Status = gEdit.Initialize( numeric, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ //numeric->FGColor = EFI_YELLOW;
+ //numeric->BGColor = EFI_BACKGROUND_BLUE;
+ //numeric->TextWidth = numeric->TextAreaWidth;
+ numeric->Chr = 0x0;
+ numeric->MinValue = UefiGetMinValue(ControlPtr);//EIP:60563 to support signed integers for NUMERIC opcode
+ numeric->MaxValue = UefiGetMaxValue(ControlPtr);
+ numeric->Step = UefiGetStepValue(ControlPtr);
+ numeric->ControlData.ControlDataWidth = Size;
+ numeric->Base = UefiGetBaseValue(ControlPtr); // default base decimal number
+ numeric->Interval = (UINT8)(numeric->ControlData.ControlFlags.ControlRefresh);
+
+ Num = EfiLibAllocateZeroPool( (Size <sizeof(NUMERIC_MIN_MAX_BASE))? sizeof(NUMERIC_MIN_MAX_BASE):Size );
+
+ if ( Num != NULL )
+ {
+ VarGetValue( numeric->ControlData.ControlVariable,
+ UefiGetQuestionOffset(ControlPtr), Size, Num );
+
+ // check that value is in range
+ //EIP:60563 to support signed integers for NUMERIC opcode
+ if(CheckForRange( numeric, Num))
+ {
+ // try to use the default
+ if(numeric->ControlData.ControlDataWidth != 0)
+ {
+ VarGetDefaults( numeric->ControlData.ControlVariable,
+ UefiGetQuestionOffset(ControlPtr),
+ Size, Num );
+ }
+ }
+
+ if(*Num < numeric->MinValue)
+ *Num = numeric->MinValue;//revert to minimum value
+
+ if(*Num > numeric->MaxValue)
+ *Num =numeric->MaxValue;//revert to maximum value
+
+ numeric->Value = *Num;
+
+ MemFreePointer( (VOID **)&Num );
+ }
+
+ NumSPrint(numeric,numeric->Value);
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericDraw
+//
+// Description: function used to draw the numeric controls
+//
+// Input: NUMERIC_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericDraw(NUMERIC_DATA *numeric )
+{
+ NUMERIC_MIN_MAX_BASE *Num;
+ VOID * ControlPtr = numeric->ControlData.ControlPtr;
+
+ if(numeric->ControlActive == TRUE)
+ return gEdit.Draw( numeric );
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( numeric->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &numeric->ControlData ) )
+ {
+ case COND_NONE:
+ case COND_GRAYOUT:
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+
+ Num = EfiLibAllocateZeroPool((numeric->ControlData.ControlDataWidth<sizeof(NUMERIC_MIN_MAX_BASE))?sizeof(NUMERIC_MIN_MAX_BASE):numeric->ControlData.ControlDataWidth);
+
+ if ( Num != NULL )
+ {
+ VarGetValue( numeric->ControlData.ControlVariable,
+ UefiGetQuestionOffset(ControlPtr),
+ numeric->ControlData.ControlDataWidth, Num );
+
+ // check that value is in range
+ //EIP:60563 to support signed integers for NUMERIC opcode
+ if(CheckForRange(numeric, Num))
+ {
+ //Report Message box
+// CallbackShowMessageBox( (UINTN)gInvalidRangeFailMsgBox, MSGBOX_TYPE_OK );
+
+ // try to use the default
+ if(numeric->ControlData.ControlDataWidth != 0)
+ {
+ VarGetDefaults( numeric->ControlData.ControlVariable,
+ UefiGetQuestionOffset(ControlPtr),
+ numeric->ControlData.ControlDataWidth, Num );
+ }
+ if(*Num < numeric->MinValue)
+ *Num = numeric->MinValue;//revert to minimum value
+
+ if(*Num > numeric->MaxValue)
+ *Num =numeric->MaxValue;//revert to maximum value
+ }
+
+ numeric->Value = *Num;
+
+ MemFreePointer( (VOID **)&Num );
+ }
+
+ NumSPrint(numeric,numeric->Value);
+#if 0
+ /*To eliminate leading zeroes*/
+ Num = atoi( numeric->Text, numeric->Base );
+ SPrint( numeric->Text, numeric->TextAreaWidth, L"%d", Num);
+#endif
+ return gEdit.Draw( numeric );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericSetCallback
+//
+// Description: function used for setting Numeric control callback.
+//
+// Input: NUMERIC_DATA *numeric, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericSetCallback( NUMERIC_DATA *numeric, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gEdit.SetCallback( numeric, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericHandleAction
+//
+// Description: function used handle the Numeric controls
+//
+// Input: NUMERIC_DATA *numeric, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericHandleAction( NUMERIC_DATA *numeric, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if(numeric->ControlActive)
+ return Status;
+
+ if (numeric->Interval == 0)
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if ( --(numeric->Interval) == 0 )
+ {
+ // initialize the interval
+ numeric->Interval = (UINT8)(numeric->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(numeric->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ if (( Data->Input.Type == ACTION_TYPE_KEY )||(Data->Input.Type == ACTION_TYPE_MOUSE))
+ return NumericHandleActionKeyMouse(numeric, Data);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckforIncrementandDecreament
+//
+// Description: function used handle the Numeric controls Increment and Decreament operation
+//
+// Input: NUMERIC_MIN_MAX_BASE *Num, NUMERIC_DATA *numeric, CONTROL_ACTION Action,UINT8 *bValueChanged
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CheckforIncrementandDecreament(NUMERIC_MIN_MAX_BASE *Num, NUMERIC_DATA *numeric, CONTROL_ACTION Action,UINT8 *bValueChanged )
+{
+ if(ControlActionIncreament == Action)
+ {
+ if(AMI_BASE_INT_DEC == numeric->Base)
+ {
+ if(numeric->ControlData.ControlDataWidth == 1)
+ {
+ if ( ((INT8)*Num + (INT8)numeric->Step) <= (INT8)numeric->MaxValue )
+ {
+ *Num = *Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 2)
+ {
+ if ( ((INT16)*Num + (INT16)numeric->Step) <= (INT16)numeric->MaxValue )
+ {
+ *Num = *Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 4)
+ {
+ if ( ((INT32)*Num + (INT32)numeric->Step) <= (INT32)numeric->MaxValue )
+ {
+ *Num = *Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+ else
+ {
+ if ( ((INT64)*Num + (INT64)numeric->Step) <= (INT64)numeric->MaxValue )
+ {
+ *Num = *Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+
+ }
+ else
+ {
+ if ( *Num + numeric->Step <= numeric->MaxValue )
+ {
+ *Num = *Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+ }
+ }
+ }
+ else
+ {
+ if(AMI_BASE_INT_DEC == numeric->Base)
+ {
+ if(numeric->ControlData.ControlDataWidth == 1)
+ {
+ if ( ((INT8)*Num - (INT8)numeric->Step) >= (INT8)numeric->MinValue)
+ {
+ *Num = *Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 2)
+ {
+ if ( ((INT16)*Num - (INT16)numeric->Step) >= (INT16)numeric->MinValue )
+ {
+ *Num = *Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 4)
+ {
+ if ( ((INT32)*Num - (INT32)numeric->Step) >= (INT32)numeric->MinValue)
+ {
+ *Num = *Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+ else
+ {
+ if ( ((INT64)*Num - (INT64)numeric->Step) >= (INT64)numeric->MinValue )
+ {
+ *Num = *Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+
+ }
+ }
+
+
+ }
+ else
+ {
+ if( *Num - numeric->Step >= numeric->MinValue )
+ {
+ *Num = *Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ *bValueChanged = 1;
+ }
+ }
+
+ }
+
+
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericHandleActionKey
+//
+// Description: function used handle the Numeric control keys
+//
+// Input: NUMERIC_DATA *numeric, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericHandleActionKeyMouse(NUMERIC_DATA *numeric, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CHAR16 Chr;
+ BOOLEAN DataOk = FALSE;
+ NUMERIC_MIN_MAX_BASE Num;
+ ACTION_DATA TempData;
+ CONTROL_ACTION Action;
+ AMI_EFI_KEY_DATA key;
+ VOID * ControlPtr = numeric->ControlData.ControlPtr;
+ UINT8 u8ChkResult;
+
+ u8ChkResult = CheckControlCondition( &numeric->ControlData );
+
+ //Not to perform action for control when token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( IsGrayoutSelectable() && (COND_GRAYOUT == u8ChkResult) ) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if(numeric->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+ key = Data->Input.Data.AmiKey;
+ //Get mapping
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ Action = MapControlKeysHook(key);
+ }
+ else if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ //EIP-123727 check whether MouseTop is within the Height and Width of Neumeric Control or not
+ if ( (ControlActionSelect == Action) &&
+ ( (Data->Input.Data.MouseInfo.Top >= (UINT32)numeric->Top) &&
+ (Data->Input.Data.MouseInfo.Top < (UINT32)(numeric->Top+numeric->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)numeric->Left) &&
+ (Data->Input.Data.MouseInfo.Left < (UINT32)(numeric->Left+numeric->Width))
+ )//EIP-139608 when mouse is clicked on numeric control and action is ControlActionSelect
+ )
+ {
+ Action = ControlActionSelect;
+ if(!TSEMouseIgnoreMouseActionHook())
+ {
+ if (numeric->Base == AMI_BASE_INT_DEC || numeric->Base == AMI_BASE_DEC)
+ NumericSoftKbdInit();
+ else if (numeric->Base == AMI_BASE_HEX || numeric->Base == AMI_BASE_OCT)
+ {
+ PrintableKeysSoftKbdInit();
+ }
+ }
+ }
+ //EIP-123727 Close softkbd if activatd when clicked/touch outside numeric
+ else if ( ((!((Data->Input.Data.MouseInfo.Top >= (UINT32)numeric->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(numeric->Top+numeric->Height))&& (Data->Input.Data.MouseInfo.Left >= (UINT32)numeric->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(numeric->Left+numeric->Width)))))
+ &&(TSEMouseIgnoreMouseActionHook())&&(( ControlMouseActionLeftDown== Action)||(ControlMouseActionLeftUp == Action))
+ )
+ {
+ if (numeric->Base == AMI_BASE_INT_DEC || numeric->Base == AMI_BASE_DEC)
+ NumericSoftKbdExit();
+ else if (numeric->Base == AMI_BASE_HEX || numeric->Base == AMI_BASE_OCT)
+ {
+ PrintableKeysSoftKbdExit();
+ }
+
+ gAction.ClearAction( Data );
+ return EFI_UNSUPPORTED;
+ }
+
+ //If mouse clicked outside numeric control area
+ else if ( ((Data->Input.Data.MouseInfo.Top < (UINT32)numeric->Top) ||
+ (Data->Input.Data.MouseInfo.Top > (UINT32)(numeric->Top+numeric->Height)) ||
+ (Data->Input.Data.MouseInfo.Left < (UINT32)numeric->Left) ||
+ (Data->Input.Data.MouseInfo.Left > (UINT32)(numeric->Left+numeric->Width))
+ )&& ( (ControlActionSelect == Action) && SingleClickActivation() ) //EIP-139608
+ )
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ //If mouse clicked in numeric control area including multi-line string also don't consume mouse action in numeric side.
+ else if ((Data->Input.Data.MouseInfo.Top >= (UINT32)numeric->Top) &&
+ (Data->Input.Data.MouseInfo.Top < (UINT32)(numeric->Top+numeric->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)numeric->Left) &&
+ (Data->Input.Data.MouseInfo.Left < (UINT32)(numeric->Left+numeric->Width))&&
+ (numeric->ControlActive)
+ )
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ }
+
+ switch(Action)
+ {
+ case ControlActionSelect:
+ // check that the data is proper.
+ if((numeric->Text[0] ==0x0)||((numeric->Base == AMI_BASE_INT_DEC)&&(L'-' == numeric->Text[0])&&( EfiStrStr(numeric->Text+1, L"-"))))
+ NumSPrint(numeric,numeric->MinValue);
+
+ Num = (NUMERIC_MIN_MAX_BASE)atoi( numeric->Text, numeric->Base );
+
+ //EIP:60563 to support signed integers for NUMERIC opcode
+ if ( CheckForRangefromsetup( numeric, &Num) )
+ {
+ if ( ( numeric->Callback != NULL ) && ( numeric->Cookie != NULL ) )
+ {
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)numeric->Cookie;
+
+ callbackData->Variable = numeric->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ControlPtr);
+ callbackData->Length = UefiGetWidth(ControlPtr);
+ callbackData->Data = (VOID *)&Num;
+ // To support UEFI 2.1.C spec to Not to update the control when Callback fails.
+ UefiPreControlUpdate(&(numeric->ControlData));
+ numeric->Callback( numeric->Container,numeric, numeric->Cookie );
+ }
+
+ {
+ if(UefiIsInteractive(&numeric->ControlData))
+ {
+ VOID * Handle=numeric->ControlData.ControlHandle;
+ UINT16 Key = UefiGetControlKey(&(numeric->ControlData));
+ CONTROL_DATA *Control;
+
+ Status = CallFormCallBack(&(numeric->ControlData), Key, 0, AMI_CALLBACK_CONTROL_UPDATE);//EIP-53480: Updated the action to AMI_CALLBACK_CONTROL_UPDATE
+ Control = GetUpdatedControlData((CONTROL_DATA*)numeric,CONTROL_TYPE_NUMERIC,Handle,Key);
+
+ if(Control == NULL) // Control deleted ?
+ return EFI_SUCCESS;
+ if(Control != (CONTROL_DATA*)numeric)
+ numeric = (NUMERIC_DATA*)Control; //control Updated
+
+ }
+ }
+
+ Status = EFI_SUCCESS;
+ numeric->ControlActive = FALSE;
+ if(((Data->Input.Type == ACTION_TYPE_KEY))&&(TSEMouseIgnoreMouseActionHook() == TRUE)&& (TRUE == NumericIncDec))
+ {
+ if (numeric->Base == AMI_BASE_INT_DEC || numeric->Base == AMI_BASE_DEC)
+ NumericSoftKbdExit();
+ else if (numeric->Base == AMI_BASE_HEX || numeric->Base == AMI_BASE_OCT)
+ {
+ PrintableKeysSoftKbdExit();
+ }
+ }
+ else if(!NumericIncDec)
+ {
+ NumericIncDec = TRUE;
+ }
+ }
+ else
+ {
+ //Report Message box
+ CallbackShowMessageBox( (UINTN)gInvalidRangeFailMsgBox, MSGBOX_TYPE_OK );
+ Data->Input.Type = ACTION_TYPE_KEY;//EIP 83703 : Providing the input type as key such that it can be consumed in edithandleaction
+ Data->Input.Data.AmiKey.Key.ScanCode = SCAN_ESC;
+ Data->Input.Data.AmiKey.Key.UnicodeChar = L'\0';
+ ClearNumericShiftState(&(Data->Input.Data.AmiKey));//EIP-83703
+ //Data->Input.Data.AmiKey.KeyState.KeyShiftState = 0;//EIP 83703 : providing the key shiftstate
+ DataOk = TRUE;
+ }
+ break;
+
+ case ControlActionBackSpace:
+ DataOk = TRUE;
+ break;
+
+ case ControlActionIncreament:
+ case ControlActionDecreament:
+ if ( ( numeric->Step != 0 ) && ( ! numeric->ControlActive ))
+ {
+ UINT8 bValueChanged = 0;
+
+ Num = (NUMERIC_MIN_MAX_BASE)atoi( numeric->Text, numeric->Base );
+ if ( ControlActionIncreament == Action )
+ {
+ if(Num == numeric->MaxValue);
+ else
+ CheckforIncrementandDecreament(&Num,numeric,Action,&bValueChanged);
+ /* if ( Num + numeric->Step <= numeric->MaxValue )
+ {
+ Num = Num + (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ bValueChanged = 1;
+ }*/
+ }
+ else if ( ControlActionDecreament == Action )
+ {
+ if(Num == numeric->MinValue);
+ else
+ CheckforIncrementandDecreament(&Num,numeric,Action,&bValueChanged);
+ /* if( Num - numeric->Step >= numeric->MinValue )
+ {
+ Num = Num - (NUMERIC_MIN_MAX_BASE)numeric->Step;
+ bValueChanged = 1;
+ }*/
+ }
+
+ NumSPrint(numeric,Num);
+ NumericIncDec = FALSE;
+ if((bValueChanged)&& CheckForRangefromsetup( numeric, &Num))
+ {
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Data.AmiKey.Key.ScanCode = 0;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ ClearNumericShiftState(&(TempData.Input.Data.AmiKey));//EIP-92407 Clearing the Shiftstate before invoking numerichandleaction with CHAR_CARRIAGE_RETURN
+ gNumeric.HandleAction(numeric,&TempData);
+ }
+ // Data updated to variables Now draw it in the screen.
+ Status = gNumeric.Draw( numeric );
+ }
+ else if( ( numeric->ControlActive )&&(numeric->Base == AMI_BASE_INT_DEC))
+ {
+ DataOk = TRUE;
+ }
+
+ break;
+
+ case ControlActionAlpha:
+ case ControlActionNumeric:
+ Chr = key.Key.UnicodeChar;
+ switch ( numeric->Base )
+ {
+ case AMI_BASE_BIN:
+ if ( ( Chr == L'0' ) || ( Chr == L'1' ) )
+ DataOk = TRUE;
+ break;
+
+ case AMI_BASE_OCT:
+ if ( ( Chr <= L'7' ) && ( Chr >= L'0' ) )
+ DataOk = TRUE;
+ break;
+
+ case AMI_BASE_DEC:
+ case AMI_BASE_INT_DEC:
+ if ( ( Chr <= L'9' ) && ( Chr >= L'0' ) )
+ DataOk = TRUE;
+ break;
+
+ case AMI_BASE_HEX:
+ // EIP: 26473 To support uppercase Hex numbers
+ if ( ( ( Chr <= L'9' ) && ( Chr >= L'0' ) ) || ( ( Chr >= L'a' ) && ( Chr <= L'f' ) ) || ( ( Chr >= L'A' ) && ( Chr <= L'F' ) ))
+
+ DataOk = TRUE;
+ break;
+ }
+ break;
+
+ case ControlActionNextUp:
+ case ControlActionNextDown:
+ case ControlActionNextLeft:
+ case ControlActionNextRight:
+ if ( numeric->ControlActive )
+ {
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Data.AmiKey.Key.ScanCode = 0;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ ClearNumericShiftState(&(TempData.Input.Data.AmiKey));//EIP-92407 Clearing the Shiftstate before invoking numerichandleaction with CHAR_CARRIAGE_RETURN
+ gNumeric.HandleAction(numeric,&TempData);
+ }
+ break;
+
+ default:
+ if ( numeric->ControlActive )
+ {
+ MemCopy(&TempData,Data,sizeof(ACTION_DATA));
+ TempData.Input.Type = ACTION_TYPE_KEY;
+ TempData.Input.Data.AmiKey.Key.ScanCode = 0;
+ TempData.Input.Data.AmiKey.Key.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ ClearNumericShiftState(&(TempData.Input.Data.AmiKey));//EIP-83703
+ //TempData.Input.Data.AmiKey.KeyState.KeyShiftState = 0;
+ gNumeric.HandleAction(numeric,&TempData);
+ }
+ // Only Alpha Numeric chars are allowed. Other Special printable chars not allowed.
+ if(Data->Input.Data.AmiKey.Key.ScanCode)
+ DataOk = TRUE;
+ break;
+ }
+
+ if ( DataOk )
+ Status = gEdit.HandleAction( numeric, Data );
+
+ if((((!numeric->ControlActive)||(!IsMouseClickedonSoftkbd())) && (TSEMouseIgnoreMouseActionHook() == TRUE) )
+ && (((Data->Input.Type == ACTION_TYPE_KEY) && ((Action == ControlActionNextLeft) ||(Action == ControlActionNextRight) ||(Action == ControlActionNextUp) ||(Action == ControlActionNextDown) ||(Action == ControlActionPageUp) ||(Action == ControlActionPageDown) ||(Action == ControlActionAbort) ||(Action == ControlActionHome) ||(Action == ControlActionEnd) ||(CheckKeyinHotKeysList(key))) )
+ || ((Data->Input.Type == ACTION_TYPE_MOUSE)&&((!((Data->Input.Data.MouseInfo.Top >= (UINT32)numeric->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(numeric->Top+numeric->Height))&& (Data->Input.Data.MouseInfo.Left >= (UINT32)numeric->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(numeric->Left+numeric->Width))))||(Action == ControlActionAbort))))
+ )
+ {
+ if (numeric->Base == AMI_BASE_INT_DEC || numeric->Base == AMI_BASE_DEC)
+ NumericSoftKbdExit();
+ else if (numeric->Base == AMI_BASE_HEX || numeric->Base == AMI_BASE_OCT)
+ {
+ PrintableKeysSoftKbdExit();
+ }
+ }
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: NUMERIC_DATA *numeric, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericSetFocus( NUMERIC_DATA *numeric, BOOLEAN focus )
+{
+ UINT8 u8ChkResult;
+
+ if(focus != FALSE)
+ {
+ u8ChkResult = CheckControlCondition( &numeric->ControlData );
+
+ //Setting focus to control which has no control-condtion and token TSE_SETUP_GRAYOUT_SELECTABLE is enable to set focus for GrayoutIf control
+ if ( ((u8ChkResult != COND_NONE) && (u8ChkResult != COND_GRAYOUT)) ||
+ (!IsGrayoutSelectable() && (u8ChkResult == COND_GRAYOUT))
+ ){
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+
+ if( !(numeric->ControlFocus && focus) )
+ numeric->ControlFocus = focus;
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericSetPosition
+//
+// Description: Function to set position.
+//
+// Input: NUMERIC_DATA *numeric, UINT16 Left, UINT16 Top
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericSetPosition(NUMERIC_DATA *numeric, UINT16 Left, UINT16 Top )
+{
+ return gEdit.SetPosition( numeric, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericSetDimensions
+//
+// Description: Function to set dimensions.
+//
+// Input: NUMERIC_DATA *numeric, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericSetDimensions(NUMERIC_DATA *numeric, UINT16 Width, UINT16 Height )
+{
+ return gEdit.SetDimensions( numeric, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericSetAttributes
+//
+// Description: Function to set attributes.
+//
+// Input: NUMERIC_DATA *numeric, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericSetAttributes(NUMERIC_DATA *numeric, UINT8 FGColor, UINT8 BGColor )
+{
+ return gEdit.SetAttributes( numeric, FGColor, BGColor );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumericGetControlHeight
+//
+// Description: Function to get label height.
+//
+// Input: NUMERIC_DATA *numeric, UINT16 Width, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NumericGetControlHeight(NUMERIC_DATA *numeric, VOID* frame , UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ Width = (UINT16)(((EDIT_DATA *)numeric)->TextMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gControlLeftPad));
+ text = HiiGetString( numeric->ControlData.ControlHandle, UefiGetPromptField((VOID *)numeric->ControlData.ControlPtr));
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ newText = StringWrapText( text, Width, height );
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height =1;
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: NumSPrint
+//
+// Description: Function to print nums.
+//
+// Input: NUMERIC_DATA *numeric,NUMERIC_MIN_MAX_BASE Num
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID NumSPrint(NUMERIC_DATA *numeric,NUMERIC_MIN_MAX_BASE Num)
+{
+ switch(numeric->Base)
+ {
+ case AMI_BASE_HEX:
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%lx", Num );
+ break;
+ case AMI_BASE_INT_DEC:
+ if(numeric->ControlData.ControlDataWidth == 1)
+ {
+ if((INT8)Num < 0)
+ {
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%d", (INT8)Num );
+ break;
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 2)
+ {
+ if((INT16)Num < 0)
+ {
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%d", (INT16)Num );
+ break;
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 4)
+ {
+ if((INT32)Num < 0)
+ {
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%d", (INT32)Num );
+ break;
+ }
+ }
+ else if(numeric->ControlData.ControlDataWidth == 8)
+ {
+ if((INT64)Num < 0)
+ {
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%ld", (INT64)Num );
+ break;
+ }
+ }
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%d", Num );
+ break;
+ case AMI_BASE_DEC:
+ default:
+ SPrint( numeric->Text, numeric->TextWidth*sizeof(CHAR16), L"%ld", Num );
+ break;
+ }
+ UpdateNumericDisplayString (&(numeric->Text), Num, numeric->Base, numeric->ControlData.ControlDataWidth, numeric->TextWidth*sizeof(CHAR16)); //EIP66976 Provision to change the Numeric string format
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/numeric.h b/EDK/MiniSetup/TseLite/numeric.h
new file mode 100644
index 0000000..ccee7d8
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/numeric.h
@@ -0,0 +1,224 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/numeric.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 12 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/numeric.h $
+//
+// 12 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 11 4/05/12 7:18a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 10 11/20/11 8:03a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 9 10/21/11 2:55a Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Updating the file with fix for issue : maximum 8 byte
+// value shows negative number
+// [Files] numeric.c, numeric.h, string.c, string.h
+//
+// 8 6/20/11 12:23p Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Support for signed decimal value for
+// EFI_IFR_NUMERIC_OP.
+// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+//
+// 7 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: numeric.h
+//
+// Description: Header file for numeric control
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+#ifndef _NUMERIC_H_
+#define _NUMERIC_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+#include "action.h"
+#include "MessageBox.h"
+
+#define AMI_BASE_BIN 2
+#define AMI_BASE_OCT 8
+#define AMI_BASE_DEC 10
+#define AMI_BASE_HEX 16
+#define AMI_BASE_INT_DEC 32
+
+#define NUMERIC_MIN_MAX_BASE UINT64 //EIP:60563 to support signed integers for NUMERIC opcode
+#define NUMERIC_VALUE_BASE UINT64
+#define NUMERIC_MEMBER_VARIABLES \
+ UINT8 Base; \
+ NUMERIC_MIN_MAX_BASE MinValue; \
+ NUMERIC_MIN_MAX_BASE MaxValue; \
+ NUMERIC_VALUE_BASE Value; \
+ NUMERIC_MIN_MAX_BASE Step; \
+ UINT8 Interval;
+
+
+typedef struct _NUMERIC_METHODS NUMERIC_METHODS;
+
+typedef struct _NUMERIC_DATA
+{
+ NUMERIC_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ EDIT_MEMBER_VARIABLES
+ NUMERIC_MEMBER_VARIABLES
+}
+NUMERIC_DATA;
+#define NUMERIC_METHOD_FUNCTIONS
+
+
+struct _NUMERIC_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ EDIT_METHOD_FUNCTIONS
+ NUMERIC_METHOD_FUNCTIONS
+};
+
+extern NUMERIC_METHODS gNumeric;
+
+// Object Methods
+EFI_STATUS NumericCreate( VOID **object );
+EFI_STATUS NumericDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS NumericInitialize( VOID *object, VOID *data );
+EFI_STATUS NumericDraw( VOID *object );
+EFI_STATUS NumericHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS NumericSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS NumericSetFocus( VOID *object, BOOLEAN focus);
+EFI_STATUS NumericSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS NumericSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS NumericSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS NumericGetControlHeight(VOID *object, VOID *frame, UINT16 *height);
+#endif /* _NUMERIC_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/object.c b/EDK/MiniSetup/TseLite/object.c
new file mode 100644
index 0000000..24461eb
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/object.c
@@ -0,0 +1,211 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/object.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 4 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/object.c $
+//
+// 4 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 6 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Object.c
+//
+// Description: This file contains code to handle Objects
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+OBJECT_METHODS gObject =
+{
+ ObjectCreate,
+ ObjectDestroy,
+ ObjectInitialize,
+ ObjectDraw,
+ ObjectHandleAction,
+ ObjectSetCallback
+};
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectCreate
+//
+// Description: function to create an object
+//
+// Input: OBJECT_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectCreate( OBJECT_DATA **object )
+{
+ if ( *object == NULL )
+ *object = EfiLibAllocateZeroPool( sizeof(OBJECT_DATA) );
+
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ (*object)->Methods = &gObject;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectDestroy
+//
+// Description: function to Destroy an object
+//
+// Input: OBJECT_DATA **object, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectDestroy( OBJECT_DATA *object, BOOLEAN freeMem )
+{
+ if ( freeMem )
+ MemFreePointer( (VOID **)&object );
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectInitialize
+//
+// Description: Function to initialize an object
+//
+// Input: OBJECT_DATA *object, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectInitialize( OBJECT_DATA *object, VOID *data )
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectDraw
+//
+// Description: Function to draw an object
+//
+// Input: OBJECT_DATA *object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectDraw( OBJECT_DATA *object )
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectHandleAction
+//
+// Description: Function to handle object action
+//
+// Input: OBJECT_DATA *object, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectHandleAction( OBJECT_DATA *object, ACTION_DATA *Data )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ObjectSetCallback
+//
+// Description: Function to set object callback
+//
+// Input: OBJECT_DATA *object, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ObjectSetCallback( OBJECT_DATA *object, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ object->Callback = callback;
+ object->Container = container,
+ object->Cookie = cookie;
+
+ return EFI_SUCCESS;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/object.h b/EDK/MiniSetup/TseLite/object.h
new file mode 100644
index 0000000..7045bfd
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/object.h
@@ -0,0 +1,144 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/object.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 5 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/object.h $
+//
+// 5 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 6/24/09 6:11p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Object.h
+//
+// Description: Header file for code to handle Objects
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _OBJECT_H_
+#define _OBJECT_H_
+
+//#include "Tiano.h"
+//#include "EfiDriverLib.h"
+#include "Minisetup.h"
+#include "action.h"
+#include "callback.h"
+
+typedef VOID (*OBJECT_CALLBACK) ( VOID *container, VOID *object, VOID *cookie );
+
+#define OBJECT_MEMBER_VARIABLES \
+ OBJECT_CALLBACK Callback; \
+ VOID *Container; \
+ VOID *Cookie;
+
+typedef struct _OBJECT_METHODS OBJECT_METHODS;
+
+typedef struct _OBJECT_DATA
+{
+ OBJECT_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+}
+OBJECT_DATA;
+
+typedef EFI_STATUS (*OBJECT_METHOD_CREATE) ( VOID **object );
+typedef EFI_STATUS (*OBJECT_METHOD_DESTROY) ( VOID *object, BOOLEAN freeMem );
+typedef EFI_STATUS (*OBJECT_METHOD_INITIALIZE) ( VOID *object, VOID *data );
+typedef EFI_STATUS (*OBJECT_METHOD_DRAW) ( VOID *object );
+typedef EFI_STATUS (*OBJECT_METHOD_HANDLE_ACTION) ( VOID *object, ACTION_DATA *Data );
+typedef EFI_STATUS (*OBJECT_METHOD_SET_CALLBACK) ( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+#define OBJECT_METHOD_FUNCTIONS \
+ OBJECT_METHOD_CREATE Create; \
+ OBJECT_METHOD_DESTROY Destroy; \
+ OBJECT_METHOD_INITIALIZE Initialize; \
+ OBJECT_METHOD_DRAW Draw; \
+ OBJECT_METHOD_HANDLE_ACTION HandleAction; \
+ OBJECT_METHOD_SET_CALLBACK SetCallback;
+
+struct _OBJECT_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+};
+
+extern OBJECT_METHODS gObject;
+
+EFI_STATUS ObjectCreate( VOID **object );
+EFI_STATUS ObjectDestroy( VOID *object, BOOLEAN freeMem );
+
+EFI_STATUS ObjectInitialize( VOID *object, VOID *data );
+EFI_STATUS ObjectDraw( VOID *object );
+EFI_STATUS ObjectHandleAction( VOID *object, ACTION_DATA *Data );
+EFI_STATUS ObjectSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+#endif /* _OBJECT_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ordlistbox.c b/EDK/MiniSetup/TseLite/ordlistbox.c
new file mode 100644
index 0000000..4d388e1
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ordlistbox.c
@@ -0,0 +1,1080 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ordlistbox.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 22 $
+//
+// $Date: 5/01/14 3:44p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ordlistbox.c $
+//
+// 22 5/01/14 3:44p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 21 7/03/13 10:29a Premkumara
+// [TAG] EIP127000
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] After suppressing any of items in orderlist, the listbox is
+// showing blank space. If items are changing using +/- then Empty list
+// item appear
+// [RootCause] Since items are suppressing in listbox and the
+// listbox->ItemCount, listbox->Sel, listbox options value and ptrtoken
+// value are not updated properly
+// [Solution] Handling orderedlistbox items and itemcount properly after
+// items are suppressed
+// [Files] OrdListBox.c
+// -$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ordlistbox.c (ver
+// 20)
+//
+// 20 7/02/13 10:19a Premkumara
+// [TAG] EIP127000
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] After suppressing any of items in orderlist, the listbox is
+// showing blank space. If items are changing using +/- then Empty list
+// item appear
+// [RootCause] Since items are suppressing in listbox and the
+// listbox->ItemCount, listbox->Sel, listbox options value and ptrtoken
+// value are not updated properly
+// [Solution] Handling orderedlistbox items and itemcount properly after
+// items are suppressed
+// [Files] OrdListBox.c
+//
+// 19 10/18/12 8:58a Rajashakerg
+// [TAG] EIP103568
+// [Category] Improvement
+// [Description] Help string support for ordered list
+// [Files] Uefi21Wapper.c, ordlistbox.c
+//
+// 18 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 17 5/28/12 12:35p Premkumara
+// [TAG] EIP67049 & 90224
+// [Category] New Feature
+// [Description] Support mouse drag operation in frame and list box
+// [Files] CommonHelper.c, Frame.c, ListBox.c, Minisetupext
+//
+// 16 5/09/12 1:37p Arunsb
+// [TAG] EIP86885
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] ISCSI attempt order is not changing on setup
+// [RootCause] Orderlist maxcontainers value and ordered list size not
+// handled properly
+// [Solution] Orderlist maxcontainers value is 0xff, but TSE changed the
+// cache value for only the added attempts(dynamic orderlist creation)
+// remaining buffer left as is, Now the remaining buffers made as 0.
+// [Files] HiiCallback.c and ordlistbox.
+//
+// 15 2/03/12 4:45a Rajashakerg
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] _OrdListGetSelection logic changed to support the
+// special controls(Boot Order).
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c and TseUefihiil.h
+//
+// 14 2/02/12 2:50a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 13 2/01/12 1:49a Arunsb
+// [TAG] EIP74968
+// [Category] Improvement
+// [Description] Support for mouse drag and drop to rearrange the items
+// in the Orderlist.
+// [Files] Ordlistbox.c, commonoem.c and commonoem.h
+//
+// 12 12/10/11 4:45a Arunsb
+// Header corrected
+//
+// 11 12/01/11 7:42a Arunsb
+// [TAG] EIP70966
+// UefiGetValidOptionSize fnc declaration added for avoiding build error
+// in 2.0.
+//
+// 10 11/28/11 4:59a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 9 11/21/11 11:18a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 8 11/21/11 8:54a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 7 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 6 11/03/11 4:29a Premkumara
+// [TAG] EIP70966
+// [Category] Improvement
+// [Description] Hii orderlist item can't update priority from value in
+// Setup menu for both enable and disable TSE_MULTILINE_CONTROLS token
+// [Files] Ordlistbox.c, ordlistbox.h, TseUefiHii.h, Uefi21Wrapper.c
+//
+// 5 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 2/17/10 7:03p Madhans
+// To suppor readonly control
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:12p Madhans
+// TSE Lite Special control support
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: orderlistbox.c
+//
+// Description: This file contains code to handle ordered list box controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+VOID _PopupSelGetSelection( POPUPSEL_DATA *popupSel );
+EFI_STATUS _OrdListMultiLIneDraw(ORD_LISTBOX_DATA *OrdList);
+UINT16 gOrderlistcount;
+extern BOOLEAN lButtonOnListBoxScroll;//EIP-67049
+
+ORD_LISTBOX_METHODS gOrdListBox =
+{
+ OrdListBoxCreate,
+ OrdListBoxDestroy,
+ OrdListBoxInitialize,
+ OrdListBoxDraw,
+ OrdListBoxHandleAction,
+ OrdListBoxSetCallback,
+ OrdListBoxSetFocus,
+ OrdListBoxSetPosition,
+ OrdListBoxSetDimensions,
+ OrdListBoxSetAttributes,
+ OrdListGetControlHeight
+};
+VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData);
+BOOLEAN FirstDownEvent = FALSE; //EIP74968 Change Order in Orderlist using Mouse drag
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxCreate
+//
+// Description: function to Create a Order List Box, which uses the PopupSel Fucntions
+//
+// Input: ORD_LISTBOX_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxCreate( ORD_LISTBOX_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(ORD_LISTBOX_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gPopupSel.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gOrdListBox;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxDestroy
+//
+// Description: function to Destroy a Order List Box, which uses the PopupSel Fucntions
+//
+// Input: ORD_LISTBOX_DATA *listbox, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxDestroy( ORD_LISTBOX_DATA *listbox, BOOLEAN freeMem )
+{
+ if(NULL == listbox)
+ return EFI_SUCCESS;
+
+ gPopupSel.Destroy( listbox, FALSE );
+
+ if( freeMem )
+ {
+ MemFreePointer( (VOID **)&(listbox->PtrTokens) );
+ MemFreePointer( (VOID **)&listbox );
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxDestroy
+//
+// Description: function to initialize a Order List Box, which uses the PopupSel Fucntions
+//
+// Input: ORD_LISTBOX_DATA *listbox, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxInitialize( ORD_LISTBOX_DATA *listbox, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gPopupSel.Initialize( listbox, data );
+// _OrdListGetSelection(listbox); // make sure data is correct.
+ listbox->ControlData.ControlHelp = UefiGetHelpField(listbox->ControlData.ControlPtr);//EIP:103568 Updated the Help field for order list control.
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxDraw
+//
+// Description: function to draw a ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxDraw( ORD_LISTBOX_DATA *listbox )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ Status = _OrdListMultiLIneDraw(listbox); //EIP-70966 Draw OrderListBox
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UpdateOrderlistcount
+//
+// Description: Function to update the orderlist count.
+//
+// Input: UINT16 ItemCount
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _UpdateOrderlistcount(UINT16 ItemCount)
+{
+ gOrderlistcount = ItemCount;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DoOrdListCallBack
+//
+// Description: Call back function of ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoOrdListCallBack(ORD_LISTBOX_DATA *listbox)
+{
+ UINT8 i=0;
+ VOID *Data = (VOID *)NULL; //EIP70966
+
+ if ( listbox->Cookie != NULL )
+ {
+ VOID *ifrData = listbox->ControlData.ControlPtr;
+ CALLBACK_VARIABLE *callbackData = (CALLBACK_VARIABLE *)listbox->Cookie;
+
+ callbackData->Variable = listbox->ControlData.ControlVariable;
+ callbackData->Offset = UefiGetQuestionOffset(ifrData);
+ callbackData->Length = UefiGetMaxEntries(ifrData);
+
+ if( (listbox->ControlData.ControlVariable == VARIABLE_ID_BOOT_ORDER) ||
+ (listbox->ControlData.ControlVariable == VARIABLE_ID_BBS_ORDER) )
+ {
+ // Special Handling for Boot Order variable change
+ Data = (UINT8*)EfiLibAllocateZeroPool( listbox->ItemCount * sizeof(UINT16) );
+ for(i=0;i<listbox->ItemCount;i++)
+ ((UINT16*)Data)[i] = (UINT16)(listbox->PtrTokens[i].Value);
+ callbackData->Length = listbox->ItemCount * sizeof(UINT16);
+ }
+ else
+ {
+ //EIP70966_START
+ UINT32 sizeOfData = 0;
+ UINTN type = 0;
+ UINT8 *tempData = (UINT8 *)NULL;
+
+ //To find the Type and Size of OrderList based on EFI_IFR_TYPE
+ UefiGetValidOptionType(&listbox->ControlData, &type, &sizeOfData);
+
+ Data = (UINT8*)EfiLibAllocateZeroPool( listbox->ItemCount * sizeOfData);
+ tempData = Data;
+
+ for(i=0;i<listbox->ItemCount;i++)
+ {
+ //Data[i] = (UINT8)(listbox->PtrTokens[i].Value);
+ //Copy Data based on EFI_IFR_TYPE and Size
+ MemCopy(tempData, &listbox->PtrTokens[i].Value, sizeOfData);
+ tempData = (UINT8 *)tempData + sizeOfData;
+ }
+ //Fix the length of Data based on EFI_IFR_TYPE
+ callbackData->Length = UefiGetMaxEntries(ifrData) * sizeOfData;
+ if (callbackData->Length > (listbox->ItemCount * sizeOfData)) //EIP86885, Filling all the dynamic forming datas with 0's
+ {
+ Data = MemReallocateZeroPool (Data, (listbox->ItemCount * sizeOfData), callbackData->Length);
+ }
+ //EIP70966_END
+ }
+
+ callbackData->Data = Data; //must send actual array of UINT8 values
+ }
+ _UpdateOrderlistcount(listbox->ItemCount); //Initializing gOrderlistcount
+ UefiPreControlUpdate(&(listbox->ControlData));
+ listbox->Callback( listbox->Container, listbox, listbox->Cookie );
+
+ //For interactive orderedlist control invoke the callback functions
+ if(UefiIsInteractive(&listbox->ControlData)){
+ EFI_STATUS Status = EFI_SUCCESS;
+ Status = CallFormCallBack(&listbox->ControlData, UefiGetControlKey(&listbox->ControlData), FALSE, AMI_CALLBACK_CONTROL_UPDATE);
+ }
+ //_OrdListGetSelection(listbox);
+
+ if(Data!=NULL)
+ MemFreePointer((VOID **)&Data);
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxHandleAction
+//
+// Description: Function to handle the ordered List Box actions
+//
+// Input: ORD_LISTBOX_DATA *listbox, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxHandleAction( ORD_LISTBOX_DATA *listbox, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 i=0;
+ CONTROL_ACTION Action;
+
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ // List box is active don't refresh
+ if ( listbox->ListBoxCtrl != NULL )
+ return Status;
+
+ if (listbox->Interval == 0)
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if ( --(listbox->Interval) == 0 )
+ {
+ // initialize the interval
+ listbox->Interval = (UINT8)(listbox->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(listbox->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ if(listbox->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+ if(!listbox->ControlFocus)
+ return Status;
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE) //EIP74968 Change Order in Orderlist using Mouse drag
+ {
+ if((listbox->Top <= (UINT16)Data->Input.Data.MouseInfo.Top ) &&
+ ((listbox->Top + listbox->Height) > (UINT16)Data->Input.Data.MouseInfo.Top )&&
+ (listbox->Left <= Data->Input.Data.MouseInfo.Left) &&
+ ((listbox->Left + listbox->Width) > (UINT16)Data->Input.Data.MouseInfo.Left) )
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ Action = MapControlKeysHook(Data->Input.Data.AmiKey);
+
+ if ( listbox->ListBoxCtrl != NULL )
+ {
+ Status = gListBox.HandleAction(listbox->ListBoxCtrl,Data);
+ // special case, we need ot get the Sel from the listbox and put it into ordlistbox
+ listbox->Sel = listbox->ListBoxCtrl->Sel;
+ if ( listbox->ListBoxEnd )
+ {
+ gListBox.Destroy(listbox->ListBoxCtrl,TRUE);
+ listbox->ListBoxCtrl = NULL;
+ listbox->ListBoxEnd = FALSE;
+ listbox->ControlActive = FALSE;
+ DoOrdListCallBack(listbox);
+ }
+ }
+ else
+ {
+ if(ControlActionSelect == Action)
+ {
+ if ( gListBox.Create( &(listbox->ListBoxCtrl) ) == EFI_SUCCESS )
+ {
+ UINT16 TempLength=0;
+
+ listbox->ControlActive = TRUE;
+ gListBox.Initialize( listbox->ListBoxCtrl, &(listbox->ControlData) );
+ //The next for loop should not be necessary after the callback
+ //updates NVRAM properly
+ //EIP70966
+ //if(TseLiteIsSpecialOptionList((CONTROL_DATA *)listbox) == TRUE) // EIP70966 -
+ {
+ for( i = 0 ; i < listbox->ItemCount; i++ )
+ {
+ listbox->ListBoxCtrl->PtrTokens[i] = listbox->PtrTokens[i].Option;
+ TempLength = (UINT16)HiiMyGetStringLength( listbox->ListBoxCtrl->ListHandle, listbox->ListBoxCtrl->PtrTokens[i] );
+ TempLength+=5; // to included barders
+ if ( TempLength > listbox->ListBoxCtrl->Width )
+ listbox->ListBoxCtrl->Width = TempLength;
+
+ }
+ }
+ if ( listbox->Sel > (listbox->ItemCount-1) ) //EIP-127000 If selected item is suppresed then reset the focus to first item
+ listbox->ListBoxCtrl->Sel = listbox->Sel = 0;
+ else
+ listbox->ListBoxCtrl->Sel = listbox->Sel;
+ gListBox.SetCallback(listbox->ListBoxCtrl, listbox, _OrdListBoxCallback, NULL);
+ gListBox.Draw( listbox->ListBoxCtrl );
+ }
+
+ Status = EFI_SUCCESS;
+ }
+ }
+
+ if(Data->Input.Type == ACTION_TYPE_MOUSE && !lButtonOnListBoxScroll)//EIP74968 Change Order in Orderlist using Mouse drag && EIP-67049
+ {
+ if ( listbox->ListBoxCtrl != NULL )
+ {
+ Action = MapControlMouseActionHook(&Data->Input.Data.MouseInfo);
+ // Check if the Mouse action is on top of list box.
+ if(
+ (Data->Input.Data.MouseInfo.Top >= (UINT32)(listbox->ListBoxCtrl->Top - 1)) &&
+ (ControlActionSelect != Action) &&
+ (Data->Input.Data.MouseInfo.Top <= (UINT32)(listbox->ListBoxCtrl->Top + listbox->ListBoxCtrl->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= listbox->ListBoxCtrl->Left) &&
+ (Data->Input.Data.MouseInfo.Left <= (UINT32)(listbox->ListBoxCtrl->Left + listbox->ListBoxCtrl->Width - 1))
+ )
+ {
+ //Note MOUSE_LEFT_DOWN position
+ if(Action==ControlMouseActionLeftDown)
+ {
+ if(FirstDownEvent == FALSE )
+ {
+ if(Data->Input.Data.MouseInfo.Top == (UINT32)(listbox->ListBoxCtrl->Top + listbox->Sel - listbox->ListBoxCtrl->FirstVisibleSel + 1))
+ FirstDownEvent = TRUE;
+ }
+ else
+ {
+ if(Data->Input.Data.MouseInfo.Top > (UINT32)(listbox->ListBoxCtrl->Top + listbox->Sel - listbox->ListBoxCtrl->FirstVisibleSel + 1))
+ Action = ControlActionDecreament;
+
+ if(Data->Input.Data.MouseInfo.Top < (UINT32)(listbox->ListBoxCtrl->Top + listbox->Sel - listbox->ListBoxCtrl->FirstVisibleSel + 1))
+ Action = ControlActionIncreament;
+ }
+ }
+ else
+ {
+ FirstDownEvent = FALSE;
+ }
+ }
+ }
+ }
+ switch ( Action )
+ {
+ case ControlActionDecreament:
+ // eip : B12674 Don't allow +/- until it is selected.
+ if ( listbox->ListBoxCtrl != NULL )
+ {
+ if(!EFI_ERROR(_OrdListBoxShift(listbox, FALSE)))
+ {
+ if ( (INTN)(listbox->Sel) < listbox->ItemCount - 1 )
+ listbox->Sel++;
+ }
+ Status = EFI_SUCCESS;
+ }
+ break;
+
+ case ControlActionIncreament:
+ // eip : B12674 Don't allow +/- until it is selected.
+ if ( listbox->ListBoxCtrl != NULL )
+ {
+ if(!EFI_ERROR(_OrdListBoxShift(listbox, TRUE)))
+ {
+ if ( listbox->Sel > 0 )
+ listbox->Sel--;
+ }
+ Status = EFI_SUCCESS;
+ }
+ break;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxSetCallback
+//
+// Description: Function to set callback for ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxSetCallback( ORD_LISTBOX_DATA *listbox, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gPopupSel.SetCallback( listbox, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxSetFocus
+//
+// Description: Function to set focus for ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox, BOOLEAN focus
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxSetFocus(ORD_LISTBOX_DATA *listbox, BOOLEAN focus)
+{
+ return gPopupSel.SetFocus(listbox,focus);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxSetPosition
+//
+// Description: Function to set position for ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox, UINT16 Left, UINT16 Top
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxSetPosition(ORD_LISTBOX_DATA *listbox, UINT16 Left, UINT16 Top )
+{
+ return gPopupSel.SetPosition( listbox, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxSetDimensions
+//
+// Description: Function to set dimension for ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxSetDimensions(ORD_LISTBOX_DATA *listbox, UINT16 Width, UINT16 Height )
+{
+ return gPopupSel.SetDimensions( listbox, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListBoxSetAttributes
+//
+// Description: Function to set atributes for ordered List Box
+//
+// Input: ORD_LISTBOX_DATA *listbox, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListBoxSetAttributes(ORD_LISTBOX_DATA *listbox, UINT8 FGColor, UINT8 BGColor )
+{
+ return gPopupSel.SetAttributes( listbox, FGColor, BGColor );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _OrdListBoxCallback
+//
+// Description: Ordered List Box callback function
+//
+// Input: ORD_LISTBOX_DATA *container, CONTROL_DATA *listbox, VOID *cookie
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _OrdListBoxCallback( ORD_LISTBOX_DATA *container, CONTROL_DATA *listbox, VOID *cookie )
+{
+ container->ListBoxEnd = TRUE;
+ if ( cookie != NULL )
+ container->Sel = *((UINT16*)cookie);
+}
+
+/*
+ Please note that the following function is non-rotatary or non-circular
+ This is an internal function to ordered list control,so we need to:
+ 1-add underscore to the name
+ 2-do not put it in control_methods
+ This function is not used by any one else outside the control.
+*/
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _OrdListBoxShift
+//
+// Description: Function used in OrdListBoxHandleAction to handle actions
+//
+// Input: ORD_LISTBOX_DATA *listbox, UINT8 bShiftUp
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _OrdListBoxShift(ORD_LISTBOX_DATA *listbox, UINT8 bShiftUp)
+{
+ PTRTOKENS unSwap;
+ UINT8 i=0;
+
+ if(TRUE == bShiftUp)
+ {
+ //move up
+ if ( listbox->Sel > 0 )
+ {
+ unSwap = listbox->PtrTokens[listbox->Sel];
+ listbox->PtrTokens[listbox->Sel] = listbox->PtrTokens[listbox->Sel-1];
+ listbox->PtrTokens[listbox->Sel-1] = unSwap;
+ if( listbox->ListBoxCtrl !=NULL)
+ {
+ // update string tokens into listbox area
+ for( i = 0 ; i < listbox->ItemCount; i++ )
+ listbox->ListBoxCtrl->PtrTokens[i] = listbox->PtrTokens[i].Option;
+ listbox->ListBoxCtrl->Sel--;
+ gPopupSel.Draw(listbox);
+ }
+ return EFI_SUCCESS;
+ }
+ }
+ else
+ {
+ //move dn
+ if ( (INTN)(listbox->Sel) < listbox->ItemCount - 1 )
+ {
+ unSwap = listbox->PtrTokens[listbox->Sel];
+ listbox->PtrTokens[listbox->Sel] = listbox->PtrTokens[listbox->Sel+1];
+ listbox->PtrTokens[listbox->Sel+1] = unSwap;
+ if( listbox->ListBoxCtrl !=NULL)
+ { // update string tokens into listbox area
+ for( i = 0 ; i < listbox->ItemCount; i++ )
+ listbox->ListBoxCtrl->PtrTokens[i] = listbox->PtrTokens[i].Option;
+ listbox->ListBoxCtrl->Sel++;
+ gPopupSel.Draw(listbox);
+ }
+
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: OrdListGetControlHeight
+//
+// Description: Function used get the hight of control
+//
+// Input: ORD_LISTBOX_DATA *OrdList, VOID* frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS OrdListGetControlHeight( ORD_LISTBOX_DATA *OrdList, VOID* frame, UINT16 *height )
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ Width = (UINT16)(OrdList->LabelMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gLabelLeftMargin));
+
+ text = HiiGetString( OrdList->ControlData.ControlHandle, OrdList->Title );
+ if ( text == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ newText = StringWrapText( text, Width, height );
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+
+ *height = (*height < OrdList->ItemCount)? OrdList->ItemCount : *height ;
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _OrdListMultiLIneDraw
+//
+// Description: Function used to draw teh Ordered list box
+//
+// Input: ORD_LISTBOX_DATA *OrdList
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _OrdListMultiLIneDraw(ORD_LISTBOX_DATA *OrdList)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorNSel = OrdList->NSelFGColor;
+ UINT8 ColorLabel = (OrdList->ControlFocus) ? OrdList->LabelFGColor : OrdList->NSelLabelFGColor ;
+ CHAR16 *text1, *text;
+ UINTN i=0,Len, oldSize = 0;
+ BOOLEAN MultilineSupport = FALSE;
+ UINT16 *OptionList=NULL, Index = 0;
+ UINT64 *ValueList=NULL;
+
+ //Draw the list box alone if the control is active
+ if( OrdList->ListBoxCtrl != NULL)
+ {
+ gListBox.Draw( OrdList->ListBoxCtrl );
+ }
+ else
+ {
+ // check conditional
+ //EIP 75486 Support grayout condition for readonly controls
+ //if( OrdList->ControlData.ControlConditionalPtr != 0x0)
+ //{
+ switch( CheckControlCondition( &OrdList->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(TseLiteIsSpecialOptionList((CONTROL_DATA *)OrdList) != TRUE) //EIP-127000 Fix options and option count in listbox if any item is suppressed
+ {
+ oldSize = OrdList->ItemCount;
+
+ Status = UefiGetOneOfOptions(&OrdList->ControlData,&OrdList->PopupSelHandle,
+ &OptionList, &ValueList, &OrdList->ItemCount,NULL,NULL);
+
+ if (OrdList->ItemCount!=oldSize)
+ {
+ OrdList->PtrTokens = MemReallocateZeroPool(OrdList->PtrTokens, oldSize*sizeof(PTRTOKENS), OrdList->ItemCount * sizeof(PTRTOKENS));
+ if (NULL == OrdList->PtrTokens)
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (EFI_ERROR(Status))
+ return Status;
+ for( Index = 0; Index < OrdList->ItemCount; Index++ )
+ {
+ OrdList->PtrTokens[Index].Option = OptionList[Index];
+ OrdList->PtrTokens[Index].Value = ValueList[Index];
+ }
+ MemFreePointer( (VOID **)&(OptionList));
+ MemFreePointer( (VOID **)&(ValueList));
+ }
+ _OrdListGetSelection(OrdList); //EIP70966 To handle OrderList Items
+ //_PopupSelGetSelection((POPUPSEL_DATA *)OrdList);
+
+ //Draw label in left column
+ text1 = HiiGetString( OrdList->ControlData.ControlHandle, OrdList->Title );
+ if ( text1 != NULL )
+ {
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(OrdList->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( OrdList->Left, OrdList->Top,
+ (UINTN)(OrdList->LabelMargin - OrdList->Left),(UINTN) OrdList->Height,
+ text1, OrdList->BGColor | ColorLabel );
+ }
+ else
+ {
+ // boundary overflow check
+ if((TestPrintLength( text1) / (NG_SIZE))> (UINTN)(OrdList->LabelMargin - OrdList->Left ))
+ text1[HiiFindStrPrintBoundary(text1 ,(UINTN)(OrdList->LabelMargin - OrdList->Left ))] = L'\0';
+
+ DrawStringWithAttribute( OrdList->Left , OrdList->Top, (CHAR16*)text1,
+ OrdList->BGColor | ColorLabel );
+ }
+
+ MemFreePointer( (VOID **)&text1 );
+ }
+ if(IsTSEMultilineControlSupported()) //TSE_MULTILINE_CONTROLS moved to binary
+ MultilineSupport = TRUE;
+
+ do
+ {
+ text1 = HiiGetString( OrdList->PopupSelHandle, OrdList->PtrTokens[i].Option);
+
+ if(!text1) //EIP-70966 To handle NULL items in orderlistbox
+ text1 = EfiLibAllocateZeroPool(2);
+
+ Len = TestPrintLength( text1 ) / (NG_SIZE);
+ if ( Len > (UINTN)(OrdList->Width - OrdList->Left - OrdList->LabelMargin -2) )
+ EfiStrCpy(&text1[HiiFindStrPrintBoundary(text1 ,(UINTN)(OrdList->Width - OrdList->Left - OrdList->LabelMargin -4))],L"..." );
+
+ //Enclose the string with [ ]
+ text = EfiLibAllocateZeroPool( (Len+3)*2 );
+ SPrint( text,(UINTN)( (Len+3)*2 ), L"[%s]", text1 );
+ MemFreePointer( (VOID **)&text1 );
+
+ DrawStringWithAttribute(
+ OrdList->Left + OrdList->LabelMargin,
+ OrdList->Top+i,
+ (CHAR16*)text,
+ (UINT8)(OrdList->ControlFocus ? OrdList->SelBGColor|OrdList->SelFGColor : OrdList->BGColor|ColorNSel)
+ );
+ i++;
+ }while(i<OrdList->ItemCount && MultilineSupport);
+
+ /*
+ i=TestPrintLength(text) / (NG_SIZE);
+ MemFreePointer( (VOID **)&text );
+
+ // erase extra spaces if neccessary
+ for(;(UINT16)(popupSel->Left + popupSel->LabelMargin + i+2) <= (popupSel->Width-1);i++)
+ DrawStringWithAttribute( popupSel->Left + popupSel->LabelMargin +i +2 , popupSel->Top, L" ",
+ popupSel->BGColor | ColorNSel );
+ */
+
+ FlushLines( OrdList->Top, OrdList->Top+i-1 );
+ }
+
+ return Status;
+}
+
+// EIP70966_START
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _OrdListGetSelection
+//
+// Description: Function to ordering the option in OrderList
+//
+// Input: ORD_LISTBOX_DATA *ordlist
+//
+// Output:
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _OrdListGetSelection( ORD_LISTBOX_DATA *ordlist )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ UINT8 *temp=NULL;
+ VOID *ifrData = ordlist->ControlData.ControlPtr;
+ int i=0,j=0;
+ PTRTOKENS *OrdPtrTokens=NULL, TempOrdPtrTokens;
+
+
+
+ UINT32 sizeOfData = 0;
+ UINTN type = 0;
+ UINTN dataLen = 0;
+ //Find the size of OrderList based on EFI_IFR_TYPE of EFI_IFR_ONE_OF_OPTION
+// UefiGetValidOptionSize(&ordlist->ControlData, &sizeOfData);
+// dataLen = ordlist->ItemCount * sizeOfData;
+
+ UefiGetValidOptionType(&ordlist->ControlData, &type, &sizeOfData);
+ dataLen = UefiGetMaxEntries(ifrData) * sizeOfData;
+
+ temp = EfiLibAllocateZeroPool( dataLen );
+ if ( temp == NULL )
+ return;
+
+ OrdPtrTokens = ordlist->PtrTokens;
+
+ Status = VarGetValue( ordlist->ControlData.ControlVariable, UefiGetQuestionOffset(ifrData), dataLen, temp );
+
+ // Check variable data and adjust item order.
+ if ( Status == EFI_SUCCESS )
+ {
+ for (i=0 ; i<ordlist->ItemCount-1 ; i++)
+ {
+ for (j=i+1 ; j<ordlist->ItemCount ; j++)
+ {
+ if ( MemCmp( (VOID *)&(OrdPtrTokens[j].Value),(VOID *)(temp + (i * sizeOfData)), sizeOfData ) == 0)
+ {
+ TempOrdPtrTokens = OrdPtrTokens[i];
+ OrdPtrTokens[i] = OrdPtrTokens[j];
+ OrdPtrTokens[j] = TempOrdPtrTokens;
+ break;
+ }
+ }
+ }
+ }
+ MemFreePointer( (VOID **)&temp );
+
+}
+// EIP70966_END
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/ordlistbox.h b/EDK/MiniSetup/TseLite/ordlistbox.h
new file mode 100644
index 0000000..5c449de
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/ordlistbox.h
@@ -0,0 +1,202 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ordlistbox.h $
+//
+// $Author: Premkumara $
+//
+// $Revision: 9 $
+//
+// $Date: 8/28/14 6:06a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/ordlistbox.h $
+//
+// 9 8/28/14 6:06a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 11/03/11 4:33a Premkumara
+// [TAG] EIP70966
+// [Category] Improvement
+// [Description] Hii orderlist item can't update priority from value in
+// Setup menu for both enable and disable TSE_MULTILINE_CONTROLS token
+// [Files] Ordlistbox.c, ordlistbox.h, TseUefiHii.h, Uefi21Wrapper.c
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+// 8 7/09/07 10:45a Arunkumars
+// - Added multi line support for ordered list
+//
+// 7 6/11/07 9:02p Arunkumars
+// Changed ordered list control to correct invalid value in variables only
+// on refresh of a page and not during initialization.
+//
+// 6 7/06/06 6:37p Arunkumars
+// Include tiano.h instead of efi.h
+//
+// 5 6/22/05 11:17a Franklynd
+// 1- Adding knowledge of dimension to the controls
+// 2- Adding check for boundaries in controls.
+//
+// 4 6/17/05 5:20p Jerryp
+// Code rollback to incorporate bug fixes BEFORE feature enhancements
+//
+// 2 5/25/05 11:56p Franklynd
+// Finalized coding on ordered list control.
+//
+// 1 5/25/05 12:26a Franklynd
+// orderedlistbox controls files
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: orderlistbox.h
+//
+// Description: Header file for code to handle ordered list box controls
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _ORD_LISTBOX_H_
+#define _ORD_LISTBOX_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "PopupSel.h"
+
+//TBD// May be removed if not needed.
+#ifndef TRUE
+ #define TRUE 1
+ #define FALSE 0
+#endif
+
+#define SCAN_PLUS '+'
+#define SCAN_MINUS '-'
+
+#define ORD_LISTBOX_MEMBER_VARIABLES \
+ VOID *ScreenBuf; \
+ /*EFI_HII_HANDLE*/VOID* ListHandle;
+
+/* These variables are defined in PopupSel control
+ UINT16 Sel; \
+ UINT16 ItemCount; \
+ UINT16 *PtrTokens;*/
+
+typedef struct _ORD_LISTBOX_METHODS ORD_LISTBOX_METHODS;
+
+typedef struct _ORD_LISTBOX_DATA
+{
+ ORD_LISTBOX_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUPSEL_MEMBER_VARIABLES
+ ORD_LISTBOX_MEMBER_VARIABLES
+
+}
+ORD_LISTBOX_DATA;
+
+
+#define ORD_LISTBOX_METHOD_FUNCTIONS
+
+
+struct _ORD_LISTBOX_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ ORD_LISTBOX_METHOD_FUNCTIONS
+};
+
+extern ORD_LISTBOX_METHODS gOrdListBox;
+
+// Object Methods
+EFI_STATUS OrdListBoxCreate( VOID **object );
+EFI_STATUS OrdListBoxDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS OrdListBoxInitialize( VOID *object, VOID *data );
+EFI_STATUS OrdListBoxDraw( VOID *object );
+EFI_STATUS OrdListBoxHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS OrdListBoxSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS OrdListBoxSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS OrdListBoxSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS OrdListBoxSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS OrdListBoxSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS OrdListGetControlHeight( VOID *OrdList,VOID* frame, UINT16 *height );
+EFI_STATUS _OrdListBoxShift(ORD_LISTBOX_DATA *listbox, UINT8 bShiftUp);
+
+VOID _OrdListBoxCallback( ORD_LISTBOX_DATA *container, CONTROL_DATA *listbox, VOID *cookie );
+VOID _OrdListGetSelection( ORD_LISTBOX_DATA *ordlist );//EIP-70966
+
+#endif /* _ORD_LISTBOX_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/page.c b/EDK/MiniSetup/TseLite/page.c
new file mode 100644
index 0000000..007e6c7
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/page.c
@@ -0,0 +1,1079 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/page.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 19 $
+//
+// $Date: 5/02/14 12:40a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/page.c $
+//
+// 19 5/02/14 12:40a Arunsb
+// [TAG] EIP150526
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE hangs on disconnecting and connecting the RAID driver
+// [Root Cause] Process pack updated on processing the existing pack
+// update
+// [Solution] First we getting remove and new pack. On getting this TSE
+// starts processing the pack(ProcessPackNotification) but on processing
+// the pack itself we getting notification again for remove and add. So
+// again process pack happens inside notification
+// itself(IFRChangeNotifyFn), this processing should not happen inside
+// notification so enabled flag gEnableProcessPack in PageHandleAction.
+// [Files] hii.c, minisetupext.c and page.c
+//
+// 18 2/11/14 8:25p Arunsb
+// [TAG] EIP129750
+// [Category] Improvement
+// [Description] Dynamic pages support in ESA
+// [Files] page.c
+//
+// 17 12/03/13 2:13p Premkumara
+// [TAG] EIP130420
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] String is getting truncated
+// [RootCause] The string for messagebox, Popup controls is getting
+// truncated
+// [Solution] Used temp variable to store original string and modify the
+// string temp and used to avoid changing org string.
+// [Files] String.c
+//
+// 16 7/01/13 9:57a Premkumara
+// [TAG] EIP126876
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Printscreen is not captured in H/W Monitor page
+// [RootCause] TSE is trying to create new file with page title name
+// after taking print screen. If page title has special character then
+// file will not create with any of these character so returning
+// FileHandle as NULL
+// [Solution] If page title has any of these character then it will be
+// replace wit hypen character
+// [Files] Page.c
+//
+// 15 5/15/13 4:44a Premkumara
+// [TAG] EIP23310
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Memory leak
+// [RootCause] Memory is not freed after taking printscreen buffer
+// [Solution] Freed memory for BmpBuffer variable after taking
+// printscreen buffer
+// [Files] Page.c
+//
+// 14 4/18/13 9:25a Arunsb
+// Wrapper function introduce to avoid build error in 2.0
+//
+// 13 3/29/13 12:24p Premkumara
+// [TAG] EIP97611
+// [Category] New Feature
+// [Description] PrintScreen Support in TSE
+// [Files] AMITSE.sdl, CommonHelper.c, HotKeyBin.h, AddBootOption.c,
+// Page.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 12 3/14/13 11:46a Premkumara
+// [TAG] EIP85745 & 109814
+// [Category] Improvement
+// [Description] Support for Modal Form Support as per UEFI 2.3.1
+// [Files] Parse.c, Page.c, Menu.c, Hotclick.c
+//
+// 11 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 10 12/07/11 3:34p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 9 11/20/11 8:05a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 8 6/23/11 3:53p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description]
+// Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 7 3/01/11 1:56p Blaines
+// Removes Engineer's name [Blaines] from commented code.
+//
+// 6 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 8 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/04/10 11:17p Madhans
+// Mouse support related code optimized
+//
+// 6 2/01/10 7:38p Madhans
+// EIP 32501 : Fix to handle the Conditional control Focusing , in the Sub
+// form
+//
+// 5 1/09/10 6:27a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 11/09/09 4:44a Mallikarjunanv
+// Eip-30111 : fixed the issue to update the help if
+// STYLE_PAGE_FIRSTITEM_FOCUS token enabled.
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+// 25 9/17/08 7:44p Madhans
+// For Boot only Driver file split changes.
+//
+// 24 8/11/08 7:04p Madhans
+// TSE_PRN_SCRN_EVENT_SUPPORT SDL token created.
+//
+// 23 7/30/08 5:52p Madhans
+// To handle the printscreen hotkey event.
+//
+// 22 3/19/08 4:00p Madhans
+// Shift Tab Support for Date and Time, MapControlKeys takes
+// AMI_EFI_KEY_DATA.
+//
+// 21 10/24/07 11:23a Arunkumars
+// - Moved IDE security code to binary
+// - Fixed build errors under UGA draw support
+// - Added EFI key password support
+// - Added modifier hot key support
+// - Added popup support in From browser protocol
+//
+// 20 7/09/07 1:27p Arunkumars
+// - Added elink hooks for Logo, Password management and Control Keys
+// customizations
+//
+// 19 5/07/07 8:46a Arunkumars
+// - Mouse input support
+// - Message box protocol to display message boxes
+//
+// 18 4/02/07 4:50p Arunkumars
+// - When a control is active Issue draw only to the frame in which the
+// control is present
+//
+// 17 6/16/06 3:40p Madhans
+// 64 Bit Support. Set SDL token TSE_FOR_64BIT for 64 bit support.
+//
+// 16 5/02/06 7:38a Arunkumars
+// Fix for alignment of the controls
+//
+// 15 4/27/06 9:59a Arunkumars
+// Fix to scroll to unfocusable views
+//
+// 14 2/14/06 1:02p Arunkumars
+// 1. Added Inconsistentif feature
+// 2. We publish two events before and after asking for password (see
+// postmgt.c and minisetup.h)
+//
+// 13 9/02/05 1:23p Jerryp
+// fix for incorrect help information being displayed
+//
+// 12 5/25/05 1:38a Jerryp
+// Moved handling of page 0 into the style specific code
+//
+// 11 4/01/05 1:54p Franklynd
+//
+// 10 2/17/05 12:47p Jerryp
+// Reversed draw order to avoid help overwriting current.
+//
+// 9 2/14/05 2:59p Jerryp
+// Renamed some functions for consistency
+//
+// 8 2/06/05 11:15a Jerryp
+// Full hotkey support
+//
+// 7 2/02/05 4:20p Jerryp
+// **WORK IN PROGRESS **
+// Latest changes for Label/Index.
+// Not completely tested
+//
+// 6 1/19/05 6:09p Jerryp
+// Cleaned up header mess
+//
+// 5 1/14/05 7:09p Jerryp
+// First integration code with boot to shell.
+// Still a bug in booting to shell from FV
+//
+// 4 1/13/05 10:37a Jerryp
+// Latest updated
+// Added ifdef for fake HII info
+//
+// 2 1/06/05 11:31a Jerryp
+// Moved callback from Control to Object
+// Better class heirarchy definitions through #define
+//
+// 1 12/30/04 5:35p Jerryp
+// Initial checkin
+// ** Still some debugging code in place
+// ** Not all object/controls work as expected
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: page.c
+//
+// Description: This file contains code to handle page level operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//////////////////////////////////////////////////
+// Variable Declarations
+//////////////////////////////////////////////////
+PAGE_METHODS gPage =
+{
+ PageCreate,
+ PageDestroy,
+ PageInitialize,
+ PageDraw,
+ PageHandleAction,
+ PageSetCallback
+};
+CHAR16 *gPageTitle = NULL;
+
+//////////////////////////////////////////////////
+// Extern variables
+//////////////////////////////////////////////////
+extern EFI_GRAPHICS_OUTPUT_PROTOCOL *gGOP;
+extern BOOLEAN gPackUpdatePending;
+extern UINT16 gSelIdx;
+extern UINT8 gAddBgrtResolutions;
+
+extern EFI_STATUS FileBrowserLaunchFileSystem (UINT32 Variable);
+//////////////////////////////////////////////////
+// Function Declarations
+//////////////////////////////////////////////////
+EFI_STATUS GetPageSubTitle(UINT32 PgIndex, UINT16 *TitleToken);
+VOID SetGetBgrtCoordinates ( UINTN *DestX, UINTN *DestY, UINTN *Width, UINTN *Height, BOOLEAN Command );
+VOID *ConvertBlt2Bmp ();
+EFI_STATUS ProcessPackNotificationHook (VOID);
+BOOLEAN IsPageModal(UINT32 PgIndex); //EIP-85745 Modal Support
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PageCreate
+//
+// Description: function to create a page
+//
+// Input: PAGE_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PageCreate( PAGE_DATA **object )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool(sizeof(PAGE_DATA));
+ if ( *object == NULL )
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gObject.Create( object );
+
+ if (EFI_ERROR(Status))
+ {
+ MemFreePointer( (VOID **)object );
+ return Status;
+ }
+
+ (*object)->Methods = &gPage;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PageDestroy
+//
+// Description: function to destroy a page, which uses the HotKey Fucntions
+//
+// Input: PAGE_DATA *page, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PageDestroy( PAGE_DATA *page, BOOLEAN freeMem )
+{
+ UINT32 i;
+
+ gObject.Destroy( page, FALSE );
+
+ for ( i = 0; i < page->HotKeyCount; i++ )
+ {
+ gHotKey.Destroy( page->HotKeyList[i], TRUE );
+ }
+
+ MemFreePointer( (VOID **)&page->HotKeyList );
+
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ gFrame.Destroy( page->FrameList[i], TRUE );
+ }
+ page->FrameCount = 0;
+ MemFreePointer( (VOID **)&page->FrameList );
+
+ if ( freeMem )
+ MemFreePointer( (VOID **)&page );
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PageInitialize
+//
+// Description: function to initialize a page, which uses the Frame Fucntions
+//
+// Input: PAGE_DATA *page, PAGE_INFO *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PageInitialize( PAGE_DATA *page, PAGE_INFO *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 i;
+
+ page->CurrentFrame = 0;
+ MemCopy( &page->PageData, data, sizeof(PAGE_INFO) );
+
+ page->FrameCount = StyleGetPageFrames( data->PageID );
+
+ page->FrameList = EfiLibAllocateZeroPool( sizeof(FRAME_DATA *) * page->FrameCount );
+ if ( page->FrameList == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ if ( gFrame.Create( &page->FrameList[i] ) != EFI_SUCCESS )
+ continue;
+
+ page->FrameList[i]->PageID = data->PageID;
+ gFrame.Initialize( page->FrameList[i], StyleGetFrameInitData( data->PageID, i ) );
+
+ Status = StyleInitializeFrame( page->FrameList[i], page->FrameList[i]->FrameData.FrameType, data );
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PageDraw
+//
+// Description: function to draw a page with attributes
+//
+// Input: PAGE_DATA *page
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PageDraw( PAGE_DATA *page )
+{
+ UINT32 i, PageNum, MainFrameIndex=0, CurrentControl;
+
+ FRAME_DATA *MainFrame = NULL;
+
+ CONTROL_DATA **control;
+
+ MainFrameIndex =StyleFrameIndexOf(MAIN_FRAME);
+ MainFrame = page->FrameList[MainFrameIndex];
+
+ StyleBeforeFrame( MainFrame ) ;
+
+ // update the help for the current selection
+ _PageUpdateHelp( page );
+ _PageUpdateTitle( page );
+ _PageUpdateSubtitle( page );
+ _PageUpdateNavStrings( page );
+ _PageUpdateFrameStrings( page );
+
+ PageNum = gApp->CurrentPage ;
+
+ //Call Oem hooks to decide item focus on complete redraw
+
+ if(gApp->CompleteRedraw && gApp->OnRedraw) {
+
+ if(gApp->OnRedraw == MENU_COMPLETE_REDRAW)
+ StylePageItemFocus(page, MainFrame);
+ else if(gApp->OnRedraw == SUBMENU_COMPLETE_REDRAW)
+ StyleSubPageItemFocus(page, MainFrame);
+
+ gApp->OnRedraw = 0 ;
+
+ }
+
+
+
+ //If there is an active control in Main frame only draw that frame
+ if(MainFrame->CurrentControl == FRAME_NONE_FOCUSED)
+ control = NULL;
+ else
+ control = &MainFrame->ControlList[MainFrame->CurrentControl];
+
+ if ( control != NULL )
+ {
+ //If a control is active only draw that
+ if( (*control)->ControlActive == TRUE )
+ {
+ StyleBeforeFrame( MainFrame ) ;
+ gFrame.Draw( MainFrame );
+
+ return EFI_SUCCESS;
+ }
+ }
+
+ // Backup the MainFrame->CurrentControl
+ CurrentControl = MainFrame->CurrentControl;
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ StyleBeforeFrame( page->FrameList[i] ) ;
+ gFrame.Draw( page->FrameList[i] );
+ if(i == MainFrameIndex)
+ {
+ // After expression evalution if current control is affected
+ if(MainFrame->CurrentControl != CurrentControl)
+ {
+ // Help might be updated
+ _PageUpdateHelp( page );
+ CurrentControl = MainFrame->CurrentControl;
+ i = 0; // Redraw all the frames again
+ }
+ }
+ }
+
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PageHandleAction
+//
+// Description: function to handle the page actions
+//
+// Input: PAGE_DATA *page, ACTION_DATA *action
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+extern BOOLEAN gEnableProcessPack;
+EFI_STATUS PageHandleAction( PAGE_DATA *page, ACTION_DATA *action )
+{
+ UINT32 i;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+//EIP: 58925 Start
+ UINT32 stackIndex = 0xFFFFFFFF, tmpcounter = 0;
+ UINT16 parentPgID = 0, TitleToken = 0;
+
+//EIP: 58925 End
+ // On printScreen HotKey, Just return Unsupported and It will handed by Application Hotkey Handler.
+ if( ( action->Input.Type == ACTION_TYPE_KEY ) &&
+ (TsePrintScreenEventSupport(action->Input.Data.AmiKey.Key.ScanCode) ) )
+ {
+ GetPageSubTitle(page->PageData.PageID, &TitleToken);
+ gPageTitle = HiiGetString( page->PageData.PageHandle, TitleToken);
+
+ if (NULL != gPageTitle)
+ {
+ while(gPageTitle[tmpcounter]!= L'\0')
+ {
+ if ( ('/' == gPageTitle[tmpcounter]) ||
+ ('\\' == gPageTitle[tmpcounter]) ||
+ ('<' == gPageTitle[tmpcounter]) ||
+ ('>' == gPageTitle[tmpcounter]) ||
+ ('?' == gPageTitle[tmpcounter]) ||
+ ('*' == gPageTitle[tmpcounter]) ||
+ (':' == gPageTitle[tmpcounter]) ||
+ ('"' == gPageTitle[tmpcounter]) ||
+ ('|' == gPageTitle[tmpcounter])
+ ) //EIP-126876 to avoid create file with special characters. If any of these character found then replace it with '-' character
+ gPageTitle[tmpcounter] = '-';
+ tmpcounter++;
+ }
+ }
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+
+ }
+/*
+#if TSE_PRN_SCRN_EVENT_SUPPORT
+ if (( action->Input.Type == ACTION_TYPE_KEY ) && ( action->Input.Data.AmiKey.Key.ScanCode == TSE_PRN_SCRN_KEY_SCAN ))
+ return EFI_UNSUPPORTED;
+#endif
+*/
+ for ( i = 0; i < page->FrameCount; i++ )
+ {
+ if ( gFrame.HandleAction( page->FrameList[StyleFrameIndexOf(i)], action ) == EFI_SUCCESS )
+ {
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+
+ //EIP-85745 Modal Support
+ //If Page is Modal do not proceed further
+ if(IsPageModal(page->PageData.PageID))
+ {
+ Status = EFI_UNSUPPORTED; //IF page is Modal
+
+ if( action->Input.Type == ACTION_TYPE_KEY )
+ action->Input.Type = ACTION_TYPE_NULL ;
+ goto DONE;
+ }
+
+ for ( i = 0; i < page->HotKeyCount; i++ )
+ {
+ if ( gHotKey.HandleAction( page->HotKeyList[i], action ) == EFI_SUCCESS )
+ {
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+
+ if(
+ (( action->Input.Type == ACTION_TYPE_KEY ) && (ControlActionAbort == MapControlKeysHook(action->Input.Data.AmiKey)))
+ || ((action->Input.Type == ACTION_TYPE_MOUSE) && (ControlActionAbort == MapControlMouseActionHook(&(action->Input.Data.MouseInfo))) /*(TSEMOUSE_RIGHT_CLICK == action->Input.Data.MouseInfo.ButtonStatus)*/)
+ )
+ {
+ if ( page->PageData.PageParentID == 0 )
+ {
+ Status = EFI_UNSUPPORTED;
+//EIP: 58925 Start
+ if(IsLinkHistorySupport())
+ {
+ Status = GetParentFormID((UINT16)gApp->CurrentPage, &parentPgID, &stackIndex); //Gets the parent page of the current page
+
+ if(Status == EFI_SUCCESS)
+ {
+ gApp->CurrentPage = parentPgID; //Else set the current page to the parent page
+ }
+ }
+//EIP: 58925 End
+
+ goto DONE;
+ }
+
+ if ( page->PageData.PageID != page->PageData.PageParentID )
+ {
+ // check for inconsistency here too.
+ if (CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[page->PageData.PageID]))!= TRUE )
+ {
+ // reset focus to first control
+ FRAME_DATA *frame = page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+//EIP: 58925 Start
+ if(IsLinkHistorySupport())
+ {
+ // tell application that we need to change pages
+ Status = GetParentFormID((UINT16)gApp->CurrentPage, &parentPgID, &stackIndex); //Gets the parent page of the current page
+ if(Status != EFI_SUCCESS)
+ gApp->CurrentPage = page->PageData.PageParentID;
+ else
+ gApp->CurrentPage = parentPgID; //Else set the current page to the parent page
+ }
+ else
+ {
+ gApp->CurrentPage = page->PageData.PageParentID;
+ }
+//EIP: 58925 End
+ gApp->CompleteRedraw = TRUE;
+ gApp->OnRedraw = SUBMENU_COMPLETE_REDRAW;
+ }
+
+ Status = EFI_SUCCESS;
+ }
+ }
+DONE:
+ if (gPackUpdatePending) //EIP75588 Update If any pack pending
+ {
+ if(!IsActiveControlPresent(page))
+ {
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] PageHandleAction () calling ProcessPackNotificationHook() \n\n");
+ gEnableProcessPack = TRUE;
+ Status = ProcessPackNotificationHook ();
+ gEnableProcessPack = FALSE;
+ }
+ }
+//EIP: 58925 Start
+ if(IsLinkHistorySupport())
+ {
+ if(Status == EFI_SUCCESS)
+ {
+ SetParentFormID(page->PageData.PageID, (UINT16)gApp->CurrentPage);
+ }
+ }
+//EIP: 58925 End
+ return Status;
+}
+
+EFI_STATUS PageSetCallback( PAGE_DATA *page, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gObject.SetCallback( page, container, callback, cookie );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateMemo
+//
+// Description: function to update the memo
+//
+// Input: PAGE_DATA *page, UINT16 frameNumber, VOID* handle, UINT16 token
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateMemo( PAGE_DATA *page, UINT32 frameType, /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+
+{
+ MEMO_DATA *memo;
+ FRAME_DATA *memoFrame;
+ UINT32 frameIndex;
+
+ frameIndex = StyleFrameIndexOf(frameType);
+ if ( ( page->FrameCount <= frameIndex ) || ( token == 0 ) )
+ return;
+
+ memoFrame = page->FrameList[frameIndex];
+
+
+ if ( memoFrame->ControlCount == 0 )
+ return;
+
+ memo = (MEMO_DATA *)memoFrame->ControlList[0];
+ memo->ControlData.ControlHandle = handle;
+
+ if(memo->ControlData.ControlType == CONTROL_TYPE_MEMO)
+ UefiSetSubTitleField((VOID *)memo->ControlData.ControlPtr,token);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateHelp
+//
+// Description: function to update the page help
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateHelp( PAGE_DATA *page )
+{
+ CONTROL_DATA *control;
+ FRAME_DATA *mainFrame;
+
+ mainFrame = page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+
+ _PageUpdateMemo( page, HELP_FRAME, gHiiHandle, STRING_TOKEN(STR_EMPTY_STRING) );
+ if ( mainFrame->ControlCount == 0 )
+ return;
+
+ if(mainFrame->CurrentControl == FRAME_NONE_FOCUSED)
+ return;
+
+ control = mainFrame->ControlList[mainFrame->CurrentControl];
+
+ if ( control->ControlFocus )
+ _PageUpdateMemo( page, HELP_FRAME, control->ControlData.ControlHandle, control->ControlData.ControlHelp );
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateSubtitle
+//
+// Description: function to update the subtitle of the page
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateSubtitle( PAGE_DATA *page )
+{
+ /*EFI_HII_HANDLE*/VOID * hiiHandle = page->PageData.PageHandle;
+ UINT16 token = page->PageData.PageSubTitle;
+
+ if ( token == 0 )
+ {
+ hiiHandle = gHiiHandle;
+ token = gScreen->MainCopyright;
+ }
+
+ _PageUpdateMemo( page, SUBTITLE_FRAME, hiiHandle, token );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateTitle
+//
+// Description: function to update the title of the page
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateTitle( PAGE_DATA *page )
+{
+ /*EFI_HII_HANDLE*/VOID * hiiHandle = page->PageData.PageHandle;
+ UINT16 token = page->PageData.PageTitle;
+
+ if ( token == 0 )
+ {
+ hiiHandle = gHiiHandle;
+ token = gScreen->MainTitle;
+ }
+
+ _PageUpdateMemo( page, TITLE_FRAME, hiiHandle, token );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateNavStrings
+//
+// Description: function to update the title of the page
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateNavStrings( PAGE_DATA *page )
+{
+ _PageUpdateMemo( page, NAV_FRAME, gHiiHandle, StyleGetNavToken( page->PageData.PageID ) );
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _PageUpdateFrameStrings
+//
+// Description: function to update the title of the page
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _PageUpdateFrameStrings( PAGE_DATA *page )
+{
+ StyleUpdateFrameStrings(page);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdatePageFocusedItemHelp
+//
+// Description: function to update the Help in case of First Item focus set.
+//
+// Input: PAGE_DATA *page
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UpdatePageFocusedItemHelp(PAGE_DATA *page)
+{
+ //call the internal function to update the page help
+ _PageUpdateHelp(page);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HotclickESCaction
+//
+// Description: function to handle the left click on ESC in Navigation frame.
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HotclickESCaction(VOID)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ PAGE_DATA *page;
+ UINT32 stackIndex = 0xFFFFFFFF;
+ UINT16 parentPgID = 0;
+ page = gApp->PageList[gApp->CurrentPage];
+
+ if ( page->PageData.PageParentID == 0 )
+ {
+ gApp->Quit = ExitApplication();
+ return;
+ }
+
+ if ( page->PageData.PageID != page->PageData.PageParentID )
+ {
+ // check for inconsistency here too.
+ if (CheckInconsistence((PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[page->PageData.PageID]))!= TRUE )
+ {
+ // reset focus to first control
+ FRAME_DATA *frame = page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ UINT32 i;
+
+ for ( i = 0; i < frame->ControlCount; i++ )
+ {
+ if ( _FrameSetControlFocus( frame, i ) )
+ {
+ frame->FirstVisibleCtrl = 0;
+ break;
+ }
+ }
+
+ if(IsLinkHistorySupport())
+ {
+ // tell application that we need to change pages
+ Status = GetParentFormID((UINT16)gApp->CurrentPage, &parentPgID, &stackIndex); //Gets the parent page of the current page
+ if(Status != EFI_SUCCESS)
+ gApp->CurrentPage = page->PageData.PageParentID;
+ //gApp->CurrentPage = gNavStartPage; //If the parent page was not found or invalid, go to the first page
+ else
+ gApp->CurrentPage = parentPgID; //Else set the current page to the parent page
+ }
+ else
+ {
+ gApp->CurrentPage = page->PageData.PageParentID;
+ }
+
+ gApp->CompleteRedraw = TRUE;
+ gApp->OnRedraw = SUBMENU_COMPLETE_REDRAW;
+ }
+
+ Status = EFI_SUCCESS;
+ }
+
+
+ if(IsLinkHistorySupport())
+ {
+ if(Status == EFI_SUCCESS)
+ {
+ SetParentFormID(page->PageData.PageID, (UINT16)gApp->CurrentPage);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PrntScrnKeyHandleaction
+//
+// Description: Function to handle PrintScreenKeyto get screen image as BltBuffer and save as BMP file to a available filesystem
+//
+// Input: VOID
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS WriteDataToFileWrapper (CHAR16 *filename, VOID *Data, UINTN length, UINT32 index);
+EFI_STATUS PrntScrnKeyHandleaction()
+{
+ BMP_IMAGE_HEADER *BmpBuffer=NULL;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_TIME time;
+
+ CHAR16 *Title = L"Snap of current page:";
+ CHAR16 *Msg = NULL;
+ CHAR16 *Filename = NULL;
+ UINT8 Sel = 0;
+ UINTN StartX = 0, StartY = 0, Width = 0, Height = 0;
+ UINT32 variable = 0xffff;
+
+
+ gAddBgrtResolutions = 1;
+ Height = (UINTN)(gGOP->Mode->Info->VerticalResolution);
+ Width = (UINTN)(gGOP->Mode->Info->HorizontalResolution);
+
+ SetGetBgrtCoordinates (&StartX,&StartY,&Width,&Height,TRUE);
+
+ //Converting blt buffer to BMP
+ BmpBuffer = ConvertBlt2Bmp ();
+
+ if (BmpBuffer)
+ {
+ //List available FileSystem
+ Status = FileBrowserLaunchFileSystem(variable);
+
+ if (EFI_ERROR(Status))
+ {
+ PostManagerDisplayMsgBox (L"PrintScreen Error!!",L"Screen is not captured",MSGBOX_TYPE_OK,&Sel);
+ goto DONE;
+ }
+
+ gRT->GetTime( &time, NULL );
+
+ if (NULL == gPageTitle)
+ {
+ gPageTitle = EfiLibAllocateZeroPool ( (EfiStrLen(L"TSE_Snap")+1)*sizeof(CHAR16) );
+ EfiStrCpy (gPageTitle, L"TSE_Snap");
+ }
+
+ Filename = EfiLibAllocateZeroPool ( (EfiStrLen(gPageTitle)+16)*sizeof(CHAR16));//length of title and time format (HH-MM-SS) and .BMP character
+ if (NULL == Filename)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ SPrint(Filename,((EfiStrLen(gPageTitle)+16)*sizeof(CHAR16)),L"%s_[%02d-%02d-%02d].BMP",gPageTitle,time.Hour,time.Minute,time.Second );
+ Status = WriteDataToFileWrapper (Filename,BmpBuffer,BmpBuffer->Size,gSelIdx);
+
+ if (!EFI_ERROR(Status))
+ {
+ Msg = EfiLibAllocateZeroPool( (EfiStrLen(L"Image is stored with name : ") + EfiStrLen (Filename) + 1) * sizeof(CHAR16) );
+
+ if (NULL == Msg)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ SPrint(Msg,( (EfiStrLen(L"Image is stored with name : ") + EfiStrLen (Filename)+1) * sizeof(CHAR16) ),L"Image is stored with name : %s",Filename);
+ PostManagerDisplayMsgBox (Title,Msg,MSGBOX_TYPE_OK,&Sel);
+ }
+
+ else
+ PostManagerDisplayMsgBox (L"Error Message",L"Failed to save to a file",MSGBOX_TYPE_OK,&Sel);
+ }
+
+DONE:
+ if (BmpBuffer) //EIP-123310 memory leak
+ MemFreePointer((VOID **)&BmpBuffer);
+ if (Filename)
+ MemFreePointer((VOID **)&Filename);
+ if (Msg)
+ MemFreePointer((VOID **)&Msg);
+ if (gPageTitle)
+ MemFreePointer ((VOID **)&gPageTitle);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PrntScrnKeyNotification
+//
+// Description: PrntScrnKeyNotification Function handle PrntScrnKey action
+//
+// Input: CHAR16 *
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID PrntScrnKeyNotification(APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie )
+{
+ if ( TRUE == TsePrintScreenEventSupport ( ((HOTKEY_DATA*)hotkey)->HotKeyData.Key.ScanCode ) )
+ PrntScrnKeyHandleaction();
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/page.h b/EDK/MiniSetup/TseLite/page.h
new file mode 100644
index 0000000..33abbc9
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/page.h
@@ -0,0 +1,185 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/page.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 6 $
+//
+// $Date: 10/18/12 6:01a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/page.h $
+//
+// 6 10/18/12 6:01a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 8 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//
+// 7 7/06/06 6:37p Arunkumars
+// Include tiano.h instead of efi.h
+//
+// 6 2/06/05 11:15a Jerryp
+// Full hotkey support
+//
+// 5 1/14/05 7:09p Jerryp
+// First integration code with boot to shell.
+// Still a bug in booting to shell from FV
+//
+// 4 1/13/05 7:14p Jerryp
+// Added new method to Control class
+// Added RUNTIME_DEBUG_SUPPORT option
+// Fixed flushing error with memo
+// Added update to help of date control
+// Removed all fake HII stuff
+//
+// 3 1/13/05 10:37a Jerryp
+// Latest updated
+// Added ifdef for fake HII info
+//
+// 2 1/06/05 11:31a Jerryp
+// Moved callback from Control to Object
+// Better class heirarchy definitions through #define
+//
+// 1 12/30/04 5:35p Jerryp
+// Initial checkin
+// ** Still some debugging code in place
+// ** Not all object/controls work as expected
+//
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: page.h
+//
+// Description: Header file for code to handle page level operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _PAGE_H_
+#define _PAGE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "object.h"
+#include "action.h"
+#include "frame.h"
+#include "hotkey.h"
+
+#define PAGE_MEMBER_VARIABLES \
+ PAGE_INFO PageData; \
+ UINT32 CurrentFrame; \
+ UINT32 FrameCount; \
+ FRAME_DATA **FrameList; \
+ UINT32 HotKeyCount; \
+ HOTKEY_DATA **HotKeyList;
+
+typedef struct _PAGE_METHODS PAGE_METHODS;
+
+typedef struct _PAGE_DATA
+{
+ PAGE_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ PAGE_MEMBER_VARIABLES
+
+}
+PAGE_DATA;
+
+#define PAGE_METHOD_FUNCTIONS
+
+struct _PAGE_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ PAGE_METHOD_FUNCTIONS
+};
+
+extern PAGE_METHODS gPage;
+
+// Object Methods
+EFI_STATUS PageCreate( VOID **object );
+EFI_STATUS PageDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PageInitialize( VOID *object, VOID *data );
+EFI_STATUS PageDraw( VOID *object );
+EFI_STATUS PageHandleAction( VOID *object, ACTION_DATA *data );
+EFI_STATUS PageSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+VOID _PageUpdateMemo( PAGE_DATA *page, UINT32 frameType, /*EFI_HII_HANDLE*/VOID * handle, UINT16 token );
+
+VOID _PageUpdateHelp( PAGE_DATA *page );
+VOID _PageUpdateSubtitle( PAGE_DATA *page );
+VOID _PageUpdateTitle( PAGE_DATA *page );
+VOID _PageUpdateNavStrings( PAGE_DATA *page );
+VOID _PageUpdateFrameStrings( PAGE_DATA *page );
+
+#endif /* _PAGE_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/popup.c b/EDK/MiniSetup/TseLite/popup.c
new file mode 100644
index 0000000..39ec33d
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/popup.c
@@ -0,0 +1,613 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/popup.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 14 $
+//
+// $Date: 5/03/14 6:22p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/popup.c $
+//
+// 14 5/03/14 6:22p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// Corrected condtion to display multi-line string
+//
+// 13 5/03/14 4:01p Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 12 5/02/14 1:03p Premkumara
+// [TAG] EIP154407
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] NVMe Driver - AddBootOption Hang
+// [RootCause] System hangs When popup->width(NvMe driver path) is more
+// than
+// gmaxcol.
+// [Solution] Added condition to initialize the popup->width =
+// gmaxcol-10 when
+// it exceeds gmaxcol.
+// [Files] popup.c
+//
+// 11 2/11/14 9:01p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 10 12/06/13 4:49a Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Comments] Corrected condtion properly for password and
+// string type control
+//
+// 9 12/03/13 9:02a Premkumara
+// [TAG] EIP135665
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE get hangs, when long string is given as title for
+// password
+// [Root Cause] TSE is not handling properl when PasswordTitle length
+// exceeds screen width
+// [Solution] Handled password title length based on screen width and
+// given support to display title in multiple lines.
+// [Files] postmgmtext.c, Popup.c, PopupEdit.c, PopupPassword.c
+//
+// 8 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 12/01/11 1:39a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 6 11/21/11 8:55a Rajashakerg
+// [TAG] EIP69104
+// [Category] Improvement
+// [Description] Not to destroy the controls if it is NULL
+// [Files] control.c, edit.c, Label.c, memo.c, menu.c, ordlistbox.c,
+// popup.c, PopupSel.c, PopupString.c, SubMenu.c, Text.c.
+//
+// 5 6/28/11 10:14a Madhans
+// To remove ";" in unwanted case.
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 4 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 6/23/09 6:52p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:05p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: popup.c
+//
+// Description: This file contains code to handle popup operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+POPUP_METHODS gPopup =
+{
+ PopupCreate,
+ PopupDestroy,
+ PopupInitialize,
+ PopupDraw,
+ PopupHandleAction,
+ PopupSetCallback,
+ PopupSetFocus,
+ PopupSetPosition,
+ PopupSetDimensions,
+ PopupSetAttributes,
+ PopupGetControlHight
+};
+
+extern BOOLEAN IsShowPromptStringAsTitle(VOID);//EIP-116315 password string
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupCreate
+//
+// Description: this function uses the create function of control
+// and creates the Popup menu
+//
+// Input: POPUP_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupCreate( POPUP_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(POPUP_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create( object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gPopup;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the Popup menu
+//
+// Input: POPUP_DATA *popup, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupDestroy( POPUP_DATA *popup, BOOLEAN freeMem )
+{
+ if(NULL == popup)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( popup, FALSE );
+
+ if( freeMem ){
+ MemFreePointer( (VOID **)&popup->Title );//EIP-73236
+ MemFreePointer( (VOID **)&popup->Help1 );
+ MemFreePointer( (VOID **)&popup->Help2 );
+ MemFreePointer( (VOID **)&popup->Help3 );
+ MemFreePointer( (VOID **)&popup );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupInitialize
+//
+// Description: this function uses the initialize function of control
+// and initializes the Popup menu
+//
+// Input: POPUP_DATA *popup, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupInitialize( POPUP_DATA *popup, VOID *data )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ Status = gControl.Initialize( (CONTROL_DATA *)popup, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ popup->PopupBorder = POPUP_SINGLE_BORDER; //Default border
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetLineCount
+//
+// Description: function to get line count and max width.
+//
+// Input: CHAR16 *line, UINT8 *Width
+//
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN PopupGetLineCount(CHAR16 *line)
+{
+ CHAR16 * text;
+ UINTN i=1;
+ CHAR16 * String=line;
+
+
+ while(1)
+ {
+ CHAR16 save;
+
+ text = String;
+ if ( *String == L'\0' )
+ break;
+
+ while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) )
+ String++;
+
+ save = *String;
+ *String = L'\0';
+
+
+ if ( ( *String = save ) != L'\0' )
+ {
+ if ( *String == L'\r' )
+ { String++;
+ i--;
+ }
+ if ( *String == L'\n' )
+ {
+ String++;
+
+ if ( *(String - sizeof(CHAR16)) == L'\r' )
+ i++;
+ }
+ }
+ else
+ break;
+ i++;
+ }
+ return i;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupDrawString
+//
+// Description: function to draw string in a popup menu with attributes
+//
+// Input: POPUP_DATA *popup, CHAR16 *Str,UINT16 Top
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID PopupDrawString(POPUP_DATA *popup, CHAR16 *Str,UINT16 Top)
+{
+ CHAR16 *PadTitle = NULL;
+ UINTN Height = 0;
+ UINT16 OpCode = 0xFF;
+
+
+ if ((EFI_IFR_OP_HEADER*)popup->ControlData.ControlPtr) //If it has valid control pointer
+ {
+ //Skipping ESC code color not to print title in color for Popup controls like OneOf,CheckBox,String,Password(based on token IsShowPromptStringAsTitle)
+ if( (popup->ControlData.ControlType == CONTROL_TYPE_POPUPSEL) ||
+ (((EFI_IFR_OP_HEADER *)popup->ControlData.ControlPtr)->OpCode == EFI_IFR_STRING_OP) ||
+ (((EFI_IFR_OP_HEADER *)popup->ControlData.ControlPtr)->OpCode == CONTROL_TYPE_ORDERED_LIST) ||
+ ( IsShowPromptStringAsTitle() && ((EFI_IFR_OP_HEADER *)popup->ControlData.ControlPtr)->OpCode == EFI_IFR_PASSWORD_OP )
+ )
+ {
+ Str = TseSkipEscCode(Str);
+ }
+ }
+
+ if ((EFI_IFR_OP_HEADER*)popup->ControlData.ControlPtr) //If it has valid control pointer
+ OpCode = ((EFI_IFR_OP_HEADER*)popup->ControlData.ControlPtr)->OpCode;
+
+ //If control is of Password OR String type, and Multiline is supported
+ if ( ( (OpCode == EFI_IFR_PASSWORD_OP ) || (EFI_IFR_STRING_OP == OpCode) ) && IsTSEMultilineControlSupported() )
+ {
+ if (Str)
+ {
+ Height=(EfiStrLen(Str) / popup->Width)+(((EfiStrLen(Str) % popup->Width) > 0)?1:0);
+ DrawMultiLineStringWithAttribute (popup->Left+2, Top, popup->Width-3, Height, Str, 0);
+ }
+ }
+
+ else
+ {
+ if ( Str != NULL )
+ {
+ PadTitle = EfiLibAllocateZeroPool( (popup->Width + 3) * sizeof(CHAR16) );
+
+ //If no multiline support truncating the long string and showing ... at last
+ if((TestPrintLength( Str) / (NG_SIZE)) > popup->Width)
+ {
+ UINTN Index=HiiFindStrPrintBoundary(Str ,popup->Width);
+ Str[Index-4] = L'\0';
+ Str[Index-5] = L'.';
+ Str[Index-6] = L'.';
+ Str[Index-7] = L'.';
+ }
+
+ if ( PadTitle != NULL )
+ SPrint( PadTitle, (EfiStrLen(Str)) * sizeof(CHAR16), L" %s ",Str );
+ }
+
+ if ( PadTitle )
+ {
+ DrawStringJustified( 0, gMaxCols, Top, JUSTIFY_CENTER, PadTitle );
+ MemFreePointer((VOID **)&PadTitle);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupDraw
+//
+// Description: function to draw popup menu with attributes
+//
+// Input: POPUP_DATA *popup
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupDraw( POPUP_DATA *popup )
+{
+ UINTN NumOfHelpLines = 0, NumOfTitleLines = 0;
+ CHAR16 *String = NULL, *text = NULL;
+ UINTN i=0;
+
+
+ BOOLEAN bShadow = StyleGetShadowSupport() ;
+ popup->Top = (UINT16)(gMaxRows - popup->Height) / 2;
+ popup->Left = (UINT16)(gMaxCols - popup->Width) / 2;
+
+ //EIP154407 System hangs if popup->Width is more than gMaxCols
+ if( popup->Width > gMaxCols)
+ {
+ popup->Width = (UINT16)(gMaxCols - 10);
+ }
+
+
+ if(popup->Style == POPUP_STYLE_NORMAL)
+ {
+ DrawWindow( popup->Left, popup->Top, popup->Width, popup->Height,
+ (UINT8)(popup->BGColor | popup->FGColor) , popup->Border, bShadow );
+
+ if ( popup->Title != NULL )
+ PopupDrawString(popup,popup->Title,popup->Top);
+ }
+ else
+ {
+#define TITLE_LINES 1
+#define HELP_LINES 3
+
+
+ if ( popup->Title != NULL )
+ NumOfTitleLines = 2 ;
+
+ if ( popup->Help1 != NULL )
+ NumOfHelpLines = PopupGetLineCount(popup->Help1)+1 ;
+
+
+ DrawWindow( popup->Left, popup->Top-NumOfTitleLines, popup->Width, popup->Height+NumOfHelpLines+NumOfTitleLines,
+ (UINT8)(popup->BGColor | popup->FGColor), FALSE, FALSE );
+
+ if(NumOfTitleLines)
+ DrawBorder( popup->Left, popup->Top-NumOfTitleLines, popup->Width, NumOfTitleLines+1 );
+ if(NumOfHelpLines)
+ DrawBorder( popup->Left, popup->Top+popup->Height-1, popup->Width, NumOfHelpLines+1);
+ DrawBorder( popup->Left, popup->Top-NumOfTitleLines, popup->Width, popup->Height+NumOfHelpLines+NumOfTitleLines );
+
+ if ( popup->Title != NULL )
+ PopupDrawString(popup,popup->Title,popup->Top-1);
+
+ //if ( popup->Help1 != NULL )
+ // PopupDrawString(popup,popup->Help1,popup->Top+popup->Height);
+
+ String = popup->Help1 ;
+
+ for(i=0;i<NumOfHelpLines;i++)
+ {
+ CHAR16 save;
+
+ text = String;
+ if ( *String == L'\0' )
+ break;
+
+ while ( ( *String != L'\n' ) &&( *String != L'\r' ) && ( *String != L'\0' ) )
+ String++;
+
+ save = *String;
+ *String = L'\0';
+
+ if((TestPrintLength( text ) / (NG_SIZE)) > (UINTN)(popup->Width-2))
+ EfiStrCpy( &text[HiiFindStrPrintBoundary(text,(UINTN)(popup->Width-5))],L"...");
+
+ PopupDrawString(popup, text, (UINT16)(popup->Top+popup->Height+i));
+
+
+ if ( ( *String = save ) != L'\0' )
+ {
+ String++;
+ if ( ( *String == L'\r' ) || ( *String == L'\n' ) )
+ String++;
+ }
+ }
+ }
+
+ return gControl.Draw( popup );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSetCallback
+//
+// Description: Function to set the Popup callback
+//
+// Input: POPUP_DATA *popup, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSetCallback( POPUP_DATA *popup, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return gControl.SetCallback( popup, container, callback, cookie );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupHandleAction
+//
+// Description: Function to handle the Popup Edit actions
+//
+// Input: POPUP_DATA *popup, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupHandleAction( POPUP_DATA *popup, ACTION_DATA *Data)
+{
+ //do nothing here, the action is handled on the child class either listbox or messagebox
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSetFocus
+//
+// Description: Function to set focus
+//
+// Input: POPUP_DATA *popup, BOOLEAN focus
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSetFocus( POPUP_DATA *popup, BOOLEAN focus)
+{
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSetPosition
+//
+// Description: Function to set focus
+//
+// Input: POPUP_DATA *popup, UINT16 Left, UINT16 Top
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSetPosition( POPUP_DATA *popup, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( popup, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSetDimensions
+//
+// Description: Function to set the dimentions of the editable popup menu
+//
+// Input: POPUP_DATA *popup, UINT16 Width, UINT16 Height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSetDimensions( POPUP_DATA *popup, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( popup, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupSetAttributes
+//
+// Description: Function to set the dimentions of the editable popup menu
+//
+// Input: POPUP_DATA *popup, UINT8 FGColor, UINT8 BGColor
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupSetAttributes( POPUP_DATA *popup, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( popup, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopupGetControlHight
+//
+// Description: Function unsuppored.
+//
+// Input: VOID *object,VOID *frame, UINT16 *height
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PopupGetControlHight( VOID *object,VOID *frame, UINT16 *height )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Norcross, Suite 200, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+
diff --git a/EDK/MiniSetup/TseLite/popup.h b/EDK/MiniSetup/TseLite/popup.h
new file mode 100644
index 0000000..31768b3
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/popup.h
@@ -0,0 +1,161 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/popup.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:02a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/popup.h $
+//
+// 7 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 5 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 6 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 5 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 8/17/09 12:27p Presannar
+// Removed References to Tiano.h and replaced it with Efi.h
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:06p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:58p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: popup.h
+//
+// Description: Header file for code to handle popup operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _POPUP_H_
+#define _POPUP_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "control.h"
+
+// popup constants
+#define POPUP_SINGLE_BORDER 1
+#define POPUP_DOUBLE_BORDER 2
+
+#define POPUP_STYLE_NORMAL 0
+#define POPUP_STYLE_BBS 1
+
+#define POPUP_MEMBER_VARIABLES \
+ CHAR16 *Title; \
+ UINT16 PopupBorder; \
+ BOOLEAN Border; \
+ BOOLEAN Shadow; \
+ UINT16 Style; \
+ CHAR16 *Help1; \
+ CHAR16 *Help2; \
+ CHAR16 *Help3;
+
+typedef struct _POPUP_METHODS POPUP_METHODS;
+
+typedef struct _POPUP_DATA
+{
+ POPUP_METHODS *Methods;
+
+ OBJECT_MEMBER_VARIABLES
+ CONTROL_MEMBER_VARIABLES
+ POPUP_MEMBER_VARIABLES
+
+}
+POPUP_DATA;
+
+#define POPUP_METHOD_FUNCTIONS
+
+struct _POPUP_METHODS
+{
+ OBJECT_METHOD_FUNCTIONS
+ CONTROL_METHOD_FUNCTIONS
+ POPUP_METHOD_FUNCTIONS
+};
+
+extern POPUP_METHODS gPopup;
+
+// Object Methods
+EFI_STATUS PopupCreate( VOID **object );
+EFI_STATUS PopupDestroy( VOID *object, BOOLEAN freeMem );
+EFI_STATUS PopupInitialize( VOID *object, VOID *data );
+EFI_STATUS PopupDraw( VOID *object );
+EFI_STATUS PopupHandleAction(VOID *object, ACTION_DATA *Data);
+EFI_STATUS PopupSetCallback( VOID *object, VOID *container, OBJECT_CALLBACK callback, VOID *cookie );
+
+// Control Methods
+EFI_STATUS PopupSetFocus(VOID *object, BOOLEAN focus);
+EFI_STATUS PopupSetPosition(VOID *object, UINT16 Left, UINT16 Top);
+EFI_STATUS PopupSetDimensions(VOID *object, UINT16 Width, UINT16 Height);
+EFI_STATUS PopupSetAttributes(VOID *object, UINT8 FGColor, UINT8 BGColor);
+EFI_STATUS PopupGetControlHight( VOID *object,VOID *frame, UINT16 *height );
+
+#endif /* _POPUP_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/time.c b/EDK/MiniSetup/TseLite/time.c
new file mode 100644
index 0000000..8a55a60
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/time.c
@@ -0,0 +1,1121 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/time.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 33 $
+//
+// $Date: 5/01/14 11:27p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/time.c $
+//
+// 33 5/01/14 11:27p Arunsb
+// [TAG] EIP128948
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] TSE security code check failure for using uninitialized
+// variable "Action"
+// [RootCause] Action variable in TimeHanldeActionKeyMouse and
+// _PostPopupEditGetValues is not initialized
+// [Solution] Initialized Action variable.
+// [Files] Time.c, TseAdvanced.c
+//
+// 32 5/01/14 3:46p Premkumara
+// [TAG] EIP123727
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Enabling Multiline and in Boot option priorities, Clicking
+// on second or third line of the boot item is not selecting boot options
+// menu
+// [RootCause] Proper Condition was not there to check whether Mouse
+// Click
+// is within the Width and Height of Control or not.
+// [Solution] Added Proper Condition to check whether Mouse Click
+// is within the Width and Height of Control or not.
+// [Files] Date.c, time.c, frame.c, SubMenu.c, numeric.c,
+// PopupString.c, PopupSel.c, ordlistbox.c, PopupPassword.c, UefiAction.c,
+//
+// 31 2/11/14 9:03p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 30 11/06/13 1:24a Premkumara
+// [TAG] EIP128948
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] TSE security code check failure for using uninitialized
+// variable "Action"
+// [RootCause] Action variable in TimeHanldeActionKeyMouse and
+// _PostPopupEditGetValues is not initialized
+// [Solution] Initialized Action variable.
+// [Files] Time.c, TseAdvanced.c
+//
+// 29 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 13 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 28 4/05/12 7:26a Rajashakerg
+// [TAG] EIP87122,85508,86449
+// [Category] Improvement
+// [Description] Numeric in old style, softkbd issues
+// [Files] CommonHelper.c, Mouse.c, Date.c, edit.c, frame.c,
+// minisetupext.h, numeric.c, numeric.h, PopupEdit.c, PopupEdit.h, time.c
+//
+// 27 2/02/12 1:18p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 26 1/11/12 7:41a Arunsb
+// [TAG] EIP79965
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Unable to set the date and time with the soft keyboard and
+// mouse
+// [RootCause] Softkbd disabled even the control is active
+// [Solution] Disabled the softkbd only when control is inactive
+// [Files] Date.c and time.c
+//
+// 25 12/08/11 7:02p Blaines
+// [TAG] - EIP 77070
+// [Category]- Function Request
+// [Synopsis]- "-"key can not loop the time setting..
+// [Files]
+// time.c
+//
+// 24 12/07/11 9:01a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Moved the UefiPreControlUpdate function call in time.c
+// and date.c to the appropriate place.
+// [Files] time.c, date.c
+//
+// 23 11/30/11 12:32a Premkumara
+// [TAG] EIP75351
+// [Category] Improvement
+// [Description] Static code analysis.Suppress the warnings from static
+// code analyzer
+// [Files] String.c, HiiString21.c, TseAdvanced.c, Special.c,
+// UefiAction., Time.c, PopupEdit.c, MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 22 11/28/11 5:00a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 21 11/21/11 11:02a Premkumara
+// [TAG] EIP72610
+// [Category] Improvement
+// [Description] Moving TSE_MULTILINE_CONTROLS to Binary
+// [Files] AMITSE-CommonHelper.c, AMITSE.sdl,
+// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
+// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c,
+// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c,
+// Date.h, Date.c,
+// LEGACY-Legacy.c,
+// BOOTONLY- Minisetup.h
+//
+// 20 11/20/11 8:20a Rajashakerg
+// [TAG] EIP62763
+// [Category] Improvement
+// [Description] Utilize the Improvements done from mouse driver in
+// AMITSE
+// [Files] HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
+// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
+// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
+// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
+// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
+// PopupPassword.c, postmgmtext.c, time.c.
+//
+// 19 11/19/11 11:49a Arunsb
+// EIP 65222 changes has been removed for 2.14 release. Now it is added.
+//
+// 18 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 17 8/26/11 6:34p Blaines
+// [TAG] EIP68354
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Callback was invoked during periodic update for time and
+// date controls without EFI_IFR_REFRESH_OP.
+// [Solution] Callback is only invoked for interactive controls.
+// [Files] TseLite: Time.c, Date.c,
+// Uefi21: Parese.c, Uefi21Wrapper.c
+//
+// 16 8/18/11 4:13a Arunsb
+// Reverted back to (INT)4.6.2_TSE_2_14_1219 source for making TSE Lite
+// release.
+//
+// 15 8/02/11 9:49a Arunsb
+// EIP 65222 fix uploaded again after the public label
+// 4.6.2_TSE_2_14_1219.
+//
+// 14 8/01/11 6:07a Arunsb
+// Reverted back to (INT)4.6.2_TSE_2_14_1219 source for making public
+// label.
+//
+// 13 7/28/11 10:36a Blaines
+// [TAG] - EIP 65222
+// [Category]- Defect
+// [Synopsis]- [ECS-DT][Acer][Q67H2-AM]Adjust RTC time issue.
+// [Description]- Set Power On by RTC Alarm -> Time(hh:mm:ss) function
+// error. When set 59 at second(ss) column. Press decrease key(-) and the
+// second(ss) value can't be modified.
+// [Solution] - In Case 2, change "if( (Tm.Second > 0) && (Tm.Hour >
+// time->Min ) )" to "if( (Tm.Second > 0) && (Tm.Second > time->Min ) )"
+// [Files changed] - Time.c
+// [Functions changed] - TimeDecrease
+//
+// 12 6/15/11 4:43p Arunsb
+// [TAG] EIP61650
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Cannot edit time field when using new "time" format
+// [RootCause] Default refresh interval set to all the time variables
+// [Solution] Default refresh interval provided only for RTC time
+// variable
+// [Files] time.c, date.c, parse.c and uefihpktool.exe
+//
+// 11 3/09/11 7:23p Madhans
+// [TAG] EIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 10 11/30/10 2:07p Blaines
+// [TAG] - EIP 48979
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- Both Date & Time controls of setup menu do not display
+// gray-out color when the controls are in the gray-out state.
+//
+// [Rootcause] - Improper use of color variable for Date and Time controls
+// in the draw function.
+// [Solution] - Proper use of color variables to handle normal and
+// gray-out state for these controls.
+// [Files] - date.c and time.c
+//
+// 9 11/17/10 3:08p Madhans
+// [TAG] - EIP 48433
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- While editing Date and Time control pressing
+// Pageup/PageDown/Home keys
+// causes to leave Date&Time in the Edit state but changes foucs.
+// [Rootcause] - Default case of Action handling not done for Date and
+// Time controls.
+// [Solution] - Add the Default action handle caes for this controls.
+// [Files] - date.c and time.c
+//
+// 7 11/10/10 7:02p Blaines
+// EIP 47037: Add range checks to properly edit and update date/time.
+//
+// 6 6/04/10 12:53p Blaines
+// Add support for UEFI 2.1 date and time controls
+//
+// 5 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:18a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 2/17/10 7:03p Madhans
+// To suppor readonly control
+//
+// 4 1/09/10 6:46a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 3 6/03/09 11:22a Blaines
+// reverting back to alpha labled version
+//
+// 1 4/28/09 11:07p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 5 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 3/31/09 4:07p Madhans
+// Fix for EDK version
+//
+// 3 2/05/09 10:15a Madhans
+// Style Module created.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Time.c
+//
+// Description: This file contains code to handle Time control operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+TIME_METHODS gTime =
+{
+ TimeCreate,
+ TimeDestroy,
+ TimeInitialize,
+ TimeDraw,
+ TimeHandleAction,
+ TimeSetCallback,
+ TimeSetFocus,
+ TimeSetPosition,
+ TimeSetDimensions,
+ TimeSetAttributes,
+ TimeGetControlHeight
+};
+
+static EFI_TIME EditTime;
+CHAR16 TimeTempNum[3];
+BOOLEAN CheckKeyinHotKeysList(AMI_EFI_KEY_DATA Key);
+VOID _TimeUpdateEntry(TIME_DATA *time);
+EFI_STATUS _TimeHandleActionKeyMouse( TIME_DATA *time, ACTION_DATA *Data);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _TimeDecrease
+//
+// Description: to decrease the time, i.e. Hours/Mins/Secs based on the selection
+//
+// Input: TIME_DATA *time, UINT16 Selection
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _TimeDecrease(TIME_DATA *time )
+{
+ EFI_TIME Tm;
+
+ time->ControlActive =TRUE;
+ //gRT->GetTime(&Tm,NULL);
+ UefiGetTime(&time->ControlData, &Tm);
+
+
+ switch(time->Sel )
+ {
+ case 0:
+ if((Tm.Hour > 0) && (Tm.Hour > time->Min ))
+ Tm.Hour--;
+ else
+ Tm.Hour = /*(time->Max < 23)? (UINT8)time->Max :*/ 23 ; //EIP 77070
+ StrZeroPad(Tm.Hour, TimeTempNum); //Update the static time string
+ break;
+ case 1:
+ if( (Tm.Minute > 0) && (Tm.Minute > time->Min ))
+ Tm.Minute--;
+ else
+ Tm.Minute = /*(time->Max < 59)? (UINT8)time->Max :*/ 59; //EIP 77070
+ StrZeroPad(Tm.Minute, TimeTempNum); //Update the static time string
+ break;
+ case 2:
+ if( (Tm.Second > 0) && (Tm.Second > time->Min ) )
+ Tm.Second--;
+ else
+ Tm.Second = /*(time->Max < 59)? (UINT8)time->Max :*/ 59; //EIP 77070
+ StrZeroPad(Tm.Second, TimeTempNum); //Update the static time string
+ break;
+ }
+
+ UefiSetTime(&time->ControlData, &Tm);
+ //gRT->SetTime(&Tm);
+ time->ControlActive =FALSE;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _TimeIncrease
+//
+// Description: to increase the time, i.e. Hours/Mins/Secs based on the selection
+//
+// Input: TIME_DATA *time, UINT16 Selection
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _TimeIncrease(TIME_DATA *time )
+{
+ EFI_TIME Tm;
+ time->ControlActive =TRUE;
+ //gRT->GetTime(&Tm,NULL);
+ UefiGetTime(&time->ControlData, &Tm);
+
+ switch(time->Sel )
+ {
+ case 0:
+ if(Tm.Hour < 23)
+ Tm.Hour++;
+ else
+ Tm.Hour =0;
+ StrZeroPad(Tm.Hour, TimeTempNum); //Update the static time string
+ break;
+ case 1:
+ if(Tm.Minute <59)
+ Tm.Minute++;
+ else
+ Tm.Minute =0;
+ StrZeroPad(Tm.Minute, TimeTempNum); //Update the static time string
+ break;
+ case 2:
+ if(Tm.Second <59)
+ Tm.Second++;
+ else
+ Tm.Second =0;
+ StrZeroPad(Tm.Second, TimeTempNum); //Update the static time string
+ break;
+ }
+
+ //gRT->SetTime(&Tm);
+ UefiSetTime(&time->ControlData, &Tm);
+ time->ControlActive =FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeCreate
+//
+// Description: this function uses the create function of control
+// and creates and sets the timer
+//
+// Input: TIME_DATA **object
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeCreate( TIME_DATA **object )
+{
+ EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
+
+ if ( *object == NULL )
+ {
+ *object = EfiLibAllocateZeroPool( sizeof(TIME_DATA) );
+
+ if ( *object == NULL )
+ return Status;
+ }
+
+ Status = gControl.Create(object );
+ if ( ! EFI_ERROR(Status) )
+ (*object)->Methods = &gTime;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeDestroy
+//
+// Description: this function uses the destroy function of control
+// and destroys the timer
+//
+// Input: TIME_DATA *time, BOOLEAN freeMem
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeDestroy( TIME_DATA *time, BOOLEAN freeMem )
+{
+ if(NULL == time)
+ return EFI_SUCCESS;
+
+ gControl.Destroy( (CONTROL_DATA *)time, FALSE );
+
+ if ( freeMem )
+ {
+ MemFreePointer((VOID **)&time->EditTime);
+ MemFreePointer( (VOID **)&time );
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeInitialize
+//
+// Description: this function uses the Initialize function of control
+// and initializes the time
+//
+// Input: TIME_DATA *time, VOID *data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeInitialize( TIME_DATA *time, VOID *data )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ Status = gControl.Initialize( (CONTROL_DATA *)time, data );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // add extra initialization here...
+ time->ControlData.ControlHelp = UefiGetHelpField(time->ControlData.ControlPtr);
+ time->Interval = (UINT8)time->ControlData.ControlFlags.ControlRefresh;
+ time->LabelMargin = (UINT8)gControlLeftMargin;
+ time->Sel=0;
+ time->ControlFocus=FALSE;
+ time->ControlActive = FALSE;
+ time->EditTime = EfiLibAllocateZeroPool( sizeof(EFI_TIME) );
+ if ( time->EditTime == NULL )
+ Status = EFI_OUT_OF_RESOURCES;
+
+ SetControlColorsHook(NULL, NULL,
+ NULL, &(time->FGColor),
+ &(time->SelBGColor), &(time->SelFGColor),
+ &(time->BGColor), &(time->NSelFGColor),
+ NULL, &(time->LabelFGColor),
+ &(time->NSelLabelFGColor),
+ NULL, NULL,
+ NULL, NULL);
+
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeDraw
+//
+// Description: function to draw time with attributes
+//
+// Input: TIME_DATA *time
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeDraw( TIME_DATA *time )
+{
+ CHAR16 *t,text[50];
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT8 ColorTime = time->NSelFGColor ;
+ UINT8 ColorLabelTime = (time->ControlFocus)? time->LabelFGColor : time->NSelLabelFGColor ;
+ CHAR16 txt[6];
+
+ if(!(time->ControlActive))
+ //Status= gRT->GetTime(&EditTime,NULL);
+ UefiGetTime(&time->ControlData, time->EditTime);
+
+
+ // check conditional ptr if necessary
+ //EIP 75486 Support grayout condition for readonly controls
+ //if ( time->ControlData.ControlConditionalPtr != 0x0 )
+ //{
+ switch( CheckControlCondition( &time->ControlData ) )
+ {
+ case COND_NONE:
+ break;
+ case COND_GRAYOUT:
+ Status = EFI_WARN_WRITE_FAILURE;
+ ColorTime = ColorLabelTime = CONTROL_GRAYOUT_COLOR;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ break;
+ }
+ //}
+ t = HiiGetString( time->ControlData.ControlHandle, UefiGetPromptField(time->ControlData.ControlPtr));
+ //EIP-75351 Suppress the warnings from static code analyzer
+ if (NULL == t){
+ t = EfiLibAllocateZeroPool(2*sizeof(CHAR16));
+ if(!t)
+ return EFI_OUT_OF_RESOURCES;
+ EfiStrCpy(t,L" ");
+ }
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(time->Height>1 && IsTSEMultilineControlSupported())
+ {
+ DrawMultiLineStringWithAttribute( time->Left , time->Top,
+ (UINTN)(time->LabelMargin - time->Left),(UINTN) time->Height,
+ t,time->BGColor | ColorLabelTime );
+ }
+ else
+ {
+ // boundary overflow check
+ if ( EfiStrLen( t ) > (UINTN)(time->LabelMargin - time->Left )/*21*/ )
+ t[time->LabelMargin - time->Left ] = L'\0';
+
+ DrawStringWithAttribute( time->Left , time->Top, (CHAR16*)t,
+ time->BGColor | ColorLabelTime );
+ }
+ MemFreePointer((VOID **)&t);
+
+ EfiStrCpy(text,L"[ : : ]");
+ DrawStringWithAttribute( time->Left + time->LabelMargin, time->Top, (CHAR16*)text,
+ time->BGColor | ColorTime );
+
+ DrawStringWithAttribute( time->Left + time->LabelMargin +1 , time->Top,
+ ( (time->Sel==0) && (time->ControlActive == TRUE ) ) ? TimeTempNum :StrZeroPad( time->EditTime->Hour,txt),
+ (UINT8)((((time->Sel == 0) && (time->ControlFocus)) ?
+ time->SelBGColor | time->SelFGColor :
+ time->BGColor | ColorTime )) );
+
+ DrawStringWithAttribute( time->Left + time->LabelMargin + 4 , time->Top,
+ ( (time->Sel==1) && (time->ControlActive == TRUE ) ) ? TimeTempNum :StrZeroPad( time->EditTime->Minute,txt),
+ (UINT8)( (((time->Sel == 1) && (time->ControlFocus)) ?
+ time->SelBGColor | time->SelFGColor :
+ time->BGColor | ColorTime )) );
+
+ DrawStringWithAttribute( time->Left + time->LabelMargin +7 , time->Top,
+ ( (time->Sel==2) && (time->ControlActive == TRUE ) ) ? TimeTempNum :StrZeroPad( time->EditTime->Second,txt),
+ (UINT8)( (((time->Sel == 2) && (time->ControlFocus)) ?
+ time->SelBGColor | time->SelFGColor :
+ time->BGColor | ColorTime )) );
+
+ FlushLines(time->Top, time->Top);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeHandleAction
+//
+// Description: function to handle the actions of time
+//
+// Input: TIME_DATA *time, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeHandleAction( TIME_DATA *time, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( Data->Input.Type == ACTION_TYPE_TIMER )
+ {
+ if(time->ControlActive)
+ return Status;
+
+ if (0 == time->ControlData.ControlFlags.ControlRefresh) //EIP61650 If control not has refresh no need of proceeding
+ return Status;
+
+ if(IsActiveControlPresent(gApp->PageList[gApp->CurrentPage]))
+ return Status;
+
+ if( --(time->Interval) == 0 )
+ {
+ // initialize the interval
+ time->Interval = (UINT8)(time->ControlData.ControlFlags.ControlRefresh);
+ return UefiRefershQuestionValueNvRAM(&(time->ControlData));
+ }
+ else
+ return Status;
+ }
+
+ if ( ! time->ControlFocus )
+ return Status;
+
+ if (( Data->Input.Type == ACTION_TYPE_KEY )||(Data->Input.Type == ACTION_TYPE_MOUSE))
+ return _TimeHandleActionKeyMouse(time, Data);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _TimeHandleActionKeyMouse
+//
+// Description: function to handle the action key of time
+//
+// Input: TIME_DATA *time, ACTION_DATA *Data
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _TimeHandleActionKeyMouse(TIME_DATA *time, ACTION_DATA *Data)
+{
+ CONTROL_ACTION Action = ControlActionUnknown;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_TIME Tm;
+ AMI_EFI_KEY_DATA key = Data->Input.Data.AmiKey;
+ if(time->ControlData.ControlFlags.ControlReadOnly)
+ return EFI_UNSUPPORTED;
+
+
+ //Get time
+ //gRT->GetTime( &Tm, NULL );
+ UefiGetTime(&time->ControlData, &Tm);
+
+
+ //Get mapping
+ if(Data->Input.Type == ACTION_TYPE_KEY)
+ {
+ Action = MapControlKeysHook(key);
+ }
+ else if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ {
+ if(ControlActionSelect == MapControlMouseActionHook(&Data->Input.Data.MouseInfo))
+ {
+ //EIP-123727 check whether MouseTop is within the Height and Width of Time Control or not
+ if( (Data->Input.Data.MouseInfo.Top >= (UINT32)time->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(time->Top+time->Height)) &&
+ (Data->Input.Data.MouseInfo.Left >= (UINT32)time->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(time->Left+time->Width))
+ )
+ {
+ Action = ControlActionSelect;
+ }
+ }
+ }
+
+ switch(Action)
+ {
+ case ControlActionNextLeft:
+//#if !SETUP_STYLE_EZPORT
+#if SETUP_STYLE_AWARD
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+
+ if ( time->Sel == 0 )
+ time->Sel = 2;
+ else
+ time->Sel--;
+
+ Status = EFI_SUCCESS;
+ break;
+#endif
+
+ case ControlActionNextRight:
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+
+#if SETUP_STYLE_AWARD
+ if ( time->Sel == 2 )
+ time->Sel = 0;
+ else
+ time->Sel++;
+
+ Status = EFI_SUCCESS;
+#endif
+ break;
+
+ case ControlActionNextUp:
+ case ControlActionNextDown:
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+ break;
+
+ case ControlActionAbort:
+ if ( time->ControlActive )
+ {
+ time->ControlActive = FALSE;
+ Status = EFI_SUCCESS;
+ }
+ break;
+
+ case ControlActionSelect:
+ if(Data->Input.Type == ACTION_TYPE_MOUSE)
+ NumericSoftKbdInit();
+ _TimeUpdateEntry(time);
+ _TimeUpdateHelp( time );
+// for EZPORT: expressely to go to next entry in time control after hitting enter
+//#if ! SETUP_STYLE_EZPORT
+#if SETUP_STYLE_AWARD
+ break;
+#endif
+ case ControlActionNextSelection:
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+
+ if ( time->Sel == 2 )
+ time->Sel = 0;
+ else
+ time->Sel++;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionPrevSelection:
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+
+ if ( time->Sel == 0 )
+ time->Sel = 2;
+ else
+ time->Sel--;
+
+ Status = EFI_SUCCESS;
+ break;
+ case ControlActionDecreament:
+ if(time->ControlActive)
+ {
+ _TimeUpdateEntry(time);
+ }
+ _TimeDecrease( time );
+ time->ControlActive = TRUE; //Set control state to active, so that control string is updated with the static time string
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionIncreament:
+ if(time->ControlActive)
+ {
+ _TimeUpdateEntry(time);
+ }
+ _TimeIncrease( time );
+ time->ControlActive = TRUE; //Set control state to active, so that control string is updated with the static time string
+ Status = EFI_SUCCESS;
+ break;
+
+ case ControlActionNumeric:
+ if( !(time->ControlActive))
+ {
+ time->ControlActive = TRUE;
+ switch(time->Sel)
+ {
+ case 0: //month
+ SPrint(TimeTempNum,sizeof(TimeTempNum),L"%d", time->EditTime->Hour);
+ break;
+ case 1: // day
+ SPrint(TimeTempNum,sizeof(TimeTempNum),L"%d", time->EditTime->Minute);
+ break;
+ case 2: //year
+ SPrint(TimeTempNum,sizeof(TimeTempNum),L"%d", time->EditTime->Second );
+ break;
+ }
+ }
+
+
+ if(EfiStrLen(TimeTempNum)>1)
+ TimeTempNum[0] = TimeTempNum[1];
+
+ TimeTempNum[1] = key.Key.UnicodeChar;
+ Status = gTime.Draw(time);
+ break;
+ default:
+ if ( time->ControlActive )
+ _TimeUpdateEntry(time);
+ break;
+ }
+
+ if( (((!time->ControlActive)||(!IsMouseClickedonSoftkbd())) && (TSEMouseIgnoreMouseActionHook() == TRUE) )&&
+ (((Data->Input.Type == ACTION_TYPE_KEY) &&
+ ((Action == ControlActionNextLeft) ||(Action == ControlActionNextRight) ||(Action == ControlActionNextUp) ||(Action == ControlActionNextDown) ||(Action == ControlActionPageUp) ||(Action == ControlActionPageDown) ||(Action == ControlActionAbort) ||(Action == ControlActionHome) ||(Action == ControlActionEnd) ||(CheckKeyinHotKeysList(key))) ) ||
+ ((Data->Input.Type == ACTION_TYPE_MOUSE)&&((!((Data->Input.Data.MouseInfo.Top >= (UINT32)time->Top) && (Data->Input.Data.MouseInfo.Top < (UINT32)(time->Top+time->Height))&&(Data->Input.Data.MouseInfo.Left >= (UINT32)time->Left) && (Data->Input.Data.MouseInfo.Left < (UINT32)(time->Left+time->Width))))||(Action == ControlActionAbort))))
+ )
+ {
+ NumericSoftKbdExit();//EIP62763 : Check for softkbd presence and existing the numeric softkbd
+ }
+ _TimeUpdateHelp( time );
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeSetCallback
+//
+// Description: Function to set callback.
+//
+// Input: TIME_DATA *time, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeSetCallback( TIME_DATA *time, OBJECT_DATA *container, OBJECT_CALLBACK callback, VOID *cookie )
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeSetFocus
+//
+// Description: Function to set focus.
+//
+// Input: TIME_DATA *time, BOOLEAN focus
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeSetFocus(TIME_DATA *time, BOOLEAN focus)
+{
+ if(focus != FALSE)
+ {
+ if ( CheckControlCondition( &time->ControlData ) )
+ return EFI_UNSUPPORTED;
+ }
+
+ if( !(time->ControlFocus && focus) )
+ {
+ time->ControlFocus = focus;
+ // set the selected field to Hour
+ time->Sel = 0;
+ _TimeUpdateHelp( time );
+ }
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeSetPosition
+//
+// Description: Function to set position.
+//
+// Input: TIME_DATA *time, UINT16 Left, UINT16 Top
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeSetPosition(TIME_DATA *time, UINT16 Left, UINT16 Top )
+{
+ return gControl.SetPosition( time, Left, Top );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeSetDimensions
+//
+// Description: Function to set time dimension.
+//
+// Input: TIME_DATA *time, UINT16 Width, UINT16 Height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeSetDimensions(TIME_DATA *time, UINT16 Width, UINT16 Height )
+{
+ return gControl.SetDimensions( time, Width, Height );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeSetAttributes
+//
+// Description: Function to set time attributes.
+//
+// Input: TIME_DATA *time, UINT8 FGColor, UINT8 BGColor
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeSetAttributes(TIME_DATA *time, UINT8 FGColor, UINT8 BGColor )
+{
+ return gControl.SetAttributes( time, FGColor, BGColor );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: TimeGetControlHeight
+//
+// Description: Function to set time height.
+//
+// Input: TIME_DATA *time, frame, UINT16 *height
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS TimeGetControlHeight(TIME_DATA *time,VOID *frame , UINT16 *height)
+{
+ //EIP-72610 TSE_MULTILINE_CONTROLS moved to binary
+ if(IsTSEMultilineControlSupported())
+ {
+ CHAR16 *newText = NULL,*text=NULL;
+ UINT16 Width;
+
+ *height = 1;
+ Width = (UINT16)(time->LabelMargin - (((FRAME_DATA*)frame)->FrameData.Left + (UINT8)gControlLeftPad));
+ text = HiiGetString( time->ControlData.ControlHandle, UefiGetPromptField(time->ControlData.ControlPtr));
+
+ newText = StringWrapText( text, Width, height );
+
+ (*height) = (*height) ? (*height):1;
+
+ MemFreePointer( (VOID **)&newText );
+ MemFreePointer( (VOID **)&text );
+ }
+ else
+ {
+ *height = 1;
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _TimeUpdateHelp
+//
+// Description: function to update the help of time
+//
+// Input: TIME_DATA *time
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _TimeUpdateHelp( TIME_DATA *time )
+{
+ UINT16 helpToken = time->ControlData.ControlHelp;
+
+ switch ( time->Sel )
+ {
+ case 0:
+ UefiGetDateTimeDetails(time->ControlData.ControlPtr,AMI_TIME_HOUR,&helpToken,&time->Min,&time->Max);
+ break;
+
+ case 1:
+ UefiGetDateTimeDetails(time->ControlData.ControlPtr,AMI_TIME_MIN,&helpToken,&time->Min,&time->Max);
+ break;
+
+ case 2:
+ UefiGetDateTimeDetails(time->ControlData.ControlPtr,AMI_TIME_SEC,&helpToken,&time->Min,&time->Max);
+ break;
+ default:
+ break;
+ }
+
+ time->ControlData.ControlHelp = helpToken;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _TimeUpdateEntry
+//
+// Description: function to update the entries in Time
+//
+// Input: TIME_DATA *time
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _TimeUpdateEntry(TIME_DATA *time)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ if ( time->ControlActive )
+ {
+ // focus stays on the selection becuase we just edited it
+ switch ( time->Sel )
+ {
+ case 0:
+ time->EditTime->Hour = (UINT8)atoi(TimeTempNum, 10);
+ break;
+ case 1:
+ time->EditTime->Minute = (UINT8)atoi(TimeTempNum, 10);
+ break;
+ case 2:
+ time->EditTime->Second = (UINT8)atoi(TimeTempNum, 10);
+ break;
+ }
+
+ UefiPreControlUpdate(&(time->ControlData));
+ UefiSetTime(&time->ControlData, time->EditTime);
+ //For interactive time control invoke the formcallback functions
+ if(UefiIsInteractive(&time->ControlData)){//code for callback based on interactive time control
+ UINT8 Flags = UefiGetFlagsField(time->ControlData.ControlPtr) ;
+
+
+ if(CheckTimeFlags(Flags))
+ {
+ //for storage type QF_TIME_STORAGE_NORMAL generate time in EFI_HII_TIME format
+
+ //Call the callbacks passing the generated input value and value size
+ Status = CallFormCallBack(&time->ControlData, UefiGetControlKey(&time->ControlData), 0, AMI_CALLBACK_CONTROL_UPDATE);
+ } //else {
+ //This case would be handled by UefiSetTime() outside
+ //since this case is directly updated using the runtime services
+ //}
+ }
+ //gRT->SetTime( &EditTime );
+ time->ControlActive = FALSE;
+ }
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/TseLite/variable.c b/EDK/MiniSetup/TseLite/variable.c
new file mode 100644
index 0000000..757d324
--- /dev/null
+++ b/EDK/MiniSetup/TseLite/variable.c
@@ -0,0 +1,1488 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/variable.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 34 $
+//
+// $Date: 2/11/14 8:44p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite/variable.c $
+//
+// 34 2/11/14 8:44p Arunsb
+// [TAG] EIP135606
+// [Category] Bug Fix
+// [Symptom:] SAS Driver Issues.
+// [Root Cause] In the function CopyNvramVariableList, the buffered value
+// for DynamicPageCount variable is updated from nvram when copying from
+// one variable list to another variable list.
+// [Solution] In the function CopyNvramVariableList, update the buffered
+// value for DynamicPageCount from the cached value of the variable.
+// [Files] variable.c
+//
+// 33 7/02/13 10:09a Premkumara
+// [TAG] EIP120011
+// [Category] Improvement
+// [Description] Variable BootOrder and LegacyDevOrder need
+// fool-proofing function when TSE load variabled
+// [Files] Bbs.c, Boot.c, Callback.c, TseLiteHelper.c, Variable.c
+//
+// 32 5/22/13 10:47a Arunsb
+// General checks added
+//
+// 31 10/18/12 6:02a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 14 10/10/12 12:38p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 29 9/17/12 6:20a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 27 9/11/12 3:40p Blaines
+// [TAG] - EIP 100429
+// [Category] - Function Request
+// [Synopsis] - "Save and exit" pop up message appear when viewing BBS
+// priorities in BIOS menu
+// [Root cause] - The function SetupConfigModifiedHook is called whenever
+// a variable is modified from Setup.
+// [Solution] - Prevent calls to SetupConfigModifiedHook for variables
+// that don't affect setup changes.
+// [Files] - Variable.c
+//
+// 26 8/29/12 8:52a Premkumara
+// [TAG] EIP93954
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Boot Options get corrupted on Loading defaults when
+// TseDefaultBootOrder is added.
+// [RootCause] Legacy dev order is not updated properly.
+// [Solution] Restore Default issue
+// [Files] variable.c
+//
+// 25 5/09/12 7:39a Rajashakerg
+// [TAG] EIP71351
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System hangs with SETUP_RUNTIME_IFR_PROCESSING enabled and
+// Intel GIG Undi driver
+// [RootCause] The issue is occured when driver is loaded from shell the
+// variable is not updated propely in setup
+// [Solution] If the variable ist is null then clearing the cache values
+// and updaitng the cache with new list
+// [Files] variable.c
+//
+// 24 4/27/12 7:52a Premkumara
+// [TAG] EIP81402
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDD Port Number is not properly updated after adding
+// "TseDefaultBootOrder"
+// [RootCause] when GROUP_BOOT_OPTIONS_BY_TAG=0 BBSList->Name is not
+// returned properly
+// [Solution] Returned BBSList->Name properly
+// [Files] bbs.c, variable.c
+//
+// 23 1/24/12 4:42a Arunsb
+// [TAG] EIP81581
+// [Category] Improvement
+// [Description] Default driver order support
+// [Files] globals.c, addbootoption.c, callback.c, minisetupext.h and
+// variable.c
+//
+// 22 1/20/12 5:07a Rajashakerg
+// [TAG] EIP77875
+// [Category] Improvement
+// [Description] Minisetup: Memory leaks in text browser
+// [Files] Uefi21Wapper.c, hiistring21.c, variable.c
+//
+// 21 12/16/11 1:36a Arunsb
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage.
+// Upto TSE entering into setup the
+// variables are read from
+// NVRAM in setup it will read from
+// temporary buffer.
+//
+// 20 12/05/11 5:43a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 19 12/02/11 8:21a Arunsb
+// [TAG] EIP75524
+// [Category] Improvement
+//
+// 18 11/30/11 11:29p Arunsb
+// [TAG] EIP75588
+// Build error correction
+//
+// 17 11/30/11 1:31p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 16 11/30/11 6:39a Premkumara
+// [TAG] EIP71351
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup Crash when iSCSI is loaded
+// [RootCause] Aptio giving length as 0xe(matches size of
+// EFI_IFR_ONE_OF_OPTION) but in latest EDKII driver it is 0x1c.
+// [Solution] change the length as j += ((EFI_IFR_OP_HEADER*)(buff + i +
+// j))->Length;
+// [Files] Parse.c, Hii.c, Variable.c, Minisetupext.c
+//
+// 15 11/23/11 5:11a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 14 11/13/11 1:09p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 13 10/31/11 9:37a Rajashakerg
+// [TAG] EIP71120,71512
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] BIOS gets stuck in infinite loop On enabling
+// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
+// disabled in Setup & BBS table but in second boot the correct device is
+// disabled in both places.
+// [Solution] Hidden option handled properly.
+// [Files] TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
+// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
+//
+// 12 9/28/11 12:38p Arunsb
+// [TAG] EIP69143
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] CPU exception
+// [RootCause] Accessing gVariableList even it is NULL in
+// VarUpdateVariable function.
+//
+// [Solution] gVariableList initialized by calling VarLoadVariables
+// [Files] TseLite\variable.c
+//
+// 10 8/23/11 1:25p Arunsb
+// In _VarUpdate function if VarGetNvram returns NULL then no need to
+// update the buffer
+//
+// 9 5/11/11 12:07p Madhans
+// [TAG] EIP54219
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Language Popup Control will not update correctly
+// CHINESE_TRAD,CHINESE_SIMP used togather.
+// [RootCause] The Current Language is not read from the NVRAM fully and
+// compared. It was reading only 2 bytes for Lanugage comparition.
+// [Solution] _VarGetRealValue function fixed to compare the Current
+// Lang from NVRAM is read and compared with supported languages.
+// [Files] variable.c
+//
+// 8 3/23/11 8:38p Blaines
+// [TAG] - EIP 23601
+// [Category]- Enhancement
+// [Symptom]- Add support for OEM special controls.
+// [Files] - AmiTse.sdl, CommonHelper.c, Setup.ini, UefiSetup.ini,
+// AmiVfr.h, minisetup.h, minisetup.sdl, variable.c, special.c
+//
+// 7 1/07/11 12:23a Mallikarjunanv
+// [TAG] EIP51619
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Changing the option in the "HDD BBS Priority" option not
+// reflected in the boot options list.
+// [RootCause] Boot page is not updated properly with changes made by
+// BBS HDD BBS Priority
+// [Solution] Updated the boot page with changes made by BBS HDD BBS
+// Priority
+// [Files] special.c, variable.c
+//
+// 6 12/24/10 12:56p Mallikarjunanv
+// [TAG] EIP 46296
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] HDD BBS priority option having two same entries in its list
+// (with 2 SATA HDD, 1 USB drive emulated as FDD)
+// [RootCause] The defaults for BBS order variable not initialized
+// properly.
+// [Solution] Fixed the issue by properly initializing the defaults for
+// BBS order variable.
+//
+// [Files] variable.c
+//
+// 5 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 9 9/13/10 4:43p Madhans
+// BBSReOrderDefultLegacyDevOrder() function checks if the
+// DefaultLegacyDevOrder can be considered or not. (if the device list is
+// different from LegacyDevOrder then DefaultLegacyDevOrder is ignored.)
+// on that case make the Size of gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ]
+// also 0.
+//
+// 8 2/19/10 8:19a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/18/10 8:26p Madhans
+// To take care NOGET and NOSET Attribs from Exetendedflags of
+// VariableInfo
+//
+// 6 1/27/10 9:30a Mallikarjunanv
+// EIP-24971: Tse features without tse sources support update for token
+// SETUP_SUPPORT_PLATFORM_LANG_VAR
+//
+// 5 1/09/10 7:10a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 9/15/09 9:52a Sudhirv
+// //to Ignore the DefaultLegacyDevOrder if is size is not matching with
+// LegacyDevOder.
+//
+// 3 6/23/09 6:53p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:07p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:13p Madhans
+// UEFI 2.1 Support
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: variable.c
+//
+// Description: This file contains code to handle variable operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+extern UINTN gSetupCount;
+
+//---------------------------------------------------------------------------
+// Variables
+//---------------------------------------------------------------------------
+NVRAM_VARIABLE *gCurrNvramVarList = (NVRAM_VARIABLE *)NULL;
+UINTN gCurrNvramVarCount = 0;
+
+CHAR8 *gPrevLanguage;
+UINTN gPrevLangSize = 0;
+BOOLEAN gSetupUpdated = FALSE;//EIP:51619 Flag which represents the setup update
+
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+EFI_STATUS OEMSpecialUpdateOneOf(UINT16 newOption,UINT32 *offset,UINTN *size, VOID OUT **buffer);
+#endif // SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+
+UINT8 IsBootOptionsGroupingEnabled (void); //EIP-93954 To Restore BootOption default issue
+
+//EIP 76381 : START
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetNvramVariableList
+//
+// Description: Gets all system variables
+//
+// Input: NVRAM_VARIABLE **RetNvramVarList - Returns pointer to the var list
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetNvramVariableList(NVRAM_VARIABLE **RetNvramVarList)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ NVRAM_VARIABLE *nvVarlist = (NVRAM_VARIABLE *)NULL;
+ UINT32 index = 0;
+
+ if ( (gCurrNvramVarList == NULL) || (gVariables->VariableCount != gCurrNvramVarCount) || (gPostStatus <= TSE_POST_STATUS_ENTERING_TSE))
+ {
+ gCurrNvramVarList = EfiLibAllocateZeroPool(gVariables->VariableCount * sizeof(NVRAM_VARIABLE));
+ if(gCurrNvramVarList == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ // Get the Current Values from the NVRAM
+ nvVarlist = gCurrNvramVarList;
+ for(index = 0; index < gVariables->VariableCount; index++, nvVarlist++){
+ nvVarlist->Buffer = VarGetNvram(index, &nvVarlist->Size);
+ if ((0 != nvVarlist->Size) && (NULL == nvVarlist->Buffer))
+ {
+ nvVarlist->Buffer = EfiLibAllocateZeroPool (nvVarlist->Size);
+ }
+ }
+ gCurrNvramVarCount = gVariables->VariableCount;
+ }
+ status = CopyNvramVariableList(gCurrNvramVarList, RetNvramVarList);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CleanTempNvramVariableList()
+//
+// Description: Clean up the current retrive variable list
+//
+// Input: None
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanTempNvramVariableList()
+{
+ NVRAM_VARIABLE *nvVarlist = (NVRAM_VARIABLE *)NULL;
+ UINT32 index = 0;
+
+ if(gCurrNvramVarList != NULL){
+ nvVarlist = gCurrNvramVarList;
+ for(index = 0; index < gCurrNvramVarCount; index++, nvVarlist++){
+ MemFreePointer(&nvVarlist->Buffer);
+ }
+ }
+ gCurrNvramVarCount = 0;
+ MemFreePointer(&gCurrNvramVarList);
+ gCurrNvramVarList = (NVRAM_VARIABLE *)NULL;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CopyNvramVariableList
+//
+// Description: Copies variable buffer from one var list to another var list
+//
+// Input: NVRAM_VARIABLE *SrcVarList - Source variable list
+// NVRAM_VARIABLE **DestVarList - Destination variable list
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CopyNvramVariableList(NVRAM_VARIABLE *SrcVarList, NVRAM_VARIABLE **DestVarList)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 index = 0;
+ NVRAM_VARIABLE *varPtr = (NVRAM_VARIABLE *)NULL;
+ NVRAM_VARIABLE *currVarPtr = (NVRAM_VARIABLE *)NULL;
+
+ *DestVarList = (NVRAM_VARIABLE *)EfiLibAllocateZeroPool(gVariables->VariableCount * sizeof(NVRAM_VARIABLE));
+ if(*DestVarList == NULL){
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ varPtr = *DestVarList;
+ currVarPtr = SrcVarList;
+ for(index = 0; index < gVariables->VariableCount; index++, varPtr++, currVarPtr++)
+ {
+ if((varPtr->Buffer == NULL) && (currVarPtr != NULL) && (currVarPtr->Size != 0))
+ {
+ varPtr->Buffer = EfiLibAllocatePool(currVarPtr->Size);
+ if(varPtr->Buffer == NULL){
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ } else{
+ if (currVarPtr->Buffer)
+ {
+ //EIP-135606: Update the buffered value for DynamicPageCount from the cache.
+ if(index == VARIABLE_ID_DYNAMIC_PAGE_COUNT)
+ VarGetValue( VARIABLE_ID_DYNAMIC_PAGE_COUNT, 0, sizeof(UINT16), currVarPtr->Buffer );
+ MemCopy( varPtr->Buffer, currVarPtr->Buffer, currVarPtr->Size );
+ }
+ varPtr->Size = currVarPtr->Size;
+ }
+ }
+ }
+DONE:
+ return status;
+}
+//EIP 76381 : END
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarLoadVariables
+//
+// Description: function to load the variables
+//
+// Input: VOID **list, NVRAM_VARIABLE *defaultList
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarLoadVariables( VOID **list, NVRAM_VARIABLE *defaultList )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 index;
+
+ NVRAM_VARIABLE *varPtr;
+ NVRAM_VARIABLE *defaultVar = defaultList;
+
+ if(*list != NULL)//EIP 71351 : If the list is null then clearing the cache values and updaitng the cache with new list
+ CleanTempNvramVariableList();
+ MemFreePointer( (VOID **)list );
+
+ if( ( ! gVariables ) || ( gVariables->VariableCount == 0 ) ) // fatal error
+ while(1);
+
+ Status = GetNvramVariableList((NVRAM_VARIABLE **)list);
+ if(EFI_ERROR(Status)){
+ goto DONE;//EIP 76381 :Performance Improving of variable data load and usage
+ }
+
+ varPtr = *list;
+ for ( index = 0; index < gVariables->VariableCount; index++, varPtr++, defaultVar++ )
+ {
+ if ( ( varPtr->Buffer == NULL ) && ( defaultList != NULL ) && ( defaultVar->Size != 0 ) )
+ {
+ varPtr->Buffer = EfiLibAllocatePool( defaultVar->Size );
+ if ( varPtr->Buffer == NULL )
+ Status = EFI_OUT_OF_RESOURCES;
+ else
+ {
+ MemCopy( varPtr->Buffer, defaultVar->Buffer, defaultVar->Size );
+ varPtr->Size = defaultVar->Size;
+ }
+ }
+
+ if ( varPtr->Buffer == NULL ) // If varPtr->Buffer is still NULL Skip the variable.
+ continue;
+
+ //Introduce DISABLED_BOOT_OPTION in place of disabled options
+ //for mem copy of BootOrder and BBSOrder
+ if(gBootData && (VARIABLE_ID_BOOT_ORDER == index))
+ {
+ UINT16 *BootOrder = (UINT16 *)varPtr->Buffer;
+ BOOT_DATA *pBootData;
+ UINTN i;
+
+ for(i=0; i<(varPtr->Size / sizeof(UINT16)); i++)
+ {
+ pBootData = BootGetBootData(BootOrder[i]); //Should yield a valid option
+ if(NULL != pBootData) //EIP-75352 Suppress the warnings from static code analyzer
+ {
+ if ( (!(pBootData->Active & LOAD_OPTION_ACTIVE)) && (!(pBootData->Active & LOAD_OPTION_HIDDEN)) )
+ BootOrder[i] = DISABLED_BOOT_OPTION;
+ }
+ }
+ }
+ //Introduce DISABLED_DRIVER_OPTION in place of disabled options
+ //Change the DriverOrder cache
+ else if (gDriverData && (VARIABLE_ID_DRIVER_ORDER == index)) //EIP70421 & 70422 Support for driver order
+ {
+ UINT16 *DriverOrder = (UINT16 *)varPtr->Buffer;
+ BOOT_DATA *pDriverData;
+ UINTN i;
+
+ for (i = 0; i < (varPtr->Size / sizeof (UINT16)); i++)
+ {
+ pDriverData = DriverGetDriverData (DriverOrder[i]); //Should yield a valid option
+ if (pDriverData)
+ {
+ if ( (!(pDriverData->Active & LOAD_OPTION_ACTIVE)) && (!(pDriverData->Active & LOAD_OPTION_HIDDEN)) )
+ DriverOrder [i] = DISABLED_DRIVER_OPTION;
+ }
+ }
+ }
+ else if(VARIABLE_ID_BBS_ORDER == index)
+ {
+ BBS_ORDER_TABLE *TypeEntry, *TSEDevOrder = (BBS_ORDER_TABLE *) varPtr->Buffer;
+ UINTN i,j,count;
+
+ TypeEntry = TSEDevOrder;
+ for(i=0; i < varPtr->Size;)
+ {
+ if ( ( TypeEntry->Length >= varPtr->Size) || (0 == TypeEntry->Length) ) //EIP-120011
+ {
+ break;
+ }
+
+ count = TypeEntry->Length / sizeof(UINT16) - 1;
+
+ for(j=0; j < count; j++)
+ {
+ if(TypeEntry->Data[j] & BBS_ORDER_DISABLE_MASK)
+ TypeEntry->Data[j] = DISABLED_BOOT_OPTION;
+ }
+
+ count = sizeof(UINT32) + TypeEntry->Length;
+ TypeEntry = (BBS_ORDER_TABLE *)((UINTN)TypeEntry + count);
+ i += count;
+ }
+ }
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarBuildDefaults
+//
+// Description: function to build the default variables
+//
+// Input: VOID
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarBuildDefaults( VOID )
+{
+ EFI_STATUS Status;
+
+ UINT8 *newBuffer = NULL;
+ UINT8 *DefDrvBuffer = NULL;
+ UINTN size = 0;
+
+ Status = VarBuildAMIDefaults();
+
+ if(Status == EFI_UNSUPPORTED)
+ {
+ Status = HiiLoadDefaults( (VOID **)&gFailsafeDefaults,(UINT32) HiiGetManufactuingMask() ); // Allocates Space and filles
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ Status = HiiLoadDefaults( (VOID **)&gOptimalDefaults, (UINT32) HiiGetDefaultMask() ); // Allocates Space and filles
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ }
+
+ //EIP-46296: reset default values of BBS order variable.
+ if ( gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer != NULL ) {
+ MemFreePointer( (VOID **) &gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer );
+ }
+ if ( gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer != NULL ) { //EIP70421 & 70422 Support for driver order
+ MemFreePointer( (VOID **) &gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer );
+ }
+ gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer = gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer = gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer = NULL;
+ gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Size = gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Size = gOptimalDefaults[ VARIABLE_ID_DRIVER_ORDER ].Size = 0;
+
+ if ( gFailsafeDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer != NULL ) {
+ MemFreePointer( (VOID **) &gFailsafeDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer );
+ }
+ if ( gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer != NULL ) {
+ MemFreePointer( (VOID **) &gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer );
+ }
+
+ gFailsafeDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer = gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer = gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Buffer = NULL;
+ gFailsafeDefaults[ VARIABLE_ID_BBS_ORDER ].Size = gFailsafeDefaults[ VARIABLE_ID_BOOT_ORDER ].Size = gFailsafeDefaults[ VARIABLE_ID_DRIVER_ORDER ].Size = 0;
+
+ // special provision for language
+ //VarGetValue( VARIABLE_ID_LANGUAGE, 0, 3, gPrevLanguage );
+ gPrevLanguage = VarGetNvram ( VARIABLE_ID_LANGUAGE, &gPrevLangSize );
+
+ //Special provision for "Boot order" and "Legacy dev order"
+ size = 0;
+ newBuffer = VarGetNvramName ( L"DefaultBootOrder", &EfiDefaultBootOrderGuid, NULL, &size );
+ if(newBuffer)
+ {
+ MemFreePointer( (VOID **) &gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer );
+ gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Buffer = (UINT8 *)newBuffer;
+ gOptimalDefaults[ VARIABLE_ID_BOOT_ORDER ].Size = size;
+ }
+ size = 0; //EIP81581 Default driver order support
+ DefDrvBuffer = VarGetNvramName (L"DefaultDriverOrder", &EfiDefaultDriverOrderGuid, NULL, &size);
+ if (DefDrvBuffer)
+ {
+ MemFreePointer ((VOID **) &gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Buffer);
+ gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Buffer = (UINT8 *)DefDrvBuffer;
+ gOptimalDefaults [VARIABLE_ID_DRIVER_ORDER].Size = size;
+ }
+ CsmLoadDefaultLegDevOrder();
+ LoadedBuildDefaultsHook();
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadDefaultLegDevOrder
+//
+// Description: Function to load default legacy boot order
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID LoadDefaultLegDevOrder(VOID)
+{
+ UINT8 *newBuffer = NULL;
+ UINTN size = 0;
+
+ newBuffer = VarGetNvramName( L"DefaultLegacyDevOrder", &EfiDefaultLegacyDevOrderGuid, NULL, &size );
+ if(newBuffer)
+ {
+ MemFreePointer( (VOID **)&gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer );
+ gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer = BBSReOrderDefultLegacyDevOrder((BBS_ORDER_TABLE *)newBuffer,size);
+ //Ignore the DefaultLegacyDevOrder if is size is not matching with LegacyDevOder.
+ if(gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Buffer == NULL)
+ size = 0;
+ gOptimalDefaults[ VARIABLE_ID_BBS_ORDER ].Size = size;
+ MemFreePointer(&newBuffer);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetNvram
+//
+// Description: function to get the NvRam varible names
+//
+// Input: UINT32 variable, UINTN *size
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *VarGetNvram( UINT32 variable, UINTN *size )
+{
+ VOID *buffer = NULL;
+ VARIABLE_INFO *varInfo;
+ EFI_STATUS status = EFI_SUCCESS;
+
+ *size = 0;
+
+ varInfo = VarGetVariableInfoIndex( variable );
+ if ( varInfo == NULL )
+ return buffer;
+
+ if((varInfo->ExtendedAttibutes & AMI_SPECIAL_VARIABLE_NO_GET) == AMI_SPECIAL_VARIABLE_NO_GET)
+ {
+ // Don't read from the NVRAM
+ // But in the Init we may need to take care return empty buffer
+ NVRAM_VARIABLE *list = gVariableList;
+ NVRAM_VARIABLE *nvVar;
+ if(gVariableList != NULL)
+ {
+ nvVar = &list[ variable ];
+ if((nvVar!=NULL)&&(nvVar->Size!=0))
+ {
+ *size = nvVar->Size;
+ //This function Suppose allocate and give the buffer
+ buffer = EfiLibAllocateZeroPool( *size );
+ if(nvVar->Buffer != NULL)
+ MemCopy( buffer, nvVar->Buffer, *size );
+ return buffer;
+ }
+ }
+ // If Local catch is not found Just return null.
+ *size = 0;
+ return buffer;
+ }
+
+ if(UefiIsEfiVariable(variable,varInfo))
+ {
+ *size = 0;
+ if(varInfo->VariableAttributes == 0)
+ varInfo->VariableAttributes = 0x07;
+ buffer = VarGetNvramName( varInfo->VariableName, &varInfo->VariableGuid, &varInfo->VariableAttributes, size );
+ }
+ else
+ {
+ {
+ if((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_VARSTORE) == VARIABLE_ATTRIBUTE_VARSTORE)
+ *size = varInfo->VariableSize;
+ status = UefiVarGetNvram(varInfo, &buffer, VAR_ZERO_OFFSET, *size);
+ if(EFI_ERROR(status))
+ {
+ *size = 0;
+ }
+ }
+ }
+ return buffer;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: VarGetNvramQuestionValue
+//
+// Description: Gets the question value buffer from a specific offset of a
+// variable buffer
+//
+// Input: UINT32 variable
+// UINTN offset
+// UINTN *size
+//
+// Output: VOID *buffer - Question value buffer
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *VarGetNvramQuestionValue(UINT32 variable, UINTN Offset, UINTN Size)
+{
+ VOID *buffer = (VOID *)NULL;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL;
+ EFI_STATUS status = EFI_SUCCESS;
+
+ varInfo = VarGetVariableInfoIndex( variable );
+ if ( varInfo == NULL )
+ return buffer;
+//EIP 77875 : Minisetup: Memory leaks in text browser
+ if(UefiIsEfiVariable(variable,varInfo))
+ {
+ UINTN size = 0;
+ UINT8 *tempBuffer = NULL;
+
+ buffer = EfiLibAllocateZeroPool(Size+1);
+ if(buffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ if(varInfo->VariableAttributes == 0){
+ varInfo->VariableAttributes = 0x07;
+ }
+ tempBuffer = VarGetNvramName( varInfo->VariableName, &varInfo->VariableGuid, &varInfo->VariableAttributes, &size );
+ if(tempBuffer != NULL && size != 0)
+ {
+ if((Offset + Size) > size)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ MemCopy(buffer, &tempBuffer[Offset], Size);
+ MemFreePointer(&tempBuffer);
+ }
+ }
+ else
+ {
+ {
+ if((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_VARSTORE) == VARIABLE_ATTRIBUTE_VARSTORE)
+ if((Offset + Size) > varInfo->VariableSize)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ status = UefiVarGetNvram(varInfo, &buffer, Offset, Size);
+ }
+ }
+DONE:
+ return buffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarSetNvram
+//
+// Description: function to set the NvRam varible names
+//
+// Input: UINT32 variable, VOID *buffer, UINTN *size
+//
+// Output: status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarSetNvram( UINT32 variable, VOID *buffer, UINTN size )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL;
+
+ if(buffer == NULL)
+ {
+ goto DONE;
+ }
+
+ varInfo = VarGetVariableInfoIndex(variable);
+ if(varInfo == NULL)
+ {
+ goto DONE;
+ }
+
+ if((varInfo->ExtendedAttibutes & AMI_SPECIAL_VARIABLE_NO_SET) == AMI_SPECIAL_VARIABLE_NO_SET)
+ {
+ // Don't save the variable
+ Status = EFI_SUCCESS;
+ }
+ else
+ {
+ if(UefiIsEfiVariable(variable,varInfo))
+ {
+ Status = VarSetNvramName( varInfo->VariableName, &varInfo->VariableGuid, varInfo->VariableAttributes, buffer, size );
+ }
+ else
+ {
+ Status = UefiVarSetNvram(varInfo, buffer, VAR_ZERO_OFFSET, size);
+ }
+ }
+ if ( ! EFI_ERROR( Status ) )
+ {
+ VarUpdateVariable(variable);
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VarGetRealValue
+//
+// Description: function to get the real value of the variable
+//
+// Input: UINT32 variable, UINTN offset, UINTN size, VOID *buffer
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _VarGetRealValue( UINT32 variable, UINTN offset, UINTN size, VOID *buffer )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN i;
+
+ switch ( variable )
+ {
+ case VARIABLE_ID_LANGUAGE:
+ {
+ UINTN varsize=0;
+ VOID * LangBuf = VarGetNvram( variable, &varsize ); // Read the Variable from Variable Service
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ if ( ! EfiCompareMem( LangBuf, gLanguages[i].LangCode, varsize ) )
+ {
+ MemSet( buffer, size, 0 );
+ *(UINT16 *)buffer = (UINT16)i;
+ break;
+ }
+ }
+ MemFreePointer(&LangBuf);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VarSetRealValue
+//
+// Description: function to set the real value of the variable
+//
+// Input: UINT32 variable, UINT32 *offset, UINTN *size,
+// VOID *buffer, VOID **realBuffer
+//
+// Output: status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _VarSetRealValue( UINT32 variable, UINT32 *offset, UINTN *size, VOID *buffer, VOID **realBuffer )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 index = *(UINT16 *)buffer;
+
+ if ( variable == VARIABLE_ID_SETUP )
+ {
+ Status = EFI_UNSUPPORTED;
+ return Status;
+ }
+ if (VARIABLE_ID_BOOT_ORDER == variable)
+ *size = gBootOptionCount * sizeof(UINT16);
+
+ if (VARIABLE_ID_DRIVER_ORDER == variable) //EIP70421 & 70422 Support for driver order
+ *size = gDriverOptionCount * sizeof(UINT16);
+
+ *realBuffer = EfiLibAllocateZeroPool( *size );
+ if ( *realBuffer == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ return Status;
+ }
+
+ switch ( variable )
+ {
+ case VARIABLE_ID_LANGUAGE:
+ {
+ if ( index > gLangCount )
+ Status = EFI_INVALID_PARAMETER;
+ else
+ {
+ ///EIP-24971:Removed the Token SETUP_SUPPORT_PLATFORM_LANG_VAR dependency from TSE sources
+ if( PlatformLangVerSupport() ) {
+ MemFreePointer( (VOID **)realBuffer );
+ *size = StrLen8(gLanguages[index].LangCode) +1;
+ *realBuffer = EfiLibAllocateZeroPool( *size );
+ }
+ else {
+ *size = 3;
+ }
+
+ MemCopy( *realBuffer, gLanguages[index].LangCode, *size );
+ }
+ }
+ break;
+ case VARIABLE_ID_BOOT_ORDER:
+ MemFreePointer ((VOID **)realBuffer);
+ BootUpdateOrder (buffer, offset, size, realBuffer);
+ break;
+ case VARIABLE_ID_DRIVER_ORDER: //EIP70421 & 70422 Support for driver order
+ MemFreePointer ((VOID **)realBuffer);
+ DriverUpdateOrder (buffer, offset, size, realBuffer);
+ break;
+ case VARIABLE_ID_BBS_ORDER:
+ MemFreePointer( (VOID **)realBuffer );
+ //BBSUpdateOrder( /*index*/buffer, offset, size, realBuffer );
+ Status = CsmBBSUpdateOrder(buffer, offset, size, realBuffer);
+ break;
+
+#if SETUP_OEM_SPECIAL_CONTROL_SUPPORT
+ case VARIABLE_ID_OEM_TSE_VAR:
+ MemFreePointer( (VOID **)realBuffer );
+ Status = OEMSpecialUpdateOneOf( index, offset, size, realBuffer );
+ break;
+#endif
+
+ default:
+ MemFreePointer( (VOID **)realBuffer );
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetValue
+//
+// Description: Function to get var value
+//
+// Input: UINT32 variable, UINT32 offset, UINTN size, VOID *buffer
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarGetValue( UINT32 variable, UINT32 offset, UINTN size, VOID *buffer )
+{
+ return _VarGetData( variable, offset, size, buffer, FALSE );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetDefaults
+//
+// Description: Function to get var defaults
+//
+// Input: UINT32 variable, UINT32 offset, UINTN size, VOID *buffer
+//
+// Output: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarGetDefaults( UINT32 variable, UINT32 offset, UINTN size, VOID *buffer )
+{
+ return _VarGetData( variable, offset, size, buffer, TRUE );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VarGetData
+//
+// Description: function to get variable data
+//
+// Input: UINT32 variable, UINT32 offset, UINTN size,
+// VOID *buffer, BOOLEAN useDefaults
+//
+// Output: status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _VarGetData( UINT32 variable, UINT32 offset, UINTN size, VOID *buffer, BOOLEAN useDefaults )
+{
+ UINT32 TempOffset =offset;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ NVRAM_VARIABLE *list = gVariableList;
+
+ if ( ( useDefaults ) || ( list == NULL ) )
+ list = gOptimalDefaults;
+
+ Status = _VarGetSetValue( VAR_COMMAND_GET_VALUE, list, variable, TempOffset, size, buffer );
+
+ if ( ! EFI_ERROR( Status ) )
+ Status = _VarGetRealValue( variable, offset,size, buffer );
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarSetValue
+//
+// Description: Function to set variable value
+//
+// Input: UINT32 variable, UINT32 offset, UINTN size, VOID *buffer
+//
+//
+// Output: status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS VarSetValue( UINT32 variable, UINT32 offset, UINTN size, VOID *buffer )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ VOID *realBuffer = (VOID *)NULL;
+
+ Status = _VarSetRealValue( variable, &offset, &size, buffer, &realBuffer );
+ if ( EFI_ERROR( Status ) )
+ realBuffer = buffer;
+
+ Status = _VarGetSetValue( VAR_COMMAND_SET_VALUE, gVariableList, variable, offset, size, realBuffer );
+
+ if ( ( variable == VARIABLE_ID_LANGUAGE ) && ( ! EFI_ERROR( Status ) ) )
+ {
+ if (NULL != gApp)
+ {
+ gApp->CompleteRedraw = TRUE;
+ }
+ Status = VarSetNvram( variable, realBuffer, size );
+ }
+
+ if ( realBuffer != buffer )
+ MemFreePointer( (VOID **)&realBuffer );
+
+ //EIP:100429 Prevent calls to SetupConfigModifiedHook for variables that don't affect setup changes.
+ if(!(
+ //variable == VARIABLE_ID_SETUP ||
+ //variable == VARIABLE_ID_LANGUAGE ||
+ //variable == VARIABLE_ID_BOOT_TIMEOUT ||
+ //variable == VARIABLE_ID_USER_DEFAULTS ||
+ variable == VARIABLE_ID_ERROR_MANAGER ||
+ //variable == VARIABLE_ID_AMITSESETUP ||
+ //variable == VARIABLE_ID_IDE_SECURITY ||
+ //variable == VARIABLE_ID_BOOT_ORDER ||
+ //variable == VARIABLE_ID_BBS_ORDER ||
+ variable == VARIABLE_ID_DEL_BOOT_OPTION ||
+ variable == VARIABLE_ID_ADD_BOOT_OPTION ||
+ variable == VARIABLE_ID_BOOT_MANAGER ||
+ variable == VARIABLE_ID_BOOT_NOW ||
+ variable == VARIABLE_ID_LEGACY_DEV_INFO ||
+ variable == VARIABLE_ID_AMI_CALLBACK ||
+ variable == VARIABLE_ID_LEGACY_GROUP_INFO ||
+ variable == VARIABLE_ID_OEM_TSE_VAR ||
+ variable == VARIABLE_ID_DYNAMIC_PAGE_COUNT ||
+ variable == VARIABLE_ID_DRV_HLTH_ENB ||
+ variable == VARIABLE_ID_DRV_HLTH_COUNT ||
+ variable == VARIABLE_ID_DRIVER_MANAGER ||
+ //variable == VARIABLE_ID_DRIVER_ORDER ||
+ variable == VARIABLE_ID_ADD_DRIVER_OPTION ||
+ variable == VARIABLE_ID_DEL_DRIVER_OPTION ||
+ variable == VARIABLE_ID_PORT_OEM1 ||
+ variable == VARIABLE_ID_PORT_OEM2 ||
+ variable == VARIABLE_ID_PORT_OEM3 ||
+ variable == VARIABLE_ID_PORT_OEM4 ||
+ variable == VARIABLE_ID_PORT_OEM5 ))
+ {
+ /// Hook can be used after a control is modified...
+ SetupConfigModifiedHook();
+ gSetupUpdated = TRUE;//EIP:51619 Flag is Set when any of the setup variable is set
+ }
+
+
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VarGetSetValue
+//
+// Description: intermediate function for the set and get operations
+//
+// Input: UINTN command, NVRAM_VARIABLE *list, UINT32 variable,
+// UINT32 offset, UINTN size, VOID *buffer
+//
+// Output: status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _VarGetSetValue( UINTN command, NVRAM_VARIABLE *list, UINT32 variable, UINT32 offset, UINTN size, VOID *buffer )
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ NVRAM_VARIABLE *varInfo;
+
+ if ( ( variable >= gVariables->VariableCount ) || ( buffer == NULL ) || ( size == 0 ) )
+ return Status;
+
+ varInfo = &list[ variable ];
+
+ if ( ( command == VAR_COMMAND_SET_VALUE ) && ( varInfo->Buffer == NULL ) )
+ {
+ varInfo->Buffer = EfiLibAllocateZeroPool( offset + size );
+ if ( varInfo->Buffer != NULL )
+ varInfo->Size = offset + size;
+ }
+
+ if ( varInfo->Size == 0 )
+ {
+ varInfo->Buffer = VarGetNvram( variable, &varInfo->Size );
+ if ( varInfo->Buffer == NULL )
+ return Status;
+ }
+
+ if ( offset + size > varInfo->Size )
+ {
+ if ( command == VAR_COMMAND_SET_VALUE )
+ {
+ UINT8 *newBuffer;
+
+ newBuffer = EfiLibAllocateZeroPool( offset + size );
+ if ( newBuffer == NULL )
+ return Status;
+ MemCopy( newBuffer, varInfo->Buffer, varInfo->Size );
+ MemFreePointer( (VOID **)&varInfo->Buffer );
+ varInfo->Buffer = newBuffer;
+ varInfo->Size = offset + size;
+ }
+ }
+
+ if ( command == VAR_COMMAND_GET_VALUE )
+ {
+ MemSet( buffer, size, 0 );
+ if ( offset + size > varInfo->Size )
+ size = varInfo->Size - offset;
+ if ( varInfo->Size > offset )
+ MemCopy( buffer, &varInfo->Buffer[offset], size );
+ }
+ else
+ MemCopy( &varInfo->Buffer[offset], buffer, size );
+
+ Status = EFI_SUCCESS;
+
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VarUpdate
+//
+// Description: Function to update variable
+//
+// Input: NVRAM_VARIABLE *nvramVar, UINT32 variable
+//
+//
+// Output: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _VarUpdate(NVRAM_VARIABLE *nvramVar, UINT32 variable)
+{
+ UINT8 *newBuffer;
+ UINTN nvSize;
+
+ newBuffer = (UINT8 *)VarGetNvram( variable, &nvSize );
+ if (NULL == newBuffer) //No need to update the buffer if it is NULL
+ {
+ return;
+ }
+ MemFreePointer( (VOID **)&nvramVar->Buffer );
+ nvramVar->Buffer = newBuffer;
+ nvramVar->Size = nvSize;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarUpdateVariable
+//
+// Description: Function to update variable
+//
+// Input: UINT32 variable
+//
+//
+// Output: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID VarUpdateVariable(UINT32 variable)
+{
+ NVRAM_VARIABLE *nvramVar;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ if (NULL == gVariableList)
+ Status = VarLoadVariables ((VOID **)&gVariableList, NULL);
+ if (EFI_ERROR (Status))
+ return;
+ nvramVar = &gVariableList[ variable ];
+ _VarUpdate(nvramVar, variable);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarUpdateDefaults
+//
+// Description: Function to update variable defaults
+//
+// Input: UINT32 variable
+//
+//
+// Output: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID VarUpdateDefaults(UINT32 variable)
+{
+ NVRAM_VARIABLE *nvramVar;
+ nvramVar = &gFailsafeDefaults[ variable ];
+ _VarUpdate(nvramVar, variable);
+ nvramVar = &gOptimalDefaults[ variable ];
+ _VarUpdate(nvramVar, variable);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarUpdateDefaults
+//
+// Description: Function to get variable
+//
+// Input: UINT32 variable, UINTN *size
+//
+//
+// Output: VOID*
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *VarGetVariable( UINT32 variable, UINTN *size )
+{
+ VOID *buffer = NULL;
+ NVRAM_VARIABLE *nvramVar;
+
+ if ( variable >= gVariables->VariableCount )
+ return buffer;
+
+ if(gVariableList == NULL)
+ return buffer;
+
+ nvramVar = &gVariableList[ variable ];
+ if ( nvramVar == NULL )
+ return buffer;
+
+ if ( ( *size == 0 ) || ( *size > nvramVar->Size ) )
+ *size = nvramVar->Size;
+
+ if(*size == 0)
+ return buffer;
+
+ buffer = EfiLibAllocateZeroPool( *size );
+ if ( ( buffer != NULL ) && ( nvramVar->Buffer != NULL ) )
+ MemCopy( buffer, nvramVar->Buffer, *size );
+ else
+ *size = 0;
+
+ return buffer;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetVariableInfoIndex
+//
+// Description: Function to get variable info index
+//
+// Input: UINT32 index
+//
+//
+// Output: VARIABLE_INFO *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VARIABLE_INFO *VarGetVariableInfoIndex( UINT32 index )
+{
+ VARIABLE_INFO *varInfo = NULL;
+
+ if ( index < gVariables->VariableCount )
+ varInfo = (VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[index]);
+
+ return varInfo;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: VarGetVariableInfoId
+//
+// Description: function to get the ID of the variable information
+//
+// Input: UINTN command, NVRAM_VARIABLE *list, UINT32 variable,
+// UINT32 offset, UINTN size, VOID *buffer
+//
+// Output: Variable Info
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VARIABLE_INFO *VarGetVariableInfoId( UINT32 varId, UINT32 *index )
+{
+ VARIABLE_INFO *varInfo = NULL;
+ UINT32 i;
+
+ for ( i = 0; i < gVariables->VariableCount; i++, varInfo++ )
+ {
+ varInfo = VarGetVariableInfoIndex( i );
+ if ( NULL != varInfo && varInfo->VariableID == varId)//EIP-75352 Suppress the warnings from static code analyzer
+ {
+ if ( index != NULL )
+ *index = i;
+ return varInfo;
+ }
+ }
+
+ varInfo = NULL;
+ return varInfo;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSReOrderDefultLegacyDevOrder
+//
+// Description: To reoder the DefaultLegacyDevOrder Variable as TSE reorders
+// the LegacyDevOrder based on Boot Order
+//
+// Input: DefaultLegDevOrder and DefaultLegDevOrderSize
+//
+// Output: NewDefultLegacyDevOrder
+// NULL = if DefaultLegDevOrderSize is not Equal with LegacuDevOrderSize
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *BBSReOrderDefultLegacyDevOrder(BBS_ORDER_TABLE *DefaultLegDevOrder,UINTN DefaultLegDevOrderSize)
+{
+ BBS_ORDER_TABLE * LegacyDevOrder,*NewDefultLegacyDevOrder,*TempDevOrder,*NewDevEntry;
+ UINTN LegacyOrderSize=0;
+ UINTN count=0;
+ UINTN i,j;
+
+ LegacyDevOrder = VarGetNvramName( L"LegacyDevOrder", &gLegacyDevGuid, NULL, &LegacyOrderSize );
+
+ // If the DefaultLegacyDevOrderSize is not Matching with LegacyDevOrderSize (EIP-25288)
+ if(LegacyOrderSize != DefaultLegDevOrderSize)
+ return NULL;
+
+ if(DefaultLegDevOrderSize && LegacyDevOrder)
+ NewDefultLegacyDevOrder = EfiLibAllocateZeroPool( DefaultLegDevOrderSize);
+ else
+ return NULL;
+
+ NewDevEntry = NewDefultLegacyDevOrder;
+ for(j=0; j<LegacyOrderSize; )
+ {
+ TempDevOrder = DefaultLegDevOrder;
+ for(i=0;i<DefaultLegDevOrderSize;)
+ {
+ if ( (0 == TempDevOrder->Length) || (TempDevOrder->Length >= DefaultLegDevOrderSize) ) //EIP-120011
+ {
+ return NULL;
+ }
+
+ count = sizeof(UINT32) + TempDevOrder->Length;
+
+ //If GROUP_BOOT_OPTIONS_BY_TAG is enable
+ if ( LegacyDevOrder->Type == TempDevOrder->Type && IsBootOptionsGroupingEnabled() ) //EIP-93954 To Restore BootOption default issue
+ {
+ MemCopy(NewDevEntry,TempDevOrder,count); //Copying default legacyDevOrder
+ NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + count);
+ break;
+ }
+ //If GROUP_BOOT_OPTIONS_BY_TAG is disable
+ else
+ {
+ if ( (LegacyDevOrder->Type == TempDevOrder->Type) && (LegacyDevOrder->Data[0] == TempDevOrder->Data[0]) )
+ {
+ MemCopy(NewDevEntry,TempDevOrder,count); //Copying default legacyDevOrder
+ NewDevEntry = (BBS_ORDER_TABLE *)((UINTN)NewDevEntry + count);
+ break;
+ }
+ }
+
+ TempDevOrder = (BBS_ORDER_TABLE *)((UINTN)TempDevOrder + count);
+ i += count;
+ }
+
+ //Go to next entry
+ count = sizeof(UINT32) + LegacyDevOrder->Length;
+ LegacyDevOrder = (BBS_ORDER_TABLE *)((UINTN)LegacyDevOrder + count);
+ j += count;
+ }
+
+ if(((UINTN)NewDevEntry - (UINTN)NewDefultLegacyDevOrder) != LegacyOrderSize)
+ // Something wrong in the Variables. Lets just use LegacyDevOrder
+ MemCopy(NewDefultLegacyDevOrder,LegacyDevOrder,LegacyOrderSize);
+
+ return NewDefultLegacyDevOrder;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HelperGetVariable
+//
+// Description: Function helper to get variable
+//
+// Input: UINT32 variable, CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size
+//
+//
+// Output: VOID *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID * HelperGetVariable( UINT32 variable, CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size )
+{
+ VOID * Buffer;
+ Buffer = VarGetVariable( variable, size );
+ if(Buffer == NULL)
+ Buffer = VarGetNvram( variable, size );
+ return Buffer;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/changelog.log b/EDK/MiniSetup/changelog.log
new file mode 100644
index 0000000..afe3815
--- /dev/null
+++ b/EDK/MiniSetup/changelog.log
@@ -0,0 +1,1458 @@
+$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE
+
+[TAG] EIP63895
+[Category] Bug Fix
+[Severity] Important
+[Symptom] Same message "Save & reset" displayed twice
+[RootCause] guidInfo->GuidFlags.GuidLaunchFilename condition also executed after executing guidInfo->GuidFlags.GuidLaunchGuid condition.
+[Solution] Made as any one condition will execute
+[Files] Tseadvanced.c
+
+[TAG] EIP64295
+[Category] New Feature
+[Description] Support for software created boot entry for USB.CheckDevSupShortFormPath function added to check whether the boot option supports short-form device path for USB class(Table 60) device path.
+[Files] boot.c
+
+[TAG] EIP64295
+[Category] New Feature
+[Description] Support for software created boot entry for USB.CheckDevSupShortFormPath function added to check whether the bootoption supports short-form device path for USB class(Table 60) devicepath.Goto statement removed in CheckDevSupShortFormPath function.
+[Files] boot.c
+
+[TAG] EIP65320
+[Category] Improvement
+[Description] Board module hook for LoadImage failure
+[Files] boot.c and commonhelper.c
+
+[TAG] EIP 63262
+[Category] Defect
+[Symptom] Setup page display problem on rose city.When SETUP_GROUP_DYNAMIC_PAGES is enabled and Network Stack is enabled, the "iSCSI" menu is listed as a dynamic page in advanced menu but only 3 of 4 "Port Configuration" pages shows up. The TSE dynamic page count is incorrect.
+[Solution] In the functions (RTIfrProcessRunTimeForms, HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack), make sure the nvram cache is updated by callingVarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT) when updating "DynamicPageCount" variable name. .
+[Files] Hii.c, Minisetup.h, Variable.h
+
+[TAG] EIP57661
+[Category] New Feature
+[Description] Driver health related variables are updated via notification function.
+[Files] notify.c, Uefi21Wapper.c and variable.h
+
+[TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS setup.
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl, Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h, CommonHelper.c
+
+[Files] TseLite\frame.c
+Removed unwanted code related to mouse hot click opetaions.
+
+
+Updated the file to restrict the control selection when cliked on help frame with mouse
+[Files] TseLite\frame.c
+
+[Files] TseLite\frame.c
+Updated the file to close the popup window when left clicked on help and navigation frame
+
+[Files] Uefi2.1\HiiCallback.c
+Suppressing the callback for AMI_CALLBACK_FORM_OPEN action
+
+
+[TAG] EIP57661
+[Category] New Feature
+[Description] Driver health variables are updated in cache too.
+[Files] notify.c, Uefi21Wapper.c and variable.h
+
+***************** FormBrowser2.c *****************
+User: Arunsb Date: 6/30/11 Time: 11:55a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ Adding config header in config string is controlled by
+EDKVersion_1_05_RetrieveData wrapper function.
+
+***************** Uefi21.sdl *****************
+User: Arunsb Date: 6/30/11 Time: 11:53a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ EDK_1_05_RETRIEVE_DATA token removed and added in AMITSE.sdl
+
+***************** frame.c *****************
+User: Rajashakerg Date: 6/30/11 Time: 5:18a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ Updated the help frame scroll restricted for left click alone.
+
+***************** minisetup.h *****************
+User: Premkumara Date: 6/30/11 Time: 5:05a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Resolve Build error with Driver Health protocol
+
+***************** logo.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:37a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ If Jpeg off and Bmp on, Jpeg image unsuccess to draw on the screen
+clearing the
+drawm bmp image.
+Fixed this issue.
+
+***************** Uefi21Wapper.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:20a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** Parse.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:19a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Dynamic parsing changed for driver health config. page via
+sendform.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** Hii.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:17a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Sets the driver health support variable.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** FormBrowser2.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:16a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ gFSetGuid added to compare in parseform.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** uefi20Wapper.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:15a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Wrapper functions added.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** minisetup.h *****************
+User: Arunsb Date: 6/30/11 Time: 4:14a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ 2.0 & 2.1 compatibility added
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** boot.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:13a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Boot device repair operation performed.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** special.h *****************
+User: Arunsb Date: 6/30/11 Time: 4:13a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Guid key added.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** special.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:12a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Driver health special controls handled.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** TseAdvanced.c *****************
+User: Arunsb Date: 6/30/11 Time: 4:12a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP57661
+[Category] New Feature
+[Description] Boot manager algorithm for interaction with Driver Health
+protocol.
+ Driver health special controls handled.
+[Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+ commonhelper.c, uefisetup.ini, tsedrvhealth.h, amivfr.h,
+minisetupbin.mak,
+ hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+special.h, boot.h, minisetup.h,
+ uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+uefi21wapper.c.
+
+***************** application.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 6:21p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ Updated the file for Hotkey and hotclicks to return their exact
+status
+
+***************** frame.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 4:34p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ Updated for Help frame scroll changes
+
+***************** frame.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:58p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** application.h *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:54p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** application.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:52p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** Memo.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:49p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** legacy.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:43p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** style.h *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:41p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** frame.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:36p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP59657
+[Category] Bug Fix
+[Severity] Normal
+[Symptom] [TSE] When change password status, sometimes will miss first item.
+[RootCause] The frame first visible control is not handled properly
+[Solution] The first visible control is handled properly by making first
+visible control as 0 in framescroll
+[Files] Frame.c
+
+***************** ezportplus.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:36p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** style.h *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:33p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus
+Comment:
+ [TAG] EIP47086
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS
+setup.
+
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** ezport.c *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:26p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport
+Comment:
+ [TAG] EIP47086, 62098
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS setup
+and the Mouse hotclicks.
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** style.h *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:24p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport
+Comment:
+ [TAG] EIP47086, 62098
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS setup
+and the Mouse hotclicks.
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** minisetup.h *****************
+User: Rajashakerg Date: 6/29/11 Time: 12:19p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP47086, 62098
+[Category] New Feature
+[Description] Right clicking from the Main page is not exiting from BIOS setup
+and the Mouse hotclicks.
+[Files] minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
+Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif, EzportPlus\style.h,
+EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak, EzportPlus\EzportPlusBin.cif,
+EzportPlus\ezportplus.c, Legacy\style.h, Legacy\EzportPlusBin.sdl,
+Legacy\LegacyBin.mak, Legacy\LegacyBin.cif, Legacy\legacy.c, TseLiteBin.sdl,
+TseLite.cif, Memo.c, frame.c, application.h, application.c, commonoem.h,
+CommonHelper.c
+
+***************** postmgmt.c *****************
+User: Arunsb Date: 6/29/11 Time: 10:16a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] Improvement
+[Description] Support for BGRT spec. version 1.2.
+ ImageType field added in BGRT_TABLE to represent the type of
+image.
+[Files] bootonly\logo.c and postmgmt.c
+
+***************** logo.c *****************
+User: Arunsb Date: 6/29/11 Time: 10:08a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] Improvement
+[Description] BGRT status field is cleared when setup key is intervented for
+setup launch while in quiet boot.
+[Files] bootonly\logo.c and postmgmt.c
+
+***************** notify.c *****************
+User: Arunsb Date: 6/29/11 Time: 6:29a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP 62631
+[Category] New Feature
+[Description] Hot key boot option support in TSE as per UEFI spec. section
+3.1.6.
+ Hot boot keys formed in AtivateInput function.
+[Files] AMITSE.sdl, bootflow.c, bootflow.h, CommonHelper.c, commonoem.c,
+commonoem.h, boot.c,
+ hiistring20.c, hiistring21.c and notify.c.
+
+***************** boot.c *****************
+User: Arunsb Date: 6/29/11 Time: 6:12a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP 62631, 60128
+[Category] New Feature
+[Description] Hot key boot option in TSE as per UEFI spec. section 3.1.6.
+[Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h, boot.c,
+hiistring20.c and hiistring21.c.
+
+***************** TseLite.cif *****************
+User: Rajashakerg Date: 6/29/11 Time: 5:11a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+
+
+***************** TseLite *****************
+User: Rajashakerg Date: 6/29/11 Time: 5:01a
+Added hotclick.c
+
+***************** TseLite *****************
+User: Rajashakerg Date: 6/29/11 Time: 5:01a
+Added hotclick.h
+
+***************** special.c *****************
+User: Madhans Date: 6/28/11 Time: 4:37p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP55290
+[Category] Bug Fix
+[Severity] Minor
+[Symptom] Keeping Different Default Language other then English will cause
+Lanuage options to show same language repeated.
+[RootCause] The Language name was not updated protperly.
+[Solution] Fix to read to update token.
+[Files] special.c
+
+***************** uefi20Wapper.c *****************
+User: Arunsb Date: 6/28/11 Time: 3:44p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0
+Comment:
+ [TAG] EIP55762
+[Description] Dummy UpdateDestiantionQuestion function added
+
+***************** frame.c *****************
+User: Arunsb Date: 6/28/11 Time: 2:42p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ Build error resolved by adding UpdateDestiantionQuestion function
+declaration.
+
+***************** Parse.c *****************
+User: Arunsb Date: 6/28/11 Time: 2:40p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ Build error resolved
+
+***************** popup.c *****************
+User: Madhans Date: 6/28/11 Time: 10:14a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ To remove ";" in unwanted case.
+
+***************** Parse.c *****************
+User: Arunsb Date: 6/28/11 Time: 9:38a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ EIP 56405 . Review comment addressed
+Comment: Uncomment the 2.1 EFI Varstore support part.
+
+***************** Hii.c *****************
+User: Arunsb Date: 6/28/11 Time: 8:26a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ EIP56405: Commented the build time parsing code.
+Name value not supported by current vfr compiler.
+Uncomment the codes once vfr compiler supports it.
+
+***************** Parse.c *****************
+User: Premkumara Date: 6/24/11 Time: 10:16a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP62310, EIP 59743, EIP 62308
+[Category] Improvement
+[Description] Merge all SupportEFI_IFR_SUPPRESS_IF_OP, EFI_IFR_GRAYOUT_IF_OP,
+cases in one case
+[Files] Parse.c
+
+***************** postmgmtext.c *****************
+User: Arunsb Date: 6/24/11 Time: 9:35a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP62754
+[Category] Bug Fix
+[Severity] Minor
+[Symptom] Time out not occurring in password popup window
+[RootCause] Timer event was set only for the first try in consecutive tries
+ event not created
+[Solution] If time out occurs in first try then TSE wont try for next
+iteration to get password.
+ TSE will report error and waits upto restarting
+the system.
+
+[Files] postmgmtext.c
+
+***************** protocol.c *****************
+User: Arunsb Date: 6/23/11 Time: 7:38p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57660
+[Category] New Feature
+[Description] Non-removable media boot behavior as described in UEFI
+ specification v 2.3.1, p. 3.4.1.
+ Checks for the setup key if no boot options avail
+ or not succedded to boot. If setup key pressed launches the
+setup.
+ If no boot option avail then inserting thumb drive with image
+efi\boot\bootxxxx.efi TSE will launch that image.
+[Files] amitse.sdl, bootflow.c and protocol.c
+
+***************** minisetup.h *****************
+User: Rajashakerg Date: 6/23/11 Time: 4:06p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** Hii.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 4:03p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** Parse.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 4:02p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** Uefi21Wapper.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 4:01p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** frame.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:58p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** minisetupext.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:56p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** minisetupext.h *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:55p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** numeric.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:54p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description]
+Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** page.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:53p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description]
+Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** PopupString.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:52p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** legacy.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:49p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** style.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:48p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** style.h *****************
+User: Rajashakerg Date: 6/23/11 Time: 3:47p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP55762, 58925, 59971
+[Category] New Feature
+[Description] Support REF2,REF3 and REF4 in AMITSE
+Support direct form navigation path
+Improper layout of controls in the root page when Dynamic pages are added using
+the Legacy Setup Style
+[Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c, minisetupext.h,
+numeric.c, page.c Popupstring.c, Hii.c, Uefi21Wrapper.c, Parse.c Hii.c
+
+***************** style.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 5:46a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/EzportPlus
+Comment:
+ [TAG] EIP63073
+[Category] New Feature
+[Description] Source modules in TSE should get the version details from binary
+in run time not at build time
+[Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+EzportPlus\style.c, Legacy\style.c
+
+***************** style.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 5:44a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Legacy
+Comment:
+ [TAG] EIP63073
+[Category] New Feature
+[Description] Source modules in TSE should get the version details from binary
+in run time not at build time
+[Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+EzportPlus\style.c, Legacy\style.c
+
+***************** style.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 5:42a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Ezport
+Comment:
+ [TAG] EIP63073
+[Category] New Feature
+[Description] Source modules in TSE should get the version details from binary
+in run time not at build time
+[Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+EzportPlus\style.c, Legacy\style.c
+
+***************** notify.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 5:36a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP63073
+[Category] New Feature
+[Description] Source modules in TSE should get the version details from binary
+in run time not at build time
+[Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+EzportPlus\style.c, Legacy\style.c
+
+***************** minisetupext.c *****************
+User: Rajashakerg Date: 6/23/11 Time: 5:32a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP63073
+[Category] New Feature
+[Description] Source modules in TSE should get the version details from binary
+in run time not at build time
+[Files] CommonHelper.c, minisetupext.c, notify.c, Ezport\style.c,
+EzportPlus\style.c, Legacy\style.c
+
+***************** Uefi21Wapper.c *****************
+User: Arunsb Date: 6/22/11 Time: 6:05p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP56405
+[Category] New Feature
+[Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+[Files] Hii.c, parse.c and uefi21wapper.c
+
+***************** Parse.c *****************
+User: Arunsb Date: 6/22/11 Time: 5:17p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP56405
+[Category] New Feature
+[Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+[Files] Hii.c, parse.c and uefi21wapper.c
+
+***************** Hii.c *****************
+User: Arunsb Date: 6/22/11 Time: 4:47p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP56405
+[Category] New Feature
+[Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+[Files] Hii.c, parse.c and uefi21wapper.c
+
+***************** boot.c *****************
+User: Arunsb Date: 6/22/11 Time: 2:40p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP 62631
+[Category] New Feature
+[Description] Support for Hot key boot option in TSE as per UEFI spec. section
+3.1.6.
+[Files] AMITSE.sdl, CommonHelper.c, commonoem.c, commonoem.h, boot.c,
+hiistring20.c and hiistring21.c.
+
+***************** callback.c *****************
+User: Premkumara Date: 6/22/11 Time: 9:33a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP57547
+[Category] Improvement
+[Description] TSE Feature to Silently Load Defaults, Including Boot Order
+Defaults
+[Files] Callback.c
+
+***************** Parse.c *****************
+User: Premkumara Date: 6/22/11 Time: 9:27a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP 62310, EIP 59743, EIP 62308
+[Description] SupportEFI_IFR_SUPPRESS_IF_OP, EFI_IFR_GRAYOUT_IF_OP,
+EFI_IFR_DISABLE_IF_OP Over the Form or Formset
+[Files] parse.c
+
+***************** logo.c *****************
+User: Premkumara Date: 6/22/11 Time: 9:15a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP60048
+[Category] Improvement
+[Description] TSE should Change the System Resolution according to the Quite
+Logo Size
+[Files] CommonHelper.c, AMITSE.sdl, Logo.c, LogoLib.h
+
+***************** protocol.c *****************
+User: Arunsb Date: 6/20/11 Time: 3:59p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57660
+[Category] New Feature
+[Description] Non-removable media boot behavior as described in UEFI
+specification v 2.3.1, p. 3.4.1.
+ Checks for the setup key if no boot options avail or
+succedded to boot and launches the setup.
+[Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c, boot.c and
+protocol.c
+
+***************** boot.c *****************
+User: Arunsb Date: 6/20/11 Time: 3:55p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57660
+[Category] New Feature
+[Description] Non-removable media boot behavior as described in UEFI
+specification v 2.3.1, p. 3.4.1.
+[Files] amitse.sdl, bootflow.c, bootflow.h, commonoem.c, boot.c and
+protocol.c
+
+***************** png.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 1:20p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP60910
+[Description] Updated with respect to the review comments.
+
+***************** pnguncmp.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 1:19p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP60910
+[Description] Updated with respect to the review comments.
+
+***************** Uefi21Wapper.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:28p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP60563
+[Category] New Feature
+[Description] Support for signed decimal value for EFI_IFR_NUMERIC_OP.
+[Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+
+***************** string.h *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:26p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP60563
+[Category] New Feature
+[Description] Support for signed decimal value for EFI_IFR_NUMERIC_OP.
+[Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+
+***************** string.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:25p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP60563
+[Category] New Feature
+[Description] Support for signed decimal value for EFI_IFR_NUMERIC_OP.
+[Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+
+***************** numeric.h *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:23p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP60563
+[Category] New Feature
+[Description] Support for signed decimal value for EFI_IFR_NUMERIC_OP.
+[Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+
+***************** numeric.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:22p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP60563
+[Category] New Feature
+[Description] Support for signed decimal value for EFI_IFR_NUMERIC_OP.
+[Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+
+***************** TseUefiHii.h *****************
+User: Rajashakerg Date: 6/20/11 Time: 12:20p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57402
+[Category] New Feature
+[Description] Support for EFI_IFR_DEFAULT_2 opcode.
+[Files] Hii.c, TseUefiHii.h
+
+***************** callback.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 11:52a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP59417
+[Category] New Feature
+[Description] Spport LOAD_OPTION_HIDDEN option in TSE
+[Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, minisetup.h,
+special.c, callback.c
+
+***************** special.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 11:50a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP59417
+[Category] New Feature
+[Description] Spport LOAD_OPTION_HIDDEN option in TSE
+[Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, minisetup.h,
+special.c, callback.c
+
+***************** minisetup.h *****************
+User: Rajashakerg Date: 6/20/11 Time: 11:46a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP59417
+[Category] New Feature
+[Description] Spport LOAD_OPTION_HIDDEN option in TSE
+[Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, minisetup.h,
+special.c, callback.c
+
+***************** boot.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 11:45a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP59417
+[Category] New Feature
+[Description] Spport LOAD_OPTION_HIDDEN option in TSE
+[Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, minisetup.h,
+special.c, callback.c
+
+***************** bbs.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 11:43a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP59417
+[Category] New Feature
+[Description] Spport LOAD_OPTION_HIDDEN option in TSE
+[Files] boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c, minisetup.h,
+special.c, callback.c
+
+***************** Hii.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 10:39a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP57402
+[Category] New Feature
+[Description] Support for EFI_IFR_DEFAULT_2 opcode.
+[Files] Hii.c
+
+***************** Expression.c *****************
+User: Rajashakerg Date: 6/20/11 Time: 10:36a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP56355
+[Category] Improvement
+[Description] TSE: Support for EFI_IFR_VERSION opcode
+[Files] Expression.c
+
+***************** minisetupext.c *****************
+User: Arunsb Date: 6/20/11 Time: 10:35a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP54861
+[Category] Improvement
+[Description] Updating string token value dynamically for Title Bar and
+Copyright messages.
+[Files] minisetup.c and tselite\minisetupext.c
+
+***************** minisetup.c *****************
+User: Arunsb Date: 6/20/11 Time: 10:33a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP54861
+[Category] Improvement
+[Description] Updating string token value dynamically for Title Bar and
+Copyright messages.
+[Files] minisetup.c and tselite\minisetupext.c
+
+***************** notify.c *****************
+User: Arunsb Date: 6/19/11 Time: 4:04p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58712
+[Category] New Feature
+[Description] To disable the BIOS Signon Message and TSE copyright version in
+post screen.
+[Files] amitse.sdl, amitse.mak, commonhelper.c and notify.c
+
+***************** minisetupext.c *****************
+User: Arunsb Date: 6/15/11 Time: 5:18p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP62185
+[Category] Bug Fix
+[Severity] Normal
+[Symptom] The Main Page cannot hide when press F2 to enter setup
+[RootCause] If pagevisible set to TRUE then it is not checked for not showing
+it
+[Solution] Pagevisible = TRUE is checked for not showing the page. The next
+parent page will be shown instead of it.
+[Files] minisetupext.c
+
+***************** Date.c *****************
+User: Arunsb Date: 6/15/11 Time: 4:46p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP61650
+[Category] Bug Fix
+[Severity] Minor
+[Symptom] Cannot edit time field when using new "time" format
+[RootCause] Default refresh interval set to all the time variables
+[Solution] Control refreshed only if refresh flag set.
+[Files] time.c, date.c, parse.c and uefihpktool.exe
+
+***************** time.c *****************
+User: Arunsb Date: 6/15/11 Time: 4:43p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP61650
+[Category] Bug Fix
+[Severity] Minor
+[Symptom] Cannot edit time field when using new "time" format
+[RootCause] Default refresh interval set to all the time variables
+[Solution] Default refresh interval provided only for RTC time variable
+[Files] time.c, date.c, parse.c and uefihpktool.exe
+
+***************** Logo.c *****************
+User: Rajashakerg Date: 6/13/11 Time: 12:32p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP60910
+[Category] New Feature
+[Description] PNG image support in TSE.
+[Files] LogoLib.h, AMITSE.sdl, CommonHelper.c, logo.c, png.c, png.h,
+pnguncmp.c, TseAdvanced.cif
+
+***************** TseAdvanced.cif *****************
+User: Rajashakerg Date: 6/13/11 Time: 12:26p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP60910
+[Category] New Feature
+[Description] PNG image support in TSE.
+[Files] LogoLib.h, AMITSE.sdl, CommonHelper.c, logo.c, png.c, png.h,
+pnguncmp.c, TseAdvanced.cif
+
+***************** TseAdvanced *****************
+User: Rajashakerg Date: 6/13/11 Time: 12:21p
+Added png.c
+
+***************** TseAdvanced *****************
+User: Rajashakerg Date: 6/13/11 Time: 12:21p
+Added png.h
+
+***************** TseAdvanced *****************
+User: Rajashakerg Date: 6/13/11 Time: 12:21p
+Added pnguncmp.c
+
+***************** boot.c *****************
+User: Arunsb Date: 6/10/11 Time: 2:35p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP57660
+[Category] New Feature
+[Description] Non-removable media boot behavior as described in UEFI
+specification v 2.3.1, p. 3.4.1.2
+[Files] boot.c, bootflow.c and bootflow.h
+
+***************** postmgmtext.c *****************
+User: Arunsb Date: 6/08/11 Time: 11:26p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP59138
+[Category] Improvement
+[Description] TSE expects extra key on the last wrong password retry
+[Files] postmgmtext.c
+
+***************** Parse.c *****************
+User: Arunsb Date: 6/08/11 Time: 4:52p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP61650
+[Category] Bug Fix
+[Severity] Minor
+[Symptom] Cannot edit time field when using new "time" format
+[RootCause] Default refresh interval set to all the time variables
+[Solution] Default refresh interval provided only for RTC time variable
+[Files] uefi2.1\Parse.c
+
+***************** numeric.c *****************
+User: Madhans Date: 6/07/11 Time: 2:44p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ [TAG] EIP61897
+[Category] Improvement
+[Description] To ignore the limit checking for the Suppressed Controls in TSE
+[Files] numeric.c
+
+***************** Version 40 *****************
+Label: (INT)4.6.2_TSE_2_13_1217
+User: Arunsb Date: 6/04/11 Time: 6:01p
+Labeled '(INT)4.6.2_TSE_2_13_1217'
+Label comment:
+ [SS Server] alaska
+[SS Path] $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE
+[Label] (INT)4.6.2_TSE_2_13_1217
+[Module Name] TSE Sources
+[Description]
+Release to QA cycle 2.
+*) Fix for dynamic update for the goto control to same target page.
+*) Fix for boot override hangs with exception 0x0d.
+*) BGRT table will be formed only for quiet boot logos. BGRT status field will
+be cleared when some changes happened in screen other than displaying the image.
+
+[Entries]
+New Features:
+=============
+
+[TAG] EIP58954
+[Category] New Feature
+[Description] Quiet boot logos only added for BGRT. BGRT status field cleared
+if any changes happened in screen other than displaying the images. BltBuffer
+freed in ConvertBlt2Bmp function.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and commonhelper.c
+
+
+General Bug Fixes:
+===================
+
+[TAG] EIP61588
+[Category] Bug Fix
+[Severity] Important
+[Symptom] Advanced -> ISCSI -> Add an attempt-> Mac Address -> Save
+changes causes the system to hang.
+[RootCause] Dynamic update for the goto control to same target page was not
+updated correctly.
+[Solution] Fixed to update the control destination page correctly.
+[Files] parse.c and special.c
+
+[TAG] EIP48930
+[Description] Boot override hangs with exception 0x0d
+[Files] Parse.c and hii.c
+
+***************** AMITSE.chm *****************
+User: Arunsb Date: 6/04/11 Time: 4:20p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE
+Comment:
+ Release notes updated for 2.13.1217 internal release
+
+***************** postmgmt.c *****************
+User: Arunsb Date: 6/04/11 Time: 1:52p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Wrapper function added for InvalidateStatusInBgrt function.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+ commonhelper.c
+
+***************** boot.c *****************
+User: Arunsb Date: 6/04/11 Time: 1:49p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Wrapper function added for InvalidateStatusInBgrt function.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+commonhelper.c
+
+***************** hii.c *****************
+User: Arunsb Date: 6/04/11 Time: 12:26p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0
+Comment:
+ [TAG] EIP48930
+[Description] Boot override hangs with exception 0x0d
+[Files] uefi2.1\Parse.c, uefi2.0\hii.c
+
+***************** Hii.c *****************
+User: Blaines Date: 6/01/11 Time: 5:22p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] 61122
+[Category] Bug Fix
+[Severity] Important
+[Symptom] If SETUP_ORPHAN_PAGES_AS_ROOT_PAGE=1, HiiExit() will cause an ASSERT
+in pool.c if debug_mode is enabled.
+[RootCause] HiiExit() exit attempts to free gSetupData elements associated
+with orphaned forms..
+[Solution] Only free gSetupData[i].FormSet if gSetupData[i].FormSetLength is
+non-zero.
+[Files] Hii.c
+
+***************** hii.c *****************
+User: Blaines Date: 6/01/11 Time: 5:22p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0
+Comment:
+ [TAG] 61122
+[Category] Bug Fix
+[Severity] Important
+[Symptom] If SETUP_ORPHAN_PAGES_AS_ROOT_PAGE=1, HiiExit() will cause an ASSERT
+in pool.c if debug_mode is enabled.
+[RootCause] HiiExit() exit attempts to free gSetupData elements associated
+with orphaned forms..
+[Solution] Only free gSetupData[i].FormSet if gSetupData[i].FormSetLength is
+non-zero.
+[Files] Hii.c
+
+***************** special.c *****************
+User: Madhans Date: 6/01/11 Time: 4:14p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseAdvanced
+Comment:
+ [TAG] EIP61588
+[Category] Bug Fix
+[Severity] Important
+[Symptom] In Advanced page Iscsi page link disappears when any update happens
+[RootCause] When pages are updated dynamically we might have few invalidated
+PageInfo. Dynamic page grouping special control want not checking them
+[Solution] Dynamic page grouping special control check if the page is valid or
+not.
+[Files] Special.c
+Parse.c
+
+***************** Parse.c *****************
+User: Madhans Date: 6/01/11 Time: 4:11p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1
+Comment:
+ [TAG] EIP61588
+[Category] Bug Fix
+[Severity] Important
+[Symptom] Advanced -> ISCSI -> Add an attempt-> Mac Address -> Save changes
+causes the system to hang.
+[RootCause] Dynamic update for the goto control to same target page was not
+updated correctly.
+[Solution] Fixed to update the control destination page correctly.
+[Files] parse.c
+special.c
+
+***************** logo.c *****************
+User: Arunsb Date: 5/31/11 Time: 7:21p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Quiet boot logos only added for BGRT. BGRT status
+field cleared if any changes happened in screen other than displaying
+the images. BltBuffer freed in ConvertBlt2Bmp function.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and
+commonhelper.c
+
+***************** Parse.c *****************
+User: Premkumara Date: 5/31/11 Time: 9:52a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMIGTSE/Uefi2.1
+Comment:
+ [TAG] EIP48930
+[Description] Boot override hangs with exception 0x0d
+[Files] Parse.c, hii.c
+
+***************** hii.c *****************
+User: Premkumara Date: 5/31/11 Time: 9:51a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMIGTSE/uefi2.0
+Comment:
+ [TAG] EIP48930
+[Description] Boot override hangs with exception 0x0d
+[Files] hii.c, Parse.c
+
+***************** postmgmt.c *****************
+User: Arunsb Date: 5/29/11 Time: 12:09p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Quiet boot logo's only added for BGRT. BGRT status field cleared
+if any changes happened in screen other than displaying the image.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and commonhelper.c
+
+***************** logo.c *****************
+User: Arunsb Date: 5/29/11 Time: 12:07p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Quiet boot logo's only added for BGRT. BGRT status field cleared
+if any changes happened in screen other than displaying the image.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and commonhelper.c
+
+***************** boot.c *****************
+User: Arunsb Date: 5/29/11 Time: 12:04p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly
+Comment:
+ [TAG] EIP58954
+[Category] New Feature
+[Description] Quiet boot logo's only added for BGRT. BGRT status field cleared
+if any changes happened in screen other than displaying the image.
+[Files] Postmgmt.c, boot.c, logo.c commonoem.c and commonhelper.c
+
+***************** ResetButton.c *****************
+User: Madhans Date: 5/18/11 Time: 11:58a
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/TseLite
+Comment:
+ To Avoid Build issue when Multiline support is enabled.
+
+***************** minisetupext.c *****************
+User: Arunsb Date: 5/17/11 Time: 6:37p
+Checked in $/Alaska/SOURCE/Modules/AMITSE2_0/AMIGTSE/TseLite
+Comment:
+ StyleExit function added in DrawBbsPopupMenu function to clear the
+screen after bbs popup menu vanishes.
+
diff --git a/EDK/MiniSetup/uefi2.0/FormBrowser.c b/EDK/MiniSetup/uefi2.0/FormBrowser.c
new file mode 100644
index 0000000..1c500a9
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/FormBrowser.c
@@ -0,0 +1,591 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/FormBrowser.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 12 $
+//
+// $Date: 10/18/12 6:00a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/FormBrowser.c $
+//
+// 12 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 11 5/28/12 5:55a Premkumara
+// [TAG] EIP75236
+// [Category] Improvement
+// [Description] Add the support to control the GOP dependency in TSE
+// notification.
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
+// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
+//
+// 10 12/01/11 5:44a Rajashakerg
+// [TAG] EIP74963
+// [Category] Improvement
+// [Description] MAX_MSGBOX_WIDTH cannot be overridden
+// [Files] AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
+// MessageBox.c, MessageBox.h, FormBrowser.c
+//
+// 9 11/21/11 5:53a Rajashakerg
+// [TAG] EIP74591
+// [Category] Improvement
+// [Description] Make MainSetupLoop as board module hook
+// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
+// FormBrowser.c, FormBrowser2.c
+//
+// 8 11/08/11 4:56a Rajashakerg
+// Lowered the TPL to Application level and invoked
+// StyleUpdateVersionString() function to update the copy right string in
+// the SendForm() function.
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 9 8/13/10 10:14a Mallikarjunanv
+// EIP-40056: Updated with the modified function call GetControlHeight
+//
+// 8 2/26/10 6:56p Madhans
+// To validate the Hii Handle
+//
+// 6 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/27/10 12:59p Madhans
+// // EIP 33804 : Issue iSCSI initiator name is not saved..
+//
+// 4 1/09/10 7:31a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/23/09 6:51p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:08p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 1 2/06/09 4:10p Madhans
+// FormBorwser protocol support added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: FormBrowser.c
+//
+// Description: This file contains code for form browser
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#include EFI_PROTOCOL_DEFINITION(FormCallback)
+extern EFI_HII_PROTOCOL *gHiiProtocol;
+
+#if SETUP_FORM_BROWSER_SUPPORT
+EFI_STATUS
+MinisetupSendForm (
+ IN EFI_FORM_BROWSER_PROTOCOL * This,
+ IN BOOLEAN UseDatabase,
+ IN EFI_HII_HANDLE * Handle,
+ IN UINTN HandleCount,
+ IN EFI_IFR_PACKET * Packet,
+ IN EFI_HANDLE CallbackHandle,
+ IN UINT8 *NvMapOverride,
+ IN SCREEN_DESCRIPTOR * ScreenDimensions,
+ OUT BOOLEAN *ResetRequired
+ );
+
+EFI_STATUS
+MinisetupCreatePopup (
+ IN UINTN NumberOfLines,
+ IN BOOLEAN HotKey,
+ IN UINTN MaximumStringSize,
+ OUT CHAR16 *StringBuffer,
+ OUT EFI_INPUT_KEY * KeyValue,
+ IN CHAR16 *String,
+ ...
+ );
+
+EFI_FORM_BROWSER_PROTOCOL gFormBrowserProtocol =
+{
+ MinisetupSendForm,
+ MinisetupCreatePopup
+};
+
+VOID* *gSfHandles;
+UINTN gSfHandleCount;
+UINT8 *gSfNvMap;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MinisetupSendForm
+//
+// Description: Function implements the SendForm interface of Formbrowser
+// Protocol. UseDatabase=True is only supported.
+//
+// Input: Refer Spec. Packet,CallbackHandle, ScreenDimensions and ResetRequired
+// parameters ignored.
+//
+// IN EFI_FORM_BROWSER_PROTOCOL * This,
+// IN BOOLEAN UseDatabase,
+// IN EFI_HII_HANDLE * Handle,
+// IN UINTN HandleCount,
+// IN EFI_IFR_PACKET * Packet,
+// IN EFI_HANDLE CallbackHandle,
+// IN UINT8 *NvMapOverride,
+// IN SCREEN_DESCRIPTOR * ScreenDimensions,
+// OUT BOOLEAN *ResetRequired
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MinisetupSendForm (
+ IN EFI_FORM_BROWSER_PROTOCOL * This,
+ IN BOOLEAN UseDatabase,
+ IN EFI_HII_HANDLE * Handles,
+ IN UINTN HandleCount,
+ IN EFI_IFR_PACKET * Packet,
+ IN EFI_HANDLE CallbackHandle,
+ IN UINT8 *NvMapOverride,
+ IN SCREEN_DESCRIPTOR * ScreenDimensions,
+ OUT BOOLEAN *ResetRequired
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN i;
+ if(UseDatabase)
+ {
+ if( Handles == NULL || HandleCount == 0 )
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+#ifndef STANDALONE_APPLICATION
+ if ( ! gConsoleControl )
+ {
+ //All necessary protocols are not available yet.
+ //We can still proceed if Uga Draw is the only protocol not available yet.
+ ActivateApplication();
+
+ if (!IsDelayLogoTillInputSupported()) //EIP-75236
+ ActivateInput();
+ }
+#endif
+
+ //Initialize send form global variables
+ if(HandleCount)
+ {
+ gSfHandles = EfiLibAllocateZeroPool( HandleCount * sizeof(VOID*));
+ gSfHandleCount = 0;
+ for(i=0;i<HandleCount;i++)
+ {
+ UINT8 *FormSet = NULL;
+ UINTN Length = 0;
+ // Check if the Handle Has Forms to Display
+ FormSet = _HiiGetForm( (VOID*)Handles[i], 0, &Length);
+ if( FormSet != NULL )
+ {
+ gSfHandles[gSfHandleCount] = (VOID*)(UINTN)Handles[i];
+ MemFreePointer( &FormSet );
+ gSfHandleCount++;
+ }
+ }
+ if( gSfHandleCount == 0 )
+ {
+ MemFreePointer( (VOID**)&gSfHandles );
+ return EFI_NOT_FOUND;
+ }
+ }
+
+
+ gSfNvMap = NvMapOverride;
+
+ if(!gVariableList)
+ VarLoadVariables( (VOID **)&gVariableList, NULL );
+
+ // this *MUST* be run a EFI_TPL_APPLICATION
+ gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT
+ gBS->RestoreTPL( EFI_TPL_APPLICATION );
+
+ StyleUpdateVersionString();
+
+ //Show forms
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook
+
+ //Reset send form global variables
+ MemFreePointer( (VOID**)&gSfHandles );
+ gSfHandles = NULL;
+
+ gSfHandleCount = 0;
+ gSfNvMap = NULL;
+
+ return Status;
+ }
+ else
+ {
+ return EFI_UNSUPPORTED;
+ }
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MinisetupCreatePopup
+//
+// Description: Function implements the CreatePopup interface of Formbrowser
+// Protocol.
+//
+// Input:
+// IN UINTN NumberOfLines,
+// IN BOOLEAN HotKey,
+// IN UINTN MaximumStringSize,
+// OUT CHAR16 *StringBuffer,
+// OUT EFI_INPUT_KEY * KeyValue,
+// IN CHAR16 *String,
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+MinisetupCreatePopup (
+ IN UINTN NumberOfLines,
+ IN BOOLEAN HotKey,
+ IN UINTN MaximumStringSize,
+ OUT CHAR16 *StringBuffer,
+ OUT EFI_INPUT_KEY * KeyValue,
+ IN CHAR16 *String,
+ ...
+ )
+{
+ VA_LIST Marker;
+ MEMO_DATA **memo;
+ POPUP_DATA *popup = NULL;
+ CONTROL_INFO dummy;
+ AMI_IFR_MSGBOX MsgData;
+ VOID *ScreenBuf;
+ UINT16 *textToken;
+ UINT16 Height =0 ;
+ EFI_IFR_SUBTITLE *buff;
+ CONTROL_INFO *MemoCtrlData;
+ EFI_STATUS Status;
+ UINTN i;
+ CONTROL_ACTION MappedAction = ControlActionUnknown;
+ UINTN StrIndex = 0;
+ EFI_INPUT_KEY Key;
+ CHAR16 *EditString;
+
+ if (HotKey)
+ {
+ if (KeyValue == NULL)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ else
+ {
+ if (StringBuffer == NULL)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //Put strings in Hii
+ VA_START (Marker, String);
+ textToken = EfiLibAllocateZeroPool(NumberOfLines*sizeof(UINT16));
+ i=0;
+ textToken[i] = HiiChangeString(gHiiHandle, textToken[i], String);
+ i++;
+ for(;i<NumberOfLines; i++)
+ {
+ textToken[i] = HiiChangeString(gHiiHandle, textToken[i], VA_ARG (Marker, CHAR16 *));
+ }
+
+ //Create
+ gPopup.Create(&popup);
+
+ //Init
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = INVALID_HANDLE;
+
+ MsgData.Opcode = 0;
+ MsgData.Length = 0;
+ MsgData.Title = 0;
+ MsgData.TextHandle = INVALID_HANDLE;
+ MsgData.Text = 0;
+
+ dummy.ControlPtr = (VOID*) (&MsgData);
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gPopup.Initialize( popup, &dummy );
+ if (EFI_ERROR(Status))
+ return Status;
+
+ // To fix the Color of the popup Box.
+ SetControlColorsHook( NULL, NULL, NULL , NULL, NULL , NULL, NULL ,
+ NULL , NULL, NULL,NULL ,
+ NULL,NULL ,&(popup->FGColor),&(popup->BGColor) );
+
+ popup->Container = NULL;
+ popup->Border =TRUE;
+ popup->Width = GetMsgboxWidth(); //EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
+ popup->Height = 4;
+
+ MemoCtrlData = EfiLibAllocateZeroPool(NumberOfLines*sizeof(CONTROL_INFO));
+ memo = EfiLibAllocateZeroPool(NumberOfLines*sizeof(MEMO_DATA *));
+ for(i=0;i<NumberOfLines;i++)
+ {
+ gMemo.Create(&(memo[i]));
+ buff = EfiLibAllocateZeroPool(sizeof(EFI_IFR_SUBTITLE));
+ buff->Header.OpCode = EFI_IFR_SUBTITLE_OP ;
+ buff->Header.Length = sizeof(EFI_IFR_SUBTITLE) ;
+ buff->SubTitle= textToken[i];
+ MemoCtrlData[i].ControlPtr = (VOID*)buff;
+ MemoCtrlData[i].ControlHandle = INVALID_HANDLE;
+ MemoCtrlData[i].ControlFlags.ControlVisible = TRUE;
+ gMemo.Initialize(memo[i],(VOID *)&(MemoCtrlData[i]));
+ memo[i]->Width = popup->Width - 2;
+//EIP:40056 - START
+//Updated with the modified function
+ // gMemo.GetTextHeight( memo[i], &Height );
+ gMemo.GetControlHeight( memo[i], NULL, &Height );
+//EIP:40056 - END
+ popup->Height = popup->Height + Height;
+ gMemo.SetAttributes(memo[i],popup->FGColor ,popup->BGColor);
+ gMemo.SetDimensions( memo[i], popup->Width-2 , Height );
+ gMemo.SetJustify( memo[i], JUSTIFY_CENTER );
+ }
+
+
+ //Draw
+ ScreenBuf = SaveScreen();
+ Status = gPopup.Draw( popup );
+ if(EFI_ERROR(Status))
+ return Status;
+ Height = popup->Top + 2;
+ for(i=0;i<NumberOfLines;i++)
+ {
+ gMemo.SetPosition( memo[i], popup->Left + 1, Height);
+ gMemo.Draw( memo[i] );
+ Height = Height + memo[i]->Height;
+ }
+
+ FlushLines( popup->Top, popup->Top + popup->Height );
+ DoRealFlushLines();
+
+ //Getkeys
+ gST->ConIn->Reset( gST->ConIn, FALSE );
+ EditString = EfiLibAllocateZeroPool(MaximumStringSize);
+ while(
+ (MappedAction != ControlActionSelect) &&
+ (MappedAction != ControlActionAbort)
+ )
+ {
+ if(EFI_SUCCESS == gST->ConIn->ReadKeyStroke( gST->ConIn, &Key ))
+ {
+ AMI_EFI_KEY_DATA AmiKey;
+ AmiKey.Key = Key;
+ MappedAction = MapControlKeysHook(AmiKey);
+
+ if(HotKey)
+ {
+ *KeyValue = Key;
+ break;
+ }
+ else
+ {
+ if((ControlActionAlpha == MappedAction) || (ControlActionNumeric == MappedAction))
+ {
+ if(StrIndex < (MaximumStringSize/2))
+ {
+ EditString[StrIndex] = Key.UnicodeChar;
+ StrIndex++;
+ }
+ }
+ }
+ }
+ }
+
+ if(MappedAction == ControlActionSelect && !HotKey)
+ {
+ MemCopy(StringBuffer, EditString, MaximumStringSize);
+ }
+
+ //Destroy
+ Status = gPopup.Destroy( popup, TRUE );
+ MemFreePointer( (VOID **)&(textToken) );
+ for(i=0;i<NumberOfLines;i++)
+ {
+ MemFreePointer( (VOID **)&(memo[i]->ControlData.ControlPtr) );
+ Status = gMemo.Destroy( memo[i], TRUE );
+ }
+ MemFreePointer( (VOID **)&(MemoCtrlData) );
+ MemFreePointer( (VOID **)&(memo) );
+ MemFreePointer( (VOID **)&(EditString) );
+
+ RestoreScreen( ScreenBuf );
+
+ //Return
+ return EFI_SUCCESS;
+}
+#endif //#if SETUP_FORM_BROWSER_SUPPORT
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InstallFormBrowserProtocol
+//
+// Description: Installs the Formbrowser Protocol in the given handle if
+// SETUP_FORM_BROWSER_SUPPORT is on.
+//
+// Input: IN EFI_HANDLE Handle
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle)
+{
+#if SETUP_FORM_BROWSER_SUPPORT
+ EFI_STATUS Status;
+ Status = gBS->InstallMultipleProtocolInterfaces(
+ &Handle,
+ &gEfiFormBrowserProtocolGuid, &gFormBrowserProtocol,
+ NULL
+ );
+ return Status;
+#else
+ return EFI_SUCCESS;
+#endif //#if SETUP_FORM_BROWSER_SUPPORT
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UnInstallFormBrowserProtocol
+//
+// Description: Uninstalls the Formbrowser Protocol in the given handle if
+// SETUP_FORM_BROWSER_SUPPORT is on.
+//
+// Input: IN EFI_HANDLE Handle
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle)
+{
+#if SETUP_FORM_BROWSER_SUPPORT
+ gBS->UninstallMultipleProtocolInterfaces(
+ &Handle,
+ &gEfiFormBrowserProtocolGuid, &gFormBrowserProtocol,
+ NULL
+ );
+#endif //#if SETUP_FORM_BROWSER_SUPPORT
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FormBrowserHandleValid
+//
+// Description: return True Browser is showing forms from SendForm interface.
+//
+// Input: none
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN FormBrowserHandleValid(VOID)
+{
+#if SETUP_FORM_BROWSER_SUPPORT
+ if(gSfHandles)
+ return TRUE;
+#endif
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FormBrowserLocateSetupHandles
+//
+// Description: return Handles and count that is passed to SendForm interface.
+//
+// Input: OUT handleBuffer and count
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FormBrowserLocateSetupHandles(VOID* **handleBuffer,UINT16 *count)
+{
+#if SETUP_FORM_BROWSER_SUPPORT
+ if(gSfHandles)
+ {
+ *handleBuffer = (VOID**)gSfHandles;
+ *count = (UINT16)gSfHandleCount;
+ return EFI_SUCCESS;
+ }
+ else
+ return EFI_NOT_FOUND;
+#else
+ return EFI_UNSUPPORTED;
+#endif
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/Hiicallback.c b/EDK/MiniSetup/uefi2.0/Hiicallback.c
new file mode 100644
index 0000000..efdbaf8
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/Hiicallback.c
@@ -0,0 +1,429 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/Hiicallback.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 11 $
+//
+// $Date: 3/25/13 8:35a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/Hiicallback.c $
+//
+// 11 3/25/13 8:35a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 10 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 1/09/12 1:53a Arunsb
+// [TAG] EIP79952
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Add driver option displays select boot option as title
+// [RootCause] Title problem
+// [Solution] Title changes
+// [Files] Faketokens.c, amitsestr.uni, addbootoption.c,
+// uefi2.0\hiicallback.c and uefi21wapper.c
+//
+// 8 12/02/11 1:51a Premkumara
+// [TAG] EIP73226
+// [Category] New Feature
+// [Description] Extended support for password prompt
+// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c,
+// HiiCallback.c, Uefi20Wapper.c
+//
+// 7 5/02/11 9:56a Arunsb
+// [TAG] EIP58126
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] System boot into setup page, it will popup "ME Update Info"
+// [RootCause] Different actions allowed in 2.0 version also
+// [Solution] Only update action is handled in 2.0 version
+// [Files] uefi2.0\Hiicallback.c, uefi2.1\Hiicallback.c, Commonhelper.c
+//
+// 6 3/21/11 12:52a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 7 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 6 1/09/10 7:27a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 1/04/10 10:40a Mallikarjunanv
+// EIPs 27161/29095 - Added support for reserved boot option names and
+// added support not to create empty boot option names
+//
+// 4 6/24/09 6:11p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:51p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 2 5/07/09 10:36a Madhans
+// Changes after Bin module
+//
+// 1 4/28/09 11:09p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: HiiCallback.c
+//
+// Description: This file contains code for Hii callback operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#include EFI_PROTOCOL_DEFINITION(FormCallback)
+extern EFI_HII_PROTOCOL *gHiiProtocol;
+
+
+static STRING_REF CallbackErrToken=0;
+
+AMI_IFR_MSGBOX _PreviousMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_PREVIOUS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_PREVIOUS_MSG) };
+AMI_IFR_MSGBOX _FailsafeMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_FAILSAFE_MSG) };
+AMI_IFR_MSGBOX _OptimalMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_OPTIMAL_MSG) };
+AMI_IFR_MSGBOX _SaveMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_VALUES), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) };
+AMI_IFR_MSGBOX _SaveExitMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_EXIT_MSG) };
+AMI_IFR_MSGBOX _ExitMsgBox = { 0, 0, STRING_TOKEN(STR_EXIT), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_EXIT_MSG) };
+AMI_IFR_MSGBOX _SaveResetMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_RESET_MSG) };
+AMI_IFR_MSGBOX _ResetMsgBox = { 0, 0, STRING_TOKEN(STR_RESET), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_RESET_MSG) };
+AMI_IFR_MSGBOX _HelpMsgBox = { 0, 0, STRING_TOKEN(STR_GENERAL_HELP), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_GENERAL_HELP_MSG) };
+AMI_IFR_MSGBOX _SaveUserMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_USER_DEFAULTS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) };
+AMI_IFR_MSGBOX _LoadUserMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_USER_DEFAULTS), (VOID*)(UINTN)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_USER_MSG) };
+
+AMI_IFR_MSGBOX _InvalidPasswordFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR),(VOID*)(UINTN) INVALID_HANDLE, STRING_TOKEN(STR_ERROR_PSWD) };
+AMI_IFR_MSGBOX _ClearPasswordMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR) };//EIP:73226 To Clear Old Password message
+AMI_IFR_MSGBOX _ClearPasswordLabelMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR_LABEL) };//EIP:73226 To Clear Old Password message
+AMI_IFR_MSGBOX _BootLaunchFailedMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_WARNING_NOT_FOUND) };
+
+AMI_IFR_MSGBOX _gInvalidRangeFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), INVALID_HANDLE, STRING_TOKEN(STR_ERROR_INPUT) };
+
+AMI_IFR_MSGBOX _gDelBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_DEL_BOOT_OPTION_RESERVED) };
+AMI_IFR_MSGBOX _gAddBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_RESERVED) };
+AMI_IFR_MSGBOX _gAddBootOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_EMPTY) };
+AMI_IFR_MSGBOX _gAddDriverOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_DRIVER_OPTION_EMPTY) };
+
+UINTN gPreviousMsgBox = (UINTN)&_PreviousMsgBox;
+UINTN gFailsafeMsgBox = (UINTN)&_FailsafeMsgBox;
+UINTN gOptimalMsgBox = (UINTN)&_OptimalMsgBox;
+UINTN gSaveMsgBox = (UINTN)&_SaveMsgBox;
+UINTN gSaveExitMsgBox = (UINTN)&_SaveExitMsgBox;
+UINTN gExitMsgBox = (UINTN)&_ExitMsgBox;
+UINTN gSaveResetMsgBox = (UINTN)&_SaveResetMsgBox;
+UINTN gResetMsgBox = (UINTN)&_ResetMsgBox;
+UINTN gHelpMsgBox = (UINTN)&_HelpMsgBox;
+UINTN gSaveUserMsgBox = (UINTN)&_SaveUserMsgBox;
+UINTN gLoadUserMsgBox = (UINTN)&_LoadUserMsgBox;
+UINTN gBootLaunchFailedMsgBox = (UINTN)&_BootLaunchFailedMsgBox;
+UINTN gInvalidPasswordFailMsgBox=(UINTN)&_InvalidPasswordFailMsgBox;
+UINTN gClearPasswordMsgBox=(UINTN)&_ClearPasswordMsgBox;//EIP:73226 To display Clear Old Password message
+UINTN gClearLabelPasswordMsgBox = (UINTN)&_ClearPasswordLabelMsgBox;
+UINTN gInvalidRangeFailMsgBox=(UINTN)&_gInvalidRangeFailMsgBox;
+UINTN gDelBootOptionReserved = (UINTN)&_gDelBootOptionReserved;
+UINTN gAddBootOptionReserved = (UINTN)&_gAddBootOptionReserved;
+UINTN gAddBootOptionEmpty = (UINTN)&_gAddBootOptionEmpty;
+UINTN gAddDriverOptionEmpty = (UINTN)&_gAddDriverOptionEmpty;
+
+static AMI_IFR_MSGBOX gCallbackErrorMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), (VOID*)(UINTN)INVALID_HANDLE, 0 };
+EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle );
+EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index );
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CallFormCallBack
+//
+// Description: To call form callback
+//
+// Input: CONTROL_INFO * pControlData,
+// UINT16 Key,
+// UINT8 Flags
+// UINTN Action
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CallFormCallBack(CONTROL_INFO * pControlData,UINT16 Key,UINT8 Flags,UINTN Action)//EIP-53480: Implementation of FormBrowser with actions support
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL;
+ EFI_IFR_FORM_SET *FormSet = NULL;
+ EFI_IFR_DATA_ARRAY * callbackData = NULL;
+ EFI_HII_CALLBACK_PACKET *Packet =NULL ;
+ UINTN Size;
+
+ if (AMI_CALLBACK_CONTROL_UPDATE != Action)
+ {
+ return EFI_UNSUPPORTED;
+ }
+ FormSet = HiiGetFormSetFromHandle( pControlData->ControlHandle );//HiiGetFormSet( 0 );
+
+ callbackData = EfiLibAllocateZeroPool( 0x10000 );
+ if(callbackData == NULL)
+ return EFI_OUT_OF_RESOURCES;
+
+ callbackData->NvRamMap = gVariableList[ pControlData->ControlVariable ].Buffer;
+
+
+ if ( FormSet != NULL )
+ {
+ callbackData->EntryCount = 1;
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->OpCode = ((EFI_IFR_OP_HEADER *)(pControlData->ControlPtr))->OpCode;
+ switch(((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->OpCode)
+ {
+ case EFI_IFR_STRING_OP:
+ Size = ((EFI_IFR_STRING *)(pControlData->ControlPtr))->MaxSize * 2;
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8)Size + 4;
+ MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_STRING *)(pControlData->ControlPtr))->QuestionId,Size);
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ Size = ((EFI_IFR_NUMERIC *)(pControlData->ControlPtr))->Width;
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4;
+ MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_NUMERIC *)(pControlData->ControlPtr))->QuestionId,Size);
+ break;
+ case EFI_IFR_REF_OP:
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = 6;
+ MemCopy(&(callbackData->Data[0].Data),&((EFI_IFR_REF *)(pControlData->ControlPtr))->FormId,2);
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ Size = ((EFI_IFR_ONE_OF *)(pControlData->ControlPtr))->Width;
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4;
+ MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_ONE_OF *)(pControlData->ControlPtr))->QuestionId,Size);
+ break;
+ //EIP-16541 : for EFIMEBX checkbox call back handle.
+ case EFI_IFR_CHECKBOX_OP:
+ Size = ((EFI_IFR_CHECK_BOX *)(pControlData->ControlPtr))->Width;
+ ((EFI_IFR_OP_HEADER*)&(callbackData->Data[0]))->Length = (UINT8) Size + 4;
+ MemCopy(&(callbackData->Data[0].Data),(UINT8 *)callbackData->NvRamMap+((EFI_IFR_CHECK_BOX *)(pControlData->ControlPtr))->QuestionId,Size);
+ break;
+ default:
+ callbackData->EntryCount=0;
+ }
+
+ Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack);
+
+
+ if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) )
+ Status = FormCallBack->Callback( FormCallBack, Key, callbackData, &Packet );
+
+
+ if(EFI_ERROR(Status))
+ if(Packet != NULL)
+ {
+ if(Packet->String!=NULL)
+ { EFI_STATUS Sts;
+ Sts = gHiiProtocol->NewString(gHiiProtocol,NULL,(EFI_HII_HANDLE)(UINTN)gHiiHandle,&CallbackErrToken, Packet->String);
+ gCallbackErrorMsgBox.Text=CallbackErrToken;
+ if(!EFI_ERROR(Sts))
+ CallbackShowMessageBox( (UINTN)&gCallbackErrorMsgBox, MSGBOX_TYPE_OK );
+ }
+ MemFreePointer( (VOID *)&Packet);
+ }
+ }
+
+ MemFreePointer( (VOID *)&callbackData);
+ return Status;
+}
+
+#if !TSE_USE_EDK_LIBRARY
+
+#pragma pack(1)
+typedef struct {
+ UINT8 OpCode; // Likely a string, numeric, or one-of
+ UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet
+ UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback
+ VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately
+ // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value
+ // If the OpCode is a String type - Data is a CHAR16[x] type
+ // If the OpCode is a Checkbox type - Data is a UINT8 value
+ // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure
+ //
+} TSE_EFI_IFR_DATA_ENTRY;
+
+typedef struct {
+ VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map,
+ // this is a pointer to a buffer copy
+ //
+ UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries
+ TSE_EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries.
+} TSE_EFI_IFR_DATA_ARRAY;
+
+#pragma pack()
+#else
+#define TSE_EFI_IFR_DATA_ARRAY EFI_IFR_DATA_ARRAY
+#endif // TSE_USE_EDK_LIBRARY
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CallTextCallBack
+//
+// Description: Fuction to call text callback
+//
+// Input: TEXT_DATA *text, ACTION_DATA *Data
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if ( --(text->Interval) == 0 )
+ {
+ EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL;
+ EFI_IFR_FORM_SET *FormSet = NULL;
+ EFI_IFR_TEXT *ifrPtr;
+ TSE_EFI_IFR_DATA_ARRAY callbackData;
+ UINT16 DataArray[2];
+ EFI_HII_CALLBACK_PACKET *Packet =NULL ;
+
+ // initialize the interval
+ text->Interval = (UINT8)(text->ControlData.ControlFlags.ControlRefresh);
+ if ( text->Callback )
+ text->Callback( text->Container, text, text->Cookie );
+
+ MemSet( &callbackData, sizeof(callbackData), 0 );
+ ifrPtr = (EFI_IFR_TEXT *)text->ControlData.ControlPtr;
+ if ( ifrPtr->Flags & EFI_IFR_FLAG_NV_ACCESS )
+ callbackData.NvRamMap = gVariableList[ text->ControlData.ControlVariable ].Buffer;
+
+ callbackData.EntryCount = 1;
+ // token number of string to update
+ DataArray[0] = (UINT16)(UINTN)text->ControlData.ControlHandle;
+ DataArray[1] = ifrPtr->TextTwo;
+ callbackData.Data[0].Data = DataArray;
+
+ FormSet = HiiGetFormSetFromHandle( text->ControlData.ControlHandle );//HiiGetFormSet( 0 );
+
+ if ( FormSet != NULL )
+ {
+ Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack);
+
+ if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) )
+ Status = FormCallBack->Callback( FormCallBack, ifrPtr->Key, (EFI_IFR_DATA_ARRAY*)&callbackData, &Packet/*NULL*/ );
+
+ }
+
+ return EFI_SUCCESS;
+ }
+ return EFI_UNSUPPORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SpecialActionCallBack
+//
+// Description: Callback for UEFI Action control. This is used only in UEFI 2.1
+//
+// Input: CONTROL_INFO * ControlData, UINT16 Key
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key)
+{
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UEFICallSetupFormCallBack
+//
+// Description: Wrapper function for the Implementation of FormBrowser with actions support .This is used only in UEFI 2.1
+//
+// Input: UINTN Action
+//
+// Output: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UEFICallSetupFormCallBack(UINTN Action )
+{//EIP-53480: Implementation of FormBrowser with actions support
+
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/Uefi20.cif b/EDK/MiniSetup/uefi2.0/Uefi20.cif
new file mode 100644
index 0000000..05cd078
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/Uefi20.cif
@@ -0,0 +1,16 @@
+<component>
+ name = "TSE Sources - UEFI2.0"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\uefi2.0"
+ RefName = "Uefi20"
+[files]
+"uefi20.sdl"
+"uefi20.mak"
+"hii.h"
+"hii.c"
+"ctrlcond.h"
+"ctrlcond.c"
+"Hiicallback.c"
+"uefi20Wapper.c"
+"FormBrowser.c"
+<endComponent>
diff --git a/EDK/MiniSetup/uefi2.0/ctrlcond.c b/EDK/MiniSetup/uefi2.0/ctrlcond.c
new file mode 100644
index 0000000..fd962fa
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/ctrlcond.c
@@ -0,0 +1,840 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 10 $
+//
+// $Date: 10/18/12 6:00a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.c $
+//
+// 10 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 9 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 9 11/01/11 10:54a Madhans
+// [TAG] EIP51899
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Some Condition evaluation is broken.
+// [RootCause] VAREQVAL is considering all the variable's size as UINTN.
+// [Solution] It should based on the size of Variable.
+// [Files] ctrlcond.c
+//
+// 8 3/29/11 1:15p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 7 3/29/11 1:11p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 6 3/23/10 3:39p Blaines
+// EIP-36010
+//
+// Fix for suppressif used with grayout condition.
+//
+//
+// 5 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 6 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 5 1/09/10 7:26a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 4 6/24/09 6:11p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:51p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:08p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ctrlcond.c
+//
+// Description: This file contains code for control conditions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include "ctrlcond.h"
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#include EFI_PROTOCOL_DEFINITION(FormCallback)
+extern EFI_HII_PROTOCOL *gHiiProtocol;
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetVarNumFromID
+//
+// Description: To get var number from ID
+//
+// Input: unsigned int ID
+//
+// Output: VarCount
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+int GetVarNumFromID(unsigned int ID)
+{
+ unsigned int i=0;
+
+ while( ( ((VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[i]))->VariableID != ID) && (i < gVariables->VariableCount))
+ i++;
+
+ return i;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckControlAccess
+//
+// Description: To check control flags
+//
+// Input: UINT32 ControlAccess
+//
+// Output: Condition
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckControlAccess(UINT32 ControlAccess)
+{
+ UINT8 Cond = COND_NONE;
+
+ if(gPasswordType == AMI_PASSWORD_USER)
+ {
+ switch(ControlAccess)
+ {
+ case CONTROL_ACCESS_ADMIN: // suppress
+ Cond = COND_SUPPRESS;
+ break;
+ case CONTROL_ACCESS_USER: // grayout (read-only)
+ Cond = COND_GRAYOUT;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return Cond;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateFinalCondition
+//
+// Description: To finalize the codition flag
+//
+// Input: UINT8 FinalCond, UINT8 Cond
+//
+// Output: Condition
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UpdateFinalCondition(UINT8 FinalCond, UINT8 Cond)
+{
+ switch(FinalCond)
+ {
+ case COND_NONE:
+ return(Cond);
+ break;
+
+ case COND_SUPPRESS:
+ case COND_HIDDEN:
+ return(FinalCond);
+ break;
+
+ case COND_GRAYOUT:
+ if(Cond != COND_NONE)
+ return(Cond);
+ break;
+
+ case COND_INCONSISTENT:
+ return(Cond);
+ break;
+
+ }
+ return(FinalCond);
+}
+//check condition
+#if TSE_SUPPORT_VFRCOMPILE_1_88
+
+static UINT8 Operands[10], StackPos;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EvaluateOpcode
+//
+// Description: To perform the stack operations based on the opcode
+//
+// Input: UINT8 OpCode
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID EvaluateOpcode(UINT8 OpCode)
+{
+ switch(OpCode)
+ {
+ case EFI_IFR_NOT_OP:
+ if(StackPos >= 1) //atleast one operand should be there
+ {
+ Operands[StackPos-1] = (Operands[StackPos-1] == 0) ? 1:0;
+ //No need to change the stack position because the
+ //result goes in the operands position
+ }
+ break;
+ case EFI_IFR_AND_OP:
+ if(StackPos >= 2)//atleast two oprerands should be there
+ {
+ Operands[StackPos-2] &= (Operands[StackPos-1]);
+ //Move stack position only one down. Result takes the
+ //second operands position
+ StackPos--;
+ }
+ break;
+ case EFI_IFR_OR_OP:
+ if(StackPos >= 2)//atleast two oprerands should be there
+ {
+ Operands[StackPos-2] |= (Operands[StackPos-1]);
+ //Move stack position only one down. Result takes the
+ //second operands position
+ StackPos--;
+ }
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetExpResult
+//
+// Description: Function to get exp result
+//
+// Input: nil
+//
+// Output: result
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 GetExpResult()
+{
+ UINT8 result = 0;
+
+ if(StackPos)
+ {
+ if(StackPos == 1)
+ {
+ result = Operands[0];
+ }
+ else
+ {
+ //Error condition!!!
+ }
+ }
+
+ StackPos = 0;
+
+ return result;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckControlCondition
+//
+// Description: This function eveluates the condition and retuns the result
+//
+// Input: Control Info
+//
+// Output: COND_NONE - Condition failed.
+// COND_SUPPRESS - Condition matchs suppress
+// COND_GRAYOUT - Condition matchs Grayout
+// COND_HIDDEN - Condition matchs and Hide
+// COND_INCONSISTENT - Inconsistent Condition matchs
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckControlCondition( CONTROL_INFO *controlInfo )
+{
+ // Used to be a long list of parameters
+ UINT32 CtrlAccess;
+ UINT8 *CondPtr;
+ UINT32 i=0;
+ UINT32 VarId1, VarId2;
+ UINT8 Cond = COND_NONE, FinalCond = COND_NONE;
+
+ UINT32 Val1 = 0, Val2 = 0;
+ BOOLEAN Inside = TRUE;
+
+ EFI_IFR_EQ_ID_VAL *IDValPtr;
+ EFI_IFR_EQ_ID_LIST *IDListPtr;
+ EFI_IFR_EQ_VAR_VAL *VarValPtr;
+ EFI_IFR_EQ_ID_ID *IDIDPtr;
+
+ CondPtr = (UINT8 *)controlInfo->ControlConditionalPtr;
+ CtrlAccess = controlInfo->ControlFlags.ControlAccess;
+
+ if ( CondPtr == NULL )
+ return ( CheckControlAccess(CtrlAccess) );
+
+ VarId1 = controlInfo->ControlConditionalVariable[0];
+ VarId2 = controlInfo->ControlConditionalVariable[1];
+
+
+ while( Inside )
+ {
+ switch(*(CondPtr+i))
+ {
+ case EFI_IFR_SUPPRESS_IF_OP:
+ if(GetExpResult())
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ }
+ Cond = COND_SUPPRESS;
+ break;
+
+ case EFI_IFR_GRAYOUT_IF_OP:
+ if(GetExpResult())
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ }
+ Cond = COND_GRAYOUT;
+ break;
+
+ case EFI_IFR_HIDDEN_OP:
+ if(GetExpResult())
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ }
+ Cond = COND_HIDDEN;
+ break;
+
+ case EFI_IFR_INCONSISTENT_IF_OP:
+ if(GetExpResult())
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ }
+ Cond = COND_INCONSISTENT;
+ break;
+
+ case EFI_IFR_NOT_OP:
+ case EFI_IFR_AND_OP:
+ case EFI_IFR_OR_OP:
+ EvaluateOpcode(*(CondPtr+i));
+ break;
+
+ case EFI_IFR_EQ_ID_VAL_OP:
+ IDValPtr = (VOID*)(CondPtr+i);
+//EIP:36010 - Start
+ Val1 = 0;
+//EIP:36010 - End
+ VarGetValue( VarId1, IDValPtr->QuestionId, IDValPtr->Width, &Val1 );
+ Operands[StackPos] = ( (UINT16)Val1 == IDValPtr->Value ) ? 1 : 0 ;
+ StackPos++;
+ break;
+
+ case EFI_IFR_EQ_ID_LIST_OP:
+ IDListPtr = (VOID*)(CondPtr+i);
+//EIP:36010 - Start
+ Val1 =0;
+//EIP:36010 - End
+ VarGetValue( VarId1, IDListPtr->QuestionId, IDListPtr->Width, &Val1 );
+ for ( Val2 = 0; Val2 < IDListPtr->ListLength; Val2++ )
+ {
+ if ( IDListPtr->ValueList[Val2] == Val1 )
+ {
+ Operands[StackPos] = 1;//Found a match in the list
+ break;
+ }
+ }
+ if(Val2 >= IDListPtr->ListLength)//Did not find a match
+ Operands[StackPos] = 0;
+ StackPos++;
+ break;
+
+ case EFI_IFR_EQ_ID_ID_OP:
+ IDIDPtr = (VOID*)(CondPtr+i);
+//EIP:36010 - Start
+ Val1 =0;
+ Val2 =0;
+//EIP:36010 - End
+ VarGetValue( VarId1, IDIDPtr->QuestionId1, IDIDPtr->Width, &Val1 );
+ VarGetValue( VarId2, IDIDPtr->QuestionId2, IDIDPtr->Width, &Val2 );
+ Operands[StackPos] = (UINT8)(( Val1 == Val2 ) ? 1 : 0);
+ StackPos++;
+ break;
+
+ case EFI_IFR_EQ_VAR_VAL_OP:
+ {
+ CHAR16 VarName[VARIABLE_NAME_LENGTH];
+ UINTN size, *VarVal, Value;
+ EFI_GUID *VarGuid;
+ PAGE_INFO *pageInfo;
+
+ VarValPtr = (VOID*)(CondPtr+i);
+
+ //Get the variable name
+ SPrint(VarName, sizeof(VarName), L"%d",VarValPtr->VariableId);
+
+ //Get the guid
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]);
+ VarGuid = &(gPageIdInfo[pageInfo->PageIdIndex].PageGuid);
+
+ //Get the value
+ size = 0;
+ VarVal = (UINTN *)VarGetNvramName(VarName,VarGuid,NULL,&size);
+// EIP51899 +>>
+ Value = 0;
+ if (VarVal != 0)
+ MemCopy(&Value, VarVal, size);
+ else
+ VarVal = 0;
+// EIP51899 <<+
+ // Value = VarVal ? *VarVal : 0; // EIP51899 -
+
+ Operands[StackPos] = (UINT8)(( (UINT16)Value == VarValPtr->Value ) ? 1 : 0) ;
+ StackPos++;
+
+ //Free variable memory
+ MemFreePointer((VOID **)&VarVal);
+ }
+ break;
+
+ case EFI_IFR_VARSTORE_SELECT_OP:
+ VarId1 = VarId2= GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT*)((char*)CondPtr +i))->VarId);
+ break;
+
+ case EFI_IFR_VARSTORE_SELECT_PAIR_OP:
+ VarId1 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->VarId);
+ VarId2 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->SecondaryVarId);
+ break;
+
+ case EFI_IFR_END_IF_OP:
+ default:
+ Inside = FALSE;
+ break;
+ }
+
+ // go to next opcode
+ i +=(UINT32)*(CondPtr+i+1);
+ }
+
+ if(GetExpResult())
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+
+ // if CtrlAccess is CONTROL_ACCESS_DEFAULT then do not override VFR conditions
+ if(CONTROL_ACCESS_DEFAULT != CtrlAccess)
+ {
+ FinalCond = CheckControlAccess(CtrlAccess);
+ }
+
+ return FinalCond;
+}
+#else
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckControlCondition
+//
+// Description: This function eveluates the condition and retuns the result
+//
+// Input: Control Info
+//
+// Output: COND_NONE - Condition failed.
+// COND_SUPPRESS - Condition matchs suppress
+// COND_GRAYOUT - Condition matchs Grayout
+// COND_HIDDEN - Condition matchs and Hide
+// COND_INCONSISTENT - Inconsistent Condition matchs
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckControlCondition( CONTROL_INFO *controlInfo )
+{
+ // Used to be a long list of parameters
+ UINT32 CtrlAccess;
+ UINT8 *CtrlPtr;
+ UINT32 CtrlVar, CtrlVar2;
+ UINT8 *CondPtr;
+
+ UINT8 Cond = COND_NONE, FinalCond = COND_NONE, tempresult = FALSE, result = FALSE, x;
+ UINT8 OpStack[5], StackPos = 0;
+ UINT32 i=0,Var = 0, Var2 = 0;
+ EFI_IFR_EQ_ID_VAL *IDValPtr;
+ EFI_IFR_EQ_ID_LIST *IDListPtr;
+ EFI_IFR_EQ_VAR_VAL *VarValPtr;
+ EFI_IFR_EQ_ID_ID *IDIDPtr;
+
+ BOOLEAN Inside = TRUE;
+
+ UINT32 tCtrlVar, tCtrlVar2;
+
+ CtrlAccess = controlInfo->ControlFlags.ControlAccess;
+ CtrlPtr = (UINT8 *)controlInfo->ControlPtr;
+ tCtrlVar =
+ CtrlVar = controlInfo->ControlConditionalVariable[0];
+ tCtrlVar2 =
+ CtrlVar2 = controlInfo->ControlConditionalVariable[1];
+ CondPtr = (UINT8 *)controlInfo->ControlConditionalPtr;
+
+ if ( CondPtr == NULL )
+ return ( CheckControlAccess(CtrlAccess) );
+
+
+ while( Inside )
+ {
+ Var = 0 ;
+
+ switch(*(CondPtr+i))
+ {
+ // note: (size matters!!!!) this code is done before the while loop
+ case EFI_IFR_SUPPRESS_IF_OP: // supress_if
+ if(result)
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ result = COND_NONE;
+ }
+
+ Cond = COND_SUPPRESS;
+ break;
+
+ case EFI_IFR_GRAYOUT_IF_OP: // grayout_if
+ if(result)
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ result = COND_NONE;
+ }
+ Cond = COND_GRAYOUT;
+ break;
+
+ case EFI_IFR_HIDDEN_OP: // hidden _if
+ if(result)
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ result = COND_NONE;
+ }
+ Cond = COND_HIDDEN;
+ break;
+
+ case EFI_IFR_NOT_OP:
+ /*StackPos++;
+ OpStack[StackPos] = EFI_IFR_NOT_OP ;
+ continue;
+ */
+ //break; // on purpose to go on code below (size matters)
+
+ case EFI_IFR_AND_OP:
+ /*StackPos++;
+ OpStack[StackPos] = EFI_IFR_AND_OP ;
+ tempresult = result;
+ continue;
+ */
+ //break; // on purpose to go on code below (size matters)
+
+ case EFI_IFR_OR_OP:
+ StackPos++;
+ OpStack[StackPos] = *(CondPtr+i) ;//EFI_IFR_OR_OP;
+ tempresult = result;
+ i +=(UINT32)*(CondPtr+i+1);
+ continue;
+ break;
+
+ case EFI_IFR_EQ_ID_VAL_OP:
+ IDValPtr = (VOID*)(CondPtr+i);
+ VarGetValue( tCtrlVar, IDValPtr->QuestionId, IDValPtr->Width, &Var );
+ result = ( (UINT16)Var == IDValPtr->Value ) ? 1 : 0 ;
+ break;
+
+ case EFI_IFR_EQ_ID_LIST_OP:
+ IDListPtr = (VOID*)(CondPtr+i);
+ VarGetValue( tCtrlVar, IDListPtr->QuestionId, IDListPtr->Width, &Var );
+ for ( Var2 = 0; Var2 < IDListPtr->ListLength; Var2++ )
+ {
+ result = (UINT8)( IDListPtr->ValueList[Var2] == Var );
+ if ( result )
+ break;
+ }
+ break;
+
+ case EFI_IFR_EQ_ID_ID_OP:
+ IDIDPtr = (VOID*)(CondPtr+i);
+ VarGetValue( tCtrlVar, IDIDPtr->QuestionId1, IDIDPtr->Width, &Var );
+ VarGetValue( tCtrlVar2, IDIDPtr->QuestionId2, IDIDPtr->Width, &Var2 );
+ result = (UINT8)(( Var == Var2 ) ? TRUE : FALSE); //WARN FIX
+
+ //result = ;
+ break;
+
+ case EFI_IFR_EQ_VAR_VAL_OP:
+ {
+ CHAR16 VarName[VARIABLE_NAME_LENGTH];
+ UINTN size, *VarVal, Value;
+ EFI_GUID *VarGuid;
+ PAGE_INFO *pageInfo;
+
+ VarValPtr = (VOID*)(CondPtr+i);
+
+ //Get the variable name
+ SPrint(VarName, sizeof(VarName), L"%d",VarValPtr->VariableId);
+
+ //Get the guid
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]);
+ VarGuid = &(gPageIdInfo[pageInfo->PageIdIndex].PageGuid);
+
+ //Get the value
+ size = 0;
+ VarVal = (UINTN *)VarGetNvramName(VarName,VarGuid,NULL,&size);
+ Value = VarVal ? *VarVal : 0;
+
+ result = (UINT8)(( (UINT16)Value == VarValPtr->Value ) ? TRUE : FALSE) ; //WARN FIX
+
+ //Free variable memory
+ MemFreePointer((VOID **)&VarVal);
+ }
+ break;
+
+ case EFI_IFR_VARSTORE_SELECT_OP:
+ tCtrlVar = tCtrlVar2= GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT*)((char*)CondPtr +i))->VarId);
+ // franklyn added next two lines for testing 1/10/2006
+ i +=(UINT32)*(CondPtr+i+1);
+ continue;
+ break;
+
+ case EFI_IFR_VARSTORE_SELECT_PAIR_OP:
+ tCtrlVar = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->VarId);
+ tCtrlVar2 = GetVarNumFromID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)CondPtr +i))->SecondaryVarId);
+ // franklyn added next two lines for testing 1/10/2006
+ i +=(UINT32)*(CondPtr+i+1);
+ continue;
+ break;
+
+ case EFI_IFR_INCONSISTENT_IF_OP: // grayout_if
+ if(result)
+ {
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ result = COND_NONE;
+ }
+ Cond = COND_INCONSISTENT;
+ break;
+
+ case EFI_IFR_END_IF_OP:
+ default:
+ Inside = FALSE;
+ break;
+ }
+
+ // go to next opcode
+ i +=(UINT32)*(CondPtr+i+1);
+
+ if(StackPos !=0)
+ {
+ // process stack operation with result and, if necessary, tempresult
+ switch(OpStack[StackPos])
+ {
+ case EFI_IFR_AND_OP:
+ result = tempresult & result;
+ break;
+
+ case EFI_IFR_OR_OP:
+ result = tempresult | result;
+ break;
+
+ case EFI_IFR_NOT_OP:
+ result = !result;
+ if(StackPos !=1)
+ {
+ x =result;
+ result = tempresult;
+ tempresult = x;
+ }
+ break;
+
+ default :
+ // wrong opcode!!! abort parsing and return condition false
+ return COND_NONE;
+ break;
+ }
+
+ StackPos--;
+ }
+ }
+
+ if(result)
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+
+ // if CtrlAccess is CONTROL_ACCESS_DEFAULT then do not override VFR conditions
+ if(CONTROL_ACCESS_DEFAULT != CtrlAccess)
+ {
+ FinalCond = CheckControlAccess(CtrlAccess);
+ }
+
+ return FinalCond;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckInconsistence
+//
+// Description: check for inconsistancy
+//
+// Input: PAGE_INFO *pPageInfo
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo )
+{
+ CONTROL_INFO *pControlInfo;
+ UINTN i;
+
+ //Find out if there is inconsistent value in any of the controls
+ for(i=0; i < pPageInfo->PageControls.ControlCount; i++)
+ {
+ pControlInfo = (CONTROL_INFO*)((UINT8 *)(gControlInfo) + pPageInfo->PageControls.ControlList[i]);
+ //Check if there is a CONTROL_TYPE_MSGBOX in this page
+ if(pControlInfo->ControlType == CONTROL_TYPE_MSGBOX)
+ {
+ if(CheckControlCondition(pControlInfo) == COND_INCONSISTENT)
+ {
+ //Draw message box
+ EFI_STATUS Status;
+ MSGBOX_DATA *msgbox = NULL;
+ CONTROL_INFO dummy;
+ AMI_IFR_MSGBOX MsgData;
+ ACTION_DATA *action = gApp->Action;
+
+ Status = gMsgBox.Create( &msgbox );
+ if ( EFI_ERROR( Status ) )
+ return TRUE; // Not able to draw msg box but thats ok dont allow a page switch
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = (VOID*)(UINTN)INVALID_HANDLE;
+
+ MsgData.Opcode = 0;
+ MsgData.Length = 0;
+ MsgData.Title = STRING_TOKEN(STR_INCONSISTENT_MSG_TITLE);
+ MsgData.TextHandle = pControlInfo->ControlHandle;
+ MsgData.Text = ((EFI_IFR_INCONSISTENT*)pControlInfo->ControlConditionalPtr)->Popup ; //pControlInfo->ControlHelp;
+
+ dummy.ControlPtr = (VOID*) (&MsgData);
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gMsgBox.Initialize( msgbox, &dummy );
+ if ( EFI_ERROR( Status ) )
+ {
+ gMsgBox.Destroy( msgbox, TRUE );;
+ return TRUE; // Not able to draw msg box but thats ok dont allow a page switch
+ }
+
+ gMsgBox.SetType( msgbox, MSGBOX_TYPE_OK | MSGBOX_STYLE_LEFT );
+
+ do
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gMsgBox.Draw( msgbox );
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ if(gMsgBox.HandleAction( msgbox, action ) == EFI_SUCCESS)
+ break;
+ DoRealFlushLines();
+ }while(1);
+
+ gMsgBox.Destroy( msgbox, TRUE );
+
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckNoSubmitIf
+//
+// Description: checks NoSubmitIf
+//
+// Parameter: VOID
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckNoSubmitIf( VOID)
+{
+ //NO_SUBMIT_IF is Unsupport in 2.0
+ return FALSE;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/ctrlcond.h b/EDK/MiniSetup/uefi2.0/ctrlcond.h
new file mode 100644
index 0000000..f2ae342
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/ctrlcond.h
@@ -0,0 +1,113 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 7 $
+//
+// $Date: 10/18/12 6:00a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/ctrlcond.h $
+//
+// 7 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 7 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 6 3/29/11 1:15p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 5 3/29/11 1:13p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 4 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 5 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 4 1/09/10 7:25a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:08p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: ctrlcond.h
+//
+// Description: Header file for control conditions
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+
+//definitions
+#define COND_NONE 0x0
+#define COND_SUPPRESS 0x1
+#define COND_HIDDEN 0x2
+#define COND_GRAYOUT 0x3
+#define COND_INCONSISTENT 0x4
+
+// functions
+UINT8 CheckControlCondition( CONTROL_INFO *controlInfo );
+BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo );
+BOOLEAN CheckNoSubmitIf( VOID); // EIP : NO_SUBMIT_IF
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/hii.c b/EDK/MiniSetup/uefi2.0/hii.c
new file mode 100644
index 0000000..0e6b2c8
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/hii.c
@@ -0,0 +1,3273 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 23 $
+//
+// $Date: 4/18/13 9:35a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.c $
+//
+// 23 4/18/13 9:35a Arunsb
+// Dummy functions added to avoid build error in 2.0 build
+//
+// 22 3/25/13 8:32a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 21 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 17 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 19 9/25/12 3:04p Arunsb
+// RTIfrRegFormNotificationWrapper function call removed
+//
+// 17 6/04/11 12:26p Arunsb
+// [TAG] EIP48930
+// [Description] Boot override hangs with exception 0x0d
+// [Files] uefi2.1\Parse.c, uefi2.0\hii.c
+//
+// 16 6/01/11 5:22p Blaines
+// [TAG] 61122
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If SETUP_ORPHAN_PAGES_AS_ROOT_PAGE=1, HiiExit() will cause
+// an ASSERT in pool.c if debug_mode is enabled.
+// [RootCause] HiiExit() exit attempts to free gSetupData elements
+// associated with orphaned forms..
+// [Solution] Only free gSetupData[i].FormSet if
+// gSetupData[i].FormSetLength is non-zero.
+// [Files] Hii.c
+//
+// 15 5/31/11 9:51a Premkumara
+// [TAG] EIP48930
+// [Description] Boot override hangs with exception 0x0d
+// [Files] hii.c, Parse.c
+//
+// 14 3/28/11 10:05p Premkumara
+// [TAG] 52562
+// [Category] Enhancement
+// [Description] Need to have the Fixed Limit in AMITSE module for
+// Controls, Pages and Variable etc.
+// [Files] TSEUefiHii.h, Parse.c, Hii.c, hii.c
+//
+// 13 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 12 2/03/11 3:47p Mallikarjunanv
+// Initialized the control flags properly
+//
+// 11 2/03/11 1:04p Mallikarjunanv
+// Fixed the issue in TSE Lite with respect to setting control info read
+// only flags. Which caused issues when selecting some controls.
+//
+// 10 2/03/11 12:40p Mallikarjunanv
+// [TAG] EIP48587
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Press "F3" not loading the optimized defaults for controls
+// [RootCause] Defaults were not updated properly for UEFI 2.0
+// [Solution] Updated the defaults values based on controls offsets and
+// check box controls are modified as one-of options.
+// [Files] hii.c
+//
+// 9 10/05/10 3:50p Madhans
+// [TAG] - EIP 45511
+// [Category]- BUG FIX
+// [Severity]- Major
+// [Symptom]- TSE 2.10 with UEFI 2.0 may not work with Runtime Prasing. It
+// crashs the system.
+// [RootCause]- Initilization of VARIABLE_INFO is affected becaus of UEFI
+// 2.1 modifications.
+// [Solution]- Initlize the VARIABLE_INFO Strcture with Zero.
+// [Files] - hii.c
+//
+// 8 7/23/10 5:21p Blaines
+// Fix root page processing to support Award Style setup.
+//
+// 7 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 11 2/25/10 7:08p Madhans
+// To build the defaults with the NVRAM values. This will avoid issues
+// caused when defaults load.
+//
+// 10 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 9 2/17/10 11:26p Madhans
+// default Var Attribute for the Var store updated to BS+RT+NV
+//
+// 8 1/09/10 7:25a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 12/22/09 6:40p Madhans
+// // EIP: 32318 fix for the crash issue when the page has many controls.
+//
+// 6 8/20/09 3:11p Madhans
+// //EIP 25092 : Fix to Use the HiiChangeString() to Add the string for
+// morethen one langs.
+//
+// 5 8/13/09 7:42a Mallikarjunanv
+// modified and moved the function HiiGetEfiKey from binary to uefi module
+//
+// 4 7/23/09 8:52a Mallikarjunanv
+// updated function InitFormsetLinks for eip-24060
+//
+// 3 6/23/09 6:51p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:08p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: hii.c
+//
+// Description: This file contains code to handle the uefi2.0 based hii operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#include EFI_PROTOCOL_DEFINITION(FormCallback)
+extern EFI_HII_PROTOCOL *gHiiProtocol;
+
+// Maximum supported page, variables, controls.
+#define MAX_PAGE 100
+#define MAX_CONTROLS 0xFFFF
+#define MAX_VARIABLE 100
+//---------------------------------------------------------------------------
+static VOID* *gSetupHandles = NULL;
+UINTN gSetupCount = 0;
+#pragma pack(1)
+typedef struct
+{
+ UINT8 *FormSet;
+ VOID *Handle;
+ UINT16 ClassID;
+ UINTN FormSetLength;
+ UINT8 Added; //To know if this page was present in the tool data
+ UINT16 SubClassID;
+}
+SETUP_LINK;
+#pragma pack()
+
+UINTN gDynamicPageCount=0;
+static SETUP_LINK *gSetupData = NULL;
+
+static UINT32 ControlListSize, ControlListOffset;
+
+static PAGE_LIST *PageListPtr;
+static PAGE_INFO *PageInfoPtr;
+static UINT32 PageListSize, PageListOffset, PageInfoSize, PageInfoOffset;
+
+static UINT32 AllocatedFirstPageSize = 0, FirstPageOffset = 0;
+static PAGE_INFO *FirstPage = NULL;
+
+EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle );
+EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index );
+
+UINT32 AddControlToList(CONTROL_INFO *NewControlInfo, UINT32 ControlSize);
+VOID AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize);
+VOID CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize, UINT32 *Offset, VOID *Buff, UINT32 BuffSize);
+VOID MergePageListAndInfo();
+
+
+VOID RTIfrProcessExitWrapper(VOID);
+VOID RTIfrProcessAddVarListAndPageIDListWrapper(VOID);
+BOOLEAN RTIfrProcessFormIfUpdatedWrapper(UINT16 link);
+VOID RTIfrProcessRunTimeFormsWrapper(EFI_IFR_REF **ref);
+
+VOID AddDynamicForm(UINT32 HiiIndex);
+int AddVariable(EFI_IFR_VARSTORE *Varstore);
+VOID AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize);
+VOID MergePageIdListAndInfo();
+VOID AddVariableToList(VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize);
+VOID MergeVariableListAndInfo();
+UINTN AddHpkControls(UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset);
+EFI_STATUS _DisplayErrorMessage(CHAR16 *Temp);
+
+static PAGE_ID_LIST *PageIdListPtr;
+static PAGE_ID_INFO *PageIdInfoPtr;
+static UINT32 PageIdListSize, PageIdListOffset, PageIdInfoSize, PageIdInfoOffset;
+
+static VARIABLE_LIST *VariableListPtr;
+static VARIABLE_INFO *VariableInfoPtr;
+static UINT32 VariableListSize, VariableListOffset, VariableInfoSize, VariableInfoOffset;
+
+#define DEFAULT_REFRESH_RATE 0x01
+#define DEFAULT_DATETIME_REFRESH 0x05
+#define FORM_SUBCLASS 3
+#define CONTROL_TYPE_TITLE CONTROL_TYPE_NULL
+#define CONTROL_TYPE_MASK 0x0FFF
+
+#define START_EVAL_IF 0x8000
+#define END_EVAL_IF 0x8001
+
+typedef struct PAGELINK
+{
+ UINT16 FormID; // number from hpk
+ UINT16 ParentPageID; // number from the tool
+ UINT16 PageNum; // number assigned by the tool
+
+}PageLink;
+
+typedef struct _VAR_KEY_TABLE
+{
+ UINT32 VarId;
+ UINT16 Index;
+ struct _VAR_KEY_TABLE *Next;
+}*PVAR_KEY_TABLE, VAR_KEY_TABLE;
+
+VAR_KEY_TABLE VarKeyTable;
+
+typedef struct FORMSETLINKS
+{
+ UINT16 PageCount;
+ PageLink PageLink[20];
+}FormSetLinks;
+
+FormSetLinks *FSetLinks = NULL;
+
+UINT32 CtrlVar=0, CtrlCondVar=0, CtrlCondVar2=0, ActualCondVar=0, ActualCondVar2=0;
+UINT32 controllabel=0,controlindex=0;
+UINTN updatecondvars=1;
+
+unsigned short controltypes[] =
+{
+ CONTROL_TYPE_TITLE, //#define EFI_IFR_FORM_OP 0x01
+ CONTROL_TYPE_MEMO, //#define EFI_IFR_SUBTITLE_OP 0x02
+ CONTROL_TYPE_TEXT, //#define EFI_IFR_TEXT_OP 0x03
+ 0x0, //#define EFI_IFR_GRAPHIC_OP 0x04
+ CONTROL_TYPE_POPUPSEL, //#define EFI_IFR_ONE_OF_OP 0x05
+ CONTROL_TYPE_CHECKBOX, //#define EFI_IFR_CHECKBOX_OP 0x06
+ CONTROL_TYPE_NUMERIC, //#define EFI_IFR_NUMERIC_OP 0x07
+ CONTROL_TYPE_PASSWORD, //#define EFI_IFR_PASSWORD_OP 0x08
+ 0x0, //#define EFI_IFR_ONE_OF_OPTION_OP 0x09 // ONEOF OPTION field
+ START_EVAL_IF, //#define EFI_IFR_SUPPRESS_IF_OP 0x0A
+ 0x0, //#define EFI_IFR_END_FORM_OP 0x0B
+ 0x0, //#define EFI_IFR_HIDDEN_OP 0x0C
+ 0x0, //#define EFI_IFR_END_FORM_SET_OP 0x0D
+ 0x0, //#define EFI_IFR_FORM_SET_OP 0x0E
+ CONTROL_TYPE_SUBMENU, //#define EFI_IFR_REF_OP 0x0F
+ 0x0, //#define EFI_IFR_END_ONE_OF_OP 0x10
+ //0x0, //#define EFI_IFR_END_OP EFI_IFR_END_ONE_OF_OP
+ INCONSISTENT_IF, //#define EFI_IFR_INCONSISTENT_IF_OP 0x11
+ 0x0, //#define EFI_IFR_EQ_ID_VAL_OP 0x12
+ 0x0, //#define EFI_IFR_EQ_ID_ID_OP 0x13
+ 0x0, //#define EFI_IFR_EQ_ID_LIST_OP 0x14
+ 0x0, //#define EFI_IFR_AND_OP 0x15
+ 0x0, //#define EFI_IFR_OR_OP 0x16
+ 0x0, //#define EFI_IFR_NOT_OP 0x17
+ END_EVAL_IF, //#define EFI_IFR_END_IF_OP 0x18 // for endif of inconsistentif, suppressif, grayoutif
+ START_EVAL_IF, //#define EFI_IFR_GRAYOUT_IF_OP 0x19
+ CONTROL_TYPE_DATE, //#define EFI_IFR_DATE_OP 0x1A
+ CONTROL_TYPE_TIME, //#define EFI_IFR_TIME_OP 0x1B
+ CONTROL_TYPE_POPUP_STRING, //#define EFI_IFR_STRING_OP 0x1C
+ 0x0, //#define EFI_IFR_LABEL_OP 0x1D // defines location where controls can be added
+ 0x0, //#define EFI_IFR_SAVE_DEFAULTS_OP 0x1E
+ 0x0, //#define EFI_IFR_RESTORE_DEFAULTS_OP 0x1F
+ 0x0, //#define EFI_IFR_BANNER_OP 0x20
+ 0x0, //#define EFI_IFR_INVENTORY_OP 0x21
+ 0x0, //#define EFI_IFR_EQ_VAR_VAL_OP 0x22
+ CONTROL_TYPE_ORDERED_LIST, //#define EFI_IFR_ORDERED_LIST_OP 0x23
+ CONTROL_TYPE_VARSTORE, //#define EFI_IFR_VARSTORE_OP 0x24
+ CONTROL_TYPE_VARSTORE_SELECT, //#define EFI_IFR_VARSTORE_SELECT_OP 0x25
+ CONTROL_TYPE_VARSTORE_SELECT_PAIR, //#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26
+ 0x0, //#define EFI_IFR_LAST_OPCODE EFI_IFR_VARSTORE_SELECT_PAIR_OP
+ 0x0, //#define EFI_IFR_NV_ACCESS_COMMAND 0xFF
+};
+
+
+
+UINTN TotalRootPages;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiExit
+//
+// Description: performs the operations that required to exit from HII
+//
+// Input: VOID
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HiiExit( VOID )
+{
+ UINTN i;
+
+ //Remove gSetupHandles
+ MemFreePointer((VOID**)&gSetupHandles);
+
+ // Remove memory held by gSetupData
+ for ( i = 0; i < gSetupCount; i++ )
+ {
+ //EIP:61122, Free memory only if gSetupData[i].FormSetLength is non-zero.
+ if(gSetupData[i].FormSetLength)
+ MemFreePointer(&(gSetupData[i].FormSet));
+ }
+ MemFreePointer(&gSetupData);
+ gSetupCount = 0;
+
+ MemFreePointer(&gControlInfo);
+ ControlListSize = ControlListOffset = 0;
+
+ MemFreePointer(&gApplicationData);
+
+ gPages = gToolPages;
+ PageListPtr = NULL;
+ PageInfoPtr = NULL;
+ FirstPage = NULL;
+ AllocatedFirstPageSize = FirstPageOffset = PageListSize = PageListOffset = PageInfoSize = PageInfoOffset = 0;
+
+ RTIfrProcessExitWrapper();
+
+ gVariables = gToolVariables;
+ gPageIdList = gToolPageIdList;
+ gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]);
+
+ return EFI_SUCCESS;
+}
+
+VOID FixupPage0ControlInfo( UINTN FormSet, UINTN ControlPtr, VOID* Handle)
+{
+ PAGE_INFO *pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[0]);
+ CONTROL_INFO *controlInfo = NULL;
+ UINT32 j;
+
+ if(pageInfo->PageControls.ControlCount)
+ {
+ for ( j = 0; j < pageInfo->PageControls.ControlCount; j++ )
+ {
+ controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + pageInfo->PageControls.ControlList[j]);
+ if( (ControlPtr-FormSet) == (UINTN)controlInfo->ControlPtr )
+ {
+ controlInfo->ControlHandle = Handle;
+ controlInfo->ControlPtr = (VOID*)ControlPtr;
+ }
+ }
+ }
+
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiFixupData
+//
+// Description: Function to fixup hhi data
+//
+// Input: NIL
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HiiFixupData( )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT32 i, j=0;
+
+ PAGE_INFO *pageInfo = NULL;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_IFR_REF *ref = NULL;
+
+ UINT16 link;
+
+ Status = _HiiLocateSetupHandles();
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ gSetupData = EfiLibAllocateZeroPool( sizeof(SETUP_LINK) * gSetupCount );
+ if ( gSetupData == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ gSetupData[i].FormSet = _HiiGetForm( gSetupHandles[i], 0, &(gSetupData[i].FormSetLength) );
+ if ( gSetupData[i].FormSet == NULL )
+ {
+ // make sure the handle is also zero
+ gSetupData[i].Handle = 0 ;
+ continue;
+ }
+ gSetupData[i].Handle = gSetupHandles[i];
+ formSet = HiiGetFormSet( i );
+ gSetupData[i].ClassID = formSet->Class;
+ gSetupData[i].SubClassID = formSet->SubClass;
+
+ }
+
+ // need to allocate one more dynamic IFR for the root page, this is NOT a 100% valid
+ // formset as there is no form defined
+ gSetupData[i].FormSet = EfiLibAllocateZeroPool(
+ sizeof(EFI_HII_PACK_HEADER) +
+ sizeof(EFI_IFR_FORM_SET) +
+ i * sizeof(EFI_IFR_REF)
+ );
+
+ formSet = HiiGetFormSet(i);
+ MemCopy(&(formSet->Guid),&(gSetupPkg->PackageGuid),sizeof(EFI_GUID));
+
+ TotalRootPages = 0;
+
+ if ( gSetupData[i].FormSet != NULL )
+ {
+ ref = (EFI_IFR_REF *)(gSetupData[i].FormSet + sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET));
+ for ( j = 1; j <= gToolPages->PageCount; j++ )
+ {
+ pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[j]);
+ if ( pageInfo->PageParentID != 0 ) //if ( pageInfo->PageFormID != 1 )
+ continue;
+
+ TotalRootPages++;
+
+ link = _HiiGetLinkIndex( &(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid),
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageClass,
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass,
+ pageInfo->PageFormID);
+
+ if ( link == (gSetupCount - 1) )
+ continue;
+
+ formSet = HiiGetFormSet( link );
+ ref->Header.OpCode = EFI_IFR_REF_OP;
+ ref->Header.Length = sizeof(EFI_IFR_REF);
+ ref->Prompt = formSet->FormSetTitle;
+ ref->Help = formSet->Help;
+ FixupPage0ControlInfo( (UINTN)gSetupData[i].FormSet, (UINTN)ref, (VOID*)gSetupData[link].Handle);
+ ref++;
+ }
+
+ gSetupData[i].Handle = gSetupData[0].Handle;
+
+ }
+
+ RTIfrProcessAddVarListAndPageIDListWrapper();
+
+ // update the control (IFR) pointers and HII handles
+ for ( i = 0; i< gToolPages->PageCount; i++ )
+ {
+ PAGE_INFO *NewPageInfo;
+ UINT32 PageSize;
+ UINT32 ControlSize;
+ CONTROL_INFO *NewControlInfo;
+ UINTN NoOfControlSpace;
+
+ pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[i]);
+
+ if(i == 0)
+ {
+ link = (UINT16)(gSetupCount - 1);
+ }
+ else
+ {
+
+ link = _HiiGetLinkIndex( &(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid),
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageClass,
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass,
+ pageInfo->PageFormID);
+ }
+
+ NoOfControlSpace = pageInfo->PageControls.ControlCount ? pageInfo->PageControls.ControlCount - 1 : pageInfo->PageControls.ControlCount;
+ PageSize = (UINT32)(sizeof(PAGE_INFO) + sizeof(pageInfo->PageControls.ControlList) * NoOfControlSpace);
+ NewPageInfo = EfiLibAllocateZeroPool(PageSize);
+
+ MemCopy(NewPageInfo,pageInfo,PageSize);
+
+ if ( link == (gSetupCount - 1) )
+ {
+ NewPageInfo->PageHandle = 0;// This page has been removed in runtime!!!
+ }
+ else
+ {
+ if(RTIfrProcessFormIfUpdatedWrapper(link) == TRUE)
+ continue;
+ NewPageInfo->PageHandle = gSetupData[link].Handle;
+ }
+
+ //Fixup and add the controls in this page to gContolInfo and update offsets in page info
+ if(NewPageInfo->PageControls.ControlCount)
+ {
+ for ( j = 0; j < NewPageInfo->PageControls.ControlCount; j++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gToolControlInfo + NewPageInfo->PageControls.ControlList[j]);
+
+ ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2;
+
+ NewControlInfo = EfiLibAllocateZeroPool(ControlSize);
+ MemCopy(NewControlInfo, controlInfo, ControlSize);
+
+ if(NewPageInfo->PageHandle != 0)
+ {
+
+ NewControlInfo->ControlHandle = gSetupData[link].Handle;
+
+ if ( NewControlInfo->ControlPtr != 0 )
+ {
+ NewControlInfo->ControlPtr = (VOID*)((UINTN)NewControlInfo->ControlPtr + (UINTN)gSetupData[link].FormSet);
+ if ( NewControlInfo->ControlConditionalPtr != 0 )
+ {
+ NewControlInfo->ControlConditionalPtr = (VOID*)((UINTN)NewControlInfo->ControlConditionalPtr + (UINTN)NewControlInfo->ControlPtr);
+ }
+ }
+ else if ( NewControlInfo ->ControlConditionalPtr != 0 )
+ {
+ NewControlInfo ->ControlConditionalPtr = (VOID*)((UINTN)NewControlInfo ->ControlConditionalPtr+(UINTN)gSetupData[link].FormSet);
+ }
+ }
+
+ NewPageInfo->PageControls.ControlList[j] = AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo
+
+ MemFreePointer(&NewControlInfo);
+ }
+ }
+ else
+ {
+ // Add the Empty Control to control List even if NewPageInfo->PageControls.ControlCount = 0
+ CONTROL_INFO *controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + 0);
+ ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2;
+ NewControlInfo = EfiLibAllocateZeroPool(ControlSize);
+ MemCopy(NewControlInfo, controlInfo, ControlSize);
+ AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo
+ MemFreePointer(&NewControlInfo);
+ }
+
+ if(i==0)
+ {
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, NewPageInfo, PageSize);
+ }
+ else
+ {
+ AddPageToList(NewPageInfo,PageSize);
+ }
+ MemFreePointer(&NewPageInfo);
+ }
+
+ RTIfrProcessRunTimeFormsWrapper(&ref);
+
+ MergePageListAndInfo();
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetStringLength
+//
+// Description: Function to get the string length
+//
+// Input: VOID* handle,
+// UINT16 token
+//
+// Output: Length
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+{
+ CHAR16 *string;
+ UINTN length = 0;
+
+ string = HiiGetString( handle, token );
+ if ( string == NULL )
+ return length;
+
+ length = EfiStrLen( string );
+ MemFreePointer( (VOID **)&string );
+
+ return length;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiFindHandle
+//
+// Description: Function to find the perticular HII handle
+//
+// Input: EFI_GUID *guid, UINT16 *index
+//
+// Output: Handle
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+/*EFI_HII_HANDLE*/VOID* HiiFindHandle( EFI_GUID *guid, UINT16 *index )
+{
+ VOID* *handleBuffer = NULL;
+ VOID* handle = (VOID*)(UINTN)INVALID_HANDLE;
+
+ EFI_IFR_FORM_SET *formSet;
+ UINT8 *buffer;
+
+ UINT16 found = 0;
+ UINT16 i, count;
+
+ handleBuffer = _HiiGetHandles( &count );
+ if ( handleBuffer == NULL )
+ return handle;
+
+ for ( i = found = 0; i < count; i++ )
+ {
+ buffer = _HiiGetForm( handleBuffer[i], 0, NULL );
+ if ( buffer == NULL )
+ continue;
+ formSet = (EFI_IFR_FORM_SET *)(buffer + sizeof(EFI_HII_PACK_HEADER));
+ if ( EfiCompareGuid( guid, &formSet->Guid ) )
+ {
+ if ( *index == found )
+ {
+ handle = handleBuffer[i];
+ (*index)++;
+ break;
+ }
+ found++;
+ }
+
+ MemFreePointer( &buffer );
+ }
+
+ MemFreePointer( (VOID **)&handleBuffer );
+ return handle;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HiiGetHandles
+//
+// Description: Function to get HII handles
+//
+// Input: UINT16 *bufferSize
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* * _HiiGetHandles( UINT16 *bufferSize )
+{
+ EFI_STATUS Status;
+ EFI_HII_HANDLE *buffer = NULL;
+ UINTN *OutBuf=NULL;
+ UINT16 i;
+
+ *bufferSize = 0;
+ Status = _HiiWrapperFindHandles( bufferSize, NULL );
+ if ( Status != EFI_BUFFER_TOO_SMALL )
+ return (VOID*)OutBuf;
+
+ buffer = EfiLibAllocatePool( *bufferSize );
+ if ( buffer != NULL )
+ {
+ Status = _HiiWrapperFindHandles( bufferSize, (VOID**)buffer );
+ if ( EFI_ERROR( Status ) )
+ MemFreePointer( (VOID **)&buffer );
+ }
+
+ *bufferSize /= sizeof(EFI_HII_HANDLE);
+ OutBuf = EfiLibAllocatePool( *bufferSize * sizeof(VOID*));
+
+ for(i=0;i<*bufferSize;i++)
+ OutBuf[i] = (UINTN)buffer[i];
+
+ MemFreePointer( (VOID **)&buffer );
+
+ //return buffer;
+ return (VOID*)OutBuf;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HiiLocateSetupHandles
+//
+// Description: Function to find the Setup Handles
+//
+// Input: void
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _HiiLocateSetupHandles( VOID )
+{
+ EFI_STATUS Status;
+ UINT16 i = 0;
+ UINT16 count;
+ /*EFI_HII_HANDLE*/VOID* *handleBuffer;
+ UINT8 *buffer;
+ UINT16 found = 0;
+
+ Status = HiiInitializeProtocol();
+ if ( EFI_ERROR( Status ) )
+ return Status;
+
+ if(FormBrowserLocateSetupHandles(&handleBuffer,&count)!= EFI_SUCCESS)
+ {
+ handleBuffer = _HiiGetHandles( &count );
+ }
+
+ if ( handleBuffer == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto _Done;
+ }
+
+ gSetupHandles = EfiLibAllocatePool( (count + 1) * sizeof(/*EFI_HII_HANDLE*/VOID*) );
+ if ( gSetupHandles == NULL )
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto _Done;
+ }
+
+ for ( i = found = 0; i < count; i++ )
+ {
+ buffer = _HiiGetForm( handleBuffer[i], 0, NULL );
+ if ( buffer == NULL )
+ continue;
+
+ gSetupHandles[found] = handleBuffer[i];
+ found++;
+ MemFreePointer( &buffer );
+ }
+
+ gSetupCount = found + 1;
+ // EIP : maximum VFRs supported in TSE
+ if(gSetupCount > MAX_PAGE)
+ {
+ CHAR16 *Temp = L"Reached TSE Maximum supported Page";
+ _DisplayErrorMessage(Temp);
+ ASSERT(0);
+ }
+
+ // at this point we have all the setup specific HII handles into our buffer
+_Done:
+ if(!FormBrowserHandleValid())
+ MemFreePointer( (VOID**)&handleBuffer );
+
+ return Status;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetFormSetFromHandle
+//
+// Description: Function to get formset handle
+//
+// Input: VOID* handle
+//
+// Output: Formset
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle )
+{
+ UINTN i;
+
+ for ( i = 0; i < gSetupCount; i++ )
+ {
+ if ( gSetupHandles[i] == handle )
+ return HiiGetFormSet( i );
+ }
+
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetFormSet
+//
+// Description: Function to get formset
+//
+// Input: UINTN index
+//
+// Output: formset
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index )
+{
+ EFI_IFR_FORM_SET *formSet = NULL;
+
+ if ( index >= gSetupCount )
+ return formSet;
+
+ if ( gSetupData == NULL )
+ return formSet;
+
+ formSet = (EFI_IFR_FORM_SET*)(gSetupData[index].FormSet + sizeof(EFI_HII_PACK_HEADER));
+
+ return formSet;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HiiGetForm
+//
+// Description: to get data using the input handle
+//
+// Input: VOID* handle, UINT16 form, UINTN *Length
+//
+// Output: info buffer
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *_HiiGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *Length )
+{
+ EFI_STATUS Status;
+ VOID *buffer = NULL;
+
+#if HII_VERSION <= 1
+ UINT16 bufferSize = 0;
+#else
+ UINTN bufferSize = 0;
+#endif
+
+ Status = HiiInitializeProtocol();
+
+ if ( EFI_ERROR(Status) )
+ return buffer;
+
+ Status = _HiiWrapperGetForm( handle, form, &bufferSize, buffer );
+ if ( Status != EFI_BUFFER_TOO_SMALL )
+ return buffer;
+
+ buffer = EfiLibAllocatePool( bufferSize );
+ if ( buffer == NULL )
+ return buffer;
+
+ Status = _HiiWrapperGetForm( handle, form, &bufferSize, buffer );
+ if ( EFI_ERROR(Status) )
+ MemFreePointer( (VOID **)&buffer );
+
+ if(Length!=NULL)
+ *Length = bufferSize;
+
+ return buffer;
+}
+
+
+UINT16 HiiAddStringLanguage( VOID* handle, CHAR16 *lang, CHAR16 *string )
+{
+ return HiiChangeStringLanguage( handle, 0, lang, string );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiChangeString
+//
+// Description: to change a existing string
+//
+// Input: VOID* handle, UINT16 token, CHAR16 *string
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 HiiChangeString( VOID* handle, UINT16 token, CHAR16 *string )
+{
+ UINTN i;
+ UINT16 returntoken;
+ UINT16 status = token;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ returntoken = HiiChangeStringLanguage( handle, token, gLanguages[i].Unicode, string );
+ if ( token != returntoken )
+ {
+ //EIP 25092 : Fix to Use the HiiChangeString() to Add the string for morethen one langs.
+ //with the same token.
+ token = status = returntoken;
+ }
+ }
+ return status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsFormFound
+//
+// Description: to check whether the perticular form found or not
+//
+// Input: EFI_IFR_FORM_SET *formSet,UINT16 formid
+//
+// Output: 0/1
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 IsFormFound(EFI_IFR_FORM_SET *formSet,UINT16 formid )
+{
+ UINT8 * RawData = (UINT8 *)formSet;
+ while( ((EFI_IFR_OP_HEADER*)RawData)->OpCode != EFI_IFR_END_FORM_SET_OP)
+ {
+ if(((EFI_IFR_OP_HEADER*)RawData)->OpCode == EFI_IFR_FORM_OP)
+ if(((EFI_IFR_FORM*)RawData)->FormId == formid)
+ return 1;
+
+ RawData += ((EFI_IFR_OP_HEADER*)RawData)->Length;
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HiiGetLinkIndex
+//
+// Description: to get the index of the link
+//
+// Input: EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid
+//
+// Output: Index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _HiiGetLinkIndex( EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid )
+{
+ UINT16 i;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_HII_PACK_HEADER *pack;
+
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ pack = (EFI_HII_PACK_HEADER *)gSetupData[i].FormSet;
+
+ if ( sizeof(EFI_HII_PACK_HEADER) == pack->Length )
+ continue;
+
+ formSet = (EFI_IFR_FORM_SET *)((UINT8 *)pack + sizeof(EFI_HII_PACK_HEADER));
+
+ if(EfiCompareGuid( guid , &(formSet->Guid) ))
+ {
+ if( gSetupData[i].ClassID == class )
+ {
+ if( gSetupData[i].SubClassID == subclass )
+ {
+ if(IsFormFound(formSet, formid))
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ return i;
+}
+
+EFI_STATUS _HiiWrapperFindHandles( UINT16 *bufferSize, /*EFI_HII_HANDLE*/VOID* *buffer )
+{
+ return gHiiProtocol->FindHandles( gHiiProtocol, bufferSize, (EFI_HII_HANDLE*)buffer );
+}
+
+#if HII_VERSION <= 1
+EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINT16 *bufferSize, VOID *buffer )
+#else
+EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *bufferSize, VOID *buffer )
+#endif
+{
+ return gHiiProtocol->GetForms( gHiiProtocol,(EFI_HII_HANDLE)(UINTN) handle, form, bufferSize, buffer );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _HiiParseVariablePack
+//
+// Description: To parse the variable pack and Update the Current Values with Default Values
+//
+// Input: EFI_HII_VARIABLE_PACK_LIST *packList, NVRAM_VARIABLE **pVarList
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _HiiParseVariablePack( EFI_HII_VARIABLE_PACK_LIST *packList, UINT32 offs, UINT32 variable, UINTN size, NVRAM_VARIABLE **pVarList )
+{
+ EFI_HII_VARIABLE_PACK *pack;
+ UINT32 index;
+ UINTN offset;
+ NVRAM_VARIABLE *varList = *pVarList;
+ NVRAM_VARIABLE *varPtr;
+ UINT8 *srcBuffer;
+
+ for ( ; packList != NULL; packList = packList->NextVariablePack )
+ {
+ pack = packList->VariablePack;
+ if ( pack == NULL )
+ continue;
+
+ if ( VarGetVariableInfoId( pack->VariableId, &index ) == NULL )
+ continue;
+
+ offset = sizeof(EFI_HII_VARIABLE_PACK) + pack->VariableNameLength;
+//--> EIP:48587
+ if( index == variable)
+ {
+ varPtr = &(varList[index]);
+ if ( offs + size > varPtr->Size )
+ {
+ UINT8 *pnewBuffer;
+ pnewBuffer = EfiLibAllocateZeroPool( offs + size );
+ MemCopy( pnewBuffer, varPtr->Buffer, varPtr->Size );
+ MemFreePointer( (VOID **)&varPtr->Buffer );
+ varPtr->Buffer = pnewBuffer;
+ varPtr->Size = offs + size;
+ }
+ srcBuffer = (UINT8 *)pack + offset;
+ if( variable == pack->VariableId )
+ {
+ // Update the Current Values with Defaults values
+ MemCopy( &varPtr->Buffer[offs], &srcBuffer[offs], size );
+ }
+ }// <-- EIP:48587
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiLoadDefaults
+//
+// Description: function to load the default values
+//
+// Input: NVRAM_VARIABLE **varList, UINTN Mask
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HiiLoadDefaults( NVRAM_VARIABLE **varList, UINTN Mask )
+{
+ EFI_STATUS ReturnStatus = EFI_OUT_OF_RESOURCES;
+ EFI_STATUS Status;
+ NVRAM_VARIABLE *defaultVar = NULL;
+ UINT32 i = 0, index = 0; // EIP:48587
+ UINT32 control; // EIP:48587
+
+ EFI_HII_VARIABLE_PACK_LIST *VariablePack = NULL;
+
+ if ( ( varList == NULL ) /*|| ( *varList == NULL )*/ )
+ return ReturnStatus;
+
+ if( ( ! gVariables ) || ( gVariables->VariableCount == 0 ) ) // fatal error
+ while(1);
+
+ *varList = EfiLibAllocateZeroPool( sizeof(NVRAM_VARIABLE) * gVariables->VariableCount );
+ if ( *varList == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ // Get the Current Values for defaults
+ defaultVar = ( NVRAM_VARIABLE * )*varList;
+ for ( i = 0; i < gVariables->VariableCount; i++, defaultVar++ )
+ {
+ defaultVar->Buffer = VarGetNvram( i, &defaultVar->Size );
+ }
+
+ ReturnStatus = HiiInitializeProtocol();
+ if ( EFI_ERROR( ReturnStatus ) )
+ return ReturnStatus;
+
+ ReturnStatus = EFI_SUCCESS;
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ Status = gHiiProtocol->GetDefaultImage(
+ gHiiProtocol,
+ (EFI_HII_HANDLE)(UINTN)gSetupHandles[i],
+ Mask,
+ &VariablePack
+ );
+
+ if ( EFI_ERROR( Status ) )
+ {
+ continue;
+ }
+// EIP:48587
+ for ( ; index < gPages->PageCount; index++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO*)((UINT8 *)gPages + gPages->PageList[index]);
+
+ if( pageInfo->PageHandle == NULL )
+ {
+ continue;
+ }
+
+ if( pageInfo->PageHandle != gSetupHandles[i] ) // EIP:48587 Find the end of current formset and go to next formset
+ break;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if ( ( controlInfo->ControlVariable == VARIABLE_ID_LANGUAGE ) || ( controlInfo->ControlVariable == VARIABLE_ID_BOOT_ORDER ) || (controlInfo->ControlVariable == VARIABLE_ID_BBS_ORDER) )
+ continue;
+
+ if ( controlInfo->ControlDataWidth > 0 )
+ {
+ VOID *ifrData = controlInfo->ControlPtr;
+ UINT32 ControlVarOffset;
+
+ if ( ifrData == NULL )
+ continue;
+
+ ControlVarOffset = UefiGetQuestionOffset(ifrData);
+
+ if ( VariablePack != NULL )
+ _HiiParseVariablePack( VariablePack, ControlVarOffset, controlInfo->ControlVariable, controlInfo->ControlDataWidth, varList );
+ }
+ }
+ }
+ MemFreePointer( (VOID **)&VariablePack );
+ }
+// EIP:48587
+
+ return ReturnStatus;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddControlToList
+//
+// Description: to add a control to list
+//
+// Input: CONTROL_INFO *NewControlInfo, UINT32 ControlSize
+//
+// Output: offset
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 AddControlToList(CONTROL_INFO *NewControlInfo, UINT32 ControlSize)
+{
+ UINT32 offset;
+ UINT32 u32Compensation;
+
+ u32Compensation = (sizeof(UINT64) - (ControlSize%sizeof(UINT64))) % sizeof(UINT64);
+
+ if((ControlListOffset + ControlSize + u32Compensation )> ControlListSize)
+ {
+ gControlInfo = MemReallocateZeroPool( gControlInfo, ControlListSize, ControlListSize + 4096 ); //Allocate 4k at a time
+ //Todo: introduce error case
+ ControlListSize+=4096;
+ }
+
+ MemCopy((UINT8 *)gControlInfo + ControlListOffset, NewControlInfo, ControlSize);
+
+ offset = ControlListOffset;
+
+ ControlListOffset += (ControlSize + u32Compensation);
+
+ return offset;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddPageToList
+//
+// Description: to add a page to list
+//
+// Input: PAGE_INFO *NewPageInfo, UINT32 PageSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize)
+{
+ UINT32 offset;
+ UINT32 ReallocSize=4096;
+
+ if( PageInfoPtr == NULL ) //EIP48930
+ PageInfoOffset = PageInfoSize = 0;
+
+ if(PageInfoOffset + PageSize >= PageInfoSize)
+ {
+ if(ReallocSize < PageSize)
+ ReallocSize = (PageSize&0xFFFFF000) + 4096;
+
+ PageInfoPtr = MemReallocateZeroPool( PageInfoPtr, PageInfoSize, PageInfoSize + ReallocSize ); //Allocate 4k at a time
+ //Todo: introduce error case
+ PageInfoSize+=ReallocSize;
+ }
+
+ MemCopy((UINT8 *)PageInfoPtr + PageInfoOffset, NewPageInfo, PageSize);
+
+ offset = PageInfoOffset;
+
+ PageInfoOffset += PageSize;
+
+ if(!PageListPtr)
+ {
+ PageListSize = 512;
+ PageListPtr = EfiLibAllocateZeroPool(PageListSize);
+ PageListPtr->PageCount = 1; //Leave space for offset of Page 0
+ PageListPtr->PageList[PageListPtr->PageCount] = offset;
+ PageListPtr->PageCount++;
+ PageListOffset = sizeof(PAGE_LIST)+sizeof(UINT32);
+ }
+ else
+ {
+ if(PageListOffset + sizeof(UINT32) >= PageListSize)
+ {
+ PageListPtr = MemReallocateZeroPool(PageListPtr, PageListSize, PageListSize + 128);
+ PageListSize += 128;
+ }
+ PageListPtr->PageList[PageListPtr->PageCount] = offset;
+ PageListPtr->PageCount++;
+ PageListOffset += sizeof(UINT32);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CreatePage
+//
+// Description: function used to create a page
+//
+// Input: PAGE_INFO **PageInfo, UINT32 *AllocatedSize,
+// UINT32 *Offset, VOID *Buff, UINT32 BuffSize
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize, UINT32 *Offset, VOID *Buff, UINT32 BuffSize)
+{
+
+ if(!(*AllocatedSize))
+ {
+ //creating a new page
+ *PageInfo = EfiLibAllocateZeroPool(BuffSize);
+ *AllocatedSize = BuffSize;
+ MemCopy(*PageInfo, Buff, BuffSize);
+
+ if((*PageInfo)->PageControls.ControlCount)
+ *Offset = BuffSize;
+ else //We have space to store one more offset
+ //*Offset = BuffSize - sizeof((*PageInfo)->PageControls.ControlList[0]);
+// Fix the Issue with the Packing, Original code was not finding the correct Offset
+ *Offset = (UINT32)((UINTN)(&(*PageInfo)->PageControls.ControlList[0]) - (UINTN)(*PageInfo));
+
+ }
+ else
+ {
+ //adding offsets
+ if(*Offset + BuffSize >= *AllocatedSize)
+ {
+ *PageInfo = MemReallocateZeroPool( *PageInfo, *AllocatedSize, *AllocatedSize + 128 ); //Allocate 128 bytes at a time
+ //Todo: introduce error case
+ *AllocatedSize+=128;
+ }
+ MemCopy((UINT8 *)(*PageInfo) + *Offset, Buff, BuffSize);
+
+ *Offset += BuffSize;
+
+ (*PageInfo)->PageControls.ControlCount++;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MergePageListAndInfo
+//
+// Description: To merge the information
+//
+// Input: NIL
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MergePageListAndInfo()
+{
+ UINTN i;
+
+ gApplicationData = EfiLibAllocateZeroPool(PageListOffset + FirstPageOffset + PageInfoOffset);
+ gPages = (PAGE_LIST *) gApplicationData;
+
+ MemCopy(gApplicationData, PageListPtr, PageListOffset);
+ MemCopy(gApplicationData + PageListOffset, FirstPage, FirstPageOffset);
+ MemCopy(gApplicationData + PageListOffset + FirstPageOffset, PageInfoPtr, PageInfoOffset);
+
+ //Fix Offsets
+ i=0;
+ gPages->PageList[i] = PageListOffset;
+ i++;
+
+ for(; i<gPages->PageCount; i++)
+ {
+ gPages->PageList[i] += (FirstPageOffset + PageListOffset);
+ }
+
+ //Free Temp Memory
+ MemFreePointer(&FirstPage);
+ MemFreePointer(&PageInfoPtr);
+ MemFreePointer(&PageListPtr);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiMyGetStringLength
+//
+// Description: user function to get the string length
+//
+// Input: VOID* handle, UINT16 token
+//
+// Output: Length
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+{
+ CHAR16 *string;
+ UINTN length = 0;
+
+ string = HiiGetString( handle, token );
+ if ( string == NULL )
+ return length;
+
+ length = TestPrintLength( string ) / (NG_SIZE);
+ MemFreePointer( (VOID **)&string );
+
+ return length;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiMyGetMultiLineStringLength
+//
+// Description: returns Max length of the in the paragraph
+//
+// Input: Handle and token
+//
+// Output: Length
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+{
+ CHAR16 *string;
+ UINTN length = 0,MaxLength=0;
+ UINTN i,j;
+
+ string = HiiGetString( handle, token );
+ if ( string == NULL )
+ return length;
+
+ i=j=0;
+ while(string[i])
+ {
+ // is Newline
+ if((string[i]==0x0d)&& (string[i+1]==0x0a))
+ {
+ string[i]=0x0;
+ length = TestPrintLength( &string[j] ) / (NG_SIZE);
+ if(length>MaxLength)
+ MaxLength = length;
+ i+=2;
+ j=i;
+ }
+ else
+ i++;
+ }
+ length = TestPrintLength( &string[j] ) / (NG_SIZE);
+ MemFreePointer( (VOID **)&string );
+
+ if(length>MaxLength)
+ MaxLength = length;
+
+ return MaxLength;
+}
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RTIfrProcessExit
+//
+// Description: Function to process ifr exit
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessExit(VOID)
+{
+ MemFreePointer(&gVariables);
+ VariableListPtr = NULL;
+ VariableInfoPtr = NULL;
+ VariableListOffset = VariableListSize = VariableInfoOffset = VariableInfoSize = 0;
+
+ MemFreePointer(&gPageIdList);
+ PageIdListPtr = NULL;
+ PageIdInfoPtr = NULL;
+ PageIdListOffset = PageIdListSize = PageIdInfoOffset = PageIdInfoSize = 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RTIfrProcessAddVarListAndPageIDList
+//
+// Description: Function to add var list page ID list
+//
+// Input: void
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessAddVarListAndPageIDList(VOID)
+{
+ UINT32 i;
+
+ //Create Variable List
+ for(i=0; i < gToolVariables->VariableCount ; i++)
+ {
+ VARIABLE_INFO *VariableInfo;
+
+ VariableInfo = (VARIABLE_INFO *)((UINT8 *)gToolVariables + gToolVariables->VariableList[i]);
+
+ AddVariableToList(VariableInfo, sizeof(VARIABLE_INFO));
+ }
+
+ //Create Page ID list
+ for(i=0; i < gToolPageIdList->PageIdCount ; i++)
+ {
+ PAGE_ID_INFO *PageIdInfo;
+
+ PageIdInfo = (PAGE_ID_INFO *)((UINT8 *)gToolPageIdList + gToolPageIdList->PageIdList[i]);
+
+ AddPageIdToList(PageIdInfo, sizeof(PAGE_ID_INFO));
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RTIfrProcessFormIfUpdated
+//
+// Description: Fuction to process form if updated
+//
+// Input: UINT16 link
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN RTIfrProcessFormIfUpdated(UINT16 link)
+{
+ UINT32 j;
+ //Check if the page has changed during run time
+ for(j=0; j < gHpkInfoLength / sizeof(HPK_INFO); j++)
+ {
+ EFI_HII_PACK_HEADER *pack;
+
+ if(
+ (gHpkInfo[j].Class == gSetupData[link].ClassID) &&
+ (gHpkInfo[j].SubClass == gSetupData[link].SubClassID)
+ )
+ {
+ pack = (EFI_HII_PACK_HEADER *)gSetupData[link].FormSet;
+
+ if ( gHpkInfo[j].Length != pack->Length )
+ break;
+ }
+ }
+
+ if(j < gHpkInfoLength / sizeof(HPK_INFO))
+ {
+ //This page changed during run time parse again
+ if(!gSetupData[link].Added)
+ AddDynamicForm(link);
+ return TRUE;
+ }
+ gSetupData[link].Added = 1;
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RTIfrProcessRunTimeForms
+//
+// Description: Function to process runtime forms
+//
+// Input: EFI_IFR_REF **ref
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessRunTimeForms(EFI_IFR_REF **ref)
+{
+ UINT32 i;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID;
+ UINT16 count = 0;
+
+ for(i = 0; i < gSetupCount - 1; i++)
+ {
+ if(!(gSetupData[i].Added))
+ {
+ AddDynamicForm(i);
+ if((gSetupData[i].Added))
+ {
+ formSet = HiiGetFormSet( i );
+ (*ref)->Header.OpCode = EFI_IFR_REF_OP;
+ (*ref)->Header.Length = sizeof(EFI_IFR_REF);
+ (*ref)->Prompt = formSet->FormSetTitle;
+ (*ref)->Help = formSet->Help;
+ (*ref)++;
+ count++ ;
+ }
+ }
+ }
+
+ gDynamicPageCount = count ;
+
+ //Set Dynamic page count variable
+ VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ MergePageIdListAndInfo();
+ MergeVariableListAndInfo();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddPageIdToList
+//
+// Description: Function to add page id to list
+//
+// Input: PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo, UINT32 PageIdSize)
+{
+ UINT32 offset;
+
+ if( PageIdInfoPtr == NULL ) //EIP48930
+ PageIdInfoOffset = PageIdInfoSize = 0;
+
+ if(PageIdInfoOffset + PageIdSize >= PageIdInfoSize)
+ {
+ PageIdInfoPtr = MemReallocateZeroPool( PageIdInfoPtr, PageIdInfoSize, PageIdInfoSize + 256 ); //Allocate 4k at a time
+ //Todo: introduce error case
+ PageIdInfoSize+=256;
+ }
+
+ MemCopy((UINT8 *)PageIdInfoPtr + PageIdInfoOffset, NewPageIdInfo, PageIdSize);
+
+ offset = PageIdInfoOffset;
+
+ PageIdInfoOffset += PageIdSize;
+
+ if(!PageIdListPtr)
+ {
+ PageIdListSize = 128;
+ PageIdListPtr = EfiLibAllocateZeroPool(PageIdListSize);
+ PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset;
+ PageIdListPtr->PageIdCount = 1;
+ PageIdListOffset = sizeof(PAGE_ID_LIST);
+ }
+ else
+ {
+ if(PageIdListOffset + sizeof(UINT32) >= PageIdListSize)
+ {
+ PageIdListPtr = MemReallocateZeroPool(PageIdListPtr, PageIdListSize, PageIdListSize + 128);
+ PageIdListSize += 128;
+ }
+ PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset;
+ PageIdListPtr->PageIdCount++;
+ PageIdListOffset += sizeof(UINT32);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MergePageIdListAndInfo
+//
+// Description: Function to merge page id list and info
+//
+// Input: NIL
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MergePageIdListAndInfo()
+{
+ UINTN i;
+
+ gPageIdList = EfiLibAllocateZeroPool(PageIdListOffset + PageIdInfoOffset);
+
+ MemCopy(gPageIdList,PageIdListPtr,PageIdListOffset);
+ MemCopy(((UINT8 *)gPageIdList)+ PageIdListOffset,PageIdInfoPtr,PageIdInfoOffset);
+
+ for(i=0; i<gPageIdList->PageIdCount; i++)
+ {
+ gPageIdList->PageIdList[i] += PageIdListOffset;
+ }
+
+ gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]);
+
+ //Free Temp Memory
+ MemFreePointer(&PageIdInfoPtr);
+ MemFreePointer(&PageIdListPtr);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddVariableToList
+//
+// Description: Function to add variable to list
+//
+// Input: VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddVariableToList(VARIABLE_INFO *NewVariableInfo, UINT32 VariableSize)
+{
+ UINT32 offset;
+
+ if(VariableInfoOffset + VariableSize >= VariableInfoSize)
+ {
+ VariableInfoPtr = MemReallocateZeroPool( VariableInfoPtr, VariableInfoSize, VariableInfoSize + 256 ); //Allocate 4k at a time
+ //Todo: introduce error case
+ VariableInfoSize+=256;
+ }
+
+ MemCopy((UINT8 *)VariableInfoPtr + VariableInfoOffset, NewVariableInfo, VariableSize);
+
+ offset = VariableInfoOffset;
+
+ VariableInfoOffset += VariableSize;
+
+ if(!VariableListPtr)
+ {
+ VariableListSize = 128;
+ VariableListPtr = EfiLibAllocateZeroPool(VariableListSize);
+ VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset;
+ VariableListPtr->VariableCount = 1;
+ VariableListOffset = sizeof(VARIABLE_LIST);
+ }
+ else
+ {
+ if(VariableListOffset + sizeof(UINT32) >= VariableListSize)
+ {
+ VariableListPtr = MemReallocateZeroPool(VariableListPtr, VariableListSize, VariableListSize + 128);
+ VariableListSize += 128;
+ }
+ VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset;
+ VariableListPtr->VariableCount++;
+ if(VariableListPtr->VariableCount >= MAX_VARIABLE)
+ {
+ CHAR16 *Temp = L"Reached TSE Maximum supported variables";
+ _DisplayErrorMessage(Temp);
+ ASSERT(0);
+ }
+ VariableListOffset += sizeof(UINT32);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MergeVariableListAndInfo
+//
+// Description: Function to merge variable list and info
+//
+// Input: NIL
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MergeVariableListAndInfo()
+{
+ UINTN i;
+
+ gVariables = EfiLibAllocateZeroPool(VariableListOffset + VariableInfoOffset);
+
+ MemCopy(gVariables,VariableListPtr,VariableListOffset);
+ MemCopy(((UINT8 *)gVariables)+ VariableListOffset,VariableInfoPtr,VariableInfoOffset);
+
+ for(i=0; i<gVariables->VariableCount; i++)
+ {
+ gVariables->VariableList[i] += VariableListOffset;
+ }
+
+ //Free Temp Memory
+ MemFreePointer(&VariableInfoPtr);
+ MemFreePointer(&VariableListPtr);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetSubFormCount
+//
+// Description: function to count the subform and Ref inside the formset.
+//
+// Input: UINT8 *buff - Pointer to form to search for links to other forms
+//
+// Output: count - no of subforms
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINTN GetSubFormCount(UINT8 *buff)
+{
+ UINTN *tmpFormIDBuf;
+ UINTN MaxPagecount=100;
+ UINTN PageCount= 0;
+ UINTN i=0, j=0, found =0;
+ EFI_IFR_OP_HEADER *Header;
+
+ tmpFormIDBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN));
+ //go thru the forms and get the links, creating the lookup table also
+ do
+ {
+ Header = (EFI_IFR_OP_HEADER*)(buff+i);
+ switch(Header->OpCode )
+ {
+ case EFI_IFR_FORM_OP: // find parent in lookup table and then the parent pageNum to link
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while( (found==0) && ( j < PageCount ) ){
+ if(tmpFormIDBuf[j] == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+ found =1;
+ break;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // pages in the root(no parent)
+ tmpFormIDBuf[PageCount] = ((EFI_IFR_FORM*)Header)->FormId ;
+ PageCount++;
+ }
+
+ break;
+
+ case EFI_IFR_REF_OP: // add to lookup table adding the PageID and ParentPageID
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while( (found==0) && ( j < PageCount ) ){
+ if(tmpFormIDBuf[j] == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+ found =1;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // pages in the root(no parent)
+ tmpFormIDBuf[PageCount] = ((EFI_IFR_FORM*)Header)->FormId ;
+ PageCount++;
+ }
+ break;
+
+ default:
+ break;
+ }
+ // If the Buffer is not enough the reallocate more
+ if(PageCount >= MaxPagecount)
+ {
+ UINTN *tmpBuf;
+ MaxPagecount +=50;
+ tmpBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN));
+ MemCopy(tmpBuf,tmpFormIDBuf,sizeof(UINTN)*PageCount);
+ MemFreePointer(&tmpFormIDBuf);
+ tmpFormIDBuf = tmpBuf;
+ }
+
+ i+=Header->Length;
+ }while(Header->OpCode != EFI_IFR_END_FORM_SET_OP);
+
+ MemFreePointer(&tmpFormIDBuf);
+ return PageCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitFormsetLinks
+//
+// Description: Function to init formset links
+//
+// Input: char *buff, UINTN InitFormNum
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID InitFormsetLinks(char *buff,UINTN InitFormNum)
+{
+ UINTN i=0, j=0, found =0,InitForm=InitFormNum;
+ EFI_IFR_OP_HEADER *Header;
+ UINTN count = 0;
+///EIP:24060 - Start
+ UINT16 RootPageinFormSet=0;
+///EIP:24060 - End
+
+ // allocate memory for data
+ if(FSetLinks != NULL)
+ MemFreePointer(&FSetLinks);
+
+ count = GetSubFormCount(buff);
+ FSetLinks = (FormSetLinks*)EfiLibAllocateZeroPool(sizeof(FormSetLinks) + count * sizeof(PageLink));
+
+ //go thru the forms and get the links, creating the lookup table also
+ do
+ {
+ Header = (EFI_IFR_OP_HEADER*)(buff+i);
+ switch(Header->OpCode )
+ {
+ case EFI_IFR_FORM_OP: // find parent in lookup table and then the parent pageNum to link
+
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while( (found==0) && ( j < FSetLinks->PageCount ) ){
+ if(FSetLinks->PageLink[j].FormID == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+ FSetLinks->PageLink[j].PageNum = (UINT16)InitForm++;
+ found =1;
+ break;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+///EIP:24060 - Start
+ if(!RootPageinFormSet)
+ RootPageinFormSet = ((EFI_IFR_FORM*)Header)->FormId;
+///EIP:24060 - End
+ // pages in the root(no parent)
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_FORM*)Header)->FormId ;
+
+ if(IsOrphanPagesAsRootPage())
+ {
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ }
+ else
+ {
+ if(RootPageinFormSet == ((EFI_IFR_FORM*)Header)->FormId)
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ else
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = FSetLinks->PageLink[0].PageNum;
+ }
+
+ FSetLinks->PageLink[FSetLinks->PageCount].PageNum = (UINT16)InitForm++;
+ FSetLinks->PageCount++;
+ }
+
+ break;
+
+ case EFI_IFR_REF_OP: // add to lookup table adding the PageID and ParentPageID
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while( (found==0) && ( j < FSetLinks->PageCount ) ){
+ if(FSetLinks->PageLink[j].FormID == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+///EIP:24060 - Start
+ if(RootPageinFormSet != FSetLinks->PageLink[j].FormID)
+ if(FSetLinks->PageLink[j].PageNum != (UINT16)InitForm-1) // Parent of the Page can't be same page id.
+ FSetLinks->PageLink[j].ParentPageID = (UINT16)InitForm-1;
+
+
+///EIP:24060 - End
+ found =1;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // sub pages
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_FORM*)Header)->FormId ;
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = (UINT16)InitForm-1;
+ FSetLinks->PageLink[FSetLinks->PageCount].PageNum = 0;
+ FSetLinks->PageCount++;
+ }
+ break;
+
+ default:
+
+ break;
+
+ }
+ i+=Header->Length;
+ }while(Header->OpCode != EFI_IFR_END_FORM_SET_OP);
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetPageParent
+//
+// Description: Function to get parent page
+//
+// Input: int PageNum
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetPageParent(int PageNum)
+{
+ UINT16 i=0;
+
+ do{
+ if(FSetLinks->PageLink[i].PageNum == PageNum )
+ {
+ return (FSetLinks->PageLink[i].ParentPageID );
+ break;
+ }
+ }while( i++ < FSetLinks->PageCount );
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetPageIdIndex
+//
+// Description: To get the index of a perticular page
+//
+// Input: EFI_GUID * FormGuid, UINT16 FormClass, UINT16 FormSubClass
+//
+// Output: PageIndex
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetPageIdIndex(EFI_GUID * FormGuid, UINT16 FormClass, UINT16 FormSubClass)
+{
+ UINT16 i;
+ PAGE_ID_INFO *PageId;
+
+ if(PageIdListPtr == NULL)
+ PageIdListPtr = EfiLibAllocateZeroPool(128);
+
+ //search if this combination exists
+ for(i = 0; i < PageIdListPtr->PageIdCount ; i++)
+ {
+ PageId = (PAGE_ID_INFO *) ((UINT8 *)PageIdInfoPtr + PageIdListPtr->PageIdList[i]);
+ if( EfiCompareGuid(FormGuid,&(PageId->PageGuid)) )//Compare Guid
+ {
+ if(FormClass == PageId->PageClass)//Compare class
+ {
+ if(FormSubClass == PageId->PageSubClass)//Compare SubClass
+ {
+ break; //found entry
+ }
+ }
+ }
+ }
+
+ if(i >= PageIdListPtr->PageIdCount)
+ {
+ PAGE_ID_INFO NewPageId;
+
+ MemCopy(&(NewPageId.PageGuid),FormGuid,sizeof(EFI_GUID));
+ NewPageId.PageClass = FormClass;
+ NewPageId.PageSubClass = FormSubClass;
+
+ i = (UINT16)PageIdListPtr->PageIdCount;
+ AddPageIdToList(&NewPageId, sizeof(PAGE_ID_INFO));
+ }
+
+ return i;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddVariable
+//
+// Description: Function to add variable
+//
+// Input: EFI_IFR_VARSTORE *Varstore
+//
+// Output: success
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+int AddVariable(EFI_IFR_VARSTORE *Varstore)
+{
+ UINT16 i=0;
+ UINTN varfound=0;
+ char *str2;
+ EFI_GUID *GUID = &(Varstore->Guid);
+ VARIABLE_INFO *Variable;
+ UINT16 VarName[40];
+ PVAR_KEY_TABLE pVarTable;
+
+
+ str2= (char*)((UINT8*)Varstore +sizeof(EFI_IFR_VARSTORE)); //name
+
+ //Convert to unicode string
+ MemSet(VarName, sizeof(VarName), 0);
+
+ i = 0;
+ while(*str2)
+ {
+ VarName[i] = *str2;
+ i++;
+ str2++;
+ }
+
+
+ // check that the variable is not already in the list
+
+
+ for(i=0; i < VariableListPtr->VariableCount; i++)
+ {
+ Variable = (VARIABLE_INFO *) ((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]);
+ if( EfiCompareGuid(GUID,&(Variable->VariableGuid)) )//Compare Guid
+ if(EfiStrCmp(VarName,Variable->VariableName) ==0)
+ {
+ varfound=1;
+ Variable->VariableID = Varstore->VarId;
+ break;
+ }
+ }
+
+ if(!varfound)
+ {
+ VARIABLE_INFO NewVariable;
+
+ MemSet(&NewVariable,sizeof(VARIABLE_INFO),0);
+ NewVariable.VariableID = Varstore->VarId;
+ MemCopy((&NewVariable.VariableGuid),&(Varstore->Guid),sizeof(EFI_GUID));
+ NewVariable.VariableAttributes = 7;
+ EfiStrCpy(NewVariable.VariableName,VarName);
+
+ AddVariableToList(&NewVariable, sizeof(VARIABLE_INFO));
+ }
+
+ pVarTable = &VarKeyTable;
+
+ while(pVarTable->Next)
+ pVarTable = pVarTable->Next;
+
+ pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE));
+ pVarTable = pVarTable->Next;
+
+ pVarTable->VarId = Varstore->VarId;
+ pVarTable->Index = i;
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetVarNumFromVarID
+//
+// Description: Function to get variable number from var ID
+//
+// Input: UINT32 ID
+//
+// Output: Variable Index
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 GetVarNumFromVarID(UINT32 ID)
+{
+ PVAR_KEY_TABLE pVarTable;
+
+ pVarTable = VarKeyTable.Next;
+
+ while(pVarTable)
+ {
+ if(pVarTable->VarId == ID)
+ return(pVarTable->Index);
+ pVarTable = pVarTable->Next;
+ }
+
+ return 0;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleanVarKeyTable
+//
+// Description: To clear the key table specific buffers
+//
+// Input: NIL
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanVarKeyTable()
+{
+ PVAR_KEY_TABLE pVarTable;
+
+ pVarTable = VarKeyTable.Next;
+
+ while(pVarTable)
+ {
+ VarKeyTable.Next = pVarTable->Next;
+ MemFreePointer(&pVarTable);
+ pVarTable = VarKeyTable.Next;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddFormSetVariable
+//
+// Description:
+//
+// Input: EFI_GUID * VarGuid
+//
+// Output: VarCount
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 AddFormSetVariable(EFI_GUID * VarGuid)
+{
+ VARIABLE_INFO Variable;
+ UINT32 i;
+
+ Variable.VariableID = 0;
+ MemCopy((&Variable.VariableGuid),VarGuid,sizeof(EFI_GUID));
+ Variable.VariableAttributes = 0x7; // BT+RT+NV
+ EfiStrCpy(Variable.VariableName,L"Setup");
+
+ i = VariableListPtr->VariableCount;
+ AddVariableToList(&Variable, sizeof(VARIABLE_INFO));
+
+ return i;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsVarGuidPresent
+//
+// Description:
+//
+// Input: EFI_GUID * VarGuid, int * Index
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+int IsVarGuidPresent(EFI_GUID * VarGuid, int * Index)
+{
+ UINT32 i=0;
+ VARIABLE_INFO *Variable;
+
+ for(i=0; i < VariableListPtr->VariableCount; i++)
+ {
+ Variable = (VARIABLE_INFO *) ((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]);
+ if( EfiCompareGuid(VarGuid,&(Variable->VariableGuid)) )//Compare Guid
+ if( (EfiStrCmp(L"Setup",Variable->VariableName) ==0) ||
+ (EfiStrCmp(L"setup",Variable->VariableName) ==0 ))
+ {
+ *Index = i;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddDynamicForm
+//
+// Description:
+//
+// Input: UINT32 HiiIndex
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddDynamicForm(UINT32 HiiIndex)
+{
+ EFI_HII_PACK_HEADER *fset;
+ EFI_IFR_FORM_SET *Formset;
+ EFI_IFR_FORM *form;
+
+ UINTN x, i=0;
+ UINT8 *buff = NULL;
+
+ CONTROL_INFO controlInfo;
+ UINT32 ControlOffset;
+ UINT32 VarIndex;
+
+ PVAR_KEY_TABLE pVarTable;
+
+ UINT32 AllocatedPageSize , PageOffset;
+ PAGE_INFO *NewPageInfo;
+
+ PAGE_INFO TempPage;
+
+ x = gSetupData[HiiIndex].FormSetLength;
+ buff = (UINT8 *) gSetupData[HiiIndex].FormSet;
+ fset = (EFI_HII_PACK_HEADER *)buff;
+
+
+ while(i<x) // Look for formsets
+ {
+ Formset = (EFI_IFR_FORM_SET *) ((UINTN)fset + sizeof(EFI_HII_PACK_HEADER));
+
+ if((fset->Type == FORM_SUBCLASS) && (Formset->Header.OpCode == EFI_IFR_FORM_SET_OP ))
+ {
+ if(EFI_IFR_END_FORM_SET_OP == *(buff + sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET)))
+ {
+ // This package has no forms. Processing this further will result in unpredictability.
+ break;
+ }
+
+ gSetupData[HiiIndex].Added = 1;
+
+ CtrlVar=0,CtrlCondVar=0; // initialize control variables for every formset
+ ActualCondVar =0; ActualCondVar2=0;
+ CtrlCondVar2=0; // this should not be necessary if vfr compiler would start
+
+ // Check the GUID is updated in the Variable list or not
+ VarIndex = 0;
+ if(IsVarGuidPresent(&(Formset->Guid), &VarIndex))
+ CtrlVar = CtrlCondVar = CtrlCondVar2 = ActualCondVar = ActualCondVar2 = VarIndex;
+ else
+ CtrlVar = CtrlCondVar = CtrlCondVar2 = ActualCondVar = ActualCondVar2 = AddFormSetVariable(&(Formset->Guid));
+
+ pVarTable = &VarKeyTable;
+
+ while(pVarTable->Next)
+ pVarTable = pVarTable->Next;
+
+ pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE));
+ pVarTable = pVarTable->Next;
+
+ pVarTable->VarId = 0;
+ pVarTable->Index = (UINT16)CtrlVar;
+
+ // with a varstote select/select_pair at the beginning of a formset
+
+ i= sizeof(EFI_HII_PACK_HEADER) + sizeof(EFI_IFR_FORM_SET);
+ form =(EFI_IFR_FORM*)(buff+i );
+
+ // create the pages lookup table
+ InitFormsetLinks((char*)form, PageListPtr ? PageListPtr->PageCount:1);
+
+ // add NULL control above submenu in main
+ ControlOffset = 0;
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32));
+
+ // add second null control for splitting the page in 2 halves
+ if (TotalRootPages == 7)
+ {
+ ControlOffset = 0;
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32));
+ }
+
+ // add the submenu control to main form that points to this form.
+ controlInfo.ControlHandle = gSetupData[HiiIndex].Handle;
+ controlInfo.ControlVariable = 0;
+ controlInfo.ControlConditionalVariable[0] = 0;
+ controlInfo.ControlConditionalVariable[1] = 0;
+ controlInfo.ControlType = CONTROL_TYPE_SUBMENU;
+ controlInfo.ControlPageID = 0;
+ controlInfo.ControlDestPageID = PageListPtr ? ((UINT16)PageListPtr->PageCount):1 ;
+
+ controlInfo.ControlFlags.ControlVisible = 1;
+ controlInfo.ControlFlags.ControlAccess = 0;
+ controlInfo.ControlFlags.ControlReadOnly = 0;
+ controlInfo.ControlFlags.ControlReset = 0;
+ controlInfo.ControlFlags.Reserved1 = 0;
+ controlInfo.ControlFlags.ControlRefresh = 0;
+ controlInfo.ControlFlags.Reserved2 = 0;
+
+
+ controlInfo.ControlHelp = 0;
+ controlInfo.ControlLabel = 0;
+ controlInfo.ControlIndex = 0;
+ controlInfo.ControlLabelCount = 0;
+ controlInfo.ControlPtr = (VOID*)((UINTN)gSetupData[HiiIndex].FormSet +
+ sizeof(EFI_HII_PACK_HEADER) +
+ sizeof(EFI_IFR_FORM_SET) +
+ TotalRootPages * sizeof(EFI_IFR_REF));
+ controlInfo.ControlConditionalPtr = 0;
+ controlInfo.ControlDataLength = 0;
+ controlInfo.ControlDataWidth = 0;
+ controlInfo.QuestionId = 0;
+
+ ControlOffset = AddControlToList(&controlInfo, sizeof(CONTROL_INFO));
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, &ControlOffset, sizeof(UINT32));
+
+ TotalRootPages++;
+
+ // add forms
+ while(i<x)
+ {
+ while((UINT8)*(buff+i) != EFI_IFR_FORM_OP)
+ {
+ if((UINT8)*(buff+i) == EFI_IFR_VARSTORE_OP)
+ AddVariable((EFI_IFR_VARSTORE*)(buff+i));
+ i+= (UINT8)*(buff+i+1);
+
+ }
+
+ form =(EFI_IFR_FORM*)(buff+i );
+
+ AllocatedPageSize = PageOffset = 0;
+ NewPageInfo = NULL;
+
+ TempPage.PageHandle = gSetupData[HiiIndex].Handle;
+ TempPage.PageIdIndex = GetPageIdIndex(&(Formset->Guid), Formset->Class, Formset->SubClass);
+ TempPage.PageFormID = form->FormId;
+ TempPage.PageTitle = (UINT16)0;
+ TempPage.PageSubTitle = form->FormTitle;
+ TempPage.PageID = PageListPtr ? ((UINT16) PageListPtr->PageCount):1;
+ TempPage.PageParentID = PageListPtr ? GetPageParent(PageListPtr->PageCount):0;
+
+ TempPage.PageFlags.PageVisible = 0;
+ TempPage.PageFlags.PageHelpVisible = 0;
+ TempPage.PageFlags.PageDisableHotKeys = 0;
+ TempPage.PageFlags.Reserved = 0;
+
+ TempPage.PageVariable = 0;
+ TempPage.PageControls.ControlCount = 0;
+ TempPage.PageControls.ControlList[0] = 0;
+
+ //Check for Dynamic Page Flag
+ if (TempPage.PageParentID == 0 && IsGroupDynamicPages()) //PageParentID is 0 && SDL token is true
+ {
+ //then set as dynamic page
+ TempPage.PageFlags.PageDynamic = TRUE ;
+ TempPage.PageFlags.PageVisible = TRUE;
+
+ }
+
+ // memory for TempPage.PageControls.ControlList[0] will be allocated later when adding controls
+ CreatePage(&NewPageInfo, &AllocatedPageSize, &PageOffset, &TempPage, sizeof(PAGE_INFO));
+
+ i += AddHpkControls(HiiIndex,(buff + i),x-i,&NewPageInfo, &AllocatedPageSize, &PageOffset);
+
+ AddPageToList(NewPageInfo, PageOffset);
+ if(NewPageInfo->PageControls.ControlCount >= MAX_CONTROLS)
+ {
+ CHAR16 *Temp = L"Reached TSE Maximum supported Controls";
+ _DisplayErrorMessage(Temp);
+ ASSERT(0);
+ }
+
+ MemFreePointer(&NewPageInfo);
+
+ if( *((char*)buff +i) == EFI_IFR_END_FORM_SET_OP)
+ {
+ controllabel = controlindex = 0;
+ if(FSetLinks !=NULL)
+ {
+ MemFreePointer(&FSetLinks);
+ FSetLinks = NULL;
+ }
+ i+=2; // add the end_formset opcode size
+ break; //no more forms in this formset...
+ }
+ }
+ }
+ else // package is NOT EFI_HII_IFR
+ {
+ //go to next package
+ i += fset->Length ;
+ }
+ } // end of while loop
+
+ CleanVarKeyTable();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetHelpToken
+//
+// Description:
+//
+// Input: UINT8 *ifr
+//
+// Output: token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetHelpToken( UINT8 *ifr )
+{
+ EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER *)ifr;
+ UINT16 token = 0;
+
+ switch ( headerPtr->OpCode )
+ {
+ case EFI_IFR_TEXT_OP:
+ {
+ EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ {
+ EFI_IFR_ORDERED_LIST *ptr = (EFI_IFR_ORDERED_LIST *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ {
+ EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ {
+ EFI_IFR_CHECK_BOX *ptr = (EFI_IFR_CHECK_BOX *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_NUMERIC_OP:
+ {
+ EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ {
+ EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_REF_OP:
+ {
+ EFI_IFR_REF *ptr = (EFI_IFR_REF *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_STRING_OP:
+ {
+ EFI_IFR_STRING *ptr = (EFI_IFR_STRING *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_SAVE_DEFAULTS_OP:
+ {
+ EFI_IFR_SAVE_DEFAULTS *ptr = (EFI_IFR_SAVE_DEFAULTS *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ case EFI_IFR_INVENTORY_OP:
+ {
+ EFI_IFR_INVENTORY *ptr = (EFI_IFR_INVENTORY *)headerPtr;
+ token = ptr->Help;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetQuestionToken
+//
+// Description:
+//
+// Input: UINT8 *ifr
+//
+// Output: token
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetQuestionToken( UINT8 *ifr )
+{
+ EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER *)ifr;
+ UINT16 token = 0;
+
+ switch ( headerPtr->OpCode )
+ {
+ case EFI_IFR_TEXT_OP:
+ {
+ EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT *)headerPtr;
+ token = ptr->Text;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ {
+ EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ {
+ EFI_IFR_CHECK_BOX *ptr = (EFI_IFR_CHECK_BOX *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_NUMERIC_OP:
+ {
+ EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ {
+ EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_REF_OP:
+ {
+ EFI_IFR_REF *ptr = (EFI_IFR_REF *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_STRING_OP:
+ {
+ EFI_IFR_STRING *ptr = (EFI_IFR_STRING *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_SAVE_DEFAULTS_OP:
+ {
+ EFI_IFR_SAVE_DEFAULTS *ptr = (EFI_IFR_SAVE_DEFAULTS *)headerPtr;
+ token = ptr->Prompt;
+ }
+ break;
+ case EFI_IFR_INVENTORY_OP:
+ {
+ EFI_IFR_INVENTORY *ptr = (EFI_IFR_INVENTORY *)headerPtr;
+ token = ptr->Text;
+ }
+ break;
+ case EFI_IFR_SUBTITLE_OP:
+ {
+ EFI_IFR_SUBTITLE *ptr = (EFI_IFR_SUBTITLE *)headerPtr;
+ token = ptr->SubTitle;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetPageNumFromFormID
+//
+// Description:
+//
+// Input: UINTN FormID
+//
+// Output: PageNum
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 GetPageNumFromFormID(UINTN FormID)
+{
+ UINTN i=0;
+
+ do{
+ if(FSetLinks->PageLink[i].FormID == FormID )
+ {
+ return (FSetLinks->PageLink[i].PageNum );
+ break;
+ }
+ }while( i++ < FSetLinks->PageCount );
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: Updatedefaults
+//
+// Description: Function to update defsaults
+//
+// Input: VOID *Data, UINT16 *size, VOID *Failsafe, VOID *Optimal,
+// struct _CONTROL_FLAGS *ControlFlags
+//
+// Output: void
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID Updatedefaults( VOID *Data, UINT16 *size, VOID *Failsafe, VOID *Optimal, struct _CONTROL_FLAGS *ControlFlags)
+{
+
+ UINT8 Flags=0;
+ UINTN i=0;
+
+
+ switch( *((UINT8*)Data) )
+ {
+ // ------ text --------------
+ case EFI_IFR_TEXT_OP: //(only interactive)
+ Flags =((EFI_IFR_TEXT*)Data)->Flags;
+
+ if(Flags & EFI_IFR_FLAG_INTERACTIVE)
+ {
+
+ ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE;
+
+ }
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+ break;
+
+ // ------ ref --------------
+ case EFI_IFR_REF_OP: // uses only interactive , but to signal that a key has to be passed
+ break; // back to a consumer (this behavior is not defined in TSE as of 5/20/05)
+
+ // ------ one of --------------
+ case EFI_IFR_ONE_OF_OP:
+
+ i= sizeof(EFI_IFR_ONE_OF);
+ do{
+ Flags =((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Flags;
+
+ if(Flags & EFI_IFR_FLAG_INTERACTIVE)
+ ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+
+ if(Flags & EFI_IFR_FLAG_DEFAULT)
+ {
+ *(UINT16*)Optimal = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value;
+ *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width;
+ }
+
+ if(Flags & EFI_IFR_FLAG_MANUFACTURING )
+ {
+ *(UINT16*)Failsafe = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value;
+ *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width;
+ }
+
+ i+=sizeof(EFI_IFR_ONE_OF_OPTION);
+
+ }while(((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Header.OpCode != EFI_IFR_END_ONE_OF_OP);
+ break;
+
+ // ------ checkbox --------------
+ case EFI_IFR_CHECKBOX_OP:
+
+ Flags = ((EFI_IFR_CHECK_BOX*) Data)->Flags ;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+
+ *size = (UINT16)((EFI_IFR_CHECK_BOX*)Data)->Width /*1*/;
+ *(UINT16*)Optimal = 0;
+ *(UINT16*)Failsafe = 0;
+ if (((EFI_IFR_CHECK_BOX*) Data)->Flags & EFI_IFR_FLAG_DEFAULT) {
+ *(UINT16*)Optimal = 1;
+ }
+ if (((EFI_IFR_CHECK_BOX*) Data)->Flags & EFI_IFR_FLAG_MANUFACTURING) {
+ *(UINT16*)Failsafe = 1;
+ }
+
+ ControlFlags->ControlRefresh=0;
+ break;
+
+ // ------ numeric --------------
+ case EFI_IFR_NUMERIC_OP:
+ ControlFlags->ControlRefresh=0;
+
+ Flags = ((EFI_IFR_CHECK_BOX*) Data)->Flags ;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+
+ // note: width is defined, but default entry is UINT16 in structure.
+ *size = ((EFI_IFR_NUMERIC*)Data)->Width/*2*/;
+ *(UINT16*)Optimal = ((EFI_IFR_NUMERIC*)Data)->Default;
+
+ *(UINT16*)Failsafe = ((EFI_IFR_NUMERIC*)Data)->Default;
+
+ break;
+
+ // ------ ordered list --------------
+ case EFI_IFR_ORDERED_LIST_OP:
+ i= sizeof(EFI_IFR_ORDERED_LIST);
+ do{
+ Flags =((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Flags;
+
+ if(Flags & EFI_IFR_FLAG_INTERACTIVE)
+ ControlFlags->ControlRefresh = DEFAULT_REFRESH_RATE;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+
+ if(Flags & EFI_IFR_FLAG_DEFAULT)
+ {
+ *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width/*2*/;
+ *(UINT16*)Optimal = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value;
+ }
+
+ if(Flags & EFI_IFR_FLAG_MANUFACTURING )
+ {
+ *size=(UINT16)((EFI_IFR_ONE_OF*)Data)->Width/*2*/;
+ *(UINT16*)Failsafe = ((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Value;
+ }
+
+ i+=sizeof(EFI_IFR_ONE_OF_OPTION);
+
+ }while(((EFI_IFR_ONE_OF_OPTION*)((char*)Data+i))->Header.OpCode != EFI_IFR_END_ONE_OF_OP);
+ break;
+
+
+ // ------ date --------------
+ case EFI_IFR_DATE_OP:
+ ControlFlags->ControlRefresh = DEFAULT_DATETIME_REFRESH;
+ break;
+
+ // ------ time --------------
+ case EFI_IFR_TIME_OP:
+ ControlFlags->ControlRefresh = DEFAULT_DATETIME_REFRESH;
+ break;
+
+ case EFI_IFR_STRING_OP:
+ Flags = ((EFI_IFR_STRING*) Data)->Flags;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+ break;
+
+ case EFI_IFR_PASSWORD_OP:
+ Flags = ((EFI_IFR_STRING*) Data)->Flags;
+
+ if(Flags & EFI_IFR_FLAG_RESET_REQUIRED)
+ ControlFlags->ControlReset = 1;
+ break;
+
+ default:
+ break;
+
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddHpkControls
+//
+// Description:
+//
+// Input: UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo,
+// UINT32 *AllocatedPageSize, UINT32 *PageOffset
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN AddHpkControls(UINT32 HiiIndex, UINT8 *buff,UINTN size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset)
+{
+ UINTN i =0 , end=0,j=0;
+ UINTN ConditionalPtr=0, ControlPtr = 0;
+ UINT16 DestPageID =0xFFFF, ControlType=0, QuestionId = 0, HelpOffset=0, OpcodeNum = 0;
+ BOOLEAN AddControl = TRUE;
+ struct _CONTROL_FLAGS ControlFlags ;
+ UINTN CtrlFailSafe = 0, CtrlOptimal = 0;
+ UINT16 Defaults_size=0;
+ EFI_IFR_OP_HEADER *Hdr;
+
+ UINT32 ControlSize;
+ UINT32 ControlOffset;
+ CONTROL_INFO *NewControlInfo;
+
+
+ // for loop for the number of controls of this
+ while(i < size )
+ {
+ CtrlFailSafe = 0;
+ CtrlOptimal = 0;
+
+ MemSet( &ControlFlags, sizeof(CONTROL_FLAGS), 0 ); //reset all the flags to zero
+ ControlFlags.ControlVisible =0x1;
+/* ControlFlags.ControlAccess =0;
+ ControlFlags.ControlRefresh =0;
+ ControlFlags.ControlReset =0;
+ ControlFlags.Reserved1 =0;
+ ControlFlags.Reserved2 =0;
+*/
+
+ // control type
+ switch(*(buff +i))
+ {
+ case EFI_IFR_END_FORM_OP:
+ controlindex++;
+ end =1;
+ break;
+
+ default :
+ if( *(buff +i) == EFI_IFR_LABEL_OP)
+ {
+ UINT8 *tBuff;
+ controllabel ++;
+ controlindex=0;
+
+ tBuff = (buff +i+ *(buff+i+1));
+ OpcodeNum=0;
+
+ while( (*tBuff != EFI_IFR_LABEL_OP ) && (*tBuff != EFI_IFR_END_FORM_SET_OP) )
+ {
+ tBuff = tBuff +(unsigned long)*(tBuff+1);
+ OpcodeNum++;
+ };
+ }
+
+ ControlType = controltypes[*(buff +i) -1];
+ HelpOffset = GetHelpToken( buff + i );
+ QuestionId = GetQuestionToken( buff + i );
+
+ // check if it is
+ switch(ControlType)
+ {
+ case CONTROL_TYPE_MEMO:
+ break;
+
+ case CONTROL_TYPE_SUBMENU:
+ DestPageID = GetPageNumFromFormID(((EFI_IFR_REF*)((char*)buff +i))->FormId);
+ break;
+
+ case CONTROL_TYPE_CHECKBOX:
+ ControlType = CONTROL_TYPE_POPUPSEL; // With no DestPageID
+ break;
+
+ case CONTROL_TYPE_POPUPSEL:
+ break;
+
+ case CONTROL_TYPE_TEXT:
+ break;
+
+
+ case CONTROL_TYPE_ORDERED_LIST:
+ break;
+
+ case END_EVAL_IF: // ENDIF for grayout,suppress or inconsistent
+ ConditionalPtr = 0;
+ updatecondvars =1;
+
+ AddControl = FALSE;
+ break;
+
+ case CONTROL_TYPE_TIME:
+ break;
+
+ case CONTROL_TYPE_DATE:
+ break;
+
+ case CONTROL_TYPE_VARSTORE:
+ AddVariable((EFI_IFR_VARSTORE*)(buff+i));
+ AddControl =FALSE;
+ break;
+
+ case CONTROL_TYPE_VARSTORE_SELECT:
+ CtrlVar= ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT*)((char*)buff +i))->VarId);
+ AddControl =FALSE;
+ break;
+
+ case CONTROL_TYPE_VARSTORE_SELECT_PAIR:
+ CtrlVar= ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)buff +i))->VarId);
+ ActualCondVar2 = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)buff +i))->SecondaryVarId);
+ AddControl =FALSE;
+ break;
+
+
+ case INCONSISTENT_IF:
+ case START_EVAL_IF: // IF for grayout,suppress or inconsistent
+
+
+ if(updatecondvars == 1)
+ {
+ Hdr= (EFI_IFR_OP_HEADER*) (buff+i);
+ Hdr = (EFI_IFR_OP_HEADER*)((UINT8*)Hdr+Hdr->Length);
+ // special case if there is a varstore just after the IF
+ switch(Hdr->OpCode)
+ {
+ case EFI_IFR_VARSTORE_SELECT_OP:
+ ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT*)((char*)Hdr))->VarId);
+ break;
+ case EFI_IFR_VARSTORE_SELECT_PAIR_OP:
+ ActualCondVar = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)Hdr))->VarId);
+ ActualCondVar2 = GetVarNumFromVarID(((EFI_IFR_VARSTORE_SELECT_PAIR*)((char*)Hdr))->SecondaryVarId);
+ break;
+
+ }
+
+ // save CtrlcondVars
+ CtrlCondVar = ActualCondVar;
+ CtrlCondVar2 = ActualCondVar2;
+ updatecondvars = 0;
+ ConditionalPtr = (UINTN)buff+i;
+
+ }
+
+ if(ControlType == INCONSISTENT_IF)
+ {
+ AddControl = TRUE;
+ break;
+ }
+
+ //break; break not used on purpose
+
+ case 0: // if is not a known control, then go to next control
+ AddControl = FALSE;
+ break;
+
+
+ }
+ break;
+ }
+
+ if(end ==1)
+ break;
+
+ if(AddControl)
+ {
+ Defaults_size =0;
+ Updatedefaults( (void *)(buff + i) , &Defaults_size, &CtrlFailSafe, &CtrlOptimal, &ControlFlags);
+
+ ControlSize = sizeof(CONTROL_INFO) + Defaults_size * 2;
+
+ NewControlInfo = EfiLibAllocateZeroPool(ControlSize);
+
+ ControlPtr = (UINTN)buff+i;
+
+ if(ControlType == INCONSISTENT_IF)
+ {
+ ControlType = CONTROL_TYPE_MSGBOX;
+ ControlPtr = 0;
+ }
+
+ NewControlInfo->ControlHandle = gSetupData[HiiIndex].Handle;
+ NewControlInfo->ControlVariable = CtrlVar;
+ NewControlInfo->ControlConditionalVariable[0] = CtrlCondVar;
+ NewControlInfo->ControlConditionalVariable[1] = CtrlCondVar2;
+ NewControlInfo->ControlType = ControlType & CONTROL_TYPE_MASK;
+ NewControlInfo->ControlPageID = PageListPtr ? ((UINT16)PageListPtr->PageCount):1;
+ NewControlInfo->ControlDestPageID = DestPageID;
+ NewControlInfo->ControlFlags = ControlFlags;
+ NewControlInfo->ControlHelp = HelpOffset;
+ NewControlInfo->ControlLabel = (UINT16)controllabel;
+ NewControlInfo->ControlIndex = (UINT16)controlindex;
+ NewControlInfo->ControlLabelCount = OpcodeNum;
+ NewControlInfo->ControlPtr = (VOID*) ControlPtr;
+ NewControlInfo->ControlConditionalPtr = (VOID*)ConditionalPtr;
+ NewControlInfo->ControlDataLength = Defaults_size;
+ NewControlInfo->ControlDataWidth = Defaults_size;
+ NewControlInfo->QuestionId = QuestionId;
+
+ if(Defaults_size !=0)
+ {
+
+ switch(Defaults_size)
+ {
+ case 1: // BYTE
+ *((UINT8 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT8)CtrlFailSafe;
+ *((UINT8 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT8)CtrlOptimal;
+ break;
+ case 2: //WORD
+ *((UINT16 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT16)CtrlFailSafe;
+ *((UINT16 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT16)CtrlOptimal;
+ break;
+ case 4: //DWORD
+ *((UINT32 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO))) = (UINT32)CtrlFailSafe;
+ *((UINT32 *) ((UINT8 *)NewControlInfo + sizeof(CONTROL_INFO) + Defaults_size)) = (UINT32)CtrlOptimal;
+ break;
+ }
+
+ }
+
+ ControlOffset = AddControlToList(NewControlInfo, ControlSize);
+ CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &ControlOffset, sizeof(UINT32));
+
+ MemFreePointer(&NewControlInfo);
+
+ if (ControlType & ~ CONTROL_TYPE_MASK)
+ {
+ ControlOffset = 0;
+ CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &ControlOffset, sizeof(UINT32));
+ }
+
+ }
+ else
+ AddControl = TRUE;
+
+ switch(ControlType)
+ {
+ case CONTROL_TYPE_POPUPSEL:
+ if( buff[i + sizeof(EFI_IFR_ONE_OF)] == EFI_IFR_ONE_OF_OPTION_OP)
+ {
+ j = sizeof(EFI_IFR_ONE_OF);
+ controlindex+=2; // account for one_of and end_one_of opcodes
+ while(buff[i+j] == EFI_IFR_ONE_OF_OPTION_OP)
+ {
+ j += sizeof(EFI_IFR_ONE_OF_OPTION);
+ controlindex++;
+ }
+ j += sizeof(EFI_IFR_END_ONE_OF);
+ break;
+ }
+ else
+ {
+ j= *((char*)buff +i+1); // checkbox
+ controlindex++;
+ }
+ break;
+
+ case CONTROL_TYPE_ORDERED_LIST:
+ if( buff[i + sizeof(EFI_IFR_ORDERED_LIST)] == EFI_IFR_ONE_OF_OPTION_OP)
+ {
+ j = sizeof(EFI_IFR_ONE_OF);
+ controlindex+=2; // account for one_of and end_one_of opcodes
+ while(buff[i+j] == EFI_IFR_ONE_OF_OPTION_OP)
+ {
+ j += sizeof(EFI_IFR_ONE_OF_OPTION);
+ controlindex++;
+ }
+ j += sizeof(EFI_IFR_END_ONE_OF);
+ break;
+ }
+
+ break;
+
+ case CONTROL_TYPE_TIME:
+ j= 3*(*((char*)buff +i+1));
+ controlindex+=2;
+ break;
+
+ case CONTROL_TYPE_DATE:
+ j= 3*(*((char*)buff +i+1));
+ controlindex+=2;
+ break;
+
+ case CONTROL_TYPE_VARSTORE:
+ j= (*((char*)buff +i+1));
+ controlindex++;
+ break;
+
+ default:
+ if( *((char*)buff +i) != EFI_IFR_LABEL_OP)
+ controlindex++;
+ j= *((char*)buff +i+1);
+
+ break;
+ }
+
+ i= i+ j;
+ DestPageID = 0x0FFFF;
+ ControlType = 0;
+ };
+
+ return i+2;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetEfiKey
+//
+// Description: Function to Encode the password key
+//
+// Input: CHAR16 *PwKey
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HiiGetEfiKey(CHAR16 *PwKey)
+{
+ EFI_KEY_DESCRIPTOR *pEfiKD = NULL; //, *pRetEfiKD = NULL;
+ UINT16 Count = 0,i;
+ EFI_STATUS Status;
+
+ if(EFI_SUCCESS != HiiInitializeProtocol())
+ return;
+
+ //Get Count (No Of Key board Desc)
+ Status= gHiiProtocol->GetKeyboardLayout(gHiiProtocol, &Count, pEfiKD);
+
+ if(EFI_BUFFER_TOO_SMALL != Status)
+ return;
+
+ if(Count)
+ {
+ //Allocate space for Count number of EFI_KEY_DESCRIPTOR
+ pEfiKD = EfiLibAllocateZeroPool(sizeof(EFI_KEY_DESCRIPTOR)*Count);
+
+ Status= gHiiProtocol->GetKeyboardLayout(gHiiProtocol, &Count, pEfiKD);
+
+ if(EFI_SUCCESS == Status)
+ {
+ for(i=0;i<Count;i++)
+ {
+ if((pEfiKD[i].Unicode == *PwKey) ||
+ (pEfiKD[i].ShiftedUnicode == *PwKey) ||
+ (pEfiKD[i].AltGrUnicode == *PwKey) ||
+ (pEfiKD[i].ShiftedAltGrUnicode == *PwKey)
+ )
+ {
+ *PwKey = (CHAR16)(pEfiKD+i)->Key;
+ break;
+ }
+ }
+ }
+ MemFreePointer((VOID **)&pEfiKD);
+ }
+}
+//----------------------------------------------------------------------------
+// Procedure: _DisplayErrorMessage
+//
+// Description: Function to display Error message when TSE supported limit exceeds
+//
+//----------------------------------------------------------------------------
+EFI_STATUS _DisplayErrorMessage(CHAR16 *Temp)
+{
+ EFI_EVENT Event;
+ EFI_STATUS status = EFI_SUCCESS;;
+ status = PostManagerDisplayInfoBox(L" Unrecoverable Error",Temp,20,&Event);
+ if(status)
+ {
+ gST->ConOut->OutputString(gST->ConOut,Temp);
+ }
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiRemoveString
+//
+// Description:
+//
+// Parameter: EFI_HII_HANDLE Handle, UINT16 Token
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HiiRemoveString(VOID* Handle, UINT16 Token)
+{
+ //UEFI2.0 doesn't support
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiGetActionWapper
+//
+// Description: The Wrapper function to get the actual action for the driver
+//
+// Parameter: UINTN Action
+//
+// Return Value: EFI_BROWSER_ACTION
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN UefiGetActionWapper(UINTN Action)
+{
+ return Action;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SavePswdString
+//
+// Description: Dummy fucntion to avoid build error
+//
+// Parameter: CONTROL_INFO * ControlData, CHAR16 *String
+//
+// Return Value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SavePswdString (CONTROL_INFO *ControlData, CHAR16 *String)
+{
+
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/hii.h b/EDK/MiniSetup/uefi2.0/hii.h
new file mode 100644
index 0000000..d6bd70d
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/hii.h
@@ -0,0 +1,328 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 18 $
+//
+// $Date: 4/18/13 9:33a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/hii.h $
+//
+// 18 4/18/13 9:33a Arunsb
+// Function declarations added to avoid build error in 2.0
+//
+// 17 3/25/13 8:34a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 16 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 16 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 15 11/28/11 5:05a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 14 11/23/11 5:22a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 13 3/28/11 5:01p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 12 3/09/11 7:25p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 11 2/01/11 7:35p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 10 12/02/10 6:09p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 9 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 8 6/15/10 12:16p Blaines
+// Update functon prototype for UefiSetTime and UefiGetTime
+//
+// 7 6/04/10 12:53p Blaines
+// Add support for UEFI 2.1 date and time controls
+//
+// 6 2/26/10 8:54p Madhans
+// For TSE 2.01.1024. refer changelog.log for file checkin history .
+//
+// 9 2/26/10 1:30p Madhans
+// To avoid build issues with EDK.
+//
+// 8 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 7 2/17/10 7:03p Madhans
+//
+// 6 1/09/10 7:22a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 5 8/17/09 12:28p Presannar
+// Removed References to Tiano.h and replace it with Efi.h
+//
+// 4 7/09/09 12:30p Mallikarjunanv
+// updated the password encoding fix
+//
+// 3 6/16/09 2:16p Presannar
+// Added File Headers for Header Files
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:08p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//*****************************************************************//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: Hii.h
+//
+// Description: Header file for Hii functionallities
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _AMIHII_H_ // DO NOT CHANGE THIS TO _HII_H_ !! That is used by the HII Protocol header
+#define _AMIHII_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+extern /*EFI_HII_HANDLE*/VOID* gHiiHandle;
+
+
+EFI_STATUS HiiExit( VOID );
+EFI_STATUS HiiFixupData( );
+UINTN HiiGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token );
+/*EFI_HII_HANDLE*/VOID* HiiFindHandle( EFI_GUID *guid, UINT16 *index );
+UINT16 HiiAddStringLanguage( /*EFI_HII_HANDLE*/VOID* handle, CHAR16 *lang, CHAR16 *string );
+UINT16 HiiChangeString( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token, CHAR16 *string );
+EFI_STATUS HiiLoadDefaults( VOID **VariableList, UINTN DefaultMask );
+VOID HiiRemoveString(VOID* Handle, UINT16 Token);
+
+/*EFI_HII_HANDLE*/VOID* * _HiiGetHandles( UINT16 *bufferSize );
+EFI_STATUS _HiiLocateSetupHandles( VOID );
+VOID *_HiiGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *Length );
+UINT16 _HiiGetLinkIndex( EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid );
+
+EFI_STATUS _HiiWrapperFindHandles( UINT16 *bufferSize, /*EFI_HII_HANDLE*/VOID* *buffer );
+
+#if HII_VERSION <= 1
+EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINT16 *bufferSize, VOID *buffer );
+#else
+EFI_STATUS _HiiWrapperGetForm( /*EFI_HII_HANDLE*/VOID* handle, UINT16 form, UINTN *bufferSize, VOID *buffer );
+#endif
+UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token );
+UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token );
+UINTN IsCharWide( CHAR16 strWide);
+
+
+extern UINTN gTitle;
+extern UINTN gHelp;
+extern UINTN gSubTitle;
+extern UINTN gHelpTitle;
+extern UINTN gNavStrings;
+
+UINT16 UefiGetHelpField(VOID *);
+UINT16 UefiGetPromptField(VOID *);
+BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData);
+UINT16 UefiGetKeyField(VOID *IfrPtr);
+UINT8 UefiGetFlagsField(VOID *IfrPtr);
+UINT16 UefiGetControlKey(CONTROL_INFO *ControlData);
+UINT16 UefiGetTextField(VOID *IfrPtr);
+UINT16 UefiGetTextTwoField(VOID *IfrPtr);
+EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data);
+
+UINT16 UefiGetMessageBoxTitle(VOID *ptr);
+UINT16 UefiGetMessageBoxText(VOID *ptr);
+VOID* UefiGetMessageBoxHandle(VOID *ptr);
+VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token);
+VOID * UefiCreateSubTitleTemplate(UINT16 Token);
+UINT16 UefiGetTitleField(VOID *IfrPtr);
+UINT64 UefiGetMinValue(VOID *IfrPtr);
+UINT64 UefiGetMaxValue(VOID *IfrPtr);
+UINT16 UefiGetWidth(VOID *IfrPtr);
+UINT64 UefiGetStepValue(VOID *IfrPtr);
+UINT8 UefiGetBaseValue(VOID *IfrPtr);
+UINT16 UefiGetQuestionOffset(VOID *IfrPtr);
+EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm);
+EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm);
+#define AMI_TIME_HOUR 1
+#define AMI_TIME_MIN 2
+#define AMI_TIME_SEC 3
+#define AMI_DATE_YEAR 4
+#define AMI_DATE_MONTH 5
+#define AMI_DATE_DAY 6
+VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max);
+UINT8 UefiGetIfrLength(VOID *IfrPtr);
+VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token);
+EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *IfrPtr,VOID **Handle,UINT16 **OptionPtrTokens, UINT64 **ValuePtrTokens, UINT16 * ItemCount,UINT16 * Interactive,UINT16 * CallBackKey );
+UINT8 UefiGetMaxEntries(VOID *IfrPtr);
+UINT16 UefiTseLiteGetBootOverRideIndex(VOID *Ptr);
+UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr,VOID * Ptr2 );
+EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer);
+EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size);
+
+BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo);
+EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size);
+EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size);
+
+UINTN HiiGetManufactuingMask(VOID);
+UINTN HiiGetDefaultMask(VOID);
+
+VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 *Variable, GUID_INFO **GuidInfo);
+UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo);
+VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID);
+VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value);
+BOOLEAN UefiIsOneOfControl(VOID *IfrPtr);
+UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr);
+VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value);
+VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo);
+VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option);
+UINT32 GetControlConditionVarId(CONTROL_INFO *control);
+VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value);
+VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width);
+VOID UefiAddEndOp(VOID *IfrPtr);
+VOID BBSUpdateControlOffset(CONTROL_INFO *control);
+UINT16 UefiGetQuestionID(CONTROL_INFO *control);
+VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value);
+EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key);
+EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control);
+//EIP 23354 : Start
+BOOLEAN IsPasswordEncodeEnabled(VOID *PwDataPtr);
+//EIP 23354 : End
+EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status);
+VOID UefiPreControlUpdate(CONTROL_INFO *ControlData);
+EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData);
+UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr);//EIP:56413 Function decleration to get the Default ID
+//EIP:56413 Function to update the Resetbutton Defaults to the control
+EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId);
+BOOLEAN CheckTimeFlags(UINT8 Flags);
+BOOLEAN CheckDateFlags(UINT8 Flags);
+UINTN UefiGetActionWapper(UINTN Action);
+VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData);
+#endif /* _AMIHII_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.0/uefi20.mak b/EDK/MiniSetup/uefi2.0/uefi20.mak
new file mode 100644
index 0000000..cc33631
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/uefi20.mak
@@ -0,0 +1,128 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 8 $
+##
+## $Date: 10/18/12 6:00a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20.mak $
+#
+# 8 10/18/12 6:00a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 9 10/10/12 12:39p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 7 4/23/10 6:12p Madhans
+#
+# 6 2/19/10 1:04p Madhans
+# Updated for TSE 2.01. Refer Changelog.log for File change history.
+##
+## 6 2/19/10 8:20a Mallikarjunanv
+## updated year in copyright message
+##
+## 5 10/28/09 5:38p Madhans
+##
+## 4 8/17/09 12:28p Presannar
+## Removed Include Path to Core Dir
+##
+## 3 6/24/09 6:11p Madhans
+## Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+##
+## 2 6/12/09 7:44p Presannar
+## Initial implementation of coding standards for AMITSE2.0
+##
+## 1 6/04/09 8:05p Madhans
+#
+# 1 4/28/09 11:09p Madhans
+# Tse 2.0 Code complete Checkin.
+##
+## 3 4/28/09 9:40p Madhans
+## Tse 2.0 Code complete Checkin.
+##
+## 2 2/05/09 10:15a Madhans
+## Style Module created.
+##
+## 1 12/18/08 7:59p Madhans
+## Intial version of TSE Lite sources
+##
+##
+##*****************************************************************##
+##*****************************************************************##
+
+# MAK file for the eModule:TseLite
+
+UEFI20_INCLUDES = \
+ -I $(TSESRC_DIR) \
+!if "$(TSE_STYLE_SOURCES_SUPPORT)" == "1"
+ -I $(TSE_STYLE_DIR) \
+!endif
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(UEFISRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+
+$(BUILD_DIR)\Uefi20Local.lib : Uefi20Lib
+
+Uefi20Lib : $(BUILD_DIR)\Uefi20.mak Uefi20LibBin
+
+$(BUILD_DIR)\Uefi20.mak : $(UEFISRC_DIR)\$(@B).cif $(UEFISRC_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(UEFISRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+Uefi20LibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\Uefi20.mak all\
+ "MY_INCLUDES=$(UEFI20_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\Uefi20Local.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/uefi2.0/uefi20.sdl b/EDK/MiniSetup/uefi2.0/uefi20.sdl
new file mode 100644
index 0000000..95cdca4
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/uefi20.sdl
@@ -0,0 +1,53 @@
+TOKEN
+ Name = "UEFI_2_0_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable UEFI 2.0 sources support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Token = "EFI_SPECIFICATION_VERSION" "<=" "0x20000"
+End
+
+TOKEN
+ Name = "UEFI_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Don't Edit."
+ TokenType = Boolean
+ TargetH = Yes
+ TargetMAK = Yes
+End
+
+TOKEN
+ Name = "TSE_SUPPORT_VFRCOMPILE_1_88"
+ Value = "1"
+ Help = "Turn on to support vfrcompiler version 1.88 and later"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_FORM_BROWSER_SUPPORT"
+ Value = "0"
+ Help = "1 => Installs form browser protocol should turn on SETUP_RUNTIME_IFR_PROCESSING. 0 => Does not install form browser protocol."
+ TokenType = Boolean
+ TargetH = Yes
+ Token = "SETUP_RUNTIME_IFR_PROCESSING" "=" "1"
+ Token = "TSE_USE_EDK_LIBRARY" "=" "1"
+End
+
+PATH
+ Name = "UEFISRC_DIR"
+End
+
+MODULE
+ Help = "Includes Uefi20.mak to Project"
+ File = "Uefi20.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\Uefi20Local.lib"
+ Parent = "$(UEFISRC_DIR)\Uefi20Local$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
diff --git a/EDK/MiniSetup/uefi2.0/uefi20Wapper.c b/EDK/MiniSetup/uefi2.0/uefi20Wapper.c
new file mode 100644
index 0000000..8b4bf06
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.0/uefi20Wapper.c
@@ -0,0 +1,2428 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20Wapper.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 34 $
+//
+// $Date: 5/02/14 10:38p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/uefi2.0/uefi20Wapper.c $
+//
+// 34 5/02/14 10:38p Arunsb
+// gEnableProcessPack variable added to avoid build error
+//
+// 33 6/10/13 2:15p Arunsb
+// EvaluateControlDefault function added to avoid build error in 2.0
+//
+// 32 3/25/13 8:34a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 31 10/18/12 6:00a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 18 10/10/12 12:39p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 28 9/25/12 1:45p Premkumara
+// EIP - 99059 - Updated for UEFI2.0
+// Files - Hii.c, Uefi20Wapper.c
+//
+// 27 2/02/12 2:56a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 26 12/08/11 9:37a Rajashakerg
+// [TAG] EIP75588
+// [Category] Improvement
+// [Description] Updated the file to aviod build errors when build for
+// UEFI 20 by providing the dummy functions.
+//
+// 25 12/02/11 1:52a Premkumara
+// [TAG] EIP73226
+// [Category] New Feature
+// [Description] Extended support for password prompt
+// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c,
+// HiiCallBack.c, Uefi20Wapper.c
+//
+// 24 12/01/11 7:16p Blaines
+// Fix build errors in Uefi2.0
+//
+// 23 11/28/11 5:06a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 22 11/23/11 5:24a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 21 10/18/11 1:50p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c,
+// uefi20Wapper.c
+//
+// 20 6/30/11 4:15a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Wrapper functions added.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 19 6/28/11 3:44p Arunsb
+// [TAG] EIP55762
+// [Description] Dummy UpdateDestiantionQuestion function added
+//
+// 18 4/29/11 4:39p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted
+//
+// 16 3/28/11 5:03p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 15 3/09/11 7:25p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 14 2/01/11 7:41p Madhans
+// [TAG] - EIP 52032
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - In UEFI2.0 Updating the Interactive One of Control may not
+// work correctly.
+// [RootCause] - The UefiGetControlKey for Interactive one of control is
+// not returned properly.
+// [Solution]- fix in UefiGetControlKey control.
+// [Files] - uefi20wapper.c
+//
+// 13 2/01/11 7:37p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 12 12/02/10 6:09p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 11 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 10 6/15/10 12:16p Blaines
+// Update functon prototype for UefiSetTime and UefiGetTime
+//
+// 9 6/04/10 12:53p Blaines
+// Add support for UEFI 2.1 date and time controls
+//
+// 8 2/19/10 1:04p Madhans
+// Updated for TSE 2.01. Refer Changelog.log for File change history.
+//
+// 11 2/19/10 8:20a Mallikarjunanv
+// updated year in copyright message
+//
+// 10 1/29/10 4:34p Madhans
+// To avoid compiler warnings.
+//
+// 9 1/27/10 12:59p Madhans
+// // EIP 33804 : Issue iSCSI initiator name is not saved..
+//
+// 8 1/09/10 7:30a Mallikarjunanv
+// Updated TSE2.01 Release sources with coding standards
+//
+// 7 10/19/09 10:52a Blaines
+// EIP #26029 Fix: UefiCreateOneOfWithOptionsTemplate() does not always
+// return NULL when EfiLibAllocateZeroPool() returns NULL
+//
+// 6 7/09/09 12:30p Mallikarjunanv
+// updated the password encoding fix
+//
+// 4 6/24/09 6:11p Madhans
+// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
+//
+// 3 6/23/09 6:51p Blaines
+// Coding standard update,
+// Remove spaces from file header to allow proper chm function list
+// creation.
+//
+// 2 6/12/09 7:44p Presannar
+// Initial implementation of coding standards for AMITSE2.0
+//
+// 1 6/04/09 8:05p Madhans
+//
+// 1 4/28/09 11:09p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 4 4/28/09 9:40p Madhans
+// Tse 2.0 Code complete Checkin.
+//
+// 3 3/31/09 4:14p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/30/09 6:06p Madhans
+// Function headers added.
+//
+// 1 12/18/08 7:59p Madhans
+// Intial version of TSE Lite sources
+//
+//
+//*****************************************************************//
+//*****************************************************************//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: uefi20wraper.c
+//
+// Description: This file contains code for UEFI2.0 wrapper
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include "minisetup.h"
+#include EFI_PROTOCOL_DEFINITION(Hii)
+#include EFI_PROTOCOL_DEFINITION(FormCallback)
+extern EFI_HII_PROTOCOL *gHiiProtocol;
+BOOLEAN gPackUpdatePending = FALSE;
+BOOLEAN gEnableProcessPack = FALSE; //Added to avoid build error
+
+static EFI_IFR_SUBTITLE _Title = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _Help = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _SubTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _HelpTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, STRING_TOKEN(STR_HELP_TITLE) };
+static EFI_IFR_SUBTITLE _NavStrings = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+
+UINTN gTitle = (UINTN)&_Title;
+UINTN gHelp = (UINTN)&_Help;
+UINTN gSubTitle = (UINTN)&_SubTitle;
+UINTN gHelpTitle = (UINTN)&_HelpTitle;
+UINTN gNavStrings = (UINTN)&_NavStrings;
+
+EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle );
+EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index );
+VOID *UefiCreateStringTemplate(UINT16 Token);
+
+UINT32 FindVarFromITKQuestionId(UINT16 QuestionId);
+UINT32 GetVarNumFromVarID(UINT32 ID);
+VOID UefiSetHelpField(VOID *IfrPtr,UINT16 Token);
+////For avoiding build error EIP101564
+UINT32 gRefreshIdCount = 0; //No. of controls with Refresh Id set
+REFRESH_ID_INFO *gRefreshIdInfo = NULL;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetHelpField
+//
+// Description: To get the specific help field
+//
+// Input: VOID *IfrPtr
+//
+// Output: Help Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetHelpField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ return ((EFI_IFR_REF*)OpHeader)->Help;
+ break;
+ case EFI_IFR_TEXT_OP:
+ return ((EFI_IFR_TEXT*)OpHeader)->Help;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ return ((EFI_IFR_ONE_OF*)OpHeader)->Help;
+ break;
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_NUMERIC_OP:
+ return ((EFI_IFR_NUMERIC*)OpHeader)->Help;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return ((EFI_IFR_PASSWORD*)OpHeader)->Help;
+ break;
+ case EFI_IFR_STRING_OP:
+ return ((EFI_IFR_STRING*)OpHeader)->Help;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetHelpField
+//
+// Description: To Set the specific help field
+//
+// Input: VOID *IfrPtr, UINT16 Token
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetHelpField(VOID *IfrPtr, UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ ((EFI_IFR_REF*)OpHeader)->Help = Token ;
+ break;
+ case EFI_IFR_TEXT_OP:
+ ((EFI_IFR_TEXT*)OpHeader)->Help = Token ;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF*)OpHeader)->Help = Token ;
+ break;
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_NUMERIC_OP:
+ ((EFI_IFR_NUMERIC*)OpHeader)->Help = Token ;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ ((EFI_IFR_PASSWORD*)OpHeader)->Help = Token ;
+ break;
+ case EFI_IFR_STRING_OP:
+ ((EFI_IFR_STRING*)OpHeader)->Help = Token ;
+ break;
+ default:
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetPromptField
+//
+// Description: To get the prompt field from ifr
+//
+// Input: VOID *IfrPtr
+//
+// Output: Prompt Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetPromptField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ return ((EFI_IFR_REF*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ return ((EFI_IFR_NUMERIC*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ return ((EFI_IFR_ONE_OF*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ return ((EFI_IFR_ORDERED_LIST*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ return ((EFI_IFR_CHECK_BOX*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return ((EFI_IFR_PASSWORD*)OpHeader)->Prompt;
+ break;
+ case EFI_IFR_STRING_OP:
+ return ((EFI_IFR_STRING*)OpHeader)->Prompt;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetKeyField
+//
+// Description: To get the Key field from ifr
+//
+// Input: VOID *IfrPtr
+//
+// Output: Key Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetKeyField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ return ((EFI_IFR_REF*)OpHeader)->Key;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ return ((EFI_IFR_NUMERIC*)OpHeader)->Key;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return ((EFI_IFR_PASSWORD*)OpHeader)->Key;
+ break;
+ case EFI_IFR_TEXT_OP:
+ return ((EFI_IFR_TEXT*)OpHeader)->Key;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ return ((EFI_IFR_CHECK_BOX*)OpHeader)->Key;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_ORDERED_LIST_OP:
+ if(OpHeader->OpCode == EFI_IFR_ORDERED_LIST_OP)
+ OpHeader = (EFI_IFR_OP_HEADER *)(((UINT8 *)OpHeader) +sizeof(EFI_IFR_ORDERED_LIST) );
+ else
+ OpHeader = (EFI_IFR_OP_HEADER *)(((UINT8 *)OpHeader) +sizeof(EFI_IFR_ONE_OF) );
+ return ((EFI_IFR_ONE_OF_OPTION*)OpHeader)->Key;
+ break;
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ return ((EFI_IFR_ONE_OF_OPTION*)OpHeader)->Key;
+ break;
+ case EFI_IFR_STRING_OP:
+ return ((EFI_IFR_STRING*)OpHeader)->Key;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTitleField
+//
+// Description: To get the Title field from ifr
+//
+// Input: VOID *IfrPtr
+//
+// Output: Title Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTitleField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUBTITLE_OP:
+ return ((EFI_IFR_SUBTITLE*)OpHeader)->SubTitle;
+ break;
+ case EFI_IFR_FORM_OP:
+ return ((EFI_IFR_FORM*)OpHeader)->FormTitle;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetFlagsField
+//
+// Description: to get the Flags field from ifr
+//
+// Input: VOID *IfrPtr
+//
+// Output: Flags Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetFlagsField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ return ((EFI_IFR_REF*)OpHeader)->Flags;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsInteractive
+//
+// Description: To get Uefi Interactive
+//
+// Input: CONTROL_INFO *ControlData
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)ControlData->ControlPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ return ((((EFI_IFR_REF*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE);
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ return ((((EFI_IFR_NUMERIC*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE);
+ break;
+ case EFI_IFR_STRING_OP:
+ return ((((EFI_IFR_STRING*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE);
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return ((((EFI_IFR_PASSWORD*)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)?TRUE:FALSE);
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetControlKey
+//
+// Description: Helper function in obtaining Control Key
+//
+// Input: CONTROL_INFO *ControlData
+//
+// Output: Key Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetControlKey(CONTROL_INFO *ControlData)
+{
+ return UefiGetKeyField((VOID*)ControlData->ControlPtr);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTextField
+//
+// Description: Function to get the Text Field.
+//
+// Input: VOID *IfrPtr
+//
+// Output: Text Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTextField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TEXT_OP:
+ return ((EFI_IFR_TEXT*)OpHeader)->Text;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTextTwoField
+//
+// Description: Function to get the Text Field.
+//
+// Input: VOID *IfrPtr
+//
+// Output: Text Field
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTextTwoField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TEXT_OP:
+ return ((EFI_IFR_TEXT*)OpHeader)->TextTwo;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetSubTitleField
+//
+// Description: Function to Set the Sub-Title Field.
+//
+// Input: VOID *IfrPtr, UINT16 Token
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUBTITLE_OP:
+ ((EFI_IFR_SUBTITLE*)OpHeader)->SubTitle = Token;
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetPromptField
+//
+// Description: Function to set the prompt Field.
+//
+// Input: VOID *IfrPtr, UINT16 Token
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ ((EFI_IFR_REF*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ ((EFI_IFR_NUMERIC*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ ((EFI_IFR_ORDERED_LIST*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ ((EFI_IFR_CHECK_BOX*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ ((EFI_IFR_PASSWORD*)OpHeader)->Prompt = Token;
+ break;
+ case EFI_IFR_STRING_OP:
+ ((EFI_IFR_STRING*)OpHeader)->Prompt = Token;
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateSubTitleTemplate
+//
+// Description: Function to prepare the template for sub-title
+//
+// Input: UINT16 Token
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID * UefiCreateSubTitleTemplate(UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_SUBTITLE));
+
+ OpHeader->OpCode = EFI_IFR_SUBTITLE_OP ;
+ OpHeader->Length = sizeof(EFI_IFR_SUBTITLE) ;
+ UefiSetSubTitleField((VOID *)OpHeader,Token);
+ return (VOID*)OpHeader;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetIfrLength
+//
+// Description: Function to get the length of Ifr
+//
+// Input: VOID *IfrPtr
+//
+// Output: Length
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetIfrLength(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ return OpHeader->Length;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMinValue
+//
+// Description: Function to get the minimum value
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT64
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetMinValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Minimum;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MinSize;
+ break;
+ case EFI_IFR_STRING_OP:
+ return (UINT64)((EFI_IFR_STRING*)OpHeader)->MinSize;
+ break;
+ default:
+ break;
+ }
+ return (UINT64)0;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMaxValue
+//
+// Description: Function to get the max value
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT64
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetMaxValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Maximum;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MaxSize;
+ break;
+ case EFI_IFR_STRING_OP:
+ return (UINT64)((EFI_IFR_STRING*)OpHeader)->MaxSize;
+ break;
+ default:
+ break;
+ }
+ return (UINT64)0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetStepValue
+//
+// Description: Function to get the step value
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT64
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetStepValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ return (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->Step;
+ break;
+ default:
+ break;
+ }
+ return (UINT64)0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetBaseValue
+//
+// Description: Function to get the base value
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT8
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetBaseValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ return AMI_BASE_DEC;
+ break;
+ default:
+ break;
+ }
+ return AMI_BASE_DEC;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetWidth
+//
+// Description: Function to get width
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetWidth(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ return (UINT16)((EFI_IFR_NUMERIC*)OpHeader)->Width;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ return (UINT16)((EFI_IFR_PASSWORD*)OpHeader)->Width;
+ break;
+ case EFI_IFR_STRING_OP:
+ return (UINT16)((EFI_IFR_STRING*)OpHeader)->Width;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ return (UINT16)((EFI_IFR_ONE_OF*)OpHeader)->Width;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ return (UINT16)((EFI_IFR_CHECK_BOX*)OpHeader)->Width;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ return (UINT16)((EFI_IFR_EQ_ID_VAL*)OpHeader)->Width;
+ break;
+ case EFI_IFR_EQ_ID_LIST_OP:
+ return (UINT16)((EFI_IFR_EQ_ID_LIST*)OpHeader)->Width;
+ break;
+ case EFI_IFR_EQ_ID_ID_OP:
+ return (UINT16)((EFI_IFR_EQ_ID_ID*)OpHeader)->Width;
+ break;
+ default:
+ break;
+ }
+ return (UINT16)0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetWidth
+//
+// Description: Function to set width
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ ((EFI_IFR_NUMERIC*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ ((EFI_IFR_PASSWORD*)OpHeader)->Width = Width ;
+ break;
+ case EFI_IFR_STRING_OP:
+ ((EFI_IFR_STRING*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ ((EFI_IFR_CHECK_BOX*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ ((EFI_IFR_EQ_ID_VAL*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_EQ_ID_LIST_OP:
+ ((EFI_IFR_EQ_ID_LIST*)OpHeader)->Width = Width;
+ break;
+ case EFI_IFR_EQ_ID_ID_OP:
+ ((EFI_IFR_EQ_ID_ID*)OpHeader)->Width = Width;
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetQuestionOffset
+//
+// Description: Function to get question offset
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetQuestionOffset(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ return (UINT16)((EFI_IFR_NV_DATA*)OpHeader)->QuestionId;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetDateTimeDetails
+//
+// Description: Function to get the details of data and time
+//
+// Input: VOID *IfrPtr,
+// UINT8 Type,
+// UINT16 * Help,
+// UINT16 * Min,
+// UINT16 * Max
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ EFI_IFR_NUMERIC *NumIfr=NULL;
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TIME_OP:
+ if(Type == AMI_TIME_HOUR)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Hour);
+ else if (Type == AMI_TIME_MIN)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Minute);
+ else if (Type == AMI_TIME_SEC)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Second);
+ break;
+ case EFI_IFR_DATE_OP:
+ if(Type == AMI_DATE_YEAR)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Year);
+ else if (Type == AMI_DATE_MONTH)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Month);
+ else if (Type == AMI_DATE_DAY)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Day);
+ break;
+ default:
+ break;
+ }
+ if(NumIfr)
+ {
+ *Help = NumIfr->Help;
+ *Min = NumIfr->Minimum;
+ *Max = NumIfr->Maximum;
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetOneOfOptions
+//
+// Description: Function to get OneOf options
+//
+// Input: VOID *IfrPtr,
+// VOID **Handle,
+// UINT16 **OptionPtrTokens,
+// UINT64 **ValuePtrTokens,
+// UINT16 * ItemCount,
+// UINT16 * Interactive,
+// UINT16 * CallBackKey
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *CtrlInfo,VOID **Handle,UINT16 **OptionPtrTokens, UINT64 **ValuePtrTokens, UINT16 * ItemCount,UINT16 * Interactive,UINT16 * CallBackKey )
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)(CtrlInfo->ControlPtr);
+ EFI_IFR_ONE_OF_OPTION *ptrData;
+ UINT8 Opcode = OpHeader->OpCode;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 Index= 0 ;
+
+ if(Opcode == EFI_IFR_ORDERED_LIST_OP)
+ ptrData = (EFI_IFR_ONE_OF_OPTION *)((UINT8 *)(OpHeader) +sizeof(EFI_IFR_ORDERED_LIST) );
+ else
+ ptrData = (EFI_IFR_ONE_OF_OPTION *)((UINT8 *)(OpHeader) +sizeof(EFI_IFR_ONE_OF) );
+
+ switch ( Opcode )
+ {
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_ORDERED_LIST_OP: // ordered list option
+ while( ptrData[Index].Header.OpCode != EFI_IFR_END_ONE_OF_OP )
+ Index++;
+ break;
+
+ case EFI_IFR_CHECKBOX_OP:
+ Index = 2;
+ *Handle = gHiiHandle;
+ break;
+ }
+ if( *OptionPtrTokens != NULL )
+ MemFreePointer( (VOID **)OptionPtrTokens);
+
+ if(ValuePtrTokens)
+ if( *ValuePtrTokens != NULL )
+ MemFreePointer( (VOID **)ValuePtrTokens);
+
+
+ *OptionPtrTokens = EfiLibAllocatePool( Index * sizeof(UINT16) );
+
+ if(ValuePtrTokens)
+ *ValuePtrTokens = EfiLibAllocatePool( Index * sizeof(UINT64) );
+
+ if ( *OptionPtrTokens == NULL )
+ Status = EFI_OUT_OF_RESOURCES;
+ else
+ {
+ *ItemCount = Index;
+
+ for ( Index = 0; Index < *ItemCount; Index++ )
+ {
+ if( ((Opcode == EFI_IFR_ONE_OF_OP)|(Opcode == EFI_IFR_ORDERED_LIST_OP)) && (ptrData->Header.OpCode == EFI_IFR_ONE_OF_OPTION_OP) )
+ {
+ (*OptionPtrTokens)[Index] = ptrData[Index].Option;
+ if(ValuePtrTokens)
+ (*ValuePtrTokens)[Index] = ptrData[Index].Value;
+
+ if(ptrData[Index].Flags & EFI_IFR_FLAG_INTERACTIVE)
+ {
+ if(Interactive) *Interactive = TRUE;
+ if(CallBackKey) *CallBackKey = ptrData[Index].Key;
+ }
+ }
+ else
+ {
+ (*OptionPtrTokens)[Index] = gCheckboxTokens[Index];
+ if(ValuePtrTokens)
+ (*ValuePtrTokens)[Index] = Index;
+ if(((EFI_IFR_CHECK_BOX *)OpHeader)->Flags & EFI_IFR_FLAG_INTERACTIVE)
+ {
+ if(Interactive) *Interactive = TRUE;
+ if(CallBackKey) *CallBackKey = ((EFI_IFR_CHECK_BOX *)OpHeader)->Key;
+ }
+
+ }
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMaxEntries
+//
+// Description: Function to get max entries
+//
+// Input: VOID *IfrPtr,
+//
+// Output: UINT8
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetMaxEntries(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_ORDERED_LIST_OP:
+ return ((EFI_IFR_ORDERED_LIST*)OpHeader)->MaxEntries;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiTseLiteGetBootOverRideIndex
+//
+// Description: Function to get boot override index
+//
+// Input: VOID *Ptr,
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiTseLiteGetBootOverRideIndex(VOID *Ptr)
+{
+ UINT16 Index=0xFFFF;
+ EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Ptr;
+ EFI_IFR_EQ_ID_LIST *EqIdList;
+
+ if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP))
+ {
+ while(OpHeader->OpCode != EFI_IFR_EQ_ID_LIST_OP)
+ {
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ if(OpHeader->OpCode == EFI_IFR_END_IF_OP) // Not found
+ return Index;
+ }
+
+ // FIX ME : Do it better. Check the list length and
+ if(OpHeader->OpCode == EFI_IFR_EQ_ID_LIST_OP)
+ {
+ EqIdList = (EFI_IFR_EQ_ID_LIST*)OpHeader;
+ Index = EqIdList->ListLength - 1;
+ }
+ }
+
+ return Index;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiTseLiteGetAmiCallbackIndex
+//
+// Description: Function to get ami callback index
+//
+// Input: VOID *Ptr,
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr, VOID * Ptr2)
+{
+ UINT16 Index=0xFFFF;
+ EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Ptr;
+
+ if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP))
+ {
+ while(OpHeader->OpCode != EFI_IFR_EQ_ID_VAL_OP)
+ {
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ if(OpHeader->OpCode == EFI_IFR_END_IF_OP) // Not found
+ return Index;
+ }
+
+ // FIX ME : Do it better. Check the list length and
+ if(OpHeader->OpCode == EFI_IFR_EQ_ID_VAL_OP)
+ {
+ Index = ((EFI_IFR_EQ_ID_VAL*)OpHeader)->Value;
+ }
+ }
+
+ return Index;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiFormCallbackNVRead
+//
+// Description: Function to get callback nvread
+//
+// Input: CHAR16 *name,
+// EFI_GUID *guid,
+// UINT32 *attributes,
+// UINTN *size,
+// VOID **buffer
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer)
+{
+ EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_IFR_FORM_SET *FmSet=NULL;
+ UINTN i=0;
+
+ if(gSetupCount)
+ {
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ FmSet = HiiGetFormSet( i );
+ if(!FmSet)
+ continue;
+
+ if( EfiCompareGuid(&(FmSet->Guid),guid) && (EFI_HANDLE)((UINTN)FmSet->CallbackHandle) )
+ {
+ Status = gBS->HandleProtocol(
+ (EFI_HANDLE)((UINTN)FmSet->CallbackHandle),
+ &gEfiFormCallbackProtocolGuid,
+ &FormCallBack );
+ }
+
+ if ( ! EFI_ERROR( Status ) )
+ {
+ if( FormCallBack->NvRead )
+ {
+ Status = FormCallBack->NvRead( FormCallBack, name, guid, attributes, size, *buffer );
+
+ if ( Status != EFI_BUFFER_TOO_SMALL )
+ break;
+
+ *buffer = EfiLibAllocatePool( *size );
+
+ if ( *buffer == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ Status = FormCallBack->NvRead( FormCallBack, name, guid, attributes, size, *buffer );
+ break;
+ }
+ else
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiFormCallbackNVWrite
+//
+// Description: Function to get callback nvwrite
+//
+// Input: CHAR16 *name,
+// EFI_GUID *guid,
+// UINT32 *attributes,
+// VOID **buffer
+// UINTN *size,
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size)
+{
+ EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL;
+ BOOLEAN Reset=FALSE;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_IFR_FORM_SET * FmSet=NULL;
+ UINTN i=0;
+
+ if(gSetupCount)
+ {
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ FmSet = HiiGetFormSet( i );
+
+ if(!FmSet)
+ continue;
+
+ if( EfiCompareGuid(&(FmSet->Guid),guid) && (EFI_HANDLE)((UINTN)FmSet->CallbackHandle) )
+ {
+ Status = gBS->HandleProtocol(
+ (EFI_HANDLE)((UINTN)FmSet->CallbackHandle),
+ &gEfiFormCallbackProtocolGuid,
+ &FormCallBack );
+ }
+
+ if ( ! EFI_ERROR(Status ) )
+ {
+ if( FormCallBack->NvWrite )
+ {
+ Reset = FALSE;
+ Status = FormCallBack->NvWrite(
+ FormCallBack,
+ name,
+ guid,
+ attributes,
+ size,
+ buffer,
+ &Reset
+ );
+ if ( ( ! EFI_ERROR(Status ) ) && Reset )
+ gResetRequired = TRUE;
+ break;
+ }
+ else
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ }
+ return Status;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitMiniSetupStrings
+//
+// Description: Function to init minisetup strings
+//
+// Input: VOID
+//
+// Output: Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1
+EFI_STATUS InitMiniSetupStrings( VOID )
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+ UINT16 Index = 0;
+
+#if HII_VERSION == 0
+ EFI_HII_PACK_LIST PackList;
+ EFI_HII_PACK_LIST *PackageList;
+#else
+ EFI_HII_PACKAGES *PackageList = NULL;
+#endif
+ VOID **Package = NULL;
+ EFI_GUID MiniSetupGuid = MINI_SETUP_GUID;
+
+ Status = HiiInitializeProtocol();
+ if ( EFI_ERROR ( Status ) )
+ return Status;
+
+ gHiiHandle = HiiFindHandle( &MiniSetupGuid, &Index );
+
+ if ( gHiiHandle == INVALID_HANDLE )
+ {
+#if HII_VERSION == 0
+ PackList.IfrPack = NULL;
+ PackList.StringPack = (EFI_HII_STRING_PACK *)STRING_ARRAY_NAME;
+ PackList.FontPack = NULL;
+ PackList.KeyboardPack = NULL;
+ PackList.GuidId = &MiniSetupGuid;
+ PackageList = &PackList;
+#else
+ PackageList = EfiLibAllocateZeroPool( sizeof(EFI_HII_PACKAGES) + sizeof(VOID *) );
+ if ( PackageList == NULL )
+ return EFI_OUT_OF_RESOURCES;
+
+ PackageList->GuidId = &MiniSetupGuid;
+ PackageList->NumberOfPackages = 1;
+ Package = (VOID **) ((UINT8 *)PackageList + sizeof (EFI_HII_PACKAGES));
+#ifdef USE_DEPRICATED_INTERFACE
+ *Package = (VOID *)STRING_ARRAY_NAME;
+#else
+ *Package = (VOID *)&STRING_ARRAY_NAME;
+#endif
+#endif
+
+ Status = gHiiProtocol->NewPack( gHiiProtocol, PackageList, (EFI_HII_HANDLE *)&gHiiHandle );
+#if HII_VERSION != 0
+ MemFreePointer( (VOID **)&PackageList );
+#endif
+ }
+
+ return Status;
+}
+#endif
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsEfiVariable
+//
+// Description: Function to check efi variable
+//
+// Input: UINT32 variable, VARIABLE_INFO *varInfo
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo)
+{
+ return TRUE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiVarGetNvram
+//
+// Description: Function to get nvram
+//
+// Parameter: VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset,
+// UINTN Size
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size)
+{
+ return EFI_UNSUPPORTED;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiVarGetNvram
+//
+// Description: Function to set nvram
+//
+// Parameter: VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset,
+// UINTN Size
+//
+// Output: STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size)
+{
+ return EFI_UNSUPPORTED;
+}
+
+#define AMI_FLAG_MANUFACTURING EFI_IFR_FLAG_MANUFACTURING
+#define AMI_FLAG_DEFAULT EFI_IFR_FLAG_DEFAULT
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetManufactuingMask
+//
+// Description: Function to get manufacturing mask
+//
+// Input: VOID
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiGetManufactuingMask(VOID)
+{
+ return AMI_FLAG_MANUFACTURING;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetDefaultMask
+//
+// Description: Function to get default mask
+//
+// Input: VOID
+//
+// Output: UINTN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiGetDefaultMask(VOID)
+{
+ return AMI_FLAG_DEFAULT;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetControlConditionVarId
+//
+// Description: Function to get control variable id
+//
+// Input: CONTROL_INFO *control
+//
+// Output: UINT32
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 GetControlConditionVarId(CONTROL_INFO *control)
+{
+ return (control->ControlConditionalVariable[0])?control->ControlConditionalVariable[0]:0xFFFF;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSUpdateControlOffset
+//
+// Description: Function to update control offset
+//
+// Input: CONTROL_INFO *control
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSUpdateControlOffset(CONTROL_INFO *control)
+{
+ UINT16 offset= ((EFI_IFR_ONE_OF*)control->ControlPtr)->QuestionId;
+
+ offset = offset +sizeof(UINT32)+sizeof(UINT16);
+ offset = (UINT16)(offset + gCurrLegacyBootData->LegacyEntryOffset);
+
+ ((EFI_IFR_ONE_OF*)control->ControlPtr)->QuestionId = offset;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetSpecialEqIDIfrPtr
+//
+// Description: Function to get special eqID Ifr pointer
+//
+// Input: VOID *Conditional, UINT32 Variable, GUID_INFO **GuidInfo
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 *Variable, GUID_INFO **GuidInfo)
+{
+ VOID *Conditional = ControlInfo->ControlConditionalPtr;
+ VOID *ControlPtr = ControlInfo->ControlPtr;
+ EFI_IFR_OP_HEADER *ifrPtr;
+ VARIABLE_INFO *varInfo;
+ UINTN i;
+ GUID_INFO *specialGuid = NULL;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)Conditional;
+
+ if((ifrPtr==NULL) || (ControlPtr <= Conditional))
+ return NULL;
+
+ if ( ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAYOUT_IF_OP ) )
+ return NULL;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+ if ( ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_OP ) || ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_PAIR_OP ) )
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+
+ // skip NOT if it is present
+ if ( ifrPtr->OpCode == EFI_IFR_NOT_OP )
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+
+ if(NoVarStoreSupport())
+ {
+ if(*Variable == VARIABLE_ID_SETUP)
+ {
+ *Variable = FindVarFromITKQuestionId(UefiGetEqIDQuestionID(ifrPtr));
+ }
+ }
+
+ varInfo = VarGetVariableInfoIndex( *Variable );
+ if ( varInfo == NULL )
+ return NULL;
+
+ for ( i = 0; i < gGuidList->GuidCount; i++ )
+ {
+ GUID_INFO *guidInfo = (GUID_INFO *)((UINTN)gGuidList + gGuidList->GuidList[i]);
+ if ( EfiCompareGuid( &varInfo->VariableGuid, &guidInfo->GuidValue ) )
+ {
+ specialGuid = guidInfo;
+ break;
+ }
+ }
+
+ if ( specialGuid != NULL )
+ {
+ if ( GuidInfo != NULL )
+ *GuidInfo = specialGuid;
+ }
+ else
+ {
+ ifrPtr = NULL;
+ }
+
+ // See if Other condition is Special condition
+ if(ifrPtr == NULL)
+ {
+ if(ControlPtr > Conditional)
+ {
+ ifrPtr = (EFI_IFR_OP_HEADER *)Conditional;
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf
+ // to skip current expression.
+ while( (VOID*)ifrPtr < ControlPtr)
+ {
+ if ( (ifrPtr != ControlPtr) && ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAYOUT_IF_OP ) )
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf
+ else
+ break;
+ }
+
+ Conditional = ifrPtr;
+ if(ControlPtr > Conditional)
+ {
+ CONTROL_INFO TempCtlInfo;
+ MemCopy(&TempCtlInfo, ControlInfo, sizeof (CONTROL_INFO));
+ TempCtlInfo.ControlConditionalPtr = Conditional;
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length); // To skip the SuppressIf or GrayOutIf
+ if ( ( ifrPtr->OpCode == EFI_IFR_VARSTORE_SELECT_OP ) )
+ VarGetVariableInfoId( ((EFI_IFR_VARSTORE_SELECT*)((char*)ifrPtr))->VarId, Variable );
+ ifrPtr = UefiGetSpecialEqIDIfrPtr(&TempCtlInfo, Variable, GuidInfo);
+ }
+ else
+ ifrPtr = NULL;
+ }
+ }
+
+ return ifrPtr;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetSpecialEqIDValue
+//
+// Description: Function to get special eqID value
+//
+// Input: CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo)
+{
+ UINT16 value = (UINT16)-2;
+ UINT32 condVarID = 0;
+ EFI_IFR_OP_HEADER *ifrPtr = NULL;
+
+ condVarID = (UINT32)GetControlConditionVarId(ControlInfo);
+ ifrPtr = (EFI_IFR_OP_HEADER *)UefiGetSpecialEqIDIfrPtr(ControlInfo, &condVarID, GuidInfo);
+
+ if(ifrPtr != NULL)
+ {
+ switch(ifrPtr->OpCode)
+ {
+ case EFI_IFR_EQ_ID_LIST_OP:
+ value = ((EFI_IFR_EQ_ID_LIST *)ifrPtr)->ValueList[0];
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ value = ((EFI_IFR_EQ_ID_VAL *)ifrPtr)->Value;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return value;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSpecialGuidCallback
+//
+// Description: Function to get special guid callback
+//
+// Input: VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID)
+{
+ EFI_FORM_CALLBACK_PROTOCOL *FormCallBack=NULL;
+ EFI_IFR_FORM_SET *FormSet = NULL;
+ EFI_IFR_DATA_ARRAY callbackData;
+ EFI_STATUS Status;
+
+ MemSet( &callbackData, sizeof(callbackData), 0 );
+
+ FormSet = HiiGetFormSetFromHandle( HiiHandle );
+
+ if ( FormSet != NULL )
+ {
+ Status = gBS->HandleProtocol ( (EFI_HANDLE)((UINTN) FormSet->CallbackHandle), &gEfiFormCallbackProtocolGuid, &FormCallBack);
+
+ if(!EFI_ERROR(Status))
+ {
+ (VOID*)callbackData.NvRamMap = (VOID*)pGUID;
+ if ( ( FormCallBack != NULL ) && ( FormCallBack->Callback != NULL ) )
+ FormCallBack->Callback( FormCallBack, Key, &callbackData, NULL );
+ }
+ }
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetEqIDValue
+//
+// Description: Function to set EqID value
+//
+// Input: VOID *IfrPtr, UINT16 Value
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_EQ_ID_LIST_OP:
+ ((EFI_IFR_EQ_ID_LIST *)IfrPtr)->ValueList[0] = Value;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ ((EFI_IFR_EQ_ID_VAL *)IfrPtr)->Value = Value;
+ break;
+ default:
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsOneOfControl
+//
+// Description: Function to check for OneOf controls
+//
+// Input: VOID *IfrPtr
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsOneOfControl(VOID *IfrPtr)
+{
+ return (((EFI_IFR_OP_HEADER *)IfrPtr)->OpCode == EFI_IFR_ONE_OF_OP)? TRUE : FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetEqIDQuestionID
+//
+// Description: Function to check EqID question ID
+//
+// Input: VOID *IfrPtr
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 questionID = 0;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_EQ_ID_ID_OP:
+ break;
+ case EFI_IFR_EQ_ID_LIST_OP:
+ questionID = ((EFI_IFR_EQ_ID_LIST *)opHeader)->QuestionId;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ questionID = ((EFI_IFR_EQ_ID_VAL *)opHeader)->QuestionId;
+ break;
+ default:
+ break;
+ }
+
+ return questionID;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetEqIDQuestionID
+//
+// Description: Function to set EqID question ID
+//
+// Input: VOID *IfrPtr, UINT16 Value
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_EQ_ID_ID_OP:
+ break;
+ case EFI_IFR_EQ_ID_LIST_OP:
+ ((EFI_IFR_EQ_ID_LIST *)opHeader)->QuestionId = Value;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ ((EFI_IFR_EQ_ID_VAL *)opHeader)->QuestionId = Value;
+ break;
+ default:
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateOneOfWithOptionsTemplate
+//
+// Description: Function to create OneOf option template
+//
+// Input: UINTN OptionCount, CONTROL_INFO *CtrlInfo
+//
+// Output: VOID*
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo)
+{
+ VOID *buffer = NULL;
+ UINTN length = 0;
+ UINTN offset = (UINTN)CtrlInfo->ControlPtr - (UINTN)CtrlInfo->ControlConditionalPtr;
+ UINT32 size = (UINT32)((UINT32)offset + sizeof(EFI_IFR_ONE_OF) + sizeof(EFI_IFR_END_ONE_OF) + OptionCount * sizeof(EFI_IFR_ONE_OF_OPTION));
+
+ buffer = EfiLibAllocateZeroPool(size);
+ if(buffer == NULL)
+ {
+ goto DONE;
+ }
+ MemCopy(buffer, CtrlInfo->ControlConditionalPtr, offset);
+
+ length = UefiGetIfrLength(CtrlInfo->ControlPtr);
+ CtrlInfo->ControlConditionalPtr = buffer;
+ MemCopy( (UINT8 *)buffer + offset, CtrlInfo->ControlPtr, length );
+ CtrlInfo->ControlPtr = (UINT8 *)buffer + offset;
+DONE:
+ return (buffer == NULL)?NULL:((UINT8*)buffer + offset);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetOneOfOption
+//
+// Description: Function to set OneOf option
+//
+// Input: VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option)
+{
+ EFI_IFR_ONE_OF_OPTION *option = (EFI_IFR_ONE_OF_OPTION *)IfrPtr;
+ UINT8 flag = 0;
+
+ flag |= ((Flag & AMI_FLAG_DEFAULT) == AMI_FLAG_DEFAULT)? EFI_IFR_FLAG_DEFAULT : 0;
+ flag |= ((Flag & AMI_FLAG_MANUFACTURING) == AMI_FLAG_MANUFACTURING)? EFI_IFR_FLAG_MANUFACTURING : 0;
+
+ option->Value = (UINT16)Value;
+ option->Option = Option;
+ option->Flags = flag;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiUpdateControlVarOffset
+//
+// Description: Function to update control variable offset
+//
+// Input: VOID *IfrPtr, UINT16 Value
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF *)opHeader)->QuestionId = Value;
+ break;
+ default:
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiAddEndOp
+//
+// Description: Function to add end op code
+//
+// Input: VOID *IfrPtr
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiAddEndOp(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ opHeader->OpCode = EFI_IFR_END_OP;
+ opHeader->Length = sizeof(EFI_IFR_OP_HEADER);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetQuestionID
+//
+// Description: Function to get question ID
+//
+// Input: CONTROL_INFO *control
+//
+// Output: UINT16
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetQuestionID(CONTROL_INFO *control)
+{
+ return UefiGetQuestionOffset(control->ControlPtr);
+}
+#pragma warning( disable : 4204 )
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateDynamicControlCondition
+//
+// Description: Function to create dynamic control condition
+//
+// Input: CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value)
+{
+ struct SuppressCondition
+ {
+ EFI_IFR_SUPPRESS Suppress;
+ EFI_IFR_VARSTORE_SELECT VarStroreSelect;
+ EFI_IFR_EQ_ID_VAL IDEqVal;
+ EFI_IFR_END_IF Endif;
+ }Condition= { {EFI_IFR_SUPPRESS_IF_OP,sizeof(EFI_IFR_SUPPRESS),0},
+ {EFI_IFR_VARSTORE_SELECT_OP,sizeof(EFI_IFR_VARSTORE_SELECT),0},
+ {EFI_IFR_EQ_ID_VAL_OP,sizeof(EFI_IFR_EQ_ID_VAL),0,sizeof(UINT16),Value },
+ {EFI_IFR_END_IF_OP,sizeof(EFI_IFR_END_IF)}};
+
+ Condition.VarStroreSelect.VarId = VarId;
+ Condition.IDEqVal.QuestionId = PrevControlQuestionID;
+// Add the New code to update the ControlConditionalPtr
+ MemCopy((void*)control->ControlConditionalPtr,(void*)&Condition,sizeof(Condition));
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateStringTemplate
+//
+// Description: Function to create uefi string template
+//
+// Parameter: UINT16 Token
+//
+// Return value: VOID *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID * UefiCreateStringTemplate(UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_STRING));
+
+ OpHeader->OpCode = EFI_IFR_STRING_OP ;
+ OpHeader->Length = sizeof(EFI_IFR_STRING) ;
+ UefiSetPromptField((VOID *)OpHeader,Token);
+ return (VOID*)OpHeader;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ProcessActionQuestionConfiguration
+//
+// Description: Function to process Action Control Configuration String.
+// UEFI Action control is a 2.1 control
+//
+// Input: CONTROL_INFO *control
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control)
+{
+ return EFI_SUCCESS;
+}
+
+//EIP 23354 : Start
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsPasswordEncodeEnabled
+//
+// Description: Function to Password Encoding Status.
+//
+// Input: VOID *PwDataPtr
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+BOOLEAN IsPasswordEncodeEnabled ( CONTROL_INFO * controlInfo )
+{
+ EFI_IFR_PASSWORD *PwData = ((EFI_IFR_PASSWORD *)controlInfo->ControlPtr);
+ return (PwData->Encoding == TRUE)? TRUE:FALSE;
+}
+//EIP 23354 : End
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTime
+//
+// Description: Function to get time
+//
+// Parameter: CONTROL_INFO *control, EFI_TIME *Tm
+//
+// Return value: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm)
+{
+ return gRT->GetTime( Tm, NULL );
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetTime
+//
+// Description: Function to set time
+//
+// Parameter: CONTROL_INFO *control, EFI_TIME *Tm
+//
+// Return value: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm)
+{
+ return gRT->SetTime( Tm );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiIsProceedWithPageChange
+//
+// Description: For UEFI 2.0 Just return EFI_SUCCESS;
+//
+// Parameter: EFI_STATUS
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status)
+{
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiPreControlUpdate
+//
+// Description: In UEFI 2.0 this is Dummy function.
+//
+// Parameter: CONTROL_INFO * ControlData
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiPreControlUpdate(CONTROL_INFO *ControlData)
+{
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiRefershQuestionValueNvRAM
+//
+// Description: Function Refresh the question
+//
+// Parameter: CONTROL_INFO *control
+//
+// Return value: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData)
+{
+ return EFI_SUCCESS;
+}
+
+//EIP:56413 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiupdateResetButtonDefault
+//
+// Description: In UEFI 2.0 this is Dummy function.
+//
+// Input: CONTROL_INFO ControlData, UINT16 DefaultId
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId)
+{
+ return EFI_SUCCESS;
+}
+
+//EIP:56413: START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetResetButtonDefaultid
+//
+// Description: In UEFI 2.0 this is Dummy function.
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr)
+{
+return 0xffff;
+}
+//EIP:56413 END
+
+//EIP: 55762 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UpdateDestiantionQuestion
+//
+// Description: Dummy function for 2.0
+//
+// Input: UINT32 CurrPageID - Current page ID
+// UINT32 DestQuestionId - Destination question ID to set focus
+// UINT32 *FocusControlIndex -
+//
+// Output: EFI_STATUS status - EFI_SUCCESS is successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UpdateDestiantionQuestion (UINT32 CurrPageID, UINT32 DestQuestionId, UINT32 *FocusControlIndex)
+{
+ return EFI_UNSUPPORTED;
+}
+//EIP: 55762 End
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FindDriverHealthDriverName
+//
+// Description: Finds the driver name which supports driver health protocol
+//
+// Input: UINT16 = Entry for which driver name has to be return
+//
+// Output: CHAR16 * = Driver Name
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *FindDriverHealthDriverName (UINT16 DriverEntry)
+{
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------------------
+// Procedure: CtrlsSupportsHealthProtocol
+//
+// Description: Finds the number of controllers supports driver health protocol for the driver entry
+//
+// Input: UINT16 = Entry for driver to which total controllers has to be find
+//
+// Output: UINT16 = Total number of controllers supports driver health
+//
+//-----------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 CtrlsSupportsHealthProtocol (UINT16 EntryItem)
+{
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------
+// Procedure: GetCtrlNameAndHealth
+//
+// Description: Finds the controller name with its health
+//
+// Input: UINT16 = Entry for controller to which name has to be find
+//
+// Output: CHAR16 * = Controller name with its health status
+//
+//-----------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetCtrlNameAndHealth (UINT16 ControllerEntry)
+{
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: SetDrvHealthHandleAndCtrlCount
+//
+// Description: Finds and sets the number of controllers supports the driver health handle
+//
+// Input: UINT16 = Driver health handle entry
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetDrvHealthHandleAndCtrlCount (UINT16 ItemEntry)
+{
+}
+
+//EIP57661 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetDriverHealthCount
+//
+// Description: Sets the DriverHealthCount and DriverHlthEnable variables
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetDriverHealthCount (VOID)
+{
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: DoDriverHealthOperation
+//
+// Description: Performs the driver health operations for the corresponding controller entry
+//
+// Input: VOID * = Control Info for the correponding controller entry
+// UINT16 = Controller entry in the page
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoDriverHealthOperation (VOID *Tempcontrol, UINT16 ControllerEntry)
+{
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UefiGetValidOptionSize
+//
+// Description: Function to get sizeof option.UEFI2.0 doesn't have EFI_IFR_TYPE support
+//
+// Input: CONTROL_INFO *CtrlInfo - Pointer to the control info data
+// UINTN *Type - Returns EFI_IFR_TYPE_NUM_SIZE
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData)
+{
+ *SizeOfData = sizeof(UINT8);//UEFI2.0 Supports UINT8 size of data for OrderList Control
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CheckTimeFlags
+//
+// Description: Function to check the time flags.
+//
+// Input: UINT8 Flags
+//
+// Output: BOOLEAN
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckTimeFlags(UINT8 Flags)
+{
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CheckDateFlags
+//
+// Description: Function to check the Date flags.
+//
+// Input: UINT8 Flags
+//
+// Output: BOOLEAN
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckDateFlags(UINT8 Flags)
+{
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: ProcessPackNotification
+//
+// Description: Processes the IFR notification queue
+//
+// Input: None
+//
+// Output: EFI_STATUS status - EFI_ABORTED, By default
+// EFI_SUCCESS, if successful
+// EFI_ERROR, otherwise
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ProcessPackNotification (VOID)
+{
+ return EFI_ABORTED;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RegFormNotification
+//
+// Description: Registers the hii pack notification
+//
+// Parameter: VOID
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RegFormNotification (VOID)
+{
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UnRegFormNotification
+//
+// Description: Unregisters the form notification
+//
+// Parameter: VOID
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UnRegFormNotification (VOID)
+{
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EvaluateControlDefault
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *CtrlInfo
+//
+// Return value: UINT64
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 EvaluateControlDefault (CONTROL_INFO *CtrlInfo, UINT64 *Defaults)
+{
+ return 0;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
diff --git a/EDK/MiniSetup/uefi2.1/CtrlCond.c b/EDK/MiniSetup/uefi2.1/CtrlCond.c
new file mode 100644
index 0000000..d783ffe
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/CtrlCond.c
@@ -0,0 +1,806 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/CtrlCond.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 21 $
+//
+// $Date: 8/28/14 6:16a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/CtrlCond.c $
+//
+// 21 8/28/14 6:16a Premkumara
+// EIP-135253 Updating file name proper in #include
+//
+// 20 2/11/14 8:49p Arunsb
+// Changes reverted for 2.16.1243 label
+//
+// 18 6/10/13 1:19p Arunsb
+// Parameters passed properly in GetDefaultValue
+//
+// 17 6/10/13 10:53a Arunsb
+// Argument added in GetDefaultValue for EFI_IFR_TYPE_OTHER support in
+// default retrieval.
+//
+// 16 5/22/13 10:52a Arunsb
+// Fixed the issue in read write opcode
+//
+// 15 4/02/13 8:04a Arunsb
+// [TAG] EIP113919, EIP114842
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_WRITE, EFI_IFR_READ,
+// EFI_IFR_GET, EFI_IFR_SET and EFI_IFR_MAP_OP.
+// [Files] Setupdata.h, ctrlcond.c, expression.c, hii.c and parse.c
+//
+// 14 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 13 2/02/12 2:59a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 12 2/01/12 4:57a Rajashakerg
+// [TAG] EIP77256
+// [Category] Improvement
+// [Description] Provide the Support to override the control Condition
+// checking() generically. And provide customization to supress the
+// controls with Security GUIDed opcode.
+// [Files] AMITSE.sdl, CommonHelper.c, CtrlCond.c and CtrlCond.h
+//
+// 11 11/28/11 2:30a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 10 11/14/11 6:55p Blaines
+// [TAG] - EIP 75486
+// [Category]- Function Request
+// [Synopsis]- Support grayout condition for readonly controls.
+// [Description] - Display readonly controls as grayout, non-selectable.
+// [Files]
+// AMITSE.sdl, CommonHelper.c, Minisetupext.h, stylecommon.c, Legacy.c,
+// date.c, edit.c, label.c, memo.c, menu.c,, numeric.c, ordlistbox.c,
+// PopupPassword.c,
+// PopupSel.c, PopupString.c, ResetButton.c, SubMenu.c, Text.c, Time.c,
+// UefiAction.c, ctrlcond.c,
+//
+// 9 3/28/11 11:03p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 8 2/03/11 8:19p Madhans
+// [TAG] - EIP 50956
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- If we leave the Setup page for 2 or more days. The system
+// may hang/Crash.
+// [Rootcause] - Memory leaks
+// [Solution]- Memeory freed.
+// [Files] - ctrlcond.c, memo.c and expression.c
+//
+// 7 12/02/10 5:34p Madhans
+// [TAG] - EIP 49559
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- OneOption contols works ok if it stores the values in BYTE
+// and Does not contain any suppressif for options.
+// But it has issues in supporting UINT16, UINT32 and UINT64 storage.
+// [Rootcause] - The Type is not checked for Storeage and issues with
+// condition check for options.
+// [Solution]- Fix done ctrlcond.c and uefi21wrapper.c
+// [Files] - CtrlCond.h, ctrlcond.c and uefi21wrapper.c
+//
+// 6 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 8 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 7 6/14/10 7:11p Madhans
+// to fix parsing issues.
+//
+// 6 3/11/10 5:41p Madhans
+// Coding Standards Update
+//
+// 5 2/19/10 8:38p Madhans
+//
+// 4 2/19/10 8:35p Madhans
+// Function header fix
+//
+// 3 11/19/09 5:28p Presannar
+// Updated TSE include file name to not clash with CORE file
+//
+// 2 8/11/09 2:27p Presannar
+// Added fn EvaluateControlDefault to evaluate the default expression.
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 2 3/31/09 4:15p Madhans
+// UEFI Wrapper improvments.
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 24 6/03/08 10:25a Madhans
+// Boot Only driver and Add/remove TSE CSM support added.
+//
+// 23 5/15/08 11:30a Madhans
+// Rolled back the Control Condition changes regarding the VarGetValue.
+// Will be taken care differently.
+//
+// 21 8/15/07 2:48p Arunkumars
+// Added support for vfr compiler 1.88
+//
+// 20 5/22/07 9:17a Arunkumars
+// Added support for vareq
+//
+// 19 12/04/06 3:13p Arunkumars
+// Fix for behaviour of control access field in CONTOL_INFO
+//
+// 18 7/06/06 6:38p Arunkumars
+// Warn fixes
+//
+// 17 6/15/06 9:34a Arunkumars
+// Support to show new pages added at runtime
+//
+// 16 2/14/06 1:02p Arunkumars
+// 1. Added Inconsistentif feature
+// 2. We publish two events before and after asking for password (see
+// postmgt.c and minisetup.h)
+//
+// 15 1/23/06 11:16p Stefanor
+// Fixed a problem reported by Intel: if the setup question have more than
+// one boolean condition for grayoutif,setup question is not behaving
+// properly. (If the setup question is under multiple condition of
+// suppressif and grayoutif, setup question is working with TSE 1.17.1050)
+//
+// 14 11/22/05 1:48p Franklynd
+// two conditional one after the other where not processed properly. The
+// last conditional was always returned.
+//
+// 13 7/19/05 3:40p Jerryp
+// Reduced number of parameters.
+// Code spacing cleanup
+//
+// 12 6/23/05 4:40p Franklynd
+// Initializing local variable.
+//
+// 11 5/27/05 10:12a Jerryp
+// Changed exit comparison of while loop
+//
+// 10 5/25/05 1:41a Jerryp
+// Added support for ideqvallist
+//
+// 9 5/24/05 5:28p Stefanor
+// fixed conditional problem for boot manager page (and, or condition)
+//
+// 8 5/18/05 11:55a Franklynd
+// Using variable number , not ID
+//
+// 7 5/18/05 10:51a Franklynd
+// updating variables on the fly from varstore_select and
+// varstore_select_pair within the conditional expression
+//
+// 6 5/16/05 5:09p Franklynd
+// 1-Support for multivariable (varstore, varstore_select,
+// varstore_select_pair)
+// 2-Support of optimal and failsafe defaults.
+// 3- support of refresh of controls using their flag information.
+// 4- added ORDERED_LIST control/
+//
+// 5 3/18/05 2:52p Jerryp
+// Fixed bug in conditional evaluation expression
+//
+// 4 3/01/05 3:33p Franklynd
+// adding parse of multiple conditions for control.
+//
+// 3 3/01/05 12:01p Franklynd
+// chack password control only if a regular user is loggd in.
+// If an admin user is logged in, then don't check password control flags
+//
+// 2 2/24/05 5:14p Franklynd
+// 1- adding number of control after a label in control_info structure.
+// 2- adding check of access flags in control (password)
+// 3- color schema code moved to styles area.
+//
+// 1 2/16/05 7:09p Franklynd
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CtrlCond.C
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+#include "minisetup.h"
+#include "CtrlCond.h"
+#include "TseUefiHii.h"
+//---------------------------------------------------------------------------
+
+extern VOID EvaluateReadWrite(UINT8 *buf,CONTROL_INFO *ControlInfo,EFI_HII_VALUE *);
+
+UINTN _SkipExpression(UINT8 *ControlCondPtr);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckControlAccess
+//
+// Description: check control flags
+//
+// Parameter: UINT32 ControlAccess
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckControlAccess(UINT32 ControlAccess)
+{
+ UINT8 Cond = COND_NONE;
+
+ if(gPasswordType == AMI_PASSWORD_USER)
+ {
+ switch(ControlAccess)
+ {
+ case CONTROL_ACCESS_ADMIN: // suppress
+ Cond = COND_SUPPRESS;
+ break;
+ case CONTROL_ACCESS_USER: // grayout (read-only)
+ Cond = COND_GRAYOUT;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return Cond;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateFinalCondition
+//
+// Description:
+//
+// Parameter: UINT8 FinalCond, UINT8 Cond
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UpdateFinalCondition(UINT8 FinalCond, UINT8 Cond)
+{
+ switch(FinalCond)
+ {
+ case COND_NONE:
+ return(Cond);
+ break;
+
+ case COND_NOSUBMIT:
+ return(Cond);
+ break;
+ case COND_SUPPRESS:
+ case COND_HIDDEN:
+ return(FinalCond);
+ break;
+
+ case COND_GRAYOUT:
+ if(Cond != COND_NONE)
+ return(Cond);
+ break;
+
+ case COND_INCONSISTENT:
+ return(Cond);
+ break;
+
+ }
+ return(FinalCond);
+}
+extern EFI_STATUS _SetValueFromQuestionId(UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE *Value);
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckControlCondition
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *controlInfo
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckControlCondition( CONTROL_INFO *controlInfo )
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *tempControlInfo = NULL;
+ UINT32 CtrlAccess;
+ UINT8 *CondPtr;
+ UINT8 *CtrlPtr;
+ UINT8 Cond = COND_NONE, FinalCond = COND_NONE;
+ UINTN controlInfoLength = 0;
+ UINTN offset = 0;
+ UINTN i = 0;
+ UINTN ScopeCount = 0;
+ EFI_IFR_OP_HEADER *opHeader= (EFI_IFR_OP_HEADER *) NULL;
+ EFI_IFR_DEFAULT *Default = (EFI_IFR_DEFAULT *) NULL;
+
+ UINT8 condStack[50];
+ UINT8 opcodeStack[50];
+
+ INTN stackIndex = 0;
+ INTN inScope = 0;
+ EFI_HII_VALUE Value;
+ EFI_HII_VALUE Value1;
+
+ BOOLEAN Inside = TRUE;
+
+ CondPtr = (UINT8 *)controlInfo->ControlConditionalPtr;
+ CtrlAccess = controlInfo->ControlFlags.ControlAccess;
+
+ CtrlPtr = (UINT8 *)controlInfo->ControlPtr;
+ EfiZeroMem (&Value1, sizeof (EFI_HII_VALUE));
+// EfiZeroMem (&Value, sizeof (EFI_HII_VALUE));
+ if(controlInfo->ControlFlags.ControlRWEvaluate)
+ {
+ do
+ {
+ opHeader = (EFI_IFR_OP_HEADER*)(CtrlPtr + i);
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_READ_OP:
+ EvaluateReadWrite((CtrlPtr + i + opHeader->Length),controlInfo,&Value1);
+ if(Value1.Type != EFI_IFR_TYPE_UNDEFINED){
+ _SetValueFromQuestionId(controlInfo->ControlKey,controlInfo->ControlPageID,&Value1);
+ }
+ break;
+ case EFI_IFR_WRITE_OP:
+ EvaluateReadWrite((CtrlPtr + i + opHeader->Length),controlInfo,&Value1);
+ break;
+ case EFI_IFR_DEFAULT_OP:
+ Default =(EFI_IFR_DEFAULT*)opHeader;
+ if(((EFI_IFR_OP_HEADER*)(CtrlPtr + i + opHeader->Length))->OpCode == EFI_IFR_VALUE_OP){
+ i += opHeader->Length;
+ opHeader = (EFI_IFR_OP_HEADER*)(CtrlPtr + i);
+ EvaluateReadWrite((CtrlPtr + i + opHeader->Length),controlInfo,&Value1);
+ }
+ break;
+ case EFI_IFR_END_OP:
+ if(ScopeCount)
+ {
+ ScopeCount--;
+ }
+ break;
+ }
+ if(opHeader->Scope)
+ {
+ ScopeCount++;
+ }
+ i += opHeader->Length ;
+ }while( ScopeCount);
+ }
+ if ( CondPtr == NULL )
+ {
+ FinalCond = CheckControlAccess(CtrlAccess) ;
+ if(FinalCond != COND_NONE)
+ return FinalCond ;
+ goto DONE ;
+ }
+
+ MemSet(&Value, sizeof(EFI_HII_VALUE),0);
+ MemSet(&condStack, 50, 0);
+ MemSet(&opcodeStack, 50, 0);
+
+ controlInfoLength = sizeof(CONTROL_INFO);
+ tempControlInfo = (CONTROL_INFO*)EfiLibAllocateZeroPool(controlInfoLength);
+ if (NULL == tempControlInfo) //EIP-75384 Static code
+ return FinalCond;
+
+ MemCopy(tempControlInfo, controlInfo, controlInfoLength);
+
+ status = EvaluateExpression(tempControlInfo, &Value, &offset);
+ if(EFI_ERROR(status))
+ {
+ offset = _SkipExpression(tempControlInfo->ControlConditionalPtr);
+ FinalCond = COND_NONE;
+ Value.Value.b = FALSE;
+ }
+ if(Value.Value.b)
+ {
+ if((((EFI_IFR_OP_HEADER*)CondPtr)->OpCode == EFI_IFR_SUPPRESS_IF_OP) ||
+ (((EFI_IFR_OP_HEADER*)CondPtr)->OpCode == EFI_IFR_DISABLE_IF_OP))
+ {
+ FinalCond = COND_SUPPRESS;
+ Inside = FALSE;
+ }
+ if(((EFI_IFR_OP_HEADER*)CondPtr)->OpCode == EFI_IFR_INCONSISTENT_IF_OP)
+ {
+ FinalCond = COND_INCONSISTENT;
+ Inside = FALSE;
+ }
+ if(((EFI_IFR_OP_HEADER*)CondPtr)->OpCode == EFI_IFR_NO_SUBMIT_IF_OP)
+ {
+ FinalCond = COND_NOSUBMIT;
+ Inside = FALSE;
+ }
+ }
+
+ while( Inside )
+ {
+ switch(*(CondPtr))
+ {
+ case EFI_IFR_DISABLE_IF_OP:
+ case EFI_IFR_SUPPRESS_IF_OP:
+ Cond = COND_SUPPRESS;
+ break;
+
+ case EFI_IFR_GRAY_OUT_IF_OP:
+ Cond = COND_GRAYOUT;
+ break;
+
+ case EFI_IFR_INCONSISTENT_IF_OP:
+ Cond = COND_INCONSISTENT;
+ Inside = FALSE;
+ break;
+ case EFI_IFR_NO_SUBMIT_IF_OP:
+ Cond = COND_NOSUBMIT;
+ Inside = FALSE;
+ break;
+ case EFI_IFR_END_OP:
+ if(stackIndex)
+ {
+ condStack[--stackIndex] = 0;
+ opcodeStack[stackIndex] = 0;
+ }
+ offset = ((EFI_IFR_OP_HEADER*)CondPtr)->Length;
+ break;
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
+ offset += ((EFI_IFR_OP_HEADER*)CondPtr)->Length;
+ break;
+ default:
+ if(CondPtr == (UINT8*)controlInfo->ControlPtr)
+ {
+ Inside = FALSE;
+ }else if(((EFI_IFR_OP_HEADER*)CondPtr)->OpCode != EFI_IFR_END_OP)
+ {
+ //Skip this Control
+ inScope = 0;
+ do
+ {
+ if(((EFI_IFR_OP_HEADER*)((UINT8*)CondPtr + offset))->Scope)
+ inScope++;
+ offset += ((EFI_IFR_OP_HEADER*)((UINT8*)CondPtr + offset))->Length;
+ if(((EFI_IFR_OP_HEADER*)((UINT8*)CondPtr + offset))->OpCode == EFI_IFR_END_OP)
+ inScope--;
+ }while(inScope > 0);
+ }
+ break;
+ }
+ if(((EFI_IFR_OP_HEADER*)CondPtr)->Scope)
+ {
+ if(Value.Value.b)
+ {
+ condStack[stackIndex] = Cond;
+ }else
+ {
+ condStack[stackIndex] = COND_NONE;
+ }
+ opcodeStack[stackIndex++] = ((EFI_IFR_OP_HEADER*)CondPtr)->OpCode;
+ }
+
+ tempControlInfo->ControlConditionalPtr = (VOID *)((UINT8 *)tempControlInfo->ControlConditionalPtr + offset);
+ CondPtr = (UINT8*)tempControlInfo->ControlConditionalPtr;
+ offset = 0;
+ Value.Value.b = 0;
+ status = EvaluateExpression(tempControlInfo, &Value, &offset);
+ if(EFI_ERROR(status))
+ {
+ offset = _SkipExpression(tempControlInfo->ControlConditionalPtr);
+ FinalCond = COND_NONE;
+ Value.Value.b = FALSE;
+ }
+ }
+
+ while(stackIndex--)
+ {
+ Cond = condStack[stackIndex];
+ FinalCond = UpdateFinalCondition(FinalCond,Cond);
+ }
+
+ // if CtrlAccess is CONTROL_ACCESS_DEFAULT then do not override VFR conditions
+ if(CONTROL_ACCESS_DEFAULT != CtrlAccess)
+ {
+ FinalCond = CheckControlAccess(CtrlAccess);
+ }
+
+ if(tempControlInfo)
+ {
+ MemFreePointer(&tempControlInfo);
+ }
+
+DONE:
+
+ if( (FinalCond == COND_NONE) &&
+ (controlInfo->ControlFlags.ControlReadOnly == 1) &&
+ IsReadOnlyGrayout() )
+ {
+ FinalCond = COND_GRAYOUT ;
+ }
+
+ FinalCond = OEMCheckControlCondition(FinalCond,controlInfo);//EIP 77256 : provide the Support to override the control Condition checking() generically. And provide customization to supress the controls with Security GUIDed opcode.
+ return FinalCond;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckInconsistence
+//
+// Description: checks Inconsistence
+//
+// Parameter: PAGE_INFO
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo )
+{
+ CONTROL_INFO *pControlInfo;
+ UINTN i;
+
+ //Find out if there is inconsistent value in any of the controls
+ for(i=0; i < pPageInfo->PageControls.ControlCount; i++)
+ {
+ pControlInfo = (CONTROL_INFO*)((UINT8 *)(gControlInfo) + pPageInfo->PageControls.ControlList[i]);
+ //Check if there is a CONTROL_TYPE_MSGBOX in this page
+ if(pControlInfo->ControlType == CONTROL_TYPE_MSGBOX)
+ {
+ if(CheckControlCondition(pControlInfo) == COND_INCONSISTENT)
+ return DrawMessageBox(pControlInfo, STRING_TOKEN(STR_INCONSISTENT_MSG_TITLE), ((EFI_IFR_INCONSISTENT_IF*)pControlInfo->ControlConditionalPtr)->Error);
+ }
+ }
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckNoSubmitIf
+//
+// Description: checks NoSubmitIf
+//
+// Parameter: VOID
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckNoSubmitIf( VOID)
+{
+ UINT32 index = 0;
+
+ // Get the Forms
+ for ( index = 0; index < gPages->PageCount; index++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO*)((UINT8 *)gPages + gPages->PageList[index]);
+ UINTN control = 0;
+
+ if(pageInfo->PageHandle == NULL)
+ {
+ continue;
+ }
+ // Get the Controls in each Page
+ for(control = 0; control < pageInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *pControlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(pControlInfo->ControlType == NO_SUBMIT_IF)
+ {
+ if(CheckControlCondition(pControlInfo) == COND_NOSUBMIT)
+ return DrawMessageBox(pControlInfo, STRING_TOKEN(STR_NOSUBMITIF_MSG_TITLE), ((EFI_IFR_NO_SUBMIT_IF*)pControlInfo->ControlConditionalPtr)->Error);
+ }
+ }
+ }
+ return FALSE;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DrawMessageBox
+//
+// Description: Draw MessageBox
+//
+// Parameter: CONTROL_INFO, UINT16, EFI_STRING_ID
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN DrawMessageBox(CONTROL_INFO *pControlInfo, UINT16 Title, EFI_STRING_ID Error)
+{
+ EFI_STATUS Status;
+ MSGBOX_DATA *msgbox = NULL;
+ CONTROL_INFO dummy;
+ AMI_IFR_MSGBOX MsgData;
+ ACTION_DATA *action = gApp->Action;
+
+ Status = gMsgBox.Create( &msgbox );
+ if ( EFI_ERROR( Status ) )
+ return TRUE; // Not able to draw msg box but thats ok dont allow a page switch
+
+ MemSet( &dummy, sizeof(dummy), 0 );
+ dummy.ControlHandle = INVALID_HANDLE;
+
+ MsgData.Opcode = 0;
+ MsgData.Length = 0;
+ MsgData.Title = Title;
+ MsgData.TextHandle = pControlInfo->ControlHandle;
+ MsgData.Text = Error;
+ dummy.ControlPtr = (VOID *) (&MsgData);
+ dummy.ControlFlags.ControlVisible = TRUE;
+
+ Status = gMsgBox.Initialize( msgbox, &dummy );
+ if ( EFI_ERROR( Status ) )
+ {
+ // Not able to draw msg box but thats ok dont allow a page switch
+ gMsgBox.Destroy( msgbox, TRUE );;
+ return TRUE;
+ }
+
+ gMsgBox.SetType( msgbox, MSGBOX_TYPE_OK | MSGBOX_STYLE_LEFT );
+
+ do
+ {
+ if ( action->Input.Type != ACTION_TYPE_NULL )
+ gAction.ClearAction( action );
+
+ gMsgBox.Draw( msgbox );
+
+ if ( gAction.GetAction( action ) != EFI_SUCCESS )
+ continue;
+
+ if(gMsgBox.HandleAction( msgbox, action ) == EFI_SUCCESS)
+ break;
+ }while(1);
+
+ gMsgBox.Destroy( msgbox, TRUE );
+ return TRUE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckOneOfOptionSuppressIf
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ParentCtrlInfo, UINT8* CtrlCondPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 CheckOneOfOptionSuppressIf(CONTROL_INFO *ParentCtrlInfo, UINT8* CtrlCondPtr, UINT8* CtrlPtr)
+{
+ CONTROL_INFO *newCtrlInfo = NULL;
+ UINT8 condition = COND_NONE;
+
+ newCtrlInfo = (CONTROL_INFO*)EfiLibAllocateZeroPool(sizeof(CONTROL_INFO));
+ if(newCtrlInfo == NULL)
+ {
+ goto DONE;
+ }
+
+ newCtrlInfo->ControlHandle = ParentCtrlInfo->ControlHandle;
+ newCtrlInfo->ControlPageID = ParentCtrlInfo->ControlPageID;
+ newCtrlInfo->ControlKey = ParentCtrlInfo->ControlKey;
+ newCtrlInfo->ControlConditionalPtr = (VOID *)CtrlCondPtr;
+ newCtrlInfo->ControlPtr = (VOID *)CtrlPtr;
+ condition = CheckControlCondition(newCtrlInfo);
+ MemFreePointer(&newCtrlInfo);
+
+DONE:
+
+ return condition;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: EvaluateControlDefault
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *CtrlInfo
+//
+// Return value: UINT64
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 EvaluateControlDefault(CONTROL_INFO *CtrlInfo, UINT64 *Defaults)
+{
+ CONTROL_INFO *newCtrlInfo = NULL;
+ EFI_IFR_OP_HEADER *header = (EFI_IFR_OP_HEADER*)CtrlInfo->ControlPtr;
+ EFI_HII_VALUE value;
+ UINT16 size = 0;
+ UINT32 scope = 0;
+ UINTN i = 0;
+ UINTN offset = 0;
+
+ newCtrlInfo = (CONTROL_INFO*)EfiLibAllocateZeroPool(sizeof(CONTROL_INFO));
+ if(newCtrlInfo == NULL)
+ {
+ goto DONE;
+ }
+
+ newCtrlInfo->ControlHandle = CtrlInfo->ControlHandle;
+ newCtrlInfo->ControlPageID = CtrlInfo->ControlPageID;
+ newCtrlInfo->ControlKey = CtrlInfo->ControlKey;
+
+ while(header->OpCode != EFI_IFR_DEFAULT_OP)
+ {
+ i += header->Length;
+ header = (EFI_IFR_OP_HEADER*)((UINT8*)header + i);
+ }
+
+ newCtrlInfo->ControlConditionalPtr = (VOID *)((UINT8 *)header + header->Length);
+ // Set End of Default Scope as ControlPtr
+ do
+ {
+ switch(header->OpCode)
+ {
+ case EFI_IFR_END_OP:
+ scope = scope? --scope : 0;
+ break;
+ default:
+ break;
+ }
+ scope = header->Scope? ++scope : scope;
+ header = (EFI_IFR_OP_HEADER*)((UINT8*)header + header->Length);
+ }while(scope > 0);
+
+ newCtrlInfo->ControlPtr = (VOID *)header;
+ EvaluateExpression(newCtrlInfo, &value, &offset);
+ MemFreePointer(&newCtrlInfo);
+
+ size = (UINT16)GetControlDataLength(CtrlInfo);
+ GetDefaultValue(value.Type, &(value.Value), &size, Defaults, (UINT8*)header);//EIP-Support Default in Orderlist
+
+DONE:
+ return size;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/CtrlCond.h b/EDK/MiniSetup/uefi2.1/CtrlCond.h
new file mode 100644
index 0000000..32c51ce
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/CtrlCond.h
@@ -0,0 +1,146 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2012, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/CtrlCond.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 8 $
+//
+// $Date: 10/18/12 6:04a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/CtrlCond.h $
+//
+// 8 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 5 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 7 2/01/12 4:59a Rajashakerg
+// [TAG] EIP77256
+// [Category] Improvement
+// [Description] Provide the Support to override the control Condition
+// checking() generically. And provide customization to supress the
+// controls with Security GUIDed opcode.
+// [Files] AMITSE.sdl, CommonHelper.c, CtrlCond.c and CtrlCond.h
+//
+// 6 3/28/11 11:03p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 5 12/02/10 5:34p Madhans
+// [TAG] - EIP 49559
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- OneOption contols works ok if it stores the values in BYTE
+// and Does not contain any suppressif for options.
+// But it has issues in supporting UINT16, UINT32 and UINT64 storage.
+// [Rootcause] - The Type is not checked for Storeage and issues with
+// condition check for options.
+// [Solution]- Fix done ctrlcond.c and uefi21wrapper.c
+// [Files] - CtrlCond.h, ctrlcond.c and uefi21wrapper.c
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 8:50p Madhans
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 6 9/17/08 7:44p Madhans
+// For Boot only Driver file split changes.
+//
+// 5 2/14/06 1:02p Arunkumars
+// 1. Added Inconsistentif feature
+// 2. We publish two events before and after asking for password (see
+// postmgt.c and minisetup.h)
+//
+// 4 7/19/05 3:40p Jerryp
+// Reduced number of parameters.
+// Code spacing cleanup
+//
+// 3 5/16/05 5:09p Franklynd
+// 1-Support for multivariable (varstore, varstore_select,
+// varstore_select_pair)
+// 2-Support of optimal and failsafe defaults.
+// 3- support of refresh of controls using their flag information.
+// 4- added ORDERED_LIST control/
+//
+// 2 2/24/05 5:14p Franklynd
+// 1- adding number of control after a label in control_info structure.
+// 2- adding check of access flags in control (password)
+// 3- color schema code moved to styles area.
+//
+// 1 2/16/05 7:09p Franklynd
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: CtrlCond.h
+//
+// Description: Header File
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+#include "minisetup.h"
+//---------------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------------
+#define COND_NONE 0x0
+#define COND_SUPPRESS 0x1
+#define COND_HIDDEN 0x2
+#define COND_GRAYOUT 0x3
+#define COND_INCONSISTENT 0x4
+#define COND_NOSUBMIT 0x5
+//---------------------------------------------------------------------------
+
+
+// functions
+//UINT8 CheckControlCondition(UINT32 ControlAccess, UINT8 *CtrlPtr, UINT32 CtrlVar, UINT32 CtrlVar2, UINT8 *CondPtr);
+UINT8 CheckControlCondition( CONTROL_INFO *controlInfo );
+BOOLEAN CheckInconsistence( PAGE_INFO *pPageInfo );
+UINT8 CheckOneOfOptionSuppressIf(CONTROL_INFO *ParentCtrlInfo, UINT8* CtrlCondPtr, UINT8* CtrlPtr);
+//Start EIP : NO_SUBMIT_IF
+BOOLEAN CheckNoSubmitIf( VOID );
+BOOLEAN DrawMessageBox(CONTROL_INFO *pControlInfo, UINT16 Title, EFI_STRING_ID Error);
+UINT8 OEMCheckControlCondition(UINT8 FinalCond, CONTROL_INFO *controlInfo);//EIP 77256 : Provide the Support to override the control Condition checking() generically. And provide customization to supress the controls with Security GUIDed opcode.
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/Expression.c b/EDK/MiniSetup/uefi2.1/Expression.c
new file mode 100644
index 0000000..f45de77
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Expression.c
@@ -0,0 +1,2861 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Expression.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 18 $
+//
+// $Date: 6/10/13 12:06p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Expression.c $
+//
+// 18 6/10/13 12:06p Arunsb
+// EIP122907. Support for pushthis condition in inconsistent and
+// nosubmitif
+//
+// 17 4/17/13 12:29p Arunsb
+// [TAG] EIP111063
+// [Category] Improvement
+// [Description] Support for EFI_IFR_QUESTION_REF3_2 and
+// EFI_IFR_QUESTION_REF3_3 opcodes
+// [Files] Expression.c
+//
+// 16 4/02/13 8:05a Arunsb
+// [TAG] EIP113919, EIP114842
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_WRITE, EFI_IFR_READ,
+// EFI_IFR_GET, EFI_IFR_SET and EFI_IFR_MAP_OP.
+// [Files] Setupdata.h, ctrlcond.c, expression.c, hii.c and parse.c
+//
+// 15 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 14 5/29/12 4:44a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 13 12/01/11 1:35a Premkumara
+// [TAG] EIP73236
+// [Category] Improvement
+// [Description] Large amounts of allocated memory are not freed
+// [Files] Expression.c, PopupEdit.c, Popup.c, MessageBox.c, Menu.c,
+// Memo.c,
+//
+// 12 11/28/11 2:08a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 11 6/20/11 10:36a Rajashakerg
+// [TAG] EIP56355
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_VERSION opcode
+// [Files] Expression.c
+//
+// 10 3/18/11 9:41a Rajashakerg
+// [TAG] EIP56355
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_VERSION opcode
+// [Files] Expression.c
+//
+// 9 2/03/11 8:19p Madhans
+// [TAG] - EIP 50956
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- If we leave the Setup page for 2 or more days. The system
+// may hang/Crash.
+// [Rootcause] - Memory leaks
+// [Solution]- Memeory freed.
+// [Files] - ctrlcond.c, memo.c and expression.c
+//
+// 8 12/02/10 2:38p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 8 8/18/10 5:58p Mallikarjunanv
+// EIP-42300: Handled dataWidth to solve the hanging issue with respect to
+// password updates
+//
+// 7 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 6 3/11/10 5:41p Madhans
+// Coding Standards Update
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Expression.C
+//
+// Description: Expression evaluation.
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+#include "Minisetup.h"
+#include "TseUefiHii.h"
+
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//
+// In Aptio UnicodeCollation2 protocol is supported in the same file as
+// UnicodeCollation Protocol depending on EFI_SPECIFICATION_VERSION
+//
+#ifndef TSE_FOR_APTIO_4_50
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation2)
+#else
+#if TSE_USE_EDK_LIBRARY
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation2)
+#else
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation)
+#endif
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#define EXPRESSION_STACK_SIZE_INCREMENT 100
+#define NewString(a, b) HiiAddString(b, a)
+#define GetToken(a,b) HiiGetString(b, a)
+//---------------------------------------------------------------------------
+
+//
+// Global stack used to evaluate boolean expresions
+//
+EFI_HII_VALUE *mOpCodeScopeStack = NULL;
+EFI_HII_VALUE *mOpCodeScopeStackEnd = NULL;
+EFI_HII_VALUE *mOpCodeScopeStackPointer = NULL;
+
+EFI_HII_VALUE *mExpressionEvaluationStack = NULL;
+EFI_HII_VALUE *mExpressionEvaluationStackEnd = NULL;
+EFI_HII_VALUE *mExpressionEvaluationStackPointer = NULL;
+
+CHAR16 *gEmptyString = L"";
+VOID *gInconsistCondPtr = NULL;
+//
+// Unicode collation protocol interface
+//
+EFI_UNICODE_COLLATION2_PROTOCOL *mUnicodeCollation = NULL;
+
+extern EFI_STATUS GetStringFromDevPath(EFI_DEVICE_PATH_PROTOCOL *DevPath, CHAR16 **DevPathStr);
+extern EFI_STATUS GetDevPathFromHandle(EFI_HII_HANDLE HiiHandle, EFI_DEVICE_PATH_PROTOCOL **DevicePath);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GrowStack
+//
+// Description: Grow size of the stack
+//
+// Parameter: Stack - On input: old stack; On output: new stack
+// StackPtr - On input: old stack pointer; On output: new stack pointer
+// StackPtr - On input: old stack end; On output: new stack end
+//
+// Return value: EFI_SUCCESS - Grow stack success.
+// EFI_OUT_OF_RESOURCES - No enough memory for stack space.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+STATIC
+EFI_STATUS
+GrowStack (
+ IN OUT EFI_HII_VALUE **Stack,
+ IN OUT EFI_HII_VALUE **StackPtr,
+ IN OUT EFI_HII_VALUE **StackEnd
+ )
+{
+ UINTN Size;
+ EFI_HII_VALUE *NewStack;
+
+ Size = EXPRESSION_STACK_SIZE_INCREMENT;
+ if (*StackPtr != NULL) {
+ Size = Size + (*StackEnd - *Stack);
+ }
+
+ NewStack = EfiLibAllocatePool (Size * sizeof (EFI_HII_VALUE));
+ if (NewStack == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (*StackPtr != NULL) {
+ //
+ // Copy from Old Stack to the New Stack
+ //
+ EfiCopyMem (
+ NewStack,
+ *Stack,
+ (*StackEnd - *Stack) * sizeof (EFI_HII_VALUE)
+ );
+
+ //
+ // Free The Old Stack
+ //
+ gBS->FreePool (*Stack);
+ }
+
+ //
+ // Make the Stack pointer point to the old data in the new stack
+ //
+ *StackPtr = NewStack + (*StackPtr - *Stack);
+ *Stack = NewStack;
+ *StackEnd = NewStack + Size;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PushStack
+//
+// Description: Push an element onto the Boolean Stack
+//
+// Parameter: Stack - On input: old stack; On output: new stack
+// StackPtr - On input: old stack pointer; On output: new stack pointer
+// StackPtr - On input: old stack end; On output: new stack end
+// Data - Data to push.
+//
+// Return value: EFI_SUCCESS - Push stack success.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PushStack (
+ IN OUT EFI_HII_VALUE **Stack,
+ IN OUT EFI_HII_VALUE **StackPtr,
+ IN OUT EFI_HII_VALUE **StackEnd,
+ IN EFI_HII_VALUE *Data
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Check for a stack overflow condition
+ //
+ if (*StackPtr >= *StackEnd) {
+ //
+ // Grow the stack
+ //
+ Status = GrowStack (Stack, StackPtr, StackEnd);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
+ // Push the item onto the stack
+ //
+ EfiCopyMem (*StackPtr, Data, sizeof (EFI_HII_VALUE));
+ *StackPtr = *StackPtr + 1;
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopStack
+//
+// Description: Pop an element from the stack.
+//
+// Parameter: Stack - On input: old stack; On output: new stack
+// StackPtr - On input: old stack pointer; On output: new stack pointer
+// StackPtr - On input: old stack end; On output: new stack end
+// Data - Data to pop.
+//
+// Return value: EFI_SUCCESS - The value was popped onto the stack.
+// EFI_ACCESS_DENIED - The pop operation underflowed the stack
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PopStack (
+ IN OUT EFI_HII_VALUE **Stack,
+ IN OUT EFI_HII_VALUE **StackPtr,
+ IN OUT EFI_HII_VALUE **StackEnd,
+ OUT EFI_HII_VALUE *Data
+ )
+{
+ //
+ // Check for a stack underflow condition
+ //
+ if (*StackPtr == *Stack) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ //
+ // Pop the item off the stack
+ //
+ *StackPtr = *StackPtr - 1;
+ EfiCopyMem (Data, *StackPtr, sizeof (EFI_HII_VALUE));
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetScopeStack
+//
+// Description: Reset stack pointer to begin of the stack.
+//
+// Parameter: None.
+//
+// Return value: None.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+ResetScopeStack (
+ VOID
+ )
+{
+ mOpCodeScopeStackPointer = mOpCodeScopeStack;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PushScope
+//
+// Description: Push an Operand onto the Stack
+//
+// Parameter: Operand to push.
+//
+// Return value: EFI_SUCCESS - The value was pushed onto the stack.
+// EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PushScope (
+ IN UINT8 Operand
+ )
+{
+ EFI_HII_VALUE Data;
+
+ Data.Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ Data.Value.u8 = Operand;
+
+ return PushStack (
+ &mOpCodeScopeStack,
+ &mOpCodeScopeStackPointer,
+ &mOpCodeScopeStackEnd,
+ &Data
+ );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopScope
+//
+// Description: Pop an Operand from the Stack
+//
+// Parameter: Operand to pop.
+//
+// Return value: EFI_SUCCESS - The value was pushed onto the stack.
+// EFI_OUT_OF_RESOURCES - There is not enough system memory to
+// grow the stack.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PopScope (
+ OUT UINT8 *Operand
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Data;
+
+ Status = PopStack (
+ &mOpCodeScopeStack,
+ &mOpCodeScopeStackPointer,
+ &mOpCodeScopeStackEnd,
+ &Data
+ );
+
+ *Operand = Data.Value.u8;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ResetExpressionStack
+//
+// Description: Reset stack pointer to begin of the stack.
+//
+// Parameter: None.
+//
+// Return value: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+ResetExpressionStack (
+ VOID
+ )
+{
+ mExpressionEvaluationStackPointer = mExpressionEvaluationStack;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PushExpression
+//
+// Description: Push an Expression value onto the Stack
+//
+// Parameter: Value - Expression value to push.
+//
+// Return value: EFI_SUCCESS - The value was pushed onto the stack.
+// EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PushExpression (
+ IN EFI_HII_VALUE *Value
+ )
+{
+ return PushStack (
+ &mExpressionEvaluationStack,
+ &mExpressionEvaluationStackPointer,
+ &mExpressionEvaluationStackEnd,
+ Value
+ );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PopExpression
+//
+// Description: Pop an Expression value from the Stack
+//
+// Parameter: Value - Expression value to pop.
+//
+// Return value: EFI_SUCCESS - The value was popped onto the stack.
+// EFI_OUT_OF_RESOURCES - The pop operation underflowed the stack
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+PopExpression (
+ OUT EFI_HII_VALUE *Value
+ )
+{
+ return PopStack (
+ &mExpressionEvaluationStack,
+ &mExpressionEvaluationStackPointer,
+ &mExpressionEvaluationStackEnd,
+ Value
+ );
+}
+
+/*
+FORM_BROWSER_FORM *
+IdToForm (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN UINT16 FormId
+)
+/*++
+
+Routine Description:
+ Get Form given its FormId.
+
+Arguments:
+ FormSet - The formset which contains this form.
+ FormId - Id of this form.
+
+Returns:
+ Pointer - The form.
+ NULL - Specified Form is not found in the formset.
+
+--* /
+{
+ EFI_LIST_ENTRY *Link;
+ FORM_BROWSER_FORM *Form;
+
+ Link = GetFirstNode (&FormSet->FormListHead);
+ while (!IsNull (&FormSet->FormListHead, Link)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);
+
+ if (Form->FormId == FormId) {
+ return Form;
+ }
+
+ Link = GetNextNode (&FormSet->FormListHead, Link);
+ }
+
+ return NULL;
+}
+
+FORM_BROWSER_STATEMENT *
+IdToQuestion2 (
+ IN FORM_BROWSER_FORM *Form,
+ IN UINT16 QuestionId
+ )
+/*++
+
+Routine Description:
+ Search a Question in Form scope using its QuestionId.
+
+Arguments:
+ Form - The form which contains this Question.
+ QuestionId - Id of this Question.
+
+Returns:
+ Pointer - The Question.
+ NULL - Specified Question not found in the form.
+
+--* /
+{
+ EFI_LIST_ENTRY *Link;
+ FORM_BROWSER_STATEMENT *Question;
+
+ if (QuestionId == 0) {
+ //
+ // The value of zero is reserved
+ //
+ return NULL;
+ }
+
+ Link = GetFirstNode (&Form->StatementListHead);
+ while (!IsNull (&Form->StatementListHead, Link)) {
+ Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
+
+ if (Question->QuestionId == QuestionId) {
+ return Question;
+ }
+
+ Link = GetNextNode (&Form->StatementListHead, Link);
+ }
+
+ return NULL;
+}
+
+FORM_BROWSER_STATEMENT *
+IdToQuestion (
+ IN FORM_BROWSER_FORMSET *FormSet,
+ IN FORM_BROWSER_FORM *Form,
+ IN UINT16 QuestionId
+ )
+/*++
+
+Routine Description:
+ Search a Question in Formset scope using its QuestionId.
+
+Arguments:
+ FormSet - The formset which contains this form.
+ Form - The form which contains this Question.
+ QuestionId - Id of this Question.
+
+Returns:
+ Pointer - The Question.
+ NULL - Specified Question not found in the form.
+
+--* /
+{
+ EFI_LIST_ENTRY *Link;
+ FORM_BROWSER_STATEMENT *Question;
+
+ //
+ // Search in the form scope first
+ //
+ Question = IdToQuestion2 (Form, QuestionId);
+ if (Question != NULL) {
+ return Question;
+ }
+
+ //
+ // Search in the formset scope
+ //
+ Link = GetFirstNode (&FormSet->FormListHead);
+ while (!IsNull (&FormSet->FormListHead, Link)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);
+
+ Question = IdToQuestion2 (Form, QuestionId);
+ if (Question != NULL) {
+ return Question;
+ }
+
+ Link = GetNextNode (&FormSet->FormListHead, Link);
+ }
+
+ return NULL;
+}
+
+FORM_EXPRESSION *
+RuleIdToExpression (
+ IN FORM_BROWSER_FORM *Form,
+ IN UINT8 RuleId
+ )
+/*++
+
+Routine Description:
+ Get Expression given its RuleId.
+
+Arguments:
+ Form - The form which contains this Expression.
+ RuleId - Id of this Expression.
+
+Returns:
+ Pointer - The Expression.
+ NULL - Specified Expression not found in the form.
+
+--* /
+{
+ EFI_LIST_ENTRY *Link;
+ FORM_EXPRESSION *Expression;
+
+ Link = GetFirstNode (&Form->ExpressionListHead);
+ while (!IsNull (&Form->ExpressionListHead, Link)) {
+ Expression = FORM_EXPRESSION_FROM_LINK (Link);
+
+ if (Expression->Type == EFI_HII_EXPRESSION_RULE && Expression->RuleId == RuleId) {
+ return Expression;
+ }
+
+ Link = GetNextNode (&Form->ExpressionListHead, Link);
+ }
+
+ return NULL;
+}
+*/
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitializeUnicodeCollationProtocol
+//
+// Description: Locate the Unicode Collation Protocol interface for later use.
+//
+// Parameter: None
+//
+// Return value: EFI_SUCCESS - Protocol interface initialize success.
+// Other - Protocol interface initialize failed.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS
+InitializeUnicodeCollationProtocol (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ if (mUnicodeCollation != NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // BUGBUG: Proper impelmentation is to locate all Unicode Collation Protocol
+ // instances first and then select one which support English language.
+ // Current implementation just pick the first instance.
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiUnicodeCollation2ProtocolGuid,
+ NULL,
+ &mUnicodeCollation
+ );
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrStrToUpper
+//
+// Description:function to conver the lower case string to upper
+//
+// Parameter:
+//
+// Return value: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+IfrStrToUpper (
+ CHAR16 *String
+ )
+{
+ while (*String != 0) {
+ if ((*String >= 'a') && (*String <= 'z')) {
+ *String = (*String) & ((UINT16) ~0x20);
+ }
+ String++;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrToString
+//
+// Description: Evaluate opcode EFI_IFR_TO_STRING.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Format - String format in EFI_IFR_TO_STRING.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrToString (
+ IN EFI_HII_HANDLE *HiiHandle,
+ IN UINT8 Format,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String;
+ CHAR16 *PrintFormat;
+ CHAR16 Buffer[CHARACTER_NUMBER_FOR_VALUE];
+ UINTN BufferSize;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ switch (Value.Type) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ BufferSize = CHARACTER_NUMBER_FOR_VALUE * sizeof (CHAR16);
+ switch (Format) {
+ case EFI_IFR_STRING_UNSIGNED_DEC:
+ case EFI_IFR_STRING_SIGNED_DEC:
+ PrintFormat = L"%ld";
+ break;
+
+ case EFI_IFR_STRING_LOWERCASE_HEX:
+ PrintFormat = L"%lx";
+ break;
+
+ case EFI_IFR_STRING_UPPERCASE_HEX:
+ PrintFormat = L"%lX";
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ }
+ SPrint (Buffer, BufferSize, PrintFormat, Value.Value.u64);
+ String = Buffer;
+ break;
+
+ case EFI_IFR_TYPE_STRING:
+ EfiCopyMem (Result, &Value, sizeof (EFI_HII_VALUE));
+ return EFI_SUCCESS;
+
+ case EFI_IFR_TYPE_BOOLEAN:
+ String = (Value.Value.b) ? L"True" : L"False";
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ }
+
+ Result->Type = EFI_IFR_TYPE_STRING;
+ Result->Value.string = NewString (String, HiiHandle);
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrToUint
+//
+// Description: Evaluate opcode EFI_IFR_TO_UINT.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrToUint (
+ IN EFI_HII_HANDLE *HiiHandle,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String;
+ CHAR16 *StringPtr;
+ UINTN BufferSize;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Value.Type >= EFI_IFR_TYPE_OTHER) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = EFI_SUCCESS;
+ if (Value.Type == EFI_IFR_TYPE_STRING) {
+ String = GetToken (Value.Value.string, HiiHandle);
+ if (String == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ IfrStrToUpper (String);
+ StringPtr = EfiStrStr (String, L"0X");
+ if (StringPtr != NULL) {
+ //
+ // Hex string
+ //
+ BufferSize = sizeof (UINT64);
+ Status = HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL);
+ } else {
+ //
+ // BUGBUG: Need handle decimal string
+ //
+ }
+ gBS->FreePool (String);
+ } else {
+ EfiCopyMem (Result, &Value, sizeof (EFI_HII_VALUE));
+ }
+
+ Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrCatenate
+//
+// Description: Evaluate opcode EFI_IFR_TO_UINT.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrCatenate (
+ IN EFI_HII_HANDLE *HiiHandle,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String[2];
+ UINTN Index;
+ CHAR16 *StringPtr;
+
+ //
+ // String[0] - The second string
+ // String[1] - The first string
+ //
+ String[0] = NULL;
+ String[1] = NULL;
+ StringPtr = NULL;
+ Status = EFI_SUCCESS;
+
+ for (Index = 0; Index < 2; Index++) {
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ String[Index] = GetToken (Value.Value.string, HiiHandle);
+ if (String== NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ }
+
+ StringPtr= EfiLibAllocatePool (EfiStrSize (String[1]) + EfiStrSize (String[0]));
+ ASSERT (StringPtr != NULL);
+ EfiStrCpy (StringPtr, String[1]);
+ EfiStrCat (StringPtr, String[0]);
+
+ Result->Type = EFI_IFR_TYPE_STRING;
+ Result->Value.string = NewString (StringPtr, HiiHandle);
+
+Done:
+ EfiLibSafeFreePool (String[0]);
+ EfiLibSafeFreePool (String[1]);
+ EfiLibSafeFreePool (StringPtr);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrMatch
+//
+// Description: Evaluate opcode EFI_IFR_MATCH.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrMatch (
+ IN EFI_HII_HANDLE *HiiHandle,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String[2];
+ UINTN Index;
+
+ //
+ // String[0] - The string to search
+ // String[1] - pattern
+ //
+ String[0] = NULL;
+ String[1] = NULL;
+ Status = EFI_SUCCESS;
+ for (Index = 0; Index < 2; Index++) {
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ String[Index] = GetToken (Value.Value.string, HiiHandle);
+ if (String== NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ }
+
+ Result->Type = EFI_IFR_TYPE_BOOLEAN;
+ Result->Value.b = mUnicodeCollation->MetaiMatch (mUnicodeCollation, String[0], String[1]);
+
+Done:
+ EfiLibSafeFreePool (String[0]);
+ EfiLibSafeFreePool (String[1]);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrFind
+//
+// Description: Evaluate opcode EFI_IFR_FIND.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Format - Case sensitive or insensitive.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrFind (
+ IN EFI_HII_HANDLE *HiiHandle,
+ IN UINT8 Format,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String[2];
+ UINTN Base;
+ CHAR16 *StringPtr;
+ UINTN Index;
+
+ if (Format > EFI_IFR_FF_CASE_INSENSITIVE) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
+ return EFI_UNSUPPORTED;
+ }
+ Base = (UINTN) Value.Value.u64;
+
+ //
+ // String[0] - sub-string
+ // String[1] - The string to search
+ //
+ String[0] = NULL;
+ String[1] = NULL;
+ for (Index = 0; Index < 2; Index++) {
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ String[Index] = GetToken (Value.Value.string, HiiHandle);
+ if (String== NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ if (Format == EFI_IFR_FF_CASE_INSENSITIVE) {
+ //
+ // Case insensitive, convert both string to upper case
+ //
+ IfrStrToUpper (String[Index]);
+ }
+ }
+
+ Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ if (Base >= EfiStrLen (String[1])) {
+ Result->Value.u64 = 0xFFFFFFFFFFFFFFFF;
+ } else {
+ StringPtr = EfiStrStr (String[1] + Base, String[0]);
+ Result->Value.u64 = (StringPtr == NULL) ? 0xFFFFFFFFFFFFFFFF : (StringPtr - String[1]);
+ }
+
+Done:
+ EfiLibSafeFreePool (String[0]);
+ EfiLibSafeFreePool (String[1]);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrMid
+//
+// Description: Evaluate opcode EFI_IFR_MID.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrMid (
+ IN EFI_HII_HANDLE *HiiHandle,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String;
+ UINTN Base;
+ UINTN Length;
+ CHAR16 *SubString;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
+ return EFI_UNSUPPORTED;
+ }
+ Length = (UINTN) Value.Value.u64;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
+ return EFI_UNSUPPORTED;
+ }
+ Base = (UINTN) Value.Value.u64;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ return EFI_UNSUPPORTED;
+ }
+ String = GetToken (Value.Value.string, HiiHandle);
+ if (String == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (Length == 0 || Base >= EfiStrLen (String)) {
+ SubString = gEmptyString;
+ } else {
+ SubString = String + Base;
+ if ((Base + Length) < EfiStrLen (String)) {
+ SubString[Length] = L'\0';
+ }
+ }
+
+ Result->Type = EFI_IFR_TYPE_STRING;
+ Result->Value.string = NewString (SubString, HiiHandle);
+
+ gBS->FreePool (String);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrToken
+//
+// Description: Evaluate opcode EFI_IFR_TOKEN.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrToken (
+ IN EFI_HII_HANDLE *HiiHandle,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String[2];
+ UINTN Count;
+ CHAR16 *Delimiter;
+ CHAR16 *SubString;
+ CHAR16 *StringPtr;
+ UINTN Index;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
+ return EFI_UNSUPPORTED;
+ }
+ Count = (UINTN) Value.Value.u64;
+
+ //
+ // String[0] - Delimiter
+ // String[1] - The string to search
+ //
+ String[0] = NULL;
+ String[1] = NULL;
+ for (Index = 0; Index < 2; Index++) {
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ String[Index] = GetToken (Value.Value.string, HiiHandle);
+ if (String== NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ }
+
+ Delimiter = String[0];
+ SubString = String[1];
+ while (Count > 0) {
+ SubString = EfiStrStr (SubString, Delimiter);
+ if (SubString != NULL) {
+ //
+ // Skip over the delimiter
+ //
+ SubString = SubString + EfiStrLen (Delimiter);
+ } else {
+ break;
+ }
+ Count--;
+ }
+
+ if (SubString == NULL) {
+ //
+ // nth delimited sub-string not found, push an empty string
+ //
+ SubString = gEmptyString;
+ } else {
+ //
+ // Put a NULL terminator for nth delimited sub-string
+ //
+ StringPtr = EfiStrStr (SubString, Delimiter);
+ if (StringPtr != NULL) {
+ *StringPtr = L'\0';
+ }
+ }
+
+ Result->Type = EFI_IFR_TYPE_STRING;
+ Result->Value.string = NewString (SubString, HiiHandle);
+
+Done:
+ EfiLibSafeFreePool (String[0]);
+ EfiLibSafeFreePool (String[1]);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfrSpan
+//
+// Description: Evaluate opcode EFI_IFR_SPAN.
+//
+// Parameter: FormSet - Formset which contains this opcode.
+// Flags - FIRST_MATCHING or FIRST_NON_MATCHING.
+// Result - Evaluation result for this opcode.
+//
+// Return value: EFI_SUCCESS - Opcode evaluation success.
+// Other - Opcode evaluation failed.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IfrSpan (
+ IN EFI_HII_HANDLE *HiiHandle,
+ IN UINT8 Flags,
+ OUT EFI_HII_VALUE *Result
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_VALUE Value;
+ CHAR16 *String[2];
+ CHAR16 *Charset;
+ UINTN Base;
+ UINTN Index;
+ CHAR16 *StringPtr;
+ BOOLEAN Found;
+
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
+ return EFI_UNSUPPORTED;
+ }
+ Base = (UINTN) Value.Value.u64;
+
+ //
+ // String[0] - Charset
+ // String[1] - The string to search
+ //
+ String[0] = NULL;
+ String[1] = NULL;
+ for (Index = 0; Index < 2; Index++) {
+ Status = PopExpression (&Value);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ if (Value.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ String[Index] = GetToken (Value.Value.string, HiiHandle);
+ if (String== NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ }
+
+ if (Base >= EfiStrLen (String[1])) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ Found = FALSE;
+ StringPtr = String[1] + Base;
+ Charset = String[0];
+ while (*StringPtr != 0 && !Found) {
+ Index = 0;
+ while (Charset[Index] != 0) {
+ if (*StringPtr >= Charset[Index] && *StringPtr <= Charset[Index + 1]) {
+ if (Flags == EFI_IFR_FLAGS_FIRST_MATCHING) {
+ Found = TRUE;
+ break;
+ }
+ } else {
+ if (Flags == EFI_IFR_FLAGS_FIRST_NON_MATCHING) {
+ Found = TRUE;
+ break;
+ }
+ }
+ //
+ // Skip characters pair representing low-end of a range and high-end of a range
+ //
+ Index += 2;
+ }
+
+ if (!Found) {
+ StringPtr++;
+ }
+ }
+
+ Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Result->Value.u64 = StringPtr - String[1];
+
+Done:
+ EfiLibSafeFreePool (String[0]);
+ EfiLibSafeFreePool (String[1]);
+
+ return Status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: ExtendValueToU64
+//
+// Description: Zero extend integer/boolean/date/time to UINT64 for comparing.
+//
+// Parameter: Value - HII Value to be converted.
+//
+// Return value: None.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID
+ExtendValueToU64 (
+ IN EFI_HII_VALUE *Value
+ )
+{
+ UINT64 Temp;
+
+ Temp = 0;
+ switch (Value->Type) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ Temp = Value->Value.u8;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ Temp = Value->Value.u16;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ Temp = Value->Value.u32;
+ break;
+
+ case EFI_IFR_TYPE_BOOLEAN:
+ Temp = Value->Value.b;
+ break;
+
+ case EFI_IFR_TYPE_TIME:
+ Temp = Value->Value.u32 & 0xffffff;
+ break;
+
+ case EFI_IFR_TYPE_DATE:
+ Temp = Value->Value.u32;
+ break;
+
+ default:
+ return;
+ }
+
+ Value->Value.u64 = Temp;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CompareHiiValue
+//
+// Description: Compare two Hii Value
+//
+// Parameter: Value1 - Expression value to compare on left-hand
+// Value2 - Expression value to compare on right-hand
+// HiiHandle - Only required for string compare
+//
+// Return value: EFI_INVALID_PARAMETER - Could not perform comparation on two values
+// 0 - Two operators equeal
+// < 0 - Value1 is greater than Value2
+// > 0 - Value1 is less than Value2
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+INTN
+CompareHiiValue (
+ IN EFI_HII_VALUE *Value1,
+ IN EFI_HII_VALUE *Value2,
+ IN EFI_HII_HANDLE HiiHandle OPTIONAL
+ )
+{
+ INTN Result;
+ INT64 Temp64;
+ CHAR16 *Str1;
+ CHAR16 *Str2;
+
+ if (Value1->Type >= EFI_IFR_TYPE_OTHER || Value2->Type >= EFI_IFR_TYPE_OTHER ) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Value1->Type == EFI_IFR_TYPE_STRING || Value2->Type == EFI_IFR_TYPE_STRING ) {
+ if (Value1->Type != Value2->Type) {
+ //
+ // Both Operator should be type of String
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Value1->Value.string == 0 || Value2->Value.string == 0) {
+ //
+ // StringId 0 is reserved
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Value1->Value.string == Value2->Value.string) {
+ return 0;
+ }
+
+ Str1 = GetToken (Value1->Value.string, HiiHandle);
+ if (Str1 == NULL) {
+ //
+ // String not found
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Str2 = GetToken (Value2->Value.string, HiiHandle);
+ if (Str2 == NULL) {
+ gBS->FreePool (Str1);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Result = EfiStrCmp (Str1, Str2);
+
+ gBS->FreePool (Str1);
+ gBS->FreePool (Str2);
+
+ return Result;
+ }
+
+ //
+ // Take remain types(integer, boolean, date/time) as integer
+ //
+ Temp64 = (INT64) (Value1->Value.u64 - Value2->Value.u64);
+ if (Temp64 > 0) {
+ Result = 1;
+ } else if (Temp64 < 0) {
+ Result = -1;
+ } else {
+ Result = 0;
+ }
+
+ return Result;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetRuleControlfromId
+//
+// Description:
+//
+// Parameter: UINT8 *IFRData, CONTROL_INFO **RuleControl
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetRuleControlfromId(UINT16 RuleId, UINT16 PageId, CONTROL_INFO **RuleControl)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_INFO *controlInfo = NULL;
+ BOOLEAN found = FALSE;
+ UINTN control = 0;
+
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[PageId]);
+ if(pageInfo->PageHandle ==0)
+ {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ for(control= 0; (control < pageInfo->PageControls.ControlCount) && (found == FALSE); control++)
+ {
+ controlInfo = (CONTROL_INFO*)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+
+ if(RuleId == controlInfo->ControlKey)
+ {
+ found = TRUE;
+ }
+ }
+
+ if(found)
+ {
+ *RuleControl = controlInfo;
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: checkforpushthispresence
+//
+// Description: Checks the condition has EFI_IFR_THIS_OP
+//
+// Parameter: UINT8 *
+//
+// Return value: TRUE if EFI_IFR_THIS_OP presents else FALSE
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN checkforpushthispresence (UINT8 *ControlConditionalPtr)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER*)ControlConditionalPtr;
+ UINTN inScope = 0;
+ UINTN i = 0;
+
+ if (opHeader->Scope)
+ {
+ do
+ {
+ switch (opHeader->OpCode)
+ {
+ case EFI_IFR_THIS_OP:
+ return TRUE;
+ case EFI_IFR_END_OP:
+ inScope--;
+ break;
+ default:
+ if(opHeader->Scope)
+ {
+ inScope++;
+ }
+ }
+ i += opHeader->Length;
+ opHeader = (EFI_IFR_OP_HEADER*)(ControlConditionalPtr + i);
+ }while(inScope);
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------------
+//
+// Procedure: GetValueFromParentControl
+//
+// Description: Gets the value for inconsistent/submitif from its parent control
+//
+// Parameter: UINT16, UINT16, EFI_HII_VALUE **, PAGE_INFO *, VOID *
+//
+// Return value: EFI_SUCCESS if value retrieved successfully else some other EFI Status
+//-----------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetValueFromQuestionId (UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE **Value);
+EFI_STATUS GetValueFromParentControl (UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE **Value, PAGE_INFO *pageInfo, VOID *CtrlCondPtr)
+{
+ UINT32 Count = 1;
+ UINTN control = 0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_IFR_OP_HEADER *OpHeader;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ CHAR16 *questionValue;
+ EFI_STRING_ID StrToken = 0;
+ CONTROL_INFO *controlInfo;
+
+ for (control= 0; control < pageInfo->PageControls.ControlCount; control++)
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]); //If two submit if present then questionid may be same so comparing conditionalptr also
+ if ((QuestionId == controlInfo->ControlKey) && ((CONTROL_TYPE_MSGBOX == controlInfo->ControlType) || (NO_SUBMIT_IF == controlInfo->ControlType)) && (CtrlCondPtr == controlInfo->ControlConditionalPtr))
+ {
+ if (checkforpushthispresence (controlInfo->ControlConditionalPtr))
+ {
+ do //Find the parent control. Inconsistent/submit only present inside question
+ {
+ controlInfo = (CONTROL_INFO*)((UINT8 *)(gControlInfo) + pageInfo->PageControls.ControlList [control-Count]);
+ Count ++;
+ }while ((CONTROL_TYPE_MSGBOX == controlInfo->ControlType) || (NO_SUBMIT_IF == controlInfo->ControlType)); //find parent suppress all the inconsistent/submit present in the control
+ OpHeader=(EFI_IFR_OP_HEADER *)controlInfo->ControlPtr;
+ if (EFI_IFR_STRING_OP != OpHeader->OpCode)
+ {
+ Status = _GetValueFromQuestionId (controlInfo->ControlKey, PageId, Value);
+ }
+ else
+ {
+ UINTN dataWidth = UefiGetWidth (controlInfo->ControlPtr);
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8 *)controlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+ questionValue = EfiLibAllocateZeroPool (dataWidth + sizeof (CHAR16)); //sizeof (CHAR16) is for NULL if maximum characters used.
+ if (NULL == questionValue)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // EIP-42300: Updated the dataWidth in comparison to the maximum supported
+ Status = VarGetValue (controlInfo->ControlVariable, questionHdr->VarStoreInfo.VarOffset, dataWidth, (VOID *)questionValue);
+ if (!EFI_ERROR(Status))
+ {
+ if (*questionValue != 0)
+ {
+ StrToken = HiiAddString (controlInfo->ControlHandle, questionValue);
+ (*Value)->Value.string = StrToken;
+ (*Value)->Type = EFI_IFR_TYPE_STRING;
+ }
+ else
+ {
+ Status = EFI_NOT_STARTED; //If null string then dont compare
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetValueFromQuestionId
+//
+// Description:
+//
+// Parameter: UINT16 QuestionId, UINT16 PageId, UINT64 *Value
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetValueFromQuestionId(UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE **Value)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ BOOLEAN found = FALSE;
+ UINT32 varId = 0;
+ UINTN control = 0;
+ UINT64 questionValue = 0;
+
+ CONTROL_INFO *controlInfo = NULL;
+
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[PageId]);
+
+ if(pageInfo->PageHandle ==0)
+ {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ for ( control= 0; (control < pageInfo->PageControls.ControlCount) && (found == FALSE); control++ )
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == controlInfo->ControlKey)
+ {
+ if ((CONTROL_TYPE_MSGBOX == controlInfo->ControlType) || (NO_SUBMIT_IF == controlInfo->ControlType) || gInconsistCondPtr)
+ {
+ if (gInconsistCondPtr == controlInfo->ControlConditionalPtr) //All inconsistentif will have 0 as question id so adding more check
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ else
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ }
+
+ if(!found)
+ {
+ // Control Definition not in this Page. Look within the formset
+ EFI_HII_HANDLE pgHandle = pageInfo->PageHandle;
+ UINT32 page = 0;
+
+ for(;page < gPages->PageCount && (found == FALSE); page++)
+ {
+/*
+ if(page == PageId)
+ {
+ continue;
+ }
+*/
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+ if(pageInfo->PageHandle != pgHandle)
+ {
+ continue;
+ }
+
+ for(control = 0; control < pageInfo->PageControls.ControlCount && (found == FALSE); control++)
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == controlInfo->ControlKey)
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ }
+ }
+
+ if(found)
+ {
+ if (NULL != controlInfo->ControlPtr) //For inconsistent and nosubmitif controlptr will be NULL
+ {
+ UINTN dataWidth = UefiGetWidth(controlInfo->ControlPtr);
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8 *)controlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+
+ // EIP-42300: Updated the dataWidth in comparision to the maximum supported
+ Status = VarGetValue(varId, questionHdr->VarStoreInfo.VarOffset, (( dataWidth > sizeof(UINT64))? sizeof(UINT64) : dataWidth ), &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ (*Value)->Value.u64 = questionValue;
+ }
+ else if ((CONTROL_TYPE_MSGBOX == controlInfo->ControlType) || (NO_SUBMIT_IF == controlInfo->ControlType)) //Check for inconistent control
+ {
+ Status = GetValueFromParentControl (QuestionId, PageId, Value, pageInfo, controlInfo->ControlConditionalPtr);
+ }
+ }
+DONE:
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _SetValueFromQuestionId
+//
+// Description:
+//
+// Parameter: UINT16 QuestionId, UINT16 PageId, UINT64 *Value
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _SetValueFromQuestionId(UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE *Value)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ BOOLEAN found = FALSE;
+ UINT32 varId = 0;
+ UINTN control = 0;
+ UINT64 questionValue = Value->Value.u64;
+
+ CONTROL_INFO *controlInfo = NULL;
+
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[PageId]);
+
+ if(pageInfo->PageHandle ==0)
+ {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ for ( control= 0; (control < pageInfo->PageControls.ControlCount) && (found == FALSE); control++ )
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == controlInfo->ControlKey)
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+
+ if(!found)
+ {
+ // Control Definition not in this Page. Look within the formset
+ EFI_HII_HANDLE pgHandle = pageInfo->PageHandle;
+ UINT32 page = 0;
+
+ for(;page < gPages->PageCount && (found == FALSE); page++)
+ {
+
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+ if(pageInfo->PageHandle != pgHandle)
+ {
+ continue;
+ }
+
+ for(control = 0; control < pageInfo->PageControls.ControlCount && (found == FALSE); control++)
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == controlInfo->ControlKey)
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ }
+ }
+
+ if(found)
+ {
+ UINTN dataWidth = UefiGetWidth(controlInfo->ControlPtr);
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8 *)controlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+
+ // EIP-42300: Updated the dataWidth in comparision to the maximum supported
+ Status = VarSetValue(varId, questionHdr->VarStoreInfo.VarOffset, (( dataWidth > sizeof(UINT64))? sizeof(UINT64) : dataWidth ), &questionValue);
+
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsScopeStackEmpty
+//
+// Description:
+//
+// Parameter: VOID
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsScopeStackEmpty()
+{
+ UINT8 opCode = 0;
+ EFI_STATUS status = EFI_SUCCESS;
+
+ status = PopScope(&opCode);
+ if(status == EFI_ACCESS_DENIED)
+ {
+ return TRUE;
+ }
+
+ status = PushScope(opCode);
+
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetPageIdFromGuid
+//
+// Description: Finds the page ID with matching Guid from the page list
+//
+// Input: EFI_GUID *FormSetGuid
+// UINT16 *PageID
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, if successful,
+// EFI_INVALID_PARAMETER, if invalid values found
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetpageIdFromGuid(EFI_GUID *FormGuid, UINT16 *PageID)
+{
+ EFI_STATUS status = EFI_INVALID_PARAMETER;
+ UINT32 pgIndex = 0;
+ PAGE_INFO *pgInfo = (PAGE_INFO *)NULL;
+ PAGE_ID_INFO *pageIdInfo = (PAGE_ID_INFO*)NULL;
+
+
+ if(gPages && gApplicationData && gPageIdList)
+ {
+ for(pgIndex = 0; pgIndex < gPages->PageCount; pgIndex++)
+ {
+ pgInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[pgIndex]);
+ if(pgInfo){
+ pageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[pgInfo->PageIdIndex]);
+ if(pageIdInfo && (EfiCompareGuid(FormGuid, &(pageIdInfo->PageGuid)) == TRUE))//Compare Guid
+ {
+ *PageID = pgInfo->PageID;
+ status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+ }
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: EvaluateExpression
+//
+// Description: Evaluate the result of a HII expression
+//
+// Parameter: IN CONTROL_INFO *ControlInfo,
+// IN OUT BOOLEAN *ExpressionResult,
+// OUT UINTN *Offset
+//
+// Return value: EFI_SUCCESS - The expression evaluated successfuly
+// EFI_NOT_FOUND - The Question which referenced by a
+// QuestionId could not be found.
+// EFI_OUT_OF_RESOURCES - There is not enough system memory to
+// grow the stack.
+// EFI_ACCESS_DENIED - The pop operation underflowed the stack
+// EFI_INVALID_PARAMETER - Syntax error with the Expression
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EvaluateExpression (
+ IN CONTROL_INFO *ControlInfo,
+ IN OUT EFI_HII_VALUE *ExpressionResult,
+ OUT UINTN *Offset
+ )
+{
+ EFI_IFR_OP_HEADER *ifrData = NULL;
+ CONTROL_INFO *ruleControl = NULL;
+ EFI_STATUS Status;
+ UINT16 Index;
+ EFI_HII_VALUE Data1;
+ EFI_HII_VALUE Data2;
+ EFI_HII_VALUE Data3;
+ EFI_HII_VALUE *questionValue = NULL;
+ EFI_HII_VALUE *questionValue2 = NULL;
+ EFI_HII_VALUE *Value = NULL;
+ EFI_QUESTION_ID questionId = 0;
+ INTN Result;
+ CHAR16 *StrPtr = NULL;
+ UINTN i = 0;
+ UINT8 opCode = 0;
+ BOOLEAN IsDevicePathFound = FALSE ,GUIDFound = FALSE;
+ EFI_GUID formSetGuid = {0}, zeroFormSetGuid = {0};
+ UINTN count = 0,tempcount = 0;
+ CHAR16 *devPathStr = (CHAR16 *)NULL, *tempDevPathStr = (CHAR16 *)NULL;
+ EFI_DEVICE_PATH_PROTOCOL *tempDevPath = (EFI_DEVICE_PATH_PROTOCOL *)NULL;
+ UINT16 DevicePath = 0;
+ //
+ // Always reset the stack before evaluating an Expression
+ //
+ ResetExpressionStack ();
+
+ ExpressionResult->Type = EFI_IFR_TYPE_OTHER;
+
+ opCode = ((EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->OpCode;
+ if(opCode != EFI_IFR_SUPPRESS_IF_OP && opCode != EFI_IFR_NO_SUBMIT_IF_OP &&
+ opCode != EFI_IFR_INCONSISTENT_IF_OP && opCode != EFI_IFR_GRAY_OUT_IF_OP &&
+ opCode != EFI_IFR_DISABLE_IF_OP && opCode != EFI_IFR_VALUE_OP)
+ {
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+
+ questionValue = (EFI_HII_VALUE*)EfiLibAllocateZeroPool(sizeof(EFI_HII_VALUE));
+ if(questionValue == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ questionValue2 = (EFI_HII_VALUE*)EfiLibAllocateZeroPool(sizeof(EFI_HII_VALUE));
+ if(questionValue2 == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ if(((EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->OpCode == EFI_IFR_RULE_OP)
+ {
+ PushScope(EFI_IFR_RULE_OP);
+ }else
+ {
+ PushScope(((EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->OpCode);
+ if (
+ ( ( (EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->OpCode == EFI_IFR_INCONSISTENT_IF_OP) ||
+ ( ( (EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->OpCode == EFI_IFR_NO_SUBMIT_IF_OP)
+ )
+ {
+ gInconsistCondPtr = ControlInfo->ControlConditionalPtr;
+ }
+ }
+
+ i += ((EFI_IFR_OP_HEADER*)ControlInfo->ControlConditionalPtr)->Length;
+
+ while (IsScopeStackEmpty() == FALSE)
+ {
+ ifrData = (EFI_IFR_OP_HEADER*)((UINT8 *)ControlInfo->ControlConditionalPtr + i);
+
+ EfiZeroMem (&Data1, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data2, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data3, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (questionValue, sizeof(EFI_HII_VALUE));
+ EfiZeroMem (questionValue2, sizeof(EFI_HII_VALUE));
+
+ Value = &Data3;
+ Value->Type = EFI_IFR_TYPE_BOOLEAN;
+ Status = EFI_SUCCESS;
+
+ questionValue->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+
+ switch (ifrData->OpCode)
+ {
+ //
+ // Built-in functions
+ //
+ case EFI_IFR_EQ_ID_VAL_OP:
+ questionId = ((EFI_IFR_EQ_ID_VAL*)ifrData)->QuestionId;
+ Status = _GetValueFromQuestionId(questionId, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ questionValue2->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ questionValue2->Value.u64 = ((EFI_IFR_EQ_ID_VAL*)ifrData)->Value;
+
+ Result = CompareHiiValue (questionValue, questionValue2, NULL);
+ if (Result == EFI_INVALID_PARAMETER)
+ {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ Value->Value.b = (Result == 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_EQ_ID_ID_OP:
+ questionId = ((EFI_IFR_EQ_ID_ID*)ifrData)->QuestionId1;
+ Status = _GetValueFromQuestionId(questionId, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ questionId = ((EFI_IFR_EQ_ID_ID*)ifrData)->QuestionId2;
+ Status = _GetValueFromQuestionId(questionId, ControlInfo->ControlPageID, &questionValue2);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ Result = CompareHiiValue (questionValue, questionValue2, ControlInfo->ControlHandle);
+ if (Result == EFI_INVALID_PARAMETER)
+ {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ Value->Value.b = (Result == 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_EQ_ID_LIST_OP:
+ questionId = ((EFI_IFR_EQ_ID_LIST*)ifrData)->QuestionId;
+ Status = _GetValueFromQuestionId(questionId, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ Value->Value.b = FALSE;
+ for (Index =0; Index < ((EFI_IFR_EQ_ID_LIST*)ifrData)->ListLength; Index++)
+ {
+ if (questionValue->Value.u16 == ((EFI_IFR_EQ_ID_LIST*)ifrData)->ValueList[Index])
+ {
+ Value->Value.b = TRUE;
+ break;
+ }
+ }
+ break;
+
+ case EFI_IFR_DUP_OP:
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+
+ Status = PushExpression (Value);
+ break;
+
+ case EFI_IFR_QUESTION_REF1_OP:
+ case EFI_IFR_THIS_OP:
+ if(ifrData->OpCode == EFI_IFR_THIS_OP)
+ {
+ questionId = ControlInfo->ControlKey;
+ }else
+ {
+ questionId = ((EFI_IFR_QUESTION_REF1*)ifrData)->QuestionId;
+ }
+ Status = _GetValueFromQuestionId(questionId, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ Value = questionValue;
+ break;
+
+
+ case EFI_IFR_QUESTION_REF3_OP:
+
+ //
+ // EFI_IFR_QUESTION_REF3
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+
+ //
+ // Validate the expression value
+ //
+
+ if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff))
+ {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ if(ifrData->Length > sizeof(EFI_IFR_QUESTION_REF3))
+ {
+ if(ifrData->Length > sizeof(EFI_IFR_QUESTION_REF3_2))
+ {
+ MemCopy(&formSetGuid,&((EFI_IFR_QUESTION_REF3_3*)ifrData)->Guid, sizeof (EFI_GUID));
+ if(EfiCompareGuid(&formSetGuid, &zeroFormSetGuid) == FALSE)
+ {
+ UINT16 PageID;
+ Status = GetpageIdFromGuid(&formSetGuid,&PageID);
+ if(Status == 0)
+ {
+ GUIDFound = TRUE;
+ Status = _GetValueFromQuestionId(Value->Value.u16,PageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ }
+ }
+ }
+ DevicePath = ifrData->Length < sizeof(EFI_IFR_QUESTION_REF3_3) ? ((EFI_IFR_QUESTION_REF3_2*)ifrData)->DevicePath : ((EFI_IFR_QUESTION_REF3_3*)ifrData)->DevicePath;
+ if(DevicePath != 0 && !GUIDFound)
+ {
+ PAGE_INFO *tempPageInfo1 = NULL;
+ devPathStr = GetToken (DevicePath,ControlInfo->ControlHandle);
+
+ if(devPathStr == NULL){
+ goto DONE;
+ }
+
+ for(count = 0; count < gPages->PageCount; count++)
+ {
+ PAGE_INFO *tempPageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[count]);
+ if(tempPageInfo == NULL)
+ {
+ continue;
+ }
+ Status = GetDevPathFromHandle(tempPageInfo->PageHandle, &tempDevPath);
+ if((Status == EFI_SUCCESS) && (tempDevPath != NULL) && tempPageInfo->PageParentID == 0)
+ {
+ GetStringFromDevPath(tempDevPath, &tempDevPathStr);
+ if(EfiStrCmp(devPathStr, tempDevPathStr) == 0)
+ {
+ tempcount++;
+ tempPageInfo1=tempPageInfo;
+ }
+ MemFreePointer( (VOID **)&tempDevPathStr );
+ }
+ }
+ MemFreePointer( (VOID **)&devPathStr );
+
+ if(tempcount == 1){
+ IsDevicePathFound = TRUE;
+ Status = _GetValueFromQuestionId(Value->Value.u16, tempPageInfo1->PageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ }
+ if(tempcount > 1){
+ goto DONE;
+ }
+ }
+ }
+ if(!IsDevicePathFound && !GUIDFound && !tempcount)
+ {
+ Status = _GetValueFromQuestionId(Value->Value.u16, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ }
+ Value = questionValue;
+ break;
+
+ case EFI_IFR_RULE_REF_OP:
+ questionId = ((EFI_IFR_RULE_REF*)ifrData)->RuleId;
+
+ Status = _GetRuleControlfromId(questionId, ControlInfo->ControlPageID, &ruleControl);
+
+ /* This Section Needs to be modified
+ //
+ // Find expression for this rule
+ //
+ RuleExpression = RuleIdToExpression (Form, OpCode->RuleId);
+ if (RuleExpression == NULL) {
+ return EFI_NOT_FOUND;
+ }*/
+
+ //
+ // Evaluate this rule expression
+ //
+ Status = EvaluateExpression (ruleControl, ExpressionResult, Offset);
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+
+ Value = ExpressionResult;
+ break;
+
+ case EFI_IFR_STRING_REF1_OP:
+ Value->Type = EFI_IFR_TYPE_STRING;
+ Value->Value.string = ((EFI_IFR_STRING_REF1*)ifrData)->StringId;
+ break;
+
+ //
+ // Constant
+ //
+ case EFI_IFR_TRUE_OP:
+ Value->Value.b = TRUE;
+ break;
+ case EFI_IFR_FALSE_OP:
+ Value->Value.b = FALSE;
+ break;
+ case EFI_IFR_ONE_OP:
+#define ONE 1
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ Value->Value.u8 = ONE;
+ break;
+ case EFI_IFR_ONES_OP:
+#define ONES 0xFFFFFFFFFFFFFFFF
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Value->Value.u64 = ONES;
+ break;
+ case EFI_IFR_UINT8_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ Value->Value.u8 = ((EFI_IFR_UINT8*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT16_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ Value->Value.u16 = ((EFI_IFR_UINT16*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT32_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
+ Value->Value.u32 = ((EFI_IFR_UINT32*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT64_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Value->Value.u64 = ((EFI_IFR_UINT64*)ifrData)->Value;
+ break;
+ case EFI_IFR_UNDEFINED_OP:
+ Value->Type = EFI_IFR_TYPE_OTHER;
+ break;
+ case EFI_IFR_VERSION_OP:
+#define VERSION (UINT16)(2<<8)|((3<<4) | 0x1) //EIP:56355 Updated the Version to 2.3.1
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ Value->Value.u16 = VERSION;
+ break;
+ case EFI_IFR_ZERO_OP:
+#define ZERO 0
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ Value->Value.u8 = ZERO;
+ break;
+
+ //
+ // unary-op
+ //
+ case EFI_IFR_LENGTH_OP:
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Value->Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ StrPtr = GetToken (Value->Value.string, ControlInfo->ControlHandle);
+ if (StrPtr == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Value->Value.u64 = EfiStrLen (StrPtr);
+ gBS->FreePool (StrPtr);
+ break;
+
+ case EFI_IFR_NOT_OP:
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Value->Type != EFI_IFR_TYPE_BOOLEAN) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ Value->Value.b = !Value->Value.b;
+ break;
+
+ case EFI_IFR_QUESTION_REF2_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Validate the expression value
+ //
+ if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff)) {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ Status = _GetValueFromQuestionId(Value->Value.u16, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ Value = questionValue;
+ break;
+
+ case EFI_IFR_STRING_REF2_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Validate the expression value
+ //
+ if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff)) {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ Value->Type = EFI_IFR_TYPE_STRING;
+ StrPtr = GetToken (Value->Value.u16, ControlInfo->ControlHandle);
+ if (StrPtr == NULL) {
+ //
+ // If String not exit, push an empty string
+ //
+ Value->Value.string = NewString (gEmptyString, ControlInfo->ControlHandle);
+ } else {
+ Index = (UINT16) Value->Value.u64;
+ Value->Value.string = Index;
+ gBS->FreePool (StrPtr);
+ }
+ break;
+
+ case EFI_IFR_TO_BOOLEAN_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Convert an expression to a Boolean
+ //
+ if (Value->Type <= EFI_IFR_TYPE_DATE) {
+ //
+ // When converting from an unsigned integer, zero will be converted to
+ // FALSE and any other value will be converted to TRUE.
+ //
+ Value->Value.b = (Value->Value.u64) ? TRUE : FALSE;
+
+ Value->Type = EFI_IFR_TYPE_BOOLEAN;
+ } else if (Value->Type == EFI_IFR_TYPE_STRING) {
+ //
+ // When converting from a string, if case-insensitive compare
+ // with "true" is True, then push True. If a case-insensitive compare
+ // with "false" is True, then push False.
+ //
+ StrPtr = GetToken (Value->Value.string, ControlInfo->ControlHandle);
+ if (StrPtr == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ if ((EfiStrCmp (StrPtr, L"true") == 0))
+ {
+ Value->Value.b = TRUE;
+ } else if(EfiStrCmp (StrPtr, L"false") == 0)
+ {
+ Value->Value.b = FALSE;
+ } else
+ {
+ Value->Type = EFI_IFR_TYPE_OTHER;
+ }
+ gBS->FreePool (StrPtr);
+ Value->Type = EFI_IFR_TYPE_BOOLEAN;
+ }
+ break;
+
+ case EFI_IFR_TO_STRING_OP:
+ Status = IfrToString (ControlInfo->ControlHandle, ((EFI_IFR_TO_STRING*)ifrData)->Format, Value);
+ break;
+
+ case EFI_IFR_TO_UINT_OP:
+ Status = IfrToUint (ControlInfo->ControlHandle, Value);
+ break;
+
+ case EFI_IFR_TO_LOWER_OP:
+ case EFI_IFR_TO_UPPER_OP:
+ Status = InitializeUnicodeCollationProtocol ();
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ if (Value->Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+
+ StrPtr = GetToken (Value->Value.string, ControlInfo->ControlHandle);
+ if (StrPtr == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ if (ifrData->OpCode == EFI_IFR_TO_LOWER_OP) {
+ mUnicodeCollation->StrLwr (mUnicodeCollation, StrPtr);
+ } else {
+ mUnicodeCollation->StrUpr (mUnicodeCollation, StrPtr);
+ }
+ Value->Value.string = NewString (StrPtr, ControlInfo->ControlHandle);
+ gBS->FreePool (StrPtr);
+ break;
+
+ case EFI_IFR_BITWISE_NOT_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Value->Type > EFI_IFR_TYPE_DATE) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Value->Value.u64 = ~Value->Value.u64;
+ break;
+
+ //
+ // binary-op
+ //
+ case EFI_IFR_ADD_OP:
+ case EFI_IFR_SUBTRACT_OP:
+ case EFI_IFR_MULTIPLY_OP:
+ case EFI_IFR_DIVIDE_OP:
+ case EFI_IFR_MODULO_OP:
+ case EFI_IFR_BITWISE_AND_OP:
+ case EFI_IFR_BITWISE_OR_OP:
+ case EFI_IFR_SHIFT_LEFT_OP:
+ case EFI_IFR_SHIFT_RIGHT_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data2.Type > EFI_IFR_TYPE_DATE) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data1.Type > EFI_IFR_TYPE_DATE) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+
+ switch (ifrData->OpCode) {
+ case EFI_IFR_ADD_OP:
+ Value->Value.u64 = Data1.Value.u64 + Data2.Value.u64;
+ break;
+
+ case EFI_IFR_SUBTRACT_OP:
+ Value->Value.u64 = Data1.Value.u64 - Data2.Value.u64;
+ break;
+
+ case EFI_IFR_MULTIPLY_OP:
+ Value->Value.u64 = MultU64x32 (Data1.Value.u64, (UINT32)Data2.Value.u64);
+ break;
+
+ case EFI_IFR_DIVIDE_OP:
+ Value->Value.u64 = AmiTseDivU64x32 (Data1.Value.u64, (UINT32)Data2.Value.u64,NULL);
+ break;
+
+ case EFI_IFR_MODULO_OP:
+ Value->Value.u64 = 0;
+ AmiTseDivU64x32(Data1.Value.u64, (UINT32)Data2.Value.u64, (UINTN*)&Value->Value.u64);
+ break;
+
+ case EFI_IFR_BITWISE_AND_OP:
+ Value->Value.u64 = Data1.Value.u64 & Data2.Value.u64;
+ break;
+
+ case EFI_IFR_BITWISE_OR_OP:
+ Value->Value.u64 = Data1.Value.u64 | Data2.Value.u64;
+ break;
+
+ case EFI_IFR_SHIFT_LEFT_OP:
+ Value->Value.u64 = LShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
+ break;
+
+ case EFI_IFR_SHIFT_RIGHT_OP:
+ Value->Value.u64 = RShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case EFI_IFR_AND_OP:
+ case EFI_IFR_OR_OP:
+ //
+ // Two Boolean operator
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data2.Type != EFI_IFR_TYPE_BOOLEAN) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data1.Type != EFI_IFR_TYPE_BOOLEAN) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ if (ifrData->OpCode == EFI_IFR_AND_OP) {
+ Value->Value.b = Data1.Value.b && Data2.Value.b;
+ } else {
+ Value->Value.b = Data1.Value.b || Data2.Value.b;
+ }
+ break;
+
+ case EFI_IFR_EQUAL_OP:
+ case EFI_IFR_NOT_EQUAL_OP:
+ case EFI_IFR_GREATER_EQUAL_OP:
+ case EFI_IFR_GREATER_THAN_OP:
+ case EFI_IFR_LESS_EQUAL_OP:
+ case EFI_IFR_LESS_THAN_OP:
+ //
+ // Compare two integer, string, boolean or date/time
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data2.Type > EFI_IFR_TYPE_BOOLEAN && Data2.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ Result = CompareHiiValue (&Data1, &Data2, ControlInfo->ControlHandle);
+ if (Result == EFI_INVALID_PARAMETER) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ switch (ifrData->OpCode) {
+ case EFI_IFR_EQUAL_OP:
+ Value->Value.b = (Result == 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_NOT_EQUAL_OP:
+ Value->Value.b = (Result != 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_GREATER_EQUAL_OP:
+ Value->Value.b = (Result >= 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_GREATER_THAN_OP:
+ Value->Value.b = (Result > 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_LESS_EQUAL_OP:
+ Value->Value.b = (Result <= 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_LESS_THAN_OP:
+ Value->Value.b = (Result < 0) ? TRUE : FALSE;
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case EFI_IFR_MATCH_OP:
+ Status = IfrMatch (ControlInfo->ControlHandle, Value);
+ break;
+
+ case EFI_IFR_CATENATE_OP:
+ Status = IfrCatenate (ControlInfo->ControlHandle, Value);
+ break;
+
+ //
+ // ternary-op
+ //
+ case EFI_IFR_CONDITIONAL_OP:
+ //
+ // Pop third expression from the expression stack
+ //
+ Status = PopExpression (&Data3);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Pop second expression from the expression stack
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Pop first expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data1.Type != EFI_IFR_TYPE_BOOLEAN) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ if (Data1.Value.b) {
+ Value = &Data3;
+ } else {
+ Value = &Data2;
+ }
+ break;
+
+ case EFI_IFR_FIND_OP:
+ Status = IfrFind (ControlInfo->ControlHandle, ((EFI_IFR_FIND*)ifrData)->Format, Value);
+ break;
+
+ case EFI_IFR_MID_OP:
+ Status = IfrMid (ControlInfo->ControlHandle, Value);
+ break;
+
+ case EFI_IFR_TOKEN_OP:
+ Status = IfrToken (ControlInfo->ControlHandle, Value);
+ break;
+
+ case EFI_IFR_SPAN_OP:
+ Status = IfrSpan (ControlInfo->ControlHandle, ((EFI_IFR_SPAN*)ifrData)->Flags, Value);
+ break;
+
+ default:
+ Status = PopScope(&opCode);
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+ continue;
+ }
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+
+ Status = PushExpression (Value);
+ if (EFI_ERROR (Status))
+ {
+ goto DONE;
+ }
+
+ i += ifrData->Length;
+ }
+ if (NULL != ifrData)//EIP-75384 Static code
+ {
+ if(ifrData->OpCode == EFI_IFR_END_OP)
+ i += ifrData->Length;
+ }
+
+ //
+ // Pop the final result from expression stack
+ //
+ Value = &Data1;
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // After evaluating an expression, there should be only one value left on the expression stack
+ //
+ if (PopExpression (Value) != EFI_ACCESS_DENIED)
+ {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ EfiCopyMem (ExpressionResult, Value, sizeof (EFI_HII_VALUE));
+
+DONE:
+ MemFreePointer(&questionValue);
+ MemFreePointer(&questionValue2);
+
+ *Offset = i;
+ gInconsistCondPtr = NULL;
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _SkipExpression
+//
+// Description: Travels till the end of the current Expression and returns the offset
+//
+// Parameter: ControlCondPtr - Pointer to the Expression beginning.
+//
+// Return value: UINTN - Offsets to skip the current expression.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _SkipExpression(UINT8 *ControlCondPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader = ( EFI_IFR_OP_HEADER * )ControlCondPtr;
+ UINTN offset = 0;
+ INTN inScope = 0;
+
+ // Skip the If condition OpCode
+ if(
+ OpHeader->OpCode != EFI_IFR_SUPPRESS_IF_OP &&
+ OpHeader->OpCode != EFI_IFR_NO_SUBMIT_IF_OP &&
+ OpHeader->OpCode != EFI_IFR_INCONSISTENT_IF_OP &&
+ OpHeader->OpCode != EFI_IFR_GRAY_OUT_IF_OP &&
+ OpHeader->OpCode != EFI_IFR_DISABLE_IF_OP
+ )
+ {
+ // This should not happen. The code should halt here.
+ offset = 0;
+ goto DONE;
+ }
+
+ // Skip the If opcode
+ offset = OpHeader->Length;
+ OpHeader = ( EFI_IFR_OP_HEADER * )(( UINT8 *)OpHeader + offset );
+
+ do
+ {
+ switch( OpHeader->OpCode )
+ {
+ case EFI_IFR_END_OP:
+ inScope--;
+ break;
+ default:
+ if(OpHeader->Scope)
+ inScope++;
+ break;
+ }
+ offset += OpHeader->Length;
+ OpHeader = ( EFI_IFR_OP_HEADER * )(( UINT8 *)OpHeader + OpHeader->Length );
+ }while(inScope > 0);
+
+DONE:
+ return offset;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/FormBrowser2.c b/EDK/MiniSetup/uefi2.1/FormBrowser2.c
new file mode 100644
index 0000000..700bcc2
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/FormBrowser2.c
@@ -0,0 +1,1175 @@
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 35 $
+//
+// $Date: 8/28/14 12:24p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.c $
+//
+// 35 8/28/14 12:24p Premkumara
+// [TAG] EIP175017
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Setup hangs when sendform called from oemdriverhealth module
+// [Solution] TSE installs timer to read the keys in conin availability.
+// This timer stopped in PostManagerHandshake but if mainsetuploop called
+// from sendform then this timer not stopped so hang happened in different
+// stages.So stopping timer properly resolves the issue.
+// [Files] FormBrowser2.c
+//
+// 34 2/11/14 8:50p Arunsb
+// [TAG] EIP147816
+// [Category] Bug Fix
+// [Symptom] Having same two formset with two different handles, confirm
+// checkbox is grayed out in one formset not in other
+// [Root Cause] During BrowserCallback, the current context
+// [gCurrVarHandle and gCurrVarIndex] is lost due to multiple pack updates
+// within a single callback.
+// [Solution] Maintain a stack to preserve the current context values for
+// (gCurrVarHandle and gCurrVarIndex) during BrowserCallback
+// [Files] FormBrowser2.c
+//
+// 33 12/04/13 3:43p Premkumara
+// [TAG] EIP144581
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE gets Hangs when HiiLibSetBrowserData try to update
+// LegacyDevOrder
+// [Root Cause] LegacyBootData is setting irrespective of valid options
+// [Solution] Validating LegacyBootData for valid options and save valid
+// options.
+// [Files] FormBrowser2.c
+//
+// 32 5/15/13 4:50a Premkumara
+// [TAG] EIP123312
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Build error when token TSE_DEBUG_MESSAGE is enabled
+// [RootCause] Parameter missed to pass to a function WriteDataToFile()
+// [Solution] Passed valid parameter to WriteDataToFile()
+// [Files] FormBrowser2.c
+//
+// 31 4/18/13 2:23a Arunsb
+// [TAG] EIP113266
+// [Category] Improvement
+// [Description] gBrowserCallbackEnabled variable moved to boot only
+// module
+// [Files] boot.c and FormBrowser2.c
+//
+// 30 2/25/13 10:57a Blaines
+// [TAG] - EIP 104273
+// [Category] - Action Item
+// [Description] - Provide ability to dump the Hii Pack from the Setup as
+// part TSE debug Infrastructure. It should dump the Pack updates on Hii
+// notification also.
+// So it can be used to debug the issue.
+// [Files] - ForBrowser2.c, Hii.c, HiiNotificationHandler.c,
+// UefiWapper.c, TseUefiHii.h
+//
+// 29 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 12 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 27 9/20/12 11:15a Arunsb
+// SendForm will operate only with SETUP_FORM_BROWSER_SUPPORT token
+// enabled.
+//
+// 26 5/29/12 3:10a Premkumara
+// Added missing version-23 (EIP-90895) changes
+//
+// 25 5/28/12 9:55a Premkumara
+// Added missing version-23 (EIP-90895) changes
+//
+// 24 5/28/12 5:56a Premkumara
+// [TAG] EIP75236
+// [Category] Improvement
+// [Description] Add the support to control the GOP dependency in TSE
+// notification.
+// [Files] AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
+// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
+//
+// 23 5/26/12 5:35a Arunsb
+// [TAG] EIP90895
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup hangs when retrieve callback produces
+// add/remove/update forms
+// [RootCause] Callback with retrieve action produces add/remove/update
+// form
+// [Solution] If retrieve callback produces add/remove/update form then
+// TSE will print debug messages and assert.
+// [Files] HiiNotificationHandler.c, HiiCallback.c and FormBrowser2.c
+//
+// 22 2/03/12 1:31p Arunsb
+// [TAG] EIP81617
+// [Category] Improvement
+// [Description] Avoiding memory leaks in TSE
+// [Files] hiistring21.c, CommonHelper.c, notify.c and formbrowser2.c
+//
+// 21 1/20/12 5:33a Rajashakerg
+// [TAG] EIP75567
+// [Category] Improvement
+// [Description] Provide ActionRequest in SendForm function
+// [Files] FormBrowser2.c
+//
+// 20 12/07/11 3:31p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 19 12/07/11 8:12a Rajashakerg
+// [TAG] EIP75118
+// [Category] Improvement
+// [Description] xtractConfig() fail since BrowserCallback() cannot find
+// the variable to process
+// [Files] FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
+// Uefi21Wapper.c, PopupSel.c
+//
+// 18 12/05/11 5:53a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 17 11/30/11 1:37p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 16 11/28/11 2:27a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 15 11/23/11 5:13a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 14 11/21/11 5:55a Rajashakerg
+// [TAG] EIP74591
+// [Category] Improvement
+// [Description] Make MainSetupLoop as board module hook
+// [Files] AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
+// FormBrowser.c, FormBrowser2.c
+//
+// 13 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 12 11/08/11 4:50a Rajashakerg
+// Lowered the TPL to Application level and invoked
+// StyleUpdateVersionString() function to update the copy right string in
+// the SendForm() function.
+//
+// 11 6/30/11 11:55a Arunsb
+// Adding config header in config string is controlled by
+// EDKVersion_1_05_RetrieveData wrapper function.
+//
+// 10 6/30/11 4:16a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// gFSetGuid added to compare in parseform.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 9 3/28/11 6:00p Madhans
+// [TAG] EIP56247
+// [Category] Improvement
+// [Description] To support BrowserCallback with ResultData=NULL.
+// To to add EDK_1_05_RETRIEVE_DATA SDL on by default for UEFI OptionROM
+// cards to work.
+// Need Core changes if EDK_1_05_RETRIEVE_DATA=1.
+// EDK_1_05_RETRIEVE_DATA=0 May cause UEFI Option ROM card to not work ok.
+//
+// [Files] Uefi21.sdl
+// FormBrowser2.c
+//
+// 8 12/02/10 5:51p Madhans
+// [TAG] - EIP 48169
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- To do the Workaround for ConfigtoBlock issues and Fix issues
+// with Retirive config.
+// [Solution]- Fix done formBrowser2.c and uefi21wrapper.c
+// [Files] - formBrowser2.c and uefi21wrapper.c
+//
+// 7 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 9 9/15/10 1:55p Madhans
+// To fix the issue with TSE when SetBrowser data is called. Without this
+// fix always lastbyte of set browser data is missed.
+//
+// 8 6/17/10 2:58p Madhans
+// Exit safely when sendform is not supported.
+//
+// 7 3/11/10 5:42p Madhans
+// Coding Standards Update
+//
+// 6 2/26/10 6:57p Madhans
+// To validate the Hii Handle before trying to process it.
+//
+// 5 2/19/10 8:35p Madhans
+// Function header fix
+//
+// 4 1/12/10 11:10a Presannar
+// Modified code to return BrowserCallback String according to either EDK
+// browser or spec
+//
+// 3 1/08/10 4:43p Presannar
+// Fixed BrowserCallback to return EFI_INVALID_PARAMETER when ResultsData
+// is NULL and *ResultsDataSize != 0
+//
+// 2 11/19/09 5:28p Presannar
+// Updated TSE include file name to not clash with CORE file
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 3 3/31/09 4:15p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/29/09 6:06p Presannar
+// Added Function Header Comments
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 1 12/29/08 4:46p Presannar
+// FormBrowser2 protocol Send Form and BrowserCallback initial draft
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: FormBrowser2.C
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//----------------------------------------------------------------------------
+#include "Minisetup.h"
+#include "FormBrowser2.h"
+#include "TseUefiHii.h"
+//----------------------------------------------------------------------------
+extern BOOLEAN gPackUpdatePending;
+extern BOOLEAN gEnableDrvNotification; //TRUE if allow notification function to process action, FALSE to ignore the notification
+extern UINTN HpkFileCount;
+//---------------------------------------------------------------------------
+// Variables
+//---------------------------------------------------------------------------
+BOOLEAN gRequireSysReboot = FALSE; //EIP 75567 :If TRUE, ACTION_REQUEST_RESET will be returned from SendForm, else ignore reboot
+VOID **gSfHandles;
+UINTN gSfHandleCount;
+EFI_GUID *gFSetGuid = NULL;
+UINT8 *gSfNvMap;
+extern BOOLEAN gBrowserCallbackEnabled; //EIP113266 Allow external drivers to change ASL cache only if it's TRUE; ignore browser callback otherwise
+extern BOOLEAN gEnterSetup;
+extern EFI_EVENT gKeyTimer;
+EFI_BROWSER_ACTION gBrowserCallbackAction = 0 ;//Contains the BrowserCallback action when a callback is in progress.
+//static CONTROL_INFO *gCallbackControl = NULL; unused
+static EFI_HANDLE gCurrVarHandle = (EFI_HANDLE)NULL;
+static UINT32 gCurrVarIndex = 0;
+#define BROWSERCALLBACK_MAX_ENTRIES 10
+static EFI_HANDLE gCallBackHandleStack[BROWSERCALLBACK_MAX_ENTRIES]; //EIP-147816
+static UINT32 gCallBackVarIndexStack[BROWSERCALLBACK_MAX_ENTRIES];//EIP-147816
+
+EFI_GUID gEfiFormBrowser2ProtocolGuid = EFI_FORM_BROWSER2_PROTOCOL_GUID;
+
+//---------------------------------------------------------------------------
+// Structure
+//---------------------------------------------------------------------------
+EFI_FORM_BROWSER2_PROTOCOL FormBrowser2 =
+{
+ SendForm,
+ BrowserCallback
+};
+
+//---------------------------------------------------------------------------
+// Function Prototypes
+//---------------------------------------------------------------------------
+EFI_STATUS _StorageToConfigResp(VARIABLE_INFO *VariableInfo, VOID *Buffer, CHAR16 *ConfigHdr, CHAR16 **ConfigResp);
+EFI_STATUS _ConfigRespToStorage(VARIABLE_INFO *varInfo, UINT8 **buffer, UINTN *Size, EFI_STRING configResp);
+BOOLEAN EDKVersion_1_05_RetrieveData (VOID);
+EFI_STATUS CleanNotificationQueue (VOID);
+//---------------------------------------------------------------------------
+// Function Implementation
+//---------------------------------------------------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SetCallBackControlInfo
+//
+// Description: Set the variable inforamtion
+//
+// Parameter: EFI_HANDLE VarHandle - Variable handle to process
+// UINT32 VarIndex - Variable index in the gVariables->VariableList
+//
+// Return value:VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetCallBackControlInfo(EFI_HANDLE VarHandle, UINT32 VarIndex)
+{
+ static int ContextVar=0;
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering SetCallBackControlInfo, HIIHandle =%x \n\n", VarHandle );
+ if(VarHandle != NULL){ //If the varaible handle is valid, set handle and variable index
+ if(ContextVar >= BROWSERCALLBACK_MAX_ENTRIES)
+ {
+ SETUP_DEBUG_TSE ("\n[TSE] Too many nested Browser Callbacks!\n\n");
+ ASSERT (0);
+ }
+ gCurrVarHandle = VarHandle;
+ gCurrVarIndex = VarIndex;
+ //EIP-147816
+ //Use Stack to manage gCurrVarHandle and gCurrVarIndex
+ gCallBackHandleStack[ContextVar] = gCurrVarHandle;
+ gCallBackVarIndexStack[ContextVar] = gCurrVarIndex;
+ ContextVar++;
+
+ } else{ //Else reset global the varaible handle and variable index
+
+ if(ContextVar == 0)
+ return;
+
+ ContextVar--;
+
+ if(ContextVar == 0)
+ {
+ gCurrVarHandle = (EFI_HANDLE)NULL;
+ gCurrVarIndex = 0;
+ }else{
+ //EIP-147816
+ //Reset gCurrVarHandle and gCurrVarIndex to previous stack entry
+ gCurrVarHandle = gCallBackHandleStack[ContextVar-1] ;
+ gCurrVarIndex = gCallBackVarIndexStack[ContextVar-1] ;
+ }
+
+ }
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting SetCallBackControlInfo HIIHandle =%x \n\n", VarHandle );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: InstallFormBrowserProtocol
+//
+// Description: Install FormBrowser Protocol
+//
+// Parameter: EFI_HANDLE Handle
+//
+// Return value:EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ UnInstallFormBrowserProtocol(Handle);
+ status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiFormBrowser2ProtocolGuid,
+ &FormBrowser2,
+ NULL
+ );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UnInstallFormBrowserProtocol
+//
+// Description: UnInstall FormBrowser Protocol
+//
+// Parameter: EFI_HANDLE Handle
+//
+// Return value:VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_HANDLE handle;
+ VOID *iface;
+ UINTN size = 0;
+
+ status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiFormBrowser2ProtocolGuid,
+ NULL,
+ &size,
+ &handle
+ );
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ handle = EfiLibAllocateZeroPool(size);
+ if (handle == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiFormBrowser2ProtocolGuid,
+ NULL,
+ &size,
+ &handle
+ );
+ }
+
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ status = gBS->LocateProtocol (
+ &gEfiFormBrowser2ProtocolGuid,
+ NULL,
+ &iface
+ );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ status = gBS->UninstallMultipleProtocolInterfaces (
+ handle,
+ &gEfiFormBrowser2ProtocolGuid,
+ iface,
+ NULL
+ );
+
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+DONE:
+ return;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: SendForm
+//
+// Description: This is the routine which an external caller uses to direct
+// the browser where to obtain it's information.
+//
+// Input: EFI_FORM_BROWSER2_PROTOCOL *This - The Form Browser protocol instanse.
+// EFI_HII_HANDLE *Handles - A pointer to an array of Handles. If
+// HandleCount > 1 we display a list of the formsets for the
+// handles specified.
+// UINTN HandleCount - The number of Handles specified in Handle.
+// EFI_GUID *FormSetGuid [OPTIONAL] - This field points to the EFI_GUID
+// which must match the Guid field in the EFI_IFR_FORM_SET
+// op-code for the specified forms-based package. If
+// FormSetGuid is NULL, then this function will display the
+// first found forms package.
+// UINT16 FormId [OPTIONAL] - This field specifies which EFI_IFR_FORM
+// to render as the first displayable page. If this field has
+// a value of 0x0000, then the forms browser will render the
+// specified forms in their encoded order.
+// EFI_SCREEN_DESCRIPTOR *ScreenDimenions [OPTIONAL] - Points to
+// recommended form dimensions, including any non-content
+// area, in characters. This allows the browser to be called
+// so that it occupies a portion of the physical screen
+// instead of dynamically determining the screen dimensions.
+// EFI_BROWSER_ACTION_REQUEST *ActionRequest [OPTIONAL] - Points to
+// the action recommended by the form.
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, The function completed successfully.
+// EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+// EFI_NOT_FOUND - No valid forms could be found to display.
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EFIAPI
+SendForm (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN EFI_HII_HANDLE *Handles,
+ IN UINTN HandleCount,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN UINT16 FormId, OPTIONAL
+ IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN i;
+ BOOLEAN BackUpgEnterSetup = FALSE;
+
+#if !SETUP_FORM_BROWSER_SUPPORT
+ SETUP_DEBUG_TSE ("[TSE] SendForm not supported with SETUP_FORM_BROWSER_SUPPORT token disabled\n");
+ return EFI_UNSUPPORTED;
+#endif
+
+ if(gApp != NULL || gSetupContextActive)
+ {
+ // Inside Setup. Setupdata contexts valid.
+ UINT8 Sel=0;
+
+ AMI_POST_MANAGER_PROTOCOL *PostMgr = NULL;
+
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &PostMgr);
+ if(Status == EFI_SUCCESS)
+ {
+ //PostManagerDisplayMsgBox (L"SendForm Unsupported",L"SendForm Not suppored Nestedly or from Valid Setup Context!",MSGBOX_TYPE_OK,&Sel);
+ PostMgr->DisplayMsgBox( L"SendForm Unsupported", L"SendForm Not suppored Nestedly or from Valid Setup Context!", MSGBOX_TYPE_OK,NULL);
+ }
+ return EFI_UNSUPPORTED;
+ }
+
+ if( Handles == NULL || HandleCount == 0 )
+ {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+#ifndef STANDALONE_APPLICATION
+ if ( ! gConsoleControl )
+ {
+ //All necessary protocols are not available yet.
+ //We can still proceed if Uga Draw is the only protocol not available yet.
+ ActivateApplication();
+
+ if (!IsDelayLogoTillInputSupported()) //EIP-75236
+ ActivateInput();
+ }
+#endif
+
+ //Initialize send form global variables
+ if(HandleCount)
+ {
+ gSfHandles = EfiLibAllocateZeroPool( HandleCount * sizeof(VOID*));
+ gSfHandleCount = 0;
+ gFSetGuid = FormSetGuid;
+ for(i=0;i<HandleCount;i++)
+ {
+ UINT8 *FormSet = NULL;
+ UINTN Length = 0;
+
+ // Check if the Handle Has Forms to Display
+ FormSet = HiiGetForm( Handles[i], 0, &Length);
+ if( FormSet != NULL )
+ {
+ gSfHandles[gSfHandleCount] = (VOID*)(UINTN)Handles[i];
+ MemFreePointer( &FormSet );
+ gSfHandleCount++;
+ }
+ }
+ if( gSfHandleCount == 0 )
+ {
+ MemFreePointer( (VOID**)&gSfHandles );
+ Status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+ }
+ gSfNvMap = NULL;//NvMapOverride;
+
+ if(!gVariableList)
+ {
+ CleanTempNvramVariableList();//EIP 76381 : Reset to read the variable from NVRAM
+ VarLoadVariables( (VOID **)&gVariableList, NULL );
+ }
+ // this *MUST* be run a EFI_TPL_APPLICATION
+ gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL ); // guarantees that RestoreTPL won't ASSERT
+ gBS->RestoreTPL( EFI_TPL_APPLICATION );
+
+ StyleUpdateVersionString();
+
+ //Show forms
+ Status = gST->ConIn->Reset( gST->ConIn, FALSE );
+ BackUpgEnterSetup = gEnterSetup; //EIP-175017
+ if (gKeyTimer)
+ {
+ TimerStopTimer( &gKeyTimer );
+ }
+ Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook
+ gEnterSetup = BackUpgEnterSetup;
+
+ //Reset send form global variables
+ //gSfHandles = (VOID**)NULL;
+ MemFreePointer( (VOID**)&gSfHandles );
+ gSfHandles = NULL;
+
+ gSfHandleCount = 0;
+ gSfNvMap = NULL;
+
+DONE:
+
+ if(gRequireSysReboot){ //EIP 75567 : If system reboot was set, return ACTION_REQUEST_RESET
+ if(ActionRequest)
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;
+ gRequireSysReboot = FALSE; //EIP 75567 :Reset system reboot variable
+ }
+ if(gPackUpdatePending) //If IFR notifications are pending clear the queue before exiting SendForm
+ {
+ CleanNotificationQueue();
+ }
+ gPackUpdatePending = FALSE;
+ CleanTempNvramVariableList();//EIP 76381 : Reset to read the variable from NVRAM
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: BrowserCallback
+//
+// Description: This function is called by a callback handler to retrieve
+// uncommitted state data from the browser.
+//
+// Input:
+// IN CONST EFI_FORM_BROWSER2_PROTOCOL *This - A pointer to the
+// EFI_FORM_BROWSER2_PROTOCOL instance.
+// IN OUT UINTN *ResultsDataSize - A pointer to the size of the
+// buffer associated with ResultsData.
+// IN OUT EFI_STRING ResultsData - A string returned from an IFR
+// browser or equivalent. The results string will have no
+// routing information in them.
+// IN BOOLEAN RetrieveData - A BOOLEAN field which allows an agent
+// to retrieve (if RetrieveData = TRUE) data from the
+// uncommitted browser state information or set
+// (if RetrieveData = FALSE) data in the uncommitted browser
+// state information.
+// IN CONST EFI_GUID *VariableGuid, OPTIONAL - An optional field to
+// indicate the target variable GUID name to use.
+// IN CONST CHAR16 *VariableName OPTIONAL - An optional field to
+// indicate the target human-readable variable name.
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, The results have been distributed
+// or are awaiting distribution.
+// EFI_BUFFER_TOO_SMALL, The ResultsDataSize
+// specified was too small to contain the results data.
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+EFIAPI
+BrowserCallback (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN OUT UINTN *ResultsDataSize,
+ IN OUT EFI_STRING ResultsData,
+ IN BOOLEAN RetrieveData,
+ IN CONST EFI_GUID *VariableGuid, OPTIONAL
+ IN CONST CHAR16 *VariableName OPTIONAL
+ )
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+ VARIABLE_INFO *varInfo = NULL;
+ BOOLEAN found;
+ CHAR16 *configResp = NULL;
+ CHAR16 *strPtr = NULL;
+ CHAR16 *configHdr = NULL;
+ UINT8 *buffer = NULL;
+ UINTN bufferSize;
+ UINTN size = 0;
+ UINTN length = 0;
+ UINT32 varIndex = 0;
+ UINT32 index = 0;
+ UINT16 CurrentBootOption = 0;
+
+ if((gBrowserCallbackEnabled == FALSE) && (gEnableDrvNotification == FALSE)) { //Allow Browser callback for AMI ExecuteCallback/AccessConfig/RouteConfig calls
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+
+ if(ResultsDataSize == NULL || (*ResultsDataSize && ResultsData == NULL))
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering BrowserCallback()\n\n" );
+
+ //
+ // Find target storage
+ //
+ if(VariableGuid != NULL)
+ {
+ //
+ // Try to find target storage
+ //
+ found = FALSE;
+ for(index = 0; index < gVariables->VariableCount; index++)
+ {
+ varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(index);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == varInfo){
+ continue;
+ }
+ if(EfiCompareGuid(&varInfo->VariableGuid, (EFI_GUID *)VariableGuid))
+ {
+ if(((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE) != VARIABLE_ATTRIBUTE_EFI_VARSTORE) &&
+ ((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) != VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ //
+ // Buffer storage require both GUID and Name
+ //
+ if (VariableName == NULL)
+ {
+ status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ if (EfiStrCmp (varInfo->VariableName, (CHAR16 *)VariableName) == 0)
+ {
+ found = TRUE;
+ varIndex = index;
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Comparing gCurrVarHandle = %x to variableHandle %x\n\n", gCurrVarHandle, varInfo->VariableHandle );
+ if (varInfo->VariableHandle == gCurrVarHandle) //Checking for same variable names for two different handles, if match not found continue with default
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!found)
+ {
+ status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+ else //If gCurrVarHandle is not matched then varInfo will have last index data so again filling VarInfo
+ {
+ //Updating the varinfo with the varIndex
+ varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(varIndex);
+ }
+ } else
+ {
+ // GUID/Name is not specified, store variable index
+ varIndex = gCurrVarIndex;
+ varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(varIndex);
+ }
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if (NULL == varInfo){
+ goto DONE;
+ }
+
+
+ if((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE) == VARIABLE_ATTRIBUTE_EFI_VARSTORE)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //
+ // Retrive NVRam Buffer
+ //
+ buffer = (UINT8 *)VarGetVariable(varIndex, &size);
+ if(buffer == NULL)
+ {
+ goto DONE;
+ }
+
+ //
+ // Generate <ConfigHdr>
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] GetConfigHeader()\n" );
+ status = GetConfigHeader(varInfo, &configHdr, &length);
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] GetConfigHeader retuned, status = 0x%x \n\n" , status );
+ if(EFI_ERROR(status) || (NULL == configHdr))//EIP-75384 Static code
+ {
+ goto DONE;
+ }
+
+ if(RetrieveData)
+ {
+ //
+ // Generate <ConfigResp>
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] _StorageToConfigResp()\n" );
+ status = _StorageToConfigResp(varInfo, buffer, configHdr, &configResp);
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] _StorageToConfigResp returned, status = 0x%x \n\n" , status );
+ if (EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ //
+ // Skip <ConfigHdr> and '&' to point to <ConfigBody>
+ //
+ if (EDKVersion_1_05_RetrieveData ())
+ {
+ strPtr = configResp + EfiStrLen (configHdr) + 1;
+ }
+ else
+ {
+ strPtr = configResp;
+ }
+ bufferSize = EfiStrSize (strPtr);
+ if (*ResultsDataSize < bufferSize)
+ {
+ *ResultsDataSize = bufferSize;
+
+ // gBS->FreePool (configResp);
+ status = EFI_BUFFER_TOO_SMALL;
+ goto DONE;
+ }
+
+ *ResultsDataSize = bufferSize;
+ EfiCopyMem (ResultsData, strPtr, bufferSize);
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Displaying Retrieve Data Buffer, VariableName: %s, VariableHandle: 0x%x\n\n", varInfo->VariableName, varInfo->VariableHandle );
+
+#if TSE_DEBUG_MESSAGES
+ DebugShowBufferContent(bufferSize, ResultsData);
+#endif
+
+ //gBS->FreePool(configResp);
+ } else
+ {
+ //
+ // Prepare <configResp>
+ //
+
+#if TSE_DEBUG_MESSAGES
+ {
+ CHAR16 BrowserCallbackFilename[50];
+ CHAR16 BrowserCallbackContent[200];
+ CHAR16 *BrowserCallbackBuffer = NULL ;
+ UINTN Len=0;
+
+
+ SPrint(BrowserCallbackFilename,50,L"BROWSERCALLBACK_%s_%03d.txt", varInfo->VariableName, HpkFileCount);
+ SPrint(BrowserCallbackContent, 200, L"VariableName: %s\nVariableGuid: %g\nResultsDataSize: 0x%x\n", VariableName, &VariableGuid, *ResultsDataSize);
+ Len = (EfiStrLen (BrowserCallbackContent) + EfiStrLen (ResultsData) + 1) * sizeof (CHAR16);
+ BrowserCallbackBuffer = EfiLibAllocateZeroPool (Len);
+
+ if (BrowserCallbackBuffer != NULL)
+ {
+ EfiStrCpy (BrowserCallbackBuffer, BrowserCallbackContent);
+ EfiStrCat (BrowserCallbackBuffer, ResultsData);
+
+ status = WriteDataToFile(BrowserCallbackFilename, BrowserCallbackBuffer, Len,0) ;//EIP-123312 resolve build issue
+ if (!EFI_ERROR (status))
+ {
+ HpkFileCount++ ;
+ }
+
+ MemFreePointer(&BrowserCallbackBuffer);
+ }
+ }
+#endif
+
+
+ bufferSize = (EfiStrLen (ResultsData) + EfiStrLen (configHdr) + 2) * sizeof (CHAR16);
+ configResp = EfiLibAllocateZeroPool (bufferSize);
+ ASSERT (configResp != NULL);
+
+ EfiStrCpy (configResp, configHdr);
+ EfiStrCat (configResp, L"&");
+ EfiStrCat (configResp, ResultsData);
+
+ //
+ // Update Browser uncommited data
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] _ConfigRespToStorage()\n" );
+ status = _ConfigRespToStorage (varInfo, &buffer, &size, configResp);
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] _ConfigRespToStorage returned, status = 0x%x \n\n" , status );
+
+ if (EFI_ERROR (status))
+ {
+ goto DONE;
+ }
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Displaying Browser Uncommited Data Buffer, VariableName: %s, VariableHandle: 0x%x\n\n", varInfo->VariableName, varInfo->VariableHandle );
+
+#if TSE_DEBUG_MESSAGES
+ DebugShowBufferContent(size, buffer);
+#endif
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "\n[TSE] Updating Browser Uncommited Data\n" );
+ if (varIndex == VARIABLE_ID_BBS_ORDER)
+ {
+ if(gCurrLegacyBootData)
+ {
+ UINT16 CurLegBootDataValid = 0;
+ UINT32 i;
+ for (i = 0; i < gBootOptionCount; i++ )
+ {
+ if ( &gBootData[i] == gCurrLegacyBootData )
+ CurLegBootDataValid = 1;
+ }
+ if(CurLegBootDataValid)
+ CurrentBootOption = gCurrLegacyBootData->Option;
+ else
+ gCurrLegacyBootData = NULL;
+ }
+ gCurrLegacyBootData = BootGetBootData(CurrentBootOption);
+ if(gCurrLegacyBootData)
+ status = VarSetValue(varIndex, 0, size, buffer);
+ }
+ else
+ status = VarSetValue(varIndex, 0, size, buffer);
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Updating Browser Uncommited Data returned, status = 0x%x \n\n" , status );
+ }
+DONE:
+//MEMFREE
+ if(configResp)
+ {
+ MemFreePointer(&configResp);
+ }
+
+ if(buffer)
+ {
+ MemFreePointer(&buffer);
+ }
+
+ if(configHdr)
+ {
+ MemFreePointer(&configHdr);
+ }
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "\n[TSE] Exiting BrowserCallback(), status = 0x%x \n\n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _StorageToConfigResp
+//
+// Description:
+//
+// Parameter: VARIABLE_INFO *VariableInfo
+// VOID *Buffer
+// CHAR16 *ConfigHdr
+// CHAR16 **ConfigResp
+//
+// Return value:EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _StorageToConfigResp(VARIABLE_INFO *VariableInfo, VOID *Buffer, CHAR16 *ConfigHdr, CHAR16 **ConfigResp)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STRING Progress;
+ CHAR16 *configHdr = NULL;
+ UINTN length = 0;
+
+ length = EfiStrLen(ConfigHdr) * sizeof(CHAR16);
+ configHdr = (CHAR16*)EfiLibAllocateZeroPool(length + 2);
+ if(configHdr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ MemCopy(configHdr, ConfigHdr, length);
+
+ //
+ // Generate <BlockName>
+ //
+ status = GetBlockName(&configHdr, &length, VAR_ZERO_OFFSET, VariableInfo->VariableSize);
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ if((VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) == VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }else
+ {
+ //
+ // VARIABLE_ATTRIBUTE_VARSTORE
+ //
+ status = HiiInitializeProtocol();
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ status = gHiiConfigRouting->BlockToConfig(gHiiConfigRouting, configHdr, Buffer,
+ VariableInfo->VariableSize, ConfigResp, &Progress);
+ }
+
+DONE:
+ if(configHdr) //EIP81617
+ {
+ MemFreePointer(&configHdr);
+ }
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ConfigRespToStorage
+//
+// Description:
+//
+// Parameter: VARIABLE_INFO *VariableInfo
+// VOID **Buffer
+// UINTN *Size
+// EFI_STRING ConfigResp
+//
+// Return value:EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ConfigRespToStorage(VARIABLE_INFO *VariableInfo, UINT8 **Buffer, UINTN *Size, EFI_STRING ConfigResp)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ if((VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) == VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }else
+ {
+ EFI_STRING stringPtr = NULL;
+ EFI_STRING tempPtr = NULL;
+ UINTN length = 0;
+ UINT16 *sizeBuf = NULL;
+
+ stringPtr = ConfigResp;
+ //
+ // Get Buffer data Size
+ //
+ for(stringPtr = ConfigResp; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&WIDTH=", EfiStrLen(L"&WIDTH=")) != 0; stringPtr++);
+ stringPtr += EfiStrLen(L"&WIDTH=");
+ tempPtr = stringPtr;
+ for(; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&VALUE=", EfiStrLen(L"&VALUE=")) != 0; length++, stringPtr++);
+ sizeBuf = (CHAR16*)EfiLibAllocateZeroPool(length + 1);
+ if(sizeBuf == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ EfiCopyMem(sizeBuf, tempPtr, length);
+ status = GetHexStringAsBuffer(Buffer, sizeBuf);
+ MemFreePointer(&sizeBuf);
+ if(EFI_ERROR(status))
+ {
+ *Size = 0;
+ goto DONE;
+ }
+ //
+ // Get Buffer Data
+ //
+ for(; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&VALUE=", EfiStrLen(L"&VALUE=")) != 0; stringPtr++);
+ stringPtr += EfiStrLen(L"&VALUE=");
+ status = GetHexStringAsBuffer(Buffer, stringPtr);
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure : FormBrowserHandleValid
+//
+// Description : return True Browser is showing forms from SendForm interface.
+//
+// Input : none
+//
+// Output : BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN FormBrowserHandleValid(VOID)
+{
+#if SETUP_FORM_BROWSER_SUPPORT
+ if(gSfHandles)
+ return TRUE;
+#endif
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure : FormBrowserLocateSetupHandles
+//
+// Description : return Handles and count that is passed to SendForm interface.
+//
+// Input : OUT handleBuffer and count
+//
+// Output : Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FormBrowserLocateSetupHandles(VOID* **handleBuffer,UINT16 *count)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+#if SETUP_FORM_BROWSER_SUPPORT
+ if(gSfHandles)
+ {
+ *handleBuffer = (VOID**)gSfHandles;
+ *count = (UINT16)gSfHandleCount;
+ }
+ else
+ {
+ status = EFI_NOT_FOUND;
+ }
+#else
+ status = EFI_UNSUPPORTED;
+#endif
+ return status;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/FormBrowser2.h b/EDK/MiniSetup/uefi2.1/FormBrowser2.h
new file mode 100644
index 0000000..1ba0808
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/FormBrowser2.h
@@ -0,0 +1,156 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2004, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 6145-F Northbelt Pkwy, Norcross, GA 30071 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 9 $
+//
+// $Date: 10/18/12 6:04a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.h $
+//
+// 9 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 4 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 8 9/17/12 6:22a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 6 9/08/12 3:53p Premkumara
+// [TAG] EIP 100546
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Old core(such as 4.6.4.0) is not building successfully with
+// latest TSE
+// [RootCause] BROWSER_ACTION related request macro are not defined in
+// TSE
+// [Solution] Defined BROWSER_ACTION related request macros in
+// FormBrowser2.h
+// [Files] FormBrowser2.h
+//
+// 5 12/07/11 8:13a Rajashakerg
+// [TAG] EIP75118
+// [Category] Improvement
+// [Description] xtractConfig() fail since BrowserCallback() cannot find
+// the variable to process
+// [Files] FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
+// Uefi21Wapper.c, PopupSel.c
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 8:50p Madhans
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 2 4/14/09 12:36p Presannar
+// Added Fn prototype FormBrowserLocateSetupHandles and
+// FormBrowserHandleValid
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 1 12/29/08 4:46p Presannar
+// FormBrowser2 protocol Send Form and BrowserCallback initial draft
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: FormBrowser2.h
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//----------------------------------------------------------------------------
+#ifndef _FORM_BROWSER2_H
+#define _FORM_BROWSER2_H
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+#include "Minisetup.h"
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+//----------------------------------------------------------------------------
+//Added for UEFI spec. 2.3 compatibility- EIP-100546 Start
+#ifndef EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
+#define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT 4
+#endif
+
+#ifndef EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
+#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT 5
+#endif
+
+#ifndef EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
+#define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY 6
+#endif
+
+#ifndef EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
+#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD 7
+#endif
+//Added for UEFI spec. 2.3 compatibility- EIP-100546 End
+VOID SetCallBackControlInfo(EFI_HANDLE VarHandle, UINT32 VarIndex);
+
+EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle);
+VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle);
+
+EFI_STATUS
+EFIAPI
+SendForm (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN EFI_HII_HANDLE *Handles,
+ IN UINTN HandleCount,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN UINT16 FormId, OPTIONAL
+ IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
+ );
+
+EFI_STATUS
+EFIAPI
+BrowserCallback (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN OUT UINTN *ResultsDataSize,
+ IN OUT EFI_STRING ResultsData,
+ IN BOOLEAN RetrieveData,
+ IN CONST EFI_GUID *VariableGuid, OPTIONAL
+ IN CONST CHAR16 *VariableName OPTIONAL
+ );
+
+EFI_STATUS FormBrowserLocateSetupHandles(VOID* **handleBuffer,UINT16 *count);
+BOOLEAN FormBrowserHandleValid(VOID);
+
+#endif /* #define _FORM_BROWSER2_H */
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/Hii.c b/EDK/MiniSetup/uefi2.1/Hii.c
new file mode 100644
index 0000000..d648b80
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Hii.c
@@ -0,0 +1,3557 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Hii.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 59 $
+//
+// $Date: 9/05/14 2:40p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Hii.c $
+//
+// 59 9/05/14 2:40p Premkumara
+// Moved GetSetDefaultsFromControlPtr() function from Uefi2.1\Hii.c to
+// TseAdvanced.c
+//
+// 58 8/28/14 12:35p Premkumara
+// [TAG] EIP175492
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Refresh_ID is not working in for static and dynamic
+// controls
+// [RootCause] RefreshGroupOnCallBack was not getting called after
+// signaling the RefreshId Event due to incorrect RefreshEventGroupId
+// [Solution] Assigning correct RefreshEventGroupId to the RefreshId
+// Event so that RefreshGroupOnCallBack will get called after signaling
+// the Event
+// [Files] Hii.c
+//
+// 57 8/28/14 6:51a Premkumara
+// [TAG] EIP93340
+// [Category] Improvement
+// [Description] - Defaults can be given to string type controls using tag
+// "Default = STRING_TOKEN(STR_DEFAULT_STRING)".
+// - New token TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL is introduced for
+// this support.
+// - Enabling this TSE_SUPPORT_DEFAULT_FOR_STRING_CONTROL token will
+// display default string mention in setup.
+// - On loading optimal defaults also string will load default mentioned
+// in default value tag.
+// [Files] AMITSE.sdl, HiiString21.c, TseAdvanced.c, MiniSetupExt.c, Hii.c
+//
+// 56 5/02/14 12:44a Arunsb
+// [TAG] EIP150526
+// [Category] Bug Fix
+// [Severity:] Important
+// [Symptom:] TSE hangs on disconnecting and connecting the RAID driver
+// [Root Cause] Process pack updated on processing the existing pack
+// update
+// [Solution] First we getting remove and new pack.
+// On getting this TSE starts processing the pack(ProcessPackNotification)
+// but on processing the pack itself we getting notification again for
+// remove and add.
+// So again process pack happens inside notification
+// itself(IFRChangeNotifyFn), this processing should not happen inside
+// notification so enabled flag gEnableProcessPack in PageHandleAction.
+// [Files] hii.c, minisetupext.c and page.c
+//
+// 55 2/11/14 8:53p Arunsb
+// [TAG] EIP132359
+// [Category] Bug Fix
+// [Root Cause] The ParentPageID in the destination page of the Ref3
+// control is not updated.
+// [Solution] In the function UpdateIFRRefXControls,
+// update the ParentPageID in the destination page of the Ref3 control.
+// [Files] hii.c
+//
+// 54 12/04/13 2:54a Premkumara
+// [TAG] EIP139099
+// [Category] New Feature
+// [Description] Supress formset other than
+// EFI_HII_PLATFORM_SETUP_FORMSET_GUID and
+// EFI_HII_DRIVER_HEALTH_FORMSET_GUID through elink based on token
+// [Files] AMITSE.sdl, AMITSE.mak, CommonOem.c, Hii.c, Parse.c,
+// TseUefiHii.h
+//
+// 53 6/10/13 12:10p Arunsb
+// EIP122907. Refresh opcode event stopped when its pack removed
+//
+// 52 5/22/13 10:57a Arunsb
+// Read write opcodes variable number retrieved in special way using
+// GetRWVariableID function.
+//
+// 51 5/21/13 1:31a Arunsb
+// [TAG] EIP122350
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup hangs on first goto after entering from Shell twice
+// [RootCause] HiiExit not happened for all the cases so offsets behaved
+// abruptly
+// [Solution] HiiExit invoked for all the possible cases
+// [Files] Hii.c
+//
+// 50 4/18/13 5:56a Arunsb
+// [TAG] EIP105468
+// [Category] New Feature
+// [Description] Support for EFI_IFR_REFRESH_ID opcode for Offline
+//
+// 49 4/17/13 2:57p Arunsb
+// [TAG] EIP109812, 107774
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_TYPE_REF and EFI_IFR_REF5
+// [Files] Hii.c, HiiCallback.c, Parse.c and TseUefiHii.h
+//
+// 48 4/16/13 9:40a Arunsb
+// Missed HII structures added in TSE itself.
+//
+// 47 4/02/13 8:08a Arunsb
+// [TAG] EIP113919, EIP114842
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_WRITE, EFI_IFR_READ,
+// EFI_IFR_GET, EFI_IFR_SET and EFI_IFR_MAP_OP.
+// [Files] Setupdata.h, ctrlcond.c, expression.c, hii.c and parse.c
+//
+// 46 3/25/13 8:06a Premkumara
+// [TAG] EIP105468
+// [Category] New Feature
+// [Description] Support for EFI_IFR_REFRESH_ID opcode for Offline
+// Parsing
+// [Files] Parse.c, Hii.c, Setupdata.h
+//
+// 45 2/25/13 10:57a Blaines
+// [TAG] - EIP 104273
+// [Category] - Action Item
+// [Description] - Provide ability to dump the Hii Pack from the Setup as
+// part TSE debug Infrastructure. It should dump the Pack updates on Hii
+// notification also.
+// So it can be used to debug the issue.
+// [Files] - ForBrowser2.c, Hii.c, HiiNotificationHandler.c,
+// UefiWapper.c, TseUefiHii.h
+//
+// 44 11/09/12 2:33a Arunsb
+// EIP 105965 : No. of root pages can be more than hii handle because of
+// AMITSE_SUBPAGE_AS_ROOT_PAGE_LIST_SUPPORT
+//
+// 43 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 21 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 41 9/18/12 2:14a Rajashakerg
+// [TAG] EIP88658
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Minisetup crashes after controller reconnection during Hii
+// callback
+// [RootCause] Minisetup crashes after controller reconnection during
+// callback. since we have new packs and new handles.
+// [Solution] Additional checks for invalid ptrs were added
+// [Files] Hii.c, Parse.c, Uefi21Wapper.c
+//
+// 40 9/17/12 6:22a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 38 9/08/12 11:42a Arunsb
+// [TAG] EIP99059
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] _ReInitializeSetupdataPointers function crashes in Hii.C
+// when DyanmicPage processed with PageIdListSize =0
+// [RootCause] Hii pack notification installed for
+// SETUP_RUNTIME_IFR_PROCESSING is disabled also
+// [Solution] Hii pack notification installed only if
+// SETUP_RUNTIME_IFR_PROCESSING is enabled
+// [Files] commonhelper.c and Hii.c
+//
+// 37 5/29/12 4:44a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 36 5/28/12 11:14a Premkumara
+// [TAG] EIP83080
+// [Category] Improvement
+// [Description] Support REF4 type control.
+// [Files] TseDrvHealth.h, Hii.c
+//
+// 35 5/27/12 3:29a Arunsb
+// [TAG] EIP90809
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup hang
+// [RootCause] gFailsafeDefaults memory corruption between
+// _MergeVariableListAndInfo and TseVarBuildAMIDefaults
+// [Solution] Removed the memory corruption
+// [Files] Hii.c
+//
+// 34 2/03/12 4:49a Rajashakerg
+// Defaults not saved for special variables.
+//
+// 33 12/07/11 3:11p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 32 12/05/11 5:51a Rajashakerg
+// [TAG] EIP76381
+// [Category] Improvement
+// [Description] Performance: Improving variable data load and usage
+// [Files] callback.c, minisetupext.c, variable.c, variable.h,
+// minisetup.h, Hii.c, FormBrowser2.c
+//
+// 31 11/30/11 1:36p Premkumara
+// [TAG] EIP75352
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
+// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
+//
+// 30 11/30/11 6:36a Premkumara
+// [TAG] EIP71351
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup Crash when iSCSI is loaded
+// [RootCause] Aptio giving length as 0xe(matches size of
+// EFI_IFR_ONE_OF_OPTION) but in latest EDKII driver it is 0x1c.
+// [Solution] change the length as j += ((EFI_IFR_OP_HEADER*)(buff + i +
+// j))->Length;
+// [Files] Parse.c, Hii.c, Variable.c, Minisetupext.c,
+//
+// 29 11/28/11 2:23a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 28 11/22/11 1:00p Arunsb
+// EIP72540 offline pages not included in run time parsing. Extra
+// provision provided to hide particular page. But this needs
+// customization.
+//
+// 27 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 26 11/14/11 4:22a Arunsb
+// [TAG] EIP72540
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Advance page disappear on using 4.6.2_TSE_2_14_1219
+// [RootCause] Offline pages also considered in dynamic parsing
+// [Solution] Offline pages are not considered in dynamic parsing
+// [Files] hii.c and parse.c.
+//
+// 25 7/19/11 10:50a Blaines
+// [TAG] - EIP 63262
+// [Category]- Defect
+// [Symptom]- Setup page display problem on rose city.
+// When SETUP_GROUP_DYNAMIC_PAGES is enabled and Network Stack is enabled,
+// the "iSCSI" menu is listed as a dynamic page in advanced menu but only
+// 3 of 4 "Port Configuration" pages shows up. The TSE dynamic page count
+// is incorrect.
+//
+// [Solution]- In the functions (RTIfrProcessRunTimeForms,
+// HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack), make sure the
+// nvram cache is updated by calling
+// VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT) when updating
+// "DynamicPageCount" variable name.
+// .
+// [Files] - Hii.c, Minisetup.h, Variable.h
+//
+// 24 7/01/11 3:27a Arunsb
+// Removed unwanted header for chm file creation.
+//
+// 23 6/30/11 4:17a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Sets the driver health support variable.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 22 6/28/11 8:26a Arunsb
+// EIP56405: Commented the build time parsing code.
+// Name value not supported by current vfr compiler.
+// Uncomment the codes once vfr compiler supports it.
+//
+// 21 6/23/11 4:03p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 20 6/22/11 4:47p Arunsb
+// [TAG] EIP56405
+// [Category] New Feature
+// [Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+// [Files] Hii.c, parse.c and uefi21wapper.c
+//
+// 19 6/20/11 10:39a Rajashakerg
+// [TAG] EIP57402
+// [Category] New Feature
+// [Description] Support for EFI_IFR_DEFAULT_2 opcode.
+// [Files] Hii.c
+//
+// 18 6/01/11 5:22p Blaines
+// [TAG] 61122
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] If SETUP_ORPHAN_PAGES_AS_ROOT_PAGE=1, HiiExit() will cause
+// an ASSERT in pool.c if debug_mode is enabled.
+// [RootCause] HiiExit() exit attempts to free gSetupData elements
+// associated with orphaned forms..
+// [Solution] Only free gSetupData[i].FormSet if
+// gSetupData[i].FormSetLength is non-zero.
+// [Files] Hii.c
+//
+// 17 4/29/11 4:41p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted.
+//
+// 14 3/28/11 5:08p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 13 2/10/11 1:44p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Modification] - Update DynamicPageCount variable on HandleNewIFRPack,
+// HandleRemoveIFRPack, and HandleAddIFRPack notifications.
+//
+// 12 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 11 12/28/10 12:31p Madhans
+// To update the Tag of EIp 46998. UEFI option ROM menus disappear in
+// Setup when certain options are selected.
+// No file changed but Comment updated right
+//
+// 10 12/02/10 2:38p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 9 10/27/10 4:25p Madhans
+// [TAG] EIP46998
+// [Category] Defect
+// [Symptom] Some user action on PCIx with UEFI Hii Pages causes Setup
+// screen pages and menu disappers.
+// [RootCause] UEFI 2.1 parsing code is not handling the Removepack and
+// New pack sequance properly. Normally UpdatePack
+// does the removepack and AddPack.
+// [Solution] UEFI 2.1 parsing code fixed to handle above case correctly.
+// [Files] hii.c HiiNotificationHandler.c Parse.c TseUefiHii.h
+// uefi21wapper.c
+//
+// 8 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 18 8/12/10 1:11p Blaines
+// EIP-40946 : Fix root page processing to support Award Style setup.
+//
+// 17 7/07/10 7:47p Madhans
+// To fix the Variables when new forms dynamically added.
+//
+// 16 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 15 6/17/10 2:46p Madhans
+// Fix in Classcode/Subclass finding function.
+//
+// 14 6/14/10 7:14p Madhans
+// Dynamic parsing support
+//
+// 13 6/14/10 7:04p Blaines
+// Fix to correctly check if FormSet length has changed and if so Parse
+// it. This fixes the issue with duplicate ClassID and SubClassID.
+//
+// 12 3/11/10 5:42p Madhans
+// Coding Standards Update
+//
+// 11 2/19/10 8:39p Madhans
+//
+// 10 2/19/10 8:35p Madhans
+// Function header fix
+//
+// 7 1/12/10 11:12a Presannar
+// Modified code to update Handle for the Variable Info referenced.
+//
+// 6 1/11/10 11:14a Presannar
+// Get The Variable Info referenced by Control Variable
+// BugFix - Remove code to set Extended Attributes
+//
+// 5 11/19/09 5:31p Presannar
+// Updated TSE include file name to not clash with CORE file
+// Added code to support Dynamic Notification
+// Commented fn. HiiGetEfiKey
+//
+// 4 8/24/09 12:13p Madhans
+// EIP 25092 : Fix to Use the HiiChangeString() to Add the string for
+// morethen one langs. with the same token.
+//
+// 3 8/12/09 8:08a Mallikarjunanv
+// moved the Hii function 'HiiGetEfiKey' from commonoem.c to hii.c
+//
+// 2 8/11/09 2:46p Presannar
+// Renamed _HiiGetForm to HiiGetForm
+// Modified HiiGetForm by moving retrieving form by ID to another function
+// GetFormByFormID
+// Added new fns HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack
+// and _FxiupNotificationData for dynamic parsing of IFR data
+// Added new fn GetFormByFormID, GetNextForm for form manipulation
+// Added Fns _ReInitializeSetupdataPointers to reinitialize setupdata
+// pointers.
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 4 4/24/09 7:53p Presannar
+// Bug fixes
+//
+// 3 4/14/09 12:39p Presannar
+// Added fn implementation for GetFormSetTitleAndHelp
+//
+// 2 3/31/09 4:15p Madhans
+// UEFI Wrapper improvments.
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 8 10/08/08 6:42p Presannar
+// Removed function PreparePackageList
+// removed call to get UEFI 2.1 HII ImageProtocol
+//
+// 7 8/22/08 4:56p Madhans
+// To skip the Formsets, thier subclass type is not
+// EFI_SETUP_APPLICATION_SUBCLASS.
+// fix resolve parentpageid for nested sub page that is out of order. (To
+// consider case where form are refered after it is defined in the VFR).
+//
+// 6 8/20/08 4:51p Presannar
+// Code Snippet Added to Check if a Form Pack indeed contains a Formset.
+//
+// 5 8/05/08 3:44p Presannar
+// Updated code snippets for functions _AddVariable, HiiFixupData,
+// _ParseForm, _UpdeateDefaults, _AddHpkControls.
+// Added new code snippets functions _CheckAndAddVariable,
+// _GetControlKeytoken, _GetControlDevicePathId,
+// _UpdateVariableDevicePathId.
+//
+// 4 7/23/08 6:09p Presannar
+// Fixed infinite loop Bug for function _IsFormFound
+//
+// 3 7/21/08 2:08p Madhans
+// Fix to add the condition control for the first control
+//
+// 2 7/17/08 11:48a Madhans
+// To fix the issue of the last control it is supposed.
+//
+// 1 6/12/08 6:40p Madhans
+// Minisetup Standalone Application for UEFI 2.1
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Hii.c
+//
+// Description: Contains Hii related Functions
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//----------------------------------------------------------------------------
+#include "minisetup.h"
+#include "TseDrvHealth.h" //EIP-83080
+#include "TseUefiHii.h"
+#ifndef TSE_FOR_APTIO_4_50
+#define EFI_HII_PACKAGE_FORMS EFI_HII_PACKAGE_FORM
+#include "tianohii.h"
+#endif
+//----------------------------------------------------------------------------
+// MACRO DEFINITIONS
+//----------------------------------------------------------------------------
+#define MAX_DEV_PATH_STR_LEN 100 //EIP: 55762
+
+//----------------------------------------------------------------------------
+// EXTERN VARIABLES
+//----------------------------------------------------------------------------
+extern UINTN gLangCount;
+extern UINTN gDynamicPageCount;
+extern UINT32 gRefreshIdCount;
+extern REFRESH_ID_INFO *gRefreshIdInfo;
+
+//----------------------------------------------------------------------------
+// VARIABLE DECLARATIONS
+//----------------------------------------------------------------------------
+static SETUP_LINK *gSetupData = NULL;
+static EFI_HII_HANDLE *gSetupHandles;
+static EFI_HANDLE gNotifyHandle[3];
+EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *gDevPathToTextProtocol = (EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *)NULL;//EIP-83080 starts
+EFI_GUID gDevPathToTextGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;//EIP-83080 Ends
+VOID *gFirstPageRef;
+PAGE_ID_INFO *PageIdInfoPtr;
+PAGE_ID_LIST *PageIdListPtr;
+PAGE_INFO *PageInfoPtr;
+PAGE_INFO *FirstPage;
+PAGE_INFO *NewPageInfo;
+PAGE_LIST *PageListPtr;
+VARIABLE_LIST *VariableListPtr;
+VARIABLE_INFO *VariableInfoPtr;
+BOOLEAN gHiiInitialized = FALSE;
+UINT32 AllocatedFirstPageSize, FirstPageOffset;
+UINT32 ControlListSize, ControlListOffset;
+UINT32 PageIdListSize, PageIdListOffset;
+UINT32 PageIdInfoSize, PageIdInfoOffset;
+UINT32 PageListSize, PageListOffset;
+UINT32 PageInfoSize, PageInfoOffset;
+UINT32 VariableListSize, VariableListOffset;
+UINT32 VariableInfoSize, VariableInfoOffset;
+UINTN TotalRootPages;
+UINTN gSetupCount = 0;
+EFI_GUID *gGuidDump=NULL; //EIP64253 offline vfr pages hided
+UINTN gGuidDumpCount=0;
+
+//----------------------------------------------------------------------------
+// FUNCCTION DECLARATIONS
+//----------------------------------------------------------------------------
+EFI_HII_HANDLE *_HiiGetHandles (UINT16 *NumberOfHiiHandles);
+EFI_IFR_FORM_SET *_HiiGetFormSet (UINTN index);
+
+
+EFI_STATUS _HiiLocateSetupHandles (VOID);
+EFI_STATUS _MergePageIdListAndInfo (VOID);
+EFI_STATUS _MergePageListAndInfo (VOID);
+EFI_STATUS _MergeVariableListAndInfo (VOID);
+EFI_STATUS _GetClassSubClassID (SETUP_LINK *SetupData);
+EFI_STATUS GetAcknowledgementKey ();
+EFI_STATUS _ReInitializeSetupdataPointers ();
+
+UINT16 _IsFormFound (EFI_IFR_FORM_SET *formSet, UINT16 formid);
+UINT16 _HiiGetLinkIndex (EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid);
+VOID UIUpdateCallback (VOID * Handle, UINT32 OldVariableCount);
+EFI_STATUS _FxiupNotificationData(SETUP_LINK *Setup_Link);
+
+EFI_STATUS UpdateIFRRefXControls (PAGE_INFO *PageInfo, CONTROL_INFO * CtrlInfo);//EIP: 55762 Start
+EFI_STATUS GetPageIdFromGuid (EFI_GUID *FormGuid, UINT16 PageFormID, UINT16 *PageID);//EIP: 55762 End
+VOID SetDriverHealthCount (VOID);//EIP57661 Starts Driver health support
+BOOLEAN IsDriverHealthSupported (VOID);//EIP57661 Ends
+EFI_STATUS CreateEventforIFR (CONTROL_INFO *control_Info );//EIP-105468
+
+
+
+VOID FixMergePagesExtraHook (VOID *gPages, VOID *tempPages);
+VOID PageRemoveHook (UINTN PageIndex, void *pageInfo, void *PageHandle, UINT16 PageFormID);
+
+////////////////////////////////////
+// Externing Functions
+///////////////////////////////////
+extern BOOLEAN IsSupportDefaultForStringControl (VOID);
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: HiiGetForm
+//
+// Description: Get HII form package by handle and form ID
+//
+// Input: EFI_HII_HANDLE Handle
+// UINT16 form
+// UINTN *Length
+//
+// Output: VOID *formPkBuffer -
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *HiiGetForm( EFI_HII_HANDLE Handle, UINT16 form, UINTN *Length )
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_HII_PACKAGE_HEADER *pkgHdr;
+ EFI_IFR_OP_HEADER *opHeader = NULL;
+
+ VOID *hiiFormPackage=NULL;
+ UINT8 *formPkBuffer = NULL;
+ UINT8 *pkgOffset;
+// UINT8 *msgBoxSel = NULL;
+ UINT8 end = 0;
+ UINT32 offset = 0;
+ UINTN len=10;
+ SETUP_LINK DummySetupLink;
+
+ if(Length == NULL)
+ Length = &len;
+
+ hiiFormPackage = EfiLibAllocateZeroPool(*Length);
+
+ status = gHiiDatabase->ExportPackageLists(gHiiDatabase, Handle, Length, hiiFormPackage);
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ MemFreePointer(&hiiFormPackage);
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ hiiFormPackage = EfiLibAllocateZeroPool(*Length);
+
+ if (hiiFormPackage == NULL)
+ {
+ hiiFormPackage = NULL;
+ goto DONE;
+ }
+ //
+ // Get all the packages associated with this HiiHandle
+ //
+ status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, Length, hiiFormPackage);
+ if(EFI_ERROR(status))
+ {
+ MemFreePointer(&hiiFormPackage);
+ hiiFormPackage = NULL;
+ goto DONE;
+ }
+ }else if(EFI_ERROR(status))
+ {
+ hiiFormPackage = NULL;
+ goto DONE;
+ }
+
+ offset = sizeof(EFI_HII_PACKAGE_LIST_HEADER);
+
+ while(offset < ((EFI_HII_PACKAGE_LIST_HEADER*)hiiFormPackage)->PackageLength)
+ {
+ pkgOffset = ((UINT8*)hiiFormPackage) + offset;
+ pkgHdr = (EFI_HII_PACKAGE_HEADER*)pkgOffset;
+ switch(pkgHdr->Type)
+ {
+ case EFI_HII_PACKAGE_FORMS:
+ formPkBuffer = (UINT8*)EfiLibAllocateZeroPool(pkgHdr->Length);
+ if(formPkBuffer == NULL)
+ {
+ goto DONE;
+ }
+ MemCopy(formPkBuffer, pkgHdr, pkgHdr->Length);
+ opHeader = (EFI_IFR_OP_HEADER*)((UINT8*)formPkBuffer + sizeof(EFI_HII_PACKAGE_HEADER));
+ if(opHeader->OpCode != EFI_IFR_FORM_SET_OP)
+ {
+#ifdef STANDALONE_APPLICATION
+ CHAR16 *Temp = L"ERROR! Form Package contains No FormSet. Skipping Package Processing.\x0a\x0dPress a Key to Continue :\x0a\x0d";
+ gST->ConOut->OutputString(gST->ConOut,Temp);
+ status = GetAcknowledgementKey();
+ if(EFI_ERROR(status))
+ {
+ gST->ConOut->OutputString(gST->ConOut, L"GetAcknowledgementKey returned ERROR!");
+ }
+#endif
+ MemFreePointer(&formPkBuffer);
+ formPkBuffer = NULL;
+ *Length = 0;
+ goto DONE;
+ }
+ // to check is the formset is EFI_SETUP_APPLICATION_SUBCLASS.
+ MemSet(&DummySetupLink,sizeof(DummySetupLink),0);
+ DummySetupLink.FormSet = formPkBuffer;
+ if(_GetClassSubClassID(&DummySetupLink) == EFI_UNSUPPORTED)
+ {
+ MemFreePointer(&formPkBuffer);
+ formPkBuffer = NULL;
+ *Length = 0;
+ goto DONE;
+ }
+ end = 1;
+ break;
+ case EFI_HII_PACKAGE_END:
+ end = 1;
+ break;
+ default:
+ break;
+ }
+ if (end)
+ {
+ break;
+ }
+ offset += pkgHdr->Length;
+ }
+ MemFreePointer(&hiiFormPackage);
+ if(form && (NULL != formPkBuffer))//EIP-75384 Static code
+ {
+ UINT8 *tempForm = NULL;
+ tempForm = GetFormByFormID((EFI_HII_PACKAGE_HEADER *)formPkBuffer, form, Length);
+ MemFreePointer(&formPkBuffer);
+ formPkBuffer = tempForm;
+ }
+
+DONE:
+ return formPkBuffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetClassSubClassID
+//
+// Description:
+//
+// Parameter: VOID *DefValue
+//
+// Return value: EFI_STATUS - The status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS _GetClassSubClassID(SETUP_LINK *SetupData)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)NULL;
+ BOOLEAN flag = TRUE;
+ INTN inScope = 0;
+
+ if(SetupData->FormSet == NULL)
+ {
+ return EFI_UNSUPPORTED;
+ }
+
+ SetupData->ClassID = 0;
+ SetupData->SubClassID = 0;
+ opHeader = (EFI_IFR_OP_HEADER*)(SetupData->FormSet + sizeof(EFI_HII_PACKAGE_HEADER));
+ do
+ {
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_GUID_OP:
+ {
+ UINT8 extOpcode = (UINT8)*((UINT8*)opHeader + sizeof(EFI_IFR_GUID));
+ switch(extOpcode)
+ {
+ case EFI_IFR_EXTEND_OP_CLASS:
+ {
+ EFI_IFR_GUID_CLASS *guidClass = (EFI_IFR_GUID_CLASS*)opHeader;
+ SetupData->ClassID = guidClass->Class;
+ }
+ break;
+ case EFI_IFR_EXTEND_OP_SUBCLASS:
+ {
+ EFI_IFR_GUID_SUBCLASS *guidSubClass = (EFI_IFR_GUID_SUBCLASS*)opHeader;
+ SetupData->SubClassID = guidSubClass->SubClass;
+ flag = FALSE;
+ }
+ break;
+ }
+ }
+ break;
+ case EFI_IFR_END_OP:
+ if(inScope)
+ {
+ inScope--;
+ }
+ default:
+ break;
+ }
+
+ if(opHeader->Scope)
+ {
+ inScope++;
+ }
+ opHeader = (EFI_IFR_OP_HEADER*)((UINT8*)opHeader + opHeader->Length);
+ } while(flag && inScope > 0);
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _MergePageIdListAndInfo
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _MergePageIdListAndInfo()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN i;
+
+ if((PageIdListOffset + PageIdInfoOffset) == 0)
+ {
+ gPageIdList = NULL;
+ gPageIdInfo = NULL;
+ return status; // NO Formset to show.
+ }
+
+ gPageIdList = (PAGE_ID_LIST*)EfiLibAllocateZeroPool(PageIdListOffset + PageIdInfoOffset);
+ if(gPageIdList == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ MemCopy(gPageIdList,PageIdListPtr,PageIdListOffset);
+ MemCopy(((UINT8 *)gPageIdList)+ PageIdListOffset,PageIdInfoPtr,PageIdInfoOffset);
+
+ for(i=0; i<gPageIdList->PageIdCount; i++)
+ {
+ gPageIdList->PageIdList[i] += PageIdListOffset;
+ }
+
+ gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]);
+
+ //Free Temp Memory
+ MemFreePointer(&PageIdInfoPtr);
+ MemFreePointer(&PageIdListPtr);
+
+DONE:
+ return status;
+}
+//EIP: 55762 Start
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SpecialControlsFixup
+//
+// Description: Fixes control information for special control in the varstore
+//
+// Parameter: None
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SpecialControlsFixup()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN i,j;
+ VARIABLE_INFO *varInfo = NULL;
+
+ for(i = 0; i < gPages->PageCount; i++)
+ {
+ PAGE_INFO *PageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[i]);
+ if(!PageInfo){
+ continue;
+ }
+ for ( j = 0; j < PageInfo->PageControls.ControlCount; j++ )
+ {
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO*)(((UINTN)gControlInfo) + PageInfo->PageControls.ControlList[j]);
+ if(!ctrlInfo){
+ continue;
+ }
+
+ UpdateIFRRefXControls(PageInfo, ctrlInfo); //Update the CONTROL_INFO with REFX information
+
+
+ }
+ }
+ for ( i = 0; i < gVariables->VariableCount; i++)
+ {
+ varInfo = (VARIABLE_INFO *)((UINT8 *)gVariables + gVariables->VariableList[i]);
+ if(!varInfo){
+ continue;
+ }
+ for(j = 0; j < gGuidList->GuidCount; j++)
+ {
+ GUID_INFO *GuidInfo = (GUID_INFO *)((UINTN)gGuidList + gGuidList->GuidList[j]);
+ if(GuidInfo && EfiCompareGuid(&varInfo->VariableGuid, &GuidInfo->GuidValue))
+ {
+ switch(GuidInfo->GuidKey)
+ {
+ //case GUID_KEY_NO_COMMIT:
+ // varInfo->ExtendedAttibutes = AMI_SPECIAL_NO_COMMIT_VARIABLE;
+ // break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return status;
+}
+//EIP: 55762 End
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _MergePageListAndInfo
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_OUT_OF_RESOURCES
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _MergePageListAndInfo()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN i;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering _MergePageListAndInfo()\n" );
+
+ gApplicationData = (UINT8*)EfiLibAllocateZeroPool(PageListOffset + FirstPageOffset + PageInfoOffset);
+ if(gApplicationData == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ gPages = (PAGE_LIST *) gApplicationData;
+ MemCopy(gApplicationData, PageListPtr, PageListOffset);
+ MemCopy(gApplicationData + PageListOffset, FirstPage, FirstPageOffset);
+ MemCopy(gApplicationData + PageListOffset + FirstPageOffset, PageInfoPtr, PageInfoOffset);
+
+ //Fix Offsets
+ i=0;
+ gPages->PageList[i] = PageListOffset;
+ i++;
+
+ for(; i < gPages->PageCount; i++)
+ {
+ gPages->PageList[i] += (FirstPageOffset + PageListOffset);
+ }
+
+ //Free Temp Memory
+ MemFreePointer(&FirstPage);
+ MemFreePointer(&PageInfoPtr);
+ MemFreePointer(&PageListPtr);
+//EIP: 55762 Start
+ SpecialControlsFixup(); //Fixes control information for special control in the varstore
+//EIP: 55762 End
+DONE:
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exitingg _MergePageListAndInfo(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _MergeVariableListAndInfo
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _MergeVariableListAndInfo()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN i;
+
+ //EIP-71351 Try to reallocate the existing Variable Cache.
+ if (gVariables->VariableCount != VariableListPtr->VariableCount) //EIP 90809 Reallocating only when counts varies
+ {
+ if(gVariableList != NULL)
+ gVariableList = MemReallocateZeroPool( gVariableList, sizeof(NVRAM_VARIABLE) * gVariables->VariableCount, VariableListPtr->VariableCount * sizeof(NVRAM_VARIABLE));
+
+ if(gOptimalDefaults != NULL)
+ gOptimalDefaults = MemReallocateZeroPool( gOptimalDefaults, sizeof(NVRAM_VARIABLE) * gVariables->VariableCount, VariableListPtr->VariableCount * sizeof(NVRAM_VARIABLE));
+
+ if(gFailsafeDefaults != NULL)
+ gFailsafeDefaults = MemReallocateZeroPool( gFailsafeDefaults, sizeof(NVRAM_VARIABLE) * gVariables->VariableCount, VariableListPtr->VariableCount * sizeof(NVRAM_VARIABLE));
+ }
+
+ gVariables = (VARIABLE_LIST*)EfiLibAllocateZeroPool(VariableListOffset + VariableInfoOffset);
+ if(gVariables == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ MemCopy(gVariables,VariableListPtr,VariableListOffset);
+ MemCopy(((UINT8 *)gVariables)+ VariableListOffset,VariableInfoPtr,VariableInfoOffset);
+
+ for(i=0; i<gVariables->VariableCount; i++)
+ {
+ gVariables->VariableList[i] += VariableListOffset;
+ }
+
+ //Free Temp Memory
+ MemFreePointer(&VariableInfoPtr);
+ MemFreePointer(&VariableListPtr);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiExit
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS - Return the Status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrUnRegFormNotificationWrapper (VOID);
+EFI_STATUS HiiExit()
+{
+ UINTN i;
+
+ //Remove gSetupHandles
+ MemFreePointer((VOID**)&gSetupHandles);
+
+ // Remove memory held by gSetupData
+ for ( i = 0; i < gSetupCount; i++ )
+ {
+ //EIP:61122, Free memory only if gSetupData[i].FormSetLength is non-zero.
+ if(gSetupData[i].FormSetLength)
+ MemFreePointer(&(gSetupData[i].FormSet));
+ }
+ MemFreePointer(&gSetupData);
+ gSetupCount = 0;
+
+ MemFreePointer(&gControlInfo);
+ ControlListSize = ControlListOffset = 0;
+
+ MemFreePointer(&gApplicationData);
+ gPages = gToolPages;
+ PageListPtr = NULL;
+ PageInfoPtr = NULL;
+ FirstPage = NULL;
+ AllocatedFirstPageSize = FirstPageOffset = PageListSize = PageListOffset = PageInfoSize = PageInfoOffset = 0;
+
+//#if SETUP_RUNTIME_IFR_PROCESSING
+ RTIfrProcessExitWrapper();
+//#endif
+
+ gVariables = gToolVariables;
+ gPageIdList = gToolPageIdList;
+ gPageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[0]);
+
+ RTIfrUnRegFormNotificationWrapper (); //EIP99059
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UnRegFormNotification
+//
+// Description: Unregisters the form notification
+//
+// Parameter: VOID
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UnRegFormNotification (VOID)
+{
+ UnRegisterFormNotification (gNotifyHandle[0]);
+ UnRegisterFormNotification (gNotifyHandle[1]);
+ UnRegisterFormNotification (gNotifyHandle[2]);
+}
+
+VOID FixupPage0ControlInfo( UINTN FormSet, UINTN ControlPtr, EFI_HII_HANDLE Handle)
+{
+ PAGE_INFO *pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[0]);
+ CONTROL_INFO *controlInfo = NULL;
+ UINT32 j;
+
+ if(pageInfo->PageControls.ControlCount)
+ {
+ for ( j = 0; j < pageInfo->PageControls.ControlCount; j++ )
+ {
+ controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + pageInfo->PageControls.ControlList[j]);
+ if( (ControlPtr-FormSet) == (UINTN)controlInfo->ControlPtr )
+ {
+ controlInfo->ControlHandle = Handle;
+ controlInfo->ControlPtr = (VOID*)ControlPtr;
+ }else{
+ if(controlInfo->ControlType == CONTROL_TYPE_NULL)
+ controlInfo->ControlHandle = Handle;
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RegFormNotification
+//
+// Description: Registers the hii pack notification
+//
+// Parameter: VOID
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RegFormNotification (VOID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ status = RegisterFormNotification(IFRChangeNotifyFn, EFI_HII_DATABASE_NOTIFY_NEW_PACK, &gNotifyHandle[0]);
+ if (EFI_ERROR(status))
+ {
+ return status;
+ }
+ status = RegisterFormNotification(IFRChangeNotifyFn, EFI_HII_DATABASE_NOTIFY_REMOVE_PACK, &gNotifyHandle[1]);
+ if (EFI_ERROR(status))
+ {
+ return status;
+ }
+ status = RegisterFormNotification(IFRChangeNotifyFn, EFI_HII_DATABASE_NOTIFY_ADD_PACK, &gNotifyHandle[2]);
+ if (EFI_ERROR(status))
+ {
+ return status;
+ }
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiFixupData
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS - Return the Status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RTIfrRegFormNotificationWrapper (VOID);
+extern EFI_GUID RefreshEventGroupId;
+EFI_STATUS HiiFixupData()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ PAGE_INFO *pageInfo = NULL;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_IFR_REF *ref = NULL;
+ //UINT16 *varString;
+ //UINT16 StringToken = 0;
+ UINT16 link;
+ UINT32 i=0;
+ UINT32 j=0;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering HiiFixupData()\n" );
+ if (PageListOffset || FirstPageOffset || PageInfoOffset) //EIP122350 If handofftse invoked second time then offsets incrementing from current so exiting and reforming.
+ {
+ HiiExit();
+ }
+ status = RTIfrRegFormNotificationWrapper (); //EIP99059
+ if (EFI_ERROR (status))
+ goto DONE;
+ status = _HiiLocateSetupHandles();
+ if (EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ gSetupData = EfiLibAllocateZeroPool(sizeof(SETUP_LINK) * gSetupCount);
+ if(gSetupData == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ for(i = 0; i < gSetupCount - 1; i++)
+ {
+ gSetupData[i].FormSet = HiiGetForm(gSetupHandles[i], 0, &(gSetupData[i].FormSetLength));
+ if(gSetupData[i].FormSet == NULL)
+ {
+ // make sure the handle is also zero
+ gSetupData[i].Handle = 0 ;
+ continue;
+ }
+ gSetupData[i].Handle = gSetupHandles[i];
+ formSet = (EFI_IFR_FORM_SET*)_HiiGetFormSet(i);
+
+ _GetClassSubClassID(&gSetupData[i]);
+
+#if TSE_DEBUG_MESSAGES
+ WritePackToFile(SETUPDATAFILENAME,
+ gSetupData[i].Handle,
+ NULL,
+ gSetupData[i].FormSetLength) ;
+#endif
+ }
+
+
+ // need to allocate one more dynamic IFR for the root page, this is NOT a 100% valid
+ // formset as there is no form defined
+ gSetupData[i].FormSet = EfiLibAllocateZeroPool(sizeof(EFI_HII_PACKAGE_HEADER) +
+ sizeof(EFI_IFR_FORM_SET) + /*i*/ gToolPages->PageCount * sizeof(EFI_IFR_REF)); //EIP 105965 : No. of root pages can be more then hii handle because of AMITSE_SUBPAGE_AS_ROOT_PAGE_LIST_SUPPORT
+ if(gSetupData[i].FormSet == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ formSet = (EFI_IFR_FORM_SET*)_HiiGetFormSet(i);
+ MemCopy(&(formSet->Guid),&(gSetupPkg->PackageGuid),sizeof(EFI_GUID));
+
+ TotalRootPages = 0;
+ if ( gSetupData[i].FormSet != NULL )
+ {
+ ref = (EFI_IFR_REF *)(gSetupData[i].FormSet + sizeof(EFI_HII_PACKAGE_HEADER) + sizeof(EFI_IFR_FORM_SET));
+ for ( j = 1; j <= gToolPages->PageCount; j++ )
+ {
+ pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[j]);
+ if ( pageInfo->PageParentID != 0 ) //if ( pageInfo->PageFormID != 1 )
+ {
+ continue;
+ }
+
+ TotalRootPages++;
+
+ link = _HiiGetLinkIndex(&(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid),
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageClass,
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass,
+ pageInfo->PageFormID);
+
+ if ( link == (gSetupCount - 1) )
+ {
+ continue;
+ }
+
+ formSet = (EFI_IFR_FORM_SET*)_HiiGetFormSet(link);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == formSet){
+ continue;
+ }
+ ref->Header.OpCode = EFI_IFR_REF_OP;
+ ref->Header.Length = sizeof(EFI_IFR_REF);
+ ref->Question.Header.Prompt = formSet->FormSetTitle;
+ ref->Question.Header.Help = formSet->Help;
+ FixupPage0ControlInfo( (UINTN)gSetupData[i].FormSet, (UINTN)ref, gSetupData[link].Handle);
+ ref++;
+ }
+ gSetupData[i].Handle = gSetupData[0].Handle;
+ }
+//#if SETUP_RUNTIME_IFR_PROCESSING
+ RTIfrProcessAddVarListAndPageIDListWrapper();
+//#endif //SETUP_RUNTIME_IFR_PROCESSING
+//EIP64253 offline vfr pages hided starts
+ i = 0;
+ if(gGuidDump == NULL)
+ {
+ gGuidDumpCount = gToolPages->PageCount;
+ gGuidDump = EfiLibAllocateZeroPool (sizeof (EFI_GUID) * gGuidDumpCount);
+ j = 0;
+ }
+ else
+ {
+ j = (UINT32) gGuidDumpCount;
+ gGuidDump = MemReallocateZeroPool (gGuidDump, gGuidDumpCount * sizeof (EFI_GUID), (gGuidDumpCount+gToolPages->PageCount) * sizeof (EFI_GUID));
+ gGuidDumpCount += gToolPages->PageCount;
+ }
+
+ if (NULL != gGuidDump)
+ {
+ for (i = 0; i < gToolPages->PageCount; i++)
+ {
+ PAGE_INFO *ParsepageInfo = NULL;
+ ParsepageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList [i]);
+
+ EfiCopyMem (&gGuidDump [i+j], &gToolPageIdInfo [ParsepageInfo->PageIdIndex].PageGuid, sizeof (EFI_GUID));
+ }
+ }
+//EIP64253 offline vfr pages hided ends
+ // update the control (IFR) pointers and HII handles
+ for ( i = 0; i< gToolPages->PageCount; i++ )
+ {
+// PAGE_INFO *NewPageInfo;
+ UINT32 PageSize;
+ UINT32 ControlSize;
+ CONTROL_INFO *NewControlInfo;
+ UINTN NoOfControlSpace;
+
+ pageInfo = (PAGE_INFO *)(((UINT8 *)gSetupPkg) + gToolPages->PageList[i]);
+
+ if(i == 0)
+ {
+ link = (UINT16)(gSetupCount - 1);
+ }
+ else
+ {
+ link = _HiiGetLinkIndex( &(gToolPageIdInfo[pageInfo->PageIdIndex].PageGuid),
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageClass,
+ gToolPageIdInfo[pageInfo->PageIdIndex].PageSubClass,
+ pageInfo->PageFormID);
+ }
+
+ NoOfControlSpace = pageInfo->PageControls.ControlCount ? pageInfo->PageControls.ControlCount - 1 : pageInfo->PageControls.ControlCount;
+ PageSize = (UINT32)(sizeof(PAGE_INFO) + sizeof(pageInfo->PageControls.ControlList) * NoOfControlSpace);
+ NewPageInfo = EfiLibAllocateZeroPool(PageSize);
+ if (NewPageInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(NewPageInfo,pageInfo,PageSize);
+
+ if ( link == (gSetupCount - 1) )
+ {
+ NewPageInfo->PageHandle = 0;// This page has been removed in runtime!!!
+ }
+ else
+ {
+//#if SETUP_RUNTIME_IFR_PROCESSING
+ if(RTIfrProcessFormIfUpdatedWrapper(link) == TRUE)
+ continue;
+//#endif //SETUP_RUNTIME_IFR_PROCESSING
+
+ NewPageInfo->PageHandle = gSetupData[link].Handle;
+ }
+
+ //Fixup and add the controls in this page to gContolInfo and update offsets in page info
+
+ if(NewPageInfo->PageControls.ControlCount)
+ {
+ for ( j = 0; j < NewPageInfo->PageControls.ControlCount; j++ )
+ {
+ VARIABLE_INFO *varInfo = NULL;
+ CONTROL_INFO *controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + NewPageInfo->PageControls.ControlList[j]);
+ //EIP:56413 Updated the contol size to copy the Default information for the control
+ ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2 + controlInfo->DefaultStoreCount * (sizeof(UINT16) + controlInfo->ControlDataWidth) ;
+
+ NewControlInfo = EfiLibAllocateZeroPool(ControlSize);
+ if (NewControlInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(NewControlInfo, controlInfo, ControlSize);
+
+ if(NewPageInfo->PageHandle != 0)
+ {
+ NewControlInfo->ControlHandle = gSetupData[link].Handle;
+
+ if ( NewControlInfo->ControlPtr != 0 )
+ {
+ NewControlInfo->ControlPtr = (VOID *)((UINTN)NewControlInfo->ControlPtr + (UINTN)gSetupData[link].FormSet);
+
+ if ( NewControlInfo->ControlFlags.RefreshID )//EIP-105468 & 175492
+ {
+ UINT32 index=0;
+ UINT8 *pOpcodeHeader=(UINT8 *)NewControlInfo->ControlPtr;
+ //search for the EFI_IFR_REFRESH_ID_OP.if Found then only type cast and assign RefreshEventGroupId and create event for IFR.
+ while(pOpcodeHeader)//EIP-175492
+ {
+ if(EFI_IFR_REFRESH_ID_OP == ((EFI_IFR_OP_HEADER *)(pOpcodeHeader))->OpCode)
+ {
+ MemCopy (&RefreshEventGroupId, &(((AMI_EFI_IFR_REFRESH_ID *)(pOpcodeHeader))->RefreshEventGroupId), sizeof (EFI_GUID));
+ CreateEventforIFR (NewControlInfo);
+ break;
+ }
+ if((((EFI_IFR_OP_HEADER *)(pOpcodeHeader))->Scope))//if OpcodeHeader has scope then, Increment index
+ index++;
+ if(EFI_IFR_END_OP == ((EFI_IFR_OP_HEADER *)(pOpcodeHeader))->OpCode)//if EFI_IFR_END_OP found then,decrement index
+ index--;
+ if(!index)
+ break;
+ pOpcodeHeader+=((EFI_IFR_OP_HEADER *)(pOpcodeHeader))->Length;//point to next opcode header depending upon the Length
+ }
+ }
+
+ if ( NewControlInfo->ControlConditionalPtr != 0 )
+ {
+ NewControlInfo->ControlConditionalPtr = (VOID *)((UINTN)NewControlInfo->ControlConditionalPtr + (UINTN)NewControlInfo->ControlPtr);
+ }
+ }
+ else if ( NewControlInfo ->ControlConditionalPtr != 0 )
+ {
+ NewControlInfo ->ControlConditionalPtr = (VOID *)((UINTN)NewControlInfo ->ControlConditionalPtr + (UINTN)gSetupData[link].FormSet);
+ }
+ // Get The Variable Info referenced by Control Variable
+ if (RTIfrUpdateVariableInfoWrapper (NewControlInfo->ControlVariable, gSetupData[link].Handle) == FALSE)
+ {
+ varInfo = VarGetVariableInfoIndex (NewControlInfo->ControlVariable);
+ if(varInfo->VariableHandle == NULL)
+ {
+ varInfo->VariableHandle = gSetupData[link].Handle;
+ }
+ //EIP56405: Commented for suppressing build time parsing. Name value not supported by current vfr compiler. Uncomment it once vfr compiler supports it.
+ /*if (VARIABLE_ATTRIBUTE_NAMEVALUE == (varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ if (0 == (EfiStrLen (varInfo->VariableName)))
+ {
+ StringToken = (UINT16)((UINT16)(varInfo->NameValueToken [1] << 8) + (UINT8)(varInfo->NameValueToken [0]));
+ varString = HiiGetString (varInfo->VariableHandle, StringToken);
+ EfiStrCpy (varInfo->VariableName, varString);
+ }
+ }*/
+ }
+ }
+ NewPageInfo->PageControls.ControlList[j] = AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo
+ MemFreePointer(&NewControlInfo);
+ }
+ }
+ else
+ {
+ // Add the Empty Control to control List even if NewPageInfo->PageControls.ControlCount = 0
+ CONTROL_INFO *controlInfo = (CONTROL_INFO*)((UINTN)gToolControlInfo + 0);
+ ControlSize = sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth * 2;
+ NewControlInfo = EfiLibAllocateZeroPool(ControlSize);
+ MemCopy(NewControlInfo, controlInfo, ControlSize);
+ AddControlToList(NewControlInfo,ControlSize); //Update new offset in gControlInfo
+ MemFreePointer(&NewControlInfo);
+ }
+
+ if(i==0)
+ {
+ status = CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset, NewPageInfo, PageSize);
+ }
+ else
+ {
+ status = AddPageToList(NewPageInfo,PageSize);
+ }
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ MemFreePointer(&NewPageInfo);
+ }
+
+//#if SETUP_RUNTIME_IFR_PROCESSING
+ RTIfrProcessRunTimeFormsWrapper(&ref);
+//#endif //SETUP_RUNTIME_IFR_PROCESSING
+
+ status = _MergePageListAndInfo();
+//EIP57661 Starts
+ if (IsDriverHealthSupported ())
+ {
+ SetDriverHealthCount ();
+ }
+//EIP57661 Ends
+DONE:
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting HiiFixupData(), status = 0x%x \n" , status );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _HiiLocateSetupHandles
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _HiiLocateSetupHandles()
+{
+ EFI_STATUS status;
+ UINT16 i = 0;
+ UINT16 count;
+ EFI_HII_HANDLE *handleBuffer;
+ UINT8 *buffer;
+ UINT16 found = 0;
+
+ status = HiiInitializeProtocol();
+ if (EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ if(FormBrowserLocateSetupHandles(&handleBuffer,&count)!= EFI_SUCCESS)
+ {
+ handleBuffer = _HiiGetHandles( &count );
+ }
+
+ if ( handleBuffer == NULL )
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ gSetupHandles = (EFI_HII_HANDLE*)EfiLibAllocatePool((count + 1) * sizeof(EFI_HII_HANDLE));
+ if ( gSetupHandles == NULL )
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ for ( i = found = 0; i < count; i++ )
+ {
+ buffer = HiiGetForm( handleBuffer[i], 0, NULL );
+ if ( buffer == NULL )
+ {
+ continue;
+ }
+
+ gSetupHandles[found] = handleBuffer[i];
+ found++;
+ MemFreePointer( &buffer );
+ }
+
+ gSetupCount = found + 1;
+
+ // at this point we have all the setup specific HII handles into our buffer
+DONE:
+
+ if(!FormBrowserHandleValid())
+ MemFreePointer((VOID**)&handleBuffer);
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _HiiGetLinkIndex
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _HiiGetLinkIndex(EFI_GUID *guid, UINT16 class, UINT16 subclass, UINT16 formid)
+{
+ UINT16 i;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_HII_PACKAGE_HEADER *pack;
+
+ for ( i = 0; i < gSetupCount - 1; i++ )
+ {
+ pack = (EFI_HII_PACKAGE_HEADER *)gSetupData[i].FormSet;
+
+ if ( sizeof(EFI_HII_PACKAGE_HEADER) == pack->Length )
+ {
+ continue;
+ }
+
+ formSet = (EFI_IFR_FORM_SET *)((UINT8 *)pack + sizeof(EFI_HII_PACKAGE_HEADER));
+
+ if(EfiCompareGuid( guid , (VOID *)&(formSet->Guid) ))
+ {
+ if( gSetupData[i].ClassID == class )
+ {
+ if( gSetupData[i].SubClassID == subclass )
+ {
+ if(_IsFormFound(formSet, formid))
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return i;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _HiiGetFormSet
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_IFR_FORM_SET
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_IFR_FORM_SET *_HiiGetFormSet(UINTN index)
+{
+ EFI_IFR_FORM_SET *formSet = NULL;
+
+ if ( (index >= gSetupCount) || (gSetupData == NULL))
+ {
+ return formSet;
+ }
+
+ formSet = (EFI_IFR_FORM_SET*)(gSetupData[index].FormSet + sizeof(EFI_HII_PACKAGE_HEADER));
+
+ return formSet;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _HiiGetHandles
+//
+// Description: gets all the HII handles
+//
+// Parameter: No of handles
+//
+// Return value: EFI_HII_HANDLE *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_HII_HANDLE *_HiiGetHandles(UINT16 *NumberOfHiiHandles)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_HII_HANDLE *hiiHandleBuffer = NULL;
+
+ UINTN handleBufferLength = 0;
+
+// gBS->AllocatePool(EfiBootServicesData, handleBufferLength,
+// (VOID **)&hiiHandleBuffer);
+ hiiHandleBuffer = EfiLibAllocatePool(handleBufferLength);
+
+ status = gHiiDatabase->ListPackageLists (gHiiDatabase, EFI_HII_PACKAGE_TYPE_ALL, NULL,
+ &handleBufferLength, hiiHandleBuffer);
+ if (status == EFI_BUFFER_TOO_SMALL)
+ {
+ //
+ // Free the old pool
+ //
+ MemFreePointer ((VOID**)&hiiHandleBuffer);
+ //
+ // Allocate new pool with correct value
+ //
+// gBS->AllocatePool (EfiBootServicesData, handleBufferLength,
+// (VOID **)&hiiHandleBuffer);
+ hiiHandleBuffer = EfiLibAllocatePool(handleBufferLength);
+
+ //
+ // Get the Handles of the packages that were registered with Hii
+ //
+ gBS->SetMem(hiiHandleBuffer,handleBufferLength,0);
+ status = gHiiDatabase->ListPackageLists (gHiiDatabase, EFI_HII_PACKAGE_TYPE_ALL,
+ NULL, &handleBufferLength, hiiHandleBuffer);
+
+ if (EFI_ERROR (status))
+ {
+ MemFreePointer((VOID**)&hiiHandleBuffer);
+ hiiHandleBuffer = NULL;
+ goto DONE;
+ }
+ }else if(EFI_ERROR(status))
+ {
+ MemFreePointer((VOID**)&hiiHandleBuffer);
+ hiiHandleBuffer = NULL;
+ goto DONE;
+ }
+
+ *NumberOfHiiHandles = (UINT16)(handleBufferLength / sizeof(EFI_HII_HANDLE));
+
+DONE:
+ return hiiHandleBuffer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _IsFormFound
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: UINT16 -
+// 1 Form Found
+// 0 Form Not Found
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _IsFormFound(EFI_IFR_FORM_SET *formSet,UINT16 formid )
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER*)formSet;
+ BOOLEAN flag = TRUE;
+ UINT16 found = 0;
+ UINTN offset = 0;
+ UINTN ScopeCount = 0;
+
+ while(flag)
+ {
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_FORM_OP:
+ {
+ EFI_IFR_FORM *formOp = (EFI_IFR_FORM*)opHeader;
+ if(formOp->FormId == formid)
+ {
+ found = 1;
+ flag = FALSE;
+ }
+ }
+ break;
+ case EFI_IFR_FORM_MAP_OP:
+ {
+ AMI_EFI_IFR_FORM_MAP *formMapOp = (AMI_EFI_IFR_FORM_MAP *)opHeader;
+ if(formMapOp->FormId == formid)
+ {
+ found = 1;
+ flag = FALSE;
+ }
+ }
+ break;
+ case EFI_IFR_END_OP:
+ flag = (--ScopeCount)? TRUE:FALSE;
+ break;
+ default:
+ break;
+ }
+ if(opHeader->Scope)
+ {
+ ScopeCount++;
+ }
+ offset += opHeader->Length;
+ opHeader = (EFI_IFR_OP_HEADER*)((UINT8*)formSet + offset);
+ }
+
+ return found;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiFindHandle
+//
+// Description: HiiFindHandle
+//
+// Parameter: EFI_GUID *guid, UINT16 *index
+//
+// Return value: EFI_HII_HANDLE
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_HII_HANDLE HiiFindHandle( EFI_GUID *guid, UINT16 *index )
+{
+ EFI_HII_HANDLE *handleBuffer = NULL;
+ EFI_HII_HANDLE handle = INVALID_HANDLE;
+ UINT16 found = 0;
+ UINT16 i, count;
+ UINTN len=10;
+ EFI_HII_PACKAGE_LIST_HEADER *hiiPackageList;
+ EFI_STATUS status=EFI_SUCCESS;
+
+ handleBuffer = _HiiGetHandles( &count );
+ if ( handleBuffer == NULL )
+ return handle;
+
+ for ( i = found = 0; i < count; i++ )
+ {
+ hiiPackageList = EfiLibAllocateZeroPool(len);
+
+ status = gHiiDatabase->ExportPackageLists(gHiiDatabase, handleBuffer[i], &len, hiiPackageList);
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ MemFreePointer(&hiiPackageList);
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ hiiPackageList = EfiLibAllocateZeroPool(len);
+
+ if (hiiPackageList == NULL)
+ {
+ hiiPackageList = NULL;
+ goto DONE;
+ }
+ //
+ // Get all the packages associated with this HiiHandle
+ //
+ status = gHiiDatabase->ExportPackageLists(gHiiDatabase, handleBuffer[i], &len, hiiPackageList);
+ if(EFI_ERROR(status))
+ {
+ MemFreePointer(&hiiPackageList);
+ hiiPackageList = NULL;
+ goto DONE;
+ }
+ }
+ if ( EfiCompareGuid( guid, &hiiPackageList->PackageListGuid ) )
+ {
+ if ( *index == found )
+ {
+ handle = handleBuffer[i];
+ (*index)++;
+ break;
+ }
+ found++;
+ }
+
+ MemFreePointer( &hiiPackageList );
+ }
+
+DONE:
+ MemFreePointer( (VOID **)&handleBuffer );
+ return handle;
+
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RTIfrProcessExit
+//
+// Description: RTIfrProcessExit
+//
+// Parameter: none
+//
+// Return value: none
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessExit(VOID)
+{
+ MemFreePointer(&gVariables);
+ VariableListPtr = NULL;
+ VariableInfoPtr = NULL;
+ VariableListOffset = VariableListSize = VariableInfoOffset = VariableInfoSize = 0;
+
+ MemFreePointer(&gPageIdList);
+ PageIdListPtr = NULL;
+ PageIdInfoPtr = NULL;
+ PageIdListOffset = PageIdListSize = PageIdInfoOffset = PageIdInfoSize = 0;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RTIfrProcessAddVarListAndPageIDList
+//
+// Description:
+//
+// Parameter: None
+//
+// Return value: None
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessAddVarListAndPageIDList(VOID)
+{
+ UINT32 i;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering RTIfrProcessAddVarListAndPageIDList()\n" );
+
+ //Create Variable List
+ for(i=0; i < gToolVariables->VariableCount ; i++)
+ {
+ VARIABLE_INFO *VariableInfo;
+
+ VariableInfo = (VARIABLE_INFO*)((UINT8*)gToolVariables + gToolVariables->VariableList[i]);
+ AddVariableToList(VariableInfo);
+ }
+
+ //Create Page ID list
+ for(i=0; i < gToolPageIdList->PageIdCount ; i++)
+ {
+ PAGE_ID_INFO *PageIdInfo;
+
+ PageIdInfo = (PAGE_ID_INFO*)((UINT8*)gToolPageIdList + gToolPageIdList->PageIdList[i]);
+ AddPageIdToList(PageIdInfo);
+ }
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting RTIfrProcessAddVarListAndPageIDList()\n" );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RTIfrProcessFormIfUpdated
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN RTIfrProcessFormIfUpdated(UINT16 link)
+{
+ UINT32 j;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering RTIfrProcessFormIfUpdated()\n" );
+
+ //Fix to correctly check if FormSet length has changed and if so Parse it. This fixes the issue with duplicate ClassID and SubClassID.
+
+ for(j=1; j < gToolPageIdList->PageIdCount; j++) // PAGE_ID_INFO[0] contains reference to the NULL page
+ {
+ //Check if the page has changed during run time
+ EFI_HII_PACKAGE_HEADER *pack;
+ PAGE_ID_INFO *pageIdList = (PAGE_ID_INFO *)((UINT8 *)gToolPageIdList + gToolPageIdList->PageIdList[j]);
+ EFI_IFR_FORM_SET *formSet = (EFI_IFR_FORM_SET*)((UINT8 *)gSetupData[link].FormSet + sizeof(EFI_HII_PACKAGE_HEADER));
+
+ // Compare if the FormSet triplet is already available
+ if((pageIdList->PageClass == gSetupData[link].ClassID) &&
+ (pageIdList->PageSubClass == gSetupData[link].SubClassID) &&
+ (EfiCompareGuid(&pageIdList->PageGuid, (VOID *)&formSet->Guid)))
+ {
+ pack = (EFI_HII_PACKAGE_HEADER *)gSetupData[link].FormSet;
+
+ if ( gHpkInfo[j-1].Length != pack->Length )
+ {
+ break;
+ }
+ }
+ }
+
+ if(j < gToolPageIdList->PageIdCount)
+ {
+ //This page changed during run time parse again
+ if(!gSetupData[link].Added)
+ {
+ ParseForm(&gSetupData[link]);
+ }
+ return TRUE;
+ }
+
+
+ gSetupData[link].Added = 1;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting RTIfrProcessFormIfUpdated()\n" );
+
+ return FALSE;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RTIfrProcessRunTimeForms
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: None
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrProcessRunTimeForms(EFI_IFR_REF **ref)
+{
+ UINT32 i;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_IFR_FORM_SET *formSet;
+ EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID;
+ UINTN count = 0;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering RTIfrProcessRunTimeForms()\n" );
+
+ if(!IsGroupDynamicPages()) //EIP: 59971
+ gFirstPageRef = (VOID*)(*ref);
+
+ for(i = 0; i < gSetupCount - 1; i++)
+ {
+ if(!(gSetupData[i].Added))
+ {
+ Status = ParseForm(&gSetupData[i]);
+ if((gSetupData[i].Added))
+ {
+ formSet = _HiiGetFormSet( i );
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == formSet){
+ continue;
+ }
+
+ if(!IsGroupDynamicPages()) //EIP: 59971
+ {
+ (*ref)->Header.OpCode = EFI_IFR_REF_OP;
+ (*ref)->Header.Length = sizeof(EFI_IFR_REF);
+ (*ref)->Question.Header.Prompt = formSet->FormSetTitle;
+ (*ref)->Question.Header.Help = formSet->Help;
+ (*ref)++;
+ gFirstPageRef = (VOID*)(*ref);
+ }
+
+ }
+ if (EFI_SUCCESS == Status) //To avoid increment count incase parsing is aborted and avoid showing sub-link under advanced page
+ count++ ;
+ }
+ }
+
+ gDynamicPageCount = count ;
+
+ //Set Dynamic page count variable
+ VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT); //EIP_63262: Update nvram cache for DynamicPageCount
+
+ _MergePageIdListAndInfo();
+ _MergeVariableListAndInfo();
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting RTIfrProcessRunTimeForms()\n" );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiLoadDefaults
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HiiLoadDefaults( VOID **varList, UINT32 Mask )
+{
+ // This function needs to be revisited once Aptio supports GetAltCfg
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 index = 0;
+
+ status = GetNvramVariableList((NVRAM_VARIABLE **)varList); // EIP 76381 : Performance Improving of variable data load and usage
+ if(EFI_ERROR(status)){
+ goto DONE;
+ }
+
+ // Get the Controls in each Page
+ for ( index = 0; index < gPages->PageCount; index++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO*)((UINT8 *)gPages + gPages->PageList[index]);
+ UINTN control = 0;
+
+ if(pageInfo->PageHandle == NULL)
+ {
+ continue;
+ }
+ // Get the Default values for each control and update DefaultStore
+ for(control = 0; control < pageInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(controlInfo->ControlDataWidth > 0)
+ {
+ UINT32 offset = 0;
+ UINTN width = 0;
+ UINT8 *defaultValue = NULL;
+
+ if( UefiIsEfiVariable(controlInfo->ControlVariable,VarGetVariableInfoIndex( controlInfo->ControlVariable ) ) )
+ continue;
+
+ offset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+ width = UefiGetWidth(controlInfo->ControlPtr);
+
+ defaultValue = (Mask & AMI_FLAG_MANUFACTURING)? ((UINT8*)controlInfo + sizeof(CONTROL_INFO)) :
+ ((UINT8*)controlInfo + sizeof(CONTROL_INFO) + controlInfo->ControlDataWidth);
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, *varList, controlInfo->ControlVariable, offset, width, defaultValue );
+ }
+ }
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiMyGetStringLength
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+{
+ CHAR16 *string;
+ UINTN length = 0;
+
+ string = HiiGetString( handle, token );
+ if ( string == NULL )
+ return length;
+
+ length = TestPrintLength( string ) / (NG_SIZE);
+ MemFreePointer( (VOID **)&string );
+
+ return length;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiMyGetMultiLineStringLength
+//
+// Description: returns Max length of the in the paragraph
+//
+// Input: Handle and token
+//
+// Output: Length
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token )
+{
+ CHAR16 *string;
+ UINTN length = 0,MaxLength=0;
+ UINTN i,j;
+
+ string = HiiGetString( handle, token );
+ if ( string == NULL )
+ return length;
+
+ i=j=0;
+ while(string[i])
+ {
+ // is Newline
+ if((string[i]==0x0d)&& (string[i+1]==0x0a))
+ {
+ string[i]=0x0;
+ length = TestPrintLength( &string[j] ) / (NG_SIZE);
+ if(length>MaxLength)
+ MaxLength = length;
+ i+=2;
+ j=i;
+ }
+ else
+ i++;
+ }
+ length = TestPrintLength( &string[j] ) / (NG_SIZE);
+ MemFreePointer( (VOID **)&string );
+
+ if(length>MaxLength)
+ MaxLength = length;
+
+ return MaxLength;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetAcknowledgementKey
+//
+// Description: Waits for a Key Press
+//
+// Parameter: VOID
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetAcknowledgementKey()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN Index;
+ EFI_INPUT_KEY Key;
+
+ //Flush Key Stroke
+ while(gST->ConIn->ReadKeyStroke( gST->ConIn, &Key ) == EFI_SUCCESS)
+ ;
+
+ status = gBS->WaitForEvent( 1, &gST->ConIn->WaitForKey, &Index );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ status = gST->ConIn->ReadKeyStroke( gST->ConIn, &Key );
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure : HiiChangeString
+//
+// Description : to change a existing string
+//
+// Input : VOID* handle, UINT16 token, CHAR16 *string
+//
+// Output : Status
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 HiiChangeString( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token, CHAR16 *string )
+{
+/* return HiiChangeStringLanguage( handle, token, L" ", string );*/
+ UINTN i;
+ UINT16 returntoken;
+ UINT16 status = token;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ returntoken = HiiChangeStringLanguage( handle, token, gLanguages[i].Unicode, string );
+ if (( token != returntoken ) && ( INVALID_TOKEN != returntoken ))
+ {
+ //EIP 25092 : Fix to Use the HiiChangeString() to Add the string for morethen one langs.
+ //with the same token.
+ token = status = returntoken;
+ }
+
+ }
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetFormSetTitleAndHelp
+//
+// Description: GetFormSetTitleAndHelp
+//
+// Parameter: EFI_HII_HANDLE Handle, EFI_STRING_ID *Title, EFI_STRING_ID *Help
+//
+// Return value: status
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetFormSetTitleAndHelp(EFI_HII_HANDLE Handle, EFI_STRING_ID *Title, EFI_STRING_ID *Help)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_FORM_SET *formSet = NULL;
+ UINT32 index = 0;
+ UINT8 *pkgHdr = NULL;
+
+
+ for(index = 0; index < gSetupCount; index++)
+ {
+ if(gSetupData[index].Handle == Handle)
+ {
+ pkgHdr = (UINT8*)gSetupData[index].FormSet;
+ formSet = (EFI_IFR_FORM_SET*)(pkgHdr + sizeof(EFI_HII_PACKAGE_HEADER));
+ *Title = formSet->FormSetTitle;
+ *Help = formSet->Help;
+ break;
+ }
+ }
+
+ if(index == gSetupCount)
+ {
+ status = EFI_INVALID_PARAMETER;
+ }
+
+ return status;
+}
+
+/*
+VOID HiiTestFormBrowser(EFI_HANDLE Handle )
+{
+ EFI_HII_HANDLE hHandle[3];
+ EFI_FORM_BROWSER2_PROTOCOL * pfb;
+
+ _HiiLocateSetupHandles();
+ hHandle[0] = gSetupHandles[1];
+ hHandle[1] = gSetupHandles[3];
+ hHandle[2] = gSetupHandles[4];
+
+ gBS->HandleProtocol(Handle,&gEfiFormBrowser2ProtocolGuid,&pfb);
+ pfb->SendForm(pfb,(EFI_HII_HANDLE *)&hHandle,3,NULL,0,NULL,NULL);
+}
+*/
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: HandleNewIFRPack
+//
+// Description: Added a new IFR pack data in gSetupData
+//
+// Input: EFI_HANDLE Handle - Formset handle
+// UINT8 *PackData - New pack data to add
+//
+// Output: EFI_STATUS status - EFI_OUT_OF_RESOURCES if memory allocation fails
+// EFI_SUCCESS if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HandleNewIFRPack(EFI_HANDLE Handle, UINT8 *PackData)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN length = 0;
+ UINTN oldSetupCount = 0, size = 0;
+ UINT8 *formSet = PackData;
+ UINT32 OldVariableCount = gVariables->VariableCount;
+ UINTN count = gDynamicPageCount;
+ EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n\n[TSE] Entering HandleNewIFRPack()\n\n" );
+
+ if(gSetupCount == 0)
+ {
+ goto DONE;
+ }
+
+ // Check if Handle contains an IFR formset
+ //formSet = (UINT8*)HiiGetForm(Handle, 0, &length);
+ if(NULL == formSet)
+ {
+ formSet = (UINT8*)HiiGetForm(Handle, 0, &length);
+ if (NULL == formSet)
+ {
+ goto DONE;
+ }
+ }
+
+ oldSetupCount = gSetupCount++;
+
+ // Reallocate gSetupHandles
+ gSetupHandles = MemReallocateZeroPool(gSetupHandles, oldSetupCount * sizeof (EFI_HII_HANDLE), gSetupCount * sizeof (EFI_HII_HANDLE));
+ if(gSetupHandles == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ gSetupHandles[oldSetupCount] = Handle;
+
+ // Reallocate and set gSetupData
+ gSetupData = MemReallocateZeroPool(gSetupData, oldSetupCount * sizeof(SETUP_LINK), gSetupCount * sizeof(SETUP_LINK));
+ if(gSetupData == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(&gSetupData[gSetupCount -1], &gSetupData[oldSetupCount -1], sizeof(SETUP_LINK));
+ gSetupData[gSetupCount -1].FormSet = formSet;
+ gSetupData[gSetupCount -1].Handle = Handle;
+ _GetClassSubClassID(&gSetupData[gSetupCount -1]);
+ status = _FxiupNotificationData(&gSetupData[gSetupCount -1]);
+ UIUpdateCallbackHook((VOID*)Handle, OldVariableCount); // EIP 129750 : Modified UIUpdateCallback as module hook
+
+ if (EFI_SUCCESS == status)//To avoid increment count incase parsing is aborted and avoid showing sub-link under advanced page
+ count++ ;
+ gDynamicPageCount = count ;
+ //Set Dynamic page count variable
+ VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT); //EIP_63262: Update nvram cache for DynamicPageCount
+
+DONE:
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n\n[TSE] Exiting HandleNewIFRPack: status = 0x%x \n\n" , status );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: HandleRemoveIFRPack
+//
+// Description: Removes a IFR pack data from gSetupData
+//
+// Input: EFI_HANDLE Handle - Formset handle
+//
+// Output: EFI_STATUS status - EFI_OUT_OF_RESOURCES if memory allocation fails
+// EFI_SUCCESS if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StopRefreshOpEvent (CONTROL_INFO *controlInfo);
+EFI_STATUS HandleRemoveIFRPack(EFI_HANDLE Handle)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN ii = 0, size = 0;
+ UINTN count = gDynamicPageCount;
+ EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n\n[TSE] Entering HandleRemoveIFRPack()\n\n" );
+
+ if(gSetupCount == 0)
+ {
+ goto DONE;
+ }
+
+ for(ii = 0; ii < gPages->PageCount; ii++)
+ {
+ UINTN control = 0;
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[ii]);
+
+ if(pageInfo->PageHandle != Handle)
+ {
+ continue;
+ }
+ for(control= 0; (control < pageInfo->PageControls.ControlCount); control++)
+ {
+ CONTROL_INFO *controlInfo = NULL;
+
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+ if (controlInfo->ControlFlags.RefreshID)
+ {
+ StopRefreshOpEvent (controlInfo);
+ }
+ controlInfo->ControlHandle = (VOID *)NULL;
+ }
+ PageRemoveHook (ii, (VOID *)pageInfo, pageInfo->PageHandle, pageInfo->PageFormID);
+ pageInfo->PageHandle = (VOID *)(UINTN)0xFFFF;
+ }
+
+ if(count)
+ {
+ count-- ;
+ gDynamicPageCount = count ;
+ //Set Dynamic page count variable
+ VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT); //EIP_63262: Update nvram cache for DynamicPageCount
+
+ }
+
+ // Find gSetupData and free memory
+ for(ii = 0; ii < gSetupCount - 1; ii++)
+ {
+ if(gSetupData[ii].Handle != Handle)
+ {
+ continue;
+ }
+ gSetupData[ii].ClassID = 0;
+ gSetupData[ii].FormSetLength = 0;
+ gSetupData[ii].Added = 0;
+ gSetupData[ii].SubClassID = 0;
+ MemFreePointer(&gSetupData[ii].FormSet);
+ break;
+ }
+DONE:
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n\n[TSE] Exiting HandleRemoveIFRPack: status = 0x%x \n\n" , status );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: HandleAddIFRPack
+//
+// Description: Adds a IFR pack data from gSetupData
+//
+// Input: EFI_HANDLE Handle - Formset handle
+// UINT8 *PackData - Update pack data to add
+//
+// Output: EFI_STATUS status - EFI_OUT_OF_RESOURCES if memory allocation fails
+// EFI_SUCCESS if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HandleAddIFRPack(EFI_HANDLE Handle, UINT8 *PackData)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN length = 0;
+ UINTN ii = 0, size = 0 ;
+ UINT32 OldVariableCount = gVariables->VariableCount;
+ UINTN count = gDynamicPageCount;
+ EFI_GUID DynamicPageGuid = DYNAMIC_PAGE_COUNT_GUID;
+ UINT8 *formSetData = PackData;
+
+
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n\n[TSE] Entering HandleAddIFRPack()\n" );
+
+ if(gSetupCount == 0)
+ {
+ goto DONE;
+ }
+
+ // Find gSetupData
+ for(ii = 0; ii < gSetupCount - 1; ii++)
+ {
+ if(gSetupHandles[ii] == Handle)
+ {
+ break;
+ }
+ }
+
+ if(NULL == formSetData)
+ {
+ formSetData = (UINT8*)HiiGetForm(Handle, 0, &length);
+ if(NULL == formSetData)
+ {
+ goto DONE;
+ }
+ }
+
+ // If iterator ii = gSetupCount - 1 (Should not be the case)
+ if(ii == gSetupCount - 1)
+ {
+ status = HandleNewIFRPack(Handle, formSetData);
+ goto DONE;
+ }
+
+ // Replace in gSetupData
+ gSetupData[ii].FormSet = formSetData;
+ _GetClassSubClassID(&gSetupData[ii]);
+ status = _FxiupNotificationData(&gSetupData[ii]);
+
+ UIUpdateCallbackHook((VOID*)Handle, OldVariableCount); // EIP 129750 : Modified UIUpdateCallback as module hook
+
+ if (EFI_SUCCESS == status)//To avoid increment count incase parsing is aborted and avoid showing sub-link under advanced page
+ count++ ;
+ gDynamicPageCount = count ;
+ //Set Dynamic page count variable
+ VarSetNvramName( L"DynamicPageCount", &DynamicPageGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &count, sizeof(count) );
+ VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT); //EIP_63262: Update nvram cache for DynamicPageCount
+
+DONE:
+ SETUP_DEBUG_UEFI_NOTIFICATION ( "\n[TSE] Exiting HandleAddIFRPack: status = 0x%x \n\n" , status );
+ return status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetFormByFormID
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID *GetFormByFormID(EFI_HII_PACKAGE_HEADER *IFRData, UINT16 FormID, UINTN *Length)
+{
+ EFI_IFR_OP_HEADER *opHeader = NULL;
+ UINTN formLength = 0;
+ UINTN offset = 0;
+ UINT8 *form = NULL;
+ UINT8 *formBegin = NULL;
+ BOOLEAN flag = TRUE;
+
+ offset = sizeof(EFI_HII_PACKAGE_HEADER);
+
+ ResetScopeStack();
+ do
+ {
+ EFI_IFR_FORM *formOp = NULL;
+ AMI_EFI_IFR_FORM_MAP *formMapOp = NULL;
+ UINT8 scope = 0;
+
+ opHeader = (EFI_IFR_OP_HEADER*)((UINT8*)IFRData + offset);
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_FORM_OP:
+ formOp = (EFI_IFR_FORM*)opHeader;
+ if(formOp->FormId == FormID)
+ {
+ formBegin = (UINT8*)opHeader;
+ }
+ break;
+ case EFI_IFR_FORM_MAP_OP:
+ formMapOp = (AMI_EFI_IFR_FORM_MAP *)opHeader;
+ if(formMapOp->FormId == FormID)
+ {
+ formBegin = (UINT8*)opHeader;
+ }
+ break;
+ case EFI_IFR_END_OP:
+ PopScope(&scope);
+ switch(scope)
+ {
+ case EFI_IFR_FORM_SET_OP:
+ flag = FALSE;
+ break;
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
+ if(formBegin)
+ {
+ flag = FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ if(opHeader->Scope)
+ {
+ PushScope(opHeader->OpCode);
+ }
+ if(formBegin)
+ {
+ formLength += opHeader->Length;
+ }
+ offset += opHeader->Length;
+ }while(flag);
+
+ if(formLength)
+ {
+ form = EfiLibAllocateZeroPool(formLength);
+ if (form == NULL)
+ {
+ goto DONE;
+ }
+ MemCopy(form, formBegin, formLength);
+ *Length = formLength;
+ }
+
+DONE:
+ ResetScopeStack();
+ return form;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetNextForm
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *GetNextForm(EFI_HII_PACKAGE_HEADER *Package, UINT8 **IFRDataPtr, UINTN *Length)
+{
+ UINT8 *form = NULL;
+ UINT8 *formBegin = NULL;
+ UINTN offset = 0;
+ UINTN formLen = 0;
+ UINTN formScope = 0;
+ BOOLEAN endForm = FALSE;
+
+ static UINTN scopeCount = 0;
+
+ if(Package == NULL)
+ {
+ goto DONE;
+ }
+ if(*IFRDataPtr == NULL)
+ {
+ *IFRDataPtr = (UINT8 *)Package + sizeof(EFI_HII_PACKAGE_HEADER);
+ scopeCount = 0;
+ }
+
+ do
+ {
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)(*IFRDataPtr + offset);
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
+ formBegin = (UINT8 *)opHeader;
+ break;
+ case EFI_IFR_END_OP:
+ scopeCount -= scopeCount? 1 : 0;
+ formScope -= formScope? 1 : 0;
+ endForm = formScope? FALSE : TRUE;
+ break;
+ default:
+ break;
+ }
+ if(opHeader->Scope)
+ {
+ scopeCount++;
+ formScope += formBegin? 1 : 0;
+ }
+ formLen += formBegin? opHeader->Length : 0;
+ offset+=opHeader->Length;
+ }while(endForm == FALSE);
+
+ if(formBegin)
+ {
+ form = EfiLibAllocateZeroPool(formLen);
+ if(form == NULL)
+ {
+ *Length = 0;
+ goto DONE;
+ }
+ MemCopy(form, formBegin, formLen);
+ *Length = formLen;
+ formBegin += formLen;
+ *IFRDataPtr += offset;
+ }
+
+DONE:
+ return form;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: FixSetupData
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FixSetupData()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN ii = 0;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering FixSetupData()\n" );
+
+ if(gIFRChangeNotify)
+ {
+ if(gRemovedHandle!=NULL)
+ {
+ UIUpdateCallbackHook((VOID*)gRemovedHandle, gVariables->VariableCount); // EIP 129750 : Modified UIUpdateCallback as module hook
+ gRemovedHandle = NULL;
+ gIFRChangeNotify = FALSE;
+ }
+ }
+//EIP 88658 : Minisetup crashes after controller reconnection during Hii callback
+ if((gApplicationData == NULL) || (gSetupCount == 0))
+ {
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+
+ for(ii = 0; ii < gPages->PageCount; ii++)
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[ii]);
+
+ if(pageInfo->PageHandle != (VOID *)(UINTN)0xFFFF)
+ {
+ continue;
+ }
+ pageInfo->PageHandle = NULL;
+ }
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting FixSetupData(), status = 0x%x \n" , status );
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _FxiupNotificationData
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _FxiupNotificationData(SETUP_LINK *Setup_Link)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ PAGE_ID_LIST *tempPageIdList = gPageIdList;
+ PAGE_LIST *tempPages = gPages;
+ VARIABLE_LIST *tempVariables = gVariables;
+
+ //ReInitialize Setupdata Pointers
+ _ReInitializeSetupdataPointers();
+ //Parse Form
+ Status = ParseForm(Setup_Link);
+ // Merge ListPtr and InfoPtr
+ _MergePageIdListAndInfo();
+ _MergeVariableListAndInfo();
+ _MergePageListAndInfo();
+
+ FixMergePagesExtraHook ((VOID *)gPages, (VOID *)tempPages );
+
+ // Free memory used by temp Ptrs
+ MemFreePointer((VOID**)&tempPageIdList);
+ MemFreePointer((VOID**)&tempPages);
+ MemFreePointer((VOID**)&tempVariables);
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ReInitializeSetupdataPointers
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ReInitializeSetupdataPointers()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 i = 0;
+
+ // Reinitialize PageIdListPtr and PageIdInfoPtr
+ PageIdListPtr = (PAGE_ID_LIST *)EfiLibAllocateZeroPool(PageIdListSize);
+ if(PageIdListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(PageIdListPtr, gPageIdList, PageIdListOffset);
+
+ //Fix Offsets
+ for(i=0; i < PageIdListPtr->PageIdCount; i++)
+ {
+ PageIdListPtr->PageIdList[i] -= PageIdListOffset;
+ }
+
+ PageIdInfoPtr = (PAGE_ID_INFO *)EfiLibAllocateZeroPool(PageIdInfoSize);
+ if(PageIdInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(PageIdInfoPtr, (UINT8 *)gPageIdList + PageIdListOffset, PageIdInfoOffset);
+
+ // Reinitialize PageListPtr, FirstPage and PageInfoPtr
+ PageListPtr = (PAGE_LIST *)EfiLibAllocateZeroPool(PageListSize);
+ if(PageIdListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(PageListPtr, gPages, PageListOffset);
+ //Fix Offsets
+ for(i = 0; i < PageListPtr->PageCount; i++)
+ {
+ PageListPtr->PageList[i] -= (i == 0)? PageListOffset : (FirstPageOffset + PageListOffset);
+ }
+
+ FirstPage = (PAGE_INFO *)EfiLibAllocateZeroPool(AllocatedFirstPageSize);
+ if(FirstPage == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(FirstPage, (UINT8 *)gPages + PageListOffset, FirstPageOffset);
+
+ PageInfoPtr = (PAGE_INFO *)EfiLibAllocateZeroPool(PageInfoSize);
+ if(PageInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(PageInfoPtr, (UINT8 *)gPages + PageListOffset + FirstPageOffset, PageInfoOffset);
+
+ // Reinitialize VariableInfoPtr and VariableListPtr
+ VariableListPtr = (VARIABLE_LIST *)EfiLibAllocateZeroPool(VariableListSize);
+ if(VariableListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(VariableListPtr, gVariables, VariableListOffset);
+
+ //Fix Offsets
+ for(i=0; i < VariableListPtr->VariableCount; i++)
+ {
+ VariableListPtr->VariableList[i] -= VariableListOffset;
+ }
+
+ VariableInfoPtr = (VARIABLE_INFO *)EfiLibAllocateZeroPool(VariableInfoSize);
+ if(VariableInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(VariableInfoPtr, (UINT8 *)gVariables + VariableListOffset, VariableInfoOffset);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: RTIfrUpdateVariableInfo
+//
+// Description: Wrapper function to include RTIfrUpdateVariableInfo
+// based on SDL token.
+//
+// Input: ControlVariable
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RTIfrUpdateVariableInfo( UINT32 ControlVariable, EFI_HANDLE Handle )
+{
+ VARIABLE_INFO *varInfo = NULL;
+// UINT16 *varString;
+// UINT16 StringToken = 0;
+
+
+ if (ControlVariable < VariableListPtr->VariableCount)
+ {
+ varInfo = (VARIABLE_INFO*)((UINT8*)VariableInfoPtr + VariableListPtr->VariableList[ControlVariable]);
+ if(varInfo->VariableHandle == NULL)
+ {
+ varInfo->VariableHandle = Handle;
+ }
+ //EIP56405: Commented for suppressing build time parsing. Name value not supported by current vfr compiler. Uncomment it once vfr compiler supports it.
+ /*if (VARIABLE_ATTRIBUTE_NAMEVALUE == (varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ if (0 == (EfiStrLen (varInfo->VariableName)))
+ {
+ StringToken = (UINT16)((UINT16)(varInfo->NameValueToken [1] << 8) + (UINT8)(varInfo->NameValueToken [0]));
+ varString = HiiGetString (varInfo->VariableHandle, StringToken);
+ EfiStrCpy (varInfo->VariableName, varString);
+ }
+ }*/
+ }else
+ {
+ // ERROR. This case should not Occur.If it Does then DOOM!!!
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetEfiKey
+//
+// Description: Function to Encode the password key
+//
+// Input: CHAR16 *PwKey
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HiiGetEfiKey(CHAR16 *PwKey)
+{
+// Need to fix this for UEFI 2.1
+/*
+ EFI_HII_KEYBOARD_LAYOUT *Key
+ EFI_KEY_DESCRIPTOR *pEfiKD = NULL; //, *pRetEfiKD = NULL;
+ UINT16 Count = 0,i;
+ EFI_STATUS Status;
+
+ if(EFI_SUCCESS != HiiInitializeProtocol())
+ return;
+
+ //Get Count (No Of Key board Desc)
+ Status= gHiiDatabase->GetKeyboardLayout(gHiiDatabase, NULL, &Count, pEfiKD);
+
+ if(EFI_BUFFER_TOO_SMALL != Status)
+ return;
+
+ if(Count)
+ {
+ //Allocate space for Count number of EFI_KEY_DESCRIPTOR
+ pEfiKD = EfiLibAllocateZeroPool(sizeof(EFI_KEY_DESCRIPTOR)*Count);
+
+ Status= gHiiDatabase->GetKeyboardLayout(gHiiDatabase, &Count, pEfiKD);
+
+ if(EFI_SUCCESS == Status)
+ {
+ for(i=0;i<Count;i++)
+ {
+ if((pEfiKD[i].Unicode == *PwKey) ||
+ (pEfiKD[i].ShiftedUnicode == *PwKey) ||
+ (pEfiKD[i].AltGrUnicode == *PwKey) ||
+ (pEfiKD[i].ShiftedAltGrUnicode == *PwKey)
+ )
+ {
+// pRetEfiKD = EfiLibAllocateZeroPool(sizeof(EFI_KEY_DESCRIPTOR));
+// MemCopy(pRetEfiKD, pEfiKD+i,sizeof(EFI_KEY_DESCRIPTOR));
+ *PwKey = (CHAR16)(pEfiKD+i)->Key;
+ break;
+ }
+ }
+ }
+ MemFreePointer((VOID **)&pEfiKD);
+ }
+*/
+}
+//EIP:56413 START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiupdateResetButtonDefault
+//
+// Description: Function to update defaults depending on the Default Id on Selecting the Reset Button
+//
+// Input: CONTROL_INFO ControlData, UINT16 DefaultId
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 control, offset = 0;
+ UINTN index=0, size = 0;
+ UINT8 *Defaultaddress = 0;
+
+ //Getting the current page info
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[ControlData.ControlPageID]);
+
+ if (NULL != pageInfo && 0 == pageInfo->PageHandle)
+ return EFI_UNSUPPORTED;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+ index=0;
+ //checking for the Default count of the control
+ while(index < controlInfo->DefaultStoreCount)
+ {
+ Defaultaddress = (UINT8 *)controlInfo + sizeof(CONTROL_INFO)+(controlInfo->ControlDataWidth * 2)+(index *(sizeof(UINT16) + controlInfo->ControlDataWidth));
+ //checking for the default Id of the Resetbutton
+ if(DefaultId == (UINT16)*Defaultaddress)
+ {
+ offset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+ size = UefiGetWidth(controlInfo->ControlPtr);
+ status = VarSetValue(controlInfo->ControlVariable, offset, size, Defaultaddress+sizeof(UINT16) );
+ }
+ index++;
+ }
+ //EIP:57402 Checking for the ControlEvaluateDefault Flag and the Default Id equal tp Manufacturing Id
+ if(controlInfo->ControlFlags.ControlEvaluateDefault)
+ {
+ UINT64 Defaults = 0 ;
+ UINT16 size = 0;
+ offset = UefiGetQuestionOffset(controlInfo->ControlPtr);
+
+ //EIP: 57402 Evaluating the Control Default
+ size = EvaluateControlDefault(controlInfo,&Defaults);
+ status = VarSetValue(controlInfo->ControlVariable, offset, size, &Defaults );
+ // EIP: 57402 Setiing the Evaluated value to the gOptimalDefaults
+ if(DefaultId == EFI_HII_DEFAULT_CLASS_MANUFACTURING)
+ _VarGetSetValue( VAR_COMMAND_SET_VALUE, gOptimalDefaults, controlInfo->ControlVariable, offset, size, &Defaults );
+ }
+ }
+
+ return status;
+
+}
+//EIP:56413 END
+
+//EIP-83080 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetDevPathFromHandle
+//
+// Description: Get the device path for the the given handle
+//
+// Input: EFI_HII_HANDLE HiiHandle - Input handle
+// EFI_DEVICE_PATH_PROTOCOL **DevicePath - Corresponding device path
+// if successful.
+//
+// Output: EFI_STATUS Status - EFI_SUCCESS, if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetDevPathFromHandle(EFI_HII_HANDLE HiiHandle, EFI_DEVICE_PATH_PROTOCOL **DevicePath)
+{
+ EFI_STATUS Status = EFI_INVALID_PARAMETER;
+ EFI_HANDLE DriverHandle = (EFI_HANDLE)NULL;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevPath = (EFI_DEVICE_PATH_PROTOCOL *)NULL;
+
+ *DevicePath = TempDevPath;
+
+ Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, HiiHandle, &DriverHandle);
+ if(EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->HandleProtocol (DriverHandle, &gEfiDevicePathProtocolGuid, &TempDevPath);
+ if(Status == EFI_SUCCESS){
+ *DevicePath = TempDevPath;
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetStringFromDevPath
+//
+// Description: Gets the string presentation of the given DevicePath
+//
+// Input: EFI_DEVICE_PATH_PROTOCOL *DevPath - Given device path
+// CHAR16 **DevPathStr - Return pointer to the string presentation
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetStringFromDevPath(EFI_DEVICE_PATH_PROTOCOL *DevPath, CHAR16 **DevPathStr)
+{
+ EFI_STATUS status = EFI_ABORTED;
+
+ if(gDevPathToTextProtocol == NULL)
+ {
+ status = gBS->LocateProtocol(&gDevPathToTextGuid, NULL, &gDevPathToTextProtocol);
+ }
+ if(gDevPathToTextProtocol != NULL)
+ {
+ *DevPathStr = gDevPathToTextProtocol->ConvertDevicePathToText(DevPath, FALSE, FALSE);
+ status = EFI_SUCCESS;
+ }
+ return status;
+}
+//EIP: 83080 End
+
+
+//EIP: 132359 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: FixIFRRefXControl
+//
+// Description: Updates the parent pageID for the EFI_IFR_REFX
+// control
+//
+// Input: CONTROL_INFO * CtrlInfo - Control Info in the library
+// PAGE_INFO *PageInfo - Page Info in the library
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FixIFRRefXControl(PAGE_INFO *PageInfo, CONTROL_INFO * CtrlInfo)
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+ UINT32 i=0;
+ PAGE_INFO *pageInfo;
+
+ for (i = 0; i < gPages->PageCount; i++)
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+ if (pageInfo->PageID == CtrlInfo->ControlDestPageID)
+ {
+ pageInfo->PageParentID = PageInfo->PageID ; //CtrlInfo->ControlPageID;
+ status = EFI_SUCCESS;
+ break;
+ }
+ }
+
+ return status;
+}
+//EIP: 55762 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UpdateIFRRefXControls
+//
+// Description: Updates the reference link information in for the EFI_IFR_REFX
+// controls
+//
+// Input: CONTROL_INFO * CtrlInfo - Control Info in the library
+// BOOLEAN *PgHasRefXCtrl - Return TRUE if REF4 control found
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UpdateIFRRefXControls(PAGE_INFO *PageInfo, CONTROL_INFO * CtrlInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_DEVICE_PATH_PROTOCOL *tempDevPath = (EFI_DEVICE_PATH_PROTOCOL *)NULL;
+ BOOLEAN IsQuestionIdValid = FALSE;
+ BOOLEAN IsFormSetIdValid = FALSE;
+ BOOLEAN IsDevicePathFound = FALSE;
+ EFI_GUID formSetGuid = {0}, zeroFormSetGuid = {0};
+ UINT16 ControlDestPageID = 0xFFFF;
+ UINT16 ControlDestQuestionID = 0xFFFF;
+ UINTN count = 0;
+ UINTN control = 0;
+ PAGE_INFO *pageInfo = (PAGE_INFO*)NULL;
+ PAGE_ID_INFO *pageIdInfo = (PAGE_ID_INFO*)NULL;
+
+ CHAR16 *devPathStr = (CHAR16 *)NULL, *tempDevPathStr = (CHAR16 *)NULL;
+
+ if((CtrlInfo == NULL) || (CtrlInfo->ControlPtr == NULL))
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ if(CtrlInfo->ControlHandle == NULL)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ if(((EFI_IFR_OP_HEADER*)CtrlInfo->ControlPtr)->OpCode != EFI_IFR_REF_OP)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //EIP109812, 107774
+ if(((EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr)->Length == sizeof(AMI_EFI_IFR_REF5)) //If AMI_EFI_IFR_REF5
+ {
+ if(CtrlInfo->ControlDataLength == sizeof(AMI_EFI_HII_REF)) //if default value is of size AMI_EFI_HII_REF, retrieve its value
+ {
+ AMI_EFI_HII_REF *Ref = NULL ;
+ Ref = (AMI_EFI_HII_REF*)((UINT8*)CtrlInfo + sizeof(CONTROL_INFO) + CtrlInfo->ControlDataLength); //take the default value
+ if(Ref)
+ {
+ //fetch the destination questionId
+ ControlDestQuestionID = Ref->QuestionId; //Set the destination question ID to set focus
+ if(Ref->DevicePath) //if device path is provided
+ {
+ devPathStr = HiiGetString(CtrlInfo->ControlHandle, Ref->DevicePath); //get the text representation of device path
+ if(devPathStr == NULL) //If the device path string is invalid, remain the same
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's question Id as the destination question Id.
+ goto DONE;
+ }
+ else
+ { //If the device path string is not NULL
+ CHAR16 *zeroDevPathStr = (CHAR16 *)EfiLibAllocateZeroPool(MAX_DEV_PATH_STR_LEN * sizeof(CHAR16));
+ if(zeroDevPathStr)
+ {
+ //MemSet(&zeroDevPathStr[0], MAX_DEV_PATH_STR_LEN * sizeof(CHAR16), L'0');
+ MemSet(&zeroDevPathStr[0], MAX_DEV_PATH_STR_LEN * sizeof(CHAR16), 0);
+ if(EfiStrCmp(devPathStr, zeroDevPathStr) == 0) //If the DevicePath string contains all zeros, remain the same page.
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's question Id as the destination question Id.
+ goto DONE;
+ }
+ }
+ }
+ //Device Path is not zero. check whether the provided device path is found.
+ for(count = 0; count < gPages->PageCount; count++)
+ {
+ PAGE_INFO *tempPageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[count]);
+ if(tempPageInfo == NULL)
+ {
+ continue;
+ }
+ status = GetDevPathFromHandle(tempPageInfo->PageHandle, &tempDevPath);
+ if((status == EFI_SUCCESS) && (tempDevPath != NULL))
+ {
+ GetStringFromDevPath(tempDevPath, &tempDevPathStr);
+ if(EfiStrCmp(devPathStr, tempDevPathStr) == 0) //if the provided device path is found
+ {
+ CtrlInfo->ControlDestPageID = tempPageInfo->PageID; //set that page ID
+ ControlDestPageID = tempPageInfo->PageID;
+ IsDevicePathFound = TRUE;
+ break;
+ }
+ }
+ }
+ if(!IsDevicePathFound) //if provided device path is not found, remain the same
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page;
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's page ID itself as destination page Id.
+ goto DONE;
+ }
+ }
+ else //if device path is not provided
+ {
+ //get formset GUID
+ MemCopy(&formSetGuid, &(Ref->FormSetGuid), sizeof (EFI_GUID));
+ if(EfiCompareGuid(&formSetGuid, &zeroFormSetGuid) == FALSE) //If it is not all zeroes
+ {
+ GetPageIdFromGuid(&formSetGuid, Ref->FormId, &ControlDestPageID);
+ if(ControlDestPageID != 0xFFFF) //If the destination page ID is valid
+ {
+ CtrlInfo->ControlDestPageID = ControlDestPageID; //Assign it to CONTROL_INFO->ControlDestPageID
+ IsFormSetIdValid = TRUE;
+ }
+ }
+ if(!IsFormSetIdValid) //if formset Id is invalid, remain the same
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page;
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's page ID itself as destination page Id.
+ goto DONE;
+ }
+ }
+ //at this point either through device path or formset ID the destination page ID will be obtained.
+ //check whether the provided Dest. Question ID exist in that destination page
+ pageInfo = (PAGE_INFO*)((UINT8 *)gPages + gPages->PageList[ControlDestPageID]);
+ if(pageInfo->PageHandle == NULL)
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page;
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's page ID itself as destination page Id.
+ goto DONE;
+ }
+ for(control = 0; control < pageInfo->PageControls.ControlCount; control++) //check if the destination Question ID is exists in any of
+ { //the availble controls of the page.
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+ if(ControlDestQuestionID == controlInfo->ControlKey)
+ {
+ IsQuestionIdValid = TRUE;
+ CtrlInfo->ControlDestPageID = ControlDestPageID; //Assign it to CONTROL_INFO->ControlDestPageID
+ CtrlInfo->DestQuestionID = ControlDestQuestionID;
+ break;
+ }
+ }
+ if(!IsQuestionIdValid) //if the provided Question ID is invalid, remain the same
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page;
+ CtrlInfo->DestQuestionID = CtrlInfo->QuestionId; //set the current control's page ID itself as destination page Id.
+ }
+ }
+ }
+ }
+
+ else if(((EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr)->Length >= sizeof(EFI_IFR_REF2)) //If EFI_IFR_REFX
+ {
+ CtrlInfo->DestQuestionID = ((EFI_IFR_REF2 *)CtrlInfo->ControlPtr)->QuestionId; //Set the destination question ID to set focus
+
+ if(((EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr)->Length >= sizeof(EFI_IFR_REF3)) //If EFI_IFR_REF3/EFI_IFR_REF4
+ {
+
+ MemCopy(&formSetGuid, &((EFI_IFR_REF3 *)CtrlInfo->ControlPtr)->FormSetId, sizeof (EFI_GUID));
+
+ if(EfiCompareGuid(&formSetGuid, &zeroFormSetGuid) == FALSE) //If it is not all zeroes
+ {
+ GetPageIdFromGuid(&formSetGuid, ((EFI_IFR_REF3 *)CtrlInfo->ControlPtr)->FormId, &ControlDestPageID);
+ if(ControlDestPageID != 0xFFFF) //If the destination page ID is valid
+ {
+ CtrlInfo->ControlDestPageID = ControlDestPageID; //Assign it to CONTROL_INFO->ControlDestPageID
+ IsFormSetIdValid = TRUE;
+ FixIFRRefXControl(PageInfo, CtrlInfo);
+ }
+ }
+
+ if(((EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr)->Length >= sizeof(EFI_IFR_REF4)) //If EFI_IFR_REF4
+ {
+
+
+ devPathStr = HiiGetString(CtrlInfo->ControlHandle, ((EFI_IFR_REF4 *)CtrlInfo->ControlPtr)->DevicePath);
+ if(devPathStr == NULL) //If the device path string is invalid
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page
+ goto DONE;
+ }
+ else
+ { //If the device path string is valid
+ CHAR16 *zeroDevPathStr = (CHAR16 *)EfiLibAllocateZeroPool(MAX_DEV_PATH_STR_LEN * sizeof(CHAR16));
+ if(zeroDevPathStr)
+ {
+ MemSet(&zeroDevPathStr[0], MAX_DEV_PATH_STR_LEN * sizeof(CHAR16), L'0');
+ if(EfiStrCmp(devPathStr, zeroDevPathStr) == 0) //If the DevicePath string contains all zeros
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page
+ goto DONE;
+ }
+ }
+ }
+
+ for(count = 0; count < gPages->PageCount; count++)
+ {
+ PAGE_INFO *tempPageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[count]);
+ if(tempPageInfo == NULL)
+ {
+ continue;
+ }
+ status = GetDevPathFromHandle(tempPageInfo->PageHandle, &tempDevPath);
+ if((status == EFI_SUCCESS) && (tempDevPath != NULL))
+ {
+ GetStringFromDevPath(tempDevPath, &tempDevPathStr);
+ if(EfiStrCmp(devPathStr, tempDevPathStr) == 0)
+ {
+ CtrlInfo->ControlDestPageID = tempPageInfo->PageID;
+ IsDevicePathFound = TRUE;
+ break;
+ }
+ }
+ }
+ if(!IsDevicePathFound) //the provided device path is not found, hence remain in the same page.
+ {
+ CtrlInfo->ControlDestPageID = PageInfo->PageID; //The link refers to the current page
+ goto DONE;
+ }
+ }
+ else
+ { //If the Device path is not present
+ if(IsFormSetIdValid == FALSE) //If the FormSetId is invalid
+ {
+ PAGE_ID_INFO *pageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[PageInfo->PageIdIndex]);
+ if(pageIdInfo)
+ {
+ ControlDestPageID = 0xFFFF;
+ GetPageIdFromGuid(&(pageIdInfo->PageGuid), ((EFI_IFR_REF3 *)CtrlInfo->ControlPtr)->FormId, &ControlDestPageID);
+ if(ControlDestPageID != 0xFFFF) //If the destination page ID is valid, assign it to CONTROL_INFO->ControlDestPageID
+ {
+ CtrlInfo->ControlDestPageID = ControlDestPageID;
+ }
+ }
+ }
+ }
+ }
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetPageIdFromGuid
+//
+// Description: Finds the page ID with matching Guid from the page list
+//
+// Input: EFI_GUID *FormGuid
+// UINT16 *PageID
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, if successful,
+// EFI_INVALID_PARAMETER, if invalid values found
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageIdFromGuid(EFI_GUID *FormGuid, UINT16 PageFormID, UINT16 *PageID)
+{
+ EFI_STATUS status = EFI_INVALID_PARAMETER;
+ UINT32 pgIndex = 0;
+ PAGE_INFO *pgInfo = (PAGE_INFO *)NULL;
+ PAGE_ID_INFO *pageIdInfo = (PAGE_ID_INFO*)NULL;
+
+ if(gPages && gApplicationData && gPageIdList)
+ {
+ for(pgIndex = 0; pgIndex < gPages->PageCount; pgIndex++)
+ {
+ pgInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[pgIndex]);
+ if ((NULL != pgInfo) && (NULL == pgInfo->PageHandle)) //EIP133981 if relash module formsetguid passed then it will return the pageid
+ continue; //so this should not happen when the resource not published so added the condition
+ if(pgInfo->PageFormID == PageFormID)
+ {
+ pageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[pgInfo->PageIdIndex]);
+ if(pageIdInfo && (EfiCompareGuid(FormGuid, &(pageIdInfo->PageGuid)) == TRUE))//Compare Guid
+ {
+ *PageID = pgInfo->PageID;
+ status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+ }
+ }
+
+DONE:
+ return status;
+}
+//EIP: 55762 End
+
+//EIP75588 starts
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: FindHandleWithInSetupData
+//
+// Description: Checks if the given handle is avaiable in the scope of the
+// current formset.
+//
+// Input: EFI_HII_HANDLE Handle
+//
+// Output: EFI_STATUS Status - EFI_NOT_FOUND, if not found, else EFI_SUCCESS
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FindHandleWithInSetupData (EFI_HII_HANDLE Handle)
+{
+ EFI_STATUS Status = EFI_NOT_FOUND;
+ UINTN i = 0;
+
+ if (gSetupData) //Check if the notification is within out formset's scope
+ {
+ for (i = 0; i < gSetupCount; i++)
+ {
+ if (gSetupData[i].Handle == Handle)
+ {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ }
+ return Status;
+}
+//EIP75588 ends
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetRWVariableID
+//
+// Description: Returns the variable ID for read write operation
+//
+// Input: UINT16, CONTROL_INFO *, UINT16 *
+//
+// Output: EFI_STATUS
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetRWVariableID (UINT16 RWVarStoreId, CONTROL_INFO *ControlInfo, UINT16 *VarStoreId)
+{
+ VARIABLE_INFO *varInfo = NULL;
+ UINT32 index = 0;
+
+ for (index = 0; index < gVariables->VariableCount; index++)
+ {
+ varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(index);
+ //EIP-75352 Suppress the warnings from static code analyzer
+ if(NULL == varInfo)
+ {
+ continue;
+ }
+ if ((ControlInfo->ControlHandle == varInfo->VariableHandle) && (varInfo->VariableID == RWVarStoreId))
+ {
+ *VarStoreId = index;
+ return EFI_SUCCESS;
+ }
+ }
+ return EFI_NOT_FOUND;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: StopRefreshOpEvent
+//
+// Description: Stops the refresh event
+//
+// Input: CONTROL_INFO *
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID StopRefreshOpEvent (CONTROL_INFO *controlInfo)
+{
+ CONTROL_INFO *RefreshEventcontrolInfo = (CONTROL_INFO *)NULL;
+ UINTN index;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (gRefreshIdInfo)
+ {
+ for(index = 0; index < gRefreshIdCount; index++)
+ {
+ if(gRefreshIdInfo[index].pEvent) //Close the event
+ {
+ RefreshEventcontrolInfo = (CONTROL_INFO *)gRefreshIdInfo[index].pNotifyContext;
+ if (
+ (controlInfo->ControlHandle == RefreshEventcontrolInfo->ControlHandle) &&
+ (controlInfo->ControlConditionalPtr == RefreshEventcontrolInfo->ControlConditionalPtr) &&
+ (controlInfo->ControlPtr == RefreshEventcontrolInfo->ControlPtr)
+ )
+ {
+ Status = gBS->CloseEvent (gRefreshIdInfo[index].pEvent);
+ if(Status == EFI_SUCCESS)
+ {
+ gRefreshIdInfo[index].pEvent = NULL;
+ } //Dont free the pNotifyContext might be using in formcallback, so freeing here will crash in formcallback. Free in MiniSetupUIExit
+ break;
+ }
+ }
+ }
+ }
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/EDK/MiniSetup/uefi2.1/HiiCallback.c b/EDK/MiniSetup/uefi2.1/HiiCallback.c
new file mode 100644
index 0000000..b78fa49
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/HiiCallback.c
@@ -0,0 +1,1073 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/HiiCallback.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 41 $
+//
+// $Date: 7/03/13 11:25a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/HiiCallback.c $
+//
+// 41 7/03/13 11:25a Arunsb
+// Validated gApplicationData to NULL. In some case gApplicationData is
+// NULL then it leading to hang.
+//
+// 40 5/22/13 11:02a Arunsb
+// [TAG] EIP123047
+// Password retrieved only for its string not for entire size. So password
+// not validated properly, changed upto entire size.
+//
+// 39 4/17/13 2:37p Arunsb
+// [TAG] EIP109812, 107774
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_TYPE_REF and EFI_IFR_REF5
+// [Files] Hii.c, HiiCallback.c, Parse.c and TseUefiHii.h
+//
+// 38 4/16/13 11:44a Arunsb
+// EFI_IFR_TYPE_UNDEFINED declaration moved to tseuefihii.h
+//
+// 37 3/12/13 11:35p Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 36 3/12/13 7:05a Rajashakerg
+// [TAG] EIP105167
+// [Category] Improvement
+// [Description] Making the specify setup items departing from F2/F3
+// effect.
+// [Files] AMITSE.sdl, CommonHelper.c, callback.c, minisetupext.h,
+// PopupPassword.c, SubMenu.c, HiiCallback.c
+//
+// 35 3/08/13 1:39a Rajashakerg
+// [TAG] EIP113085
+// [Category] Improvement
+// [Description] Modify callback function behavior to match UEFI SPEC.
+// [Files] HiiCallback.c, PopupPassword.c, SubMenu.c
+//
+// 34 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 11 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 32 9/17/12 6:22a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 30 9/10/12 10:38a Arunsb
+// [TAG] EIP90372
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup browser handling of
+// EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
+// [RootCause] For discard action current value is saved
+// [Solution] Introduced a global variable which will set for discard
+// action for that current value will not be saved
+// [Files] HiiCallback.c and Uefi21Wapper.c
+//
+// 29 5/29/12 4:46a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 28 5/26/12 5:21a Arunsb
+// [TAG] EIP90895
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup hangs when retrieve callback produces
+// add/remove/update forms
+// [RootCause] Callback with retrieve action produces add/remove/update
+// form
+// [Solution] If retrieve callback produces add/remove/update form then
+// TSE will print debug messages and assert.
+// [Files] HiiNotificationHandler.c, HiiCallback.c and FormBrowser2.c
+//
+// 27 5/09/12 1:32p Arunsb
+// [TAG] EIP86885
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] ISCSI attempt order is not changing on setup
+// [RootCause] Orderlist maxcontainers value and ordered list size not
+// handled properly
+// [Solution] Orderlist maxcontainers value is 0xff, but TSE changed the
+// cache value for only the added attempts(dynamic orderlist creation)
+// remaining buffer left as is, Now the remaining buffers made as 0.
+// [Files] HiiCallback.c and ordlistbox.c
+//
+// 26 4/19/12 6:09p Blaines
+// [TAG] - EIP 88031
+// [Category]- Defect
+// [Synopsis]- Hii Callbacks may enter infinite loop on
+// BROWSER_ACTION_RETRIEVE
+// [Solution] - Only allow EFI_BROWSER_ACTION_RETRIEVE action for all
+// Interactive controls from MiniSetupEntry.
+// [Files] - Submenu.c, HiiCallback.c,
+//
+// 25 4/05/12 12:49p Arunsb
+// [TAG] EIP83252
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] System hangs with onboard SAS Option ROM
+// [RootCause] ProcessPackNotification not invoked properly
+// [Solution] gEnableDrvNotification flag handled properly to invoke
+// ProcessPackNotification
+// [Files] uefi2.1\hiicallback.c and uefi2.1\uefi21wapper.c
+//
+// 24 2/02/12 3:00a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 23 12/16/11 2:01a Arunsb
+// [TAG] EIP78100
+// [Category] Bug Fix
+// [Severity] Critical
+// [Symptom] TSE 2.15 can't enter Setup menu
+// [RootCause] Tried to access the NULL controldata
+// [Solution] Controldata validated for NULL
+// [Files] Hiicallback.c and uefihpktool.exe
+//
+// 22 12/08/11 4:33p Arunsb
+// [TAG] EIP75536
+// [Category] Improvement
+// [Description] String handling inside the callbacks in Minisetup
+// [Files] Hiicallback.c and hiistring21.c
+//
+// 21 12/08/11 12:29a Arunsb
+// ProcessBrowserActionRequestHook declaration changed
+//
+// 20 12/07/11 3:02p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 19 12/07/11 2:22p Rajashakerg
+// [TAG] EIP75572
+// [Category] Improvement
+// [Description] Callback for Date and Time doesn't pass the new value
+// [Files] HiiCallback.c
+//
+// 18 12/07/11 9:31a Rajashakerg
+// [TAG] EIP77108
+// [Category] Improvement
+// [Description] Make ProcessBrowserActionRequest as board module hook
+// [Files] AMITSE.sdl, CommonHelper.c, HiiCallback.c
+//
+// 17 12/07/11 8:14a Rajashakerg
+// [TAG] EIP75118
+// [Category] Improvement
+// [Description] xtractConfig() fail since BrowserCallback() cannot find
+// the variable to process
+// [Files] FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
+// Uefi21Wapper.c, PopupSel.c
+//
+// 16 12/01/11 12:38p Premkumara
+// [TAG] EIP75536
+// [Category] Improvement
+// [Description] 1.String handling inside the callbacks in
+// Minisetup.Adding Null termination for String and Password control type.
+// 2.Iterate to check the available language and add/change the string
+// only for the passed language.
+// [Files] HiiCallback.c, hiistring21.c
+//
+// 15 12/01/11 11:22a Rajashakerg
+// UefiGetValidOptionSize() function declared to resolve build error.
+//
+// 14 12/01/11 7:44a Rajashakerg
+// [TAG] EIP75464
+// [Category] Improvement
+// [Description] Improper handling of action controls
+// [Files] SubMenu.c, UefiAction.c, HiiCallback.c, Uefi21Wapper.c
+//
+// 13 11/28/11 5:10a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 12 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 11 7/19/11 2:33p Arunsb
+// Suppressing the callback for AMI_CALLBACK_FORM_OPEN action
+//
+// 10 4/22/11 5:31p Arunsb
+// [TAG] EIP58009
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Certain controls not compatible with UEFI 2.3 version
+// [Solution] The UEFI 2.3 features will be added only if core supports
+// it
+// [Files] HiiCallback.c and commonhelper.c
+//
+// 9 3/21/11 12:58a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 8 3/09/11 7:26p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 7 12/02/10 6:09p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 6 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 5 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 4 2/19/10 8:50p Madhans
+//
+// 4 11/30/09 1:10p Presannar
+// Modified ConfigAccessCallback EFI_BROWSER_ACTION from pass by reference
+// to pass by value
+//
+// 3 11/19/09 5:31p Presannar
+// Updated TSE include file name to not clash with CORE file
+//
+// 2 8/11/09 2:49p Presannar
+// Added code to FormCallBack by calling FixSetupData after
+// ConfigAccess->Callback to handle dynamic removal of IFR data
+// Added code to handle callback for EFI_IFR_REF_OP opcode
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 5 4/24/09 7:54p Presannar
+// TSE 2.0 UEFI 2.1 Code Complete
+//
+// 4 4/14/09 12:41p Presannar
+// Added Fn SpecialActionCallBack
+// Modified fn signature FormCallBack
+//
+// 3 3/31/09 4:15p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/29/09 6:08p Presannar
+// Added Function Header comments
+// Modified implementation for fn CallFormCallBack and CallTextCallBack
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 1 12/29/08 4:45p Presannar
+// Initial draft Form Callback handler
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: HiiCallback.c
+//
+// Description: Contains Hii related Functions
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//----------------------------------------------------------------------------
+#include "Minisetup.h"
+#include "FormBrowser2.h"
+#include "TseUefiHii.h"
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+static UINT8 *gPrevControlValue = NULL;
+static CHAR16 *gCurPswdString = NULL;
+extern UINT16 gOrderlistcount;
+extern BOOLEAN gEnableDrvNotification; //TRUE if allow notification function to process action, FALSE to ignore the notification
+extern BOOLEAN gBrowserCallbackEnabled; //Allow external drivers to change cache only if it's TRUE; ignore browser callback otherwise
+extern EFI_BROWSER_ACTION gBrowserCallbackAction ; //Contains the BrowserCallback action when a callback is in progress.
+EFI_STATUS ProcessBrowserActionRequestHook(EFI_BROWSER_ACTION_REQUEST actionReq);//EIP77108 : Modified ProcessBrowserActionRequest as board module hook
+//----------------------------------------------------------------------------
+
+UINT32 GetUefiSpecVersion (VOID);
+VOID UefiGetValidOptionSize(CONTROL_INFO *CtrlInfo, UINT32 *SizeOfData);
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: FormCallBack
+//
+// Description:
+//
+// Parameter: EFI_HII_HANDLE Handle, EFI_QUESTION_ID QuestionID,
+// UINT8 Type, EFI_IFR_TYPE_VALUE *Value
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS FormCallBack(EFI_HII_HANDLE Handle, EFI_QUESTION_ID QuestionID, UINT8 Type, EFI_IFR_TYPE_VALUE *Value, EFI_BROWSER_ACTION action)
+{
+ EFI_HANDLE DriverHandle;
+ EFI_GUID EfiHiiConfigAccessProtocolGuid = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
+ EFI_BROWSER_ACTION_REQUEST actionReq = EFI_BROWSER_ACTION_REQUEST_NONE;
+ //EFI_BROWSER_ACTION action = EFI_BROWSER_ACTION_CHANGED; //EFI_BROWSER_ACTION_CHANGING;
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN PreservegEnableDrvNotification = FALSE;
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering FormCallBack()\n\n" );
+ SETUP_DEBUG_UEFI_CALLBACK ( "Handle = 0x%x \nQuestionID = %d \nType = 0x%x \nValue = 0x%x \naction = 0x%x\n\n" , Handle, QuestionID, Type, *Value, action );
+
+ //
+ // Get Driver Handle that installed this Hii Form
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Getting Driver Handle\n" );
+ status = gHiiDatabase->GetPackageListHandle(gHiiDatabase, Handle, &DriverHandle);
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Getting Driver Handle returned, status = 0x%x \n\n", status );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ //
+ // Get ConfigAccess protocol handle
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Getting ConfigAccess protocol handle\n" );
+ status = gBS->HandleProtocol( DriverHandle, &EfiHiiConfigAccessProtocolGuid , &ConfigAccess );
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Getting ConfigAccess protocol handle returned, status = 0x%x \n\n" , status );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ //
+ // Invoke Config Access Protocol
+ //
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] ConfigAccess->Callback()\n\n" );
+
+ PreservegEnableDrvNotification = gEnableDrvNotification;
+ gEnableDrvNotification = TRUE; //Set to enable notification processing
+ gBrowserCallbackEnabled = TRUE;
+ gBrowserCallbackAction = action ; //Save the current BrowserCallback action
+ status = ConfigAccess->Callback(ConfigAccess, action, QuestionID, Type, Value, &actionReq);
+ gBrowserCallbackAction = 0 ; //Clear the current BrowserCallback action
+ gBrowserCallbackEnabled = FALSE;
+ if (!PreservegEnableDrvNotification) // If gEnableDrvNotification is already True Don't touch it
+ gEnableDrvNotification = FALSE; //Reset to disable notification processing
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] ConfigAccess->Callback returned, status = 0x%x \n\n" , status );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ // Clean up PAGE_INFO struct with Handle set to 0xFFFF
+ status = FixSetupData();
+ if(EFI_ERROR(status))
+ {
+ }
+
+ if(actionReq)
+ {
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] ProcessBrowserActionRequestHook()\n" );
+ status = ProcessBrowserActionRequestHook(actionReq);//EIP77108 : Modified ProcessBrowserActionRequest as board module hook
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] ProcessBrowserActionRequestHook returned, status = 0x%x \n\n" , status );
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting FormCallBack()\n\n" );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: CallFormCallBack
+//
+// Description:
+//
+// Parameter: CONTROL_INFO * ControlData, UINT16 Key , UINT8 Flags, UINTN Action
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN BrowserActionDiscard = FALSE;
+EFI_STATUS CallFormCallBack(CONTROL_INFO * ControlData, UINT16 Key ,UINT8 Flags, UINTN Action)//EIP-53480: Implementation of FormBrowser with actions support
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_TYPE_VALUE value;
+ EFI_IFR_OP_HEADER *OpHeader = (EFI_IFR_OP_HEADER *)ControlData->ControlPtr;
+ EFI_BROWSER_ACTION action ;
+ EFI_HII_HANDLE hiiHandle;
+ UINT16 ControlType = 0;
+ UINT8 type = 0;
+ UINT16 tok = 0;
+ UINTN size = 0;
+ UINT32 offset = 0;
+ VOID *ctrlValue = NULL, *FullCtrlValue = NULL;
+ UINT32 UefiSpecVer = 0;
+ UINT32 tempVariable = 0;
+ MemSet( &value, sizeof(value), 0 );
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering CallFormCallBack()\n\n" );
+
+ UefiSpecVer = GetUefiSpecVersion ();
+ if (UefiSpecVer <= 0x2000A) //If spec version is 2.0 suppressing other actions
+ {
+ if (AMI_CALLBACK_CONTROL_UPDATE != Action)
+ {
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting CallFormCallBack()\n\n" );
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+ }
+ else if (UefiSpecVer >= 0x2001E) //If spec version is greater than 2.30 then suppressing other actions
+ {
+ if (
+ (AMI_CALLBACK_CONTROL_UPDATE != Action) &&
+ (AMI_CALLBACK_RETRIEVE != Action) &&
+ (AMI_CALLBACK_FORM_OPEN != Action) &&
+ (AMI_CALLBACK_FORM_CLOSE != Action) &&
+ (AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING != Action)&&
+ (AMI_CALLBACK_FORM_DEFAULT_STANDARD != Action) )//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ {
+ switch(Action)
+ {
+ case AMI_CALLBACK_FORM_OPEN:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_FORM_OPEN Unsupported\n\n" );
+ break;
+ case AMI_CALLBACK_FORM_CLOSE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_FORM_CLOSE Unsupported\n\n" );
+ break;
+ case AMI_CALLBACK_RETRIEVE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_RETRIEVE Unsupported\n\n" );
+ break;
+ case AMI_CALLBACK_CONTROL_UPDATE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_CHANGING Unsupported\n\n" );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING Unsupported\n\n" );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_STANDARD :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] AMI_CALLBACK_FORM_DEFAULT_STANDARD Unsupported\n\n" );//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ break;
+ default:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Callback Action Unsupported\n\n" );
+ break;
+ }
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting CallFormCallBack()\n\n" );
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+ }
+ action = UefiGetActionWapper(Action);
+
+ if(ControlData->ControlHandle == INVALID_HANDLE)
+ {
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] INVALID_HANDLE\n\n" );
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting CallFormCallBack()\n\n" );
+ goto DONE;
+ }
+
+ hiiHandle = ControlData->ControlHandle;
+ ControlType = ControlData->ControlType;
+ tempVariable = ControlData->ControlVariable;
+
+ if(AMI_CALLBACK_FORM_OPEN != Action)
+ {
+ if(OpHeader->OpCode != EFI_IFR_ACTION_OP && OpHeader->OpCode != EFI_IFR_REF_OP)
+ {
+ offset = UefiGetQuestionOffset(ControlData->ControlPtr);
+ //If the control is Ordered list then we are calculating the actual size
+ if(ControlData->ControlType == CONTROL_TYPE_ORDERED_LIST)
+ {
+ UINTN Type=0;
+ UefiGetValidOptionType( ControlData, &Type, (UINT32 *)&size);
+ size = gOrderlistcount * size;
+ }
+ else
+ size = UefiGetWidth(ControlData->ControlPtr);
+
+ if ((EFI_IFR_PASSWORD_OP == OpHeader->OpCode) || (EFI_IFR_STRING_OP == OpHeader->OpCode))
+ {
+ ctrlValue = EfiLibAllocateZeroPool (size + sizeof (CHAR16)); //If max character reached then the string should have NULL at last
+ }
+ else
+ {
+ ctrlValue = EfiLibAllocateZeroPool (size);
+ }
+ if(ctrlValue == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ if((EFI_IFR_PASSWORD_OP == OpHeader->OpCode)&&(NULL != gCurPswdString) )
+ {
+ MemCopy( ctrlValue, gCurPswdString, size);
+ }
+ else
+ status = VarGetValue(ControlData->ControlVariable, offset, size, ctrlValue );
+
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ //Checking the Previous value presence and updateing the cache with the previous value
+ if(NULL != gPrevControlValue)
+ status = VarSetValue(ControlData->ControlVariable, offset, size, gPrevControlValue );
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ }
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ type = ((EFI_IFR_NUMERIC *)(ControlData->ControlPtr))->Flags & EFI_IFR_NUMERIC_SIZE;
+ MemCopy(&(value), ctrlValue, size);
+ break;
+ case EFI_IFR_REF_OP:
+ //type = EFI_IFR_TYPE_UNDEFINED; //REF_OP uses type EFI_IFR_TYPE_UNDEFINED
+ //EIP109812, 107774
+ if ((GetUefiSpecVersion ()) >= 0x2001E) //If spec version is greater than or equals 2.3 then type will be buffer
+ {
+ type = EFI_IFR_TYPE_REF;
+ }
+ else
+ {
+ type = EFI_IFR_TYPE_UNDEFINED;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ type = ((EFI_IFR_ONE_OF *)(ControlData->ControlPtr))->Flags & EFI_IFR_NUMERIC_SIZE;
+ MemCopy(&(value), ctrlValue, size);
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ if ((GetUefiSpecVersion ()) >= 0x2001E) //If spec version is greater than or equals 2.3 then type will be buffer
+ {
+ type = EFI_IFR_TYPE_BUFFER;
+ }
+ else
+ {
+ type = EFI_IFR_TYPE_OTHER;
+ }
+ MemCopy(&(value), ctrlValue, size);
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ type = EFI_IFR_TYPE_BOOLEAN;
+ MemCopy(&(value), ctrlValue, size);
+ break;
+ case EFI_IFR_ACTION_OP:
+ type = EFI_IFR_TYPE_OTHER;
+ tok = ((EFI_IFR_ACTION*)ControlData->ControlPtr)->QuestionConfig;
+ MemCopy(&(value), &tok, sizeof(EFI_STRING_ID));
+ break;
+ case EFI_IFR_STRING_OP:
+ case EFI_IFR_PASSWORD_OP:
+ type = EFI_IFR_TYPE_STRING;
+ tok = HiiAddString(hiiHandle, ctrlValue);
+ MemCopy(&(value), &tok, sizeof(EFI_STRING_ID));
+ break;
+ case EFI_IFR_DATE_OP:
+ type = EFI_IFR_TYPE_DATE;
+ MemCopy(&(value), ctrlValue, size);
+ break;
+ case EFI_IFR_TIME_OP:
+ type = EFI_IFR_TYPE_TIME;
+ MemCopy(&(value), ctrlValue, size);
+ break;
+
+ default:
+ goto DONE;
+ break;
+ }
+ }
+ else
+ {
+ type = EFI_IFR_TYPE_UNDEFINED;
+ }
+
+ SetCallBackControlInfo(hiiHandle, tempVariable);
+
+ switch(Action)
+ {
+ case AMI_CALLBACK_FORM_OPEN:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_FORM_OPEN \n\n" );
+ break;
+ case AMI_CALLBACK_FORM_CLOSE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_FORM_CLOSE \n\n" );
+ break;
+ case AMI_CALLBACK_RETRIEVE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_RETRIEVE \n\n" );
+ break;
+ case AMI_CALLBACK_CONTROL_UPDATE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_CHANGING \n\n" );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING \n\n" );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_STANDARD :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_DEFAULT_STANDARD \\n\n" );//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ break;
+ default:
+
+ break;
+ }
+ BrowserActionDiscard = FALSE;
+ status = FormCallBack(hiiHandle, Key, type, &value, action);
+
+ switch(Action)
+ {
+ case AMI_CALLBACK_FORM_OPEN:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_FORM_OPEN returned, status = 0x%x \n\n" , status );
+ break;
+ case AMI_CALLBACK_FORM_CLOSE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_FORM_CLOSE returned, status = 0x%x \n\n" , status );
+ break;
+ case AMI_CALLBACK_RETRIEVE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_RETRIEVE returned, status = 0x%x \n\n" , status );
+ break;
+ case AMI_CALLBACK_CONTROL_UPDATE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_CHANGING returned, status = 0x%x \n\n" , status );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING returned, status = 0x%x \n\n" , status );
+ break;
+ case AMI_CALLBACK_FORM_DEFAULT_STANDARD :
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] AMI_CALLBACK_FORM_DEFAULT_STANDARD returned, status = 0x%x \n\n" , status ); //EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ break;
+ default:
+
+ break;
+ }
+
+ SetCallBackControlInfo(NULL, 0);
+
+ if(CONTROL_TYPE_SUBMENU == ControlType) { //Skip rest of the step for REF / Submenu control
+ goto DONE;
+ }
+ //For the action EFI_BROWSER_ACTION_CHANGING update the cache and invoke callback with EFI_BROWSER_ACTION_CHANGED
+ if((!EFI_ERROR(status))&&(OpHeader->OpCode != EFI_IFR_ACTION_OP && OpHeader->OpCode != EFI_IFR_REF_OP))
+ {
+ if (FALSE == BrowserActionDiscard)
+ {
+ if((OpHeader->OpCode == EFI_IFR_STRING_OP)||(OpHeader->OpCode == EFI_IFR_PASSWORD_OP))
+ {
+ if ( NULL != ctrlValue )
+ MemFreePointer( (VOID **)&ctrlValue );
+ ctrlValue = HiiGetString( hiiHandle, value.string );
+ FullCtrlValue = EfiLibAllocateZeroPool (size);
+ if (NULL == FullCtrlValue)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy (FullCtrlValue, ctrlValue, EfiStrLen (ctrlValue) * sizeof (CHAR16)); //If not allocated with full size then junk will be store after original string
+
+ if ((EFI_IFR_PASSWORD_OP == OpHeader->OpCode) && IsPasswordEncodeEnabled (ControlData))
+ {
+ ctrlValue = PasswordUpdate (FullCtrlValue, size);
+ }
+ VarSetValue (tempVariable, offset, size, FullCtrlValue);//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ MemFreePointer ((VOID **)&FullCtrlValue);
+ }
+ else
+ {
+ VarSetValue(tempVariable, offset, size, &value );//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+ }
+ }
+ }
+ BrowserActionDiscard = FALSE;
+
+ if( (action == EFI_BROWSER_ACTION_CHANGING ) && (/*(status == EFI_UNSUPPORTED) ||*/ (status == EFI_SUCCESS)) )
+ {
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_ORDERED_LIST_OP:
+ case EFI_IFR_CHECKBOX_OP:
+ case EFI_IFR_ACTION_OP:
+ case EFI_IFR_STRING_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ if(hiiHandle != NULL)
+ {
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_CHANGING Success\n\n" );
+
+ action = EFI_BROWSER_ACTION_CHANGED;
+ SetCallBackControlInfo(hiiHandle, tempVariable);
+
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_CHANGED \n\n" );
+
+ status = FormCallBack(hiiHandle, Key, type, &value,action);
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_CHANGED returned, status = 0x%x \n\n" , status );
+
+ SetCallBackControlInfo(NULL, 0);
+ }
+ status = EFI_SUCCESS;
+ break;
+ default:
+ break;
+ }
+ }
+ if(OpHeader->OpCode == EFI_IFR_STRING_OP || OpHeader->OpCode == EFI_IFR_PASSWORD_OP)
+ {
+ HiiRemoveString(hiiHandle, tok);
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting CallFormCallBack()\n\n" );
+ if(gPrevControlValue)
+ MemFreePointer( (VOID **)&gPrevControlValue );
+ if(gCurPswdString)
+ MemFreePointer( (VOID **)&gCurPswdString );
+ MemFreePointer( (VOID **)&ctrlValue );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: CallTextCallBack
+//
+// Description:
+//
+// Parameter: TEXT_DATA *text, ACTION_DATA *Data
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ if (text->Interval == 0)
+ return Status;
+ if ( --(text->Interval) == 0 )
+ {
+ // initialize the interval
+ text->Interval = (UINT8)(text->ControlData.ControlFlags.ControlRefresh);
+ return EFI_SUCCESS;
+ }
+ else
+ return Status;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SpecialActionCallBack
+//
+// Description:
+//
+// Parameter: CONTROL_INFO * ControlData, UINT16 Key
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_TYPE_VALUE value;
+
+ UINT16 tok = 0;
+ UINT8 type = 0;
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering SpecialActionCallBack()\n\n" );
+
+ MemSet( &value, sizeof(value), 0 );
+ type = EFI_IFR_TYPE_OTHER;
+ tok = ((EFI_IFR_ACTION*)ControlData->ControlPtr)->Question.Header.Prompt;
+ MemCopy(&(value), &tok, sizeof(EFI_STRING_ID));
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Sending EFI_BROWSER_ACTION_CHANGING \n\n" );
+
+ SetCallBackControlInfo(ControlData->ControlHandle, ControlData->ControlVariable);
+ status = FormCallBack(ControlData->ControlHandle, Key, type, &value,EFI_BROWSER_ACTION_CHANGING);
+ SetCallBackControlInfo(NULL, 0);
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] EFI_BROWSER_ACTION_CHANGING returned, status = 0x%x \n\n" , status );
+
+ SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Exiting SpecialActionCallBack()\n\n" );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiPreControlUpdate
+//
+// Description: store the Control value before updating and calling the callback.
+//
+// Parameter: CONTROL_INFO * ControlData
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID UefiPreControlUpdate (CONTROL_INFO *ControlData)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ if(gPrevControlValue)
+ MemFreePointer( (VOID **)&gPrevControlValue );
+
+ if (NULL == ControlData) //UefiPreControlUpdate will be called with NULL for clearing gPrevControlValue. So returning from here if it is NULL.
+ {
+ return;
+ }
+ if(UefiIsInteractive(ControlData))
+ {
+ UINT32 size = 0;
+ UINT32 offset = 0;
+ offset = UefiGetQuestionOffset(ControlData->ControlPtr);
+ if(ControlData->ControlType == CONTROL_TYPE_ORDERED_LIST)
+ {
+ UINTN Type=0;
+ UefiGetValidOptionType( ControlData, &Type, &size);
+ size = gOrderlistcount * size;
+ }
+ else
+ size = UefiGetWidth(ControlData->ControlPtr);
+ gPrevControlValue = EfiLibAllocateZeroPool(size);
+ if(gPrevControlValue == NULL)
+ {
+ //EFI_OUT_OF_RESOURCES;
+ return;
+ }
+
+ status = VarGetValue(ControlData->ControlVariable, offset, size, gPrevControlValue );
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SavePswdString
+//
+// Description: fucntion to save the password string.
+//
+// Parameter: CONTROL_INFO * ControlData, CHAR16 *String
+//
+// Return Value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID SavePswdString (CONTROL_INFO *ControlData, CHAR16 *String)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ if(gCurPswdString)
+ MemFreePointer( (VOID **)&gCurPswdString );
+
+ if (NULL == ControlData) //UefiPreControlUpdate will be called with NULL for clearing gPrevControlValue. So returning from here if it is NULL.
+ {
+ return;
+ }
+ if(UefiIsInteractive(ControlData))
+ {
+ UINT32 size = 0;
+ size = UefiGetWidth(ControlData->ControlPtr);
+ gCurPswdString = EfiLibAllocateZeroPool(size);
+ if ( NULL == gCurPswdString )
+ return ;
+ MemCopy(gCurPswdString, String, size);
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiIsProceedWithPageChange
+//
+// Description: If the Formcallback returns status is EFI_UNSUPPORTED or EFI_SUCCESS.
+// Change page is allowed. Otherwise changeing of page should not happen
+// For UEFI 2.0 Just return EFI_SUCCESS;
+//
+// Parameter: EFI_STATUS
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status)
+{
+ // For Submenu if the status is EFI_UNSUPPORTED or EFI_SUCCESS.
+ // Change page is allowed.
+ if((Status == EFI_UNSUPPORTED) || (Status == EFI_SUCCESS))
+ {
+ return EFI_SUCCESS;
+ }
+ else
+ return Status;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UEFICallSetupFormCallBack
+//
+// Description: The Wrapper function function which calls the CallFormCallBack() if the control is Interactive
+//
+// Parameter: UINTN Action
+//
+// Return Value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UEFICallSetupFormCallBack(UINTN Action )
+{
+//EIP-53480: Implementation of FormBrowser with actions support
+ UINT32 page, control;
+ gBrowserCallbackEnabled = TRUE;
+
+ if (NULL != gApplicationData)
+ {
+ for ( page = 0; page < gPages->PageCount; page++ )
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+
+ if (NULL != pageInfo && 0 == pageInfo->PageHandle)
+ continue;
+
+ for ( control= 0; control < pageInfo->PageControls.ControlCount; control++ )
+ {
+ CONTROL_INFO *controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if (UefiIsInteractive(controlInfo))
+ {
+ // EIP88031 : Allow BROWSER_ACTION_RETRIEVE for all Interactive controls on MiniSetupEntry
+ //if((Action == EFI_BROWSER_ACTION_RETRIEVE)&&(controlInfo->ControlType == CONTROL_TYPE_SUBMENU))
+ // continue;
+
+ UefiPreControlUpdate(NULL); //EIP 75464 : Updating the gPrevControlValue buffer to NULLL before invoking CallFormCallBack
+ CallFormCallBack(controlInfo, UefiGetControlKey(controlInfo), FALSE,Action);
+ }
+
+ }
+ }
+ }
+ gBrowserCallbackEnabled = FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UefiGetActionWapper
+//
+// Description: The Wrapper function to get the actual action for the driver
+//
+// Parameter: UINTN Action
+//
+// Return Value: EFI_BROWSER_ACTION
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_BROWSER_ACTION UefiGetActionWapper(UINTN Action)
+{
+ if(Action == AMI_CALLBACK_CONTROL_UPDATE)
+ return EFI_BROWSER_ACTION_CHANGING;
+
+ if(Action == AMI_CALLBACK_RETRIEVE)
+ return EFI_BROWSER_ACTION_RETRIEVE;
+
+ if(Action == AMI_CALLBACK_FORM_OPEN)
+ return EFI_BROWSER_ACTION_FORM_OPEN;
+
+ if(Action == AMI_CALLBACK_FORM_CLOSE)
+ return EFI_BROWSER_ACTION_FORM_CLOSE;
+
+ if(Action == AMI_CALLBACK_FORM_DEFAULT_MANUFACTURING)
+ return EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING;//EIP 105167 : Making the specify setup items departing from F2/F3 effect.
+
+ if(Action == AMI_CALLBACK_FORM_DEFAULT_STANDARD)
+ return EFI_BROWSER_ACTION_DEFAULT_STANDARD;
+
+ return Action;
+
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c b/EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c
new file mode 100644
index 0000000..c652a90
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c
@@ -0,0 +1,740 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2011, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/HiiNotificationHandler.c $
+//
+// $Author: Arunsb $
+//
+// $Revision: 14 $
+//
+// $Date: 2/11/14 8:54p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/HiiNotificationHandler.c $
+//
+// 14 2/11/14 8:54p Arunsb
+// [TAG] EIP130997
+// [Category] Improvement
+// [Description] New pack support in ESA
+//
+// 13 2/25/13 10:57a Blaines
+// [TAG] - EIP 104273
+// [Category] - Action Item
+// [Description] - Provide ability to dump the Hii Pack from the Setup as
+// part TSE debug Infrastructure. It should dump the Pack updates on Hii
+// notification also.
+// So it can be used to debug the issue.
+// [Files] - ForBrowser2.c, Hii.c, HiiNotificationHandler.c,
+// UefiWapper.c, TseUefiHii.h
+//
+// 12 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 11 5/26/12 5:20a Arunsb
+// [TAG] EIP90895
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup hangs when retrieve callback produces
+// add/remove/update forms
+// [RootCause] Callback with retrieve action produces add/remove/update
+// form
+// [Solution] If retrieve callback produces add/remove/update form then
+// TSE will print debug messages and assert.
+// [Files] HiiNotificationHandler.c, HiiCallback.c and FormBrowser2.c
+//
+// 10 12/10/11 4:47a Arunsb
+// Header corrected
+//
+// 9 12/07/11 2:54p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 8 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 7 12/28/10 12:31p Madhans
+// To update the Tag of EIp 46998. UEFI option ROM menus disappear in
+// Setup when certain options are selected.
+// No file changed but Comment updated right
+//
+// 6 10/27/10 4:25p Madhans
+// [TAG] EIP46998
+// [Category] Defect
+// [Symptom] Some user action on PCIx with UEFI Hii Pages causes Setup
+// screen pages and menu disappers.
+// [RootCause] UEFI 2.1 parsing code is not handling the Removepack and
+// New pack sequance properly. Normally UpdatePack
+// does the removepack and AddPack.
+// [Solution] UEFI 2.1 parsing code fixed to handle above case correctly.
+// [Files] hii.c HiiNotificationHandler.c Parse.c TseUefiHii.h
+// uefi21wapper.c
+//
+// 5 6/17/10 2:59p Madhans
+// Dynamic parsing support in TSE.
+//
+// 4 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 3 2/19/10 8:50p Madhans
+//
+// 4 2/19/10 8:21a Mallikarjunanv
+// updated year in copyright message
+//
+// 3 2/15/10 10:19p Madhans
+// to support EDK nt32 version
+//
+// 2 11/19/09 5:31p Presannar
+// Updated TSE include file name to not clash with CORE file
+//
+// 1 8/11/09 2:50p Presannar
+// HiiNotificationHandler to handle notification of dynamic modification
+// of IFR data.
+//
+// 2 7/24/09 3:58p Presannar
+// Modified IFRChangeNotifyFn to handle New/Add pack notification
+//
+// 1 7/09/09 11:24a Presannar
+// Initial Draft
+// Code to handle Notification arising from Dynamic Form Modification
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: HiiNotificationHandler.c
+//
+// Description: Contains Hii related Functions
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+// Include Files
+//---------------------------------------------------------------------------
+#include "Minisetup.h"
+#include "TseUefiHii.h"
+
+//---------------------------------------------------------------------------
+// Defines
+//---------------------------------------------------------------------------
+#define BY_ENTRY 0
+#define BY_HANDLE 1
+#define BY_TYPE 2
+#define BY_HANDLE_TYPE 3
+
+//---------------------------------------------------------------------------
+// Type definitions
+//---------------------------------------------------------------------------
+typedef struct _NOTIFICATION_INFO NOTIFICATION_INFO;
+
+typedef struct _NOTIFICATION_INFO
+{
+ EFI_HII_HANDLE Handle;
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType;
+ UINT8 *PackData;
+ UINTN DataLength;
+ NOTIFICATION_INFO *prevNotifInfo;
+ NOTIFICATION_INFO *nextNotifInfo;
+};
+
+typedef struct _NOTIFICATION_QUEUE
+{
+ UINTN NumOfNotification;
+ NOTIFICATION_INFO *headNotifInfo;
+ NOTIFICATION_INFO *tailNotifInfo;
+} NOTIFICATION_QUEUE;
+
+//---------------------------------------------------------------------------
+// Externs
+//---------------------------------------------------------------------------
+extern EFI_STATUS FindHandleWithInSetupData(EFI_HII_HANDLE Handle);
+extern EFI_BROWSER_ACTION gBrowserCallbackAction ;
+extern BOOLEAN gBrowserCallbackEnabled;
+//---------------------------------------------------------------------------
+// Variables
+//---------------------------------------------------------------------------
+BOOLEAN gIFRChangeNotify = FALSE;
+EFI_HII_HANDLE gRemovedHandle=NULL;
+BOOLEAN gEnableDrvNotification = FALSE; //TRUE if allow notification function to process action, FALSE to ignore the notification
+BOOLEAN gEnableProcessPack = FALSE; //TRUE if the process pack is allowed, FALSE if to be ignored
+
+static EFI_HANDLE gIFRHandle;
+static UINTN gNotifyType;
+#ifndef TSE_FOR_APTIO_4_50
+#define EFI_HII_PACKAGE_FORMS EFI_HII_PACKAGE_FORM
+#include "tianohii.h"
+#endif
+
+NOTIFICATION_QUEUE *gNotificationQueue = (NOTIFICATION_QUEUE *)NULL; //This is a pointer to the notifiaction queue
+BOOLEAN gPackUpdatePending = FALSE;
+
+//---------------------------------------------------------------------------
+// Function Prototypes
+//---------------------------------------------------------------------------
+EFI_STATUS AddNotificationToQueue(EFI_HII_HANDLE Handle, EFI_HII_DATABASE_NOTIFY_TYPE Type);
+EFI_STATUS ProcessPackNotificationHook (VOID);
+//---------------------------------------------------------------------------
+// Function Implementation
+//---------------------------------------------------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RegisterFormNotification
+//
+// Description: Notification Registering Function
+//
+// Parameter: EFI_HII_DATABASE_NOTIFY PackageNotifyFn,
+// EFI_HII_DATABASE_NOTIFY_TYPE NotifyType,
+// EFI_HANDLE *NotifyHandle
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RegisterFormNotification(EFI_HII_DATABASE_NOTIFY PackageNotifyFn,
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType,
+ EFI_HANDLE *NotifyHandle)
+{
+ //
+ // Register notification
+ //
+ return gHiiDatabase->RegisterPackageNotify (
+ gHiiDatabase,
+ EFI_HII_PACKAGE_FORMS,
+ NULL,
+ PackageNotifyFn,
+ NotifyType,
+ NotifyHandle
+ );
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: UnRegisterFormNotification
+//
+// Description: Notification UnRegistering Function
+//
+// Parameter: EFI_HANDLE *NotifyHandle
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UnRegisterFormNotification(EFI_HANDLE NotifyHandle)
+{
+ //
+ // UnRegister notification
+ //
+ return gHiiDatabase->UnregisterPackageNotify (gHiiDatabase, NotifyHandle);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IFRChangeNotifyFn
+//
+// Description: Function that handles IFR change notification
+//
+// Parameter: IN UINT8 PackageType,
+// IN CONST EFI_GUID *PackageGuid,
+// IN CONST EFI_HII_PACKAGE_HEADER *Package,
+// IN EFI_HII_HANDLE Handle,
+// IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS
+IFRChangeNotifyFn (
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_PACKAGE_HEADER *Package,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
+ )
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+
+ //EIP90895
+ if( (gBrowserCallbackEnabled == TRUE) &&
+ ( (gBrowserCallbackAction == EFI_BROWSER_ACTION_FORM_OPEN) ||
+ (gBrowserCallbackAction == EFI_BROWSER_ACTION_FORM_CLOSE) ||
+ (gBrowserCallbackAction == EFI_BROWSER_ACTION_RETRIEVE) ) )
+ {
+ if (TSE_DEBUG_MESSAGES)
+ {
+ SETUP_DEBUG_TSE ("\n\n[TSE] WARNING: Browser callback is currently in progress");
+ SETUP_DEBUG_TSE ("\n[TSE] HII PACK REMOVE/ADD/UPDATE from EFI_BROWSER_ACTION_FORM_OPEN/EFI_BROWSER_ACTION_RETRIEVE/EFI_BROWSER_ACTION_CLOSE");
+ SETUP_DEBUG_TSE ("\n[TSE] It is not recommended to proceed with the current action, behavior could be unpredictable.");
+ SETUP_DEBUG_TSE ("\n[TSE] It is advisable to work with the card vendor to properly support UEFI 2.3.1, or");
+ SETUP_DEBUG_TSE ("\n[TSE] decrease the value of TSE_CALLBACK_SPEC_VERSION to (UEFI 2.1) to change the callback functionality.");
+ SETUP_DEBUG_TSE ("\n[TSE] So UEFI 2.3.1 Callbacks will be disabled!\n\n");
+ }
+ ASSERT (0);
+ }
+
+ if (FALSE == gEnableDrvNotification) //EIP75588
+ {
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] Illegal Notification (Type: NotifyType 0x%x) recieved. \n\n", NotifyType);
+ }
+ status = AddNotificationToQueue (Handle, NotifyType); //Adding notification to the queue
+ if(status != EFI_SUCCESS) //Failed to add notification in the queue, return error
+ {
+ goto DONE;
+ }
+ gPackUpdatePending = TRUE;
+
+ if(gEnableDrvNotification && !gEnableProcessPack)
+ {
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] IFRChangeNotifyFn() calling ProcessPackNotificationHook() \n\n");
+ gEnableProcessPack = TRUE;
+ status = ProcessPackNotificationHook (); // Synchronized Notification Call happening because of Callback,ExtractConfig. routeconfig.
+ gEnableProcessPack = FALSE;
+ }
+DONE:
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] Exiting IFRChangeNotifyFn() status: %x\n\n", status);
+ return status;
+}
+
+//EIP75588 starts
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: AddNotificationToQueue
+//
+// Description: Adds new notification to the queue and increments queue size
+//
+// Input: EFI_HII_HANDLE Handle, EFI_HII_DATABASE_NOTIFY_TYPE Type
+//
+// Output: EFI_STATUS status - EFI_ABORTED, By default
+// EFI_OUT_OF_RESOURCES, if memory allocation fails
+// EFI_SUCCESS, if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AddNotificationToQueue (EFI_HII_HANDLE Handle, EFI_HII_DATABASE_NOTIFY_TYPE Type)
+{
+ EFI_STATUS status = EFI_ABORTED;
+ NOTIFICATION_INFO *tempNotifInfo = (NOTIFICATION_INFO *)NULL;
+
+ if (gNotificationQueue == NULL)
+ {
+ gNotificationQueue = EfiLibAllocateZeroPool (sizeof (NOTIFICATION_QUEUE));
+ if (NULL == gNotificationQueue)
+ {
+ status = EFI_OUT_OF_RESOURCES; //Cannot allocate memory for the notification queue
+ goto DONE;
+ }
+ }
+ if (NULL == tempNotifInfo)
+ {
+ tempNotifInfo = EfiLibAllocateZeroPool(sizeof(NOTIFICATION_INFO));
+ if (NULL == tempNotifInfo)
+ {
+ status = EFI_OUT_OF_RESOURCES; //Cannot allocate memory for the notification queue
+ goto DONE;
+ }
+ }
+ tempNotifInfo->Handle = Handle;
+ tempNotifInfo->NotifyType = Type;
+ if((Type == EFI_HII_DATABASE_NOTIFY_NEW_PACK) || (Type == EFI_HII_DATABASE_NOTIFY_ADD_PACK))
+ {
+ tempNotifInfo->PackData = (UINT8*)HiiGetForm(Handle, 0, &tempNotifInfo->DataLength);
+ }
+ if((gNotificationQueue->NumOfNotification == 0) || (gNotificationQueue->headNotifInfo == NULL))
+ {
+ gNotificationQueue->headNotifInfo = tempNotifInfo;
+ gNotificationQueue->tailNotifInfo = tempNotifInfo;
+ }
+ else
+ {
+ tempNotifInfo->prevNotifInfo = gNotificationQueue->tailNotifInfo;
+ gNotificationQueue->tailNotifInfo = tempNotifInfo;
+ gNotificationQueue->tailNotifInfo->prevNotifInfo->nextNotifInfo = tempNotifInfo;
+ }
+ gNotificationQueue->NumOfNotification++;
+ status = EFI_SUCCESS;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: RemoveFromQueueByEntry
+//
+// Description: Removes the notification entry from the queue, and returns
+// the pointer to the next notification node
+//
+// Input: NOTIFICATION_INFO *matchingNotifInfo
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RemoveFromQueueByEntry(NOTIFICATION_INFO *matchingNotifInfo)
+{
+ NOTIFICATION_INFO *tempNotifInfo = matchingNotifInfo;
+
+ if ((NULL == tempNotifInfo) || (NULL == gNotificationQueue) || (0 == gNotificationQueue->NumOfNotification)){
+ goto DONE;
+ }
+ if(gNotificationQueue->headNotifInfo == tempNotifInfo){
+ if (gNotificationQueue->headNotifInfo == gNotificationQueue->tailNotifInfo){
+ gNotificationQueue->tailNotifInfo = tempNotifInfo->nextNotifInfo;
+ }
+ gNotificationQueue->headNotifInfo = tempNotifInfo->nextNotifInfo;
+ }else if(gNotificationQueue->tailNotifInfo == tempNotifInfo){
+ gNotificationQueue->tailNotifInfo = tempNotifInfo->prevNotifInfo;
+ }
+ if(tempNotifInfo->prevNotifInfo){
+ tempNotifInfo->prevNotifInfo->nextNotifInfo = tempNotifInfo->nextNotifInfo;
+ }
+ if(tempNotifInfo->nextNotifInfo){
+ tempNotifInfo->nextNotifInfo->prevNotifInfo = tempNotifInfo->prevNotifInfo;
+ }
+ gNotificationQueue->NumOfNotification--; //Decrement the number of notification by 1
+ MemFreePointer(&tempNotifInfo); //Free the node
+DONE:
+ return;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: RemoveNotifFromQueueByHandleType
+//
+// Description: Removes the all the node with same notification handle and
+// type except the passed the entry from the queue
+//
+// Input: EFI_HII_HANDLE Handle
+// EFI_HII_DATABASE_NOTIFY_TYPE Type
+// NOTIFICATION_INFO *matchingNotifInfo
+//
+// Output: EFI_STATUS status - EFI_ABORTED, By default ;
+// EFI_INVALID_PARAMETER, if invalid gNotificationQueue
+// EFI_SUCCESS, if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RemoveNotifFromQueueByHandleType (UINTN RemoveOption, EFI_HII_HANDLE Handle, EFI_HII_DATABASE_NOTIFY_TYPE Type, NOTIFICATION_INFO *matchingNotifInfo)
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+ NOTIFICATION_INFO *tempNotifInfo = (NOTIFICATION_INFO *)NULL;
+ NOTIFICATION_INFO *currNotifInfo = (NOTIFICATION_INFO *)NULL;
+ EFI_HII_HANDLE NotifyHandle = (EFI_HII_HANDLE)NULL;
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType = 0;
+
+ if (NULL == gNotificationQueue){
+ status = EFI_INVALID_PARAMETER; //gNotificationQueue invalid
+ goto DONE;
+ }
+
+ if((Handle != NULL) || (Type != 0)){
+ NotifyHandle = Handle;
+ NotifyType = Type;
+ } else{
+ NotifyHandle = matchingNotifInfo->Handle;
+ NotifyType = matchingNotifInfo->NotifyType;
+ }
+ tempNotifInfo = gNotificationQueue->headNotifInfo;
+ while(tempNotifInfo != NULL)
+ {
+ currNotifInfo = tempNotifInfo->nextNotifInfo;
+ if (BY_ENTRY == RemoveOption){
+ if (tempNotifInfo == matchingNotifInfo){
+ RemoveFromQueueByEntry(tempNotifInfo);
+ status = EFI_SUCCESS;
+ break;
+ }
+ }else if(tempNotifInfo != matchingNotifInfo){ //Match found
+ if (BY_HANDLE == RemoveOption){
+ if (tempNotifInfo->Handle == NotifyHandle){
+ RemoveFromQueueByEntry(tempNotifInfo);
+ status = EFI_SUCCESS;
+ }
+ } else if(RemoveOption == BY_TYPE){
+ if(tempNotifInfo->NotifyType == NotifyType){
+ RemoveFromQueueByEntry(tempNotifInfo);
+ status = EFI_SUCCESS;
+ }
+ } else if(RemoveOption == BY_HANDLE_TYPE){
+//If match found process the node and move to the next node
+ if((tempNotifInfo->Handle == NotifyHandle) && (tempNotifInfo->NotifyType == NotifyType)){
+ RemoveFromQueueByEntry(tempNotifInfo);
+ status = EFI_SUCCESS;
+ }
+ }
+ }
+ tempNotifInfo = currNotifInfo;
+ }
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CleanNotificationQueue
+//
+// Description: Cleans the IFR notification queue
+//
+// Input: None
+//
+// Output: EFI_STATUS status - EFI_SUCCESS, if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CleanNotificationQueue()
+{
+ EFI_STATUS status = EFI_ABORTED;
+
+ do //Loop to clean up the notification queue
+ {
+ if((NULL == gNotificationQueue) || (NULL == gNotificationQueue->headNotifInfo))
+ {
+ status = EFI_SUCCESS; //The is no notification to process
+ goto DONE;
+ }
+ RemoveFromQueueByEntry(gNotificationQueue->headNotifInfo); //Removes this node
+ }while (1);
+ if (gNotificationQueue)
+ {
+ MemFreePointer (&gNotificationQueue);
+ gNotificationQueue = (NOTIFICATION_QUEUE *)NULL; //Reset the Notification Queue
+ }
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: RemoveDuplicateIFRNotification
+//
+// Description: Finds duplicate notification on the same handle and remove
+//
+// Input: None
+//
+// Output: EFI_STATUS status - EFI_ABORTED, By default ;
+// EFI_INVALID_PARAMETER, if invalid gNotificationQueue
+// EFI_SUCCESS, if successful
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS RemoveDuplicateIFRNotification()
+{
+ EFI_STATUS status = EFI_ABORTED;
+ EFI_HII_HANDLE Handle = (EFI_HII_HANDLE)NULL;
+ NOTIFICATION_INFO *tempNotifInfo = (NOTIFICATION_INFO *)NULL;
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType = 0;
+ BOOLEAN packFound = FALSE;
+
+ if((gNotificationQueue == NULL) || (gNotificationQueue->headNotifInfo == NULL))
+ {
+ status = EFI_SUCCESS; //The is no notification to process
+ goto DONE;
+ }
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] Before RemoveDuplicateIFRNotification(), NumOfNotification left: %d\n\n", gNotificationQueue->NumOfNotification);
+
+ tempNotifInfo = gNotificationQueue->tailNotifInfo;
+ Handle = tempNotifInfo->Handle;
+ NotifyType = tempNotifInfo->NotifyType;
+
+ while(tempNotifInfo != NULL) //Loop to removed duplicate notifications
+ {
+ if((EFI_HII_DATABASE_NOTIFY_REMOVE_PACK == tempNotifInfo->NotifyType) ||
+ (EFI_HII_DATABASE_NOTIFY_ADD_PACK == tempNotifInfo->NotifyType)){
+ RemoveNotifFromQueueByHandleType (BY_HANDLE_TYPE, 0, 0, tempNotifInfo); //If the handle belongs to the formset, clean up notification queue
+ }
+ if(tempNotifInfo != NULL){ //If the current node is valid
+ tempNotifInfo = tempNotifInfo->prevNotifInfo; //Move current notification node pointer to previous notification node
+ }
+ }
+ tempNotifInfo = gNotificationQueue->tailNotifInfo;
+ while(tempNotifInfo != NULL) //Loop to removed duplicate notifications
+ {
+ status = FindHandleWithInSetupData(tempNotifInfo->Handle);
+ if (EFI_SUCCESS == status){
+ packFound = TRUE;
+ }
+
+ if(tempNotifInfo->NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK){
+ if(packFound){
+ BOOLEAN newPackOnThisHandle = FALSE;
+ NOTIFICATION_INFO *thisNotifInfo = tempNotifInfo->prevNotifInfo;
+ while(thisNotifInfo) //Loop to find if there is a new pack notification in the queue with this handle
+ {
+ if((thisNotifInfo->Handle == tempNotifInfo->Handle) && (EFI_HII_DATABASE_NOTIFY_NEW_PACK == thisNotifInfo->NotifyType)){
+ newPackOnThisHandle = TRUE;
+ break;
+ }
+ thisNotifInfo = thisNotifInfo->prevNotifInfo;
+ }
+ if(newPackOnThisHandle){ //If a new pack notification was found, no need to process any notification on this handle
+ RemoveNotifFromQueueByHandleType(BY_HANDLE, tempNotifInfo->Handle, 0, NULL);
+ tempNotifInfo = gNotificationQueue->tailNotifInfo;
+ continue;
+ } else{ //Removed everything except for the remove pack notification on the handle
+ RemoveNotifFromQueueByHandleType(BY_HANDLE, tempNotifInfo->Handle, 0, tempNotifInfo);
+ }
+ } else{
+ RemoveNotifFromQueueByHandleType(BY_ENTRY, NULL, 0, tempNotifInfo); //clean up notification queue, except for this handle
+ }
+ } else if(tempNotifInfo->NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK) {
+ if(packFound){
+ if((gIFRChangeNotify == TRUE) && (gRemovedHandle != NULL)){
+ RemoveNotifFromQueueByHandleType(BY_HANDLE, gRemovedHandle, 0, tempNotifInfo); //If the previous remove pack is already processed, clean up notification queue with this handle
+ } else{
+ NOTIFICATION_INFO *thisNotifInfo = tempNotifInfo->prevNotifInfo;
+ while (thisNotifInfo) //Loop to find if there is a remove pack notification in the queue with this handle
+ {
+ if((thisNotifInfo->Handle == tempNotifInfo->Handle) && (thisNotifInfo->NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK)){
+ tempNotifInfo = thisNotifInfo; //Skip the first remove pack encountered on this handle
+ break;
+ }
+ thisNotifInfo = thisNotifInfo->prevNotifInfo;
+ }
+ }
+ } else{
+ RemoveNotifFromQueueByHandleType(BY_ENTRY, NULL, 0, tempNotifInfo); //clean up notification queue, except for this handle
+ }
+ }
+ if (NULL != tempNotifInfo){ //If the current node is valid
+ tempNotifInfo = tempNotifInfo->prevNotifInfo; //Move current notification node pointer to previous notification node
+ }
+ packFound = FALSE;
+ }
+ SETUP_DEBUG_UEFI_NOTIFICATION ("\n\n[TSE] After RemoveDuplicateIFRNotification(), NumOfNotification left: %d\n\n", gNotificationQueue->NumOfNotification);
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: ProcessPackNotification
+//
+// Description: Processes the IFR notification queue
+//
+// Input: None
+//
+// Output: EFI_STATUS status - EFI_ABORTED, By default
+// EFI_SUCCESS, if successful
+// EFI_ERROR, otherwise
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ProcessPackNotification (VOID)
+{
+ EFI_STATUS status = EFI_ABORTED;
+ EFI_HII_HANDLE Handle = (EFI_HII_HANDLE)NULL;
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType = 0;
+ UINT8 *PackData = (UINT8 *)NULL;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Entering IFRChangeNotifyFn() \n\n");
+ RemoveDuplicateIFRNotification();
+
+ if((gNotificationQueue == NULL) || (gNotificationQueue->headNotifInfo == NULL))
+ {
+ status = EFI_NOT_FOUND; //There is no notification to process
+ goto DONE;
+ }
+
+ do
+ {
+ if ((NULL == gNotificationQueue) || (NULL == gNotificationQueue->headNotifInfo))
+ {
+ status = EFI_SUCCESS; //All the notifications are processed
+ goto DONE;
+ }
+ Handle = gNotificationQueue->headNotifInfo->Handle;
+ NotifyType = gNotificationQueue->headNotifInfo->NotifyType;
+ PackData = gNotificationQueue->headNotifInfo->PackData;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] gNotificationQueue->NumOfNotification left: %d \n\n", gNotificationQueue->NumOfNotification);
+
+ switch(NotifyType)
+ {
+ case EFI_HII_DATABASE_NOTIFY_REMOVE_PACK:
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n[TSE] NotifyType: EFI_HII_DATABASE_NOTIFY_REMOVE_PACK \n\n[TSE] Removing IFR Pack \n");
+ if(gIFRChangeNotify)
+ {
+ if(gRemovedHandle!=NULL)
+ {
+ FixSetupData(); //Will fix the UI and Setup data.
+ }
+ }
+ status = HandleRemoveIFRPack(Handle);
+ gIFRChangeNotify = TRUE;
+ gRemovedHandle = Handle;
+ break;
+ case EFI_HII_DATABASE_NOTIFY_NEW_PACK:
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n[TSE] NotifyType: EFI_HII_DATABASE_NOTIFY_NEW_PACK \n\n[TSE] New IFR Pack \n");
+ if(gIFRChangeNotify)
+ {
+ if(gRemovedHandle!=NULL)
+ {
+ FixSetupData(); //Will fix the UI and Setup data.
+ }
+ }
+ status = HandleNewIFRPack (Handle, PackData);
+ break;
+ case EFI_HII_DATABASE_NOTIFY_ADD_PACK:
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n[TSE] NotifyType: EFI_HII_DATABASE_NOTIFY_ADD_PACK \n\n[TSE] Add IFR Pack \n");
+ status = HandleAddIFRPack(Handle, PackData);
+ gIFRChangeNotify = FALSE;
+ FixSetupData();
+ break;
+ default:
+ break;
+ }
+
+#if TSE_DEBUG_MESSAGES
+ ProcessPackToFile(NotifyType, Handle) ;
+#endif
+ RemoveFromQueueByEntry(gNotificationQueue->headNotifInfo); //Remove the processed notification node from the queue
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n[TSE] NumOfNotification left: %d, headNotifInfo: 0x%x \n\n", gNotificationQueue->NumOfNotification, gNotificationQueue->headNotifInfo);
+ }while(1);
+
+DONE:
+ gPackUpdatePending = FALSE;
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n[TSE] Exiting ProcessPackNotificationHook, status: %x \n\n", status);
+ return status;
+}
+//EIP75588 ends
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/Parse.c b/EDK/MiniSetup/uefi2.1/Parse.c
new file mode 100644
index 0000000..31579d1
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Parse.c
@@ -0,0 +1,4700 @@
+//*************************************************************************
+//*************************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//*************************************************************************
+//*************************************************************************
+
+//*************************************************************************
+// $Header: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Parse.c 68 7/12/14 12:23p Arunsb $
+//
+// $Revision: 68 $
+//
+// $Date: 7/12/14 12:23p $
+//*************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Parse.c $
+//
+// 68 7/12/14 12:23p Arunsb
+// [TAG] EIP174938
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Arrow mark shown when driver health page published
+// [Root Cause] Driver health formset considered as dynamic page so arrow
+// shown
+// [Solution] For driverhealth formset DynamicPageCount variable not
+// incremented. Returned EFI_ABORTED in parseform for driverhealth formset
+// so DynamicPageCount not incremented so arrow will not be shown.
+// [Files] Parse.c and uefi21wapper.c
+//
+// 67 5/02/14 5:48a Arunsb
+// [TAG] EIP156258
+// [Category] Improvement
+// [Description] Providing ELINK option to suppress the handle
+// comparison on dynamic parsing
+// [Files] AMITSE.mak, AMITSE.sdl, commonoem.c, commonoem.h and Parse.c
+//
+// 66 5/02/14 4:42a Premkumara
+// [TAG] EIP95647
+// [Category] Improvement
+// [Description] Dynamic Forms need to hide.
+// [Files] AMITSE.mak, AMITSE.sdl, CommonOem.c, Parse.c
+//
+// 65 5/01/14 10:29p Arunsb
+// EIP148837 change reverted, this is specially for Aptio5 customization
+//
+// 64 5/01/14 6:40p Premkumara
+// Resolved build error
+//
+// 63 5/01/14 4:42p Premkumara
+// [TAG] EIP151552
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] IScsi Configuration option throws exception on pressing it
+// after 'Esc' is done to move back to previous page.
+// [RootCause] When "Save and Exit" in iScsi page is selected to create
+// new controls, while parsing PageInfo->PageParentID is not handled
+// properly. So while initializing menu title menu menu->CurrEntry is not
+// setting properly because of ParentPageID.
+// [Solution] While parsing PageInfo->PageParentID is not handled
+// properly. So while initializing menu title menu menu->CurrEntry is not
+// setting properly so that menu will be initialize and draw proper data.
+// [Files] Parse.c
+//
+// 62 5/01/14 4:09p Premkumara
+// [TAG] EIP148837
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Checkbox Control control is not working in dynamic page.
+// [RootCause] TSE is treating both the OneOf control and CheckBox
+// Control as CONTROL_TYPE_POPUPSEL
+// During dynamic parsing TSE is changing the Control type to
+// CONTROL_TYPE_POPUPSEL if it is CheckBox.
+// That's Why in ESA ComboBox is coming instead of CheckBox.
+// [Solution] For Dynamic Parsing after creating the Control Info i am
+// calling GetCheckBoxStyle() to get the Type as
+// CONTROL_TYPE_CHECKBOX for CheckBox Control.
+// [Files] Parse.c
+//
+// 61 12/04/13 2:56a Premkumara
+// [TAG] EIP139099
+// [Category] New Feature
+// [Description] Supress formset other than
+// EFI_HII_PLATFORM_SETUP_FORMSET_GUID and
+// EFI_HII_DRIVER_HEALTH_FORMSET_GUID through elink based on token
+// [Files] AMITSE.sdl, AMITSE.mak, CommonOem.c, Hii.c, Parse.c,
+// TseUefiHii.h
+//
+// 60 6/10/13 12:21p Arunsb
+// EIP122907 EFI_IFR_TYPE_OTHER support provided.
+//
+// 59 5/22/13 11:11a Arunsb
+// Fixed these issues,
+// -If control has submit/inconsistent and its form has condition over it
+// then it will hang,
+// - Read write opcode hang
+//
+// 58 5/22/13 10:19a Premkumara
+// [TAG] EIP120418
+// [Category] Improvement
+// [Issue Faced] When any suppressif, grayoutif, disableif over
+// the form then HPKTool crashes
+// [Root Cause] The end of suppressif, grayoutif, disableif
+// over the form were not handle properly
+// [Solution] The suppressif,grayoutif,disable are pushed
+// and end of suppressif, grayoutif, disableif over the form are popupout
+// properly at the end of parsing form
+// [Files] Parse.c
+//
+// 57 5/20/13 3:36a Premkumara
+// [TAG] EIP124286
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Optimal Defaults are not loading on pressing ResetButton
+// [RootCause] While filling defaults for DefaultOp2 optimal defaults
+// are skipped in __UpdateDefaults() fn
+// [Solution] If default ID EFI_IFR_DEFAULT_OP is found then fill
+// default link for all types of defaults
+// [Files] Parse.c
+//
+// 56 4/17/13 2:29p Arunsb
+// [TAG] EIP109812, 107774
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_TYPE_REF and EFI_IFR_REF5
+// [Files] Hii.c, HiiCallback.c, Parse.c and TseUefiHii.h
+//
+// 55 4/16/13 9:58a Arunsb
+// Missed HII structures added in TSE itself. So Hii structure names
+// changed.
+//
+// 54 4/02/13 8:21a Arunsb
+// [TAG] EIP113919, EIP114842
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_WRITE, EFI_IFR_READ,
+// EFI_IFR_GET, EFI_IFR_SET and EFI_IFR_MAP_OP.
+// [Files] Setupdata.h, ctrlcond.c, expression.c, hii.c and parse.c
+//
+// 53 3/29/13 8:19a Arunsb
+// [TAG] EIP111061
+// [Category] Improvement
+// [Description] Provide support for efivarstore opcode
+// [Files] Parse.c and tseuefihii.h
+//
+// 52 3/25/13 8:05a Premkumara
+// [TAG] EIP105468
+// [Category] New Feature
+// [Description] Support for EFI_IFR_REFRESH_ID opcode for Offline
+// Parsing
+// [Files] Parse.c, Hii.c, Setupdata.h
+//
+// 51 3/20/13 10:42a Blaines
+// [TAG] - EIP 116513
+// [Category]- Defect
+// [Symptom]- System hangs while navigating SAS Card UEFI HII Page, when
+// TSE_MULTILINE_CONTROLS is enabled.
+//
+// [Root cause]
+// The Hii page contained EFI_IFR_ACTION controls with a refresh value
+// greater than zero. When DEBUG_MODE is enabled,
+// The increased page draw completion time caused the Action timer to
+// expire. The constant page refresh prevented the call
+// to function ActionReadKey from the function ActionGetAction.
+//
+// [Solution]- Set the refresh value for EFI_IFR_ACTION controls only if
+// AMI CALLBACK value is used.
+//
+// [Files]
+// - Parse.c
+//
+// 50 3/20/13 9:29a Premkumara
+// [TAG] EIP116566
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Fixed Boot Order Issue
+// [RootCause] Some controls are using checkbox(from runtime pages)
+// value to suppress some controls in SuperIO configuration page.
+// Dynamic parsing is modifying Checkbox controls optimal and failsafe
+// defaults by setting size=1 irrespective of presence of defaults.
+// [Solution] Setting size =0/1 based on presence of fail safe/Optimal
+// defaults for CheckBox controls.
+// [Files] Parse.c
+//
+//
+// 48 3/15/13 2:15a Premkumara
+// [TAG] EIP85745 & 109814
+// [Category] Improvement
+// [Description] Support for Modal Form Support as per UEFI 2.3.1
+// [Files] Parse.c, Page.c, Menu.c, Hotclick.c
+//
+// 47 12/21/12 8:34p Blaines
+// [TAG] EIP 108987
+// [Category] Defect
+// [Symptom] SAS controller card HII menus hang when selecting and HII
+// pack update occurs.
+// [RootCause] The Setup maintains a page data cache when hii packs are
+// created, and will normally try to reuse the page data when hii packs
+// are removed/updated. If the existing page data cannot be reused, the
+// function _InvalidateExistingPage is called, but the
+// NewPageInfo->PageParentID is updated with the
+// OldPageInfo->PageParentID.
+// This resulted in circular page reference, causing the function
+// MenuInitialize (menu.c) to enter an infinite loop.
+//
+// [Solution] In the function _InvalidateExistingPage, remove the code
+// that changes NewPageInfo->PageParentID with the
+// OldPageInfo->PageParentID.
+//
+// [Files Changed]
+// - Parse.c
+//
+//
+// 46 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 16 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 44 9/25/12 8:31a Rajashakerg
+// [TAG] EIP94424
+// [Category] Improvement
+// [Description] Some form can't normal display when add Hii item will
+// in runtime during
+// [Files] AMITSE.sdl, AMITSE.mak, Parse.c
+//
+// 43 9/18/12 2:15a Rajashakerg
+// [TAG] EIP88658
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Minisetup crashes after controller reconnection during Hii
+// callback
+// [RootCause] Minisetup crashes after controller reconnection during
+// callback. since we have new packs and new handles.
+// [Solution] Additional checks for invalid ptrs were added
+// [Files] Hii.c, Parse.c, Uefi21Wapper.c
+//
+// 42 2/02/12 3:12a Premkumara
+// Updated with CheckBox scope issue.
+//
+// 41 2/02/12 3:03a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 40 1/20/12 1:59a Arunsb
+// [TAG] EIP80424
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Circular reference is not updated after pack update which
+// leads to RSOD
+// [RootCause] Circular reference is not updated after pack update which
+// leads to RSOD
+// [Solution] Setting NewPageInfo->PageHandle before calling
+// _AdvAddPageToList() so that Circular reference is updated properly
+// [Files] Parse.c
+//
+// 39 1/17/12 5:39a Premkumara
+// [TAG] EIP80422
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Update Defaults for Checkbox controls doesn't support scope
+// [RootCause] The flaw in this is that this code will never get
+// executed as the scope of a Checkbox control is always 1
+// [Solution] Comment the scope check if(CheckBoxOp->Header.Scope == 0)
+// in _UpdateDefaults() function to execute if scope is 0
+// [Files] Parse.c
+//
+// 38 11/30/11 6:34a Premkumara
+// [TAG] EIP71351
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Setup Crash when iSCSI is loaded
+// [RootCause] Aptio giving length as 0xe(matches size of
+// EFI_IFR_ONE_OF_OPTION) but in latest EDKII driver it is 0x1c.
+// [Solution] change the length as j += ((EFI_IFR_OP_HEADER*)(buff + i +
+// j))->Length;
+// [Files] Parse.c, Hii.c, Variable.c, Minisetupext.c,
+//
+// 37 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 36 11/14/11 4:27a Arunsb
+// [TAG] EIP72540
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Advance page disappear on using 4.6.2_TSE_2_14_1219
+// [RootCause] Offline pages also considered in dynamic parsing
+// [Solution] Offline pages are not considered in dynamic parsing
+// [Files] hii.c and parse.c
+//
+// 35 11/10/11 11:47a Premkumara
+// [TAG] EIP73396
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] On Pressing ESC the token SETUP_GO_TO_EXIT_PAGE_ON_EXIT_KEY
+// key doesnt work in UEFI2.1
+// [RootCause] In AddPageIdToList() function.
+// If PageIdSize = 0 then first pageInfo will not copy into PageIdInfoPtr
+// [Solution] In Parse.c,
+// - removed PageIdSize =0 in AddPageIdToList() function. If PageIdSize =
+// 0 then first pageInfo will not copy into PageIdInfoPtr
+// [Files] Parse.c
+//
+// 34 9/29/11 3:24p Madhans
+// File Checkin comments corrected.
+//
+// 33 8/26/11 6:12p Blaines
+// [TAG] EIP68354
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] non-refresh date control is gets refreshed
+// [RootCause] Date controls that don't have IFR_REFRESH_OP are being
+// assumed to have it. The Flags are not checked for type
+// QF_DATE_STORAGE_TIME.
+// [Solution] The Flags are checked for type QF_DATE_STORAGE_TIME.
+// [Files] TseLite: Time.c, Date.c
+// Uefi21: Parese.c, Uefi21Wrapper.c
+//
+// 31 6/30/11 4:19a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// Dynamic parsing changed for driver health config. page
+// via sendform.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 30 6/28/11 2:40p Arunsb
+// Build error resolved
+//
+// 29 6/28/11 9:38a Arunsb
+// EIP 56405 . Review comment addressed
+// Comment: Uncomment the 2.1 EFI Varstore support part.
+//
+// 28 6/24/11 10:16a Premkumara
+// [TAG] EIP62310, EIP 59743, EIP 62308
+// [Category] Improvement
+// [Description] Merge all SupportEFI_IFR_SUPPRESS_IF_OP,
+// EFI_IFR_GRAYOUT_IF_OP,
+// cases in one case
+// [Files] Parse.c
+//
+// 27 6/23/11 4:02p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 26 6/22/11 5:17p Arunsb
+// [TAG] EIP56405
+// [Category] New Feature
+// [Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+// [Files] Hii.c, parse.c and uefi21wapper.c
+//
+// 25 6/22/11 9:27a Premkumara
+// [TAG] EIP 62310, EIP 59743, EIP 62308
+// [Description] SupportEFI_IFR_SUPPRESS_IF_OP, EFI_IFR_GRAYOUT_IF_OP,
+// EFI_IFR_DISABLE_IF_OP Over the Form or Formset
+// [Files] parse.c
+//
+// 24 6/08/11 4:52p Arunsb
+// [TAG] EIP61650
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Cannot edit time field when using new "time" format
+// [RootCause] Default refresh interval set to all the time variables
+// [Solution] Default refresh interval provided only for RTC time
+// variable
+// [Files] uefi2.1\Parse.c
+//
+// 23 6/01/11 4:11p Madhans
+// [TAG] EIP61588
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Advanced -> ISCSI -> Add an attempt-> Mac Address -> Save
+// changes causes the system to hang.
+// [RootCause] Dynamic update for the goto control to same target page
+// was not updated correctly.
+// [Solution] Fixed to update the control destination page correctly.
+// [Files] parse.c
+// special.c
+//
+// 22 5/31/11 9:52a Premkumara
+// [TAG] EIP48930
+// [Description] Boot override hangs with exception 0x0d
+// [Files] Parse.c, hii.c
+//
+// 21 4/29/11 4:46p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted
+//
+// 20 4/22/11 6:09p Arunsb
+// [TAG] EIP59002
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Refresh interval not set properly
+// [Solution] If control has callback then it is handled in
+// EFI_IFR_ACTION_OP
+// also.
+// [Files] Parse.c
+//
+// 19 4/20/11 5:37p Blaines
+// [TAG] - EIP 55762
+// [Category]- Action Item
+// [Synopsis]- Add support for IFR RefX controls.
+// [Files] - setupdata.h, special.c, frame.c, Hii.c, Parse.c,
+// Uefi21Wrapper.c
+//
+// 18 3/28/11 11:03p Madhans
+// [TAG] EIP56414
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_NO_SUBMIT_IF opcode
+// [Files] Callback.c, FakeToken.c, AMITSEstr.uni, Parse.c, CtrlCond.c,
+// CtrlCond.h, ctrlcond.h, ctrlcond.c
+//
+// 17 3/28/11 9:49p Premkumara
+// [TAG] EIP52562
+// [Category] Improvement
+// [Description] Need to have the Fixed Limit in AMITSE module for
+// Controls, Pages and Variable etc.
+// [Files] TSEUefiHii.h, Hii.c, Parse.c, hii.c
+//
+// 16 3/28/11 5:34p Rajashakerg
+// [TAG] EIP56896
+// [Category] Improvement
+// [Description]
+// TSE: Support for EFI_IFR_LOCKED opcode
+// [Files] Parse.c
+//
+// 15 3/18/11 2:46a Rajashakerg
+// [TAG] EIP56124
+// [Category] New Feature
+// [Description] TSE: Support for EFI_IFR_DEFAULT opcode
+// [Files] Parse.c, TseUefiHii.h
+//
+// 14 3/09/11 7:26p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 13 2/10/11 12:32p Blaines
+// [TAG] - EIP 53146
+// [Category]- New Feature
+// [Description] -Add the support to Move the Dynamic IFR Pages under
+// subpages. It should be customizable to move around.
+//
+// 12 12/28/10 12:31p Madhans
+// To update the Tag of EIp 46998. UEFI option ROM menus disappear in
+// Setup when certain options are selected.
+// No file changed but Comment updated right
+//
+// 11 12/06/10 5:48p Madhans
+// [TAG] - EIP 49488
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom]- ISCSI Pages not working.
+// [Rootcause] Variable Entry that is added by offline parsing is left
+// untouched and it cause the issue when locating the varible based on
+// GUID and Variable Name.
+// [Solution]- Fixed when adding Variable to the list to check for NULL
+// Variable handle.
+// [Files] - Parse.c
+//
+// 10 12/02/10 2:39p Madhans
+// [TAG] - EIP 48169
+// [Category]- Enhancement
+// [Severity]- Mordarate
+// [Symptom]- Code Cleanup and Compiler Warning need to resolved.
+// [Rootcause] Warnings reported when we build AMI higher Warning level.
+// [Solution]- 1. Fix the warnings and do the code cleanup.
+// 2. Introduce proper checks.
+// 3. change the popupSel.c to not change the Option/variable
+// cache to default or first option
+// when the variable cache is not matching with any of
+// option.
+// [Files] - commonoem.c bbs.c boot.c hiistring.c resource.c
+// popuppassword.c popupsel.c
+// expression.c hii.c parse.c
+//
+// 9 10/27/10 4:25p Madhans
+// [TAG] EIP46998
+// [Category] Defect
+// [Symptom] Some user action on PCIx with UEFI Hii Pages causes Setup
+// screen pages and menu disappers.
+// [RootCause] UEFI 2.1 parsing code is not handling the Removepack and
+// New pack sequance properly. Normally UpdatePack
+// does the removepack and AddPack.
+// [Solution] UEFI 2.1 parsing code fixed to handle above case correctly.
+// [Files] hii.c HiiNotificationHandler.c Parse.c TseUefiHii.h
+// uefi21wapper.c
+//
+// 8 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 13 9/15/10 1:53p Madhans
+// To fix the Issues Parent page fixing with Dynamic update of Pages.
+//
+// 11 9/07/10 1:43p Blaines
+// Support loading defaults for Data&Time in UEFI 2.1
+//
+// 10 8/12/10 1:11p Blaines
+// EIP-40946 : Fix root page processing to support Award Style setup.
+//
+// 9 8/10/10 7:14p Madhans
+// EIP 40555 : To avoid Compilation issues with Fareast Windows.
+//
+// 8 6/17/10 4:19p Madhans
+// To fix the circular Page referance
+//
+// 7 6/17/10 2:47p Madhans
+// Fix for parsing correctly.
+// in Dyncamic parsing Fix the parent pages.
+//
+// 6 6/14/10 7:14p Madhans
+// Dynamic parsing support
+//
+// 5 3/11/10 5:43p Madhans
+// Coding Standards Update
+//
+// 4 2/15/10 10:19p Madhans
+// to support EDK nt32 version
+//
+// 3 11/19/09 5:31p Presannar
+// Updated TSE include file name to not clash with CORE file
+//
+// 2 8/11/09 2:57p Presannar
+// Added fn _AdvAddPageToList, _ReplacePageWithNewPage and
+// _AdvAddControlToList to handle dynamic updation of IFR data
+// Renamed _GetDefaultValue as GetDefaultValue
+// Modified _GetQuestionToken to get prompt of Ordered List opcode
+// Modified AddControlToList and AddPageToList to do Advanced Parsing
+// Added fn _ReplacePageWithNewPage and _InvalidateExistingPage to help in
+// handling Adv Page parsing
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 5 5/28/09 11:49a Presannar
+// Bug fixes and clean up
+//
+// 3 5/19/09 11:29a Presannar
+// Removed check for Handle, while searching for existing Variable Info.
+// This is a temporary fix. The issue needs to be analyzed further to
+// check Handle also.
+//
+// 2 5/13/09 10:43a Presannar
+// When EFI_IFR_DEFAULT_OP was encountered, its scope got ignored when
+// skipping the opcode. Special handling of EFI_IFR_DEFAULT_OP case was
+// removed to allow the default case to take care of it.
+// Added File Header
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Parse.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+
+#include "Minisetup.h"
+#include "TseUefiHii.h"
+
+#define PARSE_START_INDEX 1
+//---------------------------------------------------------------------------
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: PageLink
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// FormID UINT16
+// ParentPageID UINT16
+// PageNum UINT16
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct PAGELINK
+{
+ UINT16 FormID; // number from hpk
+ UINT16 ParentPageID; // number from the tool
+ UINT16 PageNum; // number assigned by the tool
+}PageLink;
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: FormSetLinks
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// PageCount UINT16
+// PageLink[20] PageLink
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct FORMSETLINKS
+{
+ UINT16 PageCount;
+ PageLink PageLink[20];
+}FormSetLinks;
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: *PVAR_KEY_TABLE, VAR_KEY_TABLE
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// VarId UINT16
+// Index PageLink
+// Handle EFI_HII_HANDLE
+// *Next struct _VAR_KEY_TABLE
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _VAR_KEY_TABLE
+{
+ UINT32 VarId;
+ UINT16 Index;
+ EFI_HII_HANDLE Handle;
+ struct _VAR_KEY_TABLE *Next;
+}*PVAR_KEY_TABLE, VAR_KEY_TABLE;
+//----------------------------------------------------------------------------
+// MACRO DEFINITIONS
+//----------------------------------------------------------------------------
+#define START_EVAL_IF 0x8000
+#define END_EVAL_IF 0x8001
+#define DEFAULT_REFRESH_RATE 0x01
+#define DEFAULT_DATETIME_REFRESH 0x05
+#define CONTROL_TYPE_MASK 0x0FFF
+#define STANDARD_FORM_MAP_GUID { 0x3bd2f4ec, 0xe524, 0x46e4, 0xa9, 0xd8, 0x51, 0x1, 0x17, 0x42, 0x55, 0x62 }
+
+#ifndef TSE_FOR_APTIO_4_50
+#define EFI_HII_PACKAGE_FORMS EFI_HII_PACKAGE_FORM
+#include "tianohii.h"
+#endif
+//----------------------------------------------------------------------------
+// VARIABLE DECLARATIONS
+//----------------------------------------------------------------------------
+static FormSetLinks *FSetLinks;
+
+VAR_KEY_TABLE VarKeyTable;
+
+BOOLEAN ResetCondVars = TRUE;
+BOOLEAN ResetVars = TRUE;
+BOOLEAN Inconsistant = FALSE;
+BOOLEAN NoSubmitIf = FALSE; // EIP: NO_SUBMIT_IF
+BOOLEAN IsRecursive = FALSE;
+UINT8 DefaultStoreCount = 0;
+UINT32 CtrlVar = 0;
+UINT32 gnewCtrlVar = 0;
+UINT32 PageOffset;
+UINT32 PageVar = 0;
+UINT32 gRefreshIdCount = 0; //No. of controls with Refresh Id set
+UINTN gDynamicPageCount=0;
+VOID *gConditionalOverFormPtr = NULL;//EIP-120418
+BOOLEAN updateformcondvars = TRUE;
+BOOLEAN gConditionOverForm = FALSE;
+//BOOLEAN IsRefreshIdSet = FALSE;
+EFI_GUID RefreshEventGroupId;
+REFRESH_ID_INFO *gRefreshIdInfo = NULL;
+EFI_GUID StandardFormGuid = STANDARD_FORM_MAP_GUID;
+
+//---------------------------------------------------------------------------
+// EXTERN VARIABLES
+//---------------------------------------------------------------------------
+extern PAGE_ID_INFO *PageIdInfoPtr;
+extern PAGE_ID_LIST *PageIdListPtr;
+extern PAGE_INFO *FirstPage;
+extern PAGE_INFO *NewPageInfo;
+extern PAGE_INFO *PageInfoPtr;
+extern PAGE_LIST *PageListPtr;
+extern VARIABLE_LIST *VariableListPtr;
+extern VARIABLE_INFO *VariableInfoPtr;
+
+extern UINT32 AllocatedFirstPageSize, FirstPageOffset;
+extern UINT32 ControlListSize, ControlListOffset;
+extern UINT32 PageIdInfoSize, PageIdInfoOffset;
+extern UINT32 PageIdListSize, PageIdListOffset;
+extern UINT32 PageInfoSize, PageInfoOffset;
+extern UINT32 PageListSize, PageListOffset;
+extern UINT32 VariableListSize, VariableListOffset;
+extern UINT32 VariableInfoSize, VariableInfoOffset;
+extern UINTN TotalRootPages;
+extern SETUP_LINK *gSetupData ;
+extern VOID **gSfHandles;
+extern EFI_GUID *gGuidDump; //EIP64253 offline vfr pages hided
+extern UINTN gGuidDumpCount;
+//---------------------------------------------------------------------------
+// EXTERN FUNCTIONS
+//---------------------------------------------------------------------------
+extern BOOLEAN IsGroupDynamicPages();
+extern BOOLEAN IsOrphanPagesAsRootPage();
+
+extern EFI_STATUS DebugShowControlInfo(UINT32 formID, VOID *passedCtrlInfo) ;
+extern VOID DebugShowPageInfo(UINT32 formID, VOID *passedPageInfo) ;
+extern VOID ResetExpressionStack ( VOID );
+extern EFI_STATUS PushExpression (IN EFI_HII_VALUE *Value);
+extern EFI_STATUS PopExpression (IN EFI_HII_VALUE *Value);
+extern INTN CompareHiiValue (IN EFI_HII_VALUE *Value1,IN EFI_HII_VALUE *Value2,IN EFI_HII_HANDLE HiiHandle OPTIONAL);
+extern EFI_STATUS _GetValueFromQuestionId(UINT16 QuestionId, UINT16 PageId, EFI_HII_VALUE **Value);
+extern EFI_STATUS VarGetValue( UINT32 variable, UINT32 offset, UINTN size, VOID *buffer );
+
+extern VOID *gFirstPageRef;
+extern UINT32 GetUefiSpecVersion (VOID);
+extern BOOLEAN ShowClassGuidFormsets (TSE_EFI_IFR_FORM_SET *SetupFormSet );//EIP-139099
+extern BOOLEAN HideDynamicFormsets (EFI_GUID *FormSetGuid );//EIP-95647
+//---------------------------------------------------------------------------
+// FUNCTION DECLARATIONS
+//---------------------------------------------------------------------------
+EFI_STATUS _AddVariable(UINT8 *IFRData, EFI_HII_HANDLE Handle);
+EFI_STATUS _InitFormsetLinks(char *buff, UINTN InitFormNum);
+EFI_STATUS _AdvAddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize);
+EFI_STATUS _ReplacePageWithNewPage(PAGE_INFO *OldPageInfo, PAGE_INFO *NewPageInfo, UINT32 PageSize);
+EFI_STATUS _InvalidateExistingPage(PAGE_INFO *OldPageInfo, PAGE_INFO *NewPageInfo);
+VOID RefreshGroupOnCallBack(EFI_EVENT Event, VOID *Context);
+UINT8 _IsVarGuidPresent(EFI_GUID *VarGuid, int *Index);
+UINT16 _GetPageIdIndex(EFI_GUID *FormGuid, UINT16 FormClass, UINT16 FormSubClass);
+UINT16 _GetPageParent(int PageNum);
+UINT32 _AddFormSetVariable(EFI_GUID *VarGuid);
+UINT32 _AdvAddControlToList(CONTROL_INFO *ControlInfo, UINT32 ControlSize);
+UINT32 _GetVarNumFromVarID(UINT32 ID, EFI_HII_HANDLE Handle, void *);
+UINTN _AddHpkControls(EFI_HII_HANDLE Handle, UINT8 *buff,UINTN Size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset);
+UINTN _GetSubFormCount(UINT8 *buff);
+UINT16 _GetQuestionToken(UINT8 *ifrData) ;
+VOID _CleanVarKeyTable();
+EFI_STATUS CreateEventforIFR (CONTROL_INFO *control_Info );//EIP-105468
+
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _AddFormSetVariable
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 _AddFormSetVariable(EFI_GUID * VarGuid)
+{
+ VARIABLE_INFO Variable;
+ UINT32 i;
+
+ MemSet(&Variable, sizeof(Variable), 0);
+ MemCopy((&Variable.VariableGuid),VarGuid,sizeof(EFI_GUID));
+ Variable.VariableAttributes = 0x7; // BT+RT+NV
+ EfiStrCpy(Variable.VariableName,L"Setup");
+
+ i = VariableListPtr->VariableCount;
+ AddVariableToList(&Variable);
+
+ return i;
+}
+
+//----------------------------------------------------------------------------
+// Procedure: _DisplayErrorMessage
+//
+// Description: Function to display Error message when TSE supported limit exceeds
+//
+//----------------------------------------------------------------------------
+
+EFI_STATUS _DisplayErrorMessage(CHAR16 *Temp)
+{
+ EFI_EVENT Event;
+ EFI_STATUS status = EFI_SUCCESS;;
+ status = PostManagerDisplayInfoBox(L" Unrecoverable Error",Temp,20,&Event);
+ if(status)
+ {
+ gST->ConOut->OutputString(gST->ConOut,Temp);
+ }
+ return status;
+}
+
+//----------------------------------------------------------------------------
+// Procedure: _AddVariable
+//
+// Description:
+//----------------------------------------------------------------------------
+BOOLEAN VariableHandleSuppressed (EFI_GUID *VariableGuid, CHAR16 *VariableName);
+EFI_STATUS _AddVariable(UINT8 *IFRData, EFI_HII_HANDLE Handle)
+{
+ EFI_GUID *guid=NULL;
+ EFI_STATUS status = EFI_SUCCESS;
+ VARIABLE_INFO *variable=NULL;
+ VARIABLE_INFO newVariable;
+ PVAR_KEY_TABLE pVarTable;
+
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER*)IFRData;
+ EFI_IFR_VARSTORE *varstore=NULL;
+ AMI_EFI_IFR_VARSTORE_EFI *efivarstore;
+ EFI_IFR_VARSTORE_NAME_VALUE *nameValuevarstore;
+
+ char *str2;
+ CHAR16 *varNamePtr;
+ UINT16 i;
+ UINT16 varId = 0;
+ UINT16 varName[40];
+ UINT16 varstoreSize = 0;
+ UINT32 attributes = 0;
+ UINT32 extAttributes = 0;
+ UINTN varfound = 0;
+ BOOLEAN bGreaterUEFIVersion = FALSE;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering _AddVariable()\n" );
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_VARSTORE_OP:
+ varstore = (EFI_IFR_VARSTORE*)IFRData;
+ guid = &(varstore->Guid);
+ varId = varstore->VarStoreId;
+ varstoreSize = varstore->Size;
+ attributes |= 0;
+ extAttributes |= VARIABLE_ATTRIBUTE_VARSTORE;
+ str2 = (char*)varstore->Name;
+
+ //Convert to unicode string
+ MemSet(varName, sizeof(varName), 0);
+ i = 0;
+ for(varNamePtr = varName; *str2; *varNamePtr = *str2, str2++, varNamePtr++)
+ ;
+ break;
+ case EFI_IFR_VARSTORE_EFI_OP:
+ efivarstore = (AMI_EFI_IFR_VARSTORE_EFI*)IFRData;
+ guid = &(efivarstore->Guid);
+ varId = efivarstore->VarStoreId;
+ attributes |= efivarstore->Attributes;
+ extAttributes |= VARIABLE_ATTRIBUTE_EFI_VARSTORE;
+ if ((GetUefiSpecVersion()) > 0x2001E) //If UEFI spec version is greater than 2.3 then store the Name and size from the opcode
+ {
+ bGreaterUEFIVersion = TRUE; //set it to True for version great than 2.3
+ str2 = (char*)efivarstore->Name; //name of the opcode
+ //Convert to unicode string
+ MemSet(varName, sizeof(varName), 0);
+ i = 0;
+ for(varNamePtr = varName; *str2; *varNamePtr = *str2, str2++, varNamePtr++)
+ ;
+
+ varstoreSize = efivarstore->Size; //size of the varstore
+ }
+ break;
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP:
+ nameValuevarstore = (EFI_IFR_VARSTORE_NAME_VALUE*)IFRData;
+ guid = &(nameValuevarstore->Guid);
+ varId = nameValuevarstore->VarStoreId;
+ EfiStrCpy (varName, L"");
+ attributes |= 0;
+ extAttributes |= VARIABLE_ATTRIBUTE_NAMEVALUE;
+ break;
+ default:
+ break;
+ }
+
+ // check that the variable is not already in the list
+ for(i=0; i < VariableListPtr->VariableCount; i++)
+ {
+ variable = (VARIABLE_INFO*)((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]);
+ if( EfiCompareGuid(guid, &(variable->VariableGuid)) )//Compare Guid
+ {
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_VARSTORE_OP:
+ if((EfiStrCmp(varName, variable->VariableName) ==0))
+ {
+ if ((Handle == variable->VariableHandle) || VariableHandleSuppressed (guid, varName))
+ {
+ varfound=1;
+ break;
+ }
+
+ // Aptio SETUP Patch. refer EIP 39861
+ // In aptio If it Setup Variable all the forms refers same varstore.
+ if((i==0) || UefiIsEfiVariable(i, variable))
+ {
+ varfound=1;
+ break;
+ }
+
+ if(variable->VariableHandle == NULL)
+ {
+ // if Variable Handle is zero, then it added from OFFline parsing and we need use this
+ // Entry if the size also matchs.
+ if(varstore->Size == variable->VariableSize)
+ {
+ variable->VariableHandle = Handle;
+ varfound=1;
+ break;
+ }
+ }
+
+ }
+ break;
+ case EFI_IFR_VARSTORE_EFI_OP:
+
+ if (bGreaterUEFIVersion) //If UEFI spec version is greater than 2.3, then use the name to find the variable
+ {
+ if((EfiStrCmp(varName, variable->VariableName) ==0))
+ {
+ if ((Handle == variable->VariableHandle) || VariableHandleSuppressed (guid, varName))
+ {
+ varfound=1;
+ break;
+ }
+
+ // Aptio SETUP Patch. refer EIP 39861
+ // In aptio If it Setup Variable all the forms refers same varstore.
+ if((i==0) || UefiIsEfiVariable(i, variable))
+ {
+ varfound=1;
+ break;
+ }
+
+ if(variable->VariableHandle == NULL)
+ {
+ // if Variable Handle is zero, then it added from OFFline parsing and we need use this
+ // Entry if the size also matchs.
+ if(efivarstore->Size == variable->VariableSize)
+ {
+ variable->VariableHandle = Handle;
+ varfound=1;
+ break;
+ }
+ }
+
+ }
+ }
+ else
+ {
+ if((variable->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE) == VARIABLE_ATTRIBUTE_EFI_VARSTORE &&
+ variable->VariableAttributes == attributes)
+ {
+ varfound = 1;
+ }
+ }
+ break;
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP:
+ varfound = 1;
+ break;
+ }
+ if(varfound)
+ {
+ break;
+ }
+ }
+ }
+
+ if(!varfound)
+ {
+ MemSet(&newVariable, sizeof(VARIABLE_INFO), 0);
+ newVariable.VariableID = varId;
+ MemCopy((&newVariable.VariableGuid),guid,sizeof(EFI_GUID));
+ newVariable.VariableAttributes = attributes;
+ newVariable.ExtendedAttibutes = extAttributes;
+ newVariable.VariableHandle = Handle;
+
+ if(opHeader->OpCode == EFI_IFR_VARSTORE_OP)
+ {
+ EfiStrCpy(newVariable.VariableName, varName);
+ newVariable.VariableSize = varstoreSize;
+ }
+ else if ((EFI_IFR_VARSTORE_EFI_OP == opHeader->OpCode) && (bGreaterUEFIVersion)) //Name is available in the opcode only if UEFI spec followed is
+ { //greater than 2.3
+ EfiStrCpy(newVariable.VariableName, varName);
+ newVariable.VariableSize = varstoreSize;
+ }
+
+ AddVariableToList(&newVariable);
+ }else
+ {
+ variable->VariableID = varId;
+ variable->VariableHandle = Handle;
+ variable->ExtendedAttibutes = extAttributes;
+
+ if(opHeader->OpCode == EFI_IFR_VARSTORE_OP)
+ {
+ variable->VariableSize = varstoreSize;
+ }
+ else if (EFI_IFR_VARSTORE_NAME_VALUE_OP == opHeader->OpCode)
+ {
+ EfiStrCpy (variable->VariableName, varName);
+ }
+ else if ((EFI_IFR_VARSTORE_EFI_OP == opHeader->OpCode) && (bGreaterUEFIVersion)) //Size is available in the opcode only if UEFI spec followed is
+ { //greater than 2.3
+ variable->VariableSize = varstoreSize;
+ }
+ }
+
+ pVarTable = &VarKeyTable;
+
+ while(pVarTable->Next)
+ pVarTable = pVarTable->Next;
+
+ pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE));
+ if(pVarTable->Next == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ pVarTable = pVarTable->Next;
+ pVarTable->VarId = varId;
+ pVarTable->Handle = Handle;
+ pVarTable->Index = i;
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _AddVariable(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _CleanVarKeyTable
+//
+// Description: Clean VarKey Table
+//
+// Parameter: None
+//
+// Return value: None
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _CleanVarKeyTable()
+{
+ PVAR_KEY_TABLE pVarTable = VarKeyTable.Next;
+
+ while(pVarTable)
+ {
+ VarKeyTable.Next = pVarTable->Next;
+ MemFreePointer(&pVarTable);
+ pVarTable = VarKeyTable.Next;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetControlKeyToken
+//
+// Description: Get ControlKey Token
+//
+// Parameter: None
+//
+// Return value: None
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetControlKeyToken(UINT8 *IFRData)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER*)IFRData;
+ EFI_IFR_QUESTION_HEADER *question;
+ UINT16 questionKey = 0;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_ONE_OF_OP: // 0x05
+ case EFI_IFR_CHECKBOX_OP: // 0x06
+ case EFI_IFR_NUMERIC_OP: // 0x07
+ case EFI_IFR_PASSWORD_OP: // 0x08
+ case EFI_IFR_ACTION_OP: // 0x0C
+ case EFI_IFR_RESET_BUTTON_OP: // 0x0D
+ case EFI_IFR_REF_OP: // 0x0F
+ case EFI_IFR_DATE_OP: // 0x1A
+ case EFI_IFR_TIME_OP: // 0x1B
+ case EFI_IFR_STRING_OP: // 0x1C
+ case EFI_IFR_ORDERED_LIST_OP: // 0x23
+ question = (EFI_IFR_QUESTION_HEADER*)((UINT8*)IFRData + sizeof(EFI_IFR_OP_HEADER));
+ questionKey = question->QuestionId;
+ break;
+ case EFI_IFR_RULE_OP: // 0x18
+ questionKey = ((EFI_IFR_RULE*)((UINT8*)IFRData))->RuleId;
+ break;
+ default:
+ break;
+ }
+
+ return questionKey;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetControlDevicePathId
+//
+// Description: Get Control DevicePathId
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetControlDevicePathId(UINT8 *IFRData)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER*)IFRData;
+ UINTN inScope = 0;
+ UINTN i = 0;
+ UINT16 devicePath = 0;
+ BOOLEAN found = FALSE;
+
+ if(opHeader->Scope)
+ {
+ do
+ {
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_VARSTORE_DEVICE_OP:
+ devicePath = ((EFI_IFR_VARSTORE_DEVICE*)((UINT8*)IFRData + i))->DevicePath;
+ found = TRUE;
+ break;
+ case EFI_IFR_END_OP:
+ inScope--;
+ break;
+ default:
+ if(opHeader->Scope)
+ {
+ inScope++;
+ }
+ }
+ i += opHeader->Length;
+ opHeader = (EFI_IFR_OP_HEADER*)(IFRData + i);
+ }while(inScope || found);
+ }
+
+ return devicePath;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetDefaultValue
+//
+// Description: Get Default Value
+//
+// Input: UINT8 Type
+// EFI_IFR_TYPE_VALUE *Value
+// UINT16 *Size - [IN/OUT] parameter - IN for the type
+// EFI_IFR_TYPE_BUFFER. For all other types,
+// as OUT parameter
+// VOID *DefValue
+//
+// Output: Void
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetDefaultValue(UINT8 Type, EFI_IFR_TYPE_VALUE *Value, UINT16 *Size, VOID *DefValue, UINT8 *TempData)
+{
+ UINT8 *Data = TempData;
+ switch(Type)
+ {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ *Size = (UINT16)sizeof(UINT8);
+ *(UINT8*)DefValue = Value->u8;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ case EFI_IFR_TYPE_STRING:
+ *Size = (UINT16)sizeof(UINT16);
+ *(UINT16*)DefValue = Value->u16;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ *Size = (UINT16)sizeof(UINT32);
+ *(UINT32*)DefValue = Value->u32;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ *Size = (UINT16)sizeof(UINT64);
+ *(UINT64*)DefValue = Value->u64;
+ break;
+ case EFI_IFR_TYPE_DATE:
+ *Size = sizeof(EFI_HII_DATE);
+ MemCopy(DefValue, &(Value->date), sizeof(EFI_HII_DATE));
+ break;
+ case EFI_IFR_TYPE_TIME:
+ *Size = sizeof(EFI_HII_TIME);
+ MemCopy(DefValue, &(Value->time), sizeof(EFI_HII_TIME));
+ break;
+ case EFI_IFR_TYPE_BUFFER:
+ // Size will be received as parameter
+ MemCopy(DefValue, Value, *Size);
+ break;
+ case EFI_IFR_TYPE_REF: //EIP109812, 107774
+ // Size will be received as parameter
+ MemCopy (DefValue, Value, *Size);
+ break;
+ case EFI_IFR_TYPE_BOOLEAN:
+ *Size = 1;
+ MemCopy(DefValue, &(Value->b), *Size);
+ break;
+ case EFI_IFR_TYPE_OTHER:
+ {
+ UINTN ScopeCount = 0;
+ EFI_IFR_OP_HEADER *OpHeader = (EFI_IFR_OP_HEADER *)Data;
+ EFI_IFR_DEFAULT *DefaultOp = NULL;
+ *Size = 0;
+
+ if (OpHeader->Scope)
+ {
+ ScopeCount ++;
+ OpHeader = (EFI_IFR_OP_HEADER *)((UINT8 *)OpHeader + OpHeader->Length);
+ if (OpHeader->Scope)
+ {
+ ScopeCount ++;
+ if (EFI_IFR_VALUE_OP == OpHeader->OpCode)
+ {
+ OpHeader = (EFI_IFR_OP_HEADER *)((UINT8 *)OpHeader + OpHeader->Length);
+ switch (OpHeader->OpCode)
+ {
+ case EFI_IFR_UINT8_OP:
+ *Size = (UINT16)sizeof (UINT8);
+ *(UINT8 *)DefValue = *(UINT8 *)((UINT8 *)OpHeader + sizeof (EFI_IFR_OP_HEADER));
+ break;
+ case EFI_IFR_UINT16_OP:
+ *Size = (UINT16)sizeof (UINT16);
+ *(UINT16 *)DefValue = *(UINT16 *)((UINT8 *)OpHeader + sizeof (EFI_IFR_OP_HEADER));
+ break;
+ case EFI_IFR_UINT32_OP:
+ *Size = (UINT16)sizeof (UINT32);
+ *(UINT32 *)DefValue = *(UINT32 *)((UINT8 *)OpHeader + sizeof (EFI_IFR_OP_HEADER));
+ break;
+ case EFI_IFR_UINT64_OP:
+ *Size = (UINT16)sizeof (UINT64);
+ *(UINT64 *)DefValue = *(UINT64 *)((UINT8 *)OpHeader + sizeof (EFI_IFR_OP_HEADER));
+ break;
+ default:
+ *Size = 0;
+ break;
+ }
+ }
+ }
+ }
+ while (ScopeCount)
+ {
+ OpHeader = (EFI_IFR_OP_HEADER *)((UINT8 *)OpHeader + OpHeader->Length);
+ if (EFI_IFR_END_OP == OpHeader->OpCode)
+ {
+ ScopeCount --;
+ }
+ }
+ }
+ break;
+ default:
+ *Size = 0;
+ *(UINT8*)DefValue = 0;
+ break;
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetHelpToken
+//
+// Description: Get Control Question Help Token
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetHelpToken(UINT8 *ifrData)
+{
+ EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER*)ifrData;
+ UINT16 token = 0;
+
+ switch ( headerPtr->OpCode )
+ {
+ case EFI_IFR_TEXT_OP:
+ {
+ EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT*)headerPtr;
+ token = ptr->Statement.Help;
+ }
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ {
+ EFI_IFR_ORDERED_LIST *ptr = (EFI_IFR_ORDERED_LIST*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ {
+ EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ {
+ EFI_IFR_CHECKBOX *ptr = (EFI_IFR_CHECKBOX*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_NUMERIC_OP:
+ {
+ EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ {
+ EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_ACTION_OP:
+ {
+ EFI_IFR_ACTION *ptr = (EFI_IFR_ACTION*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ {
+ EFI_IFR_RESET_BUTTON *ptr = (EFI_IFR_RESET_BUTTON*)headerPtr;
+#ifdef TSE_FOR_APTIO_4_50
+ token = ptr->Statement.Help;
+#else
+ token = ptr->Question.Header.Help;
+#endif
+ }
+ case EFI_IFR_REF_OP:
+ {
+ EFI_IFR_REF *ptr = (EFI_IFR_REF*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ case EFI_IFR_STRING_OP:
+ {
+ EFI_IFR_STRING *ptr = (EFI_IFR_STRING*)headerPtr;
+ token = ptr->Question.Header.Help;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetPageIdIndex
+//
+// Description: Get Page ID index
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetPageIdIndex(EFI_GUID * FormGuid, UINT16 FormClass, UINT16 FormSubClass)
+{
+ UINT16 i;
+ PAGE_ID_INFO *pageId;
+
+ if(PageIdListPtr == NULL)
+ {
+ PageIdListSize = 128;
+ PageIdListPtr = (PAGE_ID_LIST *)EfiLibAllocateZeroPool(128);
+ PageIdListOffset = sizeof(UINT32); // Points to first Offset of PageIdList
+ }
+
+ //search if this combination exists
+ for(i = 0; i < PageIdListPtr->PageIdCount ; i++)
+ {
+ pageId = (PAGE_ID_INFO *) ((UINT8 *)PageIdInfoPtr + PageIdListPtr->PageIdList[i]);
+ if( EfiCompareGuid(FormGuid,&(pageId->PageGuid)) )//Compare Guid
+ {
+ if(FormClass == pageId->PageClass)//Compare class
+ {
+ if(FormSubClass == pageId->PageSubClass)//Compare SubClass
+ {
+ break; //found entry
+ }
+ }
+ }
+ }
+
+ if(i >= PageIdListPtr->PageIdCount)
+ {
+ PAGE_ID_INFO NewPageId;
+
+ MemCopy(&(NewPageId.PageGuid),FormGuid,sizeof(EFI_GUID));
+ NewPageId.PageClass = FormClass;
+ NewPageId.PageSubClass = FormSubClass;
+
+ i = (UINT16)PageIdListPtr->PageIdCount;
+ AddPageIdToList(&NewPageId);
+ }
+
+ return i;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetPageNumFromFormID
+//
+// Description: Get Page Id from Form Id
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetPageNumFromFormID(UINTN FormID)
+{
+ UINTN i=0;
+
+ do{
+ if(FSetLinks->PageLink[i].FormID == FormID)
+ {
+ return (FSetLinks->PageLink[i].PageNum);
+ break;
+ }
+ }while(i++ < FSetLinks->PageCount);
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetPageParent
+//
+// Description: Get Parent Page PageID
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetPageParent(int PageNum)
+{
+ UINT16 i=0;
+
+ do{
+ if(FSetLinks->PageLink[i].PageNum == PageNum )
+ {
+ return (FSetLinks->PageLink[i].ParentPageID );
+ break;
+ }
+ }while( i++ < FSetLinks->PageCount );
+
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetQuestionToken
+//
+// Description: Get Control Question Prompt
+//
+// Parameter:
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 _GetQuestionToken(UINT8 *ifrData)
+{
+ EFI_IFR_OP_HEADER *headerPtr = (EFI_IFR_OP_HEADER*)ifrData;
+ UINT16 token = 0;
+
+ switch ( headerPtr->OpCode )
+ {
+ case EFI_IFR_TEXT_OP:
+ {
+ EFI_IFR_TEXT *ptr = (EFI_IFR_TEXT*)headerPtr;
+ token = ptr->Statement.Prompt;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ {
+ EFI_IFR_ONE_OF *ptr = (EFI_IFR_ONE_OF*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ {
+ EFI_IFR_CHECKBOX *ptr = (EFI_IFR_CHECKBOX*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_NUMERIC_OP:
+ {
+ EFI_IFR_NUMERIC *ptr = (EFI_IFR_NUMERIC*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ {
+ EFI_IFR_ORDERED_LIST *ptr = (EFI_IFR_ORDERED_LIST *)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ {
+ EFI_IFR_PASSWORD *ptr = (EFI_IFR_PASSWORD*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_ACTION_OP:
+ {
+ EFI_IFR_ACTION *ptr = (EFI_IFR_ACTION*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ {
+ EFI_IFR_RESET_BUTTON *ptr = (EFI_IFR_RESET_BUTTON*)headerPtr;
+#ifdef TSE_FOR_APTIO_4_50
+ token = ptr->Statement.Prompt;
+#else
+ token = ptr->Question.Header.Prompt;
+#endif
+ }
+ break;
+ case EFI_IFR_REF_OP:
+ {
+ EFI_IFR_REF *ptr = (EFI_IFR_REF*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_STRING_OP:
+ {
+ EFI_IFR_STRING *ptr = (EFI_IFR_STRING*)headerPtr;
+ token = ptr->Question.Header.Prompt;
+ }
+ break;
+ case EFI_IFR_SUBTITLE_OP:
+ {
+ EFI_IFR_SUBTITLE *ptr = (EFI_IFR_SUBTITLE*)headerPtr;
+ token = ptr->Statement.Prompt;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetSubFormCount
+//
+// Description: Count the subform and Ref inside the formset
+//
+// Parameter:
+//
+// Return value: UINTN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _GetSubFormCount(UINT8 *buff)
+{
+ UINTN *tmpFormIDBuf;
+ UINTN MaxPagecount=100;
+ UINTN PageCount= 0;
+ UINTN i=0, j=0, found =0;
+ INTN ScopeCount = 0;
+ EFI_IFR_OP_HEADER *Header;
+
+ tmpFormIDBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN));
+ //go thru the forms and get the links, creating the lookup table also
+ do
+ {
+ Header = (EFI_IFR_OP_HEADER*)(buff+i);
+ switch(Header->OpCode )
+ {
+ case EFI_IFR_FORM_OP: // find parent in lookup table and then the parent pageNum to link
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while( (found==0) && ( j < PageCount ) ){
+ if(tmpFormIDBuf[j] == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+ found =1;
+ break;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // pages in the root(no parent)
+ tmpFormIDBuf[PageCount] = ((EFI_IFR_FORM*)Header)->FormId ;
+ PageCount++;
+ }
+
+ break;
+ case EFI_IFR_FORM_MAP_OP: // find parent in lookup table and then the parent pageNum to link
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while((found==0) && (j < PageCount))
+ {
+ if(tmpFormIDBuf[j] == ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId)
+ {
+ found =1;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // pages in the root(no parent)
+ tmpFormIDBuf[PageCount] = ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId ;
+ PageCount++;
+ }
+ break;
+
+ case EFI_IFR_REF_OP: // add to lookup table adding the PageID and ParentPageID
+ // Add page if is not in lookup table already
+ found=0;
+ j=0;
+
+ while((found==0) && (j < PageCount))
+ {
+ if(tmpFormIDBuf[j] == ((EFI_IFR_REF*)Header)->FormId)
+ {
+ found =1;
+ }
+ j++;
+ }
+
+ if(!found)
+ {
+ // pages in the root(no parent)
+ tmpFormIDBuf[PageCount] = ((EFI_IFR_REF*)Header)->FormId ;
+ PageCount++;
+ }
+ break;
+ case EFI_IFR_END_OP:
+ ScopeCount--;
+ break;
+ default:
+ break;
+ }
+ if(Header->Scope)
+ {
+ ScopeCount++;
+ }
+ // If the Buffer is not enough the reallocate more
+ if(PageCount >= MaxPagecount)
+ {
+ UINTN *tmpBuf;
+ MaxPagecount +=50;
+ tmpBuf = (UINTN*)EfiLibAllocateZeroPool(MaxPagecount*sizeof(UINTN));
+ MemCopy(tmpBuf,tmpFormIDBuf,sizeof(UINTN)*PageCount);
+ MemFreePointer(&tmpFormIDBuf);
+ tmpFormIDBuf = tmpBuf;
+ }
+ i+=Header->Length;
+ }while(ScopeCount != 0);
+
+ MemFreePointer(&tmpFormIDBuf);
+ return PageCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetVarNumFromVarID
+//
+// Description: Get Variable Index
+//
+// Parameter:
+//
+// Return value: UINT32
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 _GetVarNumFromVarID (UINT32 ID, EFI_HII_HANDLE Handle, void *IfrData)
+{
+ PVAR_KEY_TABLE pVarTable = VarKeyTable.Next;
+ UINT16 *varString;
+ UINT16 Width = 0;
+ VARIABLE_INFO *Variable = NULL;
+ VARIABLE_INFO newVariable;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_IFR_QUESTION_HEADER *QuestionHeader = NULL;
+
+ while(pVarTable)
+ {
+ if ((pVarTable->VarId == ID) && (pVarTable->Handle == Handle))
+ {
+ Variable = (VARIABLE_INFO*)((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList [pVarTable->Index]);
+ if (Variable)
+ {
+ if (VARIABLE_ATTRIBUTE_NAMEVALUE == (Variable->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ QuestionHeader = (EFI_IFR_QUESTION_HEADER *)((UINT8 *)IfrData + sizeof (EFI_IFR_OP_HEADER));
+ varString = HiiGetString (Variable->VariableHandle, QuestionHeader->VarStoreInfo.VarName);
+ Width = UefiGetWidth (IfrData);
+ if (varString)
+ {
+ if (0 == (EfiStrLen (Variable->VariableName)))
+ {
+ Variable->VariableSize = Width;
+ EfiStrCpy (Variable->VariableName, varString);
+ }
+ else
+ {
+ MemSet (&newVariable, sizeof (VARIABLE_INFO), 0);
+ EfiCopyMem (&newVariable, Variable, sizeof (VARIABLE_INFO));
+ newVariable.VariableSize = Width;
+ EfiStrCpy (newVariable.VariableName, varString);
+ Status = AddVariableToList (&newVariable);
+ if (!EFI_ERROR (Status))
+ {
+ return gnewCtrlVar;
+ }
+ }
+ }
+ }
+ return (pVarTable->Index);
+ }
+ }
+ pVarTable = pVarTable->Next;
+ }
+ return 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _InitFormsetLinks
+//
+// Description: Init Formset Links
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _InitFormsetLinks(char *buff,UINTN InitFormNum)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_OP_HEADER *Header;
+
+ UINTN j=0, found =0, InitForm = InitFormNum;
+ UINTN ScopeCount = 0, count = 0;
+ UINT16 RootPageinFormSet=0,RootPageID=0;
+ UINT16 *_PageIdList = (UINT16 *)NULL, _PageIdListCount = 0;
+ EFI_FORM_ID tempFormID = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _InitFormsetLinks()\n");
+
+
+ // allocate memory for data
+ if(FSetLinks != NULL)
+ MemFreePointer(&FSetLinks);
+
+ count = _GetSubFormCount(buff);
+ FSetLinks = (FormSetLinks*)EfiLibAllocateZeroPool(sizeof(FormSetLinks) + count * sizeof(PageLink));
+ if(FSetLinks == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ //go thru the forms and get the links, creating the lookup table also
+ do
+ {
+ Header = (EFI_IFR_OP_HEADER*)(buff);
+ switch(Header->OpCode )
+ {
+ case EFI_IFR_FORM_OP:
+ // find parent in lookup table and then the parent pageNum to link
+ // Add page if is not in lookup table already
+ found = 0;
+ j = 0;
+
+ while( (found == 0) && ( j < FSetLinks->PageCount ) )
+ {
+ if(FSetLinks->PageLink[j].FormID == ((EFI_IFR_FORM*)Header)->FormId )
+ {
+ FSetLinks->PageLink[j].PageNum = (UINT16)InitForm++;
+ found = 1;
+ break;
+ }
+ j++;
+ }
+
+ if(found == 0)
+ {
+ if(!RootPageinFormSet)
+ RootPageinFormSet = ((EFI_IFR_FORM*)Header)->FormId;
+ // pages in the root(no parent)
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_FORM*)Header)->FormId ;
+
+ if(IsOrphanPagesAsRootPage())
+ {
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ }
+ else
+ {
+ if(RootPageinFormSet == ((EFI_IFR_FORM*)Header)->FormId)
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ else
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = FSetLinks->PageLink[0].PageNum;
+ }
+
+ FSetLinks->PageLink[FSetLinks->PageCount].PageNum = (UINT16)InitForm++;
+ FSetLinks->PageCount++;
+ }
+
+ if(Header->Scope)
+ {
+ ScopeCount++;
+ }
+
+ break;
+ case EFI_IFR_FORM_MAP_OP:
+ // find parent in lookup table and then the parent pageNum to link
+ // Add page if is not in lookup table already
+ found = 0;
+ j = 0;
+
+ while( (found == 0) && ( j < FSetLinks->PageCount ) )
+ {
+ if(FSetLinks->PageLink[j].FormID == ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId )
+ {
+ FSetLinks->PageLink[j].PageNum = (UINT16)InitForm++;
+ found = 1;
+ break;
+ }
+ j++;
+ }
+
+ if(found == 0)
+ {
+ if(!RootPageinFormSet)
+ RootPageinFormSet = ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId;
+ // pages in the root(no parent)
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId ;
+
+ if(IsOrphanPagesAsRootPage())
+ {
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ }
+ else
+ {
+ if(RootPageinFormSet == ((AMI_EFI_IFR_FORM_MAP *)Header)->FormId)
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = 0;
+ else
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = FSetLinks->PageLink[0].PageNum;
+ }
+
+ FSetLinks->PageLink[FSetLinks->PageCount].PageNum = (UINT16)InitForm++;
+ FSetLinks->PageCount++;
+ }
+
+ if(Header->Scope)
+ {
+ ScopeCount++;
+ }
+
+ case EFI_IFR_REF_OP:
+ // add to lookup table adding the PageID and ParentPageID
+ // Add page if is not in lookup table already
+ found = 0;
+ j = 0;
+
+ while( (found == 0) && ( j < FSetLinks->PageCount ) )
+ {
+ tempFormID = ((EFI_IFR_REF*)Header)->FormId;
+ if(tempFormID == 0) //If the EFI_IFR_REFX FormId is invalid
+ {
+ tempFormID = (UINT16)InitForm; // Set the check FormId to the current FormId
+ }
+
+ if(FSetLinks->PageLink[j].FormID == tempFormID)
+ {
+ if(RootPageinFormSet != FSetLinks->PageLink[j].FormID)
+ {
+ if(FSetLinks->PageLink[j].PageNum != (UINT16)InitForm-1) // Parent of the Page can't be same page id.
+ {
+ FSetLinks->PageLink[j].ParentPageID = (UINT16)InitForm-1;
+ }
+ }
+ found = 1;
+ }
+ j++;
+ }
+
+ if(found == 0)
+ {
+ // sub pages
+ if(((EFI_IFR_FORM*)Header)->FormId) //If the the FormId is valid, store it
+ {
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = ((EFI_IFR_REF*)Header)->FormId ;
+ } else{ //Else store the current FormId
+ FSetLinks->PageLink[FSetLinks->PageCount].FormID = (UINT16)InitForm;
+ }
+ FSetLinks->PageLink[FSetLinks->PageCount].ParentPageID = (UINT16)InitForm-1;
+ FSetLinks->PageLink[FSetLinks->PageCount].PageNum = 0;
+ FSetLinks->PageCount++;
+ }
+ break;
+ case EFI_IFR_END_OP:
+ ScopeCount--;
+ break;
+ default:
+ if(Header->Scope)
+ {
+ ScopeCount++;
+ }
+ break;
+
+ }
+ buff += Header->Length;
+ }while(ScopeCount != 0);
+
+ // Fix to find the Circulr Links.
+ for(j=0;j<FSetLinks->PageCount;j++)
+ {
+ if(FSetLinks->PageLink[j].FormID == RootPageinFormSet)
+ {
+ RootPageID = FSetLinks->PageLink[j].PageNum;
+ break;
+ }
+ }
+
+ _PageIdList = EfiLibAllocateZeroPool(FSetLinks->PageCount*sizeof(UINT16));
+ for(j=0;j<FSetLinks->PageCount;j++)
+ {
+ UINT16 k,CurrentPageId,m,n;
+ BOOLEAN IsCircular=TRUE; // Default
+
+ if(FSetLinks->PageLink[j].ParentPageID == 0)
+ continue; // Rootpage.
+
+ CurrentPageId = FSetLinks->PageLink[j].PageNum;
+
+ MemSet(_PageIdList, FSetLinks->PageCount*sizeof(UINT16), 0);
+ _PageIdListCount = 0;
+
+ k=0;
+ while(k<FSetLinks->PageCount)
+ {
+ if(FSetLinks->PageLink[k].PageNum == CurrentPageId)
+ {
+ _PageIdList[_PageIdListCount++] = CurrentPageId;
+ CurrentPageId = FSetLinks->PageLink[k].ParentPageID;
+
+ if(CurrentPageId == RootPageID)
+ break; // Root found.
+
+ // Check if it circular.
+ for(m=0;(m<_PageIdListCount)&& IsCircular ;m++)
+ {
+ if(_PageIdList[m] == CurrentPageId) // Circular pages.. Fix the PageIdList[0]
+ {
+ for(n=0;n<FSetLinks->PageCount;n++)
+ {
+ if(FSetLinks->PageLink[n].PageNum == _PageIdList[0])
+ {
+ FSetLinks->PageLink[n].ParentPageID = RootPageID;
+ IsCircular = FALSE;
+ break;
+ }
+ }
+ }
+ }
+ if(!IsCircular)
+ break;
+
+ k=0;
+ continue;
+ }
+ k++;
+ }
+
+ }
+ MemFreePointer(&_PageIdList);
+
+DONE:
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _InitFormsetLinks(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _IsVarGuidPresent
+//
+// Description: Check if the Variable Guid is already defined
+//
+// Parameter:
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 _IsVarGuidPresent(EFI_GUID * VarGuid, int * Index)
+{
+ UINT32 i=0;
+ VARIABLE_INFO *Variable;
+
+ for(i=0; i < VariableListPtr->VariableCount; i++)
+ {
+ Variable = (VARIABLE_INFO *) ((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[i]);
+ if( EfiCompareGuid(VarGuid,&(Variable->VariableGuid)) )//Compare Guid
+ if( (EfiStrCmp(L"Setup",Variable->VariableName) ==0) ||
+ (EfiStrCmp(L"setup",Variable->VariableName) ==0 ))
+ {
+ *Index = i;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _UpdateDefaults
+//
+// Description: Get Control Defaults
+//
+// Parameter: EFI_HII_HANDLE Handle,
+// VOID *Data,
+// UINT16 *size,
+// VOID *Failsafe,
+// VOID *Optimal,
+// DEFAULT_VALUE **defaultValue,
+// struct _CONTROL_FLAGS *Control_Flags,
+// VOID *ConditionalPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 _UpdateDefaults( EFI_HII_HANDLE Handle, VOID *Data, UINT16 *size, VOID **FailsafeValue, VOID **OptimalValue, DEFAULT_VALUE **defaultValue, struct _CONTROL_FLAGS *Control_Flags, VOID *ConditionalPtr)
+{
+
+ EFI_IFR_OP_HEADER *OpHeader;
+ EFI_QUESTION_ID QuestionId = 0;
+
+ EFI_IFR_ONE_OF *OneOfOp = (EFI_IFR_ONE_OF *)NULL;
+ EFI_IFR_ONE_OF_OPTION *OneOfOption = (EFI_IFR_ONE_OF_OPTION *)NULL;
+ EFI_IFR_CHECKBOX *CheckBoxOp = (EFI_IFR_CHECKBOX *)NULL;
+ EFI_IFR_NUMERIC *NumericOp = (EFI_IFR_NUMERIC *)NULL;
+ EFI_IFR_ORDERED_LIST *OrderedListOp = (EFI_IFR_ORDERED_LIST *)NULL;
+ EFI_IFR_PASSWORD *PasswordOp = (EFI_IFR_PASSWORD *)NULL;
+ EFI_IFR_ACTION *ActionOp = (EFI_IFR_ACTION *)NULL;
+ EFI_IFR_STRING *StringOp = (EFI_IFR_STRING *)NULL;
+ EFI_IFR_DEFAULT *DefaultOp = (EFI_IFR_DEFAULT *)NULL;
+ EFI_IFR_REF *RefOp = (EFI_IFR_REF *)NULL;
+ EFI_IFR_DATE *DateOp = (EFI_IFR_DATE *)NULL;
+ EFI_IFR_TIME *TimeOp = (EFI_IFR_TIME *)NULL;
+ EFI_STRING_ID varName = 0;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL;
+
+ UINT8 Flags=0, questionFlags = 0;
+ UINTN ScopeCount = 0;
+ UINT16 *varString = (UINT16 *)NULL;
+ int i=0;
+ UINT8 defaultCount = 0;//EIP: 56124 Declaration to count the defaults of the control
+ VOID *Failsafe = NULL;
+ VOID *Optimal = NULL;
+ UINT16 RecommandedDefaultSize=0;
+ UINT8 DefaultSize = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _UpdateDefaults()\n");
+ // Assume the default values are 64 bits or less. If the values are larger,
+ // we will re-allocate more space.
+ Failsafe = EfiLibAllocateZeroPool (sizeof (UINT64));
+ if(NULL == Failsafe)
+ {
+ return 0;
+ }
+ Optimal = EfiLibAllocateZeroPool (sizeof (UINT64));
+ if(NULL == Optimal)
+ {
+ MemFreePointer (Failsafe);
+ return 0;
+ }
+
+ do
+ {
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)Data + i);
+ switch(OpHeader->OpCode)
+ {
+ // ------ text --------------
+ case EFI_IFR_TEXT_OP: //(only interactive)
+ break;
+
+ // ------ ref --------------
+ case EFI_IFR_REF_OP: // uses only interactive , but to signal that a key has to be passed
+ // back to a consumer (this behavior is not defined in TSE as of 5/20/05)
+ RefOp = (EFI_IFR_REF*)((UINT8*)Data + i);
+
+ questionFlags = RefOp->Question.Flags;
+ break;
+
+ // ------ one of --------------
+ case EFI_IFR_ONE_OF_OP:
+ OneOfOp = (EFI_IFR_ONE_OF*)((UINT8*)Data + i);
+
+ QuestionId = OneOfOp->Question.VarStoreInfo.VarOffset;
+ CtrlVar = _GetVarNumFromVarID(OneOfOp->Question.VarStoreId, Handle, (void *)OneOfOp);
+ varName = OneOfOp->Question.VarStoreInfo.VarName;
+
+ questionFlags = OneOfOp->Question.Flags;
+ DefaultSize = 1 << (OneOfOp->Flags & 0x0F); //if 0, the size is 1 so adding with 1
+ break;
+
+ // ------ one of option--------------
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ OneOfOption = (EFI_IFR_ONE_OF_OPTION*)((UINT8*)Data + i);
+
+ Flags =OneOfOption->Flags;
+ if((Flags & EFI_IFR_OPTION_DEFAULT) == EFI_IFR_OPTION_DEFAULT)
+ {
+ GetDefaultValue(OneOfOption->Type, &(OneOfOption->Value), size, Optimal,(UINT8*)Data + i);
+ }
+
+ if((Flags & EFI_IFR_OPTION_DEFAULT_MFG) == EFI_IFR_OPTION_DEFAULT_MFG)
+ {
+ GetDefaultValue(OneOfOption->Type, &(OneOfOption->Value), size, Failsafe,(UINT8*)Data + i);
+ }
+
+ break;
+
+ // ------ checkbox --------------
+ case EFI_IFR_CHECKBOX_OP:
+ CheckBoxOp = (EFI_IFR_CHECKBOX*)Data;
+
+ CtrlVar = _GetVarNumFromVarID(CheckBoxOp->Question.VarStoreId, Handle, (void *)CheckBoxOp);
+ QuestionId = CheckBoxOp->Question.VarStoreInfo.VarOffset;
+ varName = CheckBoxOp->Question.VarStoreInfo.VarName;
+ questionFlags = CheckBoxOp->Question.Flags;
+ //if(CheckBoxOp->Header.Scope == 0) EIP-80422
+ //{
+ Flags = CheckBoxOp->Flags ;
+
+ //*size = sizeof(UINT8);
+ *(UINT8*)Optimal = (Flags & EFI_IFR_CHECKBOX_DEFAULT)? 1 : 0;
+ if (*(UINT8*)Optimal)
+ *size = sizeof(UINT8);//EIP-116566 Set size if it has default
+
+ *(UINT8*)Failsafe = (Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG)? 1 : 0;
+ if (*(UINT8*)Failsafe)
+ *size = sizeof(UINT8);//EIP-116566 Set size if it has default
+
+ Control_Flags->ControlRefresh = 0;
+ //}
+ DefaultSize = 1;
+ break;
+
+ // ------ numeric --------------
+ case EFI_IFR_NUMERIC_OP:
+ NumericOp = (EFI_IFR_NUMERIC*)((UINT8*)Data + i);
+
+ Control_Flags->ControlRefresh = 0;
+ questionFlags = NumericOp->Question.Flags;
+ QuestionId = NumericOp->Question.VarStoreInfo.VarOffset;
+ CtrlVar = _GetVarNumFromVarID(NumericOp->Question.VarStoreId, Handle, (void *)NumericOp);
+ varName = NumericOp->Question.VarStoreInfo.VarName;
+ DefaultSize = 1 << (NumericOp->Flags & 0x0F); //if 0, the size is 1 so adding with 1
+ break;
+
+ // ------ ordered list --------------
+ case EFI_IFR_ORDERED_LIST_OP:
+ OrderedListOp = (EFI_IFR_ORDERED_LIST*)((UINT8*)Data + i);
+
+ QuestionId = OrderedListOp->Question.VarStoreInfo.VarOffset;
+ CtrlVar = _GetVarNumFromVarID(OrderedListOp->Question.VarStoreId, Handle, (void *)OrderedListOp);
+ varName = OrderedListOp->Question.VarStoreInfo.VarName;
+ questionFlags =OrderedListOp->Question.Flags;
+ DefaultSize = OrderedListOp->MaxContainers;
+ break;
+
+ // ------ date --------------
+ case EFI_IFR_DATE_OP:
+ DateOp = (EFI_IFR_DATE*)((UINT8*)Data + i);
+
+ CtrlVar = _GetVarNumFromVarID(DateOp->Question.VarStoreId, Handle, (void *)DateOp);
+ varName = DateOp->Question.VarStoreInfo.VarName;
+ questionFlags =DateOp->Question.Flags;
+ QuestionId = DateOp->Question.VarStoreInfo.VarOffset;
+ if ((DateOp->Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_TIME)
+ {
+ Control_Flags->ControlRefresh = DEFAULT_DATETIME_REFRESH; /**refresh*/
+ }
+ break;
+
+ // ------ time --------------
+ case EFI_IFR_TIME_OP:
+ TimeOp = (EFI_IFR_TIME*)((UINT8*)Data + i);
+ CtrlVar = _GetVarNumFromVarID(TimeOp->Question.VarStoreId, Handle, (void *)TimeOp);
+ varName = TimeOp->Question.VarStoreInfo.VarName;
+ questionFlags =TimeOp->Question.Flags;
+ QuestionId = TimeOp->Question.VarStoreInfo.VarOffset;
+ if ((TimeOp->Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_TIME) //EIP 61650 Not able to edit the normal storage time opcode
+ {
+ Control_Flags->ControlRefresh = DEFAULT_DATETIME_REFRESH;
+ }
+ //Control_Flags->ControlRefresh = DEFAULT_DATETIME_REFRESH;
+ break;
+
+ // ------ string --------------
+ case EFI_IFR_STRING_OP:
+ StringOp = (EFI_IFR_STRING*)Data;
+
+ questionFlags = StringOp->Question.Flags;
+ QuestionId = StringOp->Question.VarStoreInfo.VarOffset;
+ CtrlVar = _GetVarNumFromVarID(StringOp->Question.VarStoreId, Handle, (void *)StringOp);
+ varName = StringOp->Question.VarStoreInfo.VarName;
+ break;
+
+ // ------ End op --------------
+ case EFI_IFR_END_OP:
+ if(ScopeCount)
+ {
+ ScopeCount--;
+ }
+ break;
+
+ // ------ password--------------
+ case EFI_IFR_PASSWORD_OP:
+ PasswordOp = (EFI_IFR_PASSWORD*)Data;
+
+ questionFlags = PasswordOp->Question.Flags;
+ CtrlVar = _GetVarNumFromVarID(PasswordOp->Question.VarStoreId, Handle, (void *)PasswordOp);
+ QuestionId = PasswordOp->Question.VarStoreInfo.VarOffset;
+ varName = PasswordOp->Question.VarStoreInfo.VarName;
+ break;
+
+ // ------- Action --------------
+ case EFI_IFR_ACTION_OP:
+ ActionOp = (EFI_IFR_ACTION*)Data;
+
+ questionFlags = ActionOp->Question.Flags;
+ CtrlVar = _GetVarNumFromVarID(ActionOp->Question.VarStoreId, Handle, (void *)ActionOp);
+ QuestionId = ActionOp->Question.VarStoreInfo.VarOffset;
+ // if ((questionFlags & EFI_IFR_FLAG_CALLBACK) && (Control_Flags->ControlRefresh == 0))
+
+ //EIP:116513 Do refresh only if AMI CALLBACK value is used.
+ if(ConditionalPtr != NULL)
+ {
+ if(INTERACTIVE_TEXT_VALUE == UefiTseLiteGetAmiCallbackIndex(ConditionalPtr,ActionOp ))
+ Control_Flags->ControlRefresh = DEFAULT_REFRESH_RATE;
+ }
+ break;
+
+ // ------- Reset Button --------------
+ case EFI_IFR_RESET_BUTTON_OP:
+ break;
+
+ // ------ default --------------
+ case EFI_IFR_DEFAULT_OP:
+ DefaultOp = (EFI_IFR_DEFAULT*)((UINT8*)Data + i);
+
+ if(DefaultOp->Type == EFI_IFR_TYPE_BUFFER) //Update the size value for the EFI_IFR_TYPE_BUFFER
+ {
+ //Update size for the array of value stored in VALUE field excluding size for op_header, DefaultId & Type
+ *size = ((EFI_IFR_OP_HEADER*)DefaultOp)->Length - sizeof(EFI_IFR_OP_HEADER) - sizeof(UINT16) - sizeof(UINT8);
+ }
+ else if(DefaultOp->Type == EFI_IFR_TYPE_REF) //ifREf5 Opcode with default value, value is obtained as size of EFI_HII_REF EIP109812, 107774
+ {
+ //buffer is of size EFI_HII_REF.
+ *size = sizeof(AMI_EFI_HII_REF);
+ }
+
+ if(DefaultOp->Header.Scope && DefaultOp->Type > EFI_IFR_TYPE_BUFFER)
+ {
+ // retrieve default value from within scope (evaluate EFI_IFR_VALUE)
+ Control_Flags->ControlEvaluateDefault = TRUE;
+ }
+ else if(DefaultOp->DefaultId == EFI_HII_DEFAULT_CLASS_STANDARD)
+ {
+ // if Optimal is not large enough to hold the buffer, allocate more space for it.
+ if (*size > sizeof (UINT64)) {
+ Optimal = MemReallocateZeroPool (Optimal, sizeof (UINT64), (UINTN) *size);
+ }
+ GetDefaultValue(DefaultOp->Type, &(DefaultOp->Value), size, Optimal,(UINT8*)Data + i);
+ if ((0 == *size) && (DefaultOp->Type == EFI_IFR_TYPE_OTHER)) // GetDefaultValue will return 0 if need Evalutaion
+ Control_Flags->ControlEvaluateDefault = TRUE;
+ else if (DefaultSize) {
+ *size = DefaultSize;
+ }
+ }
+ else if(DefaultOp->DefaultId == EFI_IFR_OPTION_DEFAULT_MFG)
+ {
+ // if Failsafe is not large enough to hold the buffer, allocate more space for it.
+ if (*size > sizeof (UINT64)) {
+ Failsafe = MemReallocateZeroPool (Failsafe, sizeof (UINT64), (UINTN) *size);
+ }
+ GetDefaultValue(DefaultOp->Type, &(DefaultOp->Value), size, Failsafe,(UINT8*)Data + i);
+ if ((0 == *size) && (DefaultOp->Type == EFI_IFR_TYPE_OTHER))
+ Control_Flags->ControlEvaluateDefault = TRUE;
+ else if (DefaultSize) {
+ *size = DefaultSize;
+ }
+ }
+ //else //EIP-124286 Commented since it will not fill Standard and above case defaults for default2 when ResetButton is pressed
+ { // EIp : 56124 Defautls are stored as linked list
+ DEFAULT_VALUE *defaults = NULL;
+ if(*defaultValue == NULL)
+ {
+ *defaultValue = (DEFAULT_VALUE*)EfiLibAllocateZeroPool(sizeof(DEFAULT_VALUE));
+ defaults = *defaultValue;
+ }else
+ {
+ for(defaults = *defaultValue; defaults->Next; defaults = defaults->Next)
+ ;
+ defaults->Next = (DEFAULT_VALUE*)EfiLibAllocateZeroPool(sizeof(DEFAULT_VALUE));
+ defaults = defaults->Next;
+ }
+ defaults->DefaultId = DefaultOp->DefaultId;
+ GetDefaultValue(DefaultOp->Type, &(DefaultOp->Value), size, &defaults->Value, (UINT8*)Data + i);
+ if((*size == 0 ) && (DefaultOp->Type == EFI_IFR_TYPE_OTHER))
+ Control_Flags->ControlEvaluateDefault = TRUE;
+ else if (DefaultSize)
+ *size = DefaultSize;
+ defaultCount++;
+ }
+// DefaultSize = 0; //If defaultstore 2 is present then changing to 0 will mal function so commented.
+ break;
+
+ // ------ refresh --------------
+ case EFI_IFR_REFRESH_OP:
+ Control_Flags->ControlRefresh = ((EFI_IFR_REFRESH*)((UINT8*)Data + i))->RefreshInterval;
+ // SetupData's ControlRefresh Granularity is 1/20 Sec (TSE_REFRESH_GRANURALITY) and makesure it does not cross BYTE size
+ Control_Flags->ControlRefresh = (UINT8)( ((Control_Flags->ControlRefresh*TSE_REFRESH_GRANURALITY) <= 0xFF)?
+ (Control_Flags->ControlRefresh*TSE_REFRESH_GRANURALITY): 0xFF);
+ break;
+
+ // ------ refresh id --------------
+ case EFI_IFR_REFRESH_ID_OP:
+ MemCopy( &RefreshEventGroupId, &(((AMI_EFI_IFR_REFRESH_ID *)((UINT8*)Data + i))->RefreshEventGroupId), sizeof(EFI_GUID) );
+ Control_Flags->RefreshID = TRUE;//EIP-105468
+ break;
+
+ // ------ inconsistent if --------------
+ case EFI_IFR_INCONSISTENT_IF_OP:
+ if(IsRecursive == FALSE)
+ {
+ Inconsistant = TRUE;
+ }
+ break;
+ //----locked-----EIP:56896
+ case EFI_IFR_LOCKED_OP:
+ questionFlags |= EFI_IFR_FLAG_READ_ONLY;
+ break;
+ //EIP : -------------- NO_SUBMIT_IF --------------
+ case EFI_IFR_NO_SUBMIT_IF_OP:
+ if(IsRecursive == FALSE)
+ {
+ NoSubmitIf = TRUE;
+ }
+ break;
+
+
+ default:
+ break;
+ }
+
+ if(OpHeader->Scope)
+ {
+ ScopeCount++;
+ }
+
+ i += OpHeader->Length;
+ }while(ScopeCount != 0);
+
+ Control_Flags->ControlReset = (questionFlags & EFI_IFR_FLAG_RESET_REQUIRED)? 1 : 0;
+ Control_Flags->ControlReadOnly = (questionFlags & EFI_IFR_FLAG_READ_ONLY)? 1 : 0;
+ Control_Flags->ControlInteractive = (questionFlags & EFI_IFR_FLAG_CALLBACK)? 1 : 0;
+
+ if(CtrlVar)
+ {
+ varInfo = (VARIABLE_INFO*)((UINT8 *)VariableInfoPtr + VariableListPtr->VariableList[CtrlVar]);
+ if(varInfo->ExtendedAttibutes)
+ {
+ varInfo->VariableNameId = varName;
+ varString = HiiGetString(varInfo->VariableHandle, varName);
+ if(varString && (EfiStrLen(varInfo->VariableName) == 0))
+ {
+ EfiStrCpy(varInfo->VariableName, varString);
+ }
+ }
+ }
+
+ *FailsafeValue = Failsafe;
+ *OptimalValue = Optimal;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _UpdateDefaults()\n") ;
+
+ return defaultCount;//EIP:56124 Returning the Default count for the control
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetValueFromOpCode
+//
+// Description: Gets the value from the opcode
+//
+// Parameter: EFI_IFR_OP_HEADER *,
+// EFI_HII_VALUE *,
+// INTN
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetValueFromOpCode (EFI_IFR_OP_HEADER *ifrData, EFI_HII_VALUE *Value, INTN Result)
+{
+ EFI_HII_VALUE Data1;
+ EFI_HII_VALUE Data2;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EfiZeroMem (&Data1, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data1, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (Value, sizeof (EFI_HII_VALUE));
+
+ switch (ifrData->OpCode) {
+ case EFI_IFR_EQUAL_OP:
+ Value->Value.b = (Result == 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_NOT_EQUAL_OP:
+ Value->Value.b = (Result != 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_GREATER_EQUAL_OP:
+ Value->Value.b = (Result >= 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_GREATER_THAN_OP:
+ Value->Value.b = (Result > 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_LESS_EQUAL_OP:
+ Value->Value.b = (Result <= 0) ? TRUE : FALSE;
+ break;
+
+ case EFI_IFR_LESS_THAN_OP:
+ Value->Value.b = (Result < 0) ? TRUE : FALSE;
+ break;
+ case EFI_IFR_UINT8_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ Value->Value.u8 = ((EFI_IFR_UINT8*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT16_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ Value->Value.u16 = ((EFI_IFR_UINT16*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT32_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
+ Value->Value.u32 = ((EFI_IFR_UINT32*)ifrData)->Value;
+ break;
+ case EFI_IFR_UINT64_OP:
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ Value->Value.u64 = ((EFI_IFR_UINT64*)ifrData)->Value;
+ break;
+ case EFI_IFR_NOT_OP:
+ Status = PopExpression (Value);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ if (Value->Type != EFI_IFR_TYPE_BOOLEAN) {
+ break;
+ }
+ Value->Value.b = !Value->Value.b;
+ break;
+ case EFI_IFR_AND_OP:
+ case EFI_IFR_OR_OP:
+ //
+ // Two Boolean operator
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ if (Data2.Type != EFI_IFR_TYPE_BOOLEAN) {
+ break;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ if (Data1.Type != EFI_IFR_TYPE_BOOLEAN) {
+ break;
+ }
+
+ if (ifrData->OpCode == EFI_IFR_AND_OP) {
+ Value->Value.b = Data1.Value.b && Data2.Value.b;
+ } else {
+ Value->Value.b = Data1.Value.b || Data2.Value.b;
+ }
+ break;
+ //
+ // binary-op
+ //
+ case EFI_IFR_ADD_OP:
+ case EFI_IFR_SUBTRACT_OP:
+ case EFI_IFR_MULTIPLY_OP:
+ case EFI_IFR_DIVIDE_OP:
+ case EFI_IFR_MODULO_OP:
+ case EFI_IFR_BITWISE_AND_OP:
+ case EFI_IFR_BITWISE_OR_OP:
+ case EFI_IFR_SHIFT_LEFT_OP:
+ case EFI_IFR_SHIFT_RIGHT_OP:
+ //
+ // Pop an expression from the expression stack
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ if (Data2.Type > EFI_IFR_TYPE_DATE) {
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ if (Data1.Type > EFI_IFR_TYPE_DATE) {
+ break;
+ }
+
+ Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
+
+ switch (ifrData->OpCode) {
+ case EFI_IFR_ADD_OP:
+ Value->Value.u64 = Data1.Value.u64 + Data2.Value.u64;
+ break;
+
+ case EFI_IFR_SUBTRACT_OP:
+ Value->Value.u64 = Data1.Value.u64 - Data2.Value.u64;
+ break;
+
+ case EFI_IFR_MULTIPLY_OP:
+ Value->Value.u64 = MultU64x32 (Data1.Value.u64, (UINT32)Data2.Value.u64);
+ break;
+
+ case EFI_IFR_DIVIDE_OP:
+ Value->Value.u64 = AmiTseDivU64x32 (Data1.Value.u64, (UINT32)Data2.Value.u64,NULL);
+ break;
+
+ case EFI_IFR_MODULO_OP:
+ Value->Value.u64 = 0;
+ AmiTseDivU64x32(Data1.Value.u64, (UINT32)Data2.Value.u64, (UINTN*)Value->Value.u64);
+ break;
+
+ case EFI_IFR_BITWISE_AND_OP:
+ Value->Value.u64 = Data1.Value.u64 & Data2.Value.u64;
+ break;
+
+ case EFI_IFR_BITWISE_OR_OP:
+ Value->Value.u64 = Data1.Value.u64 | Data2.Value.u64;
+ break;
+
+ case EFI_IFR_SHIFT_LEFT_OP:
+ Value->Value.u64 = LShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
+ break;
+
+ case EFI_IFR_SHIFT_RIGHT_OP:
+ Value->Value.u64 = RShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
+ break;
+
+ default:
+ break;
+ }
+
+ default:
+ Value->Type = EFI_IFR_TYPE_UNDEFINED;
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: EvaluateReadWrite
+//
+// Description: Evaluates read write conditions
+//
+// Parameter: UINT8 *,
+// CONTROL_INFO *,
+// EFI_HII_VALUE *
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetRWVariableID (UINT16 RWVarStoreId, CONTROL_INFO *ControlInfo, UINT16 *VarStoreId);
+VOID EvaluateReadWrite(UINT8 *buf, CONTROL_INFO *ControlInfo, EFI_HII_VALUE *Value1)
+{
+ EFI_HII_VALUE *Value=NULL;
+ EFI_HII_VALUE *questionValue=NULL;
+ EFI_IFR_TYPE_VALUE questionValue1;
+ UINT64 qValue=0;
+ EFI_HII_VALUE Data1;
+ EFI_HII_VALUE Data2;
+ EFI_HII_VALUE Data3;
+ EFI_IFR_OP_HEADER *ifrData = NULL;
+ EFI_STATUS Status;
+ INTN Result;
+ UINTN i = 0;
+ UINTN j = 0;
+ EFI_QUESTION_ID questionId = 0;
+ AMI_EFI_IFR_GET *IfrGet =NULL;
+ AMI_EFI_IFR_SET *IfrSet =NULL;
+ UINTN dataWidth = 0;
+ UINT16 Size = 0;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ UINT64 def;
+ UINTN ScopeCount = 0;
+
+ ResetExpressionStack ();
+ questionValue = (EFI_HII_VALUE*)EfiLibAllocateZeroPool(sizeof(EFI_HII_VALUE));
+ EfiZeroMem (questionValue, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data1, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data2, sizeof (EFI_HII_VALUE));
+ EfiZeroMem (&Data3, sizeof (EFI_HII_VALUE));
+ Value = &Data3;
+ Value->Type = EFI_IFR_TYPE_BOOLEAN;
+
+ ifrData = (EFI_IFR_OP_HEADER*)buf;
+
+ do
+ {
+ if(ifrData->Scope)
+ {
+ ScopeCount++;
+ }
+
+ switch(ifrData->OpCode)
+ {
+
+ case EFI_IFR_THIS_OP:
+ Status = _GetValueFromQuestionId(ControlInfo->ControlKey, ControlInfo->ControlPageID, &questionValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ Value = questionValue;
+ break;
+ case EFI_IFR_END_OP:
+ if(ScopeCount)
+ {
+ ScopeCount--;
+ }
+
+ goto DONE;
+
+ case EFI_IFR_GET_OP:
+ {
+ UINT16 VarStoreId = 0;
+ IfrGet = (AMI_EFI_IFR_GET *)ifrData;
+ GetDefaultValue(IfrGet->VarStoreType,&questionValue1, &Size, &def, (UINT8 *)ifrData);
+ Status = GetRWVariableID (IfrGet->VarStoreId, ControlInfo, &VarStoreId);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ Status = VarGetValue(VarStoreId, IfrGet->VarStoreInfo.VarOffset, (( Size > sizeof(UINT64))? sizeof(UINT64) : Size ), &qValue);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ Value->Value.u64 = qValue;
+ break;
+ }
+ case EFI_IFR_SET_OP:
+ {
+ UINT16 VarStoreId = 0;
+ IfrSet = (AMI_EFI_IFR_SET *)ifrData;
+ GetDefaultValue(IfrSet->VarStoreType,&questionValue1, &Size, &def, (UINT8 *)ifrData);
+ Status = GetRWVariableID (IfrSet->VarStoreId, ControlInfo, &VarStoreId);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ qValue = Data1.Value.u64;
+ if(Data1.Type != EFI_IFR_TYPE_UNDEFINED){
+ Status = VarSetValue(VarStoreId, IfrSet->VarStoreInfo.VarOffset, (( Size > sizeof(UINT64))? sizeof(UINT64) : Size ), &qValue);
+ }
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+ Value->Type = Data1.Type;
+ Value->Value.u64 = qValue;
+ break;
+ }
+ case EFI_IFR_MAP_OP:
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ i+=ifrData->Length;
+ ifrData = (EFI_IFR_OP_HEADER*)(buf + i);
+ while (ifrData->OpCode != EFI_IFR_END_OP)
+ {
+ GetValueFromOpCode(ifrData,Value,Result);
+ Result = CompareHiiValue (&Data1, Value,NULL);
+ i+=ifrData->Length;
+ ifrData = (EFI_IFR_OP_HEADER*)(buf + i); //Skip its pair so incrementing ifrData
+ if (0 == Result)
+ {
+ GetValueFromOpCode(ifrData,Value,Result); //Retreiving the value
+ while(ifrData->OpCode != EFI_IFR_END_OP)
+ {
+ i+=ifrData->Length;
+ ifrData = (EFI_IFR_OP_HEADER*)(buf + i);
+ }
+ }
+ else
+ {
+ i+=ifrData->Length;
+ ifrData = (EFI_IFR_OP_HEADER*)(buf + i);
+ }
+ }
+ if ((EFI_IFR_END_OP == ifrData->OpCode) && (ScopeCount)) //Since endopcode validated before itself here we decrementing scope
+ {
+ ScopeCount --;
+ }
+ break;
+ case EFI_IFR_CONDITIONAL_OP:
+ //
+ // Pop third expression from the expression stack
+ //
+ Status = PopExpression (&Data3);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Pop second expression from the expression stack
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ //
+ // Pop first expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ if (Data1.Value.b) {
+ Value = &Data2;
+ } else {
+ Value = &Data3;
+ }
+ break;
+ case EFI_IFR_EQUAL_OP:
+ case EFI_IFR_NOT_EQUAL_OP:
+ case EFI_IFR_GREATER_EQUAL_OP:
+ case EFI_IFR_GREATER_THAN_OP:
+ case EFI_IFR_LESS_EQUAL_OP:
+ case EFI_IFR_LESS_THAN_OP:
+ //
+ // Compare two integer, string, boolean or date/time
+ //
+ Status = PopExpression (&Data2);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+ if (Data2.Type > EFI_IFR_TYPE_BOOLEAN && Data2.Type != EFI_IFR_TYPE_STRING) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ //
+ // Pop another expression from the expression stack
+ //
+ Status = PopExpression (&Data1);
+ if (EFI_ERROR (Status)) {
+ goto DONE;
+ }
+
+ Result = CompareHiiValue (&Data1, &Data2,NULL);
+ if (Result == EFI_INVALID_PARAMETER) {
+ Status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+ GetValueFromOpCode(ifrData,Value,Result);
+ break;
+ case EFI_IFR_UINT8_OP:
+ case EFI_IFR_UINT16_OP:
+ case EFI_IFR_UINT32_OP:
+ case EFI_IFR_UINT64_OP:
+ GetValueFromOpCode(ifrData,Value,Result);
+ break;
+
+ // binary-op
+
+ case EFI_IFR_ADD_OP:
+ case EFI_IFR_SUBTRACT_OP:
+ case EFI_IFR_MULTIPLY_OP:
+ case EFI_IFR_DIVIDE_OP:
+ case EFI_IFR_MODULO_OP:
+ case EFI_IFR_BITWISE_AND_OP:
+ case EFI_IFR_BITWISE_OR_OP:
+ case EFI_IFR_SHIFT_LEFT_OP:
+ case EFI_IFR_SHIFT_RIGHT_OP:
+ GetValueFromOpCode(ifrData,Value,Result);
+ break;
+ case EFI_IFR_UNDEFINED_OP:
+ Value1->Type = EFI_IFR_TYPE_UNDEFINED;
+ return;
+ default:
+ goto DONE;
+ break;
+
+ }
+ PushExpression(Value);
+ DONE:
+ i += ((EFI_IFR_OP_HEADER*)(buf + i))->Length;
+ ifrData = (EFI_IFR_OP_HEADER*)(buf + i);
+ } while(ScopeCount);
+ MemFreePointer(&questionValue);
+ Status = PopExpression (&Data1);
+ if(EFI_ERROR (Status)){
+ Data1.Type = EFI_IFR_TYPE_UNDEFINED;
+ }
+ MemCopy(Value1,&Data1,sizeof(EFI_HII_VALUE));
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _AddHpkControls
+//
+// Description: Add Control Setup Data
+//
+// Parameter:
+//
+// Return value: UINTN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN _AddHpkControls(EFI_HII_HANDLE Handle, UINT8 *buff,UINTN Size, PAGE_INFO **NewPageInfo, UINT32 *AllocatedPageSize, UINT32 *PageOffset)
+{
+ CONTROL_FLAGS control_Flags;
+ CONTROL_INFO *control_Info;
+ CONTROL_INFO *NotifyContext = (CONTROL_INFO*)NULL;
+ EFI_IFR_OP_HEADER *opHeader= NULL;
+ EFI_EVENT RefreshIdEvent = (EFI_EVENT)NULL;
+ EFI_IFR_OP_HEADER *opHdrPtr= (EFI_IFR_OP_HEADER *)NULL;
+
+
+ BOOLEAN addControl = TRUE;
+ BOOLEAN updatecondvars = TRUE;
+ UINT8 opCode = 0;
+ UINT16 controlLabel = 0;
+ UINT16 controlIndex = 0;
+ UINT16 destPageID =0xFFFF;
+ UINT16 controlType = 0;
+ UINT16 devicePathId = 0;
+ UINT16 helpOffset = 0;
+ UINT16 questionId = 0;
+ UINT16 opcodeNum = 0;
+ UINT16 defaults_size=0;
+ UINT16 controlKey = 0;
+ UINT32 controlSize = 0;
+ UINT32 controlOffset = 0;
+ INT32 ifCounter = 0;
+ VOID *ctrlFailSafe = NULL;
+ VOID *ctrlOptimal = NULL;
+ UINTN i =0, end=0,j=0,index=0, itr = 0;
+ VOID *conditionalPtr = NULL;
+ VOID *controlPtr = NULL;
+ BOOLEAN Formlock = FALSE;//EIP:56896 support for Formlock
+ UINT16 refQuestionId = 0; //EIP: 55762
+ EFI_STATUS Status = EFI_SUCCESS;
+ INT32 ScopeCount = 0;
+
+
+ DEFAULT_VALUE *defaultValue = NULL, *Temp= NULL;//EIP:56214 Declaration for the Default value
+
+ SETUP_DEBUG_UEFI("\n[TSE] Entering _AddHpkControls\n");
+
+ // for loop for the number of controls of this
+ while(i < Size )
+ {
+ addControl = TRUE;
+ MemSet(&control_Flags, sizeof(CONTROL_FLAGS), 0);
+ control_Flags.ControlVisible =0x1;
+ controlType = 0;
+ CtrlVar = 0;
+ destPageID =0xFFFF;
+
+ opHeader = (EFI_IFR_OP_HEADER*)(buff + i);
+ if(opHeader->Scope)
+ {
+ PushScope(opHeader->OpCode);
+ }
+
+ // control type
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_SUBTITLE_OP:
+ controlType = CONTROL_TYPE_MEMO;
+ break;
+ case EFI_IFR_TEXT_OP:
+ controlType = CONTROL_TYPE_TEXT;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_CHECKBOX_OP:
+ controlType = CONTROL_TYPE_POPUPSEL;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ controlType = CONTROL_TYPE_NUMERIC;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ controlType = CONTROL_TYPE_PASSWORD;
+ break;
+ case EFI_IFR_ACTION_OP:
+ controlType = CONTROL_TYPE_ACTION;
+ break;
+ case EFI_IFR_MODAL_TAG_OP: //EIP-85745 Modal Support
+ (*NewPageInfo)->PageFlags.PageModal = 1;
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ controlType = CONTROL_TYPE_RESET;
+ break;
+ case EFI_IFR_REF_OP:
+ controlType = CONTROL_TYPE_SUBMENU;
+ destPageID = _GetPageNumFromFormID(((EFI_IFR_REF*)((char*)buff +i))->FormId);
+//EIP: 55762 Start
+ if(opHeader->Length >= sizeof(EFI_IFR_REF2))
+ {
+ refQuestionId = ((EFI_IFR_REF2*)((char*)buff +i))->QuestionId;
+ }
+//EIP: 55762 End
+ break;
+ case EFI_IFR_INCONSISTENT_IF_OP:
+ controlType = INCONSISTENT_IF;
+ break;
+ //EIP : NO_SUBMIT_IF
+ case EFI_IFR_NO_SUBMIT_IF_OP:
+ controlType = NO_SUBMIT_IF;
+ break;
+ case EFI_IFR_RULE_OP:
+ controlType = CONTROL_TYPE_RULE;
+ conditionalPtr = (VOID *)((UINT8 *)opHeader + sizeof(EFI_IFR_RULE));
+ break;
+ case EFI_IFR_END_OP:
+ PopScope(&opCode);
+ switch(opCode)
+ {
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
+ i += opHeader->Length;
+ end =1;
+ break;
+ case EFI_IFR_NO_SUBMIT_IF_OP:
+ case EFI_IFR_INCONSISTENT_IF_OP:
+ case EFI_IFR_SUPPRESS_IF_OP:
+ case EFI_IFR_GRAY_OUT_IF_OP:
+ case EFI_IFR_DISABLE_IF_OP:
+ controlType = --ifCounter? 0 : END_EVAL_IF;
+ break;
+ default:
+ controlType = 0;
+ break;
+ }
+ addControl = FALSE;
+ break;
+ case EFI_IFR_DATE_OP:
+ controlType = CONTROL_TYPE_DATE;
+ break;
+ case EFI_IFR_TIME_OP:
+ controlType = CONTROL_TYPE_TIME;
+ break;
+ case EFI_IFR_STRING_OP:
+ controlType = CONTROL_TYPE_POPUP_STRING;
+ break;
+ case EFI_IFR_SUPPRESS_IF_OP:
+ //case EFI_IFR_NO_SUBMIT_IF_OP:
+ case EFI_IFR_GRAY_OUT_IF_OP:
+ case EFI_IFR_DISABLE_IF_OP:
+ controlType = START_EVAL_IF;
+ addControl =FALSE;
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ controlType = CONTROL_TYPE_ORDERED_LIST;
+ break;
+ case EFI_IFR_VARSTORE_OP:
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP:
+ case EFI_IFR_VARSTORE_EFI_OP:
+ _AddVariable((UINT8*)opHeader, Handle);
+ addControl =FALSE;
+ break;
+ //EIP:56896 Form lock support provided.
+ case EFI_IFR_LOCKED_OP:
+ Formlock = TRUE;
+ break;
+ default:
+ addControl = FALSE;
+ break;
+ }
+
+ switch(controlType)
+ {
+ //EIP : NO_SUBMIT_IF
+ case NO_SUBMIT_IF:
+ case INCONSISTENT_IF:
+ case START_EVAL_IF: // IF for grayout,suppress, no submit and disable
+ if(updatecondvars == 1)
+ {
+ updatecondvars = 0;
+ conditionalPtr = (gConditionOverForm == TRUE) ? gConditionalOverFormPtr : (VOID *)opHeader;
+ }
+ ifCounter++;
+ break;
+ case END_EVAL_IF:
+ conditionalPtr = NULL;
+ updatecondvars = TRUE;
+ ifCounter = 0;
+ break;
+ default:
+ break;
+ }
+
+ if(end ==1)
+ break;
+
+ if(addControl)
+ {
+ defaults_size =0;
+
+ controlKey = _GetControlKeyToken((UINT8*)opHeader);
+ devicePathId = _GetControlDevicePathId((UINT8*)opHeader);
+ helpOffset = _GetHelpToken((UINT8*)opHeader);
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+
+ DefaultStoreCount = _UpdateDefaults(Handle, (void *)opHeader, &defaults_size, &ctrlFailSafe, &ctrlOptimal, &defaultValue,&control_Flags, conditionalPtr);
+ //EIP:56896 Checking for the Formlock condition
+ if(Formlock)
+ control_Flags.ControlReadOnly = 1;
+ //EIP:56124 Allocating the control Size depending on the default count of the control
+ controlSize = sizeof(CONTROL_INFO) + defaults_size * 2+ DefaultStoreCount*(sizeof(UINT16) + defaults_size);
+ control_Info = EfiLibAllocateZeroPool(controlSize);
+ if(control_Info == NULL)
+ {
+ i = Size;
+ goto DONE;
+ }
+
+ controlPtr = (VOID *)opHeader;
+
+ if(controlType == INCONSISTENT_IF )
+ {
+ controlType = CONTROL_TYPE_MSGBOX;
+ controlPtr = 0;
+ }
+ //EIP : NO_SUBMIT_IF
+ if(controlType == NO_SUBMIT_IF )
+ {
+ controlType = NO_SUBMIT_IF;
+ controlPtr = 0;
+ }
+
+ /* Update Control Info*/
+ /*
+ * control_Info->ControlHandle
+ * HII Handle to the formset that contains this control
+ */
+ control_Info->ControlHandle = Handle;
+ /*
+ * control_Info->ControlVariable
+ * Overrides the variable ID for this specific control
+ */
+ control_Info->ControlVariable = CtrlVar;
+ /*
+ * control_Info->ControlConditionalVariable
+ * Conditional variable ID?s for this control
+ * or
+ * For UEFI 2.1 Use the following.
+ * control_Info->ControlKey
+ * control_Info->DefaultStoreCount
+ * control_Info->Reserved
+ */
+ control_Info->ControlKey = controlKey;
+ control_Info->DevicePathId = devicePathId;
+ control_Info->DefaultStoreCount = DefaultStoreCount;
+ /*
+ * control_Info->ControlType
+ * Type of the control on the page
+ */
+ control_Info->ControlType = controlType & CONTROL_TYPE_MASK;
+ /*
+ * control_Info->ControlPageID
+ * Page ID that contains this control
+ */
+ control_Info->ControlPageID = PageListPtr ? (UINT16)PageListPtr->PageCount:1;
+ /*
+ * control_Info->ControlDestPageID
+ * Dest PageId. Only needed for controls of type CONTROL_TYPE_SUBMENU
+ */
+ control_Info->ControlDestPageID = destPageID;
+ /*
+ * control_Info->DestQuestionID
+ * Question Id that will be selected refered page is visited. Only needed for controls of type CONTROL_TYPE_SUBMENU
+ */
+ control_Info->DestQuestionID = refQuestionId; //EIP: 55762
+ /*
+ * control_Info->ControlFlags
+ * Various attributes for a specific control
+ */
+ control_Info->ControlFlags = control_Flags;
+ /*
+ * control_Info->ControlHelp
+ * Token for help string for this control
+ */
+ control_Info->ControlHelp = helpOffset;
+ /*
+ * control_Info->ControlLabel
+ * One-based label number that this control is ?linked to?
+ */
+ control_Info->ControlLabel = controlLabel;
+ /*
+ * control_Info->ControlIndex
+ * Zero-based opcode number from the last label
+ */
+ control_Info->ControlIndex = controlIndex;
+ /*
+ * control_Info->ControlLabelCount
+ * Number of opcodes associated with this control's label
+ */
+ control_Info->ControlLabelCount = opcodeNum;
+ /*
+ * control_Info->ControlPtr
+ * Pointer to control data in HII
+ */
+ control_Info->ControlPtr = (VOID *)controlPtr;
+ /*
+ * control_Info->ControlConditionalPtr
+ * Pointer to control condition data in HII
+ */
+ control_Info->ControlConditionalPtr = (gConditionOverForm == TRUE) ? gConditionalOverFormPtr :(VOID *)conditionalPtr;
+ /*
+ * control_Info->ControlDataLength
+ * Length of HII data for control
+ */
+ control_Info->ControlDataLength = defaults_size;
+ /*
+ * control_Info->ControlDataWidth
+ * Width of data (in bytes) for this control
+ */
+ control_Info->ControlDataWidth = defaults_size;
+ /*
+ * control_Info->QuestionId
+ * QuestionId of this control
+ */
+ control_Info->QuestionId = questionId;
+
+ //READ/WRTIE opcode opHeader
+ if((*NewPageInfo)->PageFlags.PageStdMap){
+
+ if (opHeader->Scope && controlType && addControl)
+ {
+ UINT32 scopeCount = 0;
+ BOOLEAN scoped = TRUE;
+
+ if(opHeader->OpCode == EFI_IFR_SUBTITLE_OP)
+ {
+ EFI_IFR_OP_HEADER *nextOpHeader = (EFI_IFR_OP_HEADER *)((UINT8 *)opHeader + opHeader->Length);
+ if(nextOpHeader->OpCode != EFI_IFR_END_OP)
+ scoped = FALSE;
+ }
+ itr = 0;
+ while(scoped)
+ {
+ opHdrPtr = (EFI_IFR_OP_HEADER*)((UINT8*)controlPtr + itr);
+ switch(opHdrPtr->OpCode)
+ {
+ case EFI_IFR_READ_OP:
+ case EFI_IFR_WRITE_OP:
+ case EFI_IFR_MAP_OP:
+ control_Info->ControlFlags.ControlRWEvaluate = 1;
+ scoped = FALSE;
+ break;
+ case EFI_IFR_END_OP:
+ if(scopeCount)
+ {
+ scopeCount--;
+ }
+ if (!scopeCount) //Check for sudden scopeCount from previous statement
+ scoped = FALSE;
+ break;
+ }
+ if(opHdrPtr->Scope)
+ {
+ scopeCount++;
+ }
+ itr += opHdrPtr->Length ;
+ }
+ }
+ }
+
+ if(defaults_size)
+ {
+ /*
+ * control_Info[sizeof(CONTROL_INFO)]
+ * Used when user selects load failsafe value
+ */
+
+ /*
+ * control_Info[sizeof(CONTROL_INFO) + valSize]
+ * Used when user selects load optimal value
+ */
+ /* //EIP: 56124 Storing the default information by using Memcopy
+ MemCopy((UINT8 *)control_Info + sizeof(CONTROL_INFO), &ctrlFailSafe, defaults_size);
+ MemCopy((UINT8 *)control_Info + sizeof(CONTROL_INFO)+ defaults_size, &ctrlOptimal, defaults_size);
+ if(DefaultStoreCount)
+ {
+ index=0;
+ while(index < DefaultStoreCount)
+ {
+ MemCopy((UINT8 *)control_Info+sizeof(CONTROL_INFO) + (defaults_size * 2)+ (index *(sizeof(UINT16) + defaults_size)), &defaultValue->DefaultId, sizeof(UINT16) );
+ MemCopy((UINT8 *)control_Info + sizeof(CONTROL_INFO) + (defaults_size * 2) + (index *(sizeof(UINT16) + defaults_size)) + sizeof(UINT16) , &defaultValue->Value, defaults_size );
+ defaultValue = defaultValue->Next;
+ index++;
+ }
+
+ }
+
+ */
+ Temp = defaultValue;
+ switch(defaults_size)
+ {
+ case 1: // BYTE
+ *((UINT8 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO))) = *((UINT8 *) ctrlFailSafe);
+ *((UINT8 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO) + defaults_size)) = *((UINT8 *)ctrlOptimal);
+ if(DefaultStoreCount)
+ {//copy the defaults to the location in the control info
+ index=0;
+ while(index < DefaultStoreCount)
+ {
+ MemCopy((UINT8 *)control_Info+sizeof(CONTROL_INFO) + (defaults_size * 2)+ (index *(sizeof(UINT16) + defaults_size)), &Temp->DefaultId, sizeof(UINT16) );
+ *((UINT8 *) ( (UINT8 *)control_Info + sizeof(CONTROL_INFO)+(defaults_size * 2)+(index *(sizeof(UINT16) + defaults_size))+ sizeof(UINT16) )) = (UINT8 ) (Temp->Value);
+ Temp = Temp->Next;
+ index++;
+ }
+
+ }
+ break;
+ case 2: //WORD
+ *((UINT16 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO))) = *((UINT16 *)ctrlFailSafe);
+ *((UINT16 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO) + defaults_size)) = *((UINT16 *)ctrlOptimal);
+ if(DefaultStoreCount)
+ {//copy the defaults to the location in the control info
+ index=0;
+ while(index < DefaultStoreCount)
+ {
+ MemCopy((UINT8 *)control_Info+sizeof(CONTROL_INFO) + (defaults_size * 2)+ (index *(sizeof(UINT16) + defaults_size)), &Temp->DefaultId, sizeof(UINT16) );
+ *((UINT16 *) ( (UINT8 *)control_Info + sizeof(CONTROL_INFO)+(defaults_size * 2)+(index *(sizeof(UINT16) + defaults_size))+ sizeof(UINT16) ) )= (UINT16 ) (Temp->Value);
+ Temp = Temp->Next;
+ index++;
+ }
+
+ }
+ break;
+ case 4: //DWORD
+ *((UINT32 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO))) = *((UINT32 *)ctrlFailSafe);
+ *((UINT32 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO) + defaults_size)) = *((UINT32 *)ctrlOptimal);
+ if(DefaultStoreCount)
+ {//copy the defaults to the location in the control info
+ index=0;
+ while(index < DefaultStoreCount)
+ {
+ MemCopy((UINT8 *)control_Info+sizeof(CONTROL_INFO) + (defaults_size * 2)+ (index *(sizeof(UINT16) + defaults_size)), &Temp->DefaultId, sizeof(UINT16) );
+ *((UINT32 *) ( (UINT8 *)control_Info + sizeof(CONTROL_INFO)+(defaults_size * 2)+(index *(sizeof(UINT16) + defaults_size))+ sizeof(UINT16) )) = (UINT32) (Temp->Value);
+ Temp = Temp->Next;
+ index++;
+ }
+
+ }
+ break;
+ case 8: //QWORD
+ *((UINT64 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO))) = *((UINT64 *)ctrlFailSafe);
+ *((UINT64 *) ((UINT8 *)control_Info + sizeof(CONTROL_INFO) + defaults_size)) = *((UINT64 *)ctrlOptimal);
+ if(DefaultStoreCount)
+ {//copy the defaults to the location in the control info
+ index=0;
+ while(index < DefaultStoreCount)
+ {
+ MemCopy((UINT8 *)control_Info+sizeof(CONTROL_INFO) + (defaults_size * 2)+ (index *(sizeof(UINT16) + defaults_size)), &Temp->DefaultId, sizeof(UINT16) );
+ *((UINT64 *) ( (UINT8 *)control_Info + sizeof(CONTROL_INFO)+(defaults_size * 2)+(index *(sizeof(UINT16) + defaults_size))+ sizeof(UINT16) )) = (UINT64) (Temp->Value);
+ Temp = Temp->Next;
+ index++;
+ }
+
+ }
+ break;
+ default: // MemCopy the value equivalent to the default buffer size
+ MemCopy( ((UINT8 *)control_Info + sizeof(CONTROL_INFO)) , (UINT8 *)ctrlFailSafe, defaults_size);
+ MemCopy( ((UINT8 *)control_Info + sizeof(CONTROL_INFO) + defaults_size) , (UINT8 *)ctrlOptimal, defaults_size);
+ break;
+ }
+ }
+ //Create group event using Refresh Id GUID
+ if ( control_Info->ControlFlags.RefreshID )//EIP-105468
+ {
+ Status = CreateEventforIFR (control_Info);
+ if (EFI_ERROR (Status))
+ {
+ i = Size;
+ goto DONE;
+ }
+ }
+ //EIP-148837
+ /*if(IsRefreshIdSet) {
+ ++gRefreshIdCount; //increament the refresh id control count
+ NotifyContext = EfiLibAllocateZeroPool(sizeof(CONTROL_INFO));
+ if(NotifyContext == NULL)
+ {
+ i = Size;
+ goto DONE;
+ }
+ MemCopy(NotifyContext, control_Info, sizeof(CONTROL_INFO));
+ gBS->CreateEventEx (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)RefreshGroupOnCallBack,
+ (void*)NotifyContext,
+ &RefreshEventGroupId,
+ &RefreshIdEvent
+ );
+ IsRefreshIdSet = FALSE;
+ if(RefreshIdEvent == NULL)
+ {
+ i = Size;
+ goto DONE;
+ }
+
+ //store the Event and Context for this control, to be freed on exiting the application.
+ gRefreshIdInfo = MemReallocateZeroPool(gRefreshIdInfo, sizeof(REFRESH_ID_INFO)*(gRefreshIdCount-1), sizeof(REFRESH_ID_INFO)*gRefreshIdCount);
+ if(gRefreshIdInfo == NULL)
+ {
+ i = Size;
+ goto DONE;
+ }
+ gRefreshIdInfo[gRefreshIdCount-1].pEvent = RefreshIdEvent;
+ gRefreshIdInfo[gRefreshIdCount-1].pNotifyContext = (UINT8*)NotifyContext;
+ }*/
+ while(defaultValue != NULL)
+ {
+ Temp=defaultValue;
+ defaultValue = defaultValue->Next;
+ MemFreePointer(&Temp);
+ }
+
+ controlOffset = AddControlToList(control_Info, controlSize);
+ CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &controlOffset, sizeof(UINT32));
+ MemFreePointer(&control_Info);
+
+ if (controlType & ~CONTROL_TYPE_MASK)
+ {
+ controlOffset = 0;
+ CreatePage(NewPageInfo, AllocatedPageSize, PageOffset, &controlOffset, sizeof(UINT32));
+ }
+ }
+
+ MemFreePointer (&ctrlFailSafe);
+ MemFreePointer (&ctrlOptimal);
+ j= opHeader->Length;
+ if (opHeader->Scope && controlType && addControl)
+ {
+ UINT32 scopeCount = 0;
+ BOOLEAN scoped = TRUE;
+
+ if(opHeader->OpCode == EFI_IFR_SUBTITLE_OP)
+ {
+ EFI_IFR_OP_HEADER *nextOpHeader = (EFI_IFR_OP_HEADER *)((UINT8 *)opHeader + opHeader->Length);
+ if(nextOpHeader->OpCode != EFI_IFR_END_OP)
+ scoped = FALSE;
+ }
+
+ while(scoped)
+ {
+ switch(((EFI_IFR_OP_HEADER*)(buff + i + j))->OpCode)
+ {
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ //j += sizeof(EFI_IFR_ONE_OF_OPTION); //EIP71351
+ j += ((EFI_IFR_OP_HEADER*)(buff + i + j))->Length; //Aptio giving length as 0xe(matches size of EFI_IFR_ONE_OF_OPTION) but in latest EDKII driver it is 0x1c.
+ break;
+ case EFI_IFR_END_OP:
+ if(scopeCount)
+ {
+ scopeCount--;
+ j += ((EFI_IFR_OP_HEADER*)(buff + i + j))->Length;
+ }else
+ {
+ scoped = FALSE;
+ }
+ break;
+ default:
+ if(((EFI_IFR_OP_HEADER*)(buff + i + j))->Scope)
+ {
+ scopeCount++;
+ }
+ j += ((EFI_IFR_OP_HEADER*)(buff + i + j))->Length;
+ break;
+ }
+ // Increase Control Index to account above control and final EFI_IFR_END_OP
+ controlIndex++;
+ }
+ }
+
+ //
+ // Add Inconsistant Control for Control that have INCONSISTANT_IF embedded within
+ // their scope. Eg. BOOLEAN | DATE | NUMERIC | ORDERED_LIST | STRING | TIME
+ //
+ if(Inconsistant)
+ {
+ BOOLEAN BackupgConditionOverForm = FALSE;
+ Inconsistant = FALSE;
+ IsRecursive = TRUE;
+ BackupgConditionOverForm = gConditionOverForm; //To have the current control as condptr. If saving condition over form as condptr then it will hang
+ gConditionOverForm = FALSE;
+ _AddHpkControls(Handle, buff + i + opHeader->Length, j - opHeader->Length,
+ NewPageInfo, AllocatedPageSize, PageOffset);
+ gConditionOverForm = BackupgConditionOverForm;
+ IsRecursive = FALSE;
+ }
+ //EIP : NO_SUBMIT_IF
+ if(NoSubmitIf)
+ {
+ BOOLEAN BackupgConditionOverForm = FALSE;
+ NoSubmitIf = FALSE;
+ IsRecursive = TRUE;
+ BackupgConditionOverForm = gConditionOverForm; //To have the current control as condptr if has condition over form as condptr then it will hang
+ gConditionOverForm = FALSE;
+ _AddHpkControls(Handle, buff + i + opHeader->Length, j - opHeader->Length,
+ NewPageInfo, AllocatedPageSize, PageOffset);
+ gConditionOverForm = BackupgConditionOverForm;
+ IsRecursive = FALSE;
+ }
+
+ i= i+ j;
+ };
+DONE:
+ SETUP_DEBUG_UEFI("\n[TSE] Exiting _AddHpkControls\n");
+ return i;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AddControlToList
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ControlInfo
+// UINT32 ControlSize
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 AddControlToList(CONTROL_INFO *ControlInfo, UINT32 ControlSize)
+{
+// EFI_STATUS status = EFI_SUCCESS;
+ UINT32 offset = 0;
+ UINT32 u32Compensation = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering AddControlToList(), QuestionId: %d \n", ControlInfo->QuestionId );
+
+#if TSE_DEBUG_MESSAGES
+ if((gDbgPrint & PRINT_UEFI_PARSE)== PRINT_UEFI_PARSE)
+ DebugShowControlInfo( ControlInfo->ControlPageID, ControlInfo) ;
+#endif
+
+ if(gIFRChangeNotify)
+ {
+ offset = _AdvAddControlToList(ControlInfo, ControlSize);
+ if(offset)
+ {
+ goto DONE;
+ }
+ }
+ u32Compensation = (sizeof(UINT64) - (ControlSize % sizeof(UINT64))) % sizeof(UINT64);
+
+ if((ControlListOffset + ControlSize + u32Compensation ) >= ControlListSize)
+ {
+ //Allocate 4k at a time
+ gControlInfo = MemReallocateZeroPool( gControlInfo, ControlListSize, ControlListSize + 4096 );
+/*
+ if(gControlInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ offset = -1;
+ goto DONE;
+ }
+*/
+ ControlListSize+=4096;
+ }
+
+ MemCopy((UINT8 *)gControlInfo + ControlListOffset, ControlInfo, ControlSize);
+ offset = ControlListOffset;
+ ControlListOffset += (ControlSize + u32Compensation);
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting AddControlToList()\n");
+
+ return offset;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AddPageIdToList
+//
+// Description:
+//
+// Parameter: PAGE_ID_INFO *NewPageIdInfo
+//
+// Return value: EFI_STATUS -
+// EFI_SUCCESS -
+// EFI_OUT_OF_RESOURCES -
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ UINT32 offset;
+ UINT32 PageIdSize = sizeof(PAGE_ID_INFO);
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering AddPageIdToList(), PageClass: 0x%x, PageSubClass: 0x%x,\n", NewPageIdInfo->PageClass, NewPageIdInfo->PageSubClass);
+
+ //@VgDebug
+ if( PageIdInfoPtr == NULL )
+ PageIdInfoOffset = PageIdInfoSize = 0; //EIP-73396 Removed (PageIdSize=0) since size is 0 the first PageInfo will not copy to PageIdInfoPtr
+
+ if(PageIdInfoOffset + PageIdSize >= PageIdInfoSize)
+ {
+ //Allocate 4k at a time
+ PageIdInfoPtr = MemReallocateZeroPool( PageIdInfoPtr, PageIdInfoSize, PageIdInfoSize + 256 );
+ if(PageIdInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ PageIdInfoSize+=256;
+ }
+
+ MemCopy((UINT8 *)PageIdInfoPtr + PageIdInfoOffset, NewPageIdInfo, PageIdSize);
+ offset = PageIdInfoOffset;
+ PageIdInfoOffset += PageIdSize;
+
+ if(!PageIdListPtr)
+ {
+ PageIdListSize = 128;
+ PageIdListPtr = EfiLibAllocateZeroPool(PageIdListSize);
+ if(PageIdListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset;
+ PageIdListPtr->PageIdCount = 1;
+ PageIdListOffset = sizeof(PAGE_ID_LIST);
+ }
+ else
+ {
+ if(PageIdListOffset + sizeof(UINT32) >= PageIdListSize)
+ {
+ PageIdListPtr = MemReallocateZeroPool(PageIdListPtr, PageIdListSize, PageIdListSize + 128);
+ if(PageIdInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ PageIdListSize += 128;
+ }
+ PageIdListPtr->PageIdList[PageIdListPtr->PageIdCount] = offset;
+ PageIdListPtr->PageIdCount++;
+ PageIdListOffset += sizeof(UINT32);
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting AddPageIdToList(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AddPageToList
+//
+// Description:
+//
+// Parameter: PAGE_INFO *NewPageInfo
+// UINT32 PageSize
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 offset;
+ UINT32 ReallocSize=4096;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering AddPageToList(), PageFormID: %d \n", NewPageInfo->PageFormID );
+
+#if TSE_DEBUG_MESSAGES
+ if((gDbgPrint & PRINT_UEFI_PARSE)== PRINT_UEFI_PARSE)
+ DebugShowPageInfo(NewPageInfo->PageFormID, NewPageInfo) ;
+#endif
+
+
+ if(gIFRChangeNotify)
+ {
+ status = _AdvAddPageToList(NewPageInfo, PageSize);
+ if(status == EFI_SUCCESS)
+ {
+ goto DONE;
+ }
+ status = EFI_SUCCESS;// EIP 88658 : Minisetup crashes after controller reconnection during Hii callback
+ }
+ if(PageInfoOffset + PageSize >= PageInfoSize)
+ {
+ if(ReallocSize < PageSize)
+ ReallocSize = (PageSize & 0xFFFFF000) + 4096;
+ PageInfoPtr = MemReallocateZeroPool( PageInfoPtr, PageInfoSize, PageInfoSize + ReallocSize ); //Allocate 4k at a time
+ if(PageInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ PageInfoSize+=ReallocSize;
+ }
+
+ MemCopy((UINT8 *)PageInfoPtr + PageInfoOffset, NewPageInfo, PageSize);
+ offset = PageInfoOffset;
+ PageInfoOffset += PageSize;
+
+ if(!PageListPtr)
+ {
+ PageListSize = 512;
+ PageListPtr = EfiLibAllocateZeroPool(PageListSize);
+ if(PageListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ /* Leave space for offset of Page 0 */
+ PageListPtr->PageCount = 1;
+ PageListPtr->PageList[PageListPtr->PageCount] = offset;
+ PageListPtr->PageCount++;
+ PageListOffset = sizeof(PAGE_LIST)+sizeof(UINT32);
+ }
+ else
+ {
+ if(PageListOffset + sizeof(UINT32) >= PageListSize)
+ {
+ PageListPtr = MemReallocateZeroPool(PageListPtr, PageListSize, PageListSize + 128);
+ if(PageListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ PageListSize += 128;
+ }
+ PageListPtr->PageList[PageListPtr->PageCount] = offset;
+ PageListPtr->PageCount++;
+ PageListOffset += sizeof(UINT32);
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting AddPageToList(), status = 0x%x \n" , status ) ;
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AddVariableToList
+//
+// Description:
+//
+// Parameter:
+//
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS -
+// EFI_OUT_OF_RESOURCES -
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AddVariableToList(VARIABLE_INFO *NewVariableInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ UINT32 offset;
+ UINT32 VariableSize = sizeof(VARIABLE_INFO);
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering AddVariableToList(), VariableName: %s\n", NewVariableInfo->VariableName);
+
+ if(VariableInfoOffset + VariableSize >= VariableInfoSize)
+ {
+ //Allocate 4k at a time
+ VariableInfoPtr = MemReallocateZeroPool( VariableInfoPtr, VariableInfoSize,
+ VariableInfoSize + 256 );
+ if(VariableInfoPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ VariableInfoSize += 256;
+ }
+
+ MemCopy((UINT8 *)VariableInfoPtr + VariableInfoOffset, NewVariableInfo, VariableSize);
+ offset = VariableInfoOffset;
+ VariableInfoOffset += VariableSize;
+
+ if(!VariableListPtr)
+ {
+ VariableListSize = 128;
+ VariableListPtr = EfiLibAllocateZeroPool(VariableListSize);
+ if(VariableListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset;
+ VariableListPtr->VariableCount = 1;
+ VariableListOffset = sizeof(VARIABLE_LIST);
+ }
+ else
+ {
+ if(VariableListOffset + sizeof(UINT32) >= VariableListSize)
+ {
+ VariableListPtr = MemReallocateZeroPool(VariableListPtr, VariableListSize,
+ VariableListSize + 128);
+ if(VariableListPtr == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ VariableListSize += 128;
+ }
+ VariableListPtr->VariableList[VariableListPtr->VariableCount] = offset;
+ gnewCtrlVar = VariableListPtr->VariableCount;
+ VariableListPtr->VariableCount++;
+ // EIP : Display Error message variable exceeds Maximum variable supported in TSE
+ if(VariableListPtr->VariableCount >= MAX_VARIABLE)
+ {
+ CHAR16 *Temp = L"Reached TSE Maximum supported variables";
+ _DisplayErrorMessage(Temp);
+ ASSERT(0);
+ }
+ VariableListOffset += sizeof(UINT32);
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting AddVariableToList(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: CreatePage
+//
+// Description:
+//
+// Parameter: PAGE_INFO **PageInfo
+// UINT32 *AllocatedSize
+// UINT32 *Offset
+// VOID *Buff
+// UINT32 BuffSize
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS -
+// EFI_OUT_OF_RESOURCES -
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize,
+ UINT32 *Offset, VOID *Buff, UINT32 BuffSize)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering CreatePage()\n");
+
+ if(!(*AllocatedSize))
+ {
+ //creating a new page
+ *PageInfo = EfiLibAllocateZeroPool(BuffSize);
+ if(PageInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ *AllocatedSize = BuffSize;
+ MemCopy(*PageInfo, Buff, BuffSize);
+
+ if((*PageInfo)->PageControls.ControlCount)
+ *Offset = BuffSize;
+ else //We have space to store one more offset
+ //*Offset = BuffSize - sizeof((*PageInfo)->PageControls.ControlList[0]);
+ *Offset = (UINT32)((UINTN)(&(*PageInfo)->PageControls.ControlList[0]) - (UINTN)(*PageInfo));
+ }
+ else
+ {
+ //adding offsets
+ if(*Offset + BuffSize >= *AllocatedSize)
+ {
+ //Allocate 128 bytes at a time
+ *PageInfo = MemReallocateZeroPool( *PageInfo, *AllocatedSize, *AllocatedSize + 128 );
+ if(PageInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ *AllocatedSize+=128;
+ }
+ MemCopy((UINT8 *)(*PageInfo) + *Offset, Buff, BuffSize);
+ *Offset += BuffSize;
+ (*PageInfo)->PageControls.ControlCount++;
+ }
+
+DONE:
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting CreatePage(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: ParseForm
+//
+// Description: Parse the HII Package for the Form Pack and parse the FormPack
+//
+// Parameter: IFRPackage - The Header of the Package to parse.
+//
+// Return value: EFI_STATUS - Return the Status of the Parsing
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ParseForm(SETUP_LINK *Setup_Link)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_HII_PACKAGE_HEADER *pkgHdr;
+ EFI_IFR_FORM_SET *formSet = NULL;
+ EFI_IFR_FORM *form = (EFI_IFR_FORM *)NULL;
+ AMI_EFI_IFR_FORM_MAP_METHOD *formMapMethod = (AMI_EFI_IFR_FORM_MAP_METHOD *) NULL;
+ AMI_EFI_IFR_FORM_MAP *formMap = (AMI_EFI_IFR_FORM_MAP *) NULL;
+ EFI_IFR_GUID_CLASS *guidClassOp;
+ EFI_IFR_GUID_SUBCLASS *guidSubClassOp;
+ EFI_IFR_OP_HEADER *opHeader;
+ EFI_GUID DriverHealthHiiGuid = EFI_HII_DRIVER_HEALTH_FORMSET_GUID;
+ EFI_GUID CredentialHiiGuid = EFI_HII_USER_CREDENTIAL_FORMSET_GUID;
+ extern EFI_GUID *gFSetGuid;
+ UINT16 FormSetTitle = 0 ;
+ UINT32 formOffset = 0, ifOverformCounter = 0;
+ UINT8 Opcode = 0;
+ CONTROL_INFO *control_Info;
+
+ UINT8 opCode = 0;
+ UINT16 extendOpCode = 0;
+ UINT16 fsClass = 0;
+ UINT16 fsSubClass = 0;
+ UINT32 controlOffset = 0;
+ UINT32 varIndex = 0;
+ UINTN i = 0,formMapLength =0,formType = 0;
+ UINTN jIndex = 0;
+
+ PVAR_KEY_TABLE pVarTable;
+ UINT32 allocatedPageSize = 0;
+ PAGE_INFO *tmpPgInfo;
+
+ UINT8 *ifrData = NULL;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering ParseForm()\n" );
+
+ pkgHdr = (EFI_HII_PACKAGE_HEADER*)Setup_Link->FormSet;
+
+ if(pkgHdr->Type != EFI_HII_PACKAGE_FORMS)
+ {
+ status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+ ifrData = ((UINT8 *)pkgHdr) + sizeof(EFI_HII_PACKAGE_HEADER);
+
+ while(i < pkgHdr->Length)
+ {
+ opHeader = (EFI_IFR_OP_HEADER*)(ifrData + i);
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_SUPPRESS_IF_OP:
+ case EFI_IFR_DISABLE_IF_OP:
+ case EFI_IFR_GRAY_OUT_IF_OP:
+ if(updateformcondvars == 1)//EIP-120418 Support suppressif,grayoutif, DisableIf over form
+ {
+ updateformcondvars = 0;
+ gConditionOverForm = TRUE;
+ gConditionalOverFormPtr = (void*)opHeader;
+ }
+ PushScope(opHeader->OpCode);
+ ifOverformCounter++;
+ break;
+ case EFI_IFR_FORM_SET_OP:
+ formSet = (EFI_IFR_FORM_SET*)opHeader;
+
+ FormSetTitle = formSet->FormSetTitle;
+
+ if ( !ShowClassGuidFormsets( (TSE_EFI_IFR_FORM_SET*)formSet) ) //EIP-139099 If ClassGuid is matches then continue parsing to display formset
+ {
+ FormSetTitle = 0;//Clear FormSetTitle
+ i += (pkgHdr->Length - opHeader->Length); //Change i value to end of Pkg to skip parsing forms,etc,.
+ status = EFI_ABORTED;
+ gConditionOverForm = FALSE;
+ updateformcondvars = 1;
+ break;
+ }
+
+ if ( HideDynamicFormsets(&formSet->Guid) ) //EIP-95647 Suppressing formsets mentioned in elink AMITSE_SUPPRESS_DYNAMIC_FORMSET_LIST
+ {
+ FormSetTitle = 0;
+ i += (pkgHdr->Length - opHeader->Length);
+ status = EFI_ABORTED;
+ gConditionOverForm = FALSE;
+ updateformcondvars = 1;
+ break;
+ }
+
+ PushScope(opHeader->OpCode);
+
+ if(_IsVarGuidPresent(&formSet->Guid, &varIndex) == FALSE)
+ {
+ varIndex = _AddFormSetVariable(&formSet->Guid);
+ }
+
+ for(pVarTable = &VarKeyTable ; pVarTable->Next; pVarTable= pVarTable->Next)
+ ;
+
+ pVarTable->Next = EfiLibAllocateZeroPool(sizeof(VAR_KEY_TABLE));
+ if(pVarTable->Next == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ pVarTable = pVarTable->Next;
+ pVarTable->VarId = 0;
+ pVarTable->Index = (UINT16)varIndex;
+
+ // create the pages lookup table
+ _InitFormsetLinks((char*)ifrData, PageListPtr ? PageListPtr->PageCount:1);
+
+ // add NULL control above submenu in main
+ controlOffset = 0;
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset,
+ &controlOffset, sizeof(UINT32));
+
+ // add second null control for splitting the page in 2 halves
+ if (TotalRootPages == 7)
+ {
+ controlOffset = 0;
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset,
+ &controlOffset, sizeof(UINT32));
+ }
+
+ control_Info = (CONTROL_INFO*)EfiLibAllocateZeroPool(sizeof(CONTROL_INFO));
+ if(control_Info == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ // add the submenu control to main form that points to this form.
+ control_Info->ControlHandle = Setup_Link->Handle;
+ control_Info->ControlType = CONTROL_TYPE_SUBMENU;
+ control_Info->ControlDestPageID = PageListPtr ? ((UINT16)PageListPtr->PageCount):1 ;
+
+ control_Info->ControlFlags.ControlVisible = 1;
+
+ if(!IsGroupDynamicPages()) //EIP: 59971
+ control_Info->ControlPtr = (VOID*)gFirstPageRef;
+
+/* What is this here for?
+
+ controlInfo->ControlPtr = (UINTN)gSetupData[HiiIndex].FormSet +
+ sizeof(EFI_HII_PACK_HEADER) +
+ sizeof(EFI_IFR_FORM_SET) +
+ TotalRootPages * sizeof(EFI_IFR_REF);
+*/
+
+ controlOffset = AddControlToList(control_Info, sizeof(CONTROL_INFO));
+ CreatePage(&FirstPage, &AllocatedFirstPageSize, &FirstPageOffset,
+ &controlOffset, sizeof(UINT32));
+ MemFreePointer(&control_Info);
+
+ TotalRootPages++;
+ break;
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
+ if(opHeader->OpCode == EFI_IFR_FORM_OP)
+ form = (EFI_IFR_FORM*)opHeader;
+ else{
+ formMap =(AMI_EFI_IFR_FORM_MAP *)opHeader;
+ formMapMethod =(AMI_EFI_IFR_FORM_MAP_METHOD *)((UINT8 *)formMap + sizeof(AMI_EFI_IFR_FORM_MAP));
+ formMapLength = sizeof(AMI_EFI_IFR_FORM_MAP);
+ //
+ // FormMap Form must contain at least one Map Method.
+ //
+ if (opHeader->Length < (formMapLength + sizeof(AMI_EFI_IFR_FORM_MAP_METHOD))) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Try to find the standard form map method.
+ //
+ while (formMapLength < opHeader->Length) {
+ if (EfiCompareGuid((EFI_GUID *) (VOID *) &formMapMethod->MethodIdentifier, &StandardFormGuid)) {
+ formType = 1;
+ break;
+ }
+ formMapMethod ++;
+ formMapLength+= sizeof(AMI_EFI_IFR_FORM_MAP_METHOD);
+ }
+ if(!formType)
+ formMapMethod =(AMI_EFI_IFR_FORM_MAP_METHOD *)((UINT8 *)formMap + sizeof(AMI_EFI_IFR_FORM_MAP));
+ }
+
+ tmpPgInfo = (PAGE_INFO*)EfiLibAllocateZeroPool(sizeof(PAGE_INFO));
+ if(tmpPgInfo == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ allocatedPageSize = PageOffset = 0;
+ NewPageInfo = NULL;
+
+ tmpPgInfo->PageFormID = (opHeader->OpCode == EFI_IFR_FORM_OP) ? form->FormId : formMap->FormId;
+ tmpPgInfo->PageID = PageListPtr ? (UINT16) PageListPtr->PageCount : 1;
+ tmpPgInfo->PageIdIndex = _GetPageIdIndex(&formSet->Guid, fsClass, fsSubClass);
+ tmpPgInfo->PageHandle = Setup_Link->Handle;
+ tmpPgInfo->PageParentID = PageListPtr ? _GetPageParent(PageListPtr->PageCount) : 0;
+ tmpPgInfo->PageSubTitle = (opHeader->OpCode == EFI_IFR_FORM_OP) ? form->FormTitle :formMapMethod->MethodTitle;
+ if(formType &&opHeader->OpCode == EFI_IFR_FORM_MAP_OP ){
+ tmpPgInfo->PageFlags.PageStdMap = 1;
+ }
+ else{
+ tmpPgInfo->PageFlags.PageStdMap = 0;
+ }
+ //tmpPgInfo->PageSubTitle = form->FormTitle;
+
+
+
+ for (jIndex = 0; jIndex < gGuidDumpCount; jIndex ++) //EIP64253 Check for offline vfr's
+ {
+ if (EfiCompareGuid (&gGuidDump [jIndex], &formSet->Guid))
+ {
+ break;
+ }
+ }
+ if (jIndex == gGuidDumpCount) //EIP64253 If offline vfr dont hide it
+ {
+ //EIP 94424 : Some form can't normal display when add Hii item will in runtime during
+ //EIP:68341 Support for displaying FormSet Title
+ if (tmpPgInfo->PageParentID == 0)
+ {
+ tmpPgInfo->PageSubTitle = FormSetTitle ;
+ }
+ //Check for Dynamic Page Flag
+ if (tmpPgInfo->PageParentID == 0 && IsGroupDynamicPages()) //PageParentID is 0 && SDL token is true
+ {
+ //then set as dynamic page
+ // if (!EfiCompareGuid (&formSet->Guid, &DriverHealthHiiGuid) || (NULL != gSfHandles)) //EIP 57661 Not to show the form with EFI_HII_DRIVER_HEALTH_FORMSET_GUID
+ // {
+ if ((NULL == gSfHandles) && (!EfiCompareGuid (&formSet->Guid, &DriverHealthHiiGuid)) && (!EfiCompareGuid (&formSet->Guid, &CredentialHiiGuid)) )
+ {
+ tmpPgInfo->PageFlags.PageDynamic = TRUE ;
+ }
+ if ((NULL == gSfHandles) && (EfiCompareGuid (&formSet->Guid, &DriverHealthHiiGuid))) //EIP174938 if driverhealth page we have to not consider it as dynamic page so returning aborted
+ { //If not returning aborted then arrow will displayed
+ status = EFI_ABORTED;
+ }
+ // }
+ tmpPgInfo->PageFlags.PageVisible = TRUE;
+ if ( tmpPgInfo->PageFlags.PageDynamic) //EIP-151552 Title is changing to MAIN and causing crashing while navigating from dynamic page to root page
+ {
+ tmpPgInfo->PageParentID = gDynamicParentPage;
+ }
+ }
+ if( (tmpPgInfo->PageParentID == 0) && (NULL != gSfHandles))
+ {
+ if ((NULL == gFSetGuid) && (!EfiCompareGuid (&formSet->Guid, &DriverHealthHiiGuid)) && (!EfiCompareGuid (&formSet->Guid, &CredentialHiiGuid)) )
+ {
+ tmpPgInfo->PageFlags.PageVisible = FALSE;
+ }
+ else if ((NULL != gFSetGuid) && (EfiCompareGuid (&formSet->Guid, gFSetGuid)))
+ {
+ tmpPgInfo->PageFlags.PageVisible = FALSE;
+ }
+ else
+ tmpPgInfo->PageFlags.PageVisible = TRUE;
+ }
+ }
+ /*
+ * Add tmpPgInfo to PageInfo and PageList Structures.
+ * Memory for tmpPgInfo->PageControls.ControlList[0]
+ * will be allocated later when adding controls
+ */
+ CreatePage(&NewPageInfo, &allocatedPageSize, &PageOffset,
+ tmpPgInfo, sizeof(PAGE_INFO));
+ MemFreePointer(&tmpPgInfo);
+
+ i += _AddHpkControls(Setup_Link->Handle, (UINT8*)opHeader, pkgHdr->Length - i,
+ &NewPageInfo, &allocatedPageSize, &PageOffset);
+ AddPageToList(NewPageInfo, PageOffset);
+ // EIP: Display Error message when Control count exceeds MAX_CONTROLS supported
+ if(NewPageInfo->PageControls.ControlCount >= MAX_CONTROLS)
+ {
+ CHAR16 *Temp = L"Reached TSE Maximum supported Controls";
+ _DisplayErrorMessage(Temp);
+ ASSERT(0);
+ }
+ MemFreePointer(&NewPageInfo);
+ /* The Form Opcode Length is already added */
+ continue;
+
+ case EFI_IFR_GUID_OP:
+ extendOpCode = (UINT8)*((UINT8*)opHeader + sizeof(EFI_IFR_GUID));
+ switch(extendOpCode)
+ {
+ case EFI_IFR_EXTEND_OP_LABEL: //0x0
+ break;
+ case EFI_IFR_EXTEND_OP_BANNER: //0x1
+ break;
+ case EFI_IFR_EXTEND_OP_TIMEOUT: //0x2
+ break;
+ case EFI_IFR_EXTEND_OP_CLASS: //0x3
+ guidClassOp = (EFI_IFR_GUID_CLASS*)opHeader;
+ fsClass = guidClassOp->Class;
+ break;
+ case EFI_IFR_EXTEND_OP_SUBCLASS: //0x4
+ guidSubClassOp = (EFI_IFR_GUID_SUBCLASS*)opHeader;
+ fsSubClass = guidSubClassOp->SubClass;
+ break;
+ default:
+ break;
+ }
+
+ break;
+ case EFI_IFR_VARSTORE_OP: // 0x24
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP: //0x25
+ case EFI_IFR_VARSTORE_EFI_OP: // 0x26
+ _AddVariable((UINT8*)opHeader, Setup_Link->Handle);
+
+ break;
+ case EFI_IFR_DEFAULTSTORE_OP:
+ break;
+ case EFI_IFR_END_OP:
+ PopScope(&opCode);
+ if(EFI_IFR_SUPPRESS_IF_OP == opCode || EFI_IFR_GRAY_OUT_IF_OP == opCode || EFI_IFR_DISABLE_IF_OP == opCode)
+ {
+ --ifOverformCounter;//Resetting flags
+ gConditionOverForm = FALSE;
+ updateformcondvars = 1;
+ }
+
+ if(opCode == EFI_IFR_FORM_SET_OP)
+ {
+ if(FSetLinks !=NULL)
+ {
+ MemFreePointer(&FSetLinks);
+ FSetLinks = NULL;
+ }
+ i += sizeof(EFI_HII_PACKAGE_HEADER);
+ }
+ // To match the Scoping. Don't abort the parsing.
+ // Suppressif in the Form level need to be supported.
+ /*
+ else0
+ {
+ status = EFI_ABORTED;
+ goto DONE;
+ }
+ */
+ break;
+ default:
+ if(opHeader->Scope)
+ PushScope(opHeader->OpCode);
+ break;
+ }
+
+ i += opHeader->Length;
+ }
+
+ _CleanVarKeyTable();
+ Setup_Link->Added = 1;
+
+DONE:
+ SETUP_DEBUG_UEFI ("\n[TSE] Exiting ParseForm(), status = 0x%x \n" , status );
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _AdvAddControlToList
+//
+// Description: Add control info the control list
+//
+// Input: CONTROL_INFO *ControlInfo - Pointer to the CONTROL_INFO
+// UINT32 ControlSize - Size the control info
+//
+// Output: UINT32 offset - Return the control list offset
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 _AdvAddControlToList(CONTROL_INFO *ControlInfo, UINT32 ControlSize)
+{
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO*)gControlInfo;
+ UINT32 ctrlSize = 0;
+ UINT32 offset = 0;
+ UINT32 u32Compensation = 0;
+ UINT32 ctrlListOffset = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _AdvAddControlToList()\n");
+
+ do
+ {
+ if(ctrlInfo == NULL)
+ {
+ break; //If ctrlInfo is invalid
+ }
+
+ if(ctrlListOffset == ControlListOffset)
+ {
+ break;
+ }
+
+ //ctrlSize = sizeof(CONTROL_INFO) + ctrlInfo->ControlDataWidth * 2;
+ ctrlSize = sizeof(CONTROL_INFO) + (2* ctrlInfo->ControlDataWidth) + (ctrlInfo->DefaultStoreCount * (sizeof(UINT16)+ctrlInfo->ControlDataWidth));
+ if(ctrlInfo->ControlHandle == NULL && ctrlSize == ControlSize)
+ {
+ // Add the Control
+ MemCopy(ctrlInfo, ControlInfo, ControlSize);
+ offset = ctrlListOffset;
+ break;
+ }
+
+
+ // Skip to the Next Control in gControl
+ u32Compensation = (sizeof(UINT64) - (ctrlSize % sizeof(UINT64))) % sizeof(UINT64);
+ ctrlListOffset += (ctrlSize + u32Compensation);
+ ctrlInfo = (CONTROL_INFO *)((UINT8 *)ctrlInfo + ctrlSize + u32Compensation);
+ }while(TRUE);
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _AdvAddControlToList()\n");
+
+ return offset;
+}
+
+VOID UpdateCtrlDestPageID(VOID * Handle, UINT16 NewPageID)
+{
+ UINT32 page = PARSE_START_INDEX;
+ UINT32 control = 0;
+
+ for(;page < PageListPtr->PageCount; page++)
+ {
+ PAGE_INFO *pgInfo = (PAGE_INFO *)((UINT8 *)PageInfoPtr + PageListPtr->PageList[page]);
+
+ if(pgInfo->PageHandle == Handle)
+ {
+ for(control = 0;control < pgInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *controlInfo = NULL;
+
+ controlInfo = (CONTROL_INFO*)((UINT8 *)gControlInfo + pgInfo->PageControls.ControlList[control]);
+ if((NewPageID < controlInfo->ControlDestPageID) && (controlInfo->ControlDestPageID != 0xFFFF))
+ {
+ controlInfo->ControlDestPageID--;
+ }
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _AdvAddPageToList
+//
+// Description: Add page into to the page list
+//
+// Input: PAGE_INFO *NewPageInfo - Pointer to new page info structure
+// UINT32 PageSize - Page into size
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _AdvAddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 ii = 0;
+ UINT16 pageNo=0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _AdvAddPageToList()\n");
+
+ for(ii = PARSE_START_INDEX; ii < PageListPtr->PageCount; ii++)
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINT8 *)PageInfoPtr + PageListPtr->PageList[ii]);
+
+ if(pageInfo->PageHandle == (VOID *)(UINTN)0xFFFF)
+ {
+ if(pageInfo->PageFormID == NewPageInfo->PageFormID)
+ {
+ if(pageInfo->PageControls.ControlCount == NewPageInfo->PageControls.ControlCount)
+ {
+ pageNo = NewPageInfo->PageID;
+ pageInfo->PageHandle = NewPageInfo->PageHandle; //EIP-80424
+ // Updated in old page location itself
+ status = _ReplacePageWithNewPage(pageInfo, NewPageInfo, PageSize);
+ }else
+ {
+ status = _InvalidateExistingPage(pageInfo, NewPageInfo);
+ status = EFI_UNSUPPORTED;
+ }
+ break;
+ }
+ }
+ }
+
+ if(pageNo)
+ {
+ // Search in FSetLink for the Page and update PageID and ParentPageID
+ for(ii = 0; ii < FSetLinks->PageCount; ii++)
+ {
+ if(FSetLinks->PageLink[ii].FormID != NewPageInfo->PageFormID)
+ {
+ if(FSetLinks->PageLink[ii].ParentPageID == pageNo)
+ {
+ FSetLinks->PageLink[ii].ParentPageID = NewPageInfo->PageID;
+ }
+
+ if(FSetLinks->PageLink[ii].PageNum > pageNo)
+ {
+ FSetLinks->PageLink[ii].PageNum--;
+ }
+ }
+ else
+ {
+ //FSetLinks->PageLink[ii].ParentPageID = NewPageInfo->PageParentID;
+ FSetLinks->PageLink[ii].PageNum = NewPageInfo->PageID;
+ }
+
+ if(FSetLinks->PageLink[ii].ParentPageID > pageNo)
+ FSetLinks->PageLink[ii].ParentPageID--;
+
+ }
+
+ for(ii = PARSE_START_INDEX; ii < PageListPtr->PageCount; ii++)
+ {
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINT8 *)PageInfoPtr + PageListPtr->PageList[ii]);
+ if(pageInfo->PageHandle == NewPageInfo->PageHandle)
+ {
+ if(pageInfo->PageParentID == pageNo)
+ pageInfo->PageParentID = NewPageInfo->PageID;
+
+ if(pageInfo->PageParentID > pageNo)
+ pageInfo->PageParentID--;
+ }
+ }
+
+ UpdateCtrlDestPageID(NewPageInfo->PageHandle, pageNo);
+ }
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _AdvAddPageToList(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _ReplacePageWithNewPage
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ReplacePageWithNewPage(PAGE_INFO *OldPageInfo, PAGE_INFO *NewPageInfo, UINT32 PageSize)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 page = PARSE_START_INDEX;
+ UINT32 control = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _ReplacePageWithNewPage()\n");
+
+
+ // Go thru NewPageInfo CtrlList and update Control PageId
+ for(;control < NewPageInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *controlInfo = NULL;
+
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + NewPageInfo->PageControls.ControlList[control]);
+
+ // Update the ControlDestPageID if it pointing to the same page.
+ if(controlInfo->ControlDestPageID == controlInfo->ControlPageID)
+ controlInfo->ControlDestPageID = OldPageInfo->PageID;
+
+ controlInfo->ControlPageID = OldPageInfo->PageID;
+ }
+
+ // Go thru all PageList with the same Handle as NewPageInfo and
+ // Go thru their CtrlList and Update any destination PageID that
+ // refers this page
+ for(;page < PageListPtr->PageCount; page++)
+ {
+ PAGE_INFO *pgInfo = (PAGE_INFO *)((UINT8 *)PageInfoPtr + PageListPtr->PageList[page]);
+
+ if(pgInfo->PageHandle == NewPageInfo->PageHandle)
+ {
+ for(control = 0;control < pgInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *controlInfo = NULL;
+
+ controlInfo = (CONTROL_INFO*)((UINT8 *)gControlInfo + pgInfo->PageControls.ControlList[control]);
+ if(_GetPageNumFromFormID(NewPageInfo->PageFormID) == controlInfo->ControlDestPageID)
+ {
+ controlInfo->ControlDestPageID = OldPageInfo->PageID;
+ }
+ }
+
+ if(pgInfo->PageParentID == NewPageInfo->PageID)
+ pgInfo->PageParentID = OldPageInfo->PageID;
+ }
+ }
+
+ // Update NewPageInfo PageId and ParentPageId
+ NewPageInfo->PageID = OldPageInfo->PageID;
+// NewPageInfo->PageParentID = OldPageInfo->PageParentID;
+ // Copy NewPageInfo to pageInfo
+ MemCopy(OldPageInfo, NewPageInfo, PageSize);
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _ReplacePageWithNewPage(), status = 0x%x \n" , status );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _InvalidateExistingPage
+//
+// Description:
+//
+// Parameter:
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _InvalidateExistingPage(PAGE_INFO *OldPageInfo, PAGE_INFO *NewPageInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 page = 0;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Entering _InvalidateExistingPage()\n");
+
+ // Search thru gPages for pages with Controls with destination page
+ // that refer OldPage and change them to point to NewPage
+ for(page = PARSE_START_INDEX; page < PageListPtr->PageCount; page++)
+ {
+ UINT32 control = 0;
+ PAGE_INFO *pgInfo = (PAGE_INFO *)((UINTN)PageInfoPtr + PageListPtr->PageList[page]);
+
+ if(pgInfo->PageHandle == NewPageInfo->PageHandle)
+ {
+ for(control = 0; control < pgInfo->PageControls.ControlCount; control++)
+ {
+ CONTROL_INFO *controlInfo = NULL;
+
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pgInfo->PageControls.ControlList[control]);
+ if(controlInfo->ControlDestPageID == _GetPageNumFromFormID(NewPageInfo->PageFormID))
+ {
+ controlInfo->ControlDestPageID = NewPageInfo->PageID;
+ }
+ }
+ }
+ }
+ //EIP: 108987 May cause circular page reference.
+ //NewPageInfo->PageParentID = OldPageInfo->PageParentID;
+
+ SETUP_DEBUG_UEFI( "\n[TSE] Exiting _InvalidateExistingPage(), status = 0x%x \n" , status ) ;
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: RefreshGroupOnCallBack
+//
+// Description: Callback function which refreshes Controls of a Group which are
+// set with refresh Id
+//
+// Parameter: EFI_EVENT Event, VOID *Context
+//
+// Return value:
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID RefreshGroupOnCallBack(EFI_EVENT Event, VOID *Context)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_INFO *control_Info;
+ UINT16 Key;
+
+ control_Info = (CONTROL_INFO*)Context;
+ Key = UefiGetControlKey (control_Info);
+
+ //refresh the control
+ Status = UefiRefershQuestionValueNvRAM (control_Info);
+
+ if (UefiIsInteractive (control_Info))
+ {
+ UefiPreControlUpdate (control_Info);
+ Status = CallFormCallBack (control_Info, Key, 0, AMI_CALLBACK_CONTROL_UPDATE);//EIP-53480: Updated the action to AMI_CALLBACK_CONTROL_UPDATE
+ }
+
+ //check if the control is in the current page, and redraw only then.
+ if((Status == EFI_SUCCESS) && (control_Info->ControlPageID == gApp->CurrentPage))
+ {
+ gApp->CompleteRedraw = TRUE;
+ }
+}
+//EIP-105468 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: CreateEventforIFR
+//
+// Description: To create Event if any control has RefreshID opcode
+//
+//
+// Parameter: CONTROL_INFO*
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+//#define EFI_REFRESH_ID_GUID { 0x68a6632a, 0x5120, 0x45c3, 0x9b, 0x8e, 0xfc, 0xbf, 0x8c, 0xa0, 0xe7, 0x2e }
+EFI_STATUS CreateEventforIFR (CONTROL_INFO *control_Info )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_INFO *NotifyContext = (CONTROL_INFO*)NULL;
+ EFI_EVENT RefreshIdEvent = (EFI_EVENT)NULL;
+ UINTN i = 0;
+
+ //EFI_GUID RefreshIDGuid = EFI_REFRESH_ID_GUID;
+ //MemCopy( &RefreshEventGroupId, &RefreshIDGuid, sizeof(EFI_GUID) );
+// MemCopy( &RefreshEventGroupId, &(((AMI_EFI_IFR_REFRESH_ID *)control_Info->ControlPtr)->RefreshEventGroupId), sizeof(EFI_GUID) );
+ //Create group event using Refresh Id GUID
+
+ ++gRefreshIdCount; //increament the refresh id control count
+ NotifyContext = EfiLibAllocateZeroPool(sizeof(CONTROL_INFO));
+ if(NotifyContext == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ MemCopy(NotifyContext, control_Info, sizeof(CONTROL_INFO));
+ gBS->CreateEventEx (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)RefreshGroupOnCallBack,
+ (void*)NotifyContext,
+ &RefreshEventGroupId,
+ &RefreshIdEvent
+ );
+ if(RefreshIdEvent == NULL)
+ {
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+
+ //store the Event and Context for this control, to be freed on exiting the application.
+ gRefreshIdInfo = MemReallocateZeroPool(gRefreshIdInfo, sizeof(REFRESH_ID_INFO)*(gRefreshIdCount-1), sizeof(REFRESH_ID_INFO)*gRefreshIdCount);
+ if(gRefreshIdInfo == NULL)
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ gRefreshIdInfo[gRefreshIdCount-1].pEvent = RefreshIdEvent;
+ gRefreshIdInfo[gRefreshIdCount-1].pNotifyContext = (UINT8*)NotifyContext;
+DONE:
+ return Status;
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/uefi2.1/TseUefiHii.h b/EDK/MiniSetup/uefi2.1/TseUefiHii.h
new file mode 100644
index 0000000..6bbc3a8
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/TseUefiHii.h
@@ -0,0 +1,951 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/TseUefiHii.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 39 $
+//
+// $Date: 2/11/14 8:55p $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/TseUefiHii.h $
+//
+// 39 2/11/14 8:55p Arunsb
+// EFI_IFR_EQ_ID_LIST_OP entry added
+//
+// 38 12/04/13 2:57a Premkumara
+// [TAG] EIP139099
+// [Category] New Feature
+// [Description] Supress formset other than
+// EFI_HII_PLATFORM_SETUP_FORMSET_GUID and
+// EFI_HII_DRIVER_HEALTH_FORMSET_GUID through elink based on token
+// [Files] AMITSE.sdl, AMITSE.mak, CommonOem.c, Hii.c, Parse.c,
+// TseUefiHii.h
+//
+// 37 6/10/13 12:23p Arunsb
+// EIP122907 GetDefaultValue function argument added for
+// EFI_IFR_TYPE_OTHER support.
+//
+// 36 5/22/13 11:12a Arunsb
+// Build error rectified
+//
+// 35 4/18/13 9:37a Arunsb
+// Opcodes added to avoid build error in 2.0 build.
+//
+// 34 4/17/13 2:12p Arunsb
+// [TAG] EIP109812, 107774
+// [Category] Improvement
+// [Description] Provide support for EFI_IFR_TYPE_REF and EFI_IFR_REF5
+// [Files] Hii.c, HiiCallback.c, Parse.c and TseUefiHii.h
+//
+// 33 4/16/13 9:49a Arunsb
+// Missed out Hii headers and structures added.
+//
+// 32 3/29/13 12:26p Premkumara
+// [TAG] EIP97611
+// [Category] New Feature
+// [Description] PrintScreen Support in TSE
+// [Files] AMITSE.sdl, CommonHelper.c, HotKeyBin.h, AddBootOption.c,
+// Page.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 31 3/29/13 8:21a Arunsb
+// [TAG] EIP111061
+// [Category] Improvement
+// [Description] Provide support for efivarstore opcode
+// [Files] Parse.c and tseuefihii.h
+//
+// 30 2/25/13 10:57a Blaines
+// [TAG] - EIP 104273
+// [Category] - Action Item
+// [Description] - Provide ability to dump the Hii Pack from the Setup as
+// part TSE debug Infrastructure. It should dump the Pack updates on Hii
+// notification also.
+// So it can be used to debug the issue.
+// [Files] - ForBrowser2.c, Hii.c, HiiNotificationHandler.c,
+// UefiWapper.c, TseUefiHii.h
+//
+// 29 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 10 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 27 2/02/12 3:05a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 26 12/07/11 2:50p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 25 12/01/11 7:27a Arunsb
+// UefiGetValidOptionSize declaration removed. To resolce build error in
+// 2.0
+//
+// 24 11/28/11 5:13a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 23 11/23/11 5:17a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 22 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 21 11/03/11 4:44a Premkumara
+// [TAG] EIP70966
+// [Category] Improvement
+// [Description] Hii orderlist item can't update priority from value in
+// Setup menu for both enable and disable TSE_MULTILINE_CONTROLS token
+// [Files] Ordlistbox.c, ordlistbox.h, TseUefiHii.h, Uefi21Wrapper.c
+//
+// 20 10/20/11 12:25p Blaines
+// Correct the comments.
+//
+// 19 10/20/11 11:48a Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab.
+//
+// [Files Changed]
+// - AMITSE.sdl, CommonHelper.c, special.c, Menu.c, minisetupext.h,
+// TseUefiHii.h, Uefi21Wapper.c
+//
+// 18 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 17 6/20/11 12:20p Rajashakerg
+// [TAG] EIP57402
+// [Category] New Feature
+// [Description] Support for EFI_IFR_DEFAULT_2 opcode.
+// [Files] Hii.c, TseUefiHii.h
+//
+// 16 4/04/11 10:34a Arunsb
+// Added macros compatible UEFI 2.3
+//
+// 15 3/28/11 9:44p Premkumara
+// [TAG] EIP52562
+// [Category] Improvement
+// [Description] Need to have the Fixed Limit in AMITSE module for
+// Controls, Pages and Variable etc.
+//
+// [Files] TSEUefiiHii.h, Parse.c, Hii.c, hii.c
+//
+// 14 3/28/11 5:10p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 13 3/21/11 1:00a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 12 3/18/11 2:52a Rajashakerg
+// [TAG] EIP56124
+// [Category] New Feature
+// [Description] TSE: Support for EFI_IFR_DEFAULT opcode
+// [Files] Parse.c, TseUefiHii.h
+//
+// 11 3/09/11 7:26p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 10 2/01/11 7:38p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 9 12/28/10 12:31p Madhans
+// To update the Tag of EIp 46998. UEFI option ROM menus disappear in
+// Setup when certain options are selected.
+// No file changed but Comment updated right
+//
+// 8 12/02/10 6:09p Madhans
+// [TAG] - EIP49562
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- Need to support UEFI 2.2 requirements related to Calling
+// Formcallback with
+// EFI_BROWSER_ACTION_CHANGING and EFI_BROWSER_ACTION_CHANGED action.
+// [Solution]- Implemented the support.
+// [Files] - submenu.c, numeric.c, popupsel.c, popupString.c,
+// uefi20\hii.h, uefi20\uefi20wrapper.c
+// uefi21\hiicalback.c, uefi21\tseuefihii.h
+//
+// 7 10/27/10 4:25p Madhans
+// [TAG] EIP46998
+// [Category] Defect
+// [Symptom] Some user action on PCIx with UEFI Hii Pages causes Setup
+// screen pages and menu disappers.
+// [RootCause] UEFI 2.1 parsing code is not handling the Removepack and
+// New pack sequance properly. Normally UpdatePack
+// does the removepack and AddPack.
+// [Solution] UEFI 2.1 parsing code fixed to handle above case correctly.
+// [Files] hii.c HiiNotificationHandler.c Parse.c TseUefiHii.h
+// uefi21wapper.c
+//
+// 6 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 6 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 5 6/14/10 7:14p Madhans
+// Dynamic parsing support
+//
+// 4 3/11/10 5:44p Madhans
+// Coding Standards Update
+//
+// 3 2/26/10 7:01p Madhans
+// To build with EDK
+//
+// 1 11/19/09 5:26p Presannar
+//
+// 2 8/11/09 3:00p Presannar
+// Added Fn signature FixSetupData, HandleNewIFRPack, HandleRemoveIFRPack,
+// HandleAddIFRPack, GetFormByFormID, HiiGetForm, GetDefaultValue,
+// IFRChangeHandler, RegisterFormNotification, UnRegisterFormNotification
+// and VarUpdateFormSetVariable
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 2 4/14/09 12:39p Presannar
+// Added Fn prototype FormCallBack, CallFormCallBack and
+// SpecialActionCallBack
+//
+// 1 3/31/09 4:15p Madhans
+//
+// 2 1/29/09 6:09p Presannar
+// Added Function Prototypes for GetControlConditionVariable and
+// HiiRemoveString
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+// 30 9/17/08 7:44p Madhans
+// For Boot only Driver file split changes.
+//
+// 29 3/19/08 5:39p Madhans
+// Get Max line length of multiline string support for Message box
+//
+// 28 10/24/07 11:23a Arunkumars
+// - Moved IDE security code to binary
+// - Fixed build errors under UGA draw support
+// - Added EFI key password support
+// - Added modifier hot key support
+// - Added popup support in From browser protocol
+//
+// 27 7/18/07 8:04a Arunkumars
+// added hook for password encode and colour
+//
+// 26 7/09/07 1:27p Arunkumars
+// - Added elink hooks for Logo, Password management and Control Keys
+// customizations
+//
+// 25 5/22/07 9:21a Arunkumars
+// Added support to dynamically parse forms that have been updated using
+// UpdateForm; under SDL token for Run time Hii support
+//
+// 24 3/12/07 7:25p Arunkumars
+// Added support to store EFI_KEYs for password.
+//
+// 23 8/14/06 12:38p Arunkumars
+// Wide glyph support added
+//
+// 22 7/06/06 6:37p Arunkumars
+// Include tiano.h instead of efi.h
+//
+// 21 6/15/06 9:34a Arunkumars
+// Support to show new pages added at runtime
+//
+// 20 6/06/06 11:19a Madhans
+// HII_VERSION Sdl Added. the token should be
+// 0 - hii version older then aptio 3 version
+// 1 - Aptio 3, 4 and 4.5 and Tiano 8
+// 2 - tiano 8.5 and later
+//
+// 19 5/26/06 12:23p Madhans
+// HiiGetLinkIndex modified to check for Class, subclass and guid though
+// page variable.
+//
+// 18 10/04/05 11:29a Stefanor
+// add string & language
+// started fix for fixup data on mulitple reentry
+// started dynamic IFR support
+//
+// 17 9/02/05 1:24p Jerryp
+// Added skeleton for runtime IFR processing
+//
+// 16 8/10/05 5:10p Franklynd
+// Fixing callback protocol issue.
+//
+// 15 8/10/05 4:01p Franklynd
+// Fixes for ading and getting new strings from HII. using a specific
+// language instead of all available languages.
+//
+// 14 8/05/05 4:47p Jerryp
+// Added form browser callback when exploding a multiple variable
+// Updated to version 1.12.1027
+//
+// 13 7/22/05 11:02a Jerryp
+// Added code to OPTIONALLY use HII->GetDefaultImage instead of BCP
+// compatible defaults
+//
+// 12 7/19/05 3:45p Jerryp
+// Added function to change string for all languages or individual
+// languages
+//
+// 11 5/19/05 10:29a Jerryp
+// Added new HiiChangeString function
+//
+// 10 5/01/05 11:23a Jerryp
+// Modifed HiiGetFormSet to accept a parameter
+//
+// 9 4/29/05 1:11p Franklynd
+// Adding support for formcallback protocol to update nvram setup
+// variables
+//
+// 8 2/07/05 2:32p Jerryp
+// Removed HPK data
+//
+// 7 2/06/05 11:15a Jerryp
+// Full hotkey support
+//
+// 6 2/04/05 10:30a Jerryp
+// Added ability to get strings in ANY language
+//
+// 5 2/02/05 4:20p Jerryp
+// **WORK IN PROGRESS **
+// Latest changes for Label/Index.
+// Not completely tested
+//
+// 4 1/31/05 2:32p Jerryp
+// Added HiiGetStringLength function
+//
+// 3 1/14/05 7:09p Jerryp
+// First integration code with boot to shell.
+// Still a bug in booting to shell from FV
+//
+// 2 1/10/05 5:16p Jerryp
+// Finished sync with HII
+//
+// 1 1/07/05 4:30p Jerryp
+// Initial checkin
+// useful debugging functions and HII header
+//
+//*************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: TseUefiHii.h
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//*************************************************************************
+
+//---------------------------------------------------------------------------
+#ifndef _AMI_UEFI_HII_H_ // DO NOT CHANGE THIS TO _HII_H_ !! That is used by the HII Protocol header
+#define _AMI_UEFI_HII_H_
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#include "Minisetup.h"
+#include "FormBrowser2.h"
+#include EFI_PROTOCOL_DEFINITION(HiiDatabase)
+#include EFI_PROTOCOL_DEFINITION(HiiFont)
+#include EFI_PROTOCOL_DEFINITION(HiiString)
+#include EFI_PROTOCOL_DEFINITION(HiiConfigRouting)
+#include EFI_PROTOCOL_DEFINITION(HiiConfigAccess)
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#if TSE_USE_EDK_LIBRARY
+#include "TianoHii.h"
+#else
+#include "UefiTianoHii.h" // Internal file used then EDKsupport is OFF
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+#define AMI_TIME_HOUR 1
+#define AMI_TIME_MIN 2
+#define AMI_TIME_SEC 3
+#define AMI_DATE_YEAR 4
+#define AMI_DATE_MONTH 5
+#define AMI_DATE_DAY 6
+//---------------------------------------------------------------------------
+#define TSE_REFRESH_GRANURALITY 5
+//---------------------------------------------------------------------------
+// Maximum supported page, variables, controls.
+#define MAX_PAGE 246
+#define MAX_CONTROLS 0xFFFE
+#define MAX_VARIABLE 300
+
+#ifndef _EFI_IFR_TYPE_BUFFER
+#define EFI_IFR_TYPE_BUFFER 0x0B
+#endif
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+extern EFI_HII_DATABASE_PROTOCOL *gHiiDatabase;
+extern EFI_HII_FONT_PROTOCOL *gHiiFont;
+extern EFI_HII_STRING_PROTOCOL *gHiiString;
+extern EFI_HII_CONFIG_ROUTING_PROTOCOL *gHiiConfigRouting;
+
+extern /*EFI_HII_HANDLE*/VOID* gHiiHandle;
+extern UINTN gTitle;
+extern UINTN gHelp;
+extern UINTN gSubTitle;
+extern UINTN gHelpTitle;
+extern UINTN gNavStrings;
+extern BOOLEAN gIFRChangeNotify;
+extern EFI_HII_HANDLE gRemovedHandle;
+//---------------------------------------------------------------------------
+
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_HII_VALUE
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Type UINT8
+// Value EFI_IFR_TYPE_VALUE
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_HII_VALUE
+{
+ UINT8 Type;
+ EFI_IFR_TYPE_VALUE Value;
+}EFI_HII_VALUE;
+
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: SETUP_LINK
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// FormSet UINT8*
+// Handle VOID*
+// ClassID UINT16
+// FormSetLength UINTN
+// Added UINT8
+// SubClassID UINT16
+// ClassGuidCount UINT16
+// ClassGuid EFI_GUID*
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct
+{
+ UINT8* FormSet;
+ VOID* Handle;
+ UINT16 ClassID;
+ UINTN FormSetLength;
+ UINT8 Added; //To know if this page was present in the tool data
+ UINT16 SubClassID;
+ UINT16 ClassGuidCount;
+ EFI_GUID* ClassGuid;
+}SETUP_LINK;
+
+//EIP111061
+typedef struct AMI_EFI_IFR_VARSTORE_EFI {
+ EFI_IFR_OP_HEADER Header;
+ EFI_VARSTORE_ID VarStoreId;
+ EFI_GUID Guid;
+ UINT32 Attributes;
+ UINT16 Size;
+ UINT8 Name[1];
+} AMI_EFI_IFR_VARSTORE_EFI; //as per UEFI spec 2.3.1
+
+//---------------------------------------------------------------------------
+EFI_IFR_FORM_SET *HiiGetFormSetFromHandle( /*EFI_HII_HANDLE*/VOID* handle );
+EFI_IFR_FORM_SET *HiiGetFormSet( UINTN index );
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+extern VOID RTIfrProcessAddVarListAndPageIDListWrapper(VOID);
+extern VOID RTIfrProcessExitWrapper(VOID);
+extern VOID RTIfrProcessRunTimeFormsWrapper(EFI_IFR_REF **ref);
+extern BOOLEAN RTIfrUpdateVariableInfoWrapper(UINT32 ControlVariable, EFI_HANDLE Handle);
+extern BOOLEAN RTIfrProcessFormIfUpdatedWrapper(UINT16 link);
+extern INTN EfiStrnCmp(IN CHAR16 *String, IN CHAR16 *String2, IN UINTN Length);
+extern EFI_STATUS GetHexStringAsBuffer(UINT8 **Buffer, CHAR16 *HexStringBuffer);
+extern EFI_STATUS BufferToHexString(IN OUT CHAR16 *Str, IN UINT8 *Buffer, IN UINTN BufferSize);
+extern EFI_STATUS UnicodeToConfigString(IN OUT CHAR16 *ConfigString, IN OUT UINTN *StrBufferLen, IN CHAR16 *UnicodeString);
+//---------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// Hii.c
+// ----------------------------------------------------------------------------
+EFI_STATUS HiiExit(VOID);
+EFI_STATUS HiiFixupData();
+EFI_STATUS HiiLoadDefaults( VOID **varList, UINT32 Mask );
+EFI_STATUS FixSetupData();
+EFI_STATUS HandleNewIFRPack(EFI_HANDLE Handle, UINT8 *PackData); //EIP 75588
+EFI_STATUS HandleRemoveIFRPack(EFI_HANDLE Handle);
+EFI_STATUS HandleAddIFRPack(EFI_HANDLE Handle, UINT8 *PackData);
+VOID* HiiFindHandle( EFI_GUID *guid, UINT16 *index );
+UINT16 HiiChangeString(VOID* handle, UINT16 token, CHAR16 *string);
+
+VOID *GetFormByFormID(EFI_HII_PACKAGE_HEADER *IFRData, UINT16 FormID, UINTN *Length);
+VOID *HiiGetForm( EFI_HII_HANDLE Handle, UINT16 form, UINTN *Length );
+
+PAGE_ID_INFO *GetPageIdInfoByIndex(PAGE_ID_INFO *PageIdInfo, UINT16 PgIndex);
+//EIP:56413 Function to update the Resetbutton Defaults to the control
+EFI_STATUS UefiupdateResetButtonDefault(CONTROL_INFO ControlData, UINT16 DefaultId);
+ //EIP: 57402 Evaluating the Control Default
+UINT16 EvaluateControlDefault(CONTROL_INFO *CtrlInfo, UINT64 *Defaults);
+
+// ----------------------------------------------------------------------------
+// Uefi21Wrapper.c
+// ----------------------------------------------------------------------------
+EFI_STATUS GetConfigHeader(VARIABLE_INFO *VariableInfo, EFI_STRING *Configuration, UINTN *Length);
+EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control);
+EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *CtrlInfo, VOID **Handle, UINT16 **OptionPtrTokens,
+ UINT64 **ValuePtrTokens, UINT16 *ItemCount,
+ UINT16 *Interactive, UINT16 *CallBackKey);
+VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData);
+EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size);
+EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size);
+
+BOOLEAN IsPasswordEncodeEnabled(VOID *PwDataPtr);
+BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo);
+BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData);
+
+UINT8 UefiGetBaseValue(VOID *IfrPtr);
+UINT8 UefiGetIfrLength(VOID *IfrPtr);
+UINT8 UefiGetMaxEntries(VOID *IfrPtr);
+
+UINT16 UefiGetControlKey(CONTROL_INFO *ControlData);
+UINT16 UefiGetHelpField(VOID *IfrPtr);
+UINT16 UefiGetPromptField(VOID *IfrPtr);
+UINT16 UefiGetQuestionOffset(VOID *IfrPtr);
+UINT16 UefiGetTextField(VOID *IfrPtr);
+UINT16 UefiGetTextTwoField(VOID *IfrPtr);
+UINT16 UefiGetTitleField(VOID *IfrPtr);
+UINT16 UefiGetWidth(VOID *IfrPtr);
+UINT8 UefiGetFlagsField(VOID *IfrPtr);
+
+UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr,VOID * CtrlPtr);
+UINT16 UefiTseLiteGetBootOverRideIndex(VOID *IfrPtr);
+
+UINTN HiiGetDefaultMask(VOID);
+UINTN HiiGetManufactuingMask(VOID);
+UINTN HiiMyGetMultiLineStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token );
+UINTN HiiMyGetStringLength( /*EFI_HII_HANDLE*/VOID* handle, UINT16 token );
+
+UINT64 UefiGetMaxValue(VOID *IfrPtr);
+UINT64 UefiGetMinValue(VOID *IfrPtr);
+UINT64 UefiGetStepValue(VOID *IfrPtr);
+
+VOID EfiLibSafeFreePool(IN VOID *Buffer);
+VOID HiiRemoveString(EFI_HII_HANDLE Handle, UINT16 Token);
+VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max);
+VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token);
+VOID UefiSetHelpField(VOID *IfrPtr,UINT16 Token);
+VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token);
+
+VOID *UefiCreateSubTitleTemplate(UINT16 Token);
+VOID *UefiCreateStringTemplate(UINT16 Token);
+EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData);
+UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr);//EIP:56413 Function decleration to get the Default ID
+BOOLEAN CheckTimeFlags(UINT8 Flags);
+BOOLEAN CheckDateFlags(UINT8 Flags);
+
+// ----------------------------------------------------------------------------
+// TSE Advanced
+// ----------------------------------------------------------------------------
+VOID UefiAddEndOp(VOID *IfrPtr);
+VOID BBSUpdateControlOffset(CONTROL_INFO *control);
+VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value);
+VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value);
+VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value);
+VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option);
+VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width);
+VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID);
+VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value);
+
+VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo);
+VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 * Variable, GUID_INFO **GuidInfo);
+
+BOOLEAN UefiIsOneOfControl(VOID *IfrPtr);
+
+UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr);
+UINT16 UefiGetQuestionID(CONTROL_INFO *Control);
+UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo);
+
+UINT32 GetControlConditionVarId(CONTROL_INFO *controlInfo);
+UINTN GetControlDataLength(CONTROL_INFO *controlInfo);
+
+// ----------------------------------------------------------------------------
+// Expression.c
+// ----------------------------------------------------------------------------
+EFI_STATUS EvaluateExpression(IN CONTROL_INFO *ControlInfo,
+ IN OUT EFI_HII_VALUE *ExpressionResult,
+ OUT UINTN *Offset);
+VOID ResetScopeStack(VOID);
+EFI_STATUS PushScope(IN UINT8 Operand);
+EFI_STATUS PopScope(OUT UINT8 *Operand);
+BOOLEAN IsScopeStackEmpty();
+UINTN _SkipExpression(UINT8 *ControlCondPtr);
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// Parse.c
+// ----------------------------------------------------------------------------
+EFI_STATUS AddPageIdToList(PAGE_ID_INFO *NewPageIdInfo);
+EFI_STATUS AddPageToList(PAGE_INFO *NewPageInfo, UINT32 PageSize);
+EFI_STATUS AddVariableToList(VARIABLE_INFO *NewVariableInfo);
+EFI_STATUS CreatePage(PAGE_INFO **PageInfo, UINT32 *AllocatedSize, UINT32 *Offset, VOID *Buff, UINT32 BuffSize);
+EFI_STATUS ParseForm(SETUP_LINK *Setup_Link);
+UINT32 AddControlToList(CONTROL_INFO *ControlInfo, UINT32 ControlSize);
+VOID GetDefaultValue(UINT8 Type, EFI_IFR_TYPE_VALUE *Value, UINT16 *Size, VOID *DefValue, UINT8 *TempData);
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// HiiCallBack.c
+// ----------------------------------------------------------------------------
+#if TSE_DEBUG_MESSAGES
+#define SETUPDATAFILENAME L"SETUPDATA_0x%x_%03d.hpk"
+EFI_STATUS WritePackToFile(CHAR16 *filenameFormat, EFI_HANDLE Handle, UINT8 *PackData, UINTN length);
+EFI_STATUS WriteDataToFile(CHAR16 *filename, VOID *Data, UINTN length, UINT32 index);
+VOID *HiiGetPackList( EFI_HII_HANDLE Handle, UINT16 form, UINTN *Length );
+VOID ProcessPackToFile(EFI_HII_DATABASE_NOTIFY_TYPE NotifyType, EFI_HANDLE Handle);
+VOID DebugShowBufferContent(UINTN bufSize, VOID *buffer) ;
+#endif //End of TSE_DEBUG_MESSAGES
+EFI_STATUS FormCallBack(EFI_HII_HANDLE Handle, EFI_QUESTION_ID QuestionID, UINT8 Type, EFI_IFR_TYPE_VALUE *Value,EFI_BROWSER_ACTION action);
+EFI_STATUS CallFormCallBack(CONTROL_INFO * ControlData, UINT16 Key ,UINT8 Flags,UINTN Action);//EIP-53480: Implementation of FormBrowser with actions support
+EFI_STATUS SpecialActionCallBack(CONTROL_INFO * ControlData, UINT16 Key);
+EFI_STATUS CallTextCallBack(TEXT_DATA *text, ACTION_DATA *Data);
+VOID UefiPreControlUpdate(CONTROL_INFO *ControlData);
+EFI_STATUS UefiIsProceedWithPageChange(EFI_STATUS Status);
+VOID UEFICallSetupFormCallBack(UINTN Action );//EIP-53480: Decleration of the Wrapper function which calls the CallFormCallBack()
+EFI_BROWSER_ACTION UefiGetActionWapper(UINTN Action);//EIP-53480 The Wrapper function to get the actual action for the driver
+// ----------------------------------------------------------------------------
+
+//HiiNotificationHandler.c
+// ----------------------------------------------------------------------------
+EFI_STATUS
+IFRChangeNotifyFn (IN UINT8 PackageType, IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_PACKAGE_HEADER *Package, IN EFI_HII_HANDLE Handle,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType);
+EFI_STATUS RegisterFormNotification(EFI_HII_DATABASE_NOTIFY PackageNotifyFn,
+ EFI_HII_DATABASE_NOTIFY_TYPE NotifyType,
+ EFI_HANDLE *NotifyHandle);
+EFI_STATUS UnRegisterFormNotification(EFI_HANDLE NotifyHandle);
+VOID VarUpdateFormSetVariable();
+EFI_STATUS _DisplayErrorMessage(); // EIP : 52562 To display Error message when TSE limits exceeds
+// ----------------------------------------------------------------------------
+
+#define AMI_FLAG_MANUFACTURING EFI_IFR_OPTION_DEFAULT_MFG
+#define AMI_FLAG_DEFAULT EFI_IFR_OPTION_DEFAULT
+EFI_STATUS GetBlockName(EFI_STRING *Configuration, UINTN *Length, UINTN Offset, UINTN Size);
+
+// ----------------------------------------------------------------------------
+// To Be removed
+#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length))
+#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0)
+
+//EIP:56124 Defining the Default value linked list
+typedef struct _DEFAULT_VALUE
+{
+ UINT16 DefaultId;
+ UINT64 Value;
+ struct _DEFAULT_VALUE *Next;
+}DEFAULT_VALUE;
+//EIP:56124 END
+
+//Added for UEFI spec. 2.3 compatibility- Start
+#ifndef EFI_BROWSER_ACTION_RETRIEVE
+#define EFI_BROWSER_ACTION_RETRIEVE 2
+#endif
+#ifndef EFI_BROWSER_ACTION_FORM_OPEN
+#define EFI_BROWSER_ACTION_FORM_OPEN 3
+#endif
+#ifndef EFI_BROWSER_ACTION_FORM_CLOSE
+#define EFI_BROWSER_ACTION_FORM_CLOSE 4
+#endif
+
+#pragma pack (1)
+typedef struct _AMI_EFI_IFR_REFRESH_ID {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID RefreshEventGroupId;
+} AMI_EFI_IFR_REFRESH_ID;
+
+#ifndef EFI_IFR_EQ_ID_LIST_OP
+#define EFI_IFR_EQ_ID_LIST_OP 0x14
+#endif
+
+#ifndef EFI_IFR_ANIMATION_OP
+#define EFI_IFR_ANIMATION_OP 0x1F
+#endif
+
+#ifndef EFI_IFR_MAP_OP
+#define EFI_IFR_MAP_OP 0x22
+#endif
+
+#ifndef EFI_IFR_GET_OP
+#define EFI_IFR_GET_OP 0x2B
+#endif
+
+#ifndef EFI_IFR_SET_OP
+#define EFI_IFR_SET_OP 0x2C
+#endif
+
+#ifndef EFI_IFR_READ_OP
+#define EFI_IFR_READ_OP 0x2D
+#endif
+
+#ifndef EFI_IFR_WRITE_OP
+#define EFI_IFR_WRITE_OP 0x2E
+#endif
+
+#ifndef EFI_IFR_FORM_MAP_OP
+#define EFI_IFR_FORM_MAP_OP 0x5D
+#endif
+
+#ifndef EFI_IFR_MODAL_TAG_OP
+#define EFI_IFR_MODAL_TAG_OP 0x61
+#endif
+
+#ifndef EFI_IFR_REFRESH_ID_OP
+#define EFI_IFR_REFRESH_ID_OP 0x62
+#endif
+
+#ifndef EFI_IFR_TYPE_UNDEFINED
+#define EFI_IFR_TYPE_UNDEFINED 0x09
+#endif
+
+#ifndef EFI_IFR_TYPE_ACTION
+#define EFI_IFR_TYPE_ACTION 0x0A
+#endif
+
+#ifndef EFI_IFR_TYPE_REF
+#define EFI_IFR_TYPE_REF 0x0C
+#endif
+
+typedef struct _AMI_EFI_IFR_FORM_MAP_METHOD {
+ ///
+ /// The string identifier which provides the human-readable name of
+ /// the configuration method for this standards map form.
+ ///
+ EFI_STRING_ID MethodTitle;
+ ///
+ /// Identifier which uniquely specifies the configuration methods
+ /// associated with this standards map form.
+ ///
+ EFI_GUID MethodIdentifier;
+} AMI_EFI_IFR_FORM_MAP_METHOD;
+
+typedef struct _AMI_EFI_IFR_FORM_MAP {
+ ///
+ /// The sequence that defines the type of opcode as well as the length
+ /// of the opcode being defined. Header.OpCode = EFI_IFR_FORM_MAP_OP.
+ ///
+ EFI_IFR_OP_HEADER Header;
+ ///
+ /// The unique identifier for this particular form.
+ ///
+ EFI_FORM_ID FormId;
+ ///
+ /// One or more configuration method's name and unique identifier.
+ ///
+ // EFI_IFR_FORM_MAP_METHOD Methods[];
+} AMI_EFI_IFR_FORM_MAP;
+
+typedef struct _AMI_EFI_IFR_SET {
+ ///
+ /// The sequence that defines the type of opcode as well as the length
+ /// of the opcode being defined. Header.OpCode = EFI_IFR_SET_OP.
+ ///
+ EFI_IFR_OP_HEADER Header;
+ ///
+ /// Specifies the identifier of a previously declared variable store to
+ /// use when storing the question's value.
+ ///
+ EFI_VARSTORE_ID VarStoreId;
+ union {
+ ///
+ /// A 16-bit Buffer Storage offset.
+ ///
+ EFI_STRING_ID VarName;
+ ///
+ /// A Name Value or EFI Variable name (VarName).
+ ///
+ UINT16 VarOffset;
+ } VarStoreInfo;
+ ///
+ /// Specifies the type used for storage.
+ ///
+ UINT8 VarStoreType;
+} AMI_EFI_IFR_SET;
+
+typedef struct _AMI_EFI_IFR_GET {
+ ///
+ /// The sequence that defines the type of opcode as well as the length
+ /// of the opcode being defined. Header.OpCode = EFI_IFR_GET_OP.
+ ///
+ EFI_IFR_OP_HEADER Header;
+ ///
+ /// Specifies the identifier of a previously declared variable store to
+ /// use when retrieving the value.
+ ///
+ EFI_VARSTORE_ID VarStoreId;
+ union {
+ ///
+ /// A 16-bit Buffer Storage offset.
+ ///
+ EFI_STRING_ID VarName;
+ ///
+ /// A Name Value or EFI Variable name (VarName).
+ ///
+ UINT16 VarOffset;
+ } VarStoreInfo;
+ ///
+ /// Specifies the type used for storage.
+ ///
+ UINT8 VarStoreType;
+} AMI_EFI_IFR_GET;
+
+//EIP109812, 107774
+typedef struct _AMI_EFI_HII_REF {
+ EFI_QUESTION_ID QuestionId;
+ EFI_FORM_ID FormId;
+ EFI_GUID FormSetGuid;
+ EFI_STRING_ID DevicePath;
+} AMI_EFI_HII_REF;
+
+typedef struct _AMI_EFI_IFR_REF5 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+} AMI_EFI_IFR_REF5;
+
+/////////////////////////////////////////////////////////////////////////////////
+//
+//Declaring the struct which are not present in core (UefiHii.h)
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#ifndef _TSE_EFI_IFR_FORM_SET
+#define _TSE_EFI_IFR_FORM_SET
+typedef struct _TSE_EFI_IFR_FORM_SET {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ EFI_STRING_ID FormSetTitle;
+ EFI_STRING_ID Help;
+ UINT8 Flags;
+ EFI_GUID ClassGuid[1];
+} TSE_EFI_IFR_FORM_SET;
+#endif
+#pragma pack ()
+
+//End for UEFI spec. 2.3 compatibility
+#endif /* _AMI_UEFI_HII_H_ */
+// ----------------------------------------------------------------------------
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/EDK/MiniSetup/uefi2.1/Uefi21.cif b/EDK/MiniSetup/uefi2.1/Uefi21.cif
new file mode 100644
index 0000000..e026775
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Uefi21.cif
@@ -0,0 +1,21 @@
+<component>
+ name = "TSE Sources - UEFI2.1"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\uefi2.1"
+ RefName = "Uefi21"
+[files]
+"Uefi21.sdl"
+"Uefi21.mak"
+"CtrlCond.c"
+"CtrlCond.h"
+"FormBrowser2.c"
+"FormBrowser2.h"
+"Expression.c"
+"Hii.c"
+"HiiCallback.c"
+"HiiNotificationHandler.c"
+"Parse.c"
+"TseUefiHii.h"
+"Uefi21Wapper.c"
+"UefiTianoHii.h"
+<endComponent>
diff --git a/EDK/MiniSetup/uefi2.1/Uefi21.mak b/EDK/MiniSetup/uefi2.1/Uefi21.mak
new file mode 100644
index 0000000..d038c9d
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Uefi21.mak
@@ -0,0 +1,134 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Uefi21.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 8 $
+##
+## $Date: 10/18/12 6:04a $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Uefi21.mak $
+#
+# 8 10/18/12 6:04a Arunsb
+# Updated for 2.16.1235 QA submission
+##
+## 6 10/10/12 12:41p Arunsb
+## Synched the source for v2.16.1232, backup with Aptio
+#
+# 7 3/29/11 1:26p Madhans
+# To remove /Od Option. It is not needed.
+#
+# 6 10/14/10 5:07p Madhans
+#
+# 5 4/23/10 6:12p Madhans
+#
+# 4 4/16/10 5:13p Madhans
+# Changes for Tse 2.02. Please see Changelog.log for more details.
+#
+# 3 2/19/10 8:50p Madhans
+##
+## 2 11/19/09 5:39p Presannar
+## Include Path to CORE to be compatible with existing Implementation. To
+## be removed in the Next release label
+##
+## 1 7/24/09 6:54p Presannar
+##
+## 3 4/24/09 7:54p Presannar
+## TSE 2.0 UEFI 2.1 Code Complete
+##
+## 2 3/31/09 4:15p Madhans
+## UEFI Wrapper improvments.
+##
+## 1 1/09/09 2:38p Presannar
+## UEFI 2.1 Hii Related Code - Initial Drop
+##
+##
+##*****************************************************************##
+##*************************************************************************
+##<AMI_FHDR_START>
+##
+## Name: Uefi21.mak
+##
+## Description:
+##
+##<AMI_FHDR_END>
+##*************************************************************************
+
+# MAK file for the eModule:UEFI2.1
+
+Uefi21_INCLUDES = \
+ -I $(TSESRC_DIR) \
+ -I $(TSE_STYLE_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSELITESRC_DIR) \
+ -I $(UEFISRC_DIR) \
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+ -I $(EDK_SOURCE)\Foundation\Library\Dxe\UefiEfiIfrSupportLib \
+!endif
+!if "$(TSE_USE_EDK_LIBRARY)" != "1"
+ -I $(PROJECT_DIR)\Core \
+!endif
+
+!if "$(TSE_USE_EDK_LIBRARY)" == "1"
+TSE_DEFAULTS = $(EDK_DEFAULTS)
+!else
+TSE_DEFAULTS = $(BUILD_DEFAULTS)
+!endif
+
+$(BUILD_DIR)\Uefi21Local.lib : Uefi21Lib
+
+Uefi21Lib : $(BUILD_DIR)\Uefi21.mak Uefi21LibBin
+
+$(BUILD_DIR)\Uefi21.mak : $(UEFISRC_DIR)\$(@B).cif $(UEFISRC_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(UEFISRC_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+Uefi21LibBin :
+ $(MAKE) /$(MAKEFLAGS) $(TSE_DEFAULTS)\
+ /f $(BUILD_DIR)\Uefi21.mak all\
+ "MY_INCLUDES=$(Uefi21_INCLUDES)"\
+ "UNI_INCLUDE_PATH=$(TSEBIN_DIR)"\
+ TYPE=LIBRARY \
+ "EXT_HEADERS=$(BUILD_DIR)\token.h"\
+ LIBRARY_NAME=$(BUILD_DIR)\Uefi21Local.lib\
+ "CFLAGS=$(CFLAGS) /DTSE_FOR_APTIO_4_50"
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** C)Copyright 1985-2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 6145-F Northbelt Pkwy, Norcross, GA 30071 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/uefi2.1/Uefi21.sdl b/EDK/MiniSetup/uefi2.1/Uefi21.sdl
new file mode 100644
index 0000000..be933fb
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Uefi21.sdl
@@ -0,0 +1,71 @@
+TOKEN
+ Name = "UEFI_HII_2_1_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable UEFI 2.1 sources support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+ Master = Yes
+ Token = "EFI_SPECIFICATION_VERSION" ">" "0x20000"
+End
+
+TOKEN
+ Name = "UEFI_SOURCES_SUPPORT"
+ Value = "1"
+ Help = "Don't Edit."
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "UEFI_2_1_SUPPORT"
+ Value = "1"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TSE_SUPPORT_VFRCOMPILE_1_88"
+ Value = "0"
+ Help = "Turn on to support vfrcompiler version 1.88 and later"
+ TokenType = Boolean
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "TianoHII_SUPPORT"
+ Value = "1"
+ Help = "Switch to enable Tiano defined HII support in Project. Turn on for form support with class,subclass. If Core changes to use just Form Guid This can be turned off"
+ TokenType = Boolean
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+TOKEN
+ Name = "SETUP_FORM_BROWSER_SUPPORT"
+ Value = "1"
+ Help = "1 => Installs form browser protocol should turn on SETUP_RUNTIME_IFR_PROCESSING. 0 => Does not install form browser protocol."
+ TokenType = Boolean
+ TargetH = Yes
+ Token = "SETUP_RUNTIME_IFR_PROCESSING" "=" "1"
+End
+
+PATH
+ Name = "UEFISRC_DIR"
+End
+
+MODULE
+ Help = "Includes Uefi21.mak to Project"
+ File = "Uefi21.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\Uefi21Local.lib"
+ Parent = "$(UEFISRC_DIR)\Uefi21Local$(ARCH).lib"
+ InvokeOrder = ReplaceParent
+End
+
diff --git a/EDK/MiniSetup/uefi2.1/Uefi21Wapper.c b/EDK/MiniSetup/uefi2.1/Uefi21Wapper.c
new file mode 100644
index 0000000..eab9ad5
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/Uefi21Wapper.c
@@ -0,0 +1,8266 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2013, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Uefi21Wapper.c $
+//
+// $Author: Premkumara $
+//
+// $Revision: 85 $
+//
+// $Date: 8/28/14 11:54a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/Uefi21Wapper.c $
+//
+// 85 8/28/14 11:54a Premkumara
+// [TAG] EIP174031
+// [Category] Improvement
+// [Description] Removed TODO comments and added proper comments in those
+// places
+// [Files] commonoem.c, commonhelper.c, special.c, submenu.c,
+// minisetupext.c, uefi21wapper.c and legacy.c
+//
+// 84 8/28/14 9:56a Premkumara
+// [TAG] EIP173038
+// [Category] Bug Fix
+// [Symptom:] System hangs on using UefiVarsetnvramforCurrentform
+// [Root Cause] UINT32 gProcessedForms[MAX_FORMS_TO_PROCESS];
+// Entries overbound the arrary MAX_FORMS_TO_PROCESS
+// [Solution] gProcessedForms formed dynamically
+// [Files] Uefi21wapper.c
+//
+// 83 7/12/14 12:25p Arunsb
+// [TAG] EIP174938
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Arrow mark shown when driver health page published
+// [Root Cause] Driver health formset considered as dynamic page so arrow
+// shown
+// [Solution] For driverhealth formset DynamicPageCount variable not
+// incremented. Returned EFI_ABORTED in parseform for driverhealth formset
+// so DynamicPageCount not incremented so arrow will not be shown.
+// [Files] Parse.c and uefi21wapper.c
+//
+// 82 5/21/14 6:33p Arunsb
+// [TAG] EIPEIP169096,168632
+// [Description] Changed global variable guid usage for tse debug
+// messages. Removed unwanted RT flag in TSE.
+// [Files] commonoem.c, setupdbg.h, print.c and uefi21wapper.c
+//
+// 81 5/02/14 5:02a Arunsb
+// [TAG] EIP156958
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] UefiVarsetnvramforCurrentform function not saving the values
+// properly for passed page ID
+// [Root Cause] This function calling VarSetNvram to update the NVRAM,
+// this function updates the offset value to NVRAM and then got the whole
+// buffer from NVRAM again and updates the cache so second controls and
+// further modified controls cache values are overwritten by NVRAM value.
+// [Solution] Instead of calling VarSetNvram set the values in
+// UefiVarsetnvramforCurrentform fnc itself.
+// [Files] uefi21wapper.c
+//
+// 80 2/11/14 8:57p Arunsb
+// [TAG] EIP133728
+// [Category] New Feature
+// [Description] Provide special control support in ESA for driver health
+// [Files] uefi21wapper.c
+//
+// 79 10/18/13 4:20p Arunsb
+// [TAG] EIP140268
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] Clicking driver health control crashes
+// [Root Cause] Incremented pointer freed instead of allocated pointer
+// [Solution] Pointer freed properly
+// [Files] uefi21wapper.c
+//
+// 78 8/26/13 3:10p Blaines
+// [TAG] - EIP 134138
+// [Category] - Defect
+// [Symptom] - Incorrect Driver Health name shown in BIOS (UEFI Mode)
+// Setup for SAS Card.
+//
+// [Root cause]
+// In the function FindDriverHealthDriverName,when querying the
+// GetDriverName() routine of Component Name Protocol, the function is
+// passing more than one language.
+//
+// [Solution]-
+// In the function FindDriverHealthDriverName,when querying the
+// GetDriverName() routine of Component Name Protocol, pass only one
+// language to the routine.
+//
+// [Files]
+// Uefi21Wapper.c
+//
+// 77 7/01/13 10:47a Premkumara
+// [TAG] EIP126997
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] Selecting Save current form Now or Discard Current form and
+// Exit now controls causing setup crash
+// [RootCause] NULL is not handled properly for controls->controlPtr
+// [Solution] Handled NULL check properly in necessary places
+// [Files] Uefi21Wapper.c
+//
+// 76 5/22/13 11:18a Arunsb
+// Name value string not saving properly. Fixed it.
+//
+// 75 4/18/13 9:39a Arunsb
+// Functions moved to avoid build error in 2.0 build
+//
+// 74 4/16/13 9:20a Arunsb
+// Build error corrected
+//
+// 73 4/16/13 8:01a Arunsb
+// [TAG] EIP106950
+// [Category] New Feature
+// [Description] PasswordEncode hook function
+//
+// 72 3/29/13 12:30p Premkumara
+// [TAG] EIP97611
+// [Category] New Feature
+// [Description] PrintScreen Support in TSE
+// [Files] AMITSE.sdl, CommonHelper.c, HotKeyBin.h, AddBootOption.c,
+// Page.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 71 3/25/13 8:31a Premkumara
+// [TAG] EIP116315
+// [Category] Improvement
+// [Description] Display control prompt string for password control.
+// (for String on CHAP secret popup)
+// [Files] - AMITSE.sdl
+// - CommonHelper.c
+// - FakeToken.c
+// - AmiTSEStr.uni
+// - TseLite\PopupPassword.c
+// - uefi2.1\UefiWapper21.c
+// - uefi2.0\HiiCallback.c
+// - uefi2.0\hii.h
+// - uefi2.0\hii.c
+//
+// 70 2/25/13 10:57a Blaines
+// [TAG] - EIP 104273
+// [Category] - Action Item
+// [Description] - Provide ability to dump the Hii Pack from the Setup as
+// part TSE debug Infrastructure. It should dump the Pack updates on Hii
+// notification also.
+// So it can be used to debug the issue.
+// [Files] - ForBrowser2.c, Hii.c, HiiNotificationHandler.c,
+// UefiWapper.c, TseUefiHii.h
+//
+// 69 12/05/12 4:51a Premkumara
+// [TAG] EIP105552
+// [Category] Improvement
+// [Description] Adding RefreshID support for OrderList, Password
+// controls
+// [Files] Uefi21Wapper.c
+//
+// 68 10/18/12 8:56a Rajashakerg
+// [TAG] EIP103568
+// [Category] Improvement
+// [Description] Help string support for ordered list
+// [Files] Uefi21Wapper.c, ordlistbox.c
+//
+// 67 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 24 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 65 9/18/12 2:15a Rajashakerg
+// [TAG] EIP88658
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Minisetup crashes after controller reconnection during Hii
+// callback
+// [RootCause] Minisetup crashes after controller reconnection during
+// callback. since we have new packs and new handles.
+// [Solution] Additional checks for invalid ptrs were added
+// [Files] Hii.c, Parse.c, Uefi21Wapper.c
+//
+// 64 9/17/12 6:22a Rajashakerg
+// Updated EIP changes for 2.16 release.
+//
+// 62 9/10/12 11:46a Arunsb
+// [TAG] EIP90372
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Setup browser handling of
+// EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
+// [RootCause] For discard action current value is saved
+// [Solution] Introduced a global variable which will set for discard
+// action for that current value will not be saved
+// [Files] HiiCallback.c and Uefi21Wapper.c
+//
+// 61 5/29/12 4:46a Arunsb
+// [TAG] EIP91109
+// [Category] Improvement
+// [Description] Sync the Aptio IV source for AptioV
+//
+// 60 5/28/12 12:38p Arunsb
+// [TAG] EIP86885
+// [Category] Improvement
+// [Description] Support added for following callback action requests
+// EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT
+// EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT
+// EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
+// EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD
+// [Files] Uefi21Wapper.c
+//
+// 59 4/27/12 1:39a Rajashakerg
+// [TAG] EIP74964
+// [Category] Improvement
+// [Description] UefiGetDateTimeDetails does not initialize the min and
+// max values
+// [Files] Uefi21Wapper.c
+//
+// 58 4/05/12 12:49p Arunsb
+// [TAG] EIP83252
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] System hangs with onboard SAS Option ROM
+// [RootCause] ProcessPackNotification not invoked properly
+// [Solution] gEnableDrvNotification flag handled properly to invoke
+// ProcessPackNotification
+// [Files] uefi2.1\hiicallback.c and uefi2.1\uefi21wapper.c
+//
+// 57 2/02/12 5:41p Arunsb
+// [TAG] EIP81814
+// [Category] Improvement
+// [Description] Merging common utility function for page, control and
+// variable data.
+// [Files] Uefi21Wapper.c
+//
+// 56 2/02/12 1:19p Premkumara
+// [TAG] EIP75351,75352,75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] String.c, boot.c, TseAdvanced.c,Time.c, PopupEdit.c,
+// MessageBox.c, Label.c, Edit.c, Date.c
+//
+// 55 2/02/12 3:06a Premkumara
+// [TAG] EIP75066
+// [Category] Improvement
+// [Description] Support loading defaults for Ordelist controls
+// [Files] Ordlistbox.c, Uefi21Wapper.c, CtrlCond.c, HiiCallback.c,
+// Parse.c, Uefi20Wapper.c, TseUefihiil.h
+//
+// 54 1/20/12 5:10a Rajashakerg
+// [TAG] EIP77875
+// [Category] Improvement
+// [Description] Minisetup: Memory leaks in text browser
+// [Files] Uefi21Wapper.c, hiistring21.c, variable.c
+//
+// 53 1/20/12 12:31a Rajashakerg
+// [TAG] EIP80426
+// [Category] Improvement
+// [Description] When restoring settings, avoid accessing the varstore
+// for text controls
+// [Files] uefi21wapper.c, Setupdata.h.
+//
+// 52 1/13/12 1:41a Arunsb
+// [TAG] EIP80360
+// [Category] Bug Fix
+// [Severity] Important
+// [Symptom] HDDSecurity module - Issue in login with TSE, Master
+// password disabled
+// [RootCause] Cache not updated
+// [Solution] Cache updated properly
+// [Files] Tseadvanced.c, special.c and uefi21wapper.c
+//
+// 51 1/09/12 1:59a Arunsb
+// [TAG] EIP79952
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Add driver option displays select boot option as title
+// [RootCause] Title problem
+// [Solution] Title changed
+// [Files] Faketokens.c, amitsestr.uni, addbootoption.c,
+// uefi2.0\hiicallback.c and uefi21wapper.c
+//
+// 50 12/08/11 5:21p Arunsb
+// progress freeing removed
+//
+// 49 12/08/11 1:09p Rajashakerg
+// [TAG] EIP75379
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] Postmgmtext.c, Uefi21Wapper.c
+//
+// 48 12/08/11 12:18p Rajashakerg
+// [TAG] EIP75558
+// [Category] Improvement
+// [Description] Incorrect static strings retrieved in Text Broswer
+// [Files] Uefi21Wapper.c
+//
+// 47 12/07/11 2:48p Arunsb
+// [TAG] EIP75588
+// [Category] New Feature
+// [Description] Support for queuing UpdatePack notifications
+// [Files] frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
+// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
+//
+// 46 12/07/11 2:08p Arunsb
+// [TAG] EIP77475
+// [Category] New Feature
+// [Description] Changed varsetvalue to _vargetsetvalue in
+// UefiRefershQuestionValueNvRAM fnc since _vargetsetvalue wont calls the
+// SetupConfigModifiedHook
+// [Files] uefi21wapper.c
+//
+// 45 12/07/11 8:56a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Updated the check for date and time flags for NON RTC.
+// [Files] Uefi21Wapper.c
+//
+// 44 12/07/11 8:16a Rajashakerg
+// [TAG] EIP75118
+// [Category] Improvement
+// [Description] xtractConfig() fail since BrowserCallback() cannot find
+// the variable to process
+// [Files] FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
+// Uefi21Wapper.c, PopupSel.c
+//
+// 43 12/07/11 7:18a Rajashakerg
+// [TAG] EIP75558
+// [Category] Improvement
+// [Description] Incorrect static strings retrieved in Text Broswer
+// [Files] Uefi20Wapper.c
+//
+// 42 12/01/11 7:46a Rajashakerg
+// [TAG] EIP75464
+// [Category] Improvement
+// [Description] Improper handling of action controls
+// [Files] SubMenu.c, UefiAction.c, HiiCallback.c, Uefi21Wapper.c
+//
+// 41 11/28/11 5:16a Rajashakerg
+// [TAG] EIP73231
+// [Category] Improvement
+// [Description] Callback handling :For interactive controls updating
+// the currnet vaule in cache even when hii callback returns error status.
+// [Files] Date.c, SubMenu.c, ordlistbox.c, time.c, UefiAction.c,
+// hii.h, uefi20Wapper.c, HiiCallback.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 40 11/28/11 2:15a Premkumara
+// [TAG] EIP75384
+// [Category] Improvement
+// [Description] Suppress the warnings from static code analyzer
+// [Files] UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
+// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
+// EzportPlus\StyleCommon.c,
+//
+// 39 11/23/11 5:20a Rajashakerg
+// [TAG] EIP75473
+// [Category] Improvement
+// [Description] System Time is not updated every second
+// [Files] variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
+// Uefi21Wapper.c, hii.h, uefi20Wapper.c
+//
+// 38 11/20/11 7:39a Premkumara
+// [TAG] EIP73226
+// [Category] New Feature
+// [Description] Extended support for password prompt
+// [Files] FakeToken.c, Uefi21Wapper.c, AmiTSEStr.uni, PopupPassword.c,
+//
+// 37 11/14/11 2:43p Blaines
+// [TAG] - EIP 75481
+// [Category]- Function Request
+// [Synopsis]- TSE debug print infrastructure.
+// [Description]- Add TSE debug print info for basic functions such as
+// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
+// data.
+// [Files]
+// AMITSE.sdl, AmiTSEStr.uni, CommonHelper.c, commonoem.c, FakeTokens.c
+// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
+// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
+// Uefi21Wrapper.c, setupdbg.h
+//
+// 36 11/14/11 12:07a Arunsb
+// While checking in EIP70421 & 70422 Support for driver order,
+// UefiRefershQuestionValueNvRAM
+// function had a wrong fix. So reverting.
+//
+// 35 11/13/11 1:13p Arunsb
+// [TAG] EIP70421
+// [Category] New Feature
+// [Description] Support for driver order in TSE
+// [Files] AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
+// boot.c,
+// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
+// addbootoption.c,
+// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
+// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
+// TseElink.h, variable.h,
+// setup.h, Boot.vfr and Setup.uni
+//
+// 34 11/03/11 4:43a Premkumara
+// [TAG] EIP70966
+// [Category] Improvement
+// [Description] Hii orderlist item can't update priority from value in
+// Setup menu for both enable and disable TSE_MULTILINE_CONTROLS token
+// [Files] Ordlistbox.c, ordlistbox.h, TseUefiHii.h, Uefi21Wrapper.c
+//
+// 33 10/20/11 12:25p Blaines
+// Correct the comments.
+//
+// 32 10/20/11 11:48a Blaines
+// [TAG] EIP 72333
+// [Category] Sighting
+// [Symptom] Some SAS controller card HII Screen Titles are displaying
+// the wrong information
+// [RootCause] Menu tab always displays the root page title when
+// navigating submenu pages. TSE did not support the display of Formset
+// Help.
+//
+// [Solution] Display Formset Help for Dynamic page, Display page title of
+// submenu pages in the menu tab.
+//
+// [Files Changed]
+// - AMITSE.sdl, CommonHelper.c, special.c, Menu.c, minisetupext.h,
+// TseUefiHii.h, Uefi21Wapper.c
+//
+// 31 9/29/11 7:02p Blaines
+// [TAG] - EIP 66860
+// [Category]- Function Request
+// [Synopsis]- AmiPostManager interface for text entry.
+// [Files] - LogoLib.h, AMIPostMgr.h, protocol.c, protocol.h,
+// TseAdvanced.c, TseLitehelper.c, TseUefiHii.h, Uefi21Wapper.c
+//
+// 30 8/26/11 6:22p Blaines
+// [TAG] EIP68354
+// [Category] Bug Fix
+// [Severity] Normal
+// [RootCause] Callback was invoked during periodic update for time and
+// date controls without EFI_IFR_REFRESH_OP.
+// [Solution] Callback is only invoked for interactive controls.
+// [Files] TseLite: Time.c, Date.c
+// Uefi21: Parese.c, Uefi21Wrapper.c
+//
+// 29 7/19/11 3:04p Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Driver health variables are updated in cache too.
+// [Files] notify.c, Uefi21Wapper.c and variable.h
+//
+// 28 6/30/11 4:20a Arunsb
+// [TAG] EIP57661
+// [Category] New Feature
+// [Description] Boot manager algorithm for interaction with Driver
+// Health protocol.
+// [Files] amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
+// commonhelper.c, uefisetup.ini, tsedrvhealth.h,
+// amivfr.h, minisetupbin.mak,
+// hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
+// special.h, boot.h, minisetup.h,
+// uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
+// uefi21wapper.c.
+//
+// 27 6/23/11 4:01p Rajashakerg
+// [TAG] EIP55762, 58925, 59971
+// [Category] New Feature
+// [Description] Support REF2,REF3 and REF4 in AMITSE
+// Support direct form navigation path
+// Improper layout of controls in the root page when Dynamic pages are
+// added using the Legacy Setup Style
+//
+// [Files] setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
+// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
+// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
+// Uefi21Wrapper.c, Parse.c Hii.c
+//
+// 26 6/22/11 6:05p Arunsb
+// [TAG] EIP56405
+// [Category] New Feature
+// [Description] Support for EFI_IFR_VARSTORE_NAME_VALUE opcode
+// [Files] Hii.c, parse.c and uefi21wapper.c
+//
+// 25 6/20/11 12:28p Rajashakerg
+// [TAG] EIP60563
+// [Category] New Feature
+// [Description] Support for signed decimal value for
+// EFI_IFR_NUMERIC_OP.
+// [Files] numeric.c, numeric.h, string.c, string.h, Uefi21Wapper.c
+//
+// 24 4/29/11 4:46p Arunsb
+// For 2.13 public patch release IFR RefX feature is omitted
+//
+// 22 3/28/11 11:45p Madhans
+// UefiGetKeyField() updated.
+//
+// 21 3/28/11 5:06p Rajashakerg
+// [TAG] EIP56413
+// [Category] Improvement
+// [Description] TSE: Support for EFI_IFR_RESET_BUTTON opcode
+// [Files] ezport.c, minisetupext.h, ResetButton.c, ResetButton.h,
+// Hii.c, TseUefiHii.h, Uefi21Wapper.c, hii.h, Uefi20Wapper.c
+//
+// 20 3/21/11 1:02a Rajashakerg
+// [TAG] EIP53480
+// [Category] Improvement
+// [Description] FormBrowser extended actions support
+// [Files] callback.c, minisetupext.c, minisetupext.h, numeric.c,
+// PopupSel.c, PopupString.c, SubMenu.c, TseLiteCommon.c, UefiAction.c,
+// Hiicallback.c, TseUefiHii.h, Uefi21Wapper.c, HiiCallback.c
+//
+// 19 3/09/11 7:26p Madhans
+// [TAG] EIPEIP48615
+// [Category] Improvement
+// [Description] To support UEFI 2.1 RefreshOp. Based in Refersh Rate
+// Controls are refershed periodically.
+// [Files] minisetupext.h
+// SubMenu.h
+// SubMenu.c
+// Memo.c
+// Memo.h
+// numeric.c
+// numeric.h
+// time.c
+// Date.c
+// PopupSel.c
+// PopupSel.h
+// PopupString.c
+// PopupString.h
+// ordlistbox.c
+// minisetupext.c
+// UefiAction.c
+// hii.h
+// Uefi20wapper.c
+// hiicallback.c
+// Parse.c
+// tseuefihii.h
+// Uefi21wapper.c
+//
+// 18 2/01/11 7:38p Madhans
+// [TAG] - EIP 50737
+// [Category]- Defect
+// [Severity]- Mordarate
+// [Symptom] - Suppressing the Interactive control does not work
+// correctly.
+// [RootCause] - The control conditional pointer if not set correctly.
+// [Solution]- To fix the Control condition pointer. And identify the
+// suppress if related to UEFI action control
+// [Files] - UefiAction.c TseLiteHelper.c hii.h uefi20wapper.c
+// uefi21wapper.c
+//
+// 17 12/28/10 12:31p Madhans
+// To update the Tag of EIp 46998. UEFI option ROM menus disappear in
+// Setup when certain options are selected.
+// No file changed but Comment updated right
+//
+// 16 12/02/10 5:51p Madhans
+// [TAG] - EIP 48169
+// [Category]- Improvment.
+// [Severity]- Mordarate
+// [Symptom]- To do the Workaround for ConfigtoBlock issues and Fix issues
+// with Retirive config.
+// [Solution]- Fix done formBrowser2.c and uefi21wrapper.c
+// [Files] - formBrowser2.c and uefi21wrapper.c
+//
+// 15 12/02/10 5:34p Madhans
+// [TAG] - EIP 49559
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- OneOption contols works ok if it stores the values in BYTE
+// and Does not contain any suppressif for options.
+// But it has issues in supporting UINT16, UINT32 and UINT64 storage.
+// [Rootcause] - The Type is not checked for Storeage and issues with
+// condition check for options.
+// [Solution]- Fix done ctrlcond.c and uefi21wrapper.c
+// [Files] - CtrlCond.h, ctrlcond.c and uefi21wrapper.c
+//
+// 14 12/02/10 5:21p Madhans
+// [TAG] - EIP 49557
+// [Category]- defect
+// [Severity]- Mordarate
+// [Symptom]- UEFIAction controls does not work correctly.
+// [Rootcause] - Action controls does not Process the QuestionResp
+// correctly.
+// [Solution]- Fix done UEFIAction to check for QuestionResp and call the
+// callback
+// [Files] - uefiaction.c and uefi21wapper.c
+//
+// 13 11/10/10 7:02p Blaines
+// EIP 47037: Add range checks to properly edit and update date/time.
+//
+// 12 10/27/10 4:25p Madhans
+// [TAG] EIP46998
+// [Category] Defect
+// [Symptom] Some user action on PCIx with UEFI Hii Pages causes Setup
+// screen pages and menu disappers.
+// [RootCause] UEFI 2.1 parsing code is not handling the Removepack and
+// New pack sequance properly. Normally UpdatePack
+// does the removepack and AddPack.
+// [Solution] UEFI 2.1 parsing code fixed to handle above case correctly.
+// [Files] hii.c HiiNotificationHandler.c Parse.c TseUefiHii.h
+// uefi21wapper.c
+//
+// 11 9/16/10 8:38p Madhans
+// Update for TSE 2.10. Refer Changelog.log for more details.
+//
+// 17 7/07/10 7:45p Madhans
+// Changes to Support Adding Conditions to Suppress or Grayout the Special
+// controls.
+//
+// 16 6/22/10 6:44a Mallikarjunanv
+// EIP 39764 - Password Encoding Enabled by default.
+//
+// 15 6/21/10 4:19p Blaines
+// Added code to support more question types for the function
+// UefiGetKeyField.
+//
+// 14 6/17/10 2:48p Madhans
+// Varsotre NameValue fix.
+//
+// 13 6/15/10 12:33p Blaines
+// Update function header and properly initialize status variable in
+// UefiSetTime and UefiGetTime.
+//
+// 12 6/14/10 7:15p Madhans
+// Dynamic parsing support
+//
+// 11 6/08/10 5:17p Blaines
+// Add support for UEFI 2.0/2.1 Date and Time controls
+//
+// 10 4/08/10 12:09p Madhans
+// To call the Special Callback with proper Key value.
+//
+// 9 4/07/10 6:25p Madhans
+// For UEFI 2.1 Error Manger variable is EFI variable not an HII Varstore.
+//
+// 8 3/11/10 5:44p Madhans
+// Coding Standards Update
+//
+// 7 2/26/10 7:02p Madhans
+// To build with EDK support.
+//
+// 4 12/14/09 4:52p Presannar
+// Bug Fix Eip-32732
+//
+// 3 11/30/09 1:10p Presannar
+// Modified ConfigAccessCallback EFI_BROWSER_ACTION from pass by reference
+// to pass by value
+//
+// 2 11/19/09 5:33p Presannar
+// Updated TSE include file name to not clash with CORE file
+// Updated fn GetControlConditionVarId to search for Control within the
+// formset if not found in current form
+// Added Fn IsPasswordEncodeEnabled
+//
+// 1 7/24/09 6:54p Presannar
+//
+// 6 5/28/09 11:50a Presannar
+// Bug Fixes
+//
+// 5 4/24/09 7:54p Presannar
+// TSE 2.0 UEFI 2.1 Code Complete
+//
+// 4 4/14/09 12:43p Presannar
+// Added Fn ProcessActionQuestionConfiguration,
+// ProcessBrowserActionRequest and _VerifyResponseString
+// Added AMI_IFR_MSGBOX declarations
+// Updated Uefi Action control handling
+//
+// 3 3/31/09 4:15p Madhans
+// UEFI Wrapper improvments.
+//
+// 2 1/29/09 6:10p Presannar
+// Added case for EFI_IFR_SUBTITLE_OP
+// Added new fn GetControlConditionVariable and HiiRemoveString
+//
+// 1 1/09/09 2:38p Presannar
+// UEFI 2.1 Hii Related Code - Initial Drop
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: Uefi21Wapper.c
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//****************************************************************//
+
+//----------------------------------------------------------------------------
+
+#include "minisetup.h"
+#include "TseUefiHii.h"
+#include "TseElinks.h" //EIP106950
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation)
+#if TSE_DEBUG_MESSAGES
+#include <Protocol\SimpleFileSystem.h>
+#endif
+#include "TseDrvHealth.h" //Has TSE related driver health structures
+//EIP 57661 Driver health support
+UINT16 *_DevicePathToStr (EFI_DEVICE_PATH_PROTOCOL *Path);
+CHAR16 DriverHealthStatus [6][23] = {
+ L"Healthy",
+ L"Repair Required",
+ L"Configuration Required",
+ L"Failed",
+ L"Reconnect Required",
+ L"Reboot Required"
+ };
+EFI_HANDLE gDrvHandle = NULL;
+EFI_DRIVER_HEALTH_PROTOCOL *gDrvHealthInstance = NULL;
+DRV_HEALTH_HNDLS *gDrvHealthHandlesHead = NULL;
+extern BOOLEAN gEnableDrvNotification; //TRUE if allow notification function to process action, FALSE to ignore the notification
+extern AMI_POST_MANAGER_PROTOCOL *mPostMgr;
+extern VOID _GetNextLanguage(CHAR8 **LangCode, CHAR8 *Lang);
+//----------------------------------------------------------------------------
+#if TSE_DEBUG_MESSAGES
+BOOLEAN SetupDebugKeyHandler(UINT16 ItemIndex, UINT16 Unicode, CHAR16 *Value) ;
+EFI_STATUS DisplayParseFormSetData(VOID) ;
+EFI_STATUS DebugShowAllHiiVariable(UINT32 formID) ;
+UINT16 _GetQuestionToken(UINT8 *ifrData);
+VOID ProcessPackToFile(EFI_HII_DATABASE_NOTIFY_TYPE NotifyType, EFI_HANDLE Handle);
+UINTN HpkFileCount=0;
+#endif //End of TSE_DEBUG_MESSAGES
+
+EFI_FILE_PROTOCOL * CreateFile(CHAR16 *filename, UINT32 index);
+EFI_GUID guidSimpleFileSystemProtocol = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
+
+static EFI_IFR_SUBTITLE _Title = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _Help = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _SubTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+static EFI_IFR_SUBTITLE _HelpTitle = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, STRING_TOKEN(STR_HELP_TITLE) };
+static EFI_IFR_SUBTITLE _NavStrings = { { EFI_IFR_SUBTITLE_OP, sizeof(EFI_IFR_SUBTITLE) }, 0 };
+
+static STRING_REF CallbackErrToken=0;
+
+AMI_IFR_MSGBOX _PreviousMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_PREVIOUS), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_PREVIOUS_MSG) };
+AMI_IFR_MSGBOX _FailsafeMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_FAILSAFE), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_FAILSAFE_MSG) };
+AMI_IFR_MSGBOX _OptimalMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_OPTIMAL), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_OPTIMAL_MSG) };
+AMI_IFR_MSGBOX _SaveMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_VALUES), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) };
+AMI_IFR_MSGBOX _SaveExitMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_EXIT), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_EXIT_MSG) };
+AMI_IFR_MSGBOX _ExitMsgBox = { 0, 0, STRING_TOKEN(STR_EXIT), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_EXIT_MSG) };
+AMI_IFR_MSGBOX _SaveResetMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_RESET), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_RESET_MSG) };
+AMI_IFR_MSGBOX _ResetMsgBox = { 0, 0, STRING_TOKEN(STR_RESET), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_RESET_MSG) };
+AMI_IFR_MSGBOX _HelpMsgBox = { 0, 0, STRING_TOKEN(STR_GENERAL_HELP), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_GENERAL_HELP_MSG) };
+AMI_IFR_MSGBOX _SaveUserMsgBox = { 0, 0, STRING_TOKEN(STR_SAVE_USER_DEFAULTS), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_SAVE_VALUES_MSG) };
+AMI_IFR_MSGBOX _LoadUserMsgBox = { 0, 0, STRING_TOKEN(STR_LOAD_USER_DEFAULTS), (VOID*)INVALID_HANDLE, STRING_TOKEN(STR_LOAD_USER_MSG) };
+
+AMI_IFR_MSGBOX _InvalidPasswordFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_ERROR_PSWD) };
+AMI_IFR_MSGBOX _ClearPasswordMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR) };//EIP:73226 To Clear Old Password message
+AMI_IFR_MSGBOX _ClearPasswordLabelMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING),(VOID*) INVALID_HANDLE, STRING_TOKEN(STR_PSWD_CLR_LABEL) };//EIP:73226 To Clear Old Password message
+AMI_IFR_MSGBOX _BootLaunchFailedMsgBox = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_WARNING_NOT_FOUND) };
+AMI_IFR_MSGBOX _gInvalidRangeFailMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), INVALID_HANDLE, STRING_TOKEN(STR_ERROR_INPUT) };
+
+AMI_IFR_MSGBOX _gDelBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_DEL_BOOT_OPTION_RESERVED) };
+AMI_IFR_MSGBOX _gAddBootOptionReserved = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_RESERVED) };
+AMI_IFR_MSGBOX _gAddBootOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_BOOT_OPTION_EMPTY) };
+AMI_IFR_MSGBOX _gAddDriverOptionEmpty = { 0, 0, STRING_TOKEN(STR_WARNING), INVALID_HANDLE, STRING_TOKEN(STR_ADD_DRIVER_OPTION_EMPTY) };
+
+
+UINTN gPreviousMsgBox = (UINTN)&_PreviousMsgBox;
+UINTN gFailsafeMsgBox = (UINTN)&_FailsafeMsgBox;
+UINTN gOptimalMsgBox = (UINTN)&_OptimalMsgBox;
+UINTN gSaveMsgBox = (UINTN)&_SaveMsgBox;
+UINTN gSaveExitMsgBox = (UINTN)&_SaveExitMsgBox;
+UINTN gExitMsgBox = (UINTN)&_ExitMsgBox;
+UINTN gSaveResetMsgBox = (UINTN)&_SaveResetMsgBox;
+UINTN gResetMsgBox = (UINTN)&_ResetMsgBox;
+UINTN gHelpMsgBox = (UINTN)&_HelpMsgBox;
+UINTN gSaveUserMsgBox = (UINTN)&_SaveUserMsgBox;
+UINTN gLoadUserMsgBox = (UINTN)&_LoadUserMsgBox;
+
+UINTN gBootLaunchFailedMsgBox = (UINTN)&_BootLaunchFailedMsgBox;
+UINTN gInvalidPasswordFailMsgBox = (UINTN)&_InvalidPasswordFailMsgBox;
+UINTN gClearPasswordMsgBox = (UINTN)&_ClearPasswordMsgBox;//EIP:73226 To display Clear Old Password message
+UINTN gClearLabelPasswordMsgBox = (UINTN)&_ClearPasswordLabelMsgBox;
+UINTN gInvalidRangeFailMsgBox = (UINTN)&_gInvalidRangeFailMsgBox;
+UINTN gDelBootOptionReserved = (UINTN)&_gDelBootOptionReserved;
+UINTN gAddBootOptionReserved = (UINTN)&_gAddBootOptionReserved;
+UINTN gAddBootOptionEmpty = (UINTN)&_gAddBootOptionEmpty;
+UINTN gAddDriverOptionEmpty = (UINTN)&_gAddDriverOptionEmpty;
+
+static AMI_IFR_MSGBOX gCallbackErrorMsgBox = { 0, 0, STRING_TOKEN(STR_ERROR), (VOID*)INVALID_HANDLE, 0 };
+
+static BOOLEAN gHiiInitialized = FALSE;
+
+EFI_GUID gEfiHiiConfigRoutingProtocolGuid = EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID;
+
+EFI_HII_CONFIG_ROUTING_PROTOCOL *gHiiConfigRouting;
+
+UINTN gTitle = (UINTN)&_Title;
+UINTN gHelp = (UINTN)&_Help;
+UINTN gSubTitle = (UINTN)&_SubTitle;
+UINTN gHelpTitle = (UINTN)&_HelpTitle;
+UINTN gNavStrings = (UINTN)&_NavStrings;
+
+VOID _UefiGetValidOptions(CONTROL_INFO *IfrPtr, UINT16 **OptionPtrTokens,
+ UINT64 **ValuePtrTokens, UINT16 *ItemCount,
+ UINT8 MaxItems);
+
+EFI_STATUS _VerifyResponseString(EFI_STRING Configuration, BOOLEAN NameValue);
+UINT32 FindVarFromITKQuestionId(UINT16 QuestionId);
+
+//EIP81814 Starts
+//---------------------------------------------------------------------------
+// Defines for Utility Functions
+//---------------------------------------------------------------------------
+#define MAX_FORMS_TO_PROCESS 50
+#define EFI_INCONSISTENT_VALUE (0x80000000 | 28)
+#define EFI_NOSUBMIT_VALUE (0x80000000 | 29)
+#define CHECKBOX_OPTION_COUNT 2
+#define OPTION_DEFAULT 0x10
+#define OPTION_DEFAULT_MFG 0x20
+#define TSE_GET_ONE_OF_WIDTH(a) (((EFI_IFR_ONE_OF*)(a))->Width)
+#define TSE_GET_ONE_OF_OPTION_WIDTH(a) ( \
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_NUM_SIZE_8 ? sizeof(UINT8) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_NUM_SIZE_16 ? sizeof(UINT16) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_NUM_SIZE_32 ? sizeof(UINT32) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_NUM_SIZE_64 ? sizeof(UINT64) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_BOOLEAN ? sizeof(BOOLEAN) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_TIME ? sizeof(EFI_HII_TIME) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_DATE ? sizeof(EFI_HII_DATE) : (\
+ ((EFI_IFR_ONE_OF_OPTION*)a)->Type == EFI_IFR_TYPE_STRING ? sizeof(EFI_STRING_ID) : (\
+ 0)))))))))
+
+
+
+typedef struct _OPTION_LIST OPTION_LIST;
+
+typedef struct _OPTION_LIST
+{
+ UINT16 Option;
+ UINT64 Value;
+ UINT8 Flag;
+ OPTION_LIST *Next;
+};
+
+static BOOLEAN LibInitialized = FALSE;
+UINT32 *gProcessedForms; //[MAX_FORMS_TO_PROCESS]; //EIP 162180
+UINT32 gVarOffset = 0;
+UINT32 gProFormOffset = 0;
+UINT32 gProFormOffsetAllocCount = 0;
+//---------------------------------------------------------------------------
+// Prototypes for Utility Functions
+//---------------------------------------------------------------------------
+BOOLEAN _InconsistenceCheck(PAGE_INFO *PgInfo, UINT16 *ErrStrToken);
+BOOLEAN _DestinationFormProcessed(UINT32 FormID);
+EFI_STATUS _GetVariableIDList(UINT32 FormID, UINT32 **varIDList);
+EFI_STATUS _GetCheckBoxOptions(CONTROL_INFO *CtrlInfo, UINT32 *OptionCount, OPTION_LIST **OptionArray);
+EFI_STATUS LoadDefaults(UINT32 FormID, BOOLEAN *ResetVal, BOOLEAN * ValChanged);
+BOOLEAN _InconsistenceCheck(PAGE_INFO *PgInfo, UINT16 *ErrStrToken);
+BOOLEAN _NoSubmitCheck(CONTROL_INFO *ctrlInfo, UINT16 *ErrStrToken);
+EFI_STATUS _GetVariableIDList(UINT32 FormID, UINT32 **VarIDList);
+BOOLEAN _DestinationFormProcessed(UINT32 FormID);
+BOOLEAN IsNoSubmitOfForms(UINT32 FormID, UINT16* ErrToken);
+EFI_STATUS CheckforNosubmitIf(UINT32 FormID, BOOLEAN Recursive, UINT16 *ErrToken);
+EFI_STATUS _GetControlFlag(UINT32 PgIndex, UINT32 CtrlIndex, CONTROL_FLAGS **CtrlFlag);
+EFI_STATUS GetNumOfPages(UINT32 *NumOfPages);
+EFI_STATUS GetPageTitle(UINT32 PgIndex, UINT16 *TitleToken);
+EFI_STATUS GetPageSubTitle(UINT32 PgIndex, UINT16 *SubtitleToken);
+EFI_STATUS GetPageHandle(UINT32 PgIndex, EFI_HII_HANDLE *Handle);
+EFI_STATUS GetPageIdIndex(UINT32 PgIndex, UINT16 *PgIdIndex);
+BOOLEAN IsParentPage(UINT32 PgIndex);
+EFI_STATUS GetPageHiiId(UINT32 PgIndex, UINT16 *PageId);
+EFI_STATUS GetPageParentId(UINT32 PgIndex, UINT16 *PageParentId);
+EFI_STATUS GetCtrlsDestCtrlId(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *DestCtrlId);
+EFI_STATUS GetControlType(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlType);
+EFI_STATUS GetControlQuestionPrompt(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlPrompt);
+EFI_STATUS GetControlHelpStr(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlHelp);
+BOOLEAN IsControlCheckBox(UINT32 PgIndex, UINT32 CtrlIndex);
+EFI_STATUS GetControlDataWidth(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlWidth);
+EFI_STATUS GetControlDestinationPage(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlDestPg);
+UINT8 GetControlAccess(UINT32 PgIndex, UINT32 CtrlIndex);
+UINT8 GetControlRefresh(UINT32 PgIndex, UINT32 CtrlIndex);
+BOOLEAN IsControlVisible(UINT32 PgIndex, UINT32 CtrlIndex);
+BOOLEAN IsControlResetRequired(UINT32 PgIndex, UINT32 CtrlIndex);
+BOOLEAN IsControlReadOnly(UINT32 PgIndex, UINT32 CtrlIndex);
+BOOLEAN IsControlInteractive(UINT32 PgIndex, UINT32 CtrlIndex);
+EFI_STATUS EvaluateControlCondition(UINT32 PgIndex, UINT32 CtrlIndex, UINTN *ExpResult);
+EFI_STATUS GetQuestionValue(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 **Value, UINTN *ValueSize);
+EFI_STATUS SetQuestionValue(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 *Value, UINTN ValueSize, UINT16 *ErrStrToken);
+EFI_STATUS SaveQuestionValues(UINT32 FormID);
+VOID FreeOptionList(OPTION_LIST *OptionArray);
+EFI_STATUS GetControlDisplayFormat(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *Format);
+EFI_STATUS GetControlMinMax(UINT32 PgIndex, UINT32 CtrlIndex, UINT64 *Min, UINT64 *Max);
+EFI_STATUS GetControlDefault(UINT32 PgIndex, UINT32 CtrlIndex,UINT8 *Def, BOOLEAN Optimal);
+EFI_STATUS GetOrderedListMaxEntries(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 *MaxEntry);
+EFI_STATUS GetOrderedListOptionDataWidth(CONTROL_INFO *ControlInfo, UINT32 *DataWidth);
+EFI_STATUS GetOrderedListDataTypeWidth(UINT32 PgIndex, UINT32 CtrlIndex, UINT32 *DataWidth);
+BOOLEAN IsPageRefreshable(UINT32 PgIndex);
+BOOLEAN IsPageModal(UINT32 PgIndex);
+BOOLEAN IfNoCommitVariable(UINT32 PgIndex, UINT32 CtrlIndex);
+BOOLEAN IdentifyFormHasDefault(UINT32 FormID);
+BOOLEAN IsFormsetHasDefault(UINT32 FormID);
+EFI_STATUS GetPageGuidFromPgIndex(UINT32 PgIndex, EFI_GUID *FormGuid);
+void AddEntryIngProcessedForms (UINT32 FormID);
+void CleargProcessedForms (void);
+//----------------------------------------------------------------------------
+//EIP81814 Ends
+
+#define _GET_MINMAXSTEP_DATA(b,c,d) ( \
+ ((c)==EFI_IFR_NUMERIC_SIZE_1)?((b).u8.d):( \
+ ((c)==EFI_IFR_NUMERIC_SIZE_2)?((b).u16.d):( \
+ ((c)==EFI_IFR_NUMERIC_SIZE_4)?((b).u32.d): \
+ ((b).u64.d) )))
+
+#define TSE_GET_NUMERIC_MINVALUE(a) _GET_MINMAXSTEP_DATA((((EFI_IFR_NUMERIC*)(a))->data),(((EFI_IFR_NUMERIC*)(a))->Flags&EFI_IFR_NUMERIC_SIZE),MinValue)
+#define TSE_GET_NUMERIC_MAXVALUE(a) _GET_MINMAXSTEP_DATA((((EFI_IFR_NUMERIC*)(a))->data),(((EFI_IFR_NUMERIC*)(a))->Flags&EFI_IFR_NUMERIC_SIZE),MaxValue)
+#define TSE_GET_NUMERIC_STEP(a) _GET_MINMAXSTEP_DATA((((EFI_IFR_NUMERIC*)(a))->data),(((EFI_IFR_NUMERIC*)(a))->Flags&EFI_IFR_NUMERIC_SIZE),Step)
+#define TSE_GET_NUMERIC_BASE(a) (((((EFI_IFR_NUMERIC*)a)->Flags&EFI_IFR_DISPLAY)==EFI_IFR_DISPLAY_UINT_HEX)?AMI_BASE_HEX:((((EFI_IFR_NUMERIC*)a)->Flags&EFI_IFR_DISPLAY)==EFI_IFR_DISPLAY_INT_DEC) ? AMI_BASE_INT_DEC :AMI_BASE_DEC)
+
+//----------------------------------------------------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetHelpField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetHelpField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+ if(IfrPtr == NULL){
+ return Token;
+ }
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ Token = ((EFI_IFR_REF *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_TEXT_OP:
+ Token = ((EFI_IFR_TEXT *)OpHeader)->Statement.Help;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ Token = ((EFI_IFR_ONE_OF *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_TIME_OP:
+ Token = ((EFI_IFR_TIME *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_DATE_OP:
+ Token = ((EFI_IFR_DATE *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ Token = ((EFI_IFR_NUMERIC *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ Token = ((EFI_IFR_PASSWORD *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_ACTION_OP:
+ Token = ((EFI_IFR_ACTION *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_STRING_OP:
+ Token = ((EFI_IFR_STRING *)OpHeader)->Question.Header.Help;
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ Token = ((EFI_IFR_RESET_BUTTON *)OpHeader)->Statement.Help;//EIP:56413 Updated the Help field for Reset Button
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ Token = ((EFI_IFR_ORDERED_LIST *)OpHeader)->Question.Header.Help;//EIP:103568 Updated the Help field for order list control.
+ break;
+ default:
+ break;
+ }
+
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetPromptField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetPromptField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+ if(IfrPtr == NULL){
+ return Token;
+ }
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ Token = ((EFI_IFR_REF *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ Token = ((EFI_IFR_NUMERIC *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_TIME_OP:
+ Token = ((EFI_IFR_TIME *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_DATE_OP:
+ Token = ((EFI_IFR_DATE *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ Token = ((EFI_IFR_ONE_OF *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ Token = ((EFI_IFR_ORDERED_LIST *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ Token = ((EFI_IFR_CHECKBOX *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ Token = ((EFI_IFR_PASSWORD *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_ACTION_OP:
+ Token = ((EFI_IFR_ACTION *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_STRING_OP:
+ Token = ((EFI_IFR_STRING *)OpHeader)->Question.Header.Prompt;
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ Token = ((EFI_IFR_RESET_BUTTON *)OpHeader)->Statement.Prompt;//EIP:56413 Updated the Prompt field for Reset Button
+ break;
+ default:
+ break;
+ }
+
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetKeyField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetKeyField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ Token = ((EFI_IFR_REF *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ Token = ((EFI_IFR_NUMERIC *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_STRING_OP:
+ Token = ((EFI_IFR_STRING *)IfrPtr)->Question.QuestionId;
+ break;
+
+ case EFI_IFR_PASSWORD_OP:
+ Token = ((EFI_IFR_PASSWORD *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ Token = ((EFI_IFR_CHECKBOX *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_ACTION_OP:
+ Token = ((EFI_IFR_ACTION *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_DATE_OP:
+ Token = ((EFI_IFR_DATE *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ Token = ((EFI_IFR_ONE_OF *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_ORDERED_LIST_OP:
+ Token = ((EFI_IFR_ORDERED_LIST *)IfrPtr)->Question.QuestionId;
+ break;
+ case EFI_IFR_TIME_OP:
+ Token = ((EFI_IFR_TIME *)IfrPtr)->Question.QuestionId;
+ break;
+ default:
+ break;
+ }
+
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTitleField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTitleField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+// EIP 88658 : Minisetup crashes after controller reconnection during Hii callback
+ if(IfrPtr == NULL){
+ goto DONE;
+ }
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUBTITLE_OP:
+ Token = ((EFI_IFR_SUBTITLE *)IfrPtr)->Statement.Prompt;
+ break;
+ case EFI_IFR_FORM_SET_OP:
+ Token = ((EFI_IFR_FORM_SET *)IfrPtr)->FormSetTitle;
+ break;
+ case EFI_IFR_FORM_OP:
+ Token = ((EFI_IFR_FORM *)IfrPtr)->FormTitle;
+ break;
+ default:
+ break;
+ }
+
+DONE:
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetFlagsField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetFlagsField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT8 Flag = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ Flag = ((EFI_IFR_REF *)IfrPtr)->Question.Flags;
+ break;
+ case EFI_IFR_TIME_OP:
+ Flag = ((EFI_IFR_TIME *)IfrPtr)->Flags;
+ break;
+ case EFI_IFR_DATE_OP:
+ Flag = ((EFI_IFR_DATE *)IfrPtr)->Flags;
+ break;
+ default:
+ break;
+ }
+
+ return Flag;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsInteractive
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ControlData
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsInteractive(CONTROL_INFO *ControlData)
+{
+ return (BOOLEAN)(ControlData->ControlFlags.ControlInteractive);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetControlKey
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ControlData
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetControlKey(CONTROL_INFO *ControlData)
+{
+ return ControlData->ControlKey;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTextField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTextField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TEXT_OP:
+ Token = ((EFI_IFR_TEXT*)OpHeader)->Statement.Prompt;
+ break;
+ default:
+ break;
+ }
+
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTextTwoField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetTextTwoField(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Token = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TEXT_OP:
+ Token = ((EFI_IFR_TEXT*)OpHeader)->TextTwo;
+ break;
+ default:
+ break;
+ }
+
+ return Token;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetSubTitleField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,UINT16 Token
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetSubTitleField(VOID *IfrPtr,UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUBTITLE_OP:
+ ((EFI_IFR_SUBTITLE*)OpHeader)->Statement.Prompt = Token;
+ break;
+ default:
+ break;
+ }
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetHelpField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,UINT16 Token
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetHelpField(VOID *IfrPtr, UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ ((EFI_IFR_REF *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_TEXT_OP:
+ ((EFI_IFR_TEXT *)OpHeader)->Statement.Help = Token ;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_TIME_OP:
+ ((EFI_IFR_TIME *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_DATE_OP:
+ ((EFI_IFR_DATE *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_NUMERIC_OP:
+ ((EFI_IFR_NUMERIC *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ ((EFI_IFR_PASSWORD *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_ACTION_OP:
+ ((EFI_IFR_ACTION *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_STRING_OP:
+ ((EFI_IFR_STRING *)OpHeader)->Question.Header.Help = Token ;
+ break;
+ case EFI_IFR_RESET_BUTTON_OP:
+ ((EFI_IFR_RESET_BUTTON *)OpHeader)->Statement.Help = Token ;
+ break;
+ default:
+ break;
+ }
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetPromptField
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,UINT16 Token
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetPromptField(VOID *IfrPtr,UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_REF_OP:
+ ((EFI_IFR_REF*)OpHeader)->Question.Header.Prompt = Token;
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_ORDERED_LIST_OP:
+ case EFI_IFR_CHECKBOX_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_STRING_OP:
+ {
+ EFI_IFR_QUESTION_HEADER *Question = (EFI_IFR_QUESTION_HEADER *)((UINT8 *)OpHeader + sizeof(EFI_IFR_OP_HEADER));
+
+ Question->Header.Prompt = Token;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateSubTitleTemplate
+//
+// Description:
+//
+// Parameter: UINT16 Token
+//
+// Return value: VOID *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID * UefiCreateSubTitleTemplate(UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_SUBTITLE));
+
+ OpHeader->OpCode = EFI_IFR_SUBTITLE_OP ;
+ OpHeader->Length = sizeof(EFI_IFR_SUBTITLE) ;
+ UefiSetSubTitleField((VOID *)OpHeader,Token);
+ return (VOID*)OpHeader;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateStringTemplate
+//
+// Description: Function to create uefi string template
+//
+// Parameter: UINT16 Token
+//
+// Return value: VOID *
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID * UefiCreateStringTemplate(UINT16 Token)
+{
+ EFI_IFR_OP_HEADER *OpHeader = EfiLibAllocateZeroPool(sizeof(EFI_IFR_STRING));
+
+ OpHeader->OpCode = EFI_IFR_STRING_OP ;
+ OpHeader->Length = sizeof(EFI_IFR_STRING) ;
+ UefiSetPromptField((VOID *)OpHeader,Token);
+ return (VOID*)OpHeader;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetIfrLength
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetIfrLength(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+
+ return OpHeader->Length;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMinValue
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT64
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetMinValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT64 Min = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ // Should The type be Taken Into Account? //
+ //Min = (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->data.u64.MinValue;
+ Min = TSE_GET_NUMERIC_MINVALUE(IfrPtr);
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ Min = (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MinSize;
+ break;
+ case EFI_IFR_STRING_OP:
+ Min = (UINT64)((EFI_IFR_STRING*)OpHeader)->MinSize;
+ break;
+ default:
+ break;
+ }
+ return Min;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMaxValue
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT64
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetMaxValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT64 Max = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ // Should The type be Taken Into Account? //
+ //Max = (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->data.u64.MaxValue;
+ Max = TSE_GET_NUMERIC_MAXVALUE(IfrPtr);
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ Max = (UINT64)((EFI_IFR_PASSWORD*)OpHeader)->MaxSize;
+ break;
+ case EFI_IFR_STRING_OP:
+ Max = (UINT64)((EFI_IFR_STRING*)OpHeader)->MaxSize;
+ break;
+ default:
+ break;
+ }
+ return Max;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetStepValue
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT64
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT64 UefiGetStepValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT64 Step = 0;
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ // Should The type be Taken Into Account? //
+ //Step = (UINT64)((EFI_IFR_NUMERIC*)OpHeader)->data.u64.Step;
+ Step = TSE_GET_NUMERIC_STEP(IfrPtr);
+ break;
+ default:
+ break;
+ }
+ return Step;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetBaseValue
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetBaseValue(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT8 Base = EFI_IFR_DISPLAY_UINT_DEC;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ //Base = (((EFI_IFR_NUMERIC *)OpHeader)->Flags & EFI_IFR_DISPLAY);
+ Base = TSE_GET_NUMERIC_BASE(IfrPtr);
+ break;
+ default:
+ break;
+ }
+ return Base;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetWidth
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetWidth(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 Width = 0;
+
+ if (NULL == OpHeader) //EIP-126997 Avoid setup crash
+ return Width;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_ONE_OF_OP:
+ Width = (UINT16)(1 << (((EFI_IFR_NUMERIC*)OpHeader)->Flags & EFI_IFR_NUMERIC_SIZE));
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ Width = (UINT16)((EFI_IFR_PASSWORD*)OpHeader)->MaxSize * sizeof(CHAR16);
+ break;
+ case EFI_IFR_STRING_OP:
+ Width = (UINT16)((EFI_IFR_STRING*)OpHeader)->MaxSize * sizeof(CHAR16);
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ Width = sizeof(UINT8);
+ break;
+ case EFI_IFR_DATE_OP:
+ Width = sizeof(EFI_HII_DATE);
+ break;
+ case EFI_IFR_TIME_OP:
+ Width = sizeof(EFI_HII_TIME);
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ case EFI_IFR_EQ_ID_LIST_OP:
+ case EFI_IFR_EQ_ID_ID_OP:
+ ASSERT(1);
+ break;
+ default:
+ break;
+ }
+ return Width;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetQuestionOffset
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+extern UINT32 gtempCurrentPage;
+UINT16 UefiGetQuestionOffset(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ EFI_IFR_QUESTION_HEADER *QHeader = NULL;
+ UINT16 VarOffset = 0;
+ UINT32 iIndex = 0;
+ VARIABLE_INFO *Variable = NULL;
+
+ if (NULL == OpHeader) //EIP-126997 Avoid setup crash
+ return VarOffset;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_CHECKBOX_OP:
+ case EFI_IFR_REF_OP:
+ case EFI_IFR_RESET_BUTTON_OP:
+ case EFI_IFR_ACTION_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_STRING_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_ORDERED_LIST_OP:
+ case EFI_IFR_TIME_OP:
+ QHeader = (EFI_IFR_QUESTION_HEADER *)((UINT8*)OpHeader + sizeof(EFI_IFR_OP_HEADER));
+ for (iIndex = 0; iIndex < gVariables->VariableCount; iIndex++)
+ {
+ Variable = (VARIABLE_INFO*)((UINT8 *)gVariables + gVariables->VariableList [iIndex]);
+ if ((VARIABLE_ATTRIBUTE_NAMEVALUE == (Variable->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)))
+ {
+ UINT32 page = (NULL == gApp ? gtempCurrentPage : gApp->CurrentPage);
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList [page]);
+
+ //Always dont depend on VariableID alone it will be same for different handles, compare handle also
+ if (pageInfo && (pageInfo->PageHandle == Variable->VariableHandle) && (Variable->VariableID == QHeader->VarStoreId))
+ {
+ return 0;
+ }
+ }
+ }
+ VarOffset = QHeader->VarStoreInfo.VarOffset;
+ break;
+ default:
+ break;
+ }
+ return VarOffset;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetDateTimeDetails
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiGetDateTimeDetails(VOID *IfrPtr,UINT8 Type,UINT16 * Help,UINT16 * Min,UINT16 * Max)
+{
+/*
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ EFI_IFR_NUMERIC *NumIfr=NULL;
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_TIME_OP:
+ if(Type == AMI_TIME_HOUR)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Hour);
+ else if (Type == AMI_TIME_MIN)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Minute);
+ else if (Type == AMI_TIME_SEC)
+ NumIfr = &(((EFI_IFR_TIME*)OpHeader)->Second);
+ break;
+ case EFI_IFR_DATE_OP:
+ if(Type == AMI_DATE_YEAR)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Year);
+ else if (Type == AMI_DATE_MONTH)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Month);
+ else if (Type == AMI_DATE_DAY)
+ NumIfr = &(((EFI_IFR_DATE*)OpHeader)->Day);
+ break;
+ default:
+ break;
+ }
+ if(NumIfr)
+ {
+ *Help = NumIfr->Help;
+ *Min = NumIfr->Minimum;
+ *Max = NumIfr->Maximum;
+ }*/
+
+ *Min = 0;
+ *Max = 0xFFFF;//EIP 74964 Initializing the MIN/MAX values for date and time.
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetOneOfOptions
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,VOID **Handle,UINT16 **OptionPtrTokens,
+// UINT64 **ValuePtrTokens, UINT16 *ItemCount,
+// UINT16 *Interactive,UINT16 *CallBackKey
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiGetOneOfOptions(CONTROL_INFO *CtrlInfo, VOID **Handle, UINT16 **OptionPtrTokens,
+ UINT64 **ValuePtrTokens, UINT16 *ItemCount,
+ UINT16 *Interactive,UINT16 *CallBackKey )
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)(CtrlInfo->ControlPtr);
+ EFI_IFR_QUESTION_HEADER *QHeader;
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINT16 Index= 0;
+ UINT8 Opcode = OpHeader->OpCode;
+ UINT8 MaxItems = 10;
+
+ if(OpHeader->OpCode == EFI_IFR_CHECKBOX_OP)
+ {
+ MaxItems = 2;
+ *Handle = gHiiHandle;
+ }
+
+ // Evaluate Interactive and Callback
+ QHeader = (EFI_IFR_QUESTION_HEADER *)((UINT8 *)OpHeader + sizeof(EFI_IFR_OP_HEADER));
+ if(QHeader->Flags & EFI_IFR_FLAG_CALLBACK)
+ {
+ if(Interactive)
+ *Interactive = TRUE;
+ if(CallBackKey)
+ *CallBackKey = QHeader->QuestionId;
+ }
+
+ // Free Buffers if Allocated and Allocate afresh
+ if( OptionPtrTokens != NULL )
+ {
+ if( *OptionPtrTokens != NULL )
+ MemFreePointer((VOID **)OptionPtrTokens);
+ }
+
+ if( ValuePtrTokens != NULL )
+ {
+ if( *ValuePtrTokens != NULL )
+ MemFreePointer((VOID **)ValuePtrTokens);
+ }
+
+ if( NULL != OptionPtrTokens )//EIP-75379 Static code analysis check for NULL
+ {
+ *OptionPtrTokens = (UINT16 *)EfiLibAllocateZeroPool(MaxItems * sizeof(UINT16));
+ }
+
+ if(ValuePtrTokens)
+ *ValuePtrTokens = (UINT64 *)EfiLibAllocateZeroPool(MaxItems * sizeof(UINT64));
+
+ if ( NULL == OptionPtrTokens || NULL == *OptionPtrTokens )//EIP-75379 Static code analysis check for NULL
+ {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ //Populate Options
+ if(Opcode == EFI_IFR_CHECKBOX_OP)
+ {
+ *ItemCount = MaxItems;
+ for(Index = 0; Index < MaxItems; Index++)
+ {
+ (*OptionPtrTokens)[Index] = gCheckboxTokens[Index];
+ if(ValuePtrTokens)
+ (*ValuePtrTokens)[Index] = Index;
+ }
+ }
+ else
+ {
+ *ItemCount = 0;
+ _UefiGetValidOptions(CtrlInfo, OptionPtrTokens, ValuePtrTokens, ItemCount, MaxItems);
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _UefiGetValidOptions
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *CtrlInfo, UINT16 **OptionPtrTokens,
+// UINT64 **ValuePtrTokens, UINT16 *ItemCount,UINT8 MaxItems
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID _UefiGetValidOptions(CONTROL_INFO *CtrlInfo, UINT16 **OptionPtrTokens,
+ UINT64 **ValuePtrTokens, UINT16 *ItemCount,UINT8 MaxItems)
+{
+ EFI_IFR_OP_HEADER *OpHeader = (EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr;
+ UINT32 Offset = 0;
+ INT32 InScope = 0;
+ UINT16 Max = (UINT16)MaxItems;
+ UINT16 Itr = 0;
+ UINT8 suppress = FALSE;
+ UINT8 condition = COND_NONE;
+ INT32 suppressScopeCount = 0;
+ UINT8 *conditionPtr = NULL;
+
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ suppressScopeCount = suppressScopeCount? ++suppressScopeCount : 0;
+ }
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUPPRESS_IF_OP:
+ if(suppress == FALSE)
+ {
+ conditionPtr = (UINT8 *)OpHeader;
+ suppress = TRUE;
+ suppressScopeCount++;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ // Evaluate Condition to determine if option is required to be added to list
+ condition = suppress && conditionPtr? CheckOneOfOptionSuppressIf(CtrlInfo, conditionPtr, (UINT8*)OpHeader) : COND_NONE;
+ if(condition != COND_SUPPRESS)
+ {
+ // Add Option to Buffer.
+ if(Itr == Max)
+ {
+ *OptionPtrTokens = MemReallocateZeroPool(*OptionPtrTokens, Max * sizeof(UINT16), (Max + 10) * sizeof(UINT16));
+ if(ValuePtrTokens)
+ {
+ *ValuePtrTokens = MemReallocateZeroPool(*ValuePtrTokens, Max * sizeof(UINT64), (Max + 10) * sizeof(UINT64));
+ }
+ Max += 10;
+ }
+ (*OptionPtrTokens)[Itr] = ((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Option;
+ if(ValuePtrTokens)
+ {
+ switch(((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Type)
+ {
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ (*ValuePtrTokens)[Itr] = ((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Value.u16;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ (*ValuePtrTokens)[Itr] = ((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Value.u32;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ (*ValuePtrTokens)[Itr] = ((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Value.u64;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ default:
+ (*ValuePtrTokens)[Itr] = ((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Value.u8;
+ break;
+ }
+ }
+ Itr++;
+ }
+ break;
+ case EFI_IFR_END_OP:
+ InScope = InScope > 0? --InScope : 0;
+ suppressScopeCount = suppressScopeCount > 0? --suppressScopeCount : 0;
+ suppress = suppressScopeCount == 0? FALSE : suppress;
+ conditionPtr = suppress == TRUE? conditionPtr : NULL;
+ default:
+ break;
+ }
+
+ // Move to Next Opcode
+ Offset += OpHeader->Length;
+ OpHeader = (EFI_IFR_OP_HEADER *)((UINT8*)CtrlInfo->ControlPtr + Offset);
+ }while(InScope);
+ *ItemCount = Itr;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UefiGetValidOptionType
+//
+// Description: Assuming all the options in this control has option with
+// same type and length
+//
+// Input: CONTROL_INFO *CtrlInfo - Pointer to the control info data
+// UINTN *Type - Returns EFI_IFR_TYPE_NUM_SIZE
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiGetValidOptionType(CONTROL_INFO *CtrlInfo, UINTN *Type, UINT32 *SizeOfData)
+{
+ EFI_IFR_OP_HEADER *OpHeader = (EFI_IFR_OP_HEADER *)CtrlInfo->ControlPtr;
+ UINT32 Offset = 0;
+ INT32 InScope = 0;
+ UINT8 suppress = FALSE;
+ UINT8 condition = COND_NONE;
+ INT32 suppressScopeCount = 0;
+ UINT8 *conditionPtr = NULL;
+
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ suppressScopeCount = suppressScopeCount? ++suppressScopeCount : 0;
+ }
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_SUPPRESS_IF_OP:
+ if(suppress == FALSE)
+ {
+ conditionPtr = (UINT8 *)OpHeader;
+ suppress = TRUE;
+ suppressScopeCount++;
+ }
+ break;
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ // Evaluate Condition to determine if option is required to be added to list
+ condition = suppress && conditionPtr? CheckOneOfOptionSuppressIf(CtrlInfo, conditionPtr, (UINT8*)OpHeader) : COND_NONE;
+ if(condition != COND_SUPPRESS)
+ {
+ switch(((EFI_IFR_ONE_OF_OPTION *)OpHeader)->Type)
+ {
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ *Type = EFI_IFR_TYPE_NUM_SIZE_16;
+ *SizeOfData = sizeof(UINT16);
+ goto DONE;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ *Type = EFI_IFR_TYPE_NUM_SIZE_32;
+ *SizeOfData = sizeof(UINT32);
+ goto DONE;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ *Type = EFI_IFR_TYPE_NUM_SIZE_64;
+ *SizeOfData = sizeof(UINT64);
+ goto DONE;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ default:
+ *Type = EFI_IFR_TYPE_NUM_SIZE_8;
+ *SizeOfData = sizeof(UINT8);
+ goto DONE;
+ }
+ }
+ break;
+ case EFI_IFR_END_OP:
+ InScope = InScope > 0? --InScope : 0;
+ suppressScopeCount = suppressScopeCount > 0? --suppressScopeCount : 0;
+ suppress = suppressScopeCount == 0? FALSE : suppress;
+ conditionPtr = suppress == TRUE? conditionPtr : NULL;
+ break;
+ default:
+ break;
+ }
+ // Move to Next Opcode
+ Offset += OpHeader->Length;
+ OpHeader = (EFI_IFR_OP_HEADER *)((UINT8*)CtrlInfo->ControlPtr + Offset);
+ }while(InScope);
+
+DONE:
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetMaxEntries
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 UefiGetMaxEntries(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT8 Value = 0;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_ORDERED_LIST_OP:
+ Value = ((EFI_IFR_ORDERED_LIST*)OpHeader)->MaxContainers;
+ break;
+ default:
+ break;
+ }
+ return Value;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiTseLiteGetBootOverRideIndex
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiTseLiteGetBootOverRideIndex(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+ EFI_IFR_EQ_ID_LIST *EqIdList;
+ UINT16 Index=0xFFFF;
+ UINT8 InScope = 0;
+
+ if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP))
+ {
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ }
+
+ if(OpHeader->OpCode == EFI_IFR_END_OP)
+ {
+ InScope--;
+ if(InScope == 0)
+ {
+ // EFI_IFR_EQ_ID_LIST_OP opcode not found
+ goto DONE;
+ }
+ }
+
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ }while(OpHeader->OpCode != EFI_IFR_EQ_ID_LIST_OP);
+
+ // FIX ME : Do it better. Check the list length and
+ if(OpHeader->OpCode == EFI_IFR_EQ_ID_LIST_OP)
+ {
+ EqIdList = (EFI_IFR_EQ_ID_LIST*)OpHeader;
+ Index = EqIdList->ListLength - 1;
+ }
+ }
+
+DONE:
+ return Index;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiTseLiteGetAmiCallbackIndex
+//
+// Description:
+//
+// Parameter: VOID * Ptr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiTseLiteGetAmiCallbackIndex(VOID * Ptr, VOID * CtrlPtr)
+{
+ EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Ptr;
+ UINT16 Index=0xFFFF;
+ UINT8 InScope = 0;
+ VOID *SupressIfPtr = NULL;
+
+ if ((OpHeader != NULL) && (OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP))
+ {
+ // Locate the Last supress If till the control Ptr
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ }
+ if(OpHeader->OpCode == EFI_IFR_END_OP)
+ {
+ InScope--;
+ if(InScope == 0)
+ {
+ // EFI_IFR_EQ_ID_VAL_OP opcode not found
+ goto DONE;
+ }
+ }
+ if(OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP)
+ SupressIfPtr = (VOID*)OpHeader;
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ }while((UINTN)OpHeader < (UINTN)CtrlPtr);
+
+ OpHeader = (EFI_IFR_OP_HEADER*)SupressIfPtr ;
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ }
+ if(OpHeader->OpCode == EFI_IFR_END_OP)
+ {
+ InScope--;
+ if(InScope == 0)
+ {
+ // EFI_IFR_EQ_ID_VAL_OP opcode not found
+ goto DONE;
+ }
+ }
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ }while(OpHeader->OpCode != EFI_IFR_EQ_ID_VAL_OP);
+
+ // FIX ME : Do it better. Check the list length and
+ if(OpHeader->OpCode == EFI_IFR_EQ_ID_VAL_OP)
+ {
+ Index = ((EFI_IFR_EQ_ID_VAL*)OpHeader)->Value;
+ }
+ }
+
+DONE:
+ return Index;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiFormCallbackNVRead
+//
+// Description:
+//
+// Parameter: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes,
+// UINTN *size, VOID **buffer
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiFormCallbackNVWrite
+//
+// Description:
+//
+// Parameter: CHAR16 *name, EFI_GUID *guid, UINT32 attributes,
+// VOID *buffer, UINTN size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiVarGetNvram
+//
+// Description:
+//
+// Parameter: VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset,
+// UINTN Size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NameValueGetHexStringAsBuffer (UINT8 **Buffer, CHAR16 *HexStringBuffer, UINTN Size);
+EFI_STATUS UefiVarGetNvram(VARIABLE_INFO *VariableInfo, VOID **Buffer, UINTN Offset, UINTN Size)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STRING configuration = (EFI_STRING)NULL;
+ EFI_STRING result = (EFI_STRING)NULL;
+ EFI_STRING stringPtr = (EFI_STRING)NULL;
+ UINTN length = 1;
+ UINT8 *buffer = NULL;
+ EFI_GUID EfiHiiConfigAccessProtocolGuid = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
+ CHAR16 tmpString = (CHAR16)NULL;
+ EFI_STRING progress = &tmpString;
+ BOOLEAN PreservegEnableDrvNotification = FALSE;
+
+ configuration = EfiLibAllocateZeroPool(length);
+ if(configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ //
+ // Construct the Configuration Header String
+ //
+ status = GetConfigHeader(VariableInfo, &configuration, &length);
+ if(EFI_ERROR(status) || (configuration == NULL))//EIP-75384 Static Analysis
+ {
+ goto DONE;
+ }
+
+ if(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ //Allocate Memory for "&<Name>"
+ UINTN len = length + EfiStrLen(L"&") + EfiStrLen(VariableInfo->VariableName) + sizeof(CHAR16);
+
+ configuration = MemReallocateZeroPool(configuration, length * sizeof(CHAR16), len * sizeof(CHAR16));
+ if(configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ EfiStrCat(configuration, L"&");
+ EfiStrCat(configuration, VariableInfo->VariableName);
+ length = len;
+ }else
+ {
+ status = GetBlockName(&configuration, &length, Offset, Size);
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ }
+
+ SetCallBackControlInfo(VariableInfo->VariableHandle, 0); //Set this varaible handle to allow BrowserCallback
+
+ PreservegEnableDrvNotification = gEnableDrvNotification;
+ gEnableDrvNotification = TRUE; //EIP75588 Set to enable notification processing
+
+ if (!(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)) // Invoke Config Routing Route Config
+ {
+ status = gHiiConfigRouting->ExtractConfig (gHiiConfigRouting, configuration, &progress, &result);
+ }
+ else
+ {
+ status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, VariableInfo->VariableHandle, &DriverHandle); //Calling the driver which publishes the name value
+ if(!EFI_ERROR(status))
+ {
+ status = gBS->HandleProtocol (DriverHandle, &EfiHiiConfigAccessProtocolGuid , &ConfigAccess);
+ if(!EFI_ERROR(status))
+ {
+ status = ConfigAccess->ExtractConfig (ConfigAccess, configuration, &progress, &result);
+ }
+ }
+ }
+ if (!PreservegEnableDrvNotification) // If gEnableDrvNotification is already True Don't touch it
+ gEnableDrvNotification = FALSE; //EIP75588 Reset to disable notification processing
+ SetCallBackControlInfo(NULL, 0); //Disable update
+ if(EFI_ERROR(status) || (progress == (EFI_STRING)NULL))
+ {
+ goto DONE;
+ }
+
+ if(EFI_ERROR(status = _VerifyResponseString(result, (VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)? TRUE : FALSE)))
+ {
+ goto DONE;
+ }
+
+ stringPtr = result;
+ if(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ for(stringPtr = result; *stringPtr != 0 && EfiStrnCmp(stringPtr, VariableInfo->VariableName, EfiStrLen(VariableInfo->VariableName)) != 0; stringPtr++)
+ ;
+ stringPtr += EfiStrLen(VariableInfo->VariableName);
+ stringPtr += EfiStrLen(L"=");
+ status = NameValueGetHexStringAsBuffer (&buffer, stringPtr, Size);
+ }else
+ {
+ for(stringPtr = result; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&VALUE=", EfiStrLen(L"&VALUE=")) != 0; stringPtr++)
+ ;
+ stringPtr += EfiStrLen(L"&VALUE=");
+ status = GetHexStringAsBuffer (&buffer, stringPtr);
+ }
+
+
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ *Buffer = buffer;
+
+DONE:
+ if(configuration)
+ {
+ MemFreePointer(&configuration);
+ }
+ if(result)
+ {
+ MemFreePointer(&result);
+ }
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiVarSetNvram
+//
+// Description:
+//
+// Parameter: VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset,
+// UINTN Size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NameValueBufToHexString (IN OUT CHAR16 **, IN OUT UINTN *, IN UINT8 *, IN UINTN );
+EFI_STATUS UefiVarSetNvram(VARIABLE_INFO *VariableInfo, VOID *Buffer, UINTN Offset, UINTN Size)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STRING configuration = NULL;
+ EFI_STRING progress = NULL;
+ CHAR16 *tempBuffer = NULL;
+ UINTN length = 0;
+ UINTN finalLen = 0;
+ UINTN bufLen = 1;
+ BOOLEAN PreservegEnableDrvNotification = FALSE;
+
+ //
+ //Construct the Configuration Header String
+ //
+ status = GetConfigHeader(VariableInfo, &configuration, &length);
+ if(EFI_ERROR(status) || (configuration == NULL))//EIP-75384 Static Analysis
+ {
+ goto DONE;
+ }
+
+ if(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ UINTN len = length + EfiStrLen(L"&") + EfiStrLen(VariableInfo->VariableName) + EfiStrLen(L"=") + sizeof(CHAR16);
+ configuration = MemReallocateZeroPool (configuration, length * sizeof(CHAR16), len * sizeof(CHAR16));
+ if (configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ EfiStrCat(configuration, L"&");
+ EfiStrCat(configuration, VariableInfo->VariableName);
+ EfiStrCat(configuration, L"=");
+ length = EfiStrLen (configuration) * sizeof (CHAR16);
+ }else
+ {
+ status = GetBlockName(&configuration, &length, Offset, Size);
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+ }
+
+ //
+ // Get the Buffer as Hex String
+ //
+ if (!(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ tempBuffer = (UINT16*)EfiLibAllocateZeroPool(bufLen * sizeof(UINT16));
+ if(tempBuffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ status = BufToHexString(tempBuffer, &bufLen, Buffer, Size);
+ if(EFI_ERROR(status))
+ {
+ if(status != EFI_BUFFER_TOO_SMALL)
+ {
+ goto DONE;
+ }
+ if(tempBuffer)
+ {
+ MemFreePointer(&tempBuffer);
+ }
+ tempBuffer = (UINT16*)EfiLibAllocateZeroPool(bufLen * 2);
+ if(tempBuffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ }
+ status = BufToHexString(tempBuffer, &bufLen, Buffer, Size);
+ }
+ else
+ {
+ bufLen = 0;
+ status = NameValueBufToHexString (&tempBuffer, &bufLen, Buffer, Size);
+ }
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+//
+ // Calculate the total Configuration string length
+ // <Config Hdr>&OFFSET=<HexChar>0&WIDTH=<HexChar>&VALUE=<HexChar><NULL>
+ // | length | 7 | bufLen | 1 |
+ //
+ if (!(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ finalLen = length + (bufLen * 2) + (EfiStrLen(L"&VALUE=") * sizeof(CHAR16));
+ }
+ else
+ { //<exislen> + <Var val> + <NULL>
+ finalLen = length + bufLen + (2 * sizeof (CHAR16)); //Last 2 bytes for appending & and NULL
+ }
+ configuration = MemReallocateZeroPool(configuration, length, finalLen);
+ if(configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ if (!(VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE))
+ {
+ EfiStrCat(configuration, L"&VALUE=");
+ }
+ EfiStrCat(configuration, tempBuffer);
+ if (VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE)
+ {
+ EfiStrCat (configuration, L"&");
+ }
+ MemFreePointer(&tempBuffer);
+ PreservegEnableDrvNotification = gEnableDrvNotification;
+ gEnableDrvNotification = TRUE; //EIP75588 Set to enable notification processing
+ status = gHiiConfigRouting->RouteConfig (gHiiConfigRouting, configuration, &progress);
+ if(!PreservegEnableDrvNotification) // If gEnableDrvNotification is already True Don't touch it
+ gEnableDrvNotification = FALSE; //Reset to disable notification processing
+ MemFreePointer (&configuration);
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _ConstructConfigHdr
+//
+// Description: Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+//
+// Parameter: IN OUT CHAR16 *ConfigHdr,
+// IN OUT UINTN *StrBufferLen,
+// IN EFI_GUID *Guid,
+// IN CHAR16 *Name, OPTIONAL
+// IN EFI_HANDLE *DriverHandle
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _ConstructConfigHdr (
+ IN OUT CHAR16 *ConfigHdr,
+ IN OUT UINTN *StrBufferLen,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name, OPTIONAL
+ IN EFI_HANDLE *DriverHandle
+ )
+{
+ EFI_STATUS Status;
+ UINTN NameStrLen;
+ UINTN DevicePathSize;
+ UINTN BufferSize;
+ CHAR16 *StrPtr;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if (Name == NULL)
+ {
+ //
+ // There will be no "NAME" in <ConfigHdr> for Name/Value storage
+ //
+ NameStrLen = 0;
+ } else
+ {
+ //
+ // For buffer storage
+ //
+ NameStrLen = EfiStrLen (Name);
+ }
+
+ //
+ // Retrieve DevicePath Protocol associated with this HiiPackageList
+ //
+ Status = gBS->HandleProtocol (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &DevicePath
+ );
+ if (EFI_ERROR (Status))
+ {
+ return Status;
+ }
+
+ DevicePathSize = EfiDevicePathSize (DevicePath);
+
+ //
+ // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
+ // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
+ //
+ BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
+ if (*StrBufferLen < BufferSize)
+ {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+
+ StrPtr = ConfigHdr;
+
+ EfiStrCpy (StrPtr, L"GUID=");
+ StrPtr += 5;
+ BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
+ StrPtr += 32;
+
+ //
+ // Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"
+ //
+ EfiStrCpy (StrPtr, L"&NAME=");
+ StrPtr += 6;
+ if (Name != NULL)
+ {
+ BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);
+ UnicodeToConfigString (StrPtr, &BufferSize, Name);
+ StrPtr += (NameStrLen * 4);
+ }
+
+ EfiStrCpy (StrPtr, L"&PATH=");
+ StrPtr += 6;
+ BufferToHexString (StrPtr, (UINT8 *) DevicePath, DevicePathSize);
+
+ return EFI_SUCCESS;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetConfigHeader
+//
+// Description:
+//
+// Parameter: VARIABLE_INFO *VariableInfo, EFI_STRING *Configuration, UINTN *Length
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetConfigHeader(VARIABLE_INFO *VariableInfo, EFI_STRING *Configuration, UINTN *Length)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STRING configuration = NULL;
+ EFI_HANDLE driverHandle;
+ UINTN length = 50;
+
+ //
+ // Initialize Protocols
+ //
+ status = HiiInitializeProtocol();
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ //
+ // Retrieve the Device Path from Handle
+ //
+ status = gHiiDatabase->GetPackageListHandle(gHiiDatabase, VariableInfo->VariableHandle, &driverHandle);
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ // Allocate static memory of 50 Bytes, which will be freed if not used
+ configuration = (UINT16*)EfiLibAllocateZeroPool(50);
+
+ // Construct the Configuration Header String
+ //
+ status = _ConstructConfigHdr(configuration, &length, &VariableInfo->VariableGuid, VariableInfo->VariableName, driverHandle);
+ if(EFI_ERROR(status))
+ {
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ MemFreePointer(&configuration);
+ configuration = (UINT16*)EfiLibAllocateZeroPool(length);
+ if(configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ status = _ConstructConfigHdr(configuration, &length, &VariableInfo->VariableGuid, VariableInfo->VariableName, driverHandle);
+ }
+ }
+
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ if(*Configuration)
+ {
+ MemFreePointer(Configuration);
+ }
+ *Configuration = configuration;
+ *Length = length;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBlockName
+//
+// Description:
+//
+// Parameter: EFI_STRING *Configuration, UINTN *Length, UINTN Size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetBlockName(EFI_STRING *Configuration, UINTN *Length, UINTN Offset, UINTN Size)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN length = 0;
+ UINTN finalLen = 0;
+ CHAR16 *tempBuffer = NULL;
+
+ length = (EfiStrLen(L"&OFFSET=") + sizeof(Offset) + EfiStrLen(L"&WIDTH=") + sizeof(Size) + 1) * sizeof(CHAR16);
+ tempBuffer = (CHAR16*)EfiLibAllocateZeroPool(length);
+ if(tempBuffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ SPrint(tempBuffer, length, L"&OFFSET=%x&WIDTH=%x", Offset, Size);
+
+ length = EfiStrLen(*Configuration) * sizeof(CHAR16);
+ finalLen = (EfiStrLen(*Configuration) + EfiStrLen(tempBuffer) + 1) * sizeof(CHAR16);
+ *Configuration = MemReallocateZeroPool(*Configuration, length, finalLen);
+ if(*Configuration == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+
+ EfiStrCat(*Configuration, tempBuffer);
+
+ MemFreePointer(&tempBuffer);
+ *Length = finalLen;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _VerifyResponseString
+//
+// Description: Verifies Correctness of Response String. This is to prevent
+// crashing if the result pointer is pointing to an invalid location.
+//
+// Parameter: EFI_STRING *Configuration
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _VerifyResponseString(EFI_STRING Configuration, BOOLEAN NameValue)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STRING config = Configuration;
+ CHAR16 *keyWord[] = {L"GUID=", L"&NAME=", L"&PATH=", L"&OFFSET=",L"&WIDTH=", L"&VALUE="};
+ UINT32 i = 0;
+ UINT32 count = NameValue? 3 : 6; // If Name Value Check only upto &Path else check until &Value.
+
+ if(EfiStrnCmp(config, keyWord[i], EfiStrLen(keyWord[i])) != 0)
+ {
+ status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+
+ for(i = 1; i < count; i++)
+ {
+ for(;EfiStrnCmp(config, keyWord[i], EfiStrLen(keyWord[i])) != 0 && (config != (Configuration + EfiStrLen(Configuration))); config++)
+ ;
+ if(EfiStrnCmp(config, keyWord[i], EfiStrLen(keyWord[i])) != 0)
+ {
+ status = EFI_NOT_FOUND;
+ goto DONE;
+ }
+ }
+
+DONE:
+ return status;
+}
+
+#if !TSE_USE_EDK_LIBRARY
+VOID
+EfiLibSafeFreePool (
+ IN VOID *Buffer
+ )
+{
+MemFreePointer(&Buffer);
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetHexStringAsBuffer
+//
+// Description:
+//
+// Parameter: CHAR8 *Buffer
+// UINT16 *HexStringBuffer
+// UINTN Size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetHexStringAsBuffer(UINT8 **Buffer, CHAR16 *HexStringBuffer)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN bufLength = 0;
+ UINTN convertedStrLen = 0;
+
+ status = HexStringToBuf(*Buffer, &bufLength, HexStringBuffer, &convertedStrLen);
+ if(EFI_ERROR(status))
+ {
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ if(*Buffer)
+ {
+ MemFreePointer(Buffer);
+ }
+ *Buffer = EfiLibAllocateZeroPool(bufLength);
+ if(*Buffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ }else
+ {
+ goto DONE;
+ }
+ status = HexStringToBuf(*Buffer, &bufLength, HexStringBuffer, &convertedStrLen);
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: NameValueGetHexStringAsBuffer
+//
+// Description:
+//
+// Parameter: CHAR8 *Buffer
+// UINT16 *HexStringBuffer
+// UINTN Size
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS NameValueHexStringToBuf (IN OUT UINT8 *, IN OUT UINTN *Len,IN CHAR16 *, OUT UINTN *);
+EFI_STATUS NameValueGetHexStringAsBuffer (UINT8 **Buffer, CHAR16 *HexStringBuffer, UINTN Size)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN bufLength = 0;
+ UINTN convertedStrLen = 0;
+
+ if (Size <= sizeof (UINT64))
+ {
+ GetHexStringAsBuffer (Buffer, HexStringBuffer);
+ }
+ else
+ {
+ status = NameValueHexStringToBuf (*Buffer, &bufLength, HexStringBuffer, &convertedStrLen);
+ if(EFI_ERROR(status))
+ {
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ if(*Buffer)
+ {
+ MemFreePointer(Buffer);
+ }
+ bufLength = (Size > bufLength) ? Size : bufLength;
+ *Buffer = EfiLibAllocateZeroPool(bufLength);
+ if(*Buffer == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ goto DONE;
+ }
+ }else
+ {
+ goto DONE;
+ }
+ status = NameValueHexStringToBuf (*Buffer, &bufLength, HexStringBuffer, &convertedStrLen);
+ }
+ }
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: HiiExtendedInitializeProtocol
+//
+// Description:
+//
+// Parameter:
+//
+// Return value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS HiiExtendedInitializeProtocol()
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ if (gHiiInitialized)
+ {
+ goto DONE;
+ }
+
+ status = gBS->LocateProtocol(&gEfiHiiConfigRoutingProtocolGuid, NULL, &gHiiConfigRouting);
+ if(EFI_ERROR(status))
+ {
+ goto DONE;
+ }
+
+ gHiiInitialized = TRUE;
+
+DONE:
+ return status;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetControlConditionVariable
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ControlInfo
+//
+// Return value: UINT32
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 GetControlConditionVariable(CONTROL_INFO *ControlInfo)
+{
+ EFI_IFR_OP_HEADER *ifrPtr;
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[ControlInfo->ControlPageID]);
+ UINTN control = 0;
+ CONTROL_INFO *CtrlInfo;
+ BOOLEAN found = FALSE;
+ EFI_QUESTION_ID QuestionId;
+ UINT32 varId = 0;
+
+ if ( ControlInfo == NULL )
+ return 0;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)ControlInfo->ControlConditionalPtr;
+
+ if ( ifrPtr == NULL )
+ return 0;
+
+ if ( ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAY_OUT_IF_OP ) )
+ return 0;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+ // skip NOT if it is present
+ if ( ifrPtr->OpCode == EFI_IFR_NOT_OP )
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+
+ if ( ifrPtr->OpCode == EFI_IFR_EQ_ID_LIST_OP )
+ QuestionId = ((EFI_IFR_EQ_ID_LIST *)ifrPtr)->QuestionId;
+ else if ( ifrPtr->OpCode == EFI_IFR_EQ_ID_VAL_OP )
+ QuestionId = ((EFI_IFR_EQ_ID_VAL *)ifrPtr)->QuestionId;
+ else
+ return 0;
+
+ if(pageInfo->PageHandle ==0)
+ return 0;
+
+ for ( control= 0; (control < pageInfo->PageControls.ControlCount) && (found == FALSE); control++ )
+ {
+ CtrlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == CtrlInfo->ControlKey)
+ {
+ varId = CtrlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ if(!found)
+ return 0;
+
+ return varId;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiRemoveString
+//
+// Description:
+//
+// Parameter: EFI_HII_HANDLE Handle, UINT16 Token
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID HiiRemoveString(EFI_HII_HANDLE Handle, UINT16 Token)
+{
+ UINT32 i = 0;
+ CHAR16 *nullString = NULL;
+
+ for ( i = 0; i < gLangCount; i++ )
+ {
+ HiiChangeStringLanguage( Handle, Token, gLanguages[i].Unicode, nullString );
+ }
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsEfiVariable
+//
+// Description:
+//
+// Parameter: UINT32 variable, VARIABLE_INFO *varInfo
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsEfiVariable(UINT32 variable, VARIABLE_INFO *varInfo)
+{
+ if (varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE ||
+ variable == VARIABLE_ID_LANGUAGE ||
+ variable == VARIABLE_ID_DEL_BOOT_OPTION ||
+ variable == VARIABLE_ID_ADD_BOOT_OPTION ||
+ variable == VARIABLE_ID_BOOT_MANAGER ||
+ variable == VARIABLE_ID_BOOT_NOW ||
+ variable == VARIABLE_ID_LEGACY_DEV_INFO ||
+ variable == VARIABLE_ID_LEGACY_GROUP_INFO ||
+ variable == VARIABLE_ID_BOOT_TIMEOUT ||
+ variable == VARIABLE_ID_BOOT_ORDER ||
+ variable == VARIABLE_ID_AMI_CALLBACK ||
+ variable == VARIABLE_ID_AMITSESETUP ||
+ variable == VARIABLE_ID_ERROR_MANAGER ||
+ variable == VARIABLE_ID_USER_DEFAULTS ||
+ variable == VARIABLE_ID_BBS_ORDER ||
+ variable == VARIABLE_ID_DRIVER_MANAGER ||
+ variable == VARIABLE_ID_DRIVER_ORDER ||
+ variable == VARIABLE_ID_ADD_DRIVER_OPTION || //EIP70421 Support for driver order
+ variable == VARIABLE_ID_DEL_DRIVER_OPTION ||
+ variable == VARIABLE_ID_IDE_SECURITY)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+EFI_HII_PACKAGE_LIST_HEADER *
+PreparePackageList (
+ IN UINTN NumberOfPackages,
+ IN EFI_GUID *GuidId,
+ ...
+ );
+
+#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: InitMiniSetupStrings
+//
+// Description:
+//
+// Parameter: VOID
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS InitMiniSetupStrings( VOID )
+{
+ EFI_STATUS Status=EFI_SUCCESS;
+ UINT16 Index = 0;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList=NULL;
+#ifdef STANDALONE_APPLICATION
+ EFI_GUID MiniSetupGuid = ENVIRONMENT_VARIABLE_ID ;
+#else
+ EFI_GUID MiniSetupGuid = MINI_SETUP_GUID ;
+#endif
+ Status = HiiInitializeProtocol();
+ if ( EFI_ERROR ( Status ) )
+ return Status;
+
+ gHiiHandle = HiiFindHandle( &MiniSetupGuid, &Index );
+
+ if(gHiiHandle != INVALID_HANDLE){ //Remove the previous pack installed with this GUID
+ Status = gHiiDatabase->RemovePackageList(gHiiDatabase, gHiiHandle);
+ gHiiHandle = INVALID_HANDLE;
+ }
+
+ if ( gHiiHandle == INVALID_HANDLE )
+ {
+ PackageList = PreparePackageList (
+ 1,
+ &MiniSetupGuid,
+ STRING_ARRAY_NAME
+ );
+ if (PackageList == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gHiiDatabase->NewPackageList (
+ gHiiDatabase,
+ PackageList,
+ gImageHandle,
+ &gHiiHandle
+ );
+ }
+
+ return Status;
+}
+#endif
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetManufactuingMask
+//
+// Description:
+//
+// Parameter: VOID
+//
+// Return value: UINTN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiGetManufactuingMask(VOID)
+{
+ return AMI_FLAG_MANUFACTURING;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: HiiGetDefaultMask
+//
+// Description:
+//
+// Parameter: VOID
+//
+// Return value: UINTN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN HiiGetDefaultMask(VOID)
+{
+ return AMI_FLAG_DEFAULT;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetControlConditionVarId
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *controlInfo
+//
+// Return value: UINT32
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT32 GetControlConditionVarId(CONTROL_INFO *controlInfo)
+{
+ EFI_IFR_OP_HEADER *ifrPtr;
+ PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]);
+ UINTN control = 0;
+ CONTROL_INFO *CtrlInfo;
+ BOOLEAN found = FALSE;
+ EFI_QUESTION_ID QuestionId;
+ UINT32 varId = 0;
+
+ if ( controlInfo == NULL )
+ return 0;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)controlInfo->ControlConditionalPtr;
+
+ if ( ifrPtr == NULL )
+ return 0;
+
+ if ( ( ifrPtr->OpCode != EFI_IFR_SUPPRESS_IF_OP ) && ( ifrPtr->OpCode != EFI_IFR_GRAY_OUT_IF_OP ) )
+ return 0;
+
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+ // skip NOT if it is present
+ if ( ifrPtr->OpCode == EFI_IFR_NOT_OP )
+ ifrPtr = (EFI_IFR_OP_HEADER *)((UINTN)ifrPtr + ifrPtr->Length);
+
+ if ( ifrPtr->OpCode == EFI_IFR_EQ_ID_LIST_OP )
+ QuestionId = ((EFI_IFR_EQ_ID_LIST *)ifrPtr)->QuestionId;
+ else if ( ifrPtr->OpCode == EFI_IFR_EQ_ID_VAL_OP )
+ QuestionId = ((EFI_IFR_EQ_ID_VAL *)ifrPtr)->QuestionId;
+ else
+ return 0;
+
+ if(pageInfo->PageHandle ==0)
+ return 0;
+
+ for ( control= 0; (control < pageInfo->PageControls.ControlCount) && (found == FALSE); control++ )
+ {
+ CtrlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == CtrlInfo->ControlKey)
+ {
+ varId = CtrlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ if(!found)
+ {
+ // Control Definition not in this Page. Look within the formset
+ EFI_HII_HANDLE pgHandle = controlInfo->ControlHandle;
+ UINT32 page = 0;
+
+ for(;page < gPages->PageCount && (found == FALSE); page++)
+ {
+ if(page == controlInfo->ControlPageID)
+ {
+ continue;
+ }
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[page]);
+ if(pageInfo->PageHandle != pgHandle)
+ {
+ continue;
+ }
+
+ for(control = 0; control < pageInfo->PageControls.ControlCount && (found == FALSE); control++)
+ {
+ controlInfo = (CONTROL_INFO *)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[control]);
+
+ if(QuestionId == controlInfo->ControlKey)
+ {
+ varId = controlInfo->ControlVariable;
+ found = TRUE;
+ }
+ }
+ }
+ }
+
+ if(!found)
+ return 0;
+
+ return varId;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure : ProcessActionQuestionConfiguration
+//
+// Description : Function to process Action Control Configuration String.
+//
+// Input : CONTROL_INFO *control
+//
+// Output : EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS ProcessActionQuestionConfiguration(CONTROL_INFO *control)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_STRING configuration = NULL;
+ EFI_STRING progress = NULL;
+ EFI_IFR_ACTION *UefiAction = NULL;
+ BOOLEAN PreservegEnableDrvNotification = FALSE;
+
+ if((control == NULL) || (control->ControlPtr == NULL)){
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+ UefiAction = (EFI_IFR_ACTION*)control->ControlPtr;
+
+ if(UefiAction->Header.Length == sizeof(EFI_IFR_ACTION))
+ {
+ if(UefiAction->QuestionConfig)
+ {
+ //Process UefiAction QuestionConfig
+ configuration = HiiGetString(control->ControlHandle, UefiAction->QuestionConfig);
+ if((configuration != NULL) && EfiStrLen(configuration))
+ {
+ PreservegEnableDrvNotification = gEnableDrvNotification;
+ gEnableDrvNotification = TRUE; //EIP75588 Set to enable notification processing
+ Status = gHiiConfigRouting->RouteConfig(gHiiConfigRouting, configuration, &progress);
+ if (!PreservegEnableDrvNotification) // If gEnableDrvNotification is already True Don't touch it
+ gEnableDrvNotification = FALSE; //Reset to disable notification processing
+ MemFreePointer(&configuration);
+ }
+ }
+ }
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: ProcessBrowserActionRequest
+//
+// Description:
+//
+// Parameter: EFI_BROWSER_ACTION_REQUEST actionReq
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiVarsetnvramforCurrentform(UINT32 FormID);
+EFI_STATUS UefiLoadPreviousValuesforCurrentform(UINT32 FormID);
+VOID HotclickESCaction(VOID);
+extern BOOLEAN BrowserActionDiscard;
+EFI_STATUS ProcessBrowserActionRequest(EFI_BROWSER_ACTION_REQUEST ActionReq)
+{
+
+ switch(ActionReq)
+ {
+ case EFI_BROWSER_ACTION_REQUEST_RESET:
+ // Do nothing. Reset the system.
+ gApp->Quit = ResetSys();
+ break;
+ case EFI_BROWSER_ACTION_REQUEST_SUBMIT:
+ //Save values here before exiting.
+ gApp->Quit = SaveAndExit();
+ break;
+ case EFI_BROWSER_ACTION_REQUEST_EXIT:
+ //Donot save values. Exit as is.
+ gApp->Quit = ExitApplication();
+ break;
+ //EIP 86885 : START
+ //Changes to support new action request form browser
+ case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT:
+ UefiVarsetnvramforCurrentform (gApp->CurrentPage) ;
+ HotclickESCaction();
+ break;
+ case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT:
+ BrowserActionDiscard = TRUE;
+ UefiLoadPreviousValuesforCurrentform (gApp->CurrentPage);
+ HotclickESCaction();
+ break;
+ case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY:
+ UefiVarsetnvramforCurrentform (gApp->CurrentPage) ;
+ break;
+ case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD:
+ BrowserActionDiscard = TRUE;
+ UefiLoadPreviousValuesforCurrentform (gApp->CurrentPage);
+ break;
+ //EIP 86885 : END
+ default:
+ break;
+ }
+// gProFormOffset = 0; //EIP 86885
+ CleargProcessedForms ();
+// MemSet (gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+
+ return EFI_SUCCESS;
+}
+
+VOID* UefiGetSpecialEqIDIfrPtr(CONTROL_INFO *ControlInfo, UINT32 *Variable, GUID_INFO **GuidInfo)
+{
+ VOID *Conditional = ControlInfo->ControlConditionalPtr;
+ VOID *ControlPtr = ControlInfo->ControlPtr;
+ EFI_IFR_OP_HEADER * OpHeader = (EFI_IFR_OP_HEADER *)Conditional;
+ GUID_INFO *specialGuid = NULL;
+ VARIABLE_INFO *varInfo = NULL;
+ UINT32 i = 0;
+ UINT8 InScope = 0;
+
+ if((OpHeader==NULL) || (ControlPtr <= Conditional))
+ return NULL;
+
+ if ((OpHeader != NULL) &&
+ ((OpHeader->OpCode == EFI_IFR_SUPPRESS_IF_OP) ||
+ (OpHeader->OpCode == EFI_IFR_GRAY_OUT_IF_OP)))
+ {
+ do
+ {
+ if(OpHeader->Scope)
+ {
+ InScope++;
+ }
+ if(OpHeader->OpCode == EFI_IFR_END_OP)
+ {
+ InScope--;
+ if(InScope == 0)
+ {
+ // EFI_IFR_EQ_ID_VAL_OP opcode not found
+ OpHeader = NULL;
+ goto DONE;
+ }
+ }
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)OpHeader + OpHeader->Length);
+ }while((OpHeader->OpCode != EFI_IFR_EQ_ID_VAL_OP) &&
+ (OpHeader->OpCode != EFI_IFR_EQ_ID_LIST_OP));
+ }
+
+ if(NoVarStoreSupport())
+ {
+ if(*Variable == VARIABLE_ID_SETUP)
+ {
+ *Variable = FindVarFromITKQuestionId(UefiGetEqIDQuestionID(OpHeader));
+ }
+ }
+
+ // Retrieve Special Control Information??? Update with proper comment
+ varInfo = VarGetVariableInfoIndex( *Variable );
+ if( varInfo == NULL )
+ {
+ OpHeader = NULL;
+ goto DONE;
+ }
+
+ for ( i = 0; i < gGuidList->GuidCount; i++ )
+ {
+ GUID_INFO *guidInfo = (GUID_INFO *)((UINTN)gGuidList + gGuidList->GuidList[i]);
+ if ( EfiCompareGuid( &varInfo->VariableGuid, &guidInfo->GuidValue ) )
+ {
+ specialGuid = guidInfo;
+ break;
+ }
+ }
+
+ if ( specialGuid != NULL )
+ {
+ if ( GuidInfo != NULL )
+ *GuidInfo = specialGuid;
+ }
+ else
+ {
+ OpHeader = NULL;
+ }
+
+ // See if Other condition is Special condition
+ if(OpHeader == NULL)
+ {
+ if(ControlPtr > Conditional)
+ {
+ UINTN Offset = _SkipExpression(Conditional);
+ if(Offset)
+ {
+ Conditional = (VOID*)((UINTN)Conditional + Offset);
+ if(ControlPtr > Conditional)
+ {
+ CONTROL_INFO TempCtlInfo;
+ MemCopy(&TempCtlInfo, ControlInfo, sizeof (CONTROL_INFO));
+ TempCtlInfo.ControlConditionalPtr = Conditional;
+ *Variable = (UINT16)GetControlConditionVarId(&TempCtlInfo);
+ OpHeader = UefiGetSpecialEqIDIfrPtr(&TempCtlInfo, Variable, GuidInfo) ;
+ }
+ }
+ }
+ }
+
+DONE:
+ return OpHeader;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetSpecialEqIDValue
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetSpecialEqIDValue(CONTROL_INFO *ControlInfo, GUID_INFO **GuidInfo)
+{
+ UINT16 value = (UINT16)-2;
+ UINT32 condVarID = 0;
+ EFI_IFR_OP_HEADER *ifrPtr = NULL;
+
+ condVarID = (UINT32)GetControlConditionVarId(ControlInfo);
+ ifrPtr = (EFI_IFR_OP_HEADER *)UefiGetSpecialEqIDIfrPtr(ControlInfo, &condVarID, GuidInfo);
+
+ if(ifrPtr != NULL)
+ {
+ switch(ifrPtr->OpCode)
+ {
+ case EFI_IFR_EQ_ID_LIST_OP:
+ value = ((EFI_IFR_EQ_ID_LIST *)ifrPtr)->ValueList[0];
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ value = ((EFI_IFR_EQ_ID_VAL *)ifrPtr)->Value;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return value;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetEqIDValue
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr, UINT16 Value
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetEqIDValue(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_EQ_ID_LIST_OP:
+ ((EFI_IFR_EQ_ID_LIST *)IfrPtr)->ValueList[0] = Value;
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP:
+ ((EFI_IFR_EQ_ID_VAL *)IfrPtr)->Value = Value;
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiIsOneOfControl
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN UefiIsOneOfControl(VOID *IfrPtr)
+{
+ return (((EFI_IFR_OP_HEADER *)IfrPtr)->OpCode == EFI_IFR_ONE_OF_OP)? TRUE : FALSE;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiUpdateControlVarOffset
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr, UINT16 Value
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiUpdateControlVarOffset(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF *)opHeader)->Question.VarStoreInfo.VarOffset = Value;
+ break;
+ default:
+ break;
+ }
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateOneOfWithOptionsTemplate
+//
+// Description:
+//
+// Parameter: UINTN OptionCount, CONTROL_INFO *CtrlInfo
+//
+// Return value: VOID*
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID* UefiCreateOneOfWithOptionsTemplate(UINTN OptionCount, CONTROL_INFO *CtrlInfo)
+{
+ VOID *buffer = NULL;
+ UINTN size = 0;
+ UINTN length = 0;
+ UINTN offset;
+
+ offset = (UINTN)CtrlInfo->ControlPtr - (UINTN)CtrlInfo->ControlConditionalPtr;
+
+ size = offset + sizeof(EFI_IFR_ONE_OF) + sizeof(EFI_IFR_OP_HEADER) +
+ OptionCount * sizeof(EFI_IFR_ONE_OF_OPTION);
+ buffer = EfiLibAllocateZeroPool(size);
+ if(buffer == NULL)
+ {
+ goto DONE;
+ }
+ MemCopy(buffer, CtrlInfo->ControlConditionalPtr, offset);
+
+ length = UefiGetIfrLength(CtrlInfo->ControlPtr);
+ CtrlInfo->ControlConditionalPtr = buffer;
+ MemCopy( (UINT8 *)buffer + offset, CtrlInfo->ControlPtr, length );
+ CtrlInfo->ControlPtr = (UINT8 *)buffer + offset;
+
+DONE:
+ return (UINT8 *)buffer + offset;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetOneOfOption
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetOneOfOption(VOID *IfrPtr, UINT64 Value, UINT32 Size, UINT8 Flag, UINT16 Option)
+{
+ EFI_IFR_ONE_OF_OPTION *option = (EFI_IFR_ONE_OF_OPTION *)IfrPtr;
+ UINT8 flag = 0;
+
+ flag |= ((Flag & AMI_FLAG_DEFAULT) == AMI_FLAG_DEFAULT)? EFI_IFR_OPTION_DEFAULT : 0;
+ flag |= ((Flag & AMI_FLAG_MANUFACTURING) == AMI_FLAG_MANUFACTURING)? EFI_IFR_OPTION_DEFAULT_MFG : 0;
+
+ switch(Size)
+ {
+ case sizeof(UINT8):
+ flag |= EFI_IFR_TYPE_NUM_SIZE_8;
+ option->Value.u8 = (UINT8)Value;
+ break;
+ case sizeof(UINT16):
+ flag |= EFI_IFR_TYPE_NUM_SIZE_16;
+ option->Value.u16 = (UINT16)Value;
+ break;
+ case sizeof(UINT32):
+ flag |= EFI_IFR_TYPE_NUM_SIZE_32;
+ option->Value.u32 = (UINT32)Value;
+ break;
+ case sizeof(UINT64):
+ flag |= EFI_IFR_TYPE_NUM_SIZE_64;
+ option->Value.u64 = (UINT64)Value;
+ break;
+ default:
+ break;
+ }
+
+ option->Flags = flag;
+ option->Option = Option;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiAddEndOp
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiAddEndOp(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ opHeader->OpCode = EFI_IFR_END_OP;
+ opHeader->Length = sizeof(EFI_IFR_OP_HEADER);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetQuestionID
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *Control
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetQuestionID(CONTROL_INFO *Control)
+{
+ return 0; //(UINT16)GetControlConditionVarId(Control);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiCreateDynamicControlCondition
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiCreateDynamicControlCondition(CONTROL_INFO *control,UINT16 VarId, UINT16 PrevControlQuestionID,UINT16 Value)
+{
+ //Add condition here for boot and bbs special controls
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetEqIDQuestionID
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetEqIDQuestionID(VOID *IfrPtr)
+{
+ UINT16 questionID = 0;
+
+ return questionID;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetEqIDQuestionID
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr, UINT16 Value
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetEqIDQuestionID(VOID *IfrPtr, UINT16 Value)
+{
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiUpdateControlQuestionID
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr, UINT16 Value
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiUpdateControlQuestionID(VOID *IfrPtr, UINT16 Value)
+{
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)IfrPtr;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_ONE_OF_OP:
+ ((EFI_IFR_ONE_OF *)opHeader)->Question.QuestionId = Value;
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSpecialGuidCallback
+//
+// Description:
+//
+// Parameter: VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSpecialGuidCallback(VOID * HiiHandle, UINT16 Key, EFI_GUID *pGUID)
+{
+ EFI_HANDLE DriverHandle;
+ EFI_GUID EfiHiiConfigAccessProtocolGuid = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
+ EFI_IFR_TYPE_VALUE Value;
+ EFI_BROWSER_ACTION_REQUEST ActionReq;
+ EFI_STATUS Status;
+ BOOLEAN PreservegEnableDrvNotification = FALSE;
+
+ Status = gHiiDatabase->GetPackageListHandle(gHiiDatabase,HiiHandle,&DriverHandle);
+ if(!EFI_ERROR(Status))
+ {
+ Status = gBS->HandleProtocol( DriverHandle, &EfiHiiConfigAccessProtocolGuid , &ConfigAccess );
+ if(!EFI_ERROR(Status))
+ {
+ EFI_BROWSER_ACTION action = EFI_BROWSER_ACTION_CHANGED;
+
+ MemSet( &Value, sizeof(Value), 0 );
+ Value.u64 = (UINTN)pGUID;
+ PreservegEnableDrvNotification = gEnableDrvNotification;
+ gEnableDrvNotification = TRUE; //EIP75588 Set to enable notification processing
+ Status = ConfigAccess->Callback(ConfigAccess, action,Key,((sizeof(VOID*)==sizeof(UINT32))?EFI_IFR_TYPE_NUM_SIZE_32:EFI_IFR_TYPE_NUM_SIZE_64),&Value,&ActionReq);
+ if (!PreservegEnableDrvNotification) // If gEnableDrvNotification is already True Don't touch it
+ gEnableDrvNotification = FALSE; //Reset to disable notification processing
+ // Clean up PAGE_INFO struct with Handle set to 0xFFFF
+ Status = FixSetupData();
+ if(EFI_ERROR(Status))
+ {
+ }
+ }
+ }
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetWidth
+//
+// Description:
+//
+// Parameter: VOID *IfrPtr,UINT8 Width
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID UefiSetWidth(VOID *IfrPtr,UINT8 Width)
+{
+ EFI_IFR_OP_HEADER *OpHeader = (EFI_IFR_OP_HEADER*)IfrPtr;
+
+ switch(OpHeader->OpCode)
+ {
+ case EFI_IFR_NUMERIC_OP:
+ break;
+ case EFI_IFR_PASSWORD_OP:
+ break;
+ case EFI_IFR_STRING_OP:
+ break;
+ case EFI_IFR_ONE_OF_OP:
+ break;
+ case EFI_IFR_CHECKBOX_OP:
+ break;
+ default:
+ break;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BBSUpdateControlOffset
+//
+// Description:
+//
+// Parameter: CONTROL_INFO *control
+//
+// Return value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID BBSUpdateControlOffset(CONTROL_INFO *control)
+{
+ UINT16 offset= ((EFI_IFR_ONE_OF*)control->ControlPtr)->Question.VarStoreInfo.VarOffset;
+
+ offset = offset +sizeof(UINT32)+sizeof(UINT16);
+ offset = (UINT16)(offset + gCurrLegacyBootData->LegacyEntryOffset);
+
+ UefiUpdateControlVarOffset(control->ControlPtr, offset);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetControlDataLength
+//
+// Description: This function will return width of questions
+//
+// Parameter: CONTROL_INFO *
+//
+// Return value: UINTN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN GetControlDataLength(CONTROL_INFO *controlInfo)
+{
+ UINTN width = 0;
+
+ switch(controlInfo->ControlType)
+ {
+ case CONTROL_TYPE_CHECKBOX:
+ case CONTROL_TYPE_POPUPSEL:
+ case CONTROL_TYPE_NUMERIC:
+ case CONTROL_TYPE_PASSWORD:
+ case CONTROL_TYPE_POPUP_STRING:
+ width = UefiGetWidth(controlInfo->ControlPtr);
+ break;
+ case CONTROL_TYPE_ORDERED_LIST:
+ width = (((EFI_IFR_ORDERED_LIST*)(controlInfo->ControlPtr))->MaxContainers);
+ break;
+ case CONTROL_TYPE_TEXT:
+ width = sizeof(UINT16);
+ break;
+ case CONTROL_TYPE_DATE:
+ width = sizeof(EFI_HII_DATE);
+ break;
+ case CONTROL_TYPE_TIME:
+ width = sizeof(EFI_HII_TIME);
+ break;
+ default:
+ break;
+ }
+ return width;
+}
+
+
+//EIP 23354 : Start
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsPasswordEncodeEnabled
+//
+// Description: Function to return Password Encoding Status.
+//
+// Input: CONTROL_INFO
+//
+// Output: TRUE/FALSE
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsPasswordEncodeEnabled (CONTROL_INFO *controlInfo)
+{
+//EIP106950 : Starts
+ extern PASSWORD_ENOCDE_LIST_TEMPLATE gPasswordEncodeList [];
+ extern UINT32 gEncodeListCount;
+ UINT32 iIndex = 0;
+ EFI_GUID tFormsetGuid;
+
+ //Get page info
+// PAGE_INFO *pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[controlInfo->ControlPageID]);
+
+ //Get FormsetGuid
+ GetPageGuidFromPgIndex (controlInfo->ControlPageID, &tFormsetGuid);
+
+ for (iIndex = 0; iIndex < gEncodeListCount; iIndex ++)
+ {
+ //If given QuestionId and FormsetGuid is same then return Encoding Flag
+ if ( (gPasswordEncodeList [iIndex].QuestionID == ((EFI_IFR_PASSWORD *)controlInfo->ControlPtr)->Question.QuestionId) &&
+ (EfiCompareGuid(&gPasswordEncodeList [iIndex].FormsetGuid, &tFormsetGuid) )
+ )
+ {
+ return gPasswordEncodeList [iIndex].EncodingFlag;
+ }
+ }
+//EIP106950 : Ends
+
+ // IDE Password Encode the password
+ if (
+ (VARIABLE_ID_IDE_SECURITY == controlInfo->ControlVariable) ||
+ (VARIABLE_ID_AMITSESETUP == controlInfo->ControlVariable)
+ )
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//EIP 23354 : End
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetTime
+//
+// Description: Function to get time
+//
+// Parameter: CONTROL_INFO *control, EFI_TIME *Tm
+//
+// Return value: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiGetTime(CONTROL_INFO *control, EFI_TIME *Tm)
+{
+ VOID *IfrPtr = NULL ;
+ UINT8 Flags ;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ if((control != NULL) && (control->ControlPtr != NULL))
+ {
+ IfrPtr = control->ControlPtr;
+ Flags = UefiGetFlagsField(IfrPtr) ;
+
+
+ if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_TIME)||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_TIME) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+ Status = gRT->GetTime( Tm, NULL );
+ }
+ else if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) ||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+
+ if(control->ControlType == CONTROL_TYPE_DATE)
+ {
+ EFI_HII_DATE *date = NULL ;
+
+ date = EfiLibAllocateZeroPool( sizeof(EFI_HII_DATE) );
+
+ if ( date != NULL )
+ {
+ Status = VarGetValue( control->ControlVariable, UefiGetQuestionOffset(IfrPtr), UefiGetWidth(IfrPtr), date );
+ if ( ! EFI_ERROR( Status ) )
+ {
+ Tm->Month = date->Month ;
+ Tm->Day = date->Day ;
+ Tm->Year = date->Year ;
+ }
+
+ MemFreePointer( (VOID **)&date );
+ }
+ }else{
+ EFI_HII_TIME *time = NULL ;
+
+ time = EfiLibAllocateZeroPool( sizeof(EFI_HII_TIME) );
+
+ if ( time != NULL )
+ {
+ Status = VarGetValue( control->ControlVariable, UefiGetQuestionOffset(IfrPtr), UefiGetWidth(IfrPtr), time );
+ Tm->Hour = time->Hour ;
+ Tm->Minute = time->Minute ;
+ Tm->Second = time->Second ;
+
+ MemFreePointer( (VOID **)&time );
+ }
+ }
+ }
+ else if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_WAKEUP) ||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_WAKEUP) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+
+ BOOLEAN Enabled;
+ BOOLEAN Pending;
+ Status = gRT->GetWakeupTime( &Enabled, &Pending, Tm );
+ }
+ }
+ else
+ Status = gRT->GetTime( Tm, NULL );
+
+ return Status ;
+
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiSetTime
+//
+// Description: Function to set time
+//
+// Parameter: CONTROL_INFO *control, EFI_TIME *Tm
+//
+// Return value: STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiSetTime(CONTROL_INFO *control, EFI_TIME *Tm)
+{
+ VOID *IfrPtr = NULL ;
+ UINT8 Flags = 0;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+
+
+ if((control != NULL) && (control->ControlPtr != NULL))
+ {
+ IfrPtr = control->ControlPtr;
+ Flags = UefiGetFlagsField(IfrPtr) ;
+
+ if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_TIME)||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_TIME) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+ Status = gRT->SetTime( Tm );
+ }
+ else if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) ||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+ if(control->ControlType == CONTROL_TYPE_DATE)
+ {
+ EFI_HII_DATE *date = NULL ;
+ EFI_TIME Tc ;
+
+ date = EfiLibAllocateZeroPool( sizeof(EFI_HII_DATE) );
+
+ if ( date != NULL )
+ {
+//EIP 47037 : Start
+ UefiGetTime(control, &Tc);
+ date->Month = (Tm->Month <= 12)?Tm->Month : ((Tc.Month>12)? 1:Tc.Month) ;
+ date->Day = (Tm->Day <= 31)?Tm->Day : ((Tc.Day>31)? 1:Tc.Day) ;
+ date->Year = Tm->Year ;
+//EIP 47037 : End
+ Status = VarSetValue( control->ControlVariable, UefiGetQuestionOffset(IfrPtr), UefiGetWidth(IfrPtr), date );
+
+ MemFreePointer( (VOID **)&date );
+ }
+
+ }else{
+ EFI_HII_TIME *time = NULL ;
+ EFI_TIME Tc ;
+
+ time = EfiLibAllocateZeroPool( sizeof(EFI_HII_TIME) );
+
+ if ( time != NULL )
+ {
+//EIP 47037 : Start
+ UefiGetTime(control, &Tc);
+ time->Hour = (Tm->Hour <= 23)?Tm->Hour : ((Tc.Hour>23)? 0:Tc.Hour) ;
+ time->Minute = (Tm->Minute <= 59)? Tm->Minute : ((Tc.Minute>59)? 0:Tc.Minute) ;
+ time->Second = (Tm->Second <= 59)?Tm->Second : ((Tc.Second>59)? 0:Tc.Second);
+//EIP 47037 : End
+ Status = VarSetValue( control->ControlVariable, UefiGetQuestionOffset(IfrPtr), UefiGetWidth(IfrPtr), time );
+ MemFreePointer( (VOID **)&time );
+ }
+ }
+ }
+ else if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_WAKEUP) ||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_WAKEUP) )// EIP 77875 : Incorrect logic used to check Time and Date control types
+ {
+ BOOLEAN Enabled = TRUE ;
+ Status = gRT->SetWakeupTime( Enabled, Tm );
+ }
+ }
+ else
+ Status = gRT->SetTime( Tm );
+
+
+ return Status ;
+
+}
+//EIP: 55762 Start
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: UpdateDestiantionQuestion
+//
+// Description: Finds the destination question ID for the current destination
+//
+// Input: UINT32 CurrPageID - Current page ID
+// UINT32 DestQuestionId - Destination question ID to set focus
+// UINT32 *FocusControlIndex -
+//
+// Output: EFI_STATUS status - EFI_SUCCESS is successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UpdateDestiantionQuestion(UINT32 CurrPageID, UINT32 DestQuestionId, UINT32 *FocusControlIndex)
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+ UINT32 j = 0;
+
+ PAGE_INFO *PageInfo = (PAGE_INFO*)((UINTN)gApplicationData + gPages->PageList[CurrPageID]);
+
+ for ( j = 0; j < PageInfo->PageControls.ControlCount; j++ )
+ {
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO*)(((UINTN)gControlInfo) + PageInfo->PageControls.ControlList [j /*PageInfo->PageIdIndex */]);
+ if(!ctrlInfo){
+ continue;
+ }
+
+
+ if(UefiGetKeyField(ctrlInfo->ControlPtr) == DestQuestionId){
+ *FocusControlIndex = j;
+ status = EFI_SUCCESS;
+ goto DONE;
+ }
+ }
+
+DONE:
+ return status;
+}
+//EIP: 55762 End
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiRefershQuestionValueNvRAM
+//
+// Description: Function to Refresh the questions
+//
+// Parameter: CONTROL_INFO *ControlData
+//
+// Return value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiRefershQuestionValueNvRAM(CONTROL_INFO *ControlData)
+{
+
+
+ UINT8 * CurBuf=NULL;
+ UINT8 * NvBuf = NULL;
+ UINTN VarSize=0;
+ EFI_STATUS Status=EFI_UNSUPPORTED;
+ UINT8 Flags = 0;
+ UINTN offset = UefiGetQuestionOffset(ControlData->ControlPtr);
+//EIP-105552 Starts
+ UINT16 Size = 0;// = UefiGetWidth(ControlData->ControlPtr);
+ //If the control is Ordered list then we are calculating the actual size
+ if( CONTROL_TYPE_ORDERED_LIST != ControlData->ControlType)
+ {
+ Size = UefiGetWidth(ControlData->ControlPtr);
+ VarSize = GetControlDataLength(ControlData);
+ }
+ else
+ {
+ UINTN Type=0;
+ UINT16 OptionCount = 0;
+ UINT16 *OptionList=NULL;
+ UINT64 *ValueList=NULL;
+
+ UefiGetOneOfOptions(ControlData,&ControlData->ControlHandle,&OptionList, &ValueList, &OptionCount,NULL,NULL);
+ if (OptionList)
+ MemFreePointer( (VOID **)&(OptionList));
+ if (ValueList)
+ MemFreePointer( (VOID **)&(ValueList));
+
+ UefiGetValidOptionType( ControlData, &Type, (UINT32 *)&Size);
+ Size = OptionCount * Size;
+ VarSize = Size;
+
+ }
+//EIP-105552 Ends
+ NvBuf = VarGetNvramQuestionValue(ControlData->ControlVariable, offset, VarSize); //Read value for specific question
+ if(NvBuf == NULL){ // No Variable Assosiated then Just refrsh the page
+ return EFI_SUCCESS;
+ }
+
+ if((UINTN)(Size) > VarSize){
+ goto DONE;
+ }
+
+ CurBuf = EfiLibAllocateZeroPool(Size);
+
+ switch(ControlData->ControlType)
+ {
+
+ case CONTROL_TYPE_NUMERIC:
+ case CONTROL_TYPE_ORDERED_LIST:
+ case CONTROL_TYPE_POPUPSEL:
+ case CONTROL_TYPE_POPUP_STRING:
+ case CONTROL_TYPE_CHECKBOX:
+ case CONTROL_TYPE_PASSWORD:
+ VarGetValue( ControlData->ControlVariable,
+ UefiGetQuestionOffset(ControlData->ControlPtr), Size, CurBuf );
+ break;
+ case CONTROL_TYPE_DATE:
+ case CONTROL_TYPE_TIME:
+ Flags = UefiGetFlagsField(ControlData->ControlPtr) ;
+ if( ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) ||
+ ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) )
+ {
+ VarGetValue( ControlData->ControlVariable,
+ UefiGetQuestionOffset(ControlData->ControlPtr), Size, CurBuf );
+ }
+ else
+ {
+ // RTC/Wakeup Date/Timecontrol
+ Status = EFI_SUCCESS;
+ goto DONE;
+ }
+ break;
+ default:
+ goto DONE;
+ }
+ if(MemCmp((UINT8 *)NvBuf, (UINT8 *)CurBuf, Size))
+ {
+ _VarGetSetValue (VAR_COMMAND_SET_VALUE, gVariableList, ControlData->ControlVariable, UefiGetQuestionOffset (ControlData->ControlPtr), Size, NvBuf);
+ }
+ else
+ {
+ if(UefiIsInteractive(ControlData))
+ Status = CallFormCallBack(ControlData,UefiGetControlKey(ControlData),0,EFI_BROWSER_ACTION_RETRIEVE);
+ }
+
+ Status = EFI_SUCCESS;
+DONE:
+
+ MemFreePointer((VOID**)&CurBuf);
+ MemFreePointer((VOID**)&NvBuf);
+ return Status;
+}
+//EIP:56413: START
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiGetResetButtonDefaultid
+//
+// Description: Funtion get the ResetButton Default Id from the Opcode information
+//
+// Parameter: VOID *IfrPtr
+//
+// Return value: UINT16
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 UefiGetResetButtonDefaultid(VOID *IfrPtr)
+{
+ EFI_IFR_OP_HEADER *OpHeader=(EFI_IFR_OP_HEADER *)IfrPtr;
+ UINT16 DefaultId = 0xFFFF;//Initializing the default to handle error case
+
+ if(OpHeader->OpCode == EFI_IFR_RESET_BUTTON_OP )
+ {
+ DefaultId = ((EFI_IFR_RESET_BUTTON *)OpHeader)->DefaultId;
+ return DefaultId;
+ }
+return DefaultId;
+}
+//EIP:56413: END
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FindDriverHealthDriverName
+//
+// Description: Finds the driver name which supports driver health protocol
+//
+// Input: UINT16 = Entry for which driver name has to be return
+//
+// Output: CHAR16 * = Driver Name
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *FindDriverHealthDriverName (UINT16 DriverEntry)
+{
+ EFI_STATUS Status, StatusforGetHealth = EFI_UNSUPPORTED;
+// EFI_GUID DriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID;
+ EFI_HANDLE *DriverHealthHandles;
+ UINTN NumHandles = 0, iIndex = 0;
+ UINTN Count = 0;
+ CHAR16 *DriverName = NULL, *DrvNameWithStatus;
+ EFI_GUID EfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 = NULL;
+ EFI_DRIVER_HEALTH_PROTOCOL *DrvHealthInstance = NULL;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DRIVER_HEALTH_STATUS HealthStatus = EfiDriverHealthStatusHealthy;
+ EFI_GUID EfiDriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID;
+
+ CHAR8 *LangStrings = (CHAR8 *)NULL;
+ CHAR8 *tempLangStrings = (CHAR8 *)NULL;
+ CHAR8 Lang[200];
+
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &EfiDriverHealthProtocolGuid,
+ NULL,
+ &NumHandles,
+ &DriverHealthHandles
+ );
+ if ((Status != EFI_SUCCESS) || (NumHandles == 0))
+ {
+ return NULL;
+ }
+ for (iIndex = 0; iIndex < NumHandles; iIndex ++)
+ {
+ Status = gBS->HandleProtocol (DriverHealthHandles [iIndex], &EfiDriverHealthProtocolGuid, &DrvHealthInstance);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ if (Count != DriverEntry)
+ {
+ Count ++;
+ continue;
+ }
+ StatusforGetHealth = DrvHealthInstance->GetHealthStatus (DrvHealthInstance, NULL, NULL, &HealthStatus, NULL, NULL);
+ Status = gBS->HandleProtocol (DriverHealthHandles [iIndex], &EfiComponentName2ProtocolGuid, &ComponentName2);
+ if (EFI_ERROR (Status))
+ {
+ break;
+ }
+ //EIP 134138
+ LangStrings = StrDup8( ComponentName2->SupportedLanguages );
+ tempLangStrings = LangStrings; //Ptr will be incremented in _GetNextLanguage so taking backup for freeing
+ _GetNextLanguage (&LangStrings, Lang);
+
+ Status = ComponentName2->GetDriverName (
+ ComponentName2,
+ Lang,
+ //ComponentName2->SupportedLanguages,
+ &DriverName
+ );
+
+ MemFreePointer( (VOID **)&tempLangStrings );
+
+ if ((EFI_ERROR (Status)) || (NULL == DriverName))
+ {
+ break;
+ }
+ if (!EFI_ERROR (StatusforGetHealth))
+ {
+ DrvNameWithStatus = EfiLibAllocateZeroPool ((EfiStrLen (DriverName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)); //7 for spaces and NULL character
+ if (NULL != DrvNameWithStatus)
+ {
+ SPrint (
+ DrvNameWithStatus,
+ ((EfiStrLen (DriverName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)),
+ L"%s %s",
+ DriverName,
+ DriverHealthStatus [HealthStatus]
+ );
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ return DrvNameWithStatus;
+ }
+ }
+ goto DONE;
+ }
+ if (iIndex == NumHandles)
+ {
+ goto DONE;
+ }
+ if (!DriverName)
+ {
+ Status = gBS->HandleProtocol (DriverHealthHandles [iIndex], &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath);
+ if (!EFI_ERROR (Status))
+ {
+ DriverName = _DevicePathToStr (DevicePath);
+ if (!EFI_ERROR (StatusforGetHealth))
+ {
+ DrvNameWithStatus = EfiLibAllocateZeroPool ((EfiStrLen (DriverName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)); //7 for spaces and NULL character
+ if (NULL != DrvNameWithStatus)
+ {
+ SPrint (
+ DrvNameWithStatus,
+ ((EfiStrLen (DriverName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)),
+ L"%s %s",
+ DriverName,
+ DriverHealthStatus [HealthStatus]
+ );
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ return DrvNameWithStatus;
+ }
+ }
+ }
+ else
+ {
+ DriverName = EfiLibAllocateZeroPool (30 * sizeof (CHAR16)); //This case will be helpfull when driver name or device path not present
+ SPrint (
+ DriverName,
+ (30 * sizeof (CHAR16)),
+ L"Driver At Handle %x",
+ DriverHealthHandles [iIndex]
+ );
+ }
+ }
+DONE:
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ return DriverName;
+}
+
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------------------
+// Procedure: CtrlsSupportsHealthProtocol
+//
+// Description: Finds the number of controllers supports driver health protocol for the driver entry
+//
+// Input: UINT16 = Entry for driver to which total controllers has to be find
+//
+// Output: UINT16 = Total number of controllers supports driver health
+//
+//-----------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 CtrlsSupportsHealthProtocol (UINT16 EntryItem)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN NumHandles = 0;
+ UINT16 ControllerCnt = 0, Count = 0;
+ EFI_HANDLE *DriverHealthHandles;
+ UINTN DriverHealthIndex;
+ UINTN ControllerIndex = 0;
+ UINTN HandleCount = 0;
+ UINTN ChildIndex = 0;
+ EFI_DRIVER_HEALTH_PROTOCOL *DriverHealth;
+ EFI_DRIVER_HEALTH_STATUS HealthStatus;
+ EFI_GUID EfiDriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &EfiDriverHealthProtocolGuid,
+ NULL,
+ &NumHandles,
+ &DriverHealthHandles
+ );
+ if ((EFI_ERROR (Status)) || (NumHandles == 0))
+ {
+ return ControllerCnt;
+ }
+ for (DriverHealthIndex = 0; DriverHealthIndex < NumHandles; DriverHealthIndex++)
+ {
+ if (DriverHealthHandles [DriverHealthIndex] == NULL)
+ {
+ continue;
+ }
+ Status = gBS->HandleProtocol (
+ DriverHealthHandles [DriverHealthIndex],
+ &EfiDriverHealthProtocolGuid,
+ (VOID **)&DriverHealth
+ );
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ if (EntryItem > Count)
+ {
+ Count ++;
+ continue;
+ }
+ gDrvHandle = DriverHealthHandles [DriverHealthIndex];
+ gDrvHealthInstance = DriverHealth;
+ Status = gBS->LocateHandleBuffer (
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status))
+ {
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ return ControllerCnt;
+ }
+ for (ControllerIndex = 0; ControllerIndex < HandleCount; ControllerIndex ++)
+ {
+ if (NULL == Handles [ControllerIndex])
+ {
+ continue;
+ }
+ Status = DriverHealth->GetHealthStatus (DriverHealth, Handles [ControllerIndex], NULL, &HealthStatus, NULL, NULL);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ AddHandleIntoList (Handles [ControllerIndex], NULL, HealthStatus);
+ ControllerCnt ++;
+ for (ChildIndex = 0; ChildIndex < HandleCount; ChildIndex++)
+ {
+ if (Handles [ChildIndex] == NULL)
+ {
+ continue;
+ }
+ Status = DriverHealth->GetHealthStatus (DriverHealth, Handles [ControllerIndex], Handles [ChildIndex], &HealthStatus, NULL, NULL);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ AddHandleIntoList (Handles [ControllerIndex], Handles [ChildIndex], HealthStatus);
+ ControllerCnt ++;
+ }
+ }
+ break;
+ }
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ return ControllerCnt;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------
+// Procedure: GetCtrlNameAndHealth
+//
+// Description: Finds the controller name with its health
+//
+// Input: UINT16 = Entry for controller to which name has to be find
+//
+// Output: CHAR16 * = Controller name with its health status
+//
+//-----------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetCtrlNameAndHealth (UINT16 ControllerEntry)
+{
+ UINT16 Count = 0;
+ CHAR16 *ContrNameAndHlth = NULL;
+ DRV_HEALTH_HNDLS *DrvHlthHandles = NULL;
+
+
+ DrvHlthHandles = gDrvHealthHandlesHead;
+ while (Count != ControllerEntry)
+ {
+ DrvHlthHandles = DrvHlthHandles->Next;
+ Count ++;
+ }
+ ContrNameAndHlth = GetDrvHlthCtrlName (DrvHlthHandles);
+ return ContrNameAndHlth;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------
+// Procedure: GetDrvHlthCtrlName
+//
+// Description: Finds the controller name
+//
+// Input: DRV_HEALTH_HNDLS * = Details for finding the controller name
+//
+// Output: CHAR16 * = Controller name for the controller and child handle
+//
+//-----------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+CHAR16 *GetDrvHlthCtrlName (DRV_HEALTH_HNDLS *DrvHlthHandles)// EFI_HANDLE DriverHealth, EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CHAR16 *CtrlName = NULL;
+ CHAR16 *ContrNameAndHlth = NULL;
+ EFI_GUID EfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 = NULL;
+ EFI_DRIVER_HEALTH_STATUS HealthStatus = EfiDriverHealthStatusHealthy; //EIP 134138
+
+ Status = gDrvHealthInstance->GetHealthStatus ( //If controllers reconnected status might change so getting the status again
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ &HealthStatus,
+ NULL,
+ NULL
+ );
+ if (EFI_ERROR (Status))
+ {
+ return NULL;
+ }
+ DrvHlthHandles->HealthStatus = HealthStatus;
+ Status = gBS->HandleProtocol (
+ gDrvHandle,
+ &EfiComponentName2ProtocolGuid,
+ (VOID **)&ComponentName2
+ );
+ if (!EFI_ERROR (Status))
+ {
+ Status = ComponentName2->GetControllerName (ComponentName2, DrvHlthHandles->ControllerHandle, DrvHlthHandles->ChildHandle, ComponentName2->SupportedLanguages, &CtrlName);
+ if (EFI_ERROR (Status))
+ {
+ CtrlName = NULL;
+ }
+ }
+ if (NULL == CtrlName)
+ {
+ CtrlName = EfiLibAllocateZeroPool (50 * sizeof (CHAR16)); //16+16+"DriverName"
+ if (NULL == CtrlName)
+ {
+ return NULL;
+ }
+ SPrint (CtrlName, 50 * sizeof (CHAR16), L"Controller %x Child %x", DrvHlthHandles->ControllerHandle, DrvHlthHandles->ChildHandle);
+ }
+ ContrNameAndHlth = EfiLibAllocateZeroPool ((EfiStrLen (CtrlName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)); //7 for spaces and NULL char.
+ if (NULL == ContrNameAndHlth)
+ {
+ return NULL;
+ }
+ SPrint (
+ ContrNameAndHlth,
+ ((EfiStrLen (CtrlName) + EfiStrLen (DriverHealthStatus [HealthStatus]) + 7) * sizeof (CHAR16)),
+ L"%s %s",
+ CtrlName,
+ DriverHealthStatus [HealthStatus]
+ );
+ return ContrNameAndHlth;
+}
+
+//<AMI_PHDR_START>
+//-----------------------------------------------------------------------------------------------------
+// Procedure: AddHandleIntoList
+//
+// Description: Adds the driver health details to the linked list
+//
+// Input: EFI_HANDLE = Controller handle
+// EFI_HANDLE = Child handle
+// EFI_DRIVER_HEALTH_STATUS = Health status corresponding to controller and child handle
+//
+// Output: VOID
+//
+//------------------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID AddHandleIntoList (EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle, EFI_DRIVER_HEALTH_STATUS HealthStatus)
+{
+ DRV_HEALTH_HNDLS *DrvHealthHandles;
+ DRV_HEALTH_HNDLS *tempHealthHandle;
+
+ DrvHealthHandles = EfiLibAllocateZeroPool (sizeof (DRV_HEALTH_HNDLS));
+ if (NULL == DrvHealthHandles)
+ {
+ return;
+ }
+ DrvHealthHandles->ControllerHandle = ControllerHandle;
+ DrvHealthHandles->ChildHandle = ChildHandle;
+ DrvHealthHandles->HealthStatus = HealthStatus;
+ DrvHealthHandles->Next = NULL;
+ if (NULL == gDrvHealthHandlesHead)
+ {
+ gDrvHealthHandlesHead = DrvHealthHandles;
+ return;
+ }
+ tempHealthHandle = gDrvHealthHandlesHead;
+ while (tempHealthHandle->Next)
+ {
+ tempHealthHandle = tempHealthHandle->Next;
+ }
+ tempHealthHandle->Next = DrvHealthHandles;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------------
+// Procedure: FreeControllersList
+//
+// Description: Frees the driver health details linked list
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//-----------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FreeControllersList (VOID)
+{
+ DRV_HEALTH_HNDLS *DrvHealthHandles, *tempDrvHealthHandles;
+
+ if (!gDrvHealthHandlesHead)
+ {
+ return;
+ }
+ DrvHealthHandles = gDrvHealthHandlesHead;
+ while (DrvHealthHandles)
+ {
+ tempDrvHealthHandles = DrvHealthHandles;
+ DrvHealthHandles = DrvHealthHandles->Next;
+ MemFreePointer ((VOID **)&tempDrvHealthHandles);
+ }
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: SetDrvHealthHandleAndCtrlCount
+//
+// Description: Finds and sets the number of controllers supports the driver health handle
+//
+// Input: UINT16 = Driver health handle entry
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetDrvHealthHandleAndCtrlCount (UINT16 ItemEntry)
+{
+ UINTN TotControllers = 0;
+ EFI_GUID DrvHealthCtrlGuid = AMITSE_DRIVER_HEALTH_CTRL_GUID;
+
+ FreeControllersList ();
+ gDrvHealthHandlesHead = NULL;
+
+ TotControllers = CtrlsSupportsHealthProtocol (ItemEntry);
+ VarSetNvramName (L"DrvHealthCtrlCnt", &DrvHealthCtrlGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &TotControllers, sizeof (UINTN));
+}
+
+//EIP57661 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: SetDriverHealthCount
+//
+// Description: Sets the DriverHealthCount and DriverHlthEnable variables
+//
+// Input: VOID
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID SetDriverHealthCount (VOID)
+{
+ EFI_STATUS Status;
+ EFI_GUID DriverHealthProtocolGuid = EFI_DRIVER_HEALTH_PROTOCOL_GUID;
+ EFI_HANDLE *DriverHealthHandles = NULL;
+ UINTN NumHandles = 0, iIndex = 0, HealthCount = 0;
+ EFI_GUID DrvHealthGuid = AMITSE_DRIVER_HEALTH_GUID;
+ EFI_GUID DrvHlthEnableGuid = AMITSE_DRIVER_HEALTH_ENB_GUID;
+ EFI_DRIVER_HEALTH_PROTOCOL *DrvHealthInstance = NULL;
+
+ SETUP_DEBUG_UEFI ( "\n[TSE] Entering SetDriverHealthCount()\n" );
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &DriverHealthProtocolGuid,
+ NULL,
+ &NumHandles,
+ &DriverHealthHandles
+ );
+ if (EFI_SUCCESS != Status)
+ {
+ NumHandles = 0;
+ }
+ for (iIndex = 0; iIndex < NumHandles; iIndex ++)
+ {
+ Status = gBS->HandleProtocol (DriverHealthHandles [iIndex], &DriverHealthProtocolGuid, &DrvHealthInstance);
+ if (EFI_ERROR (Status))
+ {
+ continue;
+ }
+ HealthCount ++;
+ }
+ if (NumHandles)
+ {
+ MemFreePointer ((VOID **)&DriverHealthHandles);
+ }
+ VarSetNvramName (L"DriverHealthCount", &DrvHealthGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &HealthCount, sizeof (UINTN));
+ VarUpdateVariable (VARIABLE_ID_DRV_HLTH_COUNT); //Update NVRAM cache for DriverHealthCount
+ HealthCount = HealthCount ? 1 : 0; //To enable driver health root menu
+ VarSetNvramName (L"DriverHlthEnable", &DrvHlthEnableGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &HealthCount, sizeof (UINTN));
+ VarUpdateVariable (VARIABLE_ID_DRV_HLTH_ENB); //Update NVRAM cache for DriverHlthEnable
+ SETUP_DEBUG_UEFI ( "\n[TSE] Exiting SetDriverHealthCount()\n" );
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: DisplayMsgListMessageBox
+//
+// Description: Displays the messages from EFI_DRIVER_HEALTH_HII_MESSAGE
+//
+// Input: EFI_DRIVER_HEALTH_HII_MESSAGE * = Message to show
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DisplayMsgListMessageBox (EFI_DRIVER_HEALTH_HII_MESSAGE *MessageList)
+{
+ CHAR16 *DisplayString = NULL;
+ CHAR16 *String = NULL;
+ UINT8 Count = 0;
+ UINT8 MsgBoxSel = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ while (MessageList [Count].HiiHandle)
+ {
+ String = HiiGetString (MessageList [Count].HiiHandle, MessageList [Count].StringId);
+ Count ++;
+ if (Count > 15) //Checking for safe termination, otherwise msgbox fill the full screen
+ {
+ break;
+ }
+ if (String)
+ {
+ if (!DisplayString)
+ {
+ DisplayString = EfiLibAllocateZeroPool ((EfiStrLen (String) + 2) * sizeof (CHAR16)); //2 for /n and NULL character
+ }
+ else
+ {
+ DisplayString = MemReallocateZeroPool (
+ DisplayString,
+ ( (EfiStrLen (DisplayString) + 1) * sizeof (CHAR16) ),
+ ( ((EfiStrLen (String) + 2) * sizeof (CHAR16)) + ((EfiStrLen (DisplayString) + 1) * sizeof (CHAR16)) ) //2 for /n and NULL character
+ );
+ }
+ if (NULL == DisplayString)
+ {
+ MemFreePointer ((VOID **)&String);
+ continue;
+ }
+ if (DisplayString [0])
+ {
+ EfiStrCat (DisplayString, String);
+ EfiStrCat (DisplayString, L"\n");
+ }
+ else
+ {
+ EfiStrCpy (DisplayString, String);
+ EfiStrCat (DisplayString, L"\n");
+ }
+ }
+ }
+ if (DisplayString)
+ {
+ CHAR16 *text = NULL;
+ text = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DRV_HLTH_TITLE));
+ Status = mPostMgr->DisplayMsgBox (
+ text,
+ DisplayString,
+ MSGBOX_TYPE_OK,
+ &MsgBoxSel
+ );
+ if(EFI_ERROR (Status))
+ return;
+
+ MemFreePointer ((VOID **)&DisplayString);
+ if (text)
+ {
+ MemFreePointer ((VOID **)&text);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//-------------------------------------------------------------------------------------------
+// Procedure: DoDriverHealthOperation
+//
+// Description: Performs the driver health operations for the corresponding controller entry
+//
+// Input: VOID * = Control Info for the correponding controller entry
+// UINT16 = Controller entry in the page
+//
+// Output: VOID
+//
+//--------------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DoDriverHealthOperation (VOID *Tempcontrol, UINT16 ControllerEntry)
+{
+ UINT16 Count = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+ DRV_HEALTH_HNDLS *DrvHlthHandles = NULL;
+ EFI_DRIVER_HEALTH_STATUS LocalHealthStatus = EfiDriverHealthStatusHealthy;
+ EFI_DRIVER_HEALTH_HII_MESSAGE *MessageList = NULL;
+ EFI_HII_HANDLE FormHiiHandle;
+ UINT8 MsgBoxSel = 0;
+ CONTROL_INFO *control = (CONTROL_INFO *)Tempcontrol;
+
+ if(!mPostMgr)
+ {
+ //Loacate Post Manager Protocol
+ Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &mPostMgr);
+ if(Status != EFI_SUCCESS)
+ return;
+ }
+
+ DrvHlthHandles = gDrvHealthHandlesHead;
+ while (Count != ControllerEntry)
+ {
+ DrvHlthHandles = DrvHlthHandles->Next;
+ Count ++;
+ }
+ if (EfiDriverHealthStatusHealthy == DrvHlthHandles->HealthStatus)
+ {
+ Status = gDrvHealthInstance->GetHealthStatus (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ &LocalHealthStatus,
+ &MessageList,
+ &FormHiiHandle
+ );
+ if (NULL != MessageList)
+ {
+ DisplayMsgListMessageBox (MessageList);
+ }
+ }
+ if (EfiDriverHealthStatusRepairRequired == DrvHlthHandles->HealthStatus)
+ {
+ Status = gDrvHealthInstance->Repair (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ NULL
+ );
+ if (!EFI_ERROR (Status))
+ {
+ Status = gDrvHealthInstance->GetHealthStatus (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ &LocalHealthStatus,
+ &MessageList,
+ &FormHiiHandle
+ );
+ if (NULL != MessageList)
+ {
+ DisplayMsgListMessageBox (MessageList);
+ }
+ }
+ }
+ if ((EfiDriverHealthStatusConfigurationRequired == DrvHlthHandles->HealthStatus) ||
+ (EfiDriverHealthStatusConfigurationRequired == LocalHealthStatus))
+ {
+ UINT32 i=0;
+ PAGE_INFO *pageInfo;
+ if (EfiDriverHealthStatusConfigurationRequired != LocalHealthStatus)
+ {
+ Status = gDrvHealthInstance->GetHealthStatus (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ &LocalHealthStatus,
+ &MessageList,
+ &FormHiiHandle
+ );
+ }
+ if (!EFI_ERROR (Status) && (FormHiiHandle))
+ {
+ if (NULL != MessageList)
+ {
+ DisplayMsgListMessageBox (MessageList);
+ }
+ for (i = 0; i < gPages->PageCount; i++)
+ {
+ pageInfo = (PAGE_INFO *)((UINTN)gApplicationData + gPages->PageList[i]);
+ if (pageInfo->PageHandle == FormHiiHandle)
+ {
+ PAGE_DATA **page; //To display the configuration page in advanced menu itself
+
+ control->ControlDestPageID = i;
+ pageInfo->PageFlags.PageVisible = FALSE;
+ pageInfo->PageParentID = control->ControlPageID;
+
+ //For ESA gApp will be NULL but for TSE gApp will be not-NULL
+ if(gApp)
+ {
+ page = &gApp->PageList [pageInfo->PageID];
+ gPage.Destroy (*page, FALSE);
+ gPage.Initialize (*page, pageInfo);
+ gApp->CurrentPage = i;
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (EfiDriverHealthStatusFailed == DrvHlthHandles->HealthStatus)
+ {
+ Status = gDrvHealthInstance->GetHealthStatus (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ &LocalHealthStatus,
+ &MessageList,
+ &FormHiiHandle
+ );
+ if ((!EFI_ERROR (Status)) && (NULL != MessageList))
+ {
+ DisplayMsgListMessageBox (MessageList);
+ }
+ }
+ if (EfiDriverHealthStatusReconnectRequired == DrvHlthHandles->HealthStatus)
+ {
+ CHAR16 *Title = NULL;
+ CHAR16 *Message = NULL;
+
+ Title = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DRV_HLTH_TITLE));
+ Message = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DRV_HLTH_RECON));
+ Status = mPostMgr->DisplayMsgBox (
+ Title,
+ Message,
+ MSGBOX_TYPE_OKCANCEL,
+ &MsgBoxSel
+ );
+ if(EFI_ERROR (Status))
+ return;
+
+ if (0 == MsgBoxSel) //User pressed OK
+ {
+ gBS->DisconnectController (DrvHlthHandles->ControllerHandle, NULL, NULL);
+ gBS->ConnectController (DrvHlthHandles->ControllerHandle, NULL, NULL, TRUE);
+ }
+ }
+ if (EfiDriverHealthStatusRebootRequired == DrvHlthHandles->HealthStatus)
+ {
+ CHAR16 *Title = NULL;
+ CHAR16 *Message = NULL;
+
+ Title = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DRV_HLTH_TITLE));
+ Message = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DRV_HLTH_REBOOT));
+ Status = mPostMgr->DisplayMsgBox (
+ Title,
+ Message,
+ MSGBOX_TYPE_OKCANCEL,
+ &MsgBoxSel
+ );
+ if(EFI_ERROR (Status))
+ return;
+
+ if (0 == MsgBoxSel) //User pressed OK
+ {
+ DrvHlthHandles = gDrvHealthHandlesHead;
+ while (DrvHlthHandles)
+ {
+ //Proceed with repair for all the controllers in repair state
+ if (EfiDriverHealthStatusRepairRequired == DrvHlthHandles->HealthStatus)
+ {
+ Status = gDrvHealthInstance->Repair (
+ gDrvHealthInstance,
+ DrvHlthHandles->ControllerHandle,
+ DrvHlthHandles->ChildHandle,
+ NULL
+ );
+ }
+ DrvHlthHandles = DrvHlthHandles->Next;
+ }
+ FreeControllersList ();
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CheckTimeFlags
+//
+// Description: Function to check the time flags.
+//
+// Input: UINT16 ItemCount
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckTimeFlags(UINT8 Flags)
+{
+ return ((Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) ;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CheckDateFlags
+//
+// Description: Function to check the date flags.
+//
+// Input: UINT16 ItemCount
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN CheckDateFlags(UINT8 Flags)
+{
+ return ((Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL);
+}
+
+//EIP75481 Support TSE debug print infrastructure
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CreateFile
+//
+// Description: Creates a file to output hpk data
+//
+// Input: CHAR16 *filenameFormat,
+// EFI_HII_HANDLE *Handle,
+// UINTN Index
+//
+//
+// Output: EFI_FILE_PROTOCOL*
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_FILE_PROTOCOL * CreateFile(CHAR16 *filename, UINT32 index)
+{
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pSFP;
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_FILE_PROTOCOL *pRoot,*FileHandle;
+ EFI_HANDLE *gSmplFileSysHndlBuf = NULL;
+ UINTN Count = 0;
+ UINT16 i = 0;
+
+ // Locate all the simple file system devices in the system
+ Status = pBS->LocateHandleBuffer(ByProtocol, &guidSimpleFileSystemProtocol, NULL, &Count, &gSmplFileSysHndlBuf);
+
+ if(!EFI_ERROR(Status))
+ {
+ Status = gBS->HandleProtocol( gSmplFileSysHndlBuf[index], &guidSimpleFileSystemProtocol, &pSFP );
+
+ if (!EFI_ERROR(Status))
+ {
+ Status = pSFP->OpenVolume(pSFP,&pRoot);
+
+ if (!EFI_ERROR(Status))
+ {
+ Status = pRoot->Open(pRoot,
+ &FileHandle,
+ filename,
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
+ 0);
+
+ pRoot->Close(pRoot);
+
+ if (!EFI_ERROR(Status))
+ {
+ return FileHandle;
+ }
+ }
+ }
+ }
+
+ if(gSmplFileSysHndlBuf != NULL)
+ pBS->FreePool(gSmplFileSysHndlBuf);
+
+ return NULL;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: WriteDataToFile
+//
+// Description: Writes data to file
+//
+// Input: CHAR16 *filename, VOID *Data, UINTN length
+//
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS WriteDataToFile(CHAR16 *filename, VOID *Data, UINTN length, UINT32 index)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_FILE_PROTOCOL *FileHandle=NULL;
+
+ UINTN len = length;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Entering WriteDataToFile \n\n");
+
+ if (Data == NULL)
+ {
+ goto DONE;
+ }
+
+ FileHandle = CreateFile(filename, index);
+
+ if (FileHandle != NULL)
+ {
+ FileHandle->SetPosition(FileHandle,0);
+ FileHandle->Write(FileHandle,&len, Data);
+ FileHandle->Close(FileHandle);
+ Status = EFI_SUCCESS ;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Exporting Filename: %s \n\n", filename);
+ }
+DONE:
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Exiting WriteDataToFile, Status: %x \n\n", Status);
+
+ return Status ;
+}
+
+#if TSE_DEBUG_MESSAGES
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: HiiGetPackList
+//
+// Description: Get HII form package by handle and form ID
+//
+// Input: EFI_HII_HANDLE Handle
+// UINT16 form
+// UINTN *Length
+//
+// Output: VOID *formPkBuffer -
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID *HiiGetPackList( EFI_HII_HANDLE Handle, UINT16 form, UINTN *Length )
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ VOID *hiiFormPackage=NULL;
+ UINTN len=10;
+
+ if(Length == NULL)
+ Length = &len;
+
+ hiiFormPackage = EfiLibAllocateZeroPool(*Length);
+
+ status = gHiiDatabase->ExportPackageLists(gHiiDatabase, Handle, Length, hiiFormPackage);
+ if(status == EFI_BUFFER_TOO_SMALL)
+ {
+ MemFreePointer(&hiiFormPackage);
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ hiiFormPackage = EfiLibAllocateZeroPool(*Length);
+
+ if (hiiFormPackage == NULL)
+ {
+ hiiFormPackage = NULL;
+ goto DONE;
+ }
+ //
+ // Get all the packages associated with this HiiHandle
+ //
+ status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, Length, hiiFormPackage);
+ if(EFI_ERROR(status))
+ {
+ MemFreePointer(&hiiFormPackage);
+ hiiFormPackage = NULL;
+ }
+ }
+ else if(EFI_ERROR(status))
+ {
+ hiiFormPackage = NULL;
+ }
+
+DONE:
+ return hiiFormPackage;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: ProcessPackToFile
+//
+// Description: Prints the HPK data to file
+//
+// Input: EFI_HII_DATABASE_NOTIFY_TYPE NotifyType, EFI_HANDLE Handle
+//
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ProcessPackToFile(EFI_HII_DATABASE_NOTIFY_TYPE NotifyType, EFI_HANDLE Handle)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ CHAR16 *filenameFormat = NULL;
+ CHAR16 filename[50];
+ VOID *formSetData = NULL;
+ UINTN length = 0;
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Entering ProcessPackToFile \n\n");
+
+
+ if(NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK)
+ filenameFormat = L"REMOVED_0x%x_%03d.hpk" ;
+
+ else if(NotifyType == EFI_HII_DATABASE_NOTIFY_NEW_PACK)
+ filenameFormat = L"NEW_0x%x_%03d.hpk" ;
+
+ else if(NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK)
+ filenameFormat = L"UPDATE_0x%x_%03d.hpk" ;
+
+ else
+ goto DONE ;
+
+
+ formSetData = (UINT8*)HiiGetPackList(Handle, 0, &length);
+
+ if (formSetData == NULL)
+ {
+ goto DONE;
+ }
+
+ SPrint(filename, 50, filenameFormat, Handle, HpkFileCount);
+
+ Status = WriteDataToFile(filename, formSetData, length, 0) ;
+
+ if (!EFI_ERROR (Status))
+ {
+ HpkFileCount++ ;
+ }
+
+DONE:
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Exiting ProcessPackToFile, Status: %x \n\n", Status);
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: WritePackToFile
+//
+// Description: Writes Hpk data to file
+//
+// Input: CHAR16 *filenameFormat, EFI_HANDLE Handle, UINT8 *PackData, UINTN length
+//
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS WritePackToFile(CHAR16 *filenameFormat, EFI_HANDLE Handle, UINT8 *PackData, UINTN length)
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_FILE_PROTOCOL *FileHandle=NULL;
+ UINT8 *formSet = PackData;
+ UINTN len = length;
+ CHAR16 filename[50];
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Entering WritePackToFile \n\n");
+
+ if(formSet == NULL)
+ {
+ formSet = (UINT8*)HiiGetPackList(Handle, 0, &len);
+ if (formSet == NULL)
+ {
+ goto DONE;
+ }
+ }
+
+ SPrint(filename, 50, filenameFormat, Handle, HpkFileCount);
+
+ Status = WriteDataToFile(filename, formSet, length,0) ;
+
+ if (!EFI_ERROR (Status))
+ {
+ HpkFileCount++ ;
+ }
+
+DONE:
+
+ SETUP_DEBUG_UEFI_NOTIFICATION( "\n\n[TSE] Exiting WritePackToFile, Status: %x \n\n", Status);
+
+ return Status ;
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugShowBufferContent
+//
+// Description: Prints the buffer, 16 characters max in a line
+//
+// Input: UINTN bufSize - Buffer length to print
+// VOID *buffer - Buffer to print
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DebugShowBufferContent(UINTN bufSize, VOID *buffer)
+{
+
+ //#if TSE_DEBUG_MESSAGES == 2
+
+ UINTN index = 0, j = 0;
+ UINTN size = bufSize;
+ UINT8 *temp = (UINT8 *)buffer;
+
+ for(index = 0; index < size; ){
+ SETUP_DEBUG_UEFI_CALLBACK ( "[0x%08x (%04d)] ", index, index);
+ for(j = 0; (j < 16) && (temp != NULL); index++, j++){
+ if(index >= size){
+ break;
+ }
+ if(j==8) SETUP_DEBUG_UEFI_CALLBACK ( "- ");
+ SETUP_DEBUG_UEFI_CALLBACK ( "%02x ", (UINT8)temp[index]);
+ }
+ SETUP_DEBUG_UEFI_CALLBACK ("\n");
+ }
+
+
+// #endif
+
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugLibShowHiiControlState
+//
+// Description: Prints the AMI Setup Lib control states
+//
+// Input: None
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DebugLibShowHiiControlState(UINT32 formID, UINT32 ctrlIndex, VOID *passedCtrlInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO *)NULL;
+ UINTN ctrlCond = COND_NONE;
+
+ ctrlInfo = (CONTROL_INFO *)passedCtrlInfo;
+ if(passedCtrlInfo == NULL){
+ //status = _GetControlInfo(formID, ctrlIndex, &ctrlInfo);
+ //if((ctrlInfo == NULL) || EFI_ERROR(status)){
+ SETUP_DEBUG_TSE("Invalid ctrlInfo, formID: 0x%x, ctrlIndex: 0x%x, status: 0x%x", formID, ctrlIndex, status);
+ return;
+ //}
+ }
+ ctrlCond = CheckControlCondition(ctrlInfo);
+
+ switch(ctrlCond){
+ case COND_NONE:
+ SETUP_DEBUG_TSE("Control Condition: COND_NONE\n");
+ break;
+ case COND_SUPPRESS:
+ SETUP_DEBUG_TSE("Control Condition: COND_SUPPRESS\n");
+ break;
+ case COND_HIDDEN:
+ SETUP_DEBUG_TSE("Control Condition: COND_HIDDEN\n");
+ break;
+ case COND_GRAYOUT:
+ SETUP_DEBUG_TSE("Control Condition: COND_GRAYOUT\n");
+ break;
+ case COND_INCONSISTENT:
+ SETUP_DEBUG_TSE("Control Condition: COND_INCONSISTENT\n");
+ break;
+ default:
+ break;
+ }
+ return;
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugShowControlInfo
+//
+// Description: Prints the cache controls information
+//
+// Input: UINT32 formID
+// UINTN count
+// VOID *passedCtrlInfo
+// BOOLEAN detailed - If TRUE, prints the control buffers
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DebugShowControlInfo(UINT32 formID, VOID *passedCtrlInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINTN bufferLen = 0;
+ UINT32 i = 0, j = 0;
+ UINT8 *temp = (UINT8 *)NULL;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ UINT8 *questionValue = (UINT8 *)NULL;
+ UINTN dataWidth = 0;
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO *)NULL;
+ CHAR16 *String = (CHAR16 *)NULL;
+
+ ctrlInfo = (CONTROL_INFO *)passedCtrlInfo;
+
+ if(passedCtrlInfo == NULL){
+ //status = _GetControlInfo(formID, ctrlIndex, &ctrlInfo);
+ goto DONE ;
+ }
+
+ if((ctrlInfo == NULL) || EFI_ERROR(status)){
+ SETUP_DEBUG_TSE("Invalid ctrlInfo, formID: 0x%x, status: 0x%x", formID, status);
+ goto DONE ;
+ }
+
+ SETUP_DEBUG_TSE("\n----- Adding Control -----\n");
+
+ if(ctrlInfo->ControlHandle != NULL){
+ String = HiiGetString(ctrlInfo->ControlHandle, ctrlInfo->QuestionId);
+ }
+
+ if (String)
+ {
+ SETUP_DEBUG_TSE("QuestionId: 0x%x, %s\n", ctrlInfo->QuestionId, String);
+ }
+ SETUP_DEBUG_TSE("ControlHandle: 0x%x\n", ctrlInfo->ControlHandle);
+ SETUP_DEBUG_TSE("ControlType: 0x%x\n", ctrlInfo->ControlType);
+ SETUP_DEBUG_TSE("ControlPageID: %d\n", ctrlInfo->ControlPageID);
+ SETUP_DEBUG_TSE("ControlDestPageID: %d\n", ctrlInfo->ControlDestPageID);
+ SETUP_DEBUG_TSE("ControlIndex: %d\n", ctrlInfo->ControlIndex);
+ SETUP_DEBUG_TSE("ControlPtr: 0x%x\n", ctrlInfo->ControlPtr);
+ SETUP_DEBUG_TSE("ControlConditionalPtr: 0x%x\n", ctrlInfo->ControlConditionalPtr);
+ SETUP_DEBUG_TSE("ControlDataLength: 0x%x\n", ctrlInfo->ControlDataLength);
+ SETUP_DEBUG_TSE("ControlDataWidth: 0x%x\n", ctrlInfo->ControlDataWidth);
+ SETUP_DEBUG_TSE("ControlKey: %d\n", ctrlInfo->ControlKey);
+ SETUP_DEBUG_TSE("DestQuestionID: 0x%x\n", &ctrlInfo->DestQuestionID);
+ //DebugLibShowHiiControlState(formID, ctrlInfo->ControlIndex, ctrlInfo);
+ //DebugShowControlFlags(formID, ctrlIndex, ctrlInfo, &ctrlInfo->ControlFlags);
+
+
+DONE:
+ MemFreePointer( (VOID **)&String );
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugShowPageInfo
+//
+// Description: Shows the Page information
+//
+// Input: UINT32 formID - The form
+// PAGE_INFO *passedPageInfo
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID DebugShowPageInfo(UINT32 formID, VOID *passedPageInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = (PAGE_INFO *)NULL;
+
+ pageInfo = (PAGE_INFO *)passedPageInfo;
+
+ if(pageInfo == NULL)
+ return ;
+
+ SETUP_DEBUG_TSE("\n+++++ Adding Page +++++\n");
+ SETUP_DEBUG_TSE("PageTitle: %s \n", HiiGetString(pageInfo->PageHandle, pageInfo->PageSubTitle )); //Varies Allows a page to override the main title bar
+ //SETUP_DEBUG_TSE("PageSubTitle: %s \n", HiiGetString(pageInfo->PageHandle, pageInfo->PageSubTitle )); //Varies Token for the subtitle string for this page
+ SETUP_DEBUG_TSE("PageHandle: 0x%x\n", pageInfo->PageHandle);
+ SETUP_DEBUG_TSE("PageIdIndex: %d\n", pageInfo->PageIdIndex); //varies Index in to PageIdList triplets
+ SETUP_DEBUG_TSE("PageFormID: %d\n", pageInfo->PageFormID); //Varies Form ID within the formset for this page
+ SETUP_DEBUG_TSE("PageID: %d\n", pageInfo->PageID); //Varies unique ID for this page
+ SETUP_DEBUG_TSE("PageParentID: %d\n", pageInfo->PageParentID); //Varies Identify this page's parent page
+ SETUP_DEBUG_TSE("PageFlags: 0x%x\n", pageInfo->PageFlags); //3 Various attributes for a specific page
+ SETUP_DEBUG_TSE("PageVariable: 0x%x\n", pageInfo->PageVariable); //Varies Overrides the variable ID for this page (0 = use default)
+ SETUP_DEBUG_TSE("PageDynamic: 0x%x\n", pageInfo->PageFlags.PageDynamic); //Identify this page as dynamic page
+
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugShowHiiVariable
+//
+// Description: Prints the variable information for the given parameter
+//
+// Input: UINT32 formID
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DebugShowHiiVariable(UINT32 formID, UINT32 varIndex, UINT32 *passedVarIDList)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ NVRAM_VARIABLE *nvPtr = (NVRAM_VARIABLE *)NULL;
+ UINT32 *varIDList = (UINT32 *)NULL;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL ;
+ UINTN index = 0, j = 0, size = 0 ;
+ UINT8 *temp = (UINT8 *)NULL ;
+
+ nvPtr = gVariableList;
+ size = nvPtr[varIndex].Size < 0xFFFF ? nvPtr[varIndex].Size : 0;
+ temp = nvPtr[varIndex].Buffer;
+ varInfo = VarGetVariableInfoIndex( varIndex );
+
+ if(size){
+ SETUP_DEBUG_VAR ("\n----------- DebugShowHiiVariable -----------\n");
+ SETUP_DEBUG_VAR ("VariableName: %s, Buffer size: %d, Buffer: 0x%x \n", varInfo->VariableName, size, nvPtr[varIndex].Buffer);
+
+ for(index = 0; index < size; ){
+ SETUP_DEBUG_VAR ( "[0x%08x (%04d)] ", index, index);
+ for(j = 0; (j < 16) && (temp != NULL); index++, j++){
+ if(index >= size){
+ break;
+ }
+ if(j==8) SETUP_DEBUG_VAR ( "- ");
+ SETUP_DEBUG_VAR ( "%02x ", (UINT8)temp[index]);
+ }
+ SETUP_DEBUG_VAR ("\n");
+ }
+
+ SETUP_DEBUG_VAR ("----------- End of DebugShowHiiVariable, status: 0x%x -----------\n\n", status);
+ } else{
+ SETUP_DEBUG_VAR ("!!!!!! VariableName: %s, size: %d !!!!!\n", varInfo->VariableName, nvPtr[varIndex].Size);
+ }
+
+ return status;
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DebugShowAllHiiVariable
+//
+// Description: Prints the variable information in the list
+//
+// Input: UINT32 formID
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DebugShowAllHiiVariable(UINT32 formID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ NVRAM_VARIABLE *nvPtr = (NVRAM_VARIABLE *)NULL;
+ UINT32 i = 0;
+ UINT32 *varIDList = (UINT32*)EfiLibAllocateZeroPool(gVariables->VariableCount * sizeof(UINT32));
+
+ SETUP_DEBUG_VAR ("\n----------- DebugShowAllHiiVariable -----------\n");
+
+ if(varIDList == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+ SETUP_DEBUG_VAR ("ERROR-%r: varIDList Memory Allocation Failed\n", status);
+ goto DONE;
+ }
+
+ nvPtr = gVariableList;
+
+ SETUP_DEBUG_VAR ("++ Total number of variables: %d ++\n\n", gVariables->VariableCount);
+ for ( i = 0; i < gVariables->VariableCount; i++){
+ DebugShowHiiVariable(formID, i, varIDList);
+ }
+ SETUP_DEBUG_VAR ("\n");
+
+DONE:
+
+ SETUP_DEBUG_VAR ("--------- End of DebugShowAllHiiVariable, status: 0x%x ---------\n\n", status);
+ return status;
+}
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: DisplayParseFormSetData
+//
+// Description: Prints the current FormSet data
+//
+// Input: UINT32 FormID - Library formID of a FormSet
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DisplayParseFormSetData(VOID)
+{
+
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = (PAGE_INFO *)NULL;
+ EFI_HII_PACKAGE_HEADER *pkgHdr = (EFI_HII_PACKAGE_HEADER *)NULL;
+ UINT8 *formSet = (UINT8 *)NULL;
+ UINT8 *ifrData = (UINT8 *)NULL;
+ EFI_IFR_OP_HEADER *opHeader = (EFI_IFR_OP_HEADER *)NULL;
+ UINTN length = 0;
+ UINTN i = 0, count = 0;
+ CHAR16 *opcodeName = (CHAR16 *)NULL;
+ EFI_GUID *tempFormSetGuid = (EFI_GUID *)NULL;
+ BOOLEAN validOpCode = TRUE;
+ UINTN pScopeCount = 0;
+ BOOLEAN CurrentForm = FALSE;
+ PAGE_DATA *Page ;
+ UINT16 questionId = 0;
+ FRAME_DATA *frame = NULL ;
+ //UINT16 PageFormID = 0;
+
+ Page = gApp->PageList[gApp->CurrentPage];
+
+ formSet = (UINT8*)HiiGetForm(Page->PageData.PageHandle, 0, &length);
+ if(formSet == NULL){
+ status = EFI_UNSUPPORTED;
+ SETUP_DEBUG_TSE ("ERROR: 0x%x, failed to get FormSet data\n",status);
+ goto DONE;
+ }
+
+ pkgHdr = (EFI_HII_PACKAGE_HEADER*)formSet;
+
+ if(pkgHdr->Type != EFI_HII_PACKAGE_FORMS)
+ {
+ status = EFI_UNSUPPORTED;
+ SETUP_DEBUG_TSE("ERROR: 0x%x, pkgHdr->Type is not supported, Since it is not EFI_HII_PACKAGE_FORM\n",status);
+ goto DONE;
+ }
+
+
+ ifrData = ((UINT8 *)pkgHdr) + sizeof(EFI_HII_PACKAGE_HEADER);
+
+ while(i < pkgHdr->Length)
+ {
+ opHeader = (EFI_IFR_OP_HEADER*)(ifrData + i);
+ tempFormSetGuid = (EFI_GUID *)NULL;
+
+ if(opHeader == NULL){
+ break;
+ }
+
+ count = pScopeCount;
+ questionId = 0;
+
+ switch(opHeader->OpCode)
+ {
+ case EFI_IFR_FORM_OP: //0x01 - Form
+ opcodeName = L"EFI_IFR_FORM_OP";
+
+ if(CurrentForm)
+ {
+ SETUP_DEBUG_TSE ( "[TSE] Form OpCode End\n" );
+ goto DONE;
+ }
+
+ if(((EFI_IFR_FORM*)(ifrData + i))->FormId == Page->PageData.PageFormID)
+ {
+ SETUP_DEBUG_TSE ( "[TSE] Form OpCode Start\n" );
+ SETUP_DEBUG_TSE ( "FormTitle: %s\n", HiiGetString(Page->PageData.PageHandle, Page->PageData.PageSubTitle ));
+
+ frame = Page->FrameList[StyleFrameIndexOf(MAIN_FRAME)];
+ if(frame != NULL)
+ SETUP_DEBUG_TSE ( "NumberOfControls: %ld\n", frame->ControlCount );
+
+ CurrentForm = TRUE;
+ }
+
+ break;
+ case EFI_IFR_SUBTITLE_OP: //0x02 - Subtitle statement
+ opcodeName = L"EFI_IFR_SUBTITLE_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_TEXT_OP: //0x03 - Static text/image statement
+ opcodeName = L"EFI_IFR_TEXT_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_IMAGE_OP: //0x04 - Static image.
+ opcodeName = L"EFI_IFR_IMAGE_OP";
+ break;
+ case EFI_IFR_ONE_OF_OP: //0x05 - One-of question
+ opcodeName = L"EFI_IFR_ONE_OF_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_CHECKBOX_OP: //0x06 - Boolean question
+ opcodeName = L"EFI_IFR_CHECKBOX_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_NUMERIC_OP: //0x07 - Numeric question
+ opcodeName = L"EFI_IFR_NUMERIC_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_PASSWORD_OP: //0x08 - Password string question
+ opcodeName = L"EFI_IFR_PASSWORD_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_ONE_OF_OPTION_OP: //0x09 - Option
+ opcodeName = L"EFI_IFR_ONE_OF_OPTION_OP";
+ /*
+ switch(((EFI_IFR_ONE_OF_OPTION *)opHeader)->Type)
+ {
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ questionId = ((EFI_IFR_ONE_OF_OPTION *)opHeader)->Value.u16;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ questionId = ((EFI_IFR_ONE_OF_OPTION *)opHeader)->Value.u32;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ questionId = (UINT16)((EFI_IFR_ONE_OF_OPTION *)opHeader)->Value.u64;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ default:
+ questionId = ((EFI_IFR_ONE_OF_OPTION *)opHeader)->Value.u8;
+ break;
+ }
+ */
+ break;
+ case EFI_IFR_SUPPRESS_IF_OP: //0x0A - Suppress if conditional
+ opcodeName = L"EFI_IFR_SUPPRESS_IF_OP";
+ break;
+ case EFI_IFR_LOCKED_OP: //0x0B - Marks statement/question as locked
+ opcodeName = L"EFI_IFR_LOCKED_OP";
+ break;
+ case EFI_IFR_ACTION_OP: //0x0C - Button question
+ opcodeName = L"EFI_IFR_ACTION_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_RESET_BUTTON_OP: //0x0D - Reset button statement
+ opcodeName = L"EFI_IFR_RESET_BUTTON_OP";
+ break;
+ case EFI_IFR_FORM_SET_OP: //0x0E - Form set
+ opcodeName = L"EFI_IFR_FORM_SET_OP";
+ break;
+ case EFI_IFR_REF_OP: //0x0F - Cross-reference statement
+ opcodeName = L"EFI_IFR_REF_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_NO_SUBMIT_IF_OP: //0x10 - Error checking conditional
+ opcodeName = L"EFI_IFR_NO_SUBMIT_IF_OP";
+ break;
+ case EFI_IFR_INCONSISTENT_IF_OP: //0x11 - Error checking conditional
+ opcodeName = L"EFI_IFR_INCONSISTENT_IF_OP";
+ break;
+ case EFI_IFR_EQ_ID_VAL_OP: //0x12 - Return true if question value equals UINT16
+ opcodeName = L"EFI_IFR_EQ_ID_VAL_OP";
+ break;
+ case EFI_IFR_EQ_ID_ID_OP: //0x13 - Return true if question value equals another question value
+ opcodeName = L"EFI_IFR_EQ_ID_ID_OP";
+ break;
+ case 0x14: //0x14 - Return true if question value is found in list of UINT16s
+ opcodeName = L"EFI_IFR_EQ_ID_VAL_LIST_OP";
+ break;
+ case EFI_IFR_AND_OP: //0x15 - Push true if both sub-expressions returns true.
+ opcodeName = L"EFI_IFR_AND_OP";
+ break;
+ case EFI_IFR_OR_OP: //0x16 - Push true if either sub-expressions returns true.
+ opcodeName = L"EFI_IFR_OR_OP";
+ break;
+ case EFI_IFR_NOT_OP: //0x17 - Push false if sub-expression returns true, otherwise return true.
+ opcodeName = L"EFI_IFR_NOT_OP";
+ break;
+ case EFI_IFR_RULE_OP: //0x18 - Create rule in current form.
+ opcodeName = L"EFI_IFR_RULE_OP";
+ break;
+ case EFI_IFR_GRAY_OUT_IF_OP: //0x19 - Nested statements, questions or options will not be selectable if expression returns true.
+ opcodeName = L"EFI_IFR_GRAY_OUT_IF_OP";
+ break;
+ case EFI_IFR_DATE_OP: //0x1A - Date question.
+ opcodeName = L"EFI_IFR_DATE_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_TIME_OP: //0x1B - Time question.
+ opcodeName = L"EFI_IFR_TIME_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_STRING_OP: //0x1C - String question
+ opcodeName = L"EFI_IFR_STRING_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_REFRESH_OP: //0x1D - Interval for refreshing a question
+ opcodeName = L"EFI_IFR_REFRESH_OP";
+ break;
+ case EFI_IFR_DISABLE_IF_OP: //0x1E - Nested statements, questions or options will not be processed if expression returns true.
+ opcodeName = L"EFI_IFR_DISABLE_IF_OP";
+ break;
+ case 0x1F: //0x1F - Animation associated with question statement, form or form set.
+ opcodeName = L"EFI_IFR_ANIMATION_OP";
+ break;
+ case EFI_IFR_TO_LOWER_OP: //0x20 - Convert a string on the expression stack to lower case.
+ opcodeName = L"EFI_IFR_TO_LOWER_OP";
+ break;
+ case EFI_IFR_TO_UPPER_OP: //0x21 - Convert a string on the expression stack toupper case.
+ opcodeName = L"EFI_IFR_TO_UPPER_OP";
+ break;
+ case 0x22: //0x22 - Convert one value to another by selecting a match from a list.
+ opcodeName = L"EFI_IFR_MAP_OP";
+ break;
+ case EFI_IFR_ORDERED_LIST_OP: //0x23 - Set question
+ opcodeName = L"EFI_IFR_ORDERED_LIST_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_VARSTORE_OP: //0x24 - Define a buffer-style variable storage.
+ opcodeName = L"EFI_IFR_VARSTORE_OP";
+ break;
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP: //0x25 - Define a name/value style variable storage.
+ opcodeName = L"EFI_IFR_VARSTORE_NAME_VALUE_OP";
+ break;
+ case EFI_IFR_VARSTORE_EFI_OP: //0x26 - Define a UEFI variable style variable storage.
+ opcodeName = L"EFI_IFR_VARSTORE_EFI_OP";
+ break;
+ case EFI_IFR_VARSTORE_DEVICE_OP: //0x27 - Specify the device path to use for variable storage.
+ opcodeName = L"EFI_IFR_VARSTORE_DEVICE_OP";
+ break;
+ case EFI_IFR_VERSION_OP: //0x28 - Push the revision level of the UEFI Specification to which this FormsProcessor is compliant.
+ opcodeName = L"EFI_IFR_VERSION_OP";
+ break;
+ case EFI_IFR_END_OP: //0x29 - Marks end of scope.
+ opcodeName = L"EFI_IFR_END_OP";
+ break;
+ case EFI_IFR_MATCH_OP: //0x2A - Push TRUE if string matches a pattern.
+ opcodeName = L"EFI_IFR_MATCH_OP";
+ break;
+ case 0x2B: //0x2B - Return a stored value.
+ opcodeName = L"EFI_IFR_GET_OP";
+ break;
+ case 0x2C: //0x2C - Change a stored value.
+ opcodeName = L"EFI_IFR_SET_OP";
+ break;
+ case 0x2D: //0x2D - Provides a value for the current question or default.
+ opcodeName = L"EFI_IFR_READ_OP";
+ break;
+ case 0x2E: //0x2E - Change a value for the current question.
+ opcodeName = L"EFI_IFR_WRITE_OP";
+ break;
+ case EFI_IFR_EQUAL_OP: //0x2F - Push TRUE if two expressions are equal.
+ opcodeName = L"EFI_IFR_EQUAL_OP";
+ break;
+ case EFI_IFR_NOT_EQUAL_OP: //0x30 - Push TRUE if two expressions are not equal.
+ opcodeName = L"EFI_IFR_NOT_EQUAL_OP";
+ break;
+ case EFI_IFR_GREATER_THAN_OP: //0x31 - Push TRUE if one expression is greater than another expression.
+ opcodeName = L"EFI_IFR_GREATER_THAN_OP";
+ break;
+ case EFI_IFR_GREATER_EQUAL_OP: //0x32 - Push TRUE if one expression is greater than or equal to another expression.
+ opcodeName = L"EFI_IFR_GREATER_EQUAL_OP";
+ break;
+ case EFI_IFR_LESS_THAN_OP: //0x33 - Push TRUE if one expression is less than another expression.
+ opcodeName = L"EFI_IFR_LESS_THAN_OP";
+ break;
+ case EFI_IFR_LESS_EQUAL_OP: //0x34 - Push TRUE if one expression is less than or equal to another expression.
+ opcodeName = L"EFI_IFR_LESS_EQUAL_OP";
+ break;
+ case EFI_IFR_BITWISE_AND_OP: //0x35 - Bitwise-AND two unsigned integers and push the result.
+ opcodeName = L"EFI_IFR_BITWISE_AND_OP";
+ break;
+ case EFI_IFR_BITWISE_OR_OP: //0x36 - Bitwise-OR two unsigned integers and push the result.
+ opcodeName = L"EFI_IFR_BITWISE_OR_OP";
+ break;
+ case EFI_IFR_BITWISE_NOT_OP: //0x37 - Bitwise-NOT an unsigned integer and push the result.
+ opcodeName = L"EFI_IFR_BITWISE_NOT_OP";
+ break;
+ case EFI_IFR_SHIFT_LEFT_OP: //0x38 - Shift an unsigned integer left by a number of bits and push the result.
+ opcodeName = L"EFI_IFR_SHIFT_LEFT_OP";
+ break;
+ case EFI_IFR_SHIFT_RIGHT_OP: //0x39 - Shift an unsigned integer right by a number of bits and push the result.
+ opcodeName = L"EFI_IFR_SHIFT_RIGHT_OP";
+ break;
+ case EFI_IFR_ADD_OP: //0x3A - Add two unsigned integers and push the result.
+ opcodeName = L"EFI_IFR_ADD_OP";
+ break;
+ case EFI_IFR_SUBTRACT_OP: //0x3B - Subtract two unsigned integers and push the result.
+ opcodeName = L"EFI_IFR_SUBTRACT_OP";
+ break;
+ case EFI_IFR_MULTIPLY_OP: //0x3C - Multiply two unsigned integers and push the result.
+ opcodeName = L"EFI_IFR_MULTIPLY_OP";
+ break;
+ case EFI_IFR_DIVIDE_OP: //0x3D - Divide one unsigned integer by another and push the result.
+ opcodeName = L"EFI_IFR_DIVIDE_OP";
+ break;
+ case EFI_IFR_MODULO_OP: //0x3E - Divide one unsigned integer by another and push the remainder.
+ opcodeName = L"EFI_IFR_MODULO_OP";
+ break;
+ case EFI_IFR_RULE_REF_OP: //0x3F //Evaluate a rule
+ opcodeName = L"EFI_IFR_RULE_REF_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_QUESTION_REF1_OP: //0x40 - Push a question’s value
+ opcodeName = L"EFI_IFR_QUESTION_REF1_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_QUESTION_REF2_OP: //0x41 - Push a question’s value
+ opcodeName = L"EFI_IFR_QUESTION_REF2_OP";
+ questionId = _GetQuestionToken((UINT8*)opHeader);
+ break;
+ case EFI_IFR_UINT8_OP: //0x42 - Push an 8-bit unsigned integer
+ opcodeName = L"EFI_IFR_UINT8_OP";
+ break;
+ case EFI_IFR_UINT16_OP: //0x43 - Push a 16-bit unsigned integer.
+ opcodeName = L"EFI_IFR_UINT16_OP";
+ break;
+ case EFI_IFR_UINT32_OP: //0x44 - Push a 32-bit unsigned integer
+ opcodeName = L"EFI_IFR_UINT32_OP";
+ break;
+ case EFI_IFR_UINT64_OP: //0x45 - Push a 64-bit unsigned integer.
+ opcodeName = L"EFI_IFR_UINT64_OP";
+ break;
+ case EFI_IFR_TRUE_OP: //0x46 - Push a boolean TRUE.
+ opcodeName = L"EFI_IFR_TRUE_OP";
+ break;
+ case EFI_IFR_FALSE_OP: //0x47 - Push a boolean FALSE
+ opcodeName = L"EFI_IFR_FALSE_OP";
+ break;
+ case EFI_IFR_TO_UINT_OP: //0x48 - Convert expression to an unsigned integer
+ opcodeName = L"EFI_IFR_TO_UINT_OP";
+ break;
+ case EFI_IFR_TO_STRING_OP: //0x49 - Convert expression to a string
+ opcodeName = L"EFI_IFR_TO_STRING_OP";
+ break;
+ case EFI_IFR_TO_BOOLEAN_OP: //0x4A - Convert expression to a boolean.
+ opcodeName = L"EFI_IFR_TO_BOOLEAN_OP";
+ break;
+ case EFI_IFR_MID_OP: //0x4B - Extract portion of string or buffer
+ opcodeName = L"EFI_IFR_MID_OP";
+ break;
+ case EFI_IFR_FIND_OP: //0x4C - Find a string in a string.
+ opcodeName = L"EFI_IFR_FIND_OP";
+ break;
+ case EFI_IFR_TOKEN_OP: //0x4D - Extract a delimited byte or character string from buffer or string.
+ opcodeName = L"EFI_IFR_TOKEN_OP";
+ break;
+ case EFI_IFR_STRING_REF1_OP: //0x4E - Push a string
+ opcodeName = L"EFI_IFR_STRING_REF1_OP";
+ break;
+ case EFI_IFR_STRING_REF2_OP: //0x4F - Push a string
+ opcodeName = L"EFI_IFR_STRING_REF2_OP";
+ break;
+ case EFI_IFR_CONDITIONAL_OP: //0x50 - Duplicate one of two expressions depending on result of the first expression.
+ opcodeName = L"EFI_IFR_CONDITIONAL_OP";
+ break;
+ case EFI_IFR_QUESTION_REF3_OP: //0x51 - Push a question’s value from a different form.
+ opcodeName = L"EFI_IFR_QUESTION_REF3_OP";
+ break;
+ case EFI_IFR_ZERO_OP: //0x52 - Push a zero
+ opcodeName = L"EFI_IFR_ZERO_OP";
+ break;
+ case EFI_IFR_ONE_OP: //0x53 //Push a one
+ opcodeName = L"EFI_IFR_ONE_OP";
+ break;
+ case EFI_IFR_ONES_OP: //0x54 - Push a 0xFFFFFFFFFFFFFFFF.
+ opcodeName = L"EFI_IFR_ONES_OP";
+ break;
+ case EFI_IFR_UNDEFINED_OP: //0x55 - Push Undefined
+ opcodeName = L"EFI_IFR_UNDEFINED_OP";
+ break;
+ case EFI_IFR_LENGTH_OP: //0x56 - Push length of buffer or string.
+ opcodeName = L"EFI_IFR_LENGTH_OP";
+ break;
+ case EFI_IFR_DUP_OP: //0x57 - Duplicate top of expression stack
+ opcodeName = L"EFI_IFR_DUP_OP";
+ break;
+ case EFI_IFR_THIS_OP: //0x58 - Push the current question’s value
+ opcodeName = L"EFI_IFR_THIS_OP";
+ break;
+ case EFI_IFR_SPAN_OP: //0x59 - Return first matching/non-matching character in a string
+ opcodeName = L"EFI_IFR_SPAN_OP";
+ break;
+ case EFI_IFR_VALUE_OP: //0x5A - Provide a value for a question
+ opcodeName = L"EFI_IFR_VALUE_OP";
+ break;
+ case EFI_IFR_DEFAULT_OP: //0x5B - Provide a default value for a question.
+ opcodeName = L"EFI_IFR_DEFAULT_OP";
+ break;
+ case 0x5C: //0x5C - Define a Default Type Declaration
+ opcodeName = L"EFI_IFR_DEFAULTSTORE_OP";
+ break;
+ case 0x5D: //0x5D - Create a standards-map form.
+ opcodeName = L"EFI_IFR_FORM_MAP_OP";
+ break;
+ case EFI_IFR_CATENATE_OP: //0x5E - Push concatenated buffers or strings.
+ opcodeName = L"EFI_IFR_CATENATE_OP";
+ break;
+ case EFI_IFR_GUID_OP: //0x5F - An extensible GUIDed op-code
+ opcodeName = L"EFI_IFR_GUID_OP";
+ break;
+ case 0x60: //0x60 - Returns whether current user profile contains specified setup access privileges.
+ opcodeName = L"EFI_IFR_SECURITY_OP";
+ break;
+ case 0x61: //0x61 - Specify current form is modal
+ opcodeName = L"EFI_IFR_MODAL_TAG_OP";
+ break;
+ case 0x62: //0x62 - Establish an event group for refreshing a forms-based element.
+ opcodeName = L"EFI_IFR_REFRESH_ID_OP";
+ break;
+ default:
+ opcodeName = L"Invalid Opcode";
+ validOpCode = FALSE;
+ break;
+ }
+
+ if(opHeader->OpCode == EFI_IFR_END_OP){
+ pScopeCount--;
+ count = pScopeCount;
+ }
+ while(count){
+ if(CurrentForm) SETUP_DEBUG_TSE ( " ");
+
+ count--;
+ }
+
+ if(CurrentForm) SETUP_DEBUG_TSE ( "\n\n%s, len: %d\n", opcodeName, opHeader->Length);
+
+ if(CurrentForm && questionId) SETUP_DEBUG_TSE ( "questionId: 0x%x %s \n", questionId, HiiGetString(Page->PageData.PageHandle , questionId ));
+
+ if(opHeader->Length==0)
+ {
+ //validOpCode = FALSE ;
+ goto DONE;
+ }
+
+
+ if(validOpCode){
+ UINTN index = 0, j = 0;
+ UINTN size = opHeader->Length;
+ UINT8 *temp = (UINT8 *)opHeader;
+ UINTN sCount = pScopeCount;
+
+ if(size){
+ for(index = 0; index < size; ){
+ sCount = pScopeCount;
+ while(sCount){
+ sCount--;
+ }
+
+ if(CurrentForm) SETUP_DEBUG_TSE ( "[0x%08x (%04d)] ", index, index);
+
+ for(j = 0; (j < 16) && (temp != NULL); index++, j++)
+ {
+ if(index >= size){
+ break;
+ }
+ if(CurrentForm && j==8) SETUP_DEBUG_TSE ( "- ");
+ if(CurrentForm) SETUP_DEBUG_TSE ( "%02x ", (UINT8)temp[index]);
+ }
+ if(CurrentForm)SETUP_DEBUG_TSE ("\n");
+
+ }
+ }
+ }
+
+ if(opHeader->Scope){
+ pScopeCount++;
+ }
+
+ i += opHeader->Length;
+ validOpCode = TRUE;
+ }
+
+DONE:
+ if(formSet){
+ EfiLibSafeFreePool(formSet);
+ }
+
+ pScopeCount = 0;
+
+ return status;
+}
+
+#endif //End of TSE_DEBUG_MESSAGES
+//EIP75481 Support TSE debug print infrastructure
+//EIP 80426 : START
+#define ASSERT_ERROR_STATUS(assertion) if(EFI_ERROR(assertion)) goto DONE
+#define MAX_PAGES_TO_PROCESS 50
+UINT32 gProcessedPages[MAX_PAGES_TO_PROCESS];
+UINT32 gProPageOffset = 0;
+UINT32 gCurrLoadVarIndex = 0; //Used to track which variable is getting loaded
+UINT8 *gCurrLoadVarBuf = (UINT8 *)NULL; //Used to store current variable buffer
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _GetControlInfo
+//
+// Description: Returns pointer to the CONTROL_INFO struct of given CtrlIndex
+//
+// Input: UINT32 PgIndex - Page index containing the control
+// UINT32 CtrlIndex - HII Control index
+// CONTROL_INFO **CtrlInfo - Pointer to the CONTROL_INFO structure
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetPageInfo(UINT32 PgIndex, PAGE_INFO **PageInfo);
+EFI_STATUS _GetControlInfo(UINT32 PgIndex, UINT32 CtrlIndex, CONTROL_INFO **CtrlInfo)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ if(pageInfo->PageHandle == NULL)
+ {
+ status = EFI_NOT_FOUND; //If the page handle is invalid, then page may contain incorrect control data. Return error.
+ }
+ ASSERT_ERROR_STATUS(status);
+
+ if(CtrlIndex > pageInfo->PageControls.ControlCount)
+ {
+ status = EFI_INVALID_PARAMETER;
+ goto DONE;
+ }
+
+ *CtrlInfo = (CONTROL_INFO*)((UINTN)gControlInfo + pageInfo->PageControls.ControlList[CtrlIndex]);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetNumOfControls
+//
+// Description: Get the Number of Control for a Page
+//
+// Input: IN UINT32 PgIndex
+// OUT UINT32 *numOfControls
+//
+// Output: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetNumOfControls(UINT32 PgIndex, UINT32 *NumOfControls)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *NumOfControls = pageInfo->PageControls.ControlCount;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: CleanCurrLoadVarBuffer
+//
+// Description: Cleans the temporary variables
+//
+// Input: None
+//
+// Output: VOID
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CleanCurrLoadVarBuffer()
+{
+ if(gCurrLoadVarBuf!= NULL) {
+ MemFreePointer(&gCurrLoadVarBuf);
+ }
+ gCurrLoadVarBuf = (UINT8 *)NULL;
+ gCurrLoadVarIndex = 0;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DestinationPageProcessed
+//
+// Description: Checks whether the page is already processed or not.
+//
+// Input: UINT32 PageID
+//
+// Output: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _DestinationPageProcessed(UINT32 PageID)
+{
+ BOOLEAN isProcessed = FALSE;
+ UINT32 index = 0;
+
+ for(index = 0; index < gProPageOffset; index++)
+ {
+ if(PageID == gProcessedPages[index])
+ {
+ isProcessed = TRUE;
+ break;
+ }
+ }
+ return isProcessed;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _GetDefaultNvramVariableIDList
+//
+// Description: To get the default variable names.
+//
+// Input: UINT32 FormID
+// BOOLEAN DefaultsFlag
+// BOOLEAN *ResetVal
+// BOOLEAN *ValChanged
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetDefaultNvramVariableIDList(UINT32 PageID, BOOLEAN DefaultsFlag, BOOLEAN *ResetVal, BOOLEAN *ValChanged)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT16 CtrlDataSize = 0;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ UINTN CurVarSize = 0;
+ CONTROL_INFO *ctrlInfo;
+ NVRAM_VARIABLE *nvPtr = gVariableList;
+ NVRAM_VARIABLE *defaults = gOptimalDefaults;
+ EFI_IFR_QUESTION_HEADER *questionHdr = (EFI_IFR_QUESTION_HEADER *)NULL;
+
+ gProcessedPages[gProPageOffset++] = PageID;
+
+ status = GetNumOfControls(PageID, &count);
+ ASSERT_ERROR_STATUS(status);
+
+ for(index = 0; index < count; index++)
+ {
+ //Iterating for all controls
+ status = _GetControlInfo(PageID , index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ // CONTROL_TYPE_TEXT is a special case here since its value is not
+ // in the varstore. If this is a text control, continue.
+ if(ctrlInfo->ControlType == CONTROL_TYPE_TEXT){
+ continue;
+ }
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU) || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+ if(_DestinationPageProcessed(ctrlInfo->ControlDestPageID) == FALSE)
+ {
+ status = _GetDefaultNvramVariableIDList(ctrlInfo->ControlDestPageID, DefaultsFlag, ResetVal, ValChanged);
+ ASSERT_ERROR_STATUS(status);
+ }
+ }
+ if(ctrlInfo->ControlType == CONTROL_TYPE_POPUP_STRING && DefaultsFlag)
+ {
+ UINT16 defaultToken = 0;
+ CHAR16 * defaultValue = NULL;
+
+ // First, check if the control has a default value. During parsing, the
+ // Control Data Width is set to zero if there is no default value.
+ if (ctrlInfo->ControlDataWidth == 0) {
+ continue; // move to next control if this one has no default.
+ }
+
+ // Get the Default String Id
+ defaultToken = *(UINT16*)((UINT8*)ctrlInfo + sizeof(CONTROL_INFO) + ctrlInfo->ControlDataWidth);
+ // Get the string corresponding to the StringId
+ defaultValue = HiiGetString(ctrlInfo->ControlHandle, defaultToken);
+ // Set the default value to nvPtr
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+ if(defaultValue)
+ {
+ if(EfiStrCmp(defaultValue, (CHAR16 *)&nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset]) != 0)
+ {
+ EfiStrCpy((CHAR16 *)&nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], defaultValue);
+ *ValChanged = TRUE;
+
+ if(ctrlInfo->ControlFlags.ControlReset)
+ {
+ //ControlReset reset requested.
+ *ResetVal |= ctrlInfo->ControlFlags.ControlReset;
+ }
+ }
+ }
+ continue;
+ }
+
+ if(ctrlInfo->ControlFlags.ControlEvaluateDefault)
+ {
+ UINT64 defaults = 0;
+ UINT16 size = EvaluateControlDefault(ctrlInfo, &defaults);
+
+ if(DefaultsFlag)
+ {
+ //Loading Defaults for control
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+
+ if(MemCmp((UINT8*)&nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], (UINT8*)&defaults, size) != 0)
+ {
+ //defaults and Memory value donot match. Copying defaults to memory value
+ MemCopy( &nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], &defaults, size);
+ *ValChanged = TRUE;
+
+ if(ctrlInfo->ControlFlags.ControlReset)
+ {
+ //ControlReset reset requested
+ *ResetVal |= ctrlInfo->ControlFlags.ControlReset;
+ }
+ }
+ continue;
+ }
+ }
+
+ if(DefaultsFlag) { //If loading defaults, use the data size given in CONTROL_INFO. Else get the data size using GetControlDataLength().
+ CtrlDataSize = ctrlInfo->ControlDataWidth;
+ }
+ else {
+ CtrlDataSize = (UINT16)GetControlDataLength(ctrlInfo);
+ }
+
+ if(CtrlDataSize == 0) {
+ //Control Data Width for control %s is 0\n", HiiGetString(ctrlInfo->ControlHandle, ctrlInfo->QuestionId));
+ continue;
+ }
+
+ if(ctrlInfo->ControlVariable <= gVariables->VariableCount)
+ {
+ if(DefaultsFlag == TRUE)
+ {
+ //Loading Defaults for control
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+
+ if(MemCmp((UINT8*)&nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], (UINT8*)&defaults[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], ctrlInfo->ControlDataWidth) != 0)
+ {
+ //defaults and Memory value donot match. Copying defaults to memory value
+ MemCopy( &nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], &defaults[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], ctrlInfo->ControlDataWidth);
+ *ValChanged = TRUE;
+
+ if(ctrlInfo->ControlFlags.ControlReset)
+ {
+ //ControlReset reset requested.
+ *ResetVal |= ctrlInfo->ControlFlags.ControlReset;
+ }
+ }
+ }
+ else
+ {
+ UINT8 *tempLoadVarBuff = (UINT8 *)NULL;
+
+ if(gCurrLoadVarBuf != NULL)
+ {
+ if(gCurrLoadVarIndex != ctrlInfo->ControlVariable)
+ {
+ tempLoadVarBuff = VarGetNvram( ctrlInfo->ControlVariable, &CurVarSize );
+ if(tempLoadVarBuff != NULL){
+ CleanCurrLoadVarBuffer();
+ gCurrLoadVarBuf = tempLoadVarBuff;
+ gCurrLoadVarIndex = ctrlInfo->ControlVariable;
+ }
+ }
+ }
+ else
+ {
+ tempLoadVarBuff = VarGetNvram( ctrlInfo->ControlVariable, &CurVarSize );
+ if(tempLoadVarBuff != NULL){
+ CleanCurrLoadVarBuffer();
+ gCurrLoadVarBuf = tempLoadVarBuff;
+ gCurrLoadVarIndex = ctrlInfo->ControlVariable;
+ }
+ }
+
+ if(gCurrLoadVarBuf != NULL)
+ {
+ if(tempLoadVarBuff != NULL){
+ gCurrLoadVarIndex = ctrlInfo->ControlVariable;
+ }
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+ MemCopy( &nvPtr[ctrlInfo->ControlVariable].Buffer[questionHdr->VarStoreInfo.VarOffset], &gCurrLoadVarBuf[questionHdr->VarStoreInfo.VarOffset], CtrlDataSize);
+ }
+ }
+ }
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadNvram
+//
+// Description: Intermediate function to get the nvram variables to restore.
+//
+// Parameter: UINT32 PageID
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LoadNvram(UINT32 PageID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+ gProPageOffset = 0;
+ MemSet(gProcessedPages, MAX_PAGES_TO_PROCESS * sizeof(UINT32), 0);
+ status = _GetDefaultNvramVariableIDList(PageID, FALSE, NULL, NULL);
+ ASSERT_ERROR_STATUS(status);
+
+DONE:
+ CleanCurrLoadVarBuffer();
+ return status;
+}
+//EIP 80426 : END
+
+//EIP81814 Starts
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LoadDefaults
+//
+// Description: function to load the defaults to the nvram cache
+//
+// Parameter: UINT32 FormID - form identifier
+// BOOLEAN *ResetVal - Reboot flag of the control variable
+// BOOLEAN * ValChanged - flag to check whether the value changed
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS LoadDefaults(UINT32 FormID, BOOLEAN *ResetVal, BOOLEAN * ValChanged)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 *varIDList = (UINT32*)EfiLibAllocateZeroPool(gVariables->VariableCount * sizeof(UINT32));
+
+
+ if(varIDList == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+
+ goto DONE;
+ }
+
+ gVarOffset = 0;
+// gProFormOffset = 0;
+// MemSet(gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+ CleargProcessedForms ();
+
+ //inplace of updating all the variables, update only the variables that are modified
+ //status = _GetVariableIDList(FormID, &varIDList);
+ status = _GetDefaultNvramVariableIDList(FormID, TRUE, ResetVal, ValChanged);
+ ASSERT_ERROR_STATUS(status);
+
+DONE:
+ if (varIDList) {
+ MemFreePointer(&varIDList);
+ }
+ CleanCurrLoadVarBuffer();
+
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _InconsistenceCheck
+//
+// Description: Checks if the controls in a page is inconsistent
+//
+// Input: PAGE_INFO *PgInfo - Input page info
+// UINT16 *ErrStrToken - Pointer to the output error code
+//
+// Output: BOOLEAN flag - TRUE if inconsistence, else FALSE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _InconsistenceCheck(PAGE_INFO *PgInfo, UINT16 *ErrStrToken)
+{
+ CONTROL_INFO *ctrlInfo = NULL;
+ EFI_IFR_INCONSISTENT_IF *inconsistentIf = NULL;
+ BOOLEAN flag = FALSE;
+ UINT32 i = 0;
+
+ //Find out if there is inconsistent value in any of the controls
+ for(i=0; i < PgInfo->PageControls.ControlCount; i++)
+ {
+
+ ctrlInfo = (CONTROL_INFO*)((UINTN)(gControlInfo) + PgInfo->PageControls.ControlList[i]);
+ //Check if there is a CONTROL_TYPE_MSGBOX in this page
+ if(ctrlInfo->ControlType == CONTROL_TYPE_MSGBOX)
+ {
+
+ if(CheckControlCondition(ctrlInfo) == COND_INCONSISTENT)
+ {
+
+ inconsistentIf = (EFI_IFR_INCONSISTENT_IF*)ctrlInfo->ControlConditionalPtr;
+ *ErrStrToken = inconsistentIf->Error;
+ flag = TRUE;
+ goto DONE;
+ }
+ }
+ }
+
+DONE:
+
+ return flag;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _NoSubmitCheck
+//
+// Description: Checks if the controls in a page has no submit
+//
+// Input: CONTROL_INFO *ctrlInfo - Input control info
+// UINT16 *ErrStrToken - Pointer to the output error code
+//
+// Output: BOOLEAN flag - TRUE if nosubmit, else FALSE
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _NoSubmitCheck(CONTROL_INFO *ctrlInfo, UINT16 *ErrStrToken)
+{
+ EFI_IFR_NO_SUBMIT_IF *nosubmitIf = NULL;
+ BOOLEAN flag = FALSE;
+
+
+
+ if(ctrlInfo->ControlType == CONTROL_TYPE_MSGBOX)
+ {
+
+ if(CheckControlCondition(ctrlInfo) == COND_NOSUBMIT)
+ {
+
+ nosubmitIf = (EFI_IFR_NO_SUBMIT_IF*)ctrlInfo->ControlConditionalPtr;
+ *ErrStrToken = nosubmitIf->Error;
+ flag = TRUE;
+ }
+ }
+
+
+ return flag;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetVariableIDList
+//
+// Description: function to get the list of all variables that are need to update
+//
+// Parameter: UINT32 FormID,
+// UINT32 **VarIDList
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetVariableIDList(UINT32 FormID, UINT32 **VarIDList)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ UINT32 varIndex = 0;
+ UINT32 *varPtr = NULL;
+ CONTROL_INFO *ctrlInfo;
+
+
+ if(*VarIDList == NULL || VarIDList == NULL)
+ {
+ status = EFI_INVALID_PARAMETER;
+
+ goto DONE;
+ }
+ AddEntryIngProcessedForms (FormID);
+// gProcessedForms[gProFormOffset++] = FormID;
+ status = GetNumOfControls(FormID, &count);
+ ASSERT_ERROR_STATUS(status);
+ varPtr = *VarIDList;
+ for(index = 0; index < count; index++)
+ {
+
+ status = _GetControlInfo(FormID , index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU) || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+
+ if(_DestinationFormProcessed(ctrlInfo->ControlDestPageID) == FALSE)
+ {
+
+ _GetVariableIDList(ctrlInfo->ControlDestPageID, VarIDList);
+ }
+ }
+
+ for(varIndex = 0; varIndex < gVariables->VariableCount; varIndex++)
+ {
+
+ if(varPtr[varIndex] == ctrlInfo->ControlVariable)
+ {
+
+ break;
+ }
+ }
+ if(varIndex == gVariables->VariableCount)
+ {
+
+ varPtr[gVarOffset++] = ctrlInfo->ControlVariable;
+ }
+ }
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: _DestinationFormProcessed
+//
+// Description: Is this form Processed
+//
+// Parameter: IN UINT32 FormID
+//
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN _DestinationFormProcessed(UINT32 FormID)
+{
+ BOOLEAN isProcessed = FALSE;
+ UINT32 index = 0;
+
+
+ for(index = 0; index < gProFormOffset; index++)
+ {
+
+ if(FormID == gProcessedForms[index])
+ {
+
+ isProcessed = TRUE;
+ break;
+ }
+ }
+
+ return isProcessed;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsNoSubmitOfForms
+//
+// Description: Is this formset or form has the no submit if
+//
+// Parameter: IN UINT32 FormID
+// OUT UINT16* ErrToken
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsNoSubmitOfForms(UINT32 FormID, UINT16* ErrToken)
+{
+ BOOLEAN flag = FALSE;
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ CONTROL_INFO *ctrlInfo;
+
+
+// gProcessedForms[gProFormOffset++] = FormID;
+ AddEntryIngProcessedForms (FormID);
+
+ status = GetNumOfControls(FormID, &count);
+ ASSERT_ERROR_STATUS(status);
+
+ for(index = 0; index < count; index++)
+ {
+
+ status = _GetControlInfo(FormID, index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU)//If submenu traverse recursively through the sub forms
+ || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+
+ if(_DestinationFormProcessed(ctrlInfo->ControlDestPageID) == FALSE)//If the form has not be processed already
+ {
+ flag = IsNoSubmitOfForms(ctrlInfo->ControlDestPageID, ErrToken);
+ if(flag)
+ {
+ break;
+ }
+ }
+ }
+ if(_NoSubmitCheck(ctrlInfo, ErrToken) == TRUE)//if the control is no submit if
+ {
+ flag = TRUE;
+ break;
+ }
+ }//end of for loop of controls
+
+DONE:
+
+ return flag;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CheckforNosubmitIf
+//
+// Description: Check for no submit if
+//
+// Parameter: UINT32 FormID, BOOLEAN Recursive, UINT16 *ErrToken
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS CheckforNosubmitIf(UINT32 FormID, BOOLEAN Recursive, UINT16 *ErrToken)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN flag = FALSE;
+
+ if(Recursive)//To check all the forms in the formset
+ {
+// gProFormOffset = 0;
+// MemSet(gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+ CleargProcessedForms ();
+ flag = IsNoSubmitOfForms(FormID,ErrToken);
+ }
+ else//for single form ID
+ {
+ PAGE_INFO *PgInfo = NULL;
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 i = 0;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetPageInfo(FormID, &PgInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ for(i=0; i < PgInfo->PageControls.ControlCount; i++)
+ {
+
+ ctrlInfo = (CONTROL_INFO*)((UINTN)(gControlInfo) + PgInfo->PageControls.ControlList[i]);
+ if(_NoSubmitCheck(ctrlInfo, ErrToken) == TRUE)
+ {
+ flag = TRUE;
+ break;
+ }
+ }
+ }
+
+ if(flag)
+ {
+ status = EFI_NOSUBMIT_VALUE;
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: _GetControlFlag
+//
+// Description: Gets attribute flag for a given CtrlIndex in a page
+//
+// Input: UINT32 PgIndex - Page index containing the control
+// UINT32 CtrlIndex - Control index
+// CONTROL_FLAGS **CtrlFlag - Pointer to the flag attribute structure
+//
+// Output: EFI_STATUS status - EFI_SUCCESS if successful, else EFI_ERROR
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetControlFlag(UINT32 PgIndex, UINT32 CtrlIndex, CONTROL_FLAGS **CtrlFlag)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlFlag = &ctrlInfo->ControlFlags;
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetNumOfPages
+//
+// Description: Get the Total Number of HII Form Pages to display
+//
+// Parameter: OUT UINT32 *numOfPages
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_OUT_OF_RESOURCES
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetNumOfPages(UINT32 *NumOfPages)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+
+
+ if(LibInitialized == FALSE)
+ {
+ status = EFI_NOT_READY;
+
+ goto DONE;
+ }
+
+ *NumOfPages = gPages->PageCount;
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageTitle
+//
+// Description: Get the Page Title String Index
+//
+// Parameter: IN UINT32 PgIndex
+// OUT UINT16 *titleToken
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageTitle(UINT32 PgIndex, UINT16 *TitleToken)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *TitleToken = pageInfo->PageTitle;
+
+DONE:
+ return status;
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageHandle
+//
+// Description: Get the Handle for the Page
+//
+// Parameter: IN UINTN PgIndex
+// OUT EFI_HII_HANDLE *handle
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageHandle(UINT32 PgIndex, EFI_HII_HANDLE *Handle)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *Handle = pageInfo->PageHandle;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageIdIndex
+//
+// Description: Get the page ID index for the Page
+//
+// Parameter: IN UINTN PgIndex
+// OUT UINT16 *PgIdIndex
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageIdIndex(UINT32 PgIndex, UINT16 *PgIdIndex)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *PgIdIndex = pageInfo->PageIdIndex;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsParentPage
+//
+// Description: Is this page a parent page
+//
+// Parameter: IN UINT32 PgIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsParentPage(UINT32 PgIndex)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN isTrue = FALSE;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+ isTrue = pageInfo->PageParentID == 0? TRUE : FALSE;
+
+DONE:
+ return isTrue;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageHiiId
+//
+// Description: Get the Page Title String Index
+//
+// Parameter: IN UINT32 PgIndex
+// OUT UINT16 *PageId
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageHiiId(UINT32 PgIndex, UINT16 *PageId)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *PageId = pageInfo->PageFormID;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetPageParentId
+//
+// Description: Get the parent page ID from the page index
+//
+// Parameter: IN UINT32 PgIndex - Current page Index/ID
+// OUT UINT16 *PageParentId - Parent page ID
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageParentId(UINT32 PgIndex, UINT16 *PageParentId)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *PageParentId = pageInfo->PageParentID;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//---------------------------------------------------------------------------
+// Procedure: GetCtrlsDestCtrlId
+//
+// Description: Returns the QuestionID to select in the destination page
+//
+// Input: UINT32 PgIndex - ASL page ID
+// UINT32 CtrlIndex - Control index, Lib control ID
+// UINT16 *DestCtrlId - Destination control index
+//
+// Output: EFI_STATUS status
+//---------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetCtrlsDestCtrlId(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *DestCtrlId)
+{
+ EFI_STATUS status = EFI_NOT_FOUND;
+ CONTROL_INFO *ctrlInfo = (CONTROL_INFO *)NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *DestCtrlId = ctrlInfo->DestQuestionID;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlType
+//
+// Description: Get the AMI Control Type
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINT16 *ctrlType
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlType(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlType)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlType = ctrlInfo->ControlType;
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlQuestionPrompt
+//
+// Description: Get the Control Question Prompt's String Id
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINT16 *ctrlPrompt
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlQuestionPrompt(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlPrompt)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlPrompt = ctrlInfo->QuestionId;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlHelpStr
+//
+// Description: Get the Control Help String ID
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINT16 *ctrlHelp
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlHelpStr(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlHelp)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlHelp = ctrlInfo->ControlHelp;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: _GetCheckBoxOptions
+//
+// Description: Get the List of Options for the Checkbox Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINTN *optionCount
+// OUT OPTION_LIST *optionArray
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS _GetCheckBoxOptions(CONTROL_INFO *CtrlInfo, UINT32 *OptionCount, OPTION_LIST **OptionArray)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ OPTION_LIST *optList = NULL;
+ OPTION_LIST *temp = NULL;
+ EFI_IFR_CHECKBOX *checkBoxOp = (EFI_IFR_CHECKBOX*)(CtrlInfo->ControlPtr);
+ UINT32 index = 0;
+
+ *OptionCount = CHECKBOX_OPTION_COUNT;
+ for(index = 0; index < *OptionCount; index++)
+ {
+
+ temp = (OPTION_LIST*)EfiLibAllocateZeroPool(sizeof(OPTION_LIST));
+ if(temp == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+
+ goto DONE;
+ }
+
+ if(*OptionArray == NULL)
+ {
+
+ *OptionArray = temp;
+ }else
+ {
+
+ if(optList){
+ optList->Next = temp;
+ }
+ }
+ optList = temp;
+
+ // Option will be set In the Application
+ temp->Option = 0;
+ temp->Value = index;
+ temp->Flag = ((checkBoxOp->Flags & EFI_IFR_CHECKBOX_DEFAULT) == EFI_IFR_CHECKBOX_DEFAULT)? OPTION_DEFAULT : 0;
+ temp->Flag = ((checkBoxOp->Flags & EFI_IFR_CHECKBOX_DEFAULT_MFG) == EFI_IFR_CHECKBOX_DEFAULT_MFG)? OPTION_DEFAULT_MFG : 0;
+ temp->Next = NULL;
+ }
+
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsControlCheckBox
+//
+// Description: Check if the control is a check box
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsControlCheckBox(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ BOOLEAN isCheckBox = FALSE;
+ CONTROL_INFO *ctrlInfo = NULL;
+ EFI_IFR_OP_HEADER *opHeader = NULL;
+
+ _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+
+ opHeader = (EFI_IFR_OP_HEADER*)ctrlInfo->ControlPtr;
+ isCheckBox = (opHeader->OpCode == EFI_IFR_CHECKBOX_OP)? TRUE : FALSE;
+
+ return isCheckBox;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlDataWidth
+//
+// Description: Get the Data size
+//
+// Parameter: UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *controlWidth
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlDataWidth(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlWidth)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlWidth = (UINT16)GetControlDataLength(ctrlInfo)/*ctrlInfo->ControlDataWidth*/;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlDestinationPage
+//
+// Description:
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINT16 *ctrlDestPg
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlDestinationPage(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *CtrlDestPg)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *CtrlDestPg = ctrlInfo->ControlDestPageID;
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlAccess
+//
+// Description: Get the Control Access Specifier for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 GetControlAccess(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = NULL;
+
+ _GetControlFlag(PgIndex, CtrlIndex, &flags);
+
+ return (UINT8)flags->ControlAccess;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlRefresh
+//
+// Description: Get the Control Refresh for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: UINT8
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 GetControlRefresh(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = NULL;
+
+ _GetControlFlag(PgIndex, CtrlIndex, &flags);
+
+ return (UINT8)flags->ControlRefresh;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsControlVisible
+//
+// Description: Get the Control Visiblity for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsControlVisible(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = NULL;
+
+ _GetControlFlag(PgIndex, CtrlIndex, &flags);
+
+ return (BOOLEAN)flags->ControlVisible;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsControlResetRequired
+//
+// Description: Get the Control Reset status for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsControlResetRequired(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = NULL;
+
+ _GetControlFlag(PgIndex, CtrlIndex, &flags);
+
+ return (BOOLEAN)flags->ControlReset;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsControlReadOnly
+//
+// Description: Get the Control Readonly Specifier for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsControlReadOnly(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = NULL;
+
+ _GetControlFlag(PgIndex, CtrlIndex, &flags);
+
+ return (BOOLEAN)flags->ControlReadOnly;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: IsControlInteractive
+//
+// Description: Get the Control Interactive Specifier for a Control
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: EFI_STATUS
+// BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsControlInteractive(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ CONTROL_FLAGS *flags = (CONTROL_FLAGS *)NULL;
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN isInteractive = FALSE;
+
+ status = _GetControlFlag(PgIndex, CtrlIndex, &flags);
+ ASSERT_ERROR_STATUS(status);
+
+ if(flags != NULL){
+ isInteractive = (BOOLEAN)flags->ControlInteractive;
+ }
+
+DONE:
+ return isInteractive;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: EvaluateControlCondition
+//
+// Description: Evaluate control HII expression and return display Result
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINTN *expResult
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS EvaluateControlCondition(UINT32 PgIndex, UINT32 CtrlIndex, UINTN *ExpResult)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *ExpResult = CheckControlCondition(ctrlInfo);
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetQuestionValue
+//
+// Description: Get the Question Value
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// OUT UINT8 *Value
+// OUT UINTN *ValueSize
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+// EFI_OUT_OF_RESOURCES
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetQuestionValue(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 **Value, UINTN *ValueSize)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *ValueSize = GetControlDataLength(ctrlInfo);
+ *Value = (UINT8*)EfiLibAllocateZeroPool(*ValueSize);
+ if(*Value == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+
+ goto DONE;
+ }
+
+ if(ctrlInfo->ControlType == CONTROL_TYPE_TEXT)
+ {
+ UINT16 textTwo = ((EFI_IFR_TEXT*)(ctrlInfo->ControlPtr))->TextTwo;
+
+ MemCopy(*Value, &textTwo, *ValueSize);
+ goto DONE;
+ }
+
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+ status = VarGetValue(ctrlInfo->ControlVariable, questionHdr->VarStoreInfo.VarOffset, *ValueSize, Value);
+ ASSERT_ERROR_STATUS(status);
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SetQuestionValue
+//
+// Description: Set the Value for a Question
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// IN UINT8 *Value
+// IN UINTN ValueSize
+// OUT UINT16 *ErrStrToken
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SetQuestionValue(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 *Value, UINTN ValueSize, UINT16 *ErrStrToken)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_IFR_QUESTION_HEADER *questionHdr = NULL;
+ CONTROL_INFO *ctrlInfo = NULL;
+ PAGE_INFO *pgInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ questionHdr = (EFI_IFR_QUESTION_HEADER*)((UINT8*)ctrlInfo->ControlPtr + sizeof(EFI_IFR_OP_HEADER));
+ status = VarSetValue(ctrlInfo->ControlVariable, questionHdr->VarStoreInfo.VarOffset, ValueSize, Value);
+ ASSERT_ERROR_STATUS(status);
+
+ status = _GetPageInfo(PgIndex, &pgInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if(_InconsistenceCheck(pgInfo, ErrStrToken) == TRUE)
+ {
+
+ status = EFI_INCONSISTENT_VALUE;
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: SaveQuestionValues
+//
+// Description: Save all the values to the system
+//
+// Parameter: VOID
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS SaveQuestionValues(UINT32 FormID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ EFI_STATUS tempStatus = EFI_SUCCESS;
+ NVRAM_VARIABLE *nvPtr;
+ UINT32 i = 0;
+ UINT32 *varIDList = (UINT32*)EfiLibAllocateZeroPool(gVariables->VariableCount * sizeof(UINT32));
+
+ if(varIDList == NULL)
+ {
+ status = EFI_OUT_OF_RESOURCES;
+
+ goto DONE;
+ }
+
+ nvPtr = gVariableList;
+ gVarOffset = 0;
+// gProFormOffset = 0;
+// MemSet(gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+ CleargProcessedForms ();
+ status = _GetVariableIDList(FormID, &varIDList);
+ ASSERT_ERROR_STATUS(status);
+ for ( i = 0; i < gVariables->VariableCount; i++)
+ {
+
+ if(nvPtr[varIDList[i]].Buffer == NULL)
+ {
+
+ continue;
+ }
+ tempStatus = VarSetNvram(varIDList[i], nvPtr[varIDList[i]].Buffer, nvPtr[varIDList[i]].Size);
+ if(EFI_ERROR(tempStatus))
+ {
+ status = tempStatus;
+ }
+ }
+
+DONE:
+ if (varIDList) {
+ MemFreePointer(&varIDList);
+ }
+
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: FreeOptionList
+//
+// Description:
+//
+// Parameter: OPTION_LIST *OptionArray
+//
+// Return Value: VOID
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID FreeOptionList(OPTION_LIST *OptionArray)
+{
+ OPTION_LIST *optList = OptionArray;
+
+ do
+ {
+ optList = OptionArray;
+ OptionArray = OptionArray->Next;
+ if(optList)
+ {
+ MemFreePointer(&optList);
+ }
+ }while(OptionArray);
+
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlDisplayFormat
+//
+// Description:
+//
+// Parameter: UINT32 PgIndex
+// UINT32 CtrlIndex
+// UINT16 *Format
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlDisplayFormat(UINT32 PgIndex, UINT32 CtrlIndex, UINT16 *Format)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+ if(ctrlInfo->ControlType == CONTROL_TYPE_NUMERIC)
+ {
+
+ *Format = ((EFI_IFR_NUMERIC*)ctrlInfo->ControlPtr)->Flags & EFI_IFR_DISPLAY;
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlMinMax
+//
+// Description:
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// UINT64 *Min
+// UINT64 *Max
+//
+// Return Value: EFI_STATUS
+// EFI_SUCCESS
+// EFI_NOT_READY
+// EFI_INVALID_PARAMETER
+// EFI_OUT_OF_RESOURCES
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlMinMax(UINT32 PgIndex, UINT32 CtrlIndex, UINT64 *Min, UINT64 *Max)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ switch(ctrlInfo->ControlType)
+ {
+ case CONTROL_TYPE_NUMERIC:
+ case CONTROL_TYPE_PASSWORD:
+ case CONTROL_TYPE_POPUP_STRING:
+
+ *Min = UefiGetMinValue(ctrlInfo->ControlPtr);
+ *Max = UefiGetMaxValue(ctrlInfo->ControlPtr);
+ break;
+ default:
+
+ break;
+ }
+
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetControlDefault
+//
+// Description:
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+// UINT64 *Def
+// BOOLEAN Optimal
+//
+// Return Value: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetControlDefault(UINT32 PgIndex, UINT32 CtrlIndex,UINT8 *Def, BOOLEAN Optimal)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+
+ if(Def == NULL)
+ {
+ status = EFI_INVALID_PARAMETER;
+
+ goto DONE;
+ }
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ switch(ctrlInfo->ControlDataWidth)
+ {
+ /*
+ * ctrlInfo[sizeof(ctrlInfo)]
+ * Used when user selects load Optimal value
+ *
+ * ctrlInfo[sizeof(ctrlInfo) + valSize]
+ * Used when user selects load optimal value
+ */
+ case 1: // BYTE
+
+ *Def = Optimal? *((UINT8 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo))) :
+ *((UINT8 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo) + ctrlInfo->ControlDataWidth));
+ break;
+ case 2: //WORD
+
+ *((UINT16*)Def) = Optimal? *((UINT16 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo))) :
+ *((UINT16 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo) + ctrlInfo->ControlDataWidth));
+ break;
+ case 4: //DWORD
+
+ *((UINT32*)Def) = Optimal? *((UINT32 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo))) :
+ *((UINT32 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo) + ctrlInfo->ControlDataWidth));
+ break;
+ case 8: //QWORD
+
+ *((UINT64*)Def) = Optimal? *((UINT64 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo))) :
+ *((UINT64 *) ((UINT8 *)ctrlInfo + sizeof(*ctrlInfo) + ctrlInfo->ControlDataWidth));
+ break;
+ default:
+ break;
+ }
+
+DONE:
+
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetOrderedListMaxEntries
+//
+// Description: Create a Timer Event
+//
+// Input: UINT32 PgIndex, UINT32 CtrlIndex, UINT8 *MaxEntry
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetOrderedListMaxEntries(UINT32 PgIndex, UINT32 CtrlIndex, UINT8 *MaxEntry)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ CONTROL_INFO *ctrlInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ *MaxEntry = 0;
+ if(ctrlInfo->ControlType == CONTROL_TYPE_ORDERED_LIST)
+ {
+ *MaxEntry = UefiGetMaxEntries(ctrlInfo->ControlPtr);
+ }
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetOrderedListOptionDataWidth
+//
+// Description: Gets OrderedList Data Width
+//
+// Parameter: CONTROL_INFO *ControlInfo, UINT32 *DataWidth
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetOrderedListOptionDataWidth(CONTROL_INFO *ControlInfo, UINT32 *DataWidth)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ EFI_IFR_OP_HEADER *OpHeader = NULL;
+ EFI_IFR_ONE_OF_OPTION *OneOfOptionOp = NULL;
+
+ OpHeader = (EFI_IFR_OP_HEADER*)ControlInfo->ControlPtr;
+
+ if(OpHeader->OpCode != EFI_IFR_ORDERED_LIST_OP)
+ {
+ Status = EFI_UNSUPPORTED;
+ goto DONE;
+ }
+
+ do
+ {
+ OpHeader = (EFI_IFR_OP_HEADER*)((UINT8*)ControlInfo->ControlPtr + OpHeader->Length);
+ }while(OpHeader->OpCode != EFI_IFR_ONE_OF_OPTION_OP);
+
+ OneOfOptionOp = (EFI_IFR_ONE_OF_OPTION*)OpHeader;
+
+ switch(OneOfOptionOp->Type)
+ {
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ *DataWidth = sizeof(UINT16);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ *DataWidth = sizeof(UINT32);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ *DataWidth = sizeof(UINT64);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ default:
+ *DataWidth = sizeof(UINT8);
+ break;
+ }
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetOrderedListDataTypeWidth
+//
+// Description: Gets OrderedList DataType Width
+//
+// Parameter: UINT32 PgIndex, UINT32 CtrlIndex, UINT32 *DataWidth
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetOrderedListDataTypeWidth(UINT32 PgIndex, UINT32 CtrlIndex, UINT32 *DataWidth)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ CONTROL_INFO *CtrlInfo = NULL;
+
+ Status = _GetControlInfo(PgIndex, CtrlIndex, &CtrlInfo);
+ if(EFI_ERROR(Status))
+ {
+ goto DONE;
+ }
+
+ Status = GetOrderedListOptionDataWidth(CtrlInfo, DataWidth);
+
+DONE:
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsPageRefreshable
+//
+// Description: Is this page can be refreshable
+//
+// Parameter: IN UINT32 PgIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsPageRefreshable(UINT32 PgIndex)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN isTrue = FALSE;
+ PAGE_INFO *pageInfo = NULL;
+
+ status = _GetPageInfo(PgIndex, &pageInfo);
+ ASSERT_ERROR_STATUS(status);
+ isTrue = pageInfo->PageFlags.PageRefresh ? TRUE : FALSE;
+
+DONE:
+ return isTrue;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IfNoCommitVariable
+//
+// Description: Is this a no commit variable
+//
+// Parameter: IN UINT32 PgIndex
+// IN UINT32 CtrlIndex
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IfNoCommitVariable(UINT32 PgIndex, UINT32 CtrlIndex)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ BOOLEAN isTrue = FALSE;
+ CONTROL_INFO *CtrlInfo = NULL;
+ VARIABLE_INFO *varInfo = NULL;
+
+ status = _GetControlInfo(PgIndex, CtrlIndex, &CtrlInfo);
+ ASSERT_ERROR_STATUS(status);
+ varInfo = VarGetVariableInfoIndex(CtrlInfo->ControlVariable);
+ if((varInfo != NULL) && (varInfo->ExtendedAttibutes /*& AMI_SPECIAL_NO_COMMIT_VARIABLE*/)){ //If the variable is valid and set to NO_COMMIT
+ isTrue = TRUE;
+ }
+DONE:
+ return isTrue;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IdentifyFormHasDefault
+//
+// Description: Is this formset has the default set
+//
+// Parameter: IN UINT32 FormID
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IdentifyFormHasDefault(UINT32 FormID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ CONTROL_INFO *ctrlInfo;
+ BOOLEAN isDefault = FALSE;
+
+// gProcessedForms[gProFormOffset++] = FormID;
+ AddEntryIngProcessedForms (FormID);
+
+ status = GetNumOfControls(FormID, &count);
+ ASSERT_ERROR_STATUS(status);
+
+ for(index = 0; index < count; index++)
+ {
+
+ status = _GetControlInfo(FormID, index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU)//If submenu traverse recursively through the sub forms
+ || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+
+ if(_DestinationFormProcessed(ctrlInfo->ControlDestPageID) == FALSE)//If the form has not be processed already
+ {
+ isDefault = IdentifyFormHasDefault(ctrlInfo->ControlDestPageID);
+ if(isDefault)
+ {
+ break;
+ }
+ }
+ }
+
+ if(ctrlInfo->ControlType == CONTROL_TYPE_CHECKBOX || //Check for the control is checkbox
+ ctrlInfo->ControlFlags.ControlEvaluateDefault || //or if the control has the Evaluate default bit set
+ ctrlInfo->ControlDataWidth) // or if the ControlDataWidth is set to the size of the defaults
+ {
+ isDefault = TRUE;
+ break;
+ }
+ }//end of for loop of controls
+
+DONE:
+ return isDefault;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsFormsetHasDefault
+//
+// Description: Is this formset has the default set
+//
+// Parameter: IN UINT32 FormID
+//
+// Return Value: BOOLEAN
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsFormsetHasDefault(UINT32 FormID)
+{
+ BOOLEAN isDefault = FALSE;
+
+// gProFormOffset = 0;
+// MemSet(gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+ CleargProcessedForms ();
+ isDefault = IdentifyFormHasDefault(FormID);
+
+ return isDefault;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetPageGuidFromFormId
+//
+// Description: To get the form GUID from the page index
+//
+// Input: UINT32 PgIndex
+// EFI_GUID *FormGuid
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetPageGuidFromPgIndex(UINT32 PgIndex, EFI_GUID *FormGuid)
+{
+ EFI_STATUS status = EFI_INVALID_PARAMETER;
+ PAGE_INFO *pgInfo = (PAGE_INFO *)NULL;
+ PAGE_ID_INFO *pageIdInfo = (PAGE_ID_INFO*)NULL;
+
+ status = _GetPageInfo(PgIndex, &pgInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if(gPages && gPageIdList && pgInfo)
+ {
+ pageIdInfo = (PAGE_ID_INFO *)(((UINT8 *) gPageIdList) + gPageIdList->PageIdList[pgInfo->PageIdIndex]);
+ if(pageIdInfo)
+ {
+ MemCopy(FormGuid, &pageIdInfo->PageGuid, sizeof(EFI_GUID));
+ }
+ }
+
+DONE:
+ return status;
+}
+//EIP81814 Ends
+
+//EIP 86885 Starts
+//<AMI_PHDR_START>
+//--------------------------------------------------------------------------------------
+// Procedure: UefiVarsetnvramforCurrentform
+//
+// Description: Save the values for the passed pageID
+// If this function is not called as part of browser action then it is
+// caller responsibility to reset the gProFormOffset and gProcessedForms
+// gProFormOffset = 0;
+// MemSet (gProcessedForms, MAX_FORMS_TO_PROCESS, 0);
+//
+// Input: UINT32 - page ID to save the values
+//
+// Output: EFI_STATUS - Status of the operation
+//--------------------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiVarsetnvramforCurrentform (UINT32 FormID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ CONTROL_INFO *ctrlInfo;
+ UINT8 *tempLoadVarBuff = (UINT8 *)NULL;
+ UINT8 *CurrentValue = NULL;
+ UINTN CurVarSize = 0;
+ UINT32 size = 0;
+ UINT32 offset = 0;
+ VARIABLE_INFO *varInfo = (VARIABLE_INFO *)NULL;
+
+// gProcessedForms [gProFormOffset++] = FormID;
+ AddEntryIngProcessedForms (FormID);
+
+ status = GetNumOfControls (FormID, &count);
+ ASSERT_ERROR_STATUS (status);
+
+ for(index = 0; index < count; index++)
+ {
+ status = _GetControlInfo(FormID , index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if (NULL == ctrlInfo->ControlPtr) //EIP-Setup crashes when clicking Discard and Exit goto control in simulator
+ continue;
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU) || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+ if(_DestinationFormProcessed(ctrlInfo->ControlDestPageID) == FALSE)
+ {
+ UefiVarsetnvramforCurrentform(ctrlInfo->ControlDestPageID);
+ }
+ continue;
+ }
+ tempLoadVarBuff = VarGetNvram( ctrlInfo->ControlVariable, &CurVarSize );
+ if (NULL == tempLoadVarBuff)
+ {
+ continue;
+ }
+ offset = UefiGetQuestionOffset (ctrlInfo->ControlPtr);
+ if(CONTROL_TYPE_ORDERED_LIST == ctrlInfo->ControlType)
+ {
+ UINTN Type = 0;
+ UefiGetValidOptionType (ctrlInfo, &Type, &size);
+ size = (UefiGetMaxEntries (ctrlInfo->ControlPtr)) * size;
+ }
+ else
+ {
+ size = UefiGetWidth(ctrlInfo->ControlPtr);
+ }
+ if (0 == size)
+ {
+ continue;
+ }
+ CurrentValue = EfiLibAllocateZeroPool(size);
+ if(CurrentValue == NULL)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ status = VarGetValue(ctrlInfo->ControlVariable, offset, size, CurrentValue );
+ if (!EFI_ERROR (status))
+ {
+ MemCopy ( tempLoadVarBuff+offset, CurrentValue, size );
+
+ varInfo = VarGetVariableInfoIndex (ctrlInfo->ControlVariable);
+ if(varInfo == NULL)
+ {
+ continue;
+ }
+
+ if((varInfo->ExtendedAttibutes & AMI_SPECIAL_VARIABLE_NO_SET) == AMI_SPECIAL_VARIABLE_NO_SET)
+ {
+ // Don't save the variable
+ continue;
+ }
+ else
+ {
+ if(UefiIsEfiVariable(ctrlInfo->ControlVariable, varInfo))
+ {
+ VarSetNvramName( varInfo->VariableName, &varInfo->VariableGuid, varInfo->VariableAttributes, tempLoadVarBuff, CurVarSize );
+ }
+ else
+ {
+ UefiVarSetNvram(varInfo, tempLoadVarBuff, VAR_ZERO_OFFSET, CurVarSize);
+ }
+ }
+ }
+ MemFreePointer ((VOID **)&tempLoadVarBuff);
+ MemFreePointer ((VOID **)&CurrentValue);
+ }
+DONE:
+ return status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UefiLoadPreviousValuesforCurrentform
+//
+// Description: Loads previous value for the current form
+//
+// Input: FormID - Current page ID
+//
+// Output: EFI_STATUS
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS UefiLoadPreviousValuesforCurrentform(UINT32 FormID)
+{
+ EFI_STATUS status = EFI_SUCCESS;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ CONTROL_INFO *ctrlInfo;
+ UINT8 *tempLoadVarBuff = (UINT8 *)NULL;
+ UINT8 *CurrentValue = NULL;
+ UINTN CurVarSize = 0;
+ UINT32 size = 0;
+ UINT32 offset = 0;
+
+// gProcessedForms [gProFormOffset++] = FormID;
+ AddEntryIngProcessedForms (FormID);
+
+ status = GetNumOfControls (FormID, &count);
+ ASSERT_ERROR_STATUS (status);
+
+ for(index = 0; index < count; index++)
+ {
+ status = _GetControlInfo(FormID , index, &ctrlInfo);
+ ASSERT_ERROR_STATUS(status);
+
+ if (NULL == ctrlInfo->ControlPtr) //EIP-126997 Avoid setup crash
+ continue;
+
+ if((ctrlInfo->ControlType == CONTROL_TYPE_SUBMENU) || (ctrlInfo->ControlType == CONTROL_TYPE_REF2))
+ {
+ if(_DestinationFormProcessed(ctrlInfo->ControlDestPageID) == FALSE)
+ {
+ UefiVarsetnvramforCurrentform(ctrlInfo->ControlDestPageID);
+ }
+ }
+ tempLoadVarBuff = VarGetNvram (ctrlInfo->ControlVariable, &CurVarSize);
+ if (NULL == tempLoadVarBuff)
+ {
+ continue;
+ }
+ offset = UefiGetQuestionOffset (ctrlInfo->ControlPtr);
+ if (CONTROL_TYPE_ORDERED_LIST == ctrlInfo->ControlType)
+ {
+ UINTN Type = 0;
+ UefiGetValidOptionType (ctrlInfo, &Type, &size);
+ size = (UefiGetMaxEntries (ctrlInfo->ControlPtr)) * size;
+ }
+ else
+ {
+ size = UefiGetWidth (ctrlInfo->ControlPtr);
+ }
+ CurrentValue = EfiLibAllocateZeroPool(size);
+ if(CurrentValue == NULL)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ status = VarGetValue (ctrlInfo->ControlVariable, offset, size, CurrentValue);
+ if (!EFI_ERROR (status))
+ {
+ MemCopy (gVariableList [ctrlInfo->ControlVariable].Buffer + offset, tempLoadVarBuff + offset, size);
+ }
+ MemFreePointer ((VOID **)&tempLoadVarBuff);
+ MemFreePointer ((VOID **)&CurrentValue);
+ }
+DONE:
+ return status;
+}
+//EIP 86885 Ends
+
+///////////////EIP 162180 Starts//////////////////////////
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CleargProcessedForms
+//
+// Description: Clears gProcessedForms data
+//
+// Input: void
+//
+// Output: void
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void CleargProcessedForms (void)
+{
+ gProFormOffset = 0;
+ MemSet(gProcessedForms, (gProFormOffsetAllocCount * sizeof (UINT32)), 0);
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddEntryIngProcessedForms
+//
+// Description: Adds the formid in gProcessedForms
+//
+// Input: UINT32 FormID
+//
+// Output: void
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+void AddEntryIngProcessedForms (UINT32 FormID)
+{
+ if (gProFormOffset >= gProFormOffsetAllocCount) //Check if enough size has been already allocated
+ {
+ gProcessedForms = MemReallocateZeroPool (gProcessedForms, gProFormOffsetAllocCount * sizeof (UINT32), (gProFormOffsetAllocCount + MAX_FORMS_TO_PROCESS) * sizeof (UINT32));
+ if (NULL == gProcessedForms)
+ {
+ return;
+ }
+ gProFormOffsetAllocCount += MAX_FORMS_TO_PROCESS;
+ }
+ gProcessedForms [gProFormOffset++] = FormID;
+}
+///////////////EIP 162180 Ends//////////////////////////
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2013, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/EDK/MiniSetup/uefi2.1/UefiTianoHii.h b/EDK/MiniSetup/uefi2.1/UefiTianoHii.h
new file mode 100644
index 0000000..4978f3f
--- /dev/null
+++ b/EDK/MiniSetup/uefi2.1/UefiTianoHii.h
@@ -0,0 +1,241 @@
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//**********************************************************************
+// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/UefiTianoHii.h $
+//
+// $Author: Arunsb $
+//
+// $Revision: 3 $
+//
+// $Date: 10/18/12 6:04a $
+//
+//*****************************************************************//
+//*****************************************************************//
+// Revision History
+// ----------------
+// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/UefiTianoHii.h $
+//
+// 3 10/18/12 6:04a Arunsb
+// Updated for 2.16.1235 QA submission
+//
+// 4 10/10/12 12:41p Arunsb
+// Synched the source for v2.16.1232, backup with Aptio
+//
+// 2 4/16/10 5:13p Madhans
+// Changes for Tse 2.02. Please see Changelog.log for more details.
+//
+// 2 3/11/10 5:44p Madhans
+// Coding Standards Update
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//
+// Name: UefiTianoHii.h
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//****************************************************************//
+
+
+//----------------------------------------------------------------------------
+#ifndef _TIANO_HII_H_
+#define _TIANO_HII_H_
+
+#include "TseUefiHii.h"
+
+#define NARROW_CHAR 0xFFF0
+#define WIDE_CHAR 0xFFF1
+#define NON_BREAKING_CHAR 0xFFF2
+
+//
+// State defined for password statemachine
+//
+#define BROWSER_STATE_VALIDATE_PASSWORD 0
+#define BROWSER_STATE_SET_PASSWORD 1
+
+//
+// References to string tokens must use this macro to enable scanning for
+// token usages.
+//
+#define STRING_TOKEN(t) t
+
+//
+// GUIDed opcodes defined for Tiano
+//
+#define EFI_IFR_TIANO_GUID \
+ { 0xf0b1735, 0x87a0, 0x4193, 0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }
+
+//----------------------------------------------------------------------------
+
+
+#pragma pack(1)
+
+
+//----------------------------------------------------------------------------
+
+#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
+
+//----------------------------------------------------------------------------
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_IFR_GUID_LABEL
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Header EFI_IFR_OP_HEADER
+// Guid EFI_GUID
+// ExtendOpCode UINT8
+// Number UINT16
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_IFR_GUID_LABEL {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 Number;
+} EFI_IFR_GUID_LABEL;
+
+//----------------------------------------------------------------------------
+
+#define EFI_IFR_BANNER_ALIGN_LEFT 0
+#define EFI_IFR_BANNER_ALIGN_CENTER 1
+#define EFI_IFR_BANNER_ALIGN_RIGHT 2
+
+//----------------------------------------------------------------------------
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_IFR_GUID_BANNER
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Header EFI_IFR_OP_HEADER
+// Guid EFI_GUID
+// ExtendOpCode UINT8
+// Title EFI_STRING_ID
+// LineNumber UINT16
+// Alignment UINT8
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_IFR_GUID_BANNER {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode; // Extended opcode is EFI_IFR_EXTEND_OP_BANNER
+ EFI_STRING_ID Title; // The string token for the banner title
+ UINT16 LineNumber; // 1-based line number
+ UINT8 Alignment; // left, center, or right-aligned
+} EFI_IFR_GUID_BANNER;
+
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_IFR_GUID_TIMEOUT
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Header EFI_IFR_OP_HEADER
+// Guid EFI_GUID
+// ExtendOpCode UINT8
+// TimeOut UINT16
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_IFR_GUID_TIMEOUT {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 TimeOut;
+} EFI_IFR_GUID_TIMEOUT;
+
+//----------------------------------------------------------------------------
+
+#define EFI_NON_DEVICE_CLASS 0x00
+#define EFI_DISK_DEVICE_CLASS 0x01
+#define EFI_VIDEO_DEVICE_CLASS 0x02
+#define EFI_NETWORK_DEVICE_CLASS 0x04
+#define EFI_INPUT_DEVICE_CLASS 0x08
+#define EFI_ON_BOARD_DEVICE_CLASS 0x10
+#define EFI_OTHER_DEVICE_CLASS 0x20
+
+//----------------------------------------------------------------------------
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_IFR_GUID_CLASS
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Header EFI_IFR_OP_HEADER
+// Guid EFI_GUID
+// ExtendOpCode UINT8
+// Class UINT16
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_IFR_GUID_CLASS {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 Class;
+} EFI_IFR_GUID_CLASS;
+
+//----------------------------------------------------------------------------
+
+#define EFI_SETUP_APPLICATION_SUBCLASS 0x00
+#define EFI_GENERAL_APPLICATION_SUBCLASS 0x01
+#define EFI_FRONT_PAGE_SUBCLASS 0x02
+#define EFI_SINGLE_USE_SUBCLASS 0x03
+
+//----------------------------------------------------------------------------
+
+
+//<AMI_SHDR_START>
+//----------------------------------------------------------------------------
+// Name: EFI_IFR_GUID_SUBCLASS
+//
+// Description:
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// Header EFI_IFR_OP_HEADER
+// Guid EFI_GUID
+// ExtendOpCode UINT8
+// SubClass UINT16
+//----------------------------------------------------------------------------
+//<AMI_SHDR_END>
+typedef struct _EFI_IFR_GUID_SUBCLASS {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 SubClass;
+} EFI_IFR_GUID_SUBCLASS;
+
+
+#pragma pack()
+
+
+#endif
diff --git a/FixedBootOrder.cif b/FixedBootOrder.cif
new file mode 100644
index 0000000..87a7410
--- /dev/null
+++ b/FixedBootOrder.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "Fixed Boot Order"
+ category = eModule
+ Rank = 46
+ RefName = "FixedBootOrder"
+[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"
+[parts]
+"DefaultFixedBootOrder"
+"FixedBootOrderStyle"
+<endComponent>
diff --git a/RomImage/FitcBuild.bat b/RomImage/FitcBuild.bat
index 312c997..bc5683c 100644
--- a/RomImage/FitcBuild.bat
+++ b/RomImage/FitcBuild.bat
@@ -103,7 +103,7 @@ GOTO ImageOutput
:ImageOutput
IF EXIST %DestDir%\OutImage.bin ECHO Rom_%RomSize%%RomSkue%.bin && move /Y %DestDir%\OutImage.bin Rom_%RomSize%%RomSkue%.bin
-IF EXIST Rom_%RomSize%%RomSkue%.bin move /Y Rom_%RomSize%%RomSkue%.bin SZPRJM0A.bin
+IF EXIST Rom_%RomSize%%RomSkue%.bin move /Y Rom_%RomSize%%RomSkue%.bin SZPRJM0B.bin
IF EXIST %DestDir%\OutImage_1.bin ECHO Rom00%RomSkue%.bin && move /Y %DestDir%\OutImage_1.bin Rom00%RomSkue%.bin
IF EXIST %DestDir%\OutImage_2.bin ECHO Rom01%RomSkue%.bin && move /Y %DestDir%\OutImage_2.bin Rom01%RomSkue%.bin
echo Rom_%RomSize%%RomSkue%.bin>ForPfatName.txt
diff --git a/SharkBayDT.veb b/SharkBayDT.veb
index f5f718c..648abc8 100644
--- a/SharkBayDT.veb
+++ b/SharkBayDT.veb
@@ -501,6 +501,8 @@
"INCLUDE\Protocol\SecSMIFlashProtocols.CIF"= "SS: ALASKA;$/Alaska/SOURCE/Modules/SecureFlashPkg\SecureSmiFlash;4.6.5.1_SECMOD_017"
"Keys\FW\FWkey.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/SecureFlashPkg\PlatformKey;4.6.5.1_SECMOD_017"
"SecUtils.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/SecureFlashPkg\Utils;4.6.5.1_SECMOD_017"
+"Core\EM\Slp10\Slp10.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/Slp10;4.5.00_SLP10_02"
+"Core\EM\SLP20\SlpSupport.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/SLP;4.6.0_SlpSupport_3"
"Core\EM\SMM\SMM.cif"= "SS: Alaska;$/Alaska/SOURCE/Modules/SMM;4.6.3_SMM_46"
"Core\EM\SMM\SmmDispatcher.cif"= "SS: Alaska;$/Alaska/SOURCE/Modules/SMM\SMMDispatcher;4.6.3_SMM_46"
"Core\EM\SMM\SmmBase.cif"= "SS: Alaska;$/Alaska/SOURCE/Modules/SMM\SMMBase;4.6.3_SMM_46"
@@ -702,6 +704,17 @@
"EDK\MiniSetup\Legacy\LegacyBin.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/AMITSE2_0/AMITSE\Legacy;4.6.2_TSE_2_17_1247"
"EDK\MiniSetup\EzportPlus\EzportPlusBin.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/AMITSE2_0/AMITSE\EzportPlus;4.6.2_TSE_2_17_1247"
"EDK\MiniSetup\PasswordEncode\PasswordEncodeBin.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/AMITSE2_0/AMITSE\PasswordEncode;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\TSESources.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\TseAdvanced\TseAdvanced.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\TseAdvanced;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\BootOnly\MiniSetup.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\BootOnly;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\TseLite\TseLite.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\TseLite;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\TseLite\StyleHook\StyleHook.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\TseLite/StyleHook;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\uefi2.0\Uefi20.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\uefi2.0;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\uefi2.1\Uefi21.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\Uefi2.1;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\Ezport\Ezport.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\Ezport;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\Legacy\Legacy.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\Legacy;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\EzportPlus\EzportPlus.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\EzportPlus;4.6.2_TSE_2_17_1247"
+"EDK\MiniSetup\PasswordEncode\TsePasswordEncode.cif"= "SS: ALASKA;$/Alaska/SOURCE/Modules/AMITSE2_0/AMITSE\PasswordEncode;4.6.2_TSE_2_17_1247"
"Core\EM\TseDefaultBootOrder\TseDefaultBootOrder.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/BootOptionPolicies/TseDefaultBootOrder;4.6.4.1_DefBootOrder_1.3"
"Core\EM\UEfiNetworkStack\UefiNetworkStackII.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/Network/UEFINetworkStack II;4.6.5.4_UefiNetworkStackII_11"
"Core\EM\UEfiNetworkStack\Common\UefiCommonNetworkStackII.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/Network/UEFINetworkStack II\Common;4.6.5.4_UefiNetworkStackII_11"
@@ -786,6 +799,9 @@
"Core\EM\AMIDebugRx\binaries\LIBS\DbgrUsbCableSelectLib.cif"= "SS: Alaska;$/Alaska/BIN/Modules/AMIDebugRx\binaries/LIBS;4.6.2_AMIDebugRx_2.04.0074"
"Core\EM\AMIDebugRx\binaries\LIBS\DbgrX64Lib\DbgrX64Lib.cif"= "SS: Alaska;$/Alaska/BIN/Modules/AMIDebugRx\binaries/LIBS/DbgrX64Lib;4.6.2_AMIDebugRx_2.04.0074"
"Core\EM\AMIDebugRx\binaries\LIBS\DebuggerLib\DebuggerLib.cif"= "SS: Alaska;$/Alaska/BIN/Modules/AMIDebugRx\binaries/LIBS/DebuggerLib;4.6.2_AMIDebugRx_2.04.0074"
+"FixedBootOrder.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/Template/FixedBootOrder Demo;4.6.5.1_FixedBootOrder_17"
+"Board\EM\FixedBootOrder\DefaultFixedBootOrder\DefaultFixedBootOrder.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/Template/FixedBootOrder Demo\Board/em/FixedBootOrder;4.6.5.1_FixedBootOrder_17"
+"Board\EM\FixedBootOrder\FixedBootOrderStyle\FixedBootOrderStyle.cif"= "SS: ALASKA;$/Alaska/BIN/Modules/Template/FixedBootOrder Demo\Board/em/FixedBootOrder;4.6.5.1_FixedBootOrder_17"
"Board\Board.cif"= "SS: Alaska;$/Alaska/BIN/Board;4.6.5.4_Board_31"
"Board\em\Setup\Setup.cif"= "SS: Alaska;$/Alaska/BIN/Board\Setup;4.6.5.4_Board_31"
"Include\Protocol\AmiSetupProtocol.cif"= "SS: ALASKA;$/Alaska/BIN/Board\Setup;4.6.5.4_Board_31"