From 31bb486c913795c8b67d1c4dbaae2bdec4943fc9 Mon Sep 17 00:00:00 2001 From: raywu Date: Thu, 13 Sep 2018 16:11:56 +0800 Subject: SLP1.0 / SLP2.0 / Default Password / Logo / Fix Boot Order --- BIOS_CUSTOM/OA20Marker.bin | Bin 0 -> 182 bytes BIOS_CUSTOM/OA20PKSign.bin | Bin 0 -> 284 bytes BIOS_CUSTOM/OA20PubKey.bin | Bin 0 -> 156 bytes BIOS_CUSTOM/logo.jpg | Bin 0 -> 16126 bytes .../OEMDefaultPwdHook/OEMDefaultPwdHook.c | 164 + .../OEMDefaultPwdHook/OEMDefaultPwdHook.cif | 10 + .../OEMDefaultPwdHook/OEMDefaultPwdHook.mak | 59 + .../OEMDefaultPwdHook/OEMDefaultPwdHook.sdl | 55 + .../DefaultFixedBootOrder/DefaultFixedBootOrder.c | 843 ++ .../DefaultFixedBootOrder.cif | 12 + .../DefaultFixedBootOrder.mak | 107 + .../DefaultFixedBootOrder/DefaultFixedBootOrder.sd | 962 +++ .../DefaultFixedBootOrder.sdl | 88 + .../DefaultFixedBootOrder.uni | Bin 0 -> 17928 bytes Board/EM/FixedBootOrder/FBOSetOrder.c | 1699 ++++ Board/EM/FixedBootOrder/FixedBootOrder.c | 3149 ++++++++ Board/EM/FixedBootOrder/FixedBootOrder.chm | Bin 0 -> 120169 bytes Board/EM/FixedBootOrder/FixedBootOrder.h | 309 + Board/EM/FixedBootOrder/FixedBootOrder.mak | 138 + Board/EM/FixedBootOrder/FixedBootOrder.sdl | 280 + Board/EM/FixedBootOrder/FixedBootOrderHII.c | 888 +++ Board/EM/FixedBootOrder/FixedBootOrderHII.h | 128 + .../FixedBootOrderStyle/FixedBootOrderStyle.c | 482 ++ .../FixedBootOrderStyle/FixedBootOrderStyle.cif | 10 + .../FixedBootOrderStyle/FixedBootOrderStyle.mak | 95 + .../FixedBootOrderStyle/FixedBootOrderStyle.sdl | 51 + Board/EM/FixedBootOrder/FixedBootOrderTSE.c | 1478 ++++ Board/EM/Setup/Setup.uni | Bin 24798 -> 24798 bytes CRB/CSP.sdl | 123 + Core/EM/SLP20/Marker.bin | 1 + Core/EM/SLP20/PubKey.bin | 1 + Core/EM/SLP20/SlpSupport.c | 407 + Core/EM/SLP20/SlpSupport.chm | Bin 0 -> 41243 bytes Core/EM/SLP20/SlpSupport.cif | 15 + Core/EM/SLP20/SlpSupport.dxs | 73 + Core/EM/SLP20/SlpSupport.h | 207 + Core/EM/SLP20/SlpSupport.mak | 118 + Core/EM/SLP20/SlpSupport.sdl | 52 + Core/EM/Slp10/OemTable.asm | 67 + Core/EM/Slp10/Slp10.c | 125 + Core/EM/Slp10/Slp10.chm | Bin 0 -> 24774 bytes Core/EM/Slp10/Slp10.cif | 14 + Core/EM/Slp10/Slp10.dxs | 18 + Core/EM/Slp10/Slp10.h | 104 + Core/EM/Slp10/Slp10.mak | 83 + Core/EM/Slp10/Slp10.sdl | 43 + EDK/MiniSetup/AMITSE.chm | Bin 0 -> 754045 bytes EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c | 103 + EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h | 104 + EDK/MiniSetup/BootOnly/EDKhelper.c | 1737 ++++ EDK/MiniSetup/BootOnly/EDKhelper.h | 419 + EDK/MiniSetup/BootOnly/HookAnchor.c | 676 ++ EDK/MiniSetup/BootOnly/MiniSetup.cif | 47 + EDK/MiniSetup/BootOnly/MiniSetup.mak | 138 + EDK/MiniSetup/BootOnly/MiniSetup.sdl | 83 + EDK/MiniSetup/BootOnly/Resources.c | 231 + EDK/MiniSetup/BootOnly/Timer.h | 91 + EDK/MiniSetup/BootOnly/amiver.h | 143 + EDK/MiniSetup/BootOnly/bbs.c | 1552 ++++ EDK/MiniSetup/BootOnly/bbs.h | 146 + EDK/MiniSetup/BootOnly/boot.c | 3034 +++++++ EDK/MiniSetup/BootOnly/box.c | 241 + EDK/MiniSetup/BootOnly/box.h | 95 + EDK/MiniSetup/BootOnly/buffer.c | 501 ++ EDK/MiniSetup/BootOnly/buffer.h | 95 + EDK/MiniSetup/BootOnly/dobmpmgr.c | 301 + EDK/MiniSetup/BootOnly/globals.c | 212 + EDK/MiniSetup/BootOnly/hiistring.c | 251 + EDK/MiniSetup/BootOnly/hiistring.h | 153 + EDK/MiniSetup/BootOnly/logo.c | 1163 +++ EDK/MiniSetup/BootOnly/mem.c | 255 + EDK/MiniSetup/BootOnly/minisetup.c | 551 ++ EDK/MiniSetup/BootOnly/minisetup.h | 1519 ++++ EDK/MiniSetup/BootOnly/minisetupext.c | 927 +++ EDK/MiniSetup/BootOnly/notify.c | 1271 +++ EDK/MiniSetup/BootOnly/password.c | 253 + EDK/MiniSetup/BootOnly/password.h | 111 + EDK/MiniSetup/BootOnly/postmgmt.c | 897 +++ EDK/MiniSetup/BootOnly/postmgmtext.c | 964 +++ EDK/MiniSetup/BootOnly/print.c | 476 ++ EDK/MiniSetup/BootOnly/protocol.c | 1870 +++++ EDK/MiniSetup/BootOnly/protocol.h | 198 + EDK/MiniSetup/BootOnly/screen.c | 346 + EDK/MiniSetup/BootOnly/screen.h | 96 + EDK/MiniSetup/BootOnly/string.c | 1488 ++++ EDK/MiniSetup/BootOnly/string.h | 158 + EDK/MiniSetup/BootOnly/timer.c | 154 + EDK/MiniSetup/BootOnly/variable.c | 204 + EDK/MiniSetup/Ezport/Ezport.cif | 14 + EDK/MiniSetup/Ezport/Ezport.mak | 123 + EDK/MiniSetup/Ezport/Ezport.sdl | 1057 +++ EDK/MiniSetup/Ezport/ezport.c | 731 ++ EDK/MiniSetup/Ezport/ezport.h | 134 + EDK/MiniSetup/Ezport/style.c | 546 ++ EDK/MiniSetup/Ezport/style.h | 247 + EDK/MiniSetup/Ezport/stylecommon.c | 1440 ++++ EDK/MiniSetup/EzportPlus/EzportPlus.cif | 14 + EDK/MiniSetup/EzportPlus/EzportPlus.mak | 130 + EDK/MiniSetup/EzportPlus/EzportPlus.sdl | 1073 +++ EDK/MiniSetup/EzportPlus/ezportplus.c | 1251 +++ EDK/MiniSetup/EzportPlus/ezportplus.h | 141 + EDK/MiniSetup/EzportPlus/style.c | 625 ++ EDK/MiniSetup/EzportPlus/style.h | 255 + EDK/MiniSetup/EzportPlus/stylecommon.c | 1437 ++++ EDK/MiniSetup/Legacy/Legacy.cif | 14 + EDK/MiniSetup/Legacy/Legacy.mak | 131 + EDK/MiniSetup/Legacy/Legacy.sdl | 445 ++ EDK/MiniSetup/Legacy/legacy.c | 1622 ++++ EDK/MiniSetup/Legacy/legacy.h | 160 + EDK/MiniSetup/Legacy/style.c | 725 ++ EDK/MiniSetup/Legacy/style.h | 259 + EDK/MiniSetup/Legacy/stylecommon.c | 1362 ++++ EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c | 101 + EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif | 10 + EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak | 145 + EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl | 34 + EDK/MiniSetup/TSESources.Sdl | 20 + EDK/MiniSetup/TSESources.cif | 20 + EDK/MiniSetup/TseAdvanced/Bbs.c | 946 +++ EDK/MiniSetup/TseAdvanced/Jpeg6.h | 123 + EDK/MiniSetup/TseAdvanced/Logo.c | 282 + EDK/MiniSetup/TseAdvanced/MyDefs.h | 103 + EDK/MiniSetup/TseAdvanced/TseAdvanced.c | 3962 ++++++++++ EDK/MiniSetup/TseAdvanced/TseAdvanced.cif | 28 + EDK/MiniSetup/TseAdvanced/TseAdvanced.mak | 160 + EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl | 42 + EDK/MiniSetup/TseAdvanced/bootflowLib.c | 199 + EDK/MiniSetup/TseAdvanced/dogif.c | 1197 +++ EDK/MiniSetup/TseAdvanced/dogifmgr.c | 486 ++ EDK/MiniSetup/TseAdvanced/iJpeg.c | 253 + EDK/MiniSetup/TseAdvanced/ipcx.c | 188 + EDK/MiniSetup/TseAdvanced/jpeg.h | 106 + EDK/MiniSetup/TseAdvanced/jpeg6.c | 1320 ++++ EDK/MiniSetup/TseAdvanced/pcx.h | 138 + EDK/MiniSetup/TseAdvanced/pcxc.c | 321 + EDK/MiniSetup/TseAdvanced/png.c | 1353 ++++ EDK/MiniSetup/TseAdvanced/png.h | 136 + EDK/MiniSetup/TseAdvanced/pnguncmp.c | 879 +++ EDK/MiniSetup/TseAdvanced/special.c | 1898 +++++ EDK/MiniSetup/TseAdvanced/special.h | 196 + EDK/MiniSetup/TseLite/Action.c | 365 + EDK/MiniSetup/TseLite/AddBootOption.c | 2548 ++++++ EDK/MiniSetup/TseLite/Date.c | 1397 ++++ EDK/MiniSetup/TseLite/Date.h | 181 + EDK/MiniSetup/TseLite/Label.c | 523 ++ EDK/MiniSetup/TseLite/Label.h | 160 + EDK/MiniSetup/TseLite/ListBox.c | 1436 ++++ EDK/MiniSetup/TseLite/ListBox.h | 186 + EDK/MiniSetup/TseLite/Memo.c | 764 ++ EDK/MiniSetup/TseLite/Memo.h | 195 + EDK/MiniSetup/TseLite/Menu.c | 1069 +++ EDK/MiniSetup/TseLite/Menu.h | 179 + EDK/MiniSetup/TseLite/MessageBox.c | 1192 +++ EDK/MiniSetup/TseLite/MessageBox.h | 207 + EDK/MiniSetup/TseLite/PopupEdit.c | 890 +++ EDK/MiniSetup/TseLite/PopupEdit.h | 192 + EDK/MiniSetup/TseLite/PopupPassword.c | 1377 ++++ EDK/MiniSetup/TseLite/PopupPassword.h | 178 + EDK/MiniSetup/TseLite/PopupSel.c | 1646 ++++ EDK/MiniSetup/TseLite/PopupSel.h | 229 + EDK/MiniSetup/TseLite/PopupString.c | 1283 +++ EDK/MiniSetup/TseLite/PopupString.h | 200 + EDK/MiniSetup/TseLite/ResetButton.c | 297 + EDK/MiniSetup/TseLite/ResetButton.h | 106 + EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif | 49 + EDK/MiniSetup/TseLite/StyleHook/StyleHook.h | 147 + EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak | 114 + EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl | 24 + EDK/MiniSetup/TseLite/StyleHook/styleHook1.c | 99 + EDK/MiniSetup/TseLite/StyleHook/styleHook10.c | 97 + EDK/MiniSetup/TseLite/StyleHook/styleHook11.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook12.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook13.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook14.c | 99 + EDK/MiniSetup/TseLite/StyleHook/styleHook15.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook16.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook17.c | 99 + EDK/MiniSetup/TseLite/StyleHook/styleHook18.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook19.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook2.c | 102 + EDK/MiniSetup/TseLite/StyleHook/styleHook20.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook21.c | 100 + EDK/MiniSetup/TseLite/StyleHook/styleHook22.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook23.c | 95 + EDK/MiniSetup/TseLite/StyleHook/styleHook24.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook25.c | 94 + EDK/MiniSetup/TseLite/StyleHook/styleHook26.c | 94 + EDK/MiniSetup/TseLite/StyleHook/styleHook27.c | 95 + EDK/MiniSetup/TseLite/StyleHook/styleHook28.c | 94 + EDK/MiniSetup/TseLite/StyleHook/styleHook29.c | 94 + EDK/MiniSetup/TseLite/StyleHook/styleHook3.c | 101 + EDK/MiniSetup/TseLite/StyleHook/styleHook30.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook31.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook32.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook33.c | 97 + EDK/MiniSetup/TseLite/StyleHook/styleHook34.c | 97 + EDK/MiniSetup/TseLite/StyleHook/styleHook35.c | 93 + EDK/MiniSetup/TseLite/StyleHook/styleHook36.c | 97 + EDK/MiniSetup/TseLite/StyleHook/styleHook37.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook38.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook39.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook4.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook5.c | 99 + EDK/MiniSetup/TseLite/StyleHook/styleHook6.c | 96 + EDK/MiniSetup/TseLite/StyleHook/styleHook7.c | 98 + EDK/MiniSetup/TseLite/StyleHook/styleHook8.c | 97 + EDK/MiniSetup/TseLite/StyleHook/styleHook9.c | 96 + EDK/MiniSetup/TseLite/SubMenu.c | 876 +++ EDK/MiniSetup/TseLite/SubMenu.h | 197 + EDK/MiniSetup/TseLite/Text.c | 587 ++ EDK/MiniSetup/TseLite/Text.h | 154 + EDK/MiniSetup/TseLite/Time.h | 180 + EDK/MiniSetup/TseLite/TseLite.cif | 73 + EDK/MiniSetup/TseLite/TseLite.mak | 124 + EDK/MiniSetup/TseLite/TseLite.sdl | 40 + EDK/MiniSetup/TseLite/TseLiteCommon.c | 433 + EDK/MiniSetup/TseLite/TseLitehelper.c | 1310 ++++ EDK/MiniSetup/TseLite/UefiAction.c | 498 ++ EDK/MiniSetup/TseLite/UefiAction.h | 119 + EDK/MiniSetup/TseLite/action.h | 163 + EDK/MiniSetup/TseLite/application.c | 436 ++ EDK/MiniSetup/TseLite/application.h | 180 + EDK/MiniSetup/TseLite/callback.c | 1341 ++++ EDK/MiniSetup/TseLite/callback.h | 189 + EDK/MiniSetup/TseLite/control.c | 337 + EDK/MiniSetup/TseLite/control.h | 171 + EDK/MiniSetup/TseLite/edit.c | 636 ++ EDK/MiniSetup/TseLite/edit.h | 166 + EDK/MiniSetup/TseLite/frame.c | 2563 ++++++ EDK/MiniSetup/TseLite/frame.h | 221 + EDK/MiniSetup/TseLite/hotclick.c | 230 + EDK/MiniSetup/TseLite/hotclick.h | 120 + EDK/MiniSetup/TseLite/hotkey.c | 237 + EDK/MiniSetup/TseLite/hotkey.h | 157 + EDK/MiniSetup/TseLite/minisetupext.c | 2378 ++++++ EDK/MiniSetup/TseLite/minisetupext.h | 537 ++ EDK/MiniSetup/TseLite/numeric.c | 1430 ++++ EDK/MiniSetup/TseLite/numeric.h | 224 + EDK/MiniSetup/TseLite/object.c | 211 + EDK/MiniSetup/TseLite/object.h | 144 + EDK/MiniSetup/TseLite/ordlistbox.c | 1080 +++ EDK/MiniSetup/TseLite/ordlistbox.h | 202 + EDK/MiniSetup/TseLite/page.c | 1079 +++ EDK/MiniSetup/TseLite/page.h | 185 + EDK/MiniSetup/TseLite/popup.c | 613 ++ EDK/MiniSetup/TseLite/popup.h | 161 + EDK/MiniSetup/TseLite/time.c | 1121 +++ EDK/MiniSetup/TseLite/variable.c | 1488 ++++ EDK/MiniSetup/changelog.log | 1458 ++++ EDK/MiniSetup/uefi2.0/FormBrowser.c | 591 ++ EDK/MiniSetup/uefi2.0/Hiicallback.c | 429 + EDK/MiniSetup/uefi2.0/Uefi20.cif | 16 + EDK/MiniSetup/uefi2.0/ctrlcond.c | 840 ++ EDK/MiniSetup/uefi2.0/ctrlcond.h | 113 + EDK/MiniSetup/uefi2.0/hii.c | 3273 ++++++++ EDK/MiniSetup/uefi2.0/hii.h | 328 + EDK/MiniSetup/uefi2.0/uefi20.mak | 128 + EDK/MiniSetup/uefi2.0/uefi20.sdl | 53 + EDK/MiniSetup/uefi2.0/uefi20Wapper.c | 2428 ++++++ EDK/MiniSetup/uefi2.1/CtrlCond.c | 806 ++ EDK/MiniSetup/uefi2.1/CtrlCond.h | 146 + EDK/MiniSetup/uefi2.1/Expression.c | 2861 +++++++ EDK/MiniSetup/uefi2.1/FormBrowser2.c | 1175 +++ EDK/MiniSetup/uefi2.1/FormBrowser2.h | 156 + EDK/MiniSetup/uefi2.1/Hii.c | 3557 +++++++++ EDK/MiniSetup/uefi2.1/HiiCallback.c | 1073 +++ EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c | 740 ++ EDK/MiniSetup/uefi2.1/Parse.c | 4700 +++++++++++ EDK/MiniSetup/uefi2.1/TseUefiHii.h | 951 +++ EDK/MiniSetup/uefi2.1/Uefi21.cif | 21 + EDK/MiniSetup/uefi2.1/Uefi21.mak | 134 + EDK/MiniSetup/uefi2.1/Uefi21.sdl | 71 + EDK/MiniSetup/uefi2.1/Uefi21Wapper.c | 8266 ++++++++++++++++++++ EDK/MiniSetup/uefi2.1/UefiTianoHii.h | 241 + FixedBootOrder.cif | 19 + RomImage/FitcBuild.bat | 2 +- SharkBayDT.veb | 16 + 277 files changed, 142397 insertions(+), 1 deletion(-) create mode 100644 BIOS_CUSTOM/OA20Marker.bin create mode 100644 BIOS_CUSTOM/OA20PKSign.bin create mode 100644 BIOS_CUSTOM/OA20PubKey.bin create mode 100644 BIOS_CUSTOM/logo.jpg create mode 100644 Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.c create mode 100644 Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.cif create mode 100644 Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.mak create mode 100644 Board/AAEON/OEMFeatures/OEMDefaultPwdHook/OEMDefaultPwdHook.sdl create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.c create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.cif create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.mak create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sd create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.sdl create mode 100644 Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.uni create mode 100644 Board/EM/FixedBootOrder/FBOSetOrder.c create mode 100644 Board/EM/FixedBootOrder/FixedBootOrder.c create mode 100644 Board/EM/FixedBootOrder/FixedBootOrder.chm create mode 100644 Board/EM/FixedBootOrder/FixedBootOrder.h create mode 100644 Board/EM/FixedBootOrder/FixedBootOrder.mak create mode 100644 Board/EM/FixedBootOrder/FixedBootOrder.sdl create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderHII.c create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderHII.h create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.c create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.cif create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.mak create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderStyle/FixedBootOrderStyle.sdl create mode 100644 Board/EM/FixedBootOrder/FixedBootOrderTSE.c create mode 100644 Core/EM/SLP20/Marker.bin create mode 100644 Core/EM/SLP20/PubKey.bin create mode 100644 Core/EM/SLP20/SlpSupport.c create mode 100644 Core/EM/SLP20/SlpSupport.chm create mode 100644 Core/EM/SLP20/SlpSupport.cif create mode 100644 Core/EM/SLP20/SlpSupport.dxs create mode 100644 Core/EM/SLP20/SlpSupport.h create mode 100644 Core/EM/SLP20/SlpSupport.mak create mode 100644 Core/EM/SLP20/SlpSupport.sdl create mode 100644 Core/EM/Slp10/OemTable.asm create mode 100644 Core/EM/Slp10/Slp10.c create mode 100644 Core/EM/Slp10/Slp10.chm create mode 100644 Core/EM/Slp10/Slp10.cif create mode 100644 Core/EM/Slp10/Slp10.dxs create mode 100644 Core/EM/Slp10/Slp10.h create mode 100644 Core/EM/Slp10/Slp10.mak create mode 100644 Core/EM/Slp10/Slp10.sdl create mode 100644 EDK/MiniSetup/AMITSE.chm create mode 100644 EDK/MiniSetup/BootOnly/AMILogo/AMILogo.c create mode 100644 EDK/MiniSetup/BootOnly/AMILogo/AMILogo.h create mode 100644 EDK/MiniSetup/BootOnly/EDKhelper.c create mode 100644 EDK/MiniSetup/BootOnly/EDKhelper.h create mode 100644 EDK/MiniSetup/BootOnly/HookAnchor.c create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.cif create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.mak create mode 100644 EDK/MiniSetup/BootOnly/MiniSetup.sdl create mode 100644 EDK/MiniSetup/BootOnly/Resources.c create mode 100644 EDK/MiniSetup/BootOnly/Timer.h create mode 100644 EDK/MiniSetup/BootOnly/amiver.h create mode 100644 EDK/MiniSetup/BootOnly/bbs.c create mode 100644 EDK/MiniSetup/BootOnly/bbs.h create mode 100644 EDK/MiniSetup/BootOnly/boot.c create mode 100644 EDK/MiniSetup/BootOnly/box.c create mode 100644 EDK/MiniSetup/BootOnly/box.h create mode 100644 EDK/MiniSetup/BootOnly/buffer.c create mode 100644 EDK/MiniSetup/BootOnly/buffer.h create mode 100644 EDK/MiniSetup/BootOnly/dobmpmgr.c create mode 100644 EDK/MiniSetup/BootOnly/globals.c create mode 100644 EDK/MiniSetup/BootOnly/hiistring.c create mode 100644 EDK/MiniSetup/BootOnly/hiistring.h create mode 100644 EDK/MiniSetup/BootOnly/logo.c create mode 100644 EDK/MiniSetup/BootOnly/mem.c create mode 100644 EDK/MiniSetup/BootOnly/minisetup.c create mode 100644 EDK/MiniSetup/BootOnly/minisetup.h create mode 100644 EDK/MiniSetup/BootOnly/minisetupext.c create mode 100644 EDK/MiniSetup/BootOnly/notify.c create mode 100644 EDK/MiniSetup/BootOnly/password.c create mode 100644 EDK/MiniSetup/BootOnly/password.h create mode 100644 EDK/MiniSetup/BootOnly/postmgmt.c create mode 100644 EDK/MiniSetup/BootOnly/postmgmtext.c create mode 100644 EDK/MiniSetup/BootOnly/print.c create mode 100644 EDK/MiniSetup/BootOnly/protocol.c create mode 100644 EDK/MiniSetup/BootOnly/protocol.h create mode 100644 EDK/MiniSetup/BootOnly/screen.c create mode 100644 EDK/MiniSetup/BootOnly/screen.h create mode 100644 EDK/MiniSetup/BootOnly/string.c create mode 100644 EDK/MiniSetup/BootOnly/string.h create mode 100644 EDK/MiniSetup/BootOnly/timer.c create mode 100644 EDK/MiniSetup/BootOnly/variable.c create mode 100644 EDK/MiniSetup/Ezport/Ezport.cif create mode 100644 EDK/MiniSetup/Ezport/Ezport.mak create mode 100644 EDK/MiniSetup/Ezport/Ezport.sdl create mode 100644 EDK/MiniSetup/Ezport/ezport.c create mode 100644 EDK/MiniSetup/Ezport/ezport.h create mode 100644 EDK/MiniSetup/Ezport/style.c create mode 100644 EDK/MiniSetup/Ezport/style.h create mode 100644 EDK/MiniSetup/Ezport/stylecommon.c create mode 100644 EDK/MiniSetup/EzportPlus/EzportPlus.cif create mode 100644 EDK/MiniSetup/EzportPlus/EzportPlus.mak create mode 100644 EDK/MiniSetup/EzportPlus/EzportPlus.sdl create mode 100644 EDK/MiniSetup/EzportPlus/ezportplus.c create mode 100644 EDK/MiniSetup/EzportPlus/ezportplus.h create mode 100644 EDK/MiniSetup/EzportPlus/style.c create mode 100644 EDK/MiniSetup/EzportPlus/style.h create mode 100644 EDK/MiniSetup/EzportPlus/stylecommon.c create mode 100644 EDK/MiniSetup/Legacy/Legacy.cif create mode 100644 EDK/MiniSetup/Legacy/Legacy.mak create mode 100644 EDK/MiniSetup/Legacy/Legacy.sdl create mode 100644 EDK/MiniSetup/Legacy/legacy.c create mode 100644 EDK/MiniSetup/Legacy/legacy.h create mode 100644 EDK/MiniSetup/Legacy/style.c create mode 100644 EDK/MiniSetup/Legacy/style.h create mode 100644 EDK/MiniSetup/Legacy/stylecommon.c create mode 100644 EDK/MiniSetup/PasswordEncode/TsePasswordEncode.c create mode 100644 EDK/MiniSetup/PasswordEncode/TsePasswordEncode.cif create mode 100644 EDK/MiniSetup/PasswordEncode/TsePasswordEncode.mak create mode 100644 EDK/MiniSetup/PasswordEncode/TsePasswordEncode.sdl create mode 100644 EDK/MiniSetup/TSESources.Sdl create mode 100644 EDK/MiniSetup/TSESources.cif create mode 100644 EDK/MiniSetup/TseAdvanced/Bbs.c create mode 100644 EDK/MiniSetup/TseAdvanced/Jpeg6.h create mode 100644 EDK/MiniSetup/TseAdvanced/Logo.c create mode 100644 EDK/MiniSetup/TseAdvanced/MyDefs.h create mode 100644 EDK/MiniSetup/TseAdvanced/TseAdvanced.c create mode 100644 EDK/MiniSetup/TseAdvanced/TseAdvanced.cif create mode 100644 EDK/MiniSetup/TseAdvanced/TseAdvanced.mak create mode 100644 EDK/MiniSetup/TseAdvanced/TseAdvanced.sdl create mode 100644 EDK/MiniSetup/TseAdvanced/bootflowLib.c create mode 100644 EDK/MiniSetup/TseAdvanced/dogif.c create mode 100644 EDK/MiniSetup/TseAdvanced/dogifmgr.c create mode 100644 EDK/MiniSetup/TseAdvanced/iJpeg.c create mode 100644 EDK/MiniSetup/TseAdvanced/ipcx.c create mode 100644 EDK/MiniSetup/TseAdvanced/jpeg.h create mode 100644 EDK/MiniSetup/TseAdvanced/jpeg6.c create mode 100644 EDK/MiniSetup/TseAdvanced/pcx.h create mode 100644 EDK/MiniSetup/TseAdvanced/pcxc.c create mode 100644 EDK/MiniSetup/TseAdvanced/png.c create mode 100644 EDK/MiniSetup/TseAdvanced/png.h create mode 100644 EDK/MiniSetup/TseAdvanced/pnguncmp.c create mode 100644 EDK/MiniSetup/TseAdvanced/special.c create mode 100644 EDK/MiniSetup/TseAdvanced/special.h create mode 100644 EDK/MiniSetup/TseLite/Action.c create mode 100644 EDK/MiniSetup/TseLite/AddBootOption.c create mode 100644 EDK/MiniSetup/TseLite/Date.c create mode 100644 EDK/MiniSetup/TseLite/Date.h create mode 100644 EDK/MiniSetup/TseLite/Label.c create mode 100644 EDK/MiniSetup/TseLite/Label.h create mode 100644 EDK/MiniSetup/TseLite/ListBox.c create mode 100644 EDK/MiniSetup/TseLite/ListBox.h create mode 100644 EDK/MiniSetup/TseLite/Memo.c create mode 100644 EDK/MiniSetup/TseLite/Memo.h create mode 100644 EDK/MiniSetup/TseLite/Menu.c create mode 100644 EDK/MiniSetup/TseLite/Menu.h create mode 100644 EDK/MiniSetup/TseLite/MessageBox.c create mode 100644 EDK/MiniSetup/TseLite/MessageBox.h create mode 100644 EDK/MiniSetup/TseLite/PopupEdit.c create mode 100644 EDK/MiniSetup/TseLite/PopupEdit.h create mode 100644 EDK/MiniSetup/TseLite/PopupPassword.c create mode 100644 EDK/MiniSetup/TseLite/PopupPassword.h create mode 100644 EDK/MiniSetup/TseLite/PopupSel.c create mode 100644 EDK/MiniSetup/TseLite/PopupSel.h create mode 100644 EDK/MiniSetup/TseLite/PopupString.c create mode 100644 EDK/MiniSetup/TseLite/PopupString.h create mode 100644 EDK/MiniSetup/TseLite/ResetButton.c create mode 100644 EDK/MiniSetup/TseLite/ResetButton.h create mode 100644 EDK/MiniSetup/TseLite/StyleHook/StyleHook.cif create mode 100644 EDK/MiniSetup/TseLite/StyleHook/StyleHook.h create mode 100644 EDK/MiniSetup/TseLite/StyleHook/StyleHook.mak create mode 100644 EDK/MiniSetup/TseLite/StyleHook/StyleHook.sdl create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook1.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook10.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook11.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook12.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook13.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook14.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook15.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook16.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook17.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook18.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook19.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook2.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook20.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook21.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook22.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook23.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook24.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook25.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook26.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook27.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook28.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook29.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook3.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook30.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook31.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook32.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook33.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook34.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook35.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook36.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook37.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook38.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook39.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook4.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook5.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook6.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook7.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook8.c create mode 100644 EDK/MiniSetup/TseLite/StyleHook/styleHook9.c create mode 100644 EDK/MiniSetup/TseLite/SubMenu.c create mode 100644 EDK/MiniSetup/TseLite/SubMenu.h create mode 100644 EDK/MiniSetup/TseLite/Text.c create mode 100644 EDK/MiniSetup/TseLite/Text.h create mode 100644 EDK/MiniSetup/TseLite/Time.h create mode 100644 EDK/MiniSetup/TseLite/TseLite.cif create mode 100644 EDK/MiniSetup/TseLite/TseLite.mak create mode 100644 EDK/MiniSetup/TseLite/TseLite.sdl create mode 100644 EDK/MiniSetup/TseLite/TseLiteCommon.c create mode 100644 EDK/MiniSetup/TseLite/TseLitehelper.c create mode 100644 EDK/MiniSetup/TseLite/UefiAction.c create mode 100644 EDK/MiniSetup/TseLite/UefiAction.h create mode 100644 EDK/MiniSetup/TseLite/action.h create mode 100644 EDK/MiniSetup/TseLite/application.c create mode 100644 EDK/MiniSetup/TseLite/application.h create mode 100644 EDK/MiniSetup/TseLite/callback.c create mode 100644 EDK/MiniSetup/TseLite/callback.h create mode 100644 EDK/MiniSetup/TseLite/control.c create mode 100644 EDK/MiniSetup/TseLite/control.h create mode 100644 EDK/MiniSetup/TseLite/edit.c create mode 100644 EDK/MiniSetup/TseLite/edit.h create mode 100644 EDK/MiniSetup/TseLite/frame.c create mode 100644 EDK/MiniSetup/TseLite/frame.h create mode 100644 EDK/MiniSetup/TseLite/hotclick.c create mode 100644 EDK/MiniSetup/TseLite/hotclick.h create mode 100644 EDK/MiniSetup/TseLite/hotkey.c create mode 100644 EDK/MiniSetup/TseLite/hotkey.h create mode 100644 EDK/MiniSetup/TseLite/minisetupext.c create mode 100644 EDK/MiniSetup/TseLite/minisetupext.h create mode 100644 EDK/MiniSetup/TseLite/numeric.c create mode 100644 EDK/MiniSetup/TseLite/numeric.h create mode 100644 EDK/MiniSetup/TseLite/object.c create mode 100644 EDK/MiniSetup/TseLite/object.h create mode 100644 EDK/MiniSetup/TseLite/ordlistbox.c create mode 100644 EDK/MiniSetup/TseLite/ordlistbox.h create mode 100644 EDK/MiniSetup/TseLite/page.c create mode 100644 EDK/MiniSetup/TseLite/page.h create mode 100644 EDK/MiniSetup/TseLite/popup.c create mode 100644 EDK/MiniSetup/TseLite/popup.h create mode 100644 EDK/MiniSetup/TseLite/time.c create mode 100644 EDK/MiniSetup/TseLite/variable.c create mode 100644 EDK/MiniSetup/changelog.log create mode 100644 EDK/MiniSetup/uefi2.0/FormBrowser.c create mode 100644 EDK/MiniSetup/uefi2.0/Hiicallback.c create mode 100644 EDK/MiniSetup/uefi2.0/Uefi20.cif create mode 100644 EDK/MiniSetup/uefi2.0/ctrlcond.c create mode 100644 EDK/MiniSetup/uefi2.0/ctrlcond.h create mode 100644 EDK/MiniSetup/uefi2.0/hii.c create mode 100644 EDK/MiniSetup/uefi2.0/hii.h create mode 100644 EDK/MiniSetup/uefi2.0/uefi20.mak create mode 100644 EDK/MiniSetup/uefi2.0/uefi20.sdl create mode 100644 EDK/MiniSetup/uefi2.0/uefi20Wapper.c create mode 100644 EDK/MiniSetup/uefi2.1/CtrlCond.c create mode 100644 EDK/MiniSetup/uefi2.1/CtrlCond.h create mode 100644 EDK/MiniSetup/uefi2.1/Expression.c create mode 100644 EDK/MiniSetup/uefi2.1/FormBrowser2.c create mode 100644 EDK/MiniSetup/uefi2.1/FormBrowser2.h create mode 100644 EDK/MiniSetup/uefi2.1/Hii.c create mode 100644 EDK/MiniSetup/uefi2.1/HiiCallback.c create mode 100644 EDK/MiniSetup/uefi2.1/HiiNotificationHandler.c create mode 100644 EDK/MiniSetup/uefi2.1/Parse.c create mode 100644 EDK/MiniSetup/uefi2.1/TseUefiHii.h create mode 100644 EDK/MiniSetup/uefi2.1/Uefi21.cif create mode 100644 EDK/MiniSetup/uefi2.1/Uefi21.mak create mode 100644 EDK/MiniSetup/uefi2.1/Uefi21.sdl create mode 100644 EDK/MiniSetup/uefi2.1/Uefi21Wapper.c create mode 100644 EDK/MiniSetup/uefi2.1/UefiTianoHii.h create mode 100644 FixedBootOrder.cif diff --git a/BIOS_CUSTOM/OA20Marker.bin b/BIOS_CUSTOM/OA20Marker.bin new file mode 100644 index 0000000..9e65faa Binary files /dev/null and b/BIOS_CUSTOM/OA20Marker.bin differ diff --git a/BIOS_CUSTOM/OA20PKSign.bin b/BIOS_CUSTOM/OA20PKSign.bin new file mode 100644 index 0000000..cf8aeac Binary files /dev/null and b/BIOS_CUSTOM/OA20PKSign.bin differ diff --git a/BIOS_CUSTOM/OA20PubKey.bin b/BIOS_CUSTOM/OA20PubKey.bin new file mode 100644 index 0000000..4982ea8 Binary files /dev/null and b/BIOS_CUSTOM/OA20PubKey.bin differ diff --git a/BIOS_CUSTOM/logo.jpg b/BIOS_CUSTOM/logo.jpg new file mode 100644 index 0000000..110f161 Binary files /dev/null and b/BIOS_CUSTOM/logo.jpg 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: $ +// +//********************************************************************** +// +// +// Name: +// +// Description: +// +// +//********************************************************************** + +#include "token.h" +#include +#include +#include +#include + +#if EFI_SPECIFICATION_VERSION>0x20000 +#include +#include +#include +#else +#include +#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 @@ + + name = "OemDefualtPwdHook - Set Default Password" + category = ModulePart + LocalRoot = "Board\AAEON\OEMFeatures\OEMDefaultPwdHook\" + RefName = "OEMDefaultPwdHook" +[files] +"OEMDefaultPwdHook.c" +"OEMDefaultPwdHook.sdl" +"OEMDefaultPwdHook.mak" + 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: $ +# +#********************************************************************** +# +# +# Name: OemTseHook.mak +# +# Description: +# +# +#********************************************************************** + +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. +// +// +//*****************************************************************// + +// +//---------------------------------------------------------------------- +// +// Name: DefaultFixedBootOrder.c +// +// Description: Default FixedBootOrder Boot type setting. +// +//---------------------------------------------------------------------- +// + +//---------------------------------------------------------------------- +// Include Files +//---------------------------------------------------------------------- +#include +#include +#include +#include +#if CSM_SUPPORT +#include +#endif +#include +#include +#include +#include +#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 + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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 ; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetDevInform +// +// Description: Get Device Information(Description, Type, Path) by BootOptionList +// +// Input: FBO_DEVICE_INFORM **DevHead +// +// Output: FBO_DEVICE_INFORM **DevHead +// +// Notes: EIP 143657 +// +//--------------------------------------------------------------------------- +// +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) ; + } + } +} + +// +//--------------------------------------------------------------------------- +// +// 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") +//--------------------------------------------------------------------------- +// +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 ; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FBO_AdjustDeviceName +// +// Description: Change FBO Device Name +// +// Input: +// +// Output: +// +// Notes: EIP 143657 +// +//--------------------------------------------------------------------------- +// +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); + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: GetUefiBootOptionTag +// +// Description: Function returns device type for given handle +// +// Input: EFI_DEVICE_PATH_PROTOCOL *Dp - +// +// Output: UINT32 - device type +// +//---------------------------------------------------------------------------- +// +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 @@ + + name = "Default FixedBootOrder" + category = ModulePart + LocalRoot = "Board\EM\FixedBootOrder\DefaultFixedBootOrder\" + RefName = "DefaultFixedBootOrder" +[files] +"DefaultFixedBootOrder.sdl" +"DefaultFixedBootOrder.c" +"DefaultFixedBootOrder.sd" +"DefaultFixedBootOrder.uni" +"DefaultFixedBootOrder.mak" + 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 + +# +#----------------------------------------------------------------------- +# Name: DefaultFixedBootOrder.mak +# +# Description: This is a make file used to build component +# +#----------------------------------------------------------------------- +# +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 + +#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 Binary files /dev/null and b/Board/EM/FixedBootOrder/DefaultFixedBootOrder/DefaultFixedBootOrder.uni 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. +// +//*****************************************************************// + +// +//---------------------------------------------------------------------- +// +// Name: FBOSetOrder.c +// +// Description: FixedBootOrder Boot Option control +// +//---------------------------------------------------------------------- +// + +//---------------------------------------------------------------------- +// Include Files +//---------------------------------------------------------------------- +#include +#include +#include + +#include +#include +#include + +#if CSM_SUPPORT +#include +#include +#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; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +//---------------------------------------------------------------------------- +// +UINT32 FBO_FindTagPriority(UINT16 Tag){ + UINT32 i=0; + UINT16 DeviceMapCount; + + DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap ); + + for( i=0; i +//---------------------------------------------------------------------------- +// Procedure: IsUSBkeyByHandle +// +// Description: determine the device type of the USBKey size. +// +// Input: EFI_HANDLE Handle +// +// Output: BOOLEAN +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +//---------------------------------------------------------------------------- +// +BOOLEAN CheckIsUSBkey(BBS_TABLE *BbsEntry) +{ + if( BbsEntry->DeviceType == BBS_HARDDISK ) + return IsUSBkeyByHandle( *(VOID**)(&BbsEntry->IBV1) ); + else + return FALSE; +} +#endif + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 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 + +} + +// +//---------------------------------------------------------------------------- +// 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: +//---------------------------------------------------------------------------- +// +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; iType = 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; jDevice[j] & 0xff00) continue; + NewOrder->Device[NewOrderCount]=DevOrder->Device[j]; + NewOrderCount++; + } + + for(j=0; jDevice[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 ); +} + +// +//---------------------------------------------------------------------------- +// +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// 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: +//---------------------------------------------------------------------------- +// +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; iType = 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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetLegacyBootOptionPriority +// +// Description: Set legacy boot option list priority. +// +// Input: DeviceType - Legacy Device type +// Priority - pointer of Priority(UINT32). +// +// Output: none +// +// Note: +//---------------------------------------------------------------------------- +// +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)); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetUefiBootOptionPriority +// +// Description: Set uefi boot option list priority. +// +// Input: DeviceType - Uefi Device type +// Priority - pointer of Priority(UINT32). +// +// Output: none +// +// Note: +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: FBO_UpdateBootListPriority +// +// Description: use setup data LegacyPriorities/UefiPriorities/DualPriorities +// ,set legacy/uefi boot option list priority. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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;iDualPriorities[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; iUefiPriorities[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; iLegacyPriorities[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"); +} +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// + +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+)> +// +//---------------------------------------------------------------------------- +// Procedure: FBO_AdjustWtgPriority() +// +// Description: First boot order of group, Change this gorup +// uefi Priorities to Top position. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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;iDualPriorities[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; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: FBO_AdjustPriority() +// +// Description: first boot order of group, Change this gorup +// uefi and dual Priorities to Top position. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +void FBO_AdjustPriority() +{ + FBO_AdjustWtgPriority(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: FBO_Init +// +// Description: Initialize the module memory, and device map data. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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; iLegacyPriorities[i]=pSetupData->BcpDefaultLegacyPriorities[i]; + + DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap ); + for( i=0; iUefiPriorities[i]=pSetupData->BcpDefaultUefiPriorities[i]; + //(EIP122146+)> +#if FBO_DUAL_MODE + DeviceMapCount=GetDevMapDataCount( pFBODualDevMap ); + for( i=0; iDualPriorities[i]=pSetupData->BcpDefaultDualPriorities[i]; +#endif + //<(EIP122146+) +#else //<(EIP107268+) + DeviceMapCount=GetDevMapDataCount( pFBOLegacyDevMap ); + for( i=0; iLegacyPriorities[i]=i; + + DeviceMapCount=GetDevMapDataCount( pFBOUefiDevMap ); + for( i=0; iUefiPriorities[i]=i; + +#if FBO_DUAL_MODE + DeviceMapCount=GetDevMapDataCount( pFBODualDevMap ); + for( i=0; iDualPriorities[i]=i; +#endif + +#endif //#if USE_BCP_DEFAULT_PRIORITIES //(EIP107268+) + + Status = pRS->SetVariable(L"Setup",&gSetupGuid, SetupAttr, SetupSize, pSetupData); + pBS->FreePool( pSetupData ); + } + } + + return Status; +} +// +//---------------------------------------------------------------------------- +// 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 * +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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. +// +//*****************************************************************// + +// +//********************************************************************** +// +// Name: FixedBootOrder.c +// +// Description: This file is linked to Setup Binary for form callback +// +//********************************************************************** +// + +#include +#include +#include +#include + +#if CSM_SUPPORT +#include +#endif + +#if EFI_SPECIFICATION_VERSION>0x20000 +#include +#include +#include +#include +#include +#ifdef DEFAULT_LANGUAGE_CODE +const char *DefaultLanguageCode = CONVERT_TO_STRING(DEFAULT_LANGUAGE_CODE); +#endif +#else //#if EFI_SPECIFICATION_VERSION>0x20000 +#include +#include +#include +#endif + //(EIP103171+)> +#if CORE_COMBINED_VERSION>=0x4028e +#include +#endif + //<(EIP103171+) + +#include //(EIP112714) +#include +#include + +#include +#include + +#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; +// +//--------------------------------------------------------------------------- +// +// Procedure: GetDevMapDataCount +// +// Description: get the FBODevMap data amount. +// +// Input: +// IN FBODevMap *pFBODevMap +// +// Output: +// OUT UINT16 +// +// Modified: None +// +// Referrals: None +// +// Notes: None +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetHiiMapDataCount +// +// Description: get the FBOHiiMap data amount. +// +// Input: +// None +// +// Output: +// OUT UINT16 +// +// Modified: None +// +// Referrals: None +// +// Notes: None +// +//--------------------------------------------------------------------------- +// +UINT16 GetHiiMapDataCount() +{ + UINT16 count = 0; + + if( !pFBOHiiMap ) return 0; //end of data + + do{ + if( pFBOHiiMap[count].DevType == 0 ) break; + count++; + }while(1); + + return count; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: SearchHiiMapByType +// +// Description: Search HiiMap data index by device type. +// +// Input: +// IN UINT16 DevType +// +// Output: +// OUT UINT16 +// +// Modified: None +// +// Referrals: None +// +// Notes: None +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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 ; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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 ; + +} + +// +//--------------------------------------------------------------------------- +// +// 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 +// +//--------------------------------------------------------------------------- +// +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 ; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FBO_AdjustGroupName +// +// Description: Change FBO Group Name +// +// Input: +// +// Output: +// +// Referrals: None +// +// Notes: EIP 143657 +// +//--------------------------------------------------------------------------- +// +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) ; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetUEFIBootName +// +// Description: Get Variable Boot#### and return data pointer. +// +// Input: +// IN UINT16 BootIndex +// +// Output: +// EFI_LOAD_OPTION +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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+)> +// +//--------------------------------------------------------------------------- +// +// Procedure: UpdateDeviceHiiString +// +// Description: Update device item multi-language Hii string +// +// Input: +// UINT16 StrToken +// CHAR16 *DeviceName +// +// Output: +// None +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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; iSetString(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+) +// +//--------------------------------------------------------------------------- +// +// Procedure: UpdateLegacyDeviceHiiString +// +// Description: Update boot option type string token +// +// Input: +// IN UINT16 DevType +// IN UINT8 Index +// +// Output: +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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= 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 +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: UpdateUefiDeviceHiiString +// +// Description: Update boot option type string token +// +// Input: +// IN UINT16 DevType +// IN UINT8 Index +// +// Output: +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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= 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); + } +} + + +// +//--------------------------------------------------------------------------- +// +// 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: +// +//--------------------------------------------------------------------------- +// +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; +} + + +// +//--------------------------------------------------------------------------- +// +// 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: +// +//--------------------------------------------------------------------------- +// +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; iDualPriorities[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; iDualPriorities[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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: InitLegacyGroupDefault +// +// Description: Each group device name Hii String Update, and fixed HiiDB Oneof +// Data. +// +// +// Input: +// +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: InitUefiGroupDefault +// +// Description: Each group device name Hii String Update, and fixed HiiDB Oneof +// Data. +// +// +// Input: +// NONE +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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+)> +// +//--------------------------------------------------------------------------- +// +// Procedure: HiiAddLanguageBootOptionString +// +// Description: Install multi-language for STR_BOOT_OPTION. +// +// Input: +// NONE +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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+) + +// +//--------------------------------------------------------------------------- +// +// Procedure: InitialLegacyHiiItemDefault +// +// Description: Create legacy boot item device Hii Item data. +// +// Input: +// EFI_HANDLE HiiHandle +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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;iLegacyPriorities[i], LegacyBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11); + + for(j=0;j +#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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: InitialUefiHiiItemDefault +// +// Description: Create UEFI boot item device Hii Item data. +// +// Input: +// EFI_HANDLE HiiHandle +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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;iUefiPriorities[i], UefiBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11); + + for(j=0;j +#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 +// +//--------------------------------------------------------------------------- +// +// Procedure: InitialDaulHiiItem +// +// Description: Create Dual mode boot item device Hii Item data. +// +// Input: +// EFI_HANDLE HiiHandle +// Output: +// EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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;iDualPriorities[i], DualBootItemKey+i, Strid, STR_BOOT_OPTION_HELP, 0x11); + + for(j=0;j +#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 + +// +//--------------------------------------------------------------------------- +// +// 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: +// +//--------------------------------------------------------------------------- +// +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); +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FixedBootOrderStringInit +// +// Description: Install a form callback. +// +// Input: +// IN EFI_HII_HANDLE HiiHandle +// IN UINT16 Class +// +// Output: +// +// Modified: +// +// Referrals: SetupStringInit +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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; iCopyMem( &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;iSetVariable( + 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 Binary files /dev/null and b/Board/EM/FixedBootOrder/FixedBootOrder.chm 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 +// +//*****************************************************************// + +// +//********************************************************************** +// +// Name: FixedBootOrder.h +// +// Description: Header file of FixedBootOrder module +// +//********************************************************************** +// + + +#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 + +# +#----------------------------------------------------------------------- +# Name: FixedBootOrder.mak +# +# Description: This is a make file used to build component +# +#----------------------------------------------------------------------- +# +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 +// +//*****************************************************************// + + +// +//********************************************************************** +// +// Name: FixedBootOrderHII.c +// +// Description: HiiDatabase Related Functions +// +//********************************************************************** +// + +#include +#include +#include + +#if EFI_SPECIFICATION_VERSION>0x20000 +#include +#include +#include +#else +#include +#include +#include +#endif + +#include +#include +#include + +#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; + +// +//---------------------------------------------------------------------------- +// Procedure: EfiCompareGuid +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_GUID *Guid1, IN EFI_GUID *Guid2 +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +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 + +// +//--------------------------------------------------------------------------- +// +// 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 +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: CreateHiiIfrEndItem +// +// Description: Create a Ifr End Item. +// +// Input: +// UINT8 **IfrBufferPtr +// Output: +// EFI_STATUS +// Modified: +// NONE +// Referrals: +// NONE +// Notes: +// NONE +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// 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 +//--------------------------------------------------------------------------- +// +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; +}; + +// +//--------------------------------------------------------------------------- +// +// Procedure: CreateHiiIfrFormItem +// +// Description: Create a Form Item. +// +// Input: +// UINT8 **IfrBufferPtr +// UINT16 FromID +// STRING_REF StrTokenId +// +// Output: +// EFI_STATUS +// Modified: +// NONE +// Referrals: +// NONE +// Notes: +// NONE +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: InitHiiData +// +// Description: Use HiiDatabaseProtocol get hii data package to buffer +// +// Input: +// EFI_HANDLE HiiHandle +// +// Output: +// NONE +// Modified: +// NONE +// Referrals: +// NONE +// Notes: +// NONE +//--------------------------------------------------------------------------- +// +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); +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FIndVariableID +// +// Description: Search Hii Form Package Data of variable ID. +// +// Input: +// CHAR8 *VarName +// Output: +// UINT16 VarID +// Modified: +// NONE +// Referrals: +// NONE +// Notes: +// NONE +//--------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// + +// +//********************************************************************** +// +// Name: FixedBootOrderHii.h +// +// Description: Header file of FixedBootOrder module +// +//********************************************************************** +// + + +#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. +// +// +//*****************************************************************// + + +//********************************************************************** +// +// +// Name: FixedBootOrderStyle.c +// +// Description: Replace TSE funtion Popupsel.Draw PopupSel.HandleAction +// Frame.HandleAction +// +// +//********************************************************************** + +#include "minisetup.h" +#include "build\autoid.h" +#include +#include + +#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 @@ + + name = "Style - Up/Down move mode" + category = ModulePart + LocalRoot = "Board\EM\FixedBootOrder\FixedBootOrderStyle\" + RefName = "FixedBootOrderStyle" +[files] +"FixedBootOrderStyle.c" +"FixedBootOrderStyle.mak" +"FixedBootOrderStyle.sdl" + 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. +# +# +#***************************************************************** +# +#********************************************************************** +# +# +# Name: FixedBootOrderStyle.mak +# +# Description: +# +# +#********************************************************************** + +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 +//*****************************************************************// + + +// +//--------------------------------------------------------------------------- +// +// Name: FixedBootOrderTSE.c +// +// Description: TSE Related Functions +// +//--------------------------------------------------------------------------- +// + +//--------------------------------------------------------------------------- +// Include Files +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#if CSM_SUPPORT +#include +#endif +#include +#include +#include +#include +#include "FixedBootOrderHII.h" +#include "FixedBootOrder.h" +#include "AMITSEStrTokens.h" +//#include "SetupStrTokens.h" +#include +#include + +#include +#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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FixedBootOrderSetupEnter +// +// Description: TSE Setup enter Hook. +// +// Input: +// None +// +// Output: +// None +// +// Modified: +// +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +BOOLEAN FBO_EnterSetup = FALSE; +EFI_STATUS FixedBootOrderSetupEnter(IN void) +{ + TRACE((-1,"FixedBootOrder ELINK Setup Enter......\n")); + FBO_EnterSetup = TRUE; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FixedBootOrderToBoot +// +// Description: +// +// Input: +// None +// +// Output: +// None +// +// Modified: +// variable "LegacyDevOrder", "UefiDevOrder". +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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; iDualPriorities[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; jDeviceType ) + { + 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; iUefiPriorities[%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; iLegacyPriorities[i]; + if( pFBOLegacyDevMap[DevIndex].DevType == 0 ) continue; //Is Disable? + + for( j=0; jDeviceType ) + { + 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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: SetBootVariable +// +// Description: Set Boot#### variable Enable/Disable. +// +// Input: +// UINT16 BootIndex +// BOOLEAN EnableDisable +// +// Output: +// None +// +// Modified: variable Boot####. +// +// Referrals: +// +// Notes: +// +//--------------------------------------------------------------------------- +// +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; + +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FixedBootOrderSaveChange +// +// Description: Save boot device priority to variable. +// +// Input: +// None +// +// Output: +// None +// +// Modified: +// variable "LegacyDevOrder", "UefiDevOrder". +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: FixedBootOrderLoadedConfigDefaults +// +// Description: TSE LoadDefault ELINK Hook. +// +// Input: +// None +// Output: +// None +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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;iLegacyPriorities[i]=pSetupData->BcpDefaultLegacyPriorities[i]; + + DevMapDataCount = GetDevMapDataCount(pFBOUefiDevMap); + for(i=0;iUefiPriorities[i]=pSetupData->BcpDefaultUefiPriorities[i]; + //(EIP122146+)> +#if FBO_DUAL_MODE + DevMapDataCount = GetDevMapDataCount(pFBODualDevMap); + for(i=0;iDualPriorities[i]=pSetupData->BcpDefaultDualPriorities[i]; +#endif + //<(EIP122146+) +#else //<(EIP107268+) + DevMapDataCount = GetDevMapDataCount(pFBOLegacyDevMap); + for(i=0;iLegacyPriorities[i]=i; + + DevMapDataCount = GetDevMapDataCount(pFBOUefiDevMap); + for(i=0;iUefiPriorities[i]=i; + +#if FBO_DUAL_MODE + DevMapDataCount = GetDevMapDataCount(pFBODualDevMap); + for(i=0;iDualPriorities[i]=i; +#endif + +#endif //(EIP107268+) + pSetupData->FBO_Init=1; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: SetLegacyDevMap +// +// Description: Set Legacy DevMap data to pFBOLegacyDevMap +// +// Input: +// FBODevMap *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +EFI_STATUS SetLegacyDevMap(IN FBODevMap *p) +{ + pFBOLegacyDevMap = p; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: SetUefiDevMap +// +// Description: Set Uefi DevMap data to pFBOUefiDevMap +// +// Input: +// FBODevMap *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +EFI_STATUS SetUefiDevMap(IN FBODevMap *p) +{ + pFBOUefiDevMap = p; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: SetDualDevMap +// +// Description: Set Dual DevMap data to pFBODaulDevMap +// +// Input: +// FBODevMap *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +EFI_STATUS SetDualDevMap(IN FBODevMap *p) +{ + pFBODualDevMap = p; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetLegacyDevMap +// +// Description: Get Legacy DevMap data. +// +// Input: +// None +// Output: +// *FBODevMap +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +FBODevMap *GetLegacyDevMap(IN VOID) +{ + return pFBOLegacyDevMap; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetUefiDevMap +// +// Description: Get Uefi DevMap data. +// +// Input: +// None +// Output: +// *FBODevMap +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +FBODevMap *GetUefiDevMap(IN VOID) +{ + return pFBOUefiDevMap; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetDualDevMap +// +// Description: Get Daul DevMap data. +// +// Input: +// *FBODevMap +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +FBODevMap *GetDualDevMap(IN VOID) +{ + return pFBODualDevMap; +} + + +// +//--------------------------------------------------------------------------- +// +// Procedure: SetHiiMap +// +// Description: Set Uefi DevMap data to pFBOHiiMap +// +// Input: +// FBOHiiMap *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +EFI_STATUS SetHiiMap(IN FBOHiiMap *p) +{ + pFBOHiiMap = p; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetHiiMap +// +// Description: Get HiiMap data. +// +// Input: +// None +// Output: +// *pFBOHiiMap +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +FBOHiiMap *GetHiiMap(IN VOID) +{ + return pFBOHiiMap; +} + + //(EIP123284+)> +// +//--------------------------------------------------------------------------- +// +// Procedure: SetBootOptionTokenMap +// +// Description: Set BootOptionTokenMap data +// +// Input: +// UINT16 *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +EFI_STATUS SetBootOptionTokenMap(IN UINT16 *p) +{ + pBootOptionTokenMap = p; + return EFI_SUCCESS; +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetBootOptionTokenMap +// +// Description: Get BootOptionTokenMap data. +// +// Input: +// None +// Output: +// *UINT16 +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +UINT16 *GetBootOptionTokenMap(IN VOID) +{ + return pBootOptionTokenMap; +} + //<(EIP123284+) + +// +//--------------------------------------------------------------------------- +// +// Procedure: FBOSetNewDescription +// +// Description: Set New Description data +// +// Input: +// FBO_DEVICE_INFORM *p +// Output: +// EFI_STATUS +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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 ; + } + +} + +// +//--------------------------------------------------------------------------- +// +// Procedure: GetNewDescription +// +// Description: Get New Description data. +// +// Input: +// None +// Output: +// *FBO_DEVICE_INFORM +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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 +}; + +// +//--------------------------------------------------------------------------- +// +// Procedure: FBO_Protocol_install +// +// Description: Initialize EFI_FIXED_BOOT_ORDER_PROTOCOL function service. +// +// Input: +// None +// Output: +// None +// Modified: +// None +// Referrals: +// None +// Notes: +// +//--------------------------------------------------------------------------- +// +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 Binary files a/Board/EM/Setup/Setup.uni and b/Board/EM/Setup/Setup.uni 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 +// +//**************************************************************************** +// +// +// Name: SlpSupport.c +// +// Description: +// Updated the XSDT with the SLIC OEM Activation ACPI Table. +// +// +//**************************************************************************** + + +//--------------------------------------------------------------------------- + +#include +#include +#include +#include "SlpSupport.h" + +//--------------------------------------------------------------------------- + + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// + +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; +} + + +// +//---------------------------------------------------------------------------- +// +// Procedure: PreserveSlicBinaries +// +// Description: This function preserves the the Marker and PubKey binaries. +// +// Input: VOID +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// + +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; +} + + +// +//---------------------------------------------------------------------------- +// +// Procedure: PublishSlicTable +// +// Description: This function publish SLIC table in the ACPI. +// +// Input: VOID +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// + +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; +} + + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// + +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 Binary files /dev/null and b/Core/EM/SLP20/SlpSupport.chm 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 @@ + + 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" + 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 +// +// +//***************************************************************************** +// +// +// Name: SlpSupport.dxs +// +// Description: This file is the dependency file for SlpSupport eModule. +// +// +//***************************************************************************** + +//---------------------------------------------------------------------------- +// Header files for GUID definitions +//---------------------------------------------------------------------------- + +#include + +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 +// +// +//**************************************************************************** +// +// +// Name: SlpSupport.h +// +// Description: SlpSupport Header file. +// +// +//**************************************************************************** + +#ifndef __SLP_SUPPORT__H__ +#define __SLP_SUPPORT__H__ +#ifdef __cplusplus +extern "C" { +#endif + +//------------------------------------------------------------------------ + +#include +#include +#include + +//------------------------------------------------------------------------ + +#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) + +// +//---------------------------------------------------------------------------- +// +// 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. +// +//---------------------------------------------------------------------------- +// + +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; + +// +//---------------------------------------------------------------------------- +// +// 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) +// +//---------------------------------------------------------------------------- +// + +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; + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// + +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 +# +#********************************************************************** +# +# +# Name: SlpSupport.mak +# +# Description: Make file for SlpSupport eModule. +# +# +#********************************************************************** + +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 +; +;***************************************************************************** +; +; +; Name: OemTable.asm +; +; Description: This is OEM table binary for Aptio Firmware Volume. +; +; +;***************************************************************************** + + 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 +// +// +//***************************************************************************** +// +// +// Name: Slp10.c +// +// Description: Implementation of the SLP 1.0 eModule. +// +// +//***************************************************************************** + +//---------------------------------------------------------------------------- + +#include +#include +#include +#include "Slp10.h" + +//---------------------------------------------------------------------------- + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// + +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 Binary files /dev/null and b/Core/EM/Slp10/Slp10.chm 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 @@ + + 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" + 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 @@ +// +//---------------------------------------------------------------------------- +// Name: Slp10.dxs +// +// Description: This file is the dependency file for Slp10 driver +// +//---------------------------------------------------------------------------- +// + +//---------------------------------------------------------------------------- +// Header files for GUID definitions +//---------------------------------------------------------------------------- + +#include + +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 +// +// +//***************************************************************************** +// +// +// Name: Slp10.h +// +// Description: Internal header file of the Slp10 eModule. +// +// +//***************************************************************************** + +#ifndef _AMI_SLP10_MODULE_H +#define _AMI_SLP10_MODULE_H + +#include +#include + +#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) + +// +//---------------------------------------------------------------------------- +// 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) +// +//---------------------------------------------------------------------------- +// + +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 +# +#***************************************************************************** +# +# +# Name: Slp10.mak +# +# Description: Make file for Slp10 eModule. +# +# +#***************************************************************************** + +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 Binary files /dev/null and b/EDK/MiniSetup/AMITSE.chm 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. +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: AMILogo.c +// +// Description: This file contains code to handle logo. +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: AMILogo.h +// +// Description: header file to define logo related stuff. +// +//---------------------------------------------------------------------------- +// + +#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. +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: EdkHelper.c +// +// Description: This file contains code from EDK library. +// +//---------------------------------------------------------------------------- +// + +/*++ + +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 +); + +// +//---------------------------------------------------------------------------- +// Procedure: EfiInitializeDriverLib +// +// Description: To avoid including EDK libs. +// +// Input: ImageHandle and Systemtable +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS +EfiInitializeDriverLib ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + InitAmiLib(ImageHandle,SystemTable); + gST = pST; + gBS = pBS; + gRT = pRS; + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibAllocateZeroPool +// +// Description: To avoid including EDK libs. +// +// Input: size +// +// Output: pointer +// +//---------------------------------------------------------------------------- +// +void* MallocZ(UINTN Size); +VOID * +EfiLibAllocateZeroPool ( + IN UINTN AllocationSize + ) +{ + return MallocZ(AllocationSize); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibAllocatePool +// +// Description: To avoid including EDK libs. +// +// Input: size +// +// Output: pointer +// +//---------------------------------------------------------------------------- +// +void* Malloc(UINTN Size); +VOID * +EfiLibAllocatePool ( + IN UINTN AllocationSize + ) +{ + return Malloc(AllocationSize); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiCompareGuid +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_GUID *Guid1, IN EFI_GUID *Guid2 +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN +EfiCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +{ + return (BOOLEAN)(0==MemCmp((UINT8*)Guid1,(UINT8*)Guid2,sizeof(EFI_GUID))); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiCompareMem +// +// Description: To avoid including EDK libs. +// +// Input: IN VOID *MemOne, IN VOID *MemTwo, +// +// Output: INTN +// +//---------------------------------------------------------------------------- +// +INTN +EfiCompareMem ( + IN VOID *MemOne, + IN VOID *MemTwo, + IN UINTN Length + ) +{ + return MemCmp(MemOne,MemTwo,Length); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcslen +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +// +UINTN Wcslen(CHAR16 *string); +UINTN +EfiStrLen ( + IN CHAR16 *String + ) +{ + return Wcslen(String); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcscpy +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string1, CHAR16* string2 +// +// Output: CHAR16* +// +//---------------------------------------------------------------------------- +// +CHAR16* Wcscpy(CHAR16 *string1, CHAR16* string2); +VOID +EfiStrCpy ( + IN CHAR16 *Destination, + IN CHAR16 *Source + ) +{ + Wcscpy(Destination,Source); +} + +// +//---------------------------------------------------------------------------- +// Procedure: Wcscmp +// +// Description: To avoid including EDK libs. +// +// Input: CHAR16 *string1, CHAR16 *string2 +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DPAdd +// +// Description: To avoid including EDK libs. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2 +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DPAddNode +// +// Description: To avoid including EDK libs. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *pDp1, EFI_DEVICE_PATH_PROTOCOL *pDp2 +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiDevicePathFromHandle +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_HANDLE Handle +// +// Output: EFI_DEVICE_PATH_PROTOCOL * +// +//---------------------------------------------------------------------------- +// +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) + +// +//---------------------------------------------------------------------------- +// Procedure: EfiFileDevicePath +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_HANDLE Device OPTIONAL, IN CHAR16 *FileName +// +// Output: EFI_DEVICE_PATH_PROTOCOL * +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiInitializeFwVolDevicepathNode +// +// Description: To avoid including EDK libs. +// +// Input: IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode, +// IN EFI_GUID *NameGuid +// +// Output: VOID EFIAPI +// +//---------------------------------------------------------------------------- +// +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)); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiLibNamedEventSignal +// +// Description: To avoid including EDK libs. +// +// Input: IN EFI_GUID *Name +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: IsHexDigit +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: HexStringToBuf +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------------------------------------------------------------------------------- +// 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. +// +//----------------------------------------------------------------------------------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: Mul64 +// +// Description: To avoid including EDK libs. +// +// Input: +// +// Output: +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +CHAR16 +NibbleToHexChar ( + IN UINT8 Nibble + ) +{ + Nibble &= 0x0F; + if (Nibble <= 0x9) { + return (CHAR16)(Nibble + L'0'); + } + + return (CHAR16)(Nibble - 0xA + L'A'); +} + + +// +//------------------------------------------------------------------------------------ +// Procedure: HexToNibbleChar +// +// Description: Converts the hex value to character. +// +// Input: Nibble - lower nibble of a byte. +// +// Output: Hex unicode character. +// +//-------------------------------------------------------------------------------------- +// +UINT8 +HexToNibbleChar ( + IN UINT8 Nibble + ) +{ + if (Nibble - L'0' <= 0x9) { + return (CHAR16)(Nibble - L'0'); + } + + return (CHAR16)(Nibble + 0xA - L'A'); +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ToLower +// +// Description: Converts the unicode character of the string from uppercase to lowercase. +// +// Input: Str - String to be converted +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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'); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SwapBuffer +// +// Description: Swap bytes in the buffer. +// +// Input: Buffer - Binary buffer. +// BufferSize - Size of the buffer in bytes. +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: UnicodeToConfigString +// +// Description: Convert Unicode string to binary representation Config string, e.g. +// "ABCD" => "0041004200430044". Config string appears in (i.e. +// "&NAME="), or Name/Value pair in (i.e. "label="). +// +// Input: ConfigString - Binary representation of Unicode String, := (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. +// +//---------------------------------------------------------------------------- +// +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 is defined in lowercase format. + // + ToLower (String); + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 is defined in lowercase format. + // + ToLower (Str); + + return Status; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 +// +// +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: edkhelper.h +// +// Description: Edk helper header file. +// +// +//********************************************************************** + +#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 +// +//*****************************************************************// +//*****************************************************************// + + +// +//---------------------------------------------------------------------------- +// +// Name: HOOKANCHOR.C +// +// Description: file to handle the hook functions +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: SearchLastHook +// +// Description: Returns the lasthookfn number +// +// Input: firsthookfn +// +// Output: lastHookfn +// +//---------------------------------------------------------------------------- +// +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 +} + + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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(); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 @@ + + 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" + 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 +//********************************************************************** +// +// +// Name: Resources.c +// +// Description: Library routines to load image resources. +// +// +//********************************************************************** +#include + +#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 + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: timer.h +// +// Description: Header file for code to handle the timer. +// +//---------------------------------------------------------------------------- +// +#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 +// +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: amiver.h +// +// Description: This file contains version macros. +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: bbs.c +// +// Description: takecare of bbs/legacy boot management. +// +// +//********************************************************************** + +#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); + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSInitProtocol +// +// Description: function to initialize the bbs protocol. +// +// Input: void +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +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); +} + + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 +// +//------------------------------------------------------------------------------------- +// Procedure: RearrangeBBSOrder +// +// Description: Rearranges the bootdata legacy entries with legacydevorder defaults +// +// Input: VOID * - Cache Buffer +// +// Output: VOID +// +//-------------------------------------------------------------------------------------- +// +//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 + +// +//---------------------------------------------------------------------------- +// Procedure: BBSGetDeviceList +// +// Description: function to get the list of all the devices +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; jLength >= 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(jLength); + NoOfLegacyGroups++; + + pBootData->LegacyEntryOffset = (UINTN)NewDevEntry - (UINTN)NewLegacyOrder; + pBootData->LegacyDevCount = count; + + + if(gIsSaveDisabledBBSDevicePath) + { + //Make sure the right devices are disabled + for(j=0;jData[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; lData[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) ); + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSSetBootPriorities_BootOrder +// +// Description: Assign priority as per boot order other than 0 priority devices +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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;jDevicePath ) ) + { + 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;indexLegacyDevCount;index++)//EIP-166385 + { + for(index1=0;index1LegacyDevCount;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;iLegacyDevCount;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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSSetBootPriorities +// +// Description: function to set boot priorities +// +// Input: BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 ); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSSetDevicePriorities +// +// Description: function to set boot device priorities +// +// Input: BBS_TABLE *BBSInfo, UINT16 *Priority, BOOT_DATA *BootData +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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;indexLegacyDevCount;index++)//EIP-166385 + { + for(index1=0;index1LegacyDevCount;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); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: CreateDriveString +// +// Description: function to create the device string +// +// Input: CHAR16 *String, UINT16 *IdentifyDriveData +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: BBSBuildDefaultName +// +// Description: function to build the default boot device name +// +// Input: CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; + } + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSLaunchDevicePath +// +// Description: function to launch the device path +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSUpdateBootData +// +// Description: function to update boot related data +// +// Input: UINT16 GroupNo +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID BBSUpdateBootData(UINT16 GroupNo) +{ + UINTN i,j; + BOOT_DATA *bootData; + + for( j=0,i=0; iActive & LOAD_OPTION_HIDDEN)) + continue; + + if ( BBSValidDevicePath(bootData->DevicePath) ) + { + if(GroupNo == j) + { + gCurrLegacyBootData = bootData; + break; + } + j++; + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSGetOptionName +// +// Description: function to get the name of the option +// +// Input: UINT16 *Option, UINT16 Pos +// +// Output: string +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BBSCheckDisabled +// +// Description: function to check whether a perticular entry is disabled. +// +// Input: UINT16 *Option, UINT16 Pos +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: BBSSetDisabled +// +// Description: function to disable a perticular entry. +// +// Input: UINT16 Index, VOID **DisDPs, UINTN *DPSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: GetBBSBootOptionName +// +// Description: function to get the Boot option name. +// +// Input: BOOT_DATA *bootData +// +// Output: CHAR16* - BootOptionName +// +//---------------------------------------------------------------------------- +// + +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; iData[0]) + break; + } + if(iName; + } + + return bootData->Name; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsBBSDevicePath +// +// Description: function to check for bbs device path support. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN IsBBSDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath ) +{ + return (BOOLEAN)( + ( DevicePathType( DevicePath ) == BBS_DEVICE_PATH ) && + ( DevicePathSubType( DevicePath ) == BBS_BBS_DP ) + ); +} + +//EIP-93797 Starts +// +//---------------------------------------------------------------------------- +// Procedure: GetBBSOptionStatus +// +// Description: function to get for bbs option status +// +// Input: BOOT_DATA +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// +//********************************************************************** +// +// +// Name: bbs.h +// +// Description: Header file for bbs/legacy boot management. +// +// +//********************************************************************** + +#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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: BOOT.C +// +// Description: This file contains code for Boot management +// +//---------------------------------------------------------------------------- +// + +#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 + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +BOOT_DATA *DriverGetDriverData (UINT16 Option) +{ + UINTN i; + + for ( i = 0; i < gDriverOptionCount; i++ ) + { + if ( gDriverData[i].Option == Option ) + return &gDriverData[i]; + } + return NULL; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +CHAR16 *BootGetOptionName( BOOT_DATA *bootData) +{ + if ( BBSValidDevicePath(bootData->DevicePath) ) { + return CsmBBSBootOptionName(bootData); + } + return bootData->Name; +} + +//EIP70421 & 70422 Support for driver order +// +//------------------------------------------------------------------------------------ +// 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 +// +//------------------------------------------------------------------------------------ +// +CHAR16 *DriverGetOptionName (BOOT_DATA *DriverData) +{ + return DriverData->Name; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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) + { + //gBootData[j].Option is not present in BootOrder; fill it + BootOrder[i] = gBootData[j].Option; + i++; + } + } + } + } + + if(ShowAllBBSDev) + { + count = 0; + for(i=0;iDevicePath) ) + { + 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); + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetLanguages +// +// Description: Finds the languages that the firmware supports. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetLanguages +// +// Description: Finds the languages that the firmware supports. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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;iDevicePath) ) + { + 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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//------------------------------------------------------------------------------- +// Procedure: FixHiddenOptions +// +// Description: Function to move the hidden option at last of the boot order +// +// Input: UINT16 ** => Boot order to be reformed +// +// Output: VOID +// +//-------------------------------------------------------------------------------- +// +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; + } + } + } + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootSetBootManagerVariables +// +// Description: function to set the variables for the boot manager +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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) + { + //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 +// +//-------------------------------------------------------------------------------------- +// Procedure: _SetDriverManagerVariables +// +// Description: Sets DriverManager variable for drivers count and sets DriverOrder +// +// Input: void +// +// Output: void +// +//-------------------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: _BootSetBootNowCount +// +// Description: function to set boot new devices count +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +UINT16 _BootSetBootNowCount(VOID) +{ + UINT16 count = 0; + UINTN i; + + BOOT_DATA *bootData; + + for( i=0; iDevicePath)) + { + count = count + bootData->LegacyDevCount; + } + else + count++; + } + + return count; +} + +//EIP 77400 Starts +// +//---------------------------------------------------------------------------- +// Procedure: _ShellClearScreen +// +// Description: Clears the screen for shell boot +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _RegisterShellGuid +// +// Description: Registers the shell guid +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: _BootLaunchDevicePath +// +// Description: function to launch the boot operation +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Options, UINTN OptionSize, BOOLEAN ValidBootOption +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _DiscoverPartition +// +// Description: function to launch the boot operation +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevicePath +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +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; iHandleProtocol(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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootInstallLoadOptions +// +// Description: function to install the load options +// +// Input: EFI_HANDLE handle, VOID *Options, UINTN OptionSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 } +}; + +// +//---------------------------------------------------------------------------- +// Procedure: _BootBuildFVDevicePath +// +// Description: function to build firmware volume device path protocol. +// +// Input: UINT32 *index, EFI_GUID *guidPtr +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _BootBuildFileDevicePath +// +// Description: function to build File device path protocol. +// +// Input: UINT32 *index, CHAR16 *fileName +// +// Output: device path +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: IsBootDeviceEnabled +// +// Description: Function to check the boot option status +// +// Input: UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup +// +// Output: +// +//---------------------------------------------------------------------------- +// +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) + { + //gBootData[j].Option is not present in BootOrder; fill it + BootOrder[i] = gBootData[j].Option; + i++; + } + } + } + } + + if(ShowAllBBSDev) + { + count = 0; + for(i=0;iDevicePath) ) + { + 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); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetOptionStatus +// +// Description: Function to check the boot option status in Boot Order +// +// Input: BOOT_DATA *bootData, BOOLEAN FromSetup +// +// Output: +// +//---------------------------------------------------------------------------- +// +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 ; iOption) + break; + } + if(i == gBootOptionCount ) + { + MemFreePointer((VOID **) &buffer); + return TRUE; + } + else + { + MemFreePointer((VOID **) &buffer); + return FALSE; + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootGetBBSOptionStatus +// +// Description: Function to check the Legacy boot option status +// +// Input: BOOT_DATA *bootData, BOOLEAN FromSetup, BOOLEAN ShowAllBBSDev +// +// Output: +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: LoadOptionhidden +// +// Description: Function to check the Boot option status if gLoadOptionhidden token is Enabled +// +// Input: UINT16 value +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CheckHiddenforBootDriverOption +// +// Description: Check whether the Boot/Driver option has hidden property +// +// Input: UINT16, BOOLEAN +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +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 +// +//----------------------------------------------------------------------------------------------- +// 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 +// +//------------------------------------------------------------------------------------------------ +// +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; +} + +// +//-------------------------------------------------------------------------------------- +// Procedure: SetBootOptionSupportVariable +// +// Description: Function to set the BootOptionSupport variable +// +// Input: UINT32 = Capabilities for the BootOptionSupport variable +// +// Output: VOID +// +//-------------------------------------------------------------------------------------- +// +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 +// +//-------------------------------------------------------------------------------------- +// 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 +// +//-------------------------------------------------------------------------------------- +// +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" + +// +//---------------------------------------------------------------------------- +// Procedure: DrawLineWithAttribute +// +// Description: function to draw the lines with attributes +// +// Input: UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBorder +// +// Description: function to draw the border +// +// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBox +// +// Description: function to draw a box +// +// Input: UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +// +// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: Box.h +// +// Description: Header file for box related functions +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Buffer.c +// +// Description: This file contains code to manage buffers +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +VOID GetCoordinates(INT32 *x, INT32 *y, INT32 *z); +INT32 GetactualScreentop(VOID); +BOOLEAN IsMouseSupported(VOID); +// +//---------------------------------------------------------------------------- +// Procedure: InitializeScreenBuffer +// +// Description: function to initialize the screen buffer +// +// Input: UINT8 attrib +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SlowFlushLines +// +// Description: function to slow flush lines +// +// Input: UINTN Top, UINTN Bottom +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +// +//---------------------------------------------------------------------------- +// Procedure: FlushLines +// +// Description: function to set the positions for flush lines +// +// Input: UINTN Top, UINTN Bottom +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: DoRealFlushLines +// +// Description: function to flush lines +// +// Input: NIL +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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+1Chars[TempOffSet + LastDiff + 1]) && LastDiff+210) // 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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetDesiredTextMode +// +// Description: function to set the test mode +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: Buffer.h +// +// Description: Header file for code to manage buffers +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: DoBMPmgr.c +// +// Description: file contains code that is taken from graphics.c +// to eliminnate library dependancy +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + + +//#if SETUP_BMP_LOGO_SUPPORT + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: globals.c +// +// Description: file contains code to take care of the globals in boot only +// +//---------------------------------------------------------------------------- +// + +#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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: hiistring.c +// +// Description: file contains code to handle the hii sting operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +#define VARIABLE_NAME_LENGTH 40 + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsCharWide +// +// Description: function to check the given character is wide +// +// Input: CHAR16 strWide +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: HiiAddString +// +// Description: function to add a string +// +// Input: VOID* handle, CHAR16 *string +// +// Output: token +// +//---------------------------------------------------------------------------- +// + +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: EfiTestPrintLength +// +// Description: function to get the printable lenght of the string +// +// Input: CHAR16 *string +// +// Output: Size of string +// +//---------------------------------------------------------------------------- +// +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. +// +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: hiistring.h +// +// Description: Header file for code to handle the hii sting operations +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: logo.c +// +// Description: file contains code to handle the logo operations. +// Taken from graphics.c to eliminnate library dependancy +// +//---------------------------------------------------------------------------- +// + +#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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CleanUpLogo +// +// Description: function to Clear all the logo buffers. +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID CleanUpLogo() +{ + CleanUpExtendedLogoWrapper(); + InvalidateStatusInBgrtWrapper (); //Setup key detected so clearing the status field +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetScreenResolution +// +// Description: function to set the screen resolutions. +// +// Input: UINTN ResX, UINTN ResY +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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;iMode->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 +// +//---------------------------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------------------------- +// +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;iMode->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 + +// +//---------------------------------------------------------------------------- +// Procedure: GetScreenResolution +// +// Description: function to get the screen resolutions. +// +// Input: UINTN *ResX, UINTN *ResY +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBltProgressBar +// +// Description: function to draw a progress bar +// +// Input: nil +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawBlock +// +// Description: function to draw draw a block +// +// Input: UINTN DestX, UINTN DestY, UINTN Width, UINTN Height, EFI_UGA_PIXEL *BltBuffer +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: ConvertBlt2Bmp +// +// Description: Converts the Blt in the screen to Bmp buffer +// +// Input: VOID +// +// Output: VOID * +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//------------------------------------------------------------------------------------------------------- +// 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 +// +//-------------------------------------------------------------------------------------------------------- +// +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); + } +} + +// +//------------------------------------------------------------------------------------------------------- +// 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 +// +//-------------------------------------------------------------------------------------------------------- +// +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 +// +//------------------------------------------------------------------------------------------------------- +// 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 +// +//-------------------------------------------------------------------------------------------------------- +// +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; +} + +// +//------------------------------------------------------------------------------------------------------- +// Procedure: SetNativeResFromEdid +// +// Description: Finds and sets the resolution from EDID +// +// Input: VOID +// +// Output: VOID +// +//-------------------------------------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: mem.c +// +// Description: file contains code to handle the memory operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: MemFreePointer +// +// Description: function to free the pointers +// +// Input: VOID **ptr +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemFreePointer( VOID **ptr ) +{ + if ( ( ptr == NULL ) || ( *ptr == NULL ) ) + return; + + gBS->FreePool( *ptr ); + *ptr = NULL; +} + +// +//----------------------------------------------------------------------------------------------- +// 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 +// +//------------------------------------------------------------------------------------------------- +// +VOID StringZeroFreeMemory (VOID **ptr) +{ + if ( (ptr == NULL) || (*ptr == NULL)) + return; + + MemSet (*ptr, (EfiStrLen ((CHAR16 *)*ptr) * sizeof (CHAR16)), 0); + gBS->FreePool (*ptr); + *ptr = NULL; +} +// +//---------------------------------------------------------------------------- +// Procedure: MemCopy +// +// Description: function to copy a memory +// +// Input: VOID *dest, VOID *src, UINTN size +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemCopy( VOID *dest, VOID *src, UINTN size ) +{ + gBS->CopyMem( dest, src, size ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemSet +// +// Description: function to set the memory with the specified value +// +// Input: VOID *buffer, UINTN size, UINT8 value +// +// Output: void +// +//---------------------------------------------------------------------------- +// +#if TSE_USE_EDK_LIBRARY +VOID MemSet( VOID *buffer, UINTN size, UINT8 value ) +{ + gBS->SetMem( buffer, size, value ); +} +#endif //#if TSE_USE_EDK_LIBRARY + +// +//---------------------------------------------------------------------------- +// Procedure: MemReallocateZeroPool +// +// Description: function to reuse a allocated buffer +// +// Input: VOID *oldBuffer, UINTN oldSize, UINTN newSize +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemFillUINT16Buffer +// +// Description: function to fill a UINT16 Buffer +// +// Input: VOID *buffer, UINTN bufferSize, UINT16 value +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID MemFillUINT16Buffer( VOID *buffer, UINTN bufferSize, UINT16 value ) +{ + UINTN Index; + UINT16 *bufPtr = (UINT16 *)buffer; + + for ( Index = 0; Index < bufferSize; Index++ ) + *bufPtr++ = value; +} + +// +//---------------------------------------------------------------------------- +// Procedure: MemCmp +// +// Description: function to compare the memory of two buffers. +// +// Input: UINT8 *dest, UINT8 *src, UINTN size +// +// Output: 0/1/-1 +// +//---------------------------------------------------------------------------- +// +#if TSE_USE_EDK_LIBRARY +INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size ) +{ + UINTN i; + + for( i=0; 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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUP.C +// +// Description: This file contains code for entrypoint and setup loop +// +//---------------------------------------------------------------------------- +// + +#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 } +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: MainSetupLoopInit +// +// Description: Main function that initializes the setup Loops. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: GetDefaultPassword +// +// Description: Getting default password from SDL token based on USER/ADMIN token +// +// Input: UINT32, AMITSESETUP* +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetDefaultPassword +// +// Description: Function to set defaults password in NVRAM, if any present in SDL +// +// Input: void +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUP.h +// +// Description: Main header file takes care of TSE includes. +// +//---------------------------------------------------------------------------- +// + +#ifndef _MINISETUP_H_ +#define _MINISETUP_H_ + +#ifdef TSE_FOR_APTIO_4_50 +#include +#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 +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: MINISETUPEXT.C +// +// Description: This file contains code for entrypoint and setup loop +// +//---------------------------------------------------------------------------- +// + +#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); +// +//---------------------------------------------------------------------------- +// Procedure: ClearGrphxScreen +// +// Description: Function to clear the graphics screen. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +} + + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: DrawBootOnlyBbsPopupMenu +// +// Description: function for the BBS Popup menu +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 ; + } +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// + +VOID BbsBoot(VOID) +{ + if(gEnterSetup != TRUE) + BootLaunchBootNow(gBBSPopupSel, gPopupMenuShowAllBbsDev) ; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BbsStrnCpy +// +// Description: function the string copy +// +// Input: CHAR16 *Dst, CHAR16 *Src, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBS_GetKey +// +// Description: function to read the input key +// +// Input: void +// +// Output: ScanCode/UniCode +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CheckStrings +// +// Description: function to validate the stings +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetScrollPosition +// +// Description: function to set the position of the Scroll bar +// +// Input: int Index, int DirFlg +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: UpDisplayList +// +// Description: function to display the upside list +// +// Input: int Start, int End, int flag, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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--; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DownDisplayList +// +// Description: function to display the downside list +// +// Input: int Start, int End, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +void DownDisplayList(int Start, int End, int NumLines) +{ + int RowNum; + + for( RowNum=START_ROW_IDX; Start +//---------------------------------------------------------------------------- +// Procedure: HighLightLine +// +// Description: function to hilight a perticular line +// +// Input: int UpDown, int NumLines +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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++; + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: InitgProgress +// +// Description: +// +// Input: No Arguments +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID InitgProgress( VOID ) +{ + gProgress = EfiLibAllocateZeroPool(sizeof (PROGRESSBAR_INFO) ); + gProgress->quiteBootActive = FALSE ; + gProgress->active = FALSE ; + gProgress->completed = 0 ; + gProgress->delta = 0 ; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: BootOnlyUpdateVersionString +// +// Description: Function to update version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SavePostScreen +// +// Description: Function to save the post screen +// +// Input: UINTN *SizeOfX, UINTN *SizeOfY +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestorePostScreen +// +// Description: Function to restore the saved screen +// +// Input: VOID *UgaBlt, UINTN SizeOfX, UINTN SizeOfY +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: notify.c +// +// Description: file contains code to support the notification functions +// +//---------------------------------------------------------------------------- +// + +#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 ); + +// +//---------------------------------------------------------------------------- +// Procedure: _DrvHealthNotifyFunction +// +// Description: Notification function for driver health protocol instal. +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _DrvHealthNotifyFunction (EFI_EVENT Event, VOID *Context) +{ + SetDriverHealthCount (); +} + + +// +//---------------------------------------------------------------------------- +// Procedure: _UpdateGoPNotifyFunction +// +// Description: Notification function for driver health protocol instal. +// +// Input: EFI_EVENT , VOID * +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: RegisterNotification +// +// Description: It will create a notify event and register a notification. +// +// Input: VOID +// +// Output: Status +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: NotificationFunction +// +// Description: function to perform the notification operations. +// +// Input: EFI_EVENT Event, NOTIFICATION_INFO *Context +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// Procedure: ActivateApplication +// +// Description: function for the Active application operations. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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(); +*/ + } +} + + + +// +//---------------------------------------------------------------------------- +// Procedure: ActivateInput +// +// Description: function for the active Input. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: UpdateGoPUgaDraw +// +// Description: function to update the Gop when controls comes to TSE. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// + +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: password.c +// +// Description: This file contains code to handle password operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordCheckInstalledLocal +// +// Description: function to check the password type +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordAuthenticateLocal +// +// Description: function to check the authentication of the password +// +// Input: CHAR16 *Password +// +// Output: password type +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PasswordUpdateLocal +// +// Description: function to ubdate the password +// +// Input: CHAR16 *Password, , UINTN Size +// +// Output: updated password +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: password.h +// +// Description: Header file for code to handle password operations +// +//---------------------------------------------------------------------------- +// + +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: postmgmt.c +// +// Description: file to handle the post management operations +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" +#if !TSE_USE_EDK_LIBRARY +#include "Acpi.h" +#include +#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); +// +//---------------------------------------------------------------------------- +// Procedure: DrawOEMImage +// +// Description: Function to draw OEMLogo to in post screen operations +// +// Input: UINTN *, UINTN*, INTN, INTN +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: InitPostScreen +// +// Description: fucntion to perform the post screen operations +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: InstallKeyHandlers +// +// Description: fucntion to install the timer event +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: InstallClickHandlers +// +// Description: fucntion to install the timer event +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: CalculateChecksum +// +// Description: Calculates the checksum for the given structure +// +// Input: VOID => Table structure +// UINT8 => Table Size +// +// Output: UINT8 => Checksum for the table +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------------------------------------------- +// Procedure: InvalidateStatusInBgrt +// +// Description: Disables the BGRT status field if any changes happened in screen other than the image display +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------------------------------------------- +// Procedure: UninstallBGRT +// +// Description: UninstallsBGRT table, Called for Legacy Boot +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: PostMgmtExt.c +// +// Description: This file contains code extended post management operations +// +//---------------------------------------------------------------------------- +// + +#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 ); +// +//---------------------------------------------------------------------------- +// Procedure: SetSystemAccessValue +// +// Description: function to set the system access Value +// +// Input: UINT8 sysAccessValue +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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) ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SetPasswordType +// +// Description: function to set the type of password +// +// Input: UINT32 PasswordType +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} +*/ +// +//---------------------------------------------------------------------------- +// Procedure: CheckSystemPassword +// +// Description: Function to check the system password +// +// Input: UINT32 EmptyPasswordType, UINTN *NoOfRetries, UINTN *TimeOut +// +// Output: PasswordCheck +// +//---------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + //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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _DrawPasswordWindow +// +// Description: Function to draw password window with attributes +// +// Input: UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _ReportInBox +// +// Description: Function to report using Box +// +// Input: UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos, +// UINTN CurrYPos, BOOLEAN bWaitForReturn +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _GetPassword +// +// Description: Function to get password from the user +// +// Input: CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos, +// UINTN CurrYPos, UINTN *pTimeOut +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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] = (iConOut->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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Print.c +// +// Description: file contains code to support the print functionalities +// +//---------------------------------------------------------------------------- +// + +/*++ + 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 +// +//------------------------------------------------------------------------------------------------------------- +// 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. +// +//------------------------------------------------------------------------------------------------------------- +// +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 + ); + } +} + + + +// +//------------------------------------------------------------------------------------------------------------- +// 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. +// +//------------------------------------------------------------------------------------------------------------- +// +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]; + +// +//------------------------------------------------------------------------------------------------------------- +// Procedure: SetupDebugPrint +// +// Description: +// +// Input: +// +// Output: +// +//------------------------------------------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupShowDebugScreen +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +//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 + +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupShowDebugScreen +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +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); + + +} +// +//---------------------------------------------------------------------------- +// +// Procedure: SetupDebugKeyHandler +// +// Description: +// +// Parameter: +// +// Return value: +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: PROTOCOL.C +// +// Description: This file contains code for TSE exported protocol +// functions. +// +//---------------------------------------------------------------------------- +// + +#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 + +// +//---------------------------------------------------------------------------- +// Procedure: InstallProtocol +// +// Description: This function installs different protocols exported. +// +// Input: VOID +// +// Output: Return Status based on errors that occurred in library +// functions. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: UninstallProtocol +// +// Description: This function uninstalls different protocols exported. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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); +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 + +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +EFI_STATUS PostManagerDisplayPostMessage( CHAR16 *message ) +{ + if ( ! gPostMsgProtocolActive ) + return EFI_UNSUPPORTED; + + if (NULL == gST->ConOut) + return EFI_NOT_READY; + + return PrintPostMessage(message, TRUE); +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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 +} +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// + +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; +} + +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerSetProgressBarPosition() +{ + EFI_STATUS Status = EFI_SUCCESS; + if(gProgress->active) + DrawBltProgressBar(); + else + Status = EFI_UNSUPPORTED; + + return Status; +} + + + + +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerSetCursorPosition(UINTN X, UINTN Y) +{ + return SetCurPos(X,Y); +} + +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS PostManagerGetCursorPosition(UINTN *pX, UINTN *pY) +{ + return GetCurPos(pX, pY); +} + +// +//-------------------------------------------------------------------------- +// +// Name: PostManagerDisplayMsgBox +// +// Description: +// +// +// Input: IN CHAR16 *MsgBoxTitle, +// IN CHAR16 *Message, +// IN UINT8 MsgBoxType, +// +// Output: EFI_STATUS status and UINT8 MsgBoxSel +// +//-------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + 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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +TSE_POST_STATUS PostManagerGetPostStatus(VOID) +{ + return gPostStatus; +} + + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowInfoBox(InfoBoxTitle, InfoString, Timeout, Event); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; + +} + + +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerSetAttribute(UINT8 Attrib) +{ + gPostMgrAttribute = Attrib ; + return EFI_SUCCESS ; +} +//EIP-41838: New interface to get the attribute using AMI Post Manager Protocol +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// +EFI_STATUS PostManagerGetAttribute(UINT8 *Attrib) +{ + *Attrib = gPostMgrAttribute ; + return EFI_SUCCESS ; +} + +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + 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; +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 ; +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowPostMenu(HiiHandle, TitleToken, LegendToken, MenuData, MenuCount, pSelection); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 (¤ttextModeCols, ¤ttextModeRows, ¤tGOPMode); + + if ( EFI_ERROR(Status) ) + return Status; + + Status = ShowPostTextBox(HiiHandle, TitleToken, InputData, ItemCount, ValidateKeyFunc); + + RestoreTextGOPMode (currenttextModeCols, currenttextModeRows, currentGOPMode); + + return Status; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StopClickEvent +// +// Description: Function to Stop the Click Event +// +// Input: VOID +// +// Output: VOID +// +//-------------------------------------------------------------------------- +// +VOID StopClickEvent(VOID) +{ + if(gClickTimer) + { + gBS->SetTimer ( gClickTimer,TimerCancel,0); + TimerStopTimer( &gClickTimer ); + } +} + +//EIP 128665 starts +// +//-------------------------------------------------------------------------- +// +// Name: InvalidateBgrtStatusByProtocol +// +// Description: Protocol interface to invalidate BGRT status +// +// +// Input: VOID +// +// +// Output: EFI_STATUS +// +//-------------------------------------------------------------------------- +// +VOID InvalidateStatusInBgrtWrapper (VOID); +EFI_STATUS InvalidateBgrtStatusByProtocol (VOID) +{ + InvalidateStatusInBgrtWrapper(); + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// +// Procedure: InvalidateBGRTStatusProtocol +// +// Description: Install Invalidate BGRT status protocol +// +// Parameter: EFI_HANDLE Handle +// +// Return value:EFI_STATUS +//---------------------------------------------------------------------------- +// +EFI_STATUS InstallInvalBGRTStatusProtocol (EFI_HANDLE Handle) +{ + EFI_STATUS Status = EFI_SUCCESS; + + Status = gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gTSEInvalidateBgrtStatusProtocolGuid, + &gInvalidateBgrtStatus, + NULL + ); + + return Status; +} +//EIP 128665 ends + +// +//-------------------------------------------------------------------------- +// +// Name : SaveCurrentTextGOP +// +// Description : Function to Save current TextMode and GOP +// +// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode +// +// Output : EFI_STATUS +// +//-------------------------------------------------------------------------- +// +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; +} + +// +//-------------------------------------------------------------------------- +// +// Name : RestoreTextGOPMode +// +// Description : Function to Save current TextMode and GOP +// +// Input : UINTN currentTextModCols, UINTN currentTextModRows, UINT32 currentGOPMode +// +// Output : EFI_STATUS +// +//-------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: screen.c +// +// Description: This file contains code for screen operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +VOID MouseStop(VOID); +VOID MouseRefresh(VOID); + +// +//---------------------------------------------------------------------------- +// Procedure: ClearScreenWithoutFlush +// +// Description: function to clear screen without flushing. +// +// Input: UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID ClearScreenWithoutFlush( UINT8 Attrib ) +{ + + gActiveBuffer->ScreenTag = ACTIVE_SCREEN_TAG; + MemSet( gActiveBuffer->Attribs, sizeof(gActiveBuffer->Attribs), Attrib ); + + MemFillUINT16Buffer( gActiveBuffer->Chars, MAX_DIMENSIONS, (UINT16)L' ' ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: ClearLinesWithoutFlush +// +// Description: function to clear lines without flushing. +// +// Input: UINT8 LineStart, UINT8 NumLines, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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' ' ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: ClearScreen +// +// Description: function to clear the screen. +// +// Input: UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +// +//---------------------------------------------------------------------------- +// Procedure: SaveScreen +// +// Description: function to get the backup of the screen. +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestoreScreen +// +// Description: function to restore the screen from the saved screen buffer. +// +// Input: VOID *ScreenBuffer +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SaveGraphicsScreen +// +// Description: Saves post graphics screen +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: RestoreGraphicsScreen +// +// Description: Restores the saved post graphics screen +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: string.c +// +// Description: This file contains code for string functionalities. +// +//---------------------------------------------------------------------------- +// + +#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(); + + +// +//---------------------------------------------------------------------------- +// Procedure: SetPostScreenScrollArea +// +// Description: Sets the PostScreen Scroll Area. +// +// Input: UINTN TopX, UINTN TopY, UINTN BottomX, UINTN BottomY +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID SetPostScreenScrollArea(UINTN TopRow, UINTN TopCol, UINTN BottomRow, UINTN BottomCol) +{ + if((TopCol +//---------------------------------------------------------------------------- +// Procedure: atoi +// +// Description: function to convet a string to integer +// +// Input: CHAR16 *string, UINT8 base +// +// Output: integer +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StrZeroPad +// +// Description: function to pad with zero +// +// Input: INT32 Tm, CHAR16 *Str +// +// Output: String +// +//---------------------------------------------------------------------------- +// +CHAR16 *StrZeroPad(INT32 Tm, CHAR16 *Str) +{ + CHAR16 *fmt = L"%d"; + + if ( Tm < 10 ) + fmt = L"0%d"; + + SPrint( Str, 10, fmt, Tm ); + return Str; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StrDup +// +// Description: function to dump and return the string +// +// Input: CHAR16 *String +// +// Output: String +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawAttribute +// +// Description: function to write a attribute +// +// Input: UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +VOID DrawAttribute( UINTN Col, UINTN Row, UINT8 Attrib, UINTN Length ) +{ + UINTN Offset = Row * gMaxCols + Col; + + if ( Row >= gMaxRows ) + return; + + DrawAttributeOffset( Offset, Attrib, Length ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: DrawAttributeOffset +// +// Description: function to write in a peticular offset. +// +// Input: UINTN Offset, UINT8 Attrib, UINTN Length +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: DrawMultiLineStringWithAttribute +// +// Description: function to write a multiline string. +// +// Input: UINTN Col, UINTN Row,UINTN Width, UINTN Height, +// CHAR16 *line, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: DrawPostStringWithAttribute +// +// Description: function to write a multiline string in the post screen. +// +// Input: UINTN Col, UINTN Row, +// CHAR16 *line, UINT8 Attrib +// +// Output: UINTN +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: DrawStringWithAttribute +// +// Description: function to write a string with attributes. +// +// Input: UINTN Col, UINTN Row, CHAR16 *String, UINT8 Attrib +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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 ); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: StringWrapText +// +// Description: function to create a new text by wrapping the given text. +// +// Input: CHAR16 *OrgText, UINT16 width, UINT16 *height +// +// Output: text +// +//---------------------------------------------------------------------------- +// +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= (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;iAttribs[CopyTo] = gActiveBuffer->Attribs[CopyFrom]; + gActiveBuffer->Chars[CopyTo] = gActiveBuffer->Chars[CopyFrom]; + if((i+1)==EndRow) + { + gActiveBuffer->Chars[CopyFrom] = L' '; + } + CopyFrom++; + CopyTo++; + } + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: PrintPostMessage +// +// Description: function to Print the post massages +// +// Input: CHAR16 *message, BOOLEAN bAdvanceLine +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +VOID PreservePostMessages(UINTN NewMaxCols, UINTN OldMaxCols) +{ + UINTN i,CharCount; + + if(OldMaxCols <= NewMaxCols) + return; + // Loop to copy each line to newmax cols + for(i=0;iCopyMem ((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;iChars[(stNextLine*NewMaxCols)+i] = L' '; +} +//eip:26893-End + +// +//---------------------------------------------------------------------------- +// Procedure: DisplayActivePostMsgs +// +// Description: function to Display active messages +// +// Input: UINTN LogoHeight +// +// Output: void +// +//---------------------------------------------------------------------------- +// +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(); + } +} + +// +//-------------------------------------------------------------------------- +// +// 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. +// +//-------------------------------------------------------------------------- +// + +EFI_STATUS SetCurPos(UINTN X, UINTN Y) +{ + if((X < gMaxCols) && ( Y < gMaxRows)) + { + stColNum = X; + stNextLine = Y; + return EFI_SUCCESS; + } + + return EFI_UNSUPPORTED; +} + +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// + +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; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup8 +// +// Description: Duplicates a String of type CHAR8 +// +// Input: CHAR8* string +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +CHAR8 *StrDup8( CHAR8 *string ) +{ + CHAR8 *text; + + text = EfiLibAllocatePool(1 + StrLen8( string )); + if ( text != NULL ) + StrCpy8( text, string ); + + return text; +} +#pragma warning( disable : 4706 ) + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup8to16 +// +// Description: Duplicates a String from CHAR8 to CHAR16 +// +// Input: CHAR8* string +// +// Output: CHAR16 * +// +// +//-------------------------------------------------------------------------- +// +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; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrLen8 +// +// Description: Returns Length of a String of type CHAR8 +// +// Input: CHAR8* string +// +// Output: UINTN +// +// +//-------------------------------------------------------------------------- +// +UINTN StrLen8(CHAR8 *string) +{ + UINTN i=0; + while(string[i]) + i++; + + return i; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrCpy8 +// +// Description: Copies a CHAR8 String from source to destination +// +// Input: CHAR8 *dest, CHAR8 *src +// +// Output: VOID +// +// +//-------------------------------------------------------------------------- +// +VOID StrCpy8(CHAR8 *dest, CHAR8 *src) +{ + UINTN i=0; + while(dest[i] = src[i]) + i++; +} + + +// +//-------------------------------------------------------------------------- +// +// Name: GetTokenCount +// +// Description: +// +// Input: CHAR8 *String +// +// Output: UINTN +// +// +//-------------------------------------------------------------------------- +// +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); +} + +// +//-------------------------------------------------------------------------- +// +// Name: GetTokenString +// +// Description: +// +// Input: CHAR8 *String, UINTN *pos +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +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; +} + +// +//-------------------------------------------------------------------------- +// +// Name: StrDup16to8 +// +// Description: Duplicates a String from CHAR16 to CHAR8 +// +// Input: CHAR16 *String +// +// Output: CHAR8 * +// +// +//-------------------------------------------------------------------------- +// +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 +// +//-------------------------------------------------------------------------- +// +// Name: FindAnsiEscCode +// +// Description: Fills the EscCode in current line +// +// Input: CHAR16 *, CHAR16 ** +// +// Output: void +// +// +//-------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: string.h +// +// Description: Header file for string functionalities. +// +//---------------------------------------------------------------------------- +// + +#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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: timer.c +// +// Description: This file contains code to handle the timer. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TimerStopTimer +// +// Description: function to stop the timer event. +// +// Input: EFI_EVENT *Event +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: variable.c +// +// Description: This file contains code to handle bootonly lever variables operations. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +extern UINTN gSetupCount; + +// +//---------------------------------------------------------------------------- +// Procedure: VarGetNvramName +// +// Description: function to get the NvRam Variable Name +// +// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size +// +// Output: Name String +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: VarSetNvramName +// +// Description: function to Set the NvRam Variable Name +// +// Input: CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, +// VOID *buffer, UINTN *size +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 @@ + + 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" + 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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: ezport.c +// +// Description: Main file for ezport style module. +// +// +//********************************************************************** +#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 ; + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameIndexOf +// +// Description: Function to get frame index +// +// Input: UINT32 frameType +// +// Output: UINT32 index +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageFrames +// +// Description: Function to number of frames +// +// Input: UINT32 page +// +// Output: UINT32 number of frames +// +//---------------------------------------------------------------------------- +// +UINT32 StyleGetPageFrames( UINT32 page ) +{ + return sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO); +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleDrawPageBorder +// +// Description: Function to draw page border +// +// Input: UINT32 page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page, UINT32 frame +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame ) +{ + return &_gStyleSubFrames[frame]; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameAddTitle +// +// Description: Function to add frame title +// +// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy ) +{ + return EFI_UNSUPPORTED; +} + +#endif /* SETUP_STYLE_EZPORT */ + +// +//---------------------------------------------------------------------------- +// Procedure: HandleEscKey +// +// Description: Function to handle ESC Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleSaveExitKey +// +// Description: Function to handle Save and Exit Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + app->Quit = SaveAndExit(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandlePrevValuesKey +// +// Description: Function to handle Load Previous value Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadPreviousValues( TRUE ); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleFailsafeKey +// +// Description: Function to handle Load Failsafe values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadFailsafeDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleOptimalKey +// +// Description: Function to handle Load Optimal values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadOptimalDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleHelpKey +// +// Description: Function to handle Help Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + ShowHelpMessageBox(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandlePrnScrnKey +// +// Description: Function to handle print screen Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: MainFrameHandlewithMouse +// +// Description: Function to handle Main Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID MainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + NumericSoftKbdExit(); + if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK) + app->Quit = ExitApplication(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: HelpFrameHandlewithMouse +// +// Description: Function to handle Help Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID HelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + NumericSoftKbdExit(); + +} + +// +//---------------------------------------------------------------------------- +// Procedure: NavFrameHandlewithMouse +// +// Description: Function to handle Navigation Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: ezport.h +// +// Description: Main header file for ezport style module. +// +// +//********************************************************************** +#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.c +// +// Description: Contains style override functions. +// +// +//********************************************************************** +#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 +}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleHandleControlOverflow +// +// Description: Function to handle contro overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInitializeFrame +// +// Description: Function to initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetNavToken +// +// Description: Function to get navigation frame token +// +// Input: UINT32 page number +// +// Output: UINT16 token +// +//---------------------------------------------------------------------------- +// +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) }; + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleAddAdditionalControls +// +// Description: Function to add additional controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleSelectFirstDisplayPage +// +// Description: Function to set first page display +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID OverRideStyleSelectFirstDisplayPage( VOID ) +{ + gApp->CurrentPage = 1; +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleUpdateVersionString +// +// Description: Function to update version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + } +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame ) +{ + EFI_STATUS Status = EFI_SUCCESS; + + if(!frame->FrameData.Drawable){ + Status = EFI_UNSUPPORTED; + } + return Status ; +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddSpacing +// +// Description: Function to add spacing +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddControl +// +// Description: Function to add controls +// +// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.h +// +// Description: Style override prototypes. +// +// +//********************************************************************** +//#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: stylecommon.c +// +// Description: Contains generic or default style functions. +// +// +//********************************************************************** +#include "minisetup.h" + +#if SETUP_STYLE_EZPORT + + +VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref ); +VOID UpdatePageFocusedItemHelp(PAGE_DATA *page); +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetSpecialColor +// +// Description: Function to get control special color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: GetWindowLevel +// +// Description: Function to get window level +// +// Input: UINT16 PageID +// +// Output: INTN Level +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType) +{ + return EFI_SUCCESS ; + +} + +VOID GetMessageboxColorHook(UINT8 **Color); +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetMessageboxColor +// +// Description: Function to get control Messagebox color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleBeforeFrame +// +// Description: Function to alter frame styling before frame is drawn +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateFrameStrings +// +// Description: Function to update frame strings +// +// Input: PAGE_DATA *page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleInit( VOID ) +{ + SetDesiredTextMode(); + OverRideStyleInit(); // From ezport.c + +#ifdef STYLE_OEM_INIT // SDL + OEMStyleInit(); // OEM +#endif + MouseInit(); +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleExit +// +// Description: Function to do style initialization on exit +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawPageBorder +// +// Description: Function to draw the page border +// +// Input: UINT32 page number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawHelpScrollBar +// +// Description: Function to draw the help frame scrollbar +// +// Input: MEMO_DATA *memo, UINT16 height +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page number, UINT32 frame number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleKey +// +// Description: Function to handle frame action keys +// +// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleMouse +// +// Description: Function to handle frame using mouse +// +// Input: FRAME_DATA *frame, +// MOUSE_INFO MouseInfo +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleTimer +// +// Description: Function to handle frame timer action +// +// Input: FRAME_DATA *frame, ACTION_DATA *action +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHandleControlOverflow +// +// Description: Function to handle control overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInitializeFrame +// +// Description: Function to Initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetNavToken +// +// Description: Function to get navigation token +// +// Input: UINT32 page +// +// Output: UINT16 token number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddAdditionalControls +// +// Description: Function to add additinal controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLanguagePage +// +// Description: Function to set Language page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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; + +// +//---------------------------------------------------------------------------- +// Procedure: StyleBootManagerPage +// +// Description: Function to set boot manager page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLabelCallback +// +// Description: Function to set label callback +// +// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleSelectFirstDisplayPage +// +// Description: Function to set the first display page +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleSelectFirstDisplayPage( VOID ) +{ + #ifdef STYLE_OEM_FIRST_PAGE + OEMStyleSelectFirstDisplayPage(); + #else + #ifdef STYLE_OVERRIDE_FIRST_PAGE + OverRideStyleSelectFirstDisplayPage(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddExtraPagesData +// +// Description: Function to add extra pages +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleAddExtraPagesData(VOID) +{ + #ifdef STYLE_OEM_ADD_EXTRA_PAGES + OEMStyleAddExtraPagesData(); + #else + #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES + OverRideStyleAddExtraPagesData(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetTextMode +// +// Description: Function to get text mode +// +// Input: UINTN Rows, UINTN Cols +// +// Output: UNNTN mode +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateVersionString +// +// Description: Function to set the version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleUpdateVersionString( VOID ) +{ + #ifdef STYLE_OEM_VERSION_STRING + OEMStyleUpdateVersionString(); + #else + #ifdef STYLE_OVERRIDE_VERSION_STRING + OverRideStyleUpdateVersionString(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameSetControlPositions +// +// Description: Function to set control positioning in a frame +// +// Input: FRAME_DATA *frame, UINT32 *pOtherEnd +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleOverRideComponent +// +// Description: Function to override component or control functionality +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleControlSubmenu +// +// Description: Function to initialize submenu control +// +// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHelpAreaScrollable +// +// Description: Function to get Help area scroll support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleHelpAreaScrollable(VOID) +{ + if(IsHelpAreaScrollBarSupport()) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetShadowSupport +// +// Description: Function to get shadow support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetShadowSupport(VOID) +{ + if(STYLE_SHADOW_SUPPORT) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBehavior +// +// Description: Function to get scroll behavior +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetScrollBehavior(VOID) +{ + return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetDateFormat +// +// Description: Function to get date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetDateFormat(VOID) +{ + #ifdef STYLE_OEM_DATE_FOMAT + return OEMStyleGetDateFormat(); + #else + return STYLE_DATE_FORMAT; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleShowDay +// +// Description: Function to show day in date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleShowDay(VOID) +{ + return STYLE_SHOW_DAY ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxRows +// +// Description: Function to max number of columns +// +// Input: VOID +// +// Output: STYLE_STD_MAX_ROWS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxRows(VOID) +{ + return STYLE_STD_MAX_ROWS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxCols +// +// Description: Function to get max number of rows +// +// Input: VOID +// +// Output: STYLE_STD_MAX_COLS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxCols(VOID) +{ + return STYLE_STD_MAX_COLS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetClearScreenColor +// +// Description: Function to Get Clear Screen Color +// +// Input: VOID +// +// Output: STYLE_CLEAR_SCREEN_COLOR +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetClearScreenColor(VOID) +{ + #ifdef STYLE_OVERRIDE_CLEAR_SCREEN_COLOR + return OverRideStyleGetClearScreenColor(); + #else + return STYLE_CLEAR_SCREEN_COLOR; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageLinkColor +// +// Description: Function to PageLink (Submenu) color +// +// Input: VOID +// +// Output: PAGE_LINK_FGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetPageLinkColor(VOID) +{ + #ifdef STYLE_OVERRIDE_PAGELINK_COLOR + return OverRideStyleGetPageLinkColor(); + #else + return PAGE_LINK_COLOR; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarColor +// +// Description: Function to get scrollbar color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_COLOR + return OverRideStyleGetScrollBarColor(); + #else + return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarUpArrowColor +// +// Description: Function to get scrollbar UpArrow Color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarUpArrowColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_UP_ARROW_COLOR + return OverRideStyleGetScrollBarUpArrowColor(); + #else + return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarDownArrowColor +// +// Description: Function to get scrollbar downarrow color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarDownArrowColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_DOWN_ARROW_COLOR + return OverRideStyleGetScrollBarDownArrowColor(); + #else + return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 @@ + + 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" + 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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: ezportplus.c +// +// Description: Main file for ezportplus style module. +// +// +//********************************************************************** +#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 ; + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameIndexOf +// +// Description: Function to get frame index +// +// Input: UINT32 frameType +// +// Output: UINT32 index +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageFrames +// +// Description: Function to number of frames +// +// Input: UINT32 page +// +// Output: UINT32 number of frames +// +//---------------------------------------------------------------------------- +// +UINT32 StyleGetPageFrames( UINT32 page ) +{ + return sizeof(_gStyleStandardSubFrames) / sizeof(FRAME_INFO); +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleDrawPageBorder +// +// Description: Function to draw page border +// +// Input: UINT32 page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page, UINT32 frame +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame ) +{ + return &_gStyleSubFrames[frame]; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameAddTitle +// +// Description: Function to add frame title +// +// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy ) +{ + return EFI_UNSUPPORTED; +} + +#endif /* SETUP_STYLE_EZPORTPLUS */ + +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandleEscKey +// +// Description: Function to handle ESC Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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(); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandleSaveExitKey +// +// Description: Function to handle Save and Exit Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + app->Quit = SaveAndExit(); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandlePrevValuesKey +// +// Description: Function to handle Load Previous value Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadPreviousValues( TRUE ); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandleFailsafeKey +// +// Description: Function to handle Load Failsafe values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadFailsafeDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandleOptimalKey +// +// Description: Function to handle Load Optimal values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + LoadOptimalDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandleHelpKey +// +// Description: Function to handle Help Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + if ( app->CurrentPage != 0 ) + ShowHelpMessageBox(); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHandlePrnScrnKey +// +// Description: Function to handle print screen Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusMainFrameHandlewithMouse +// +// Description: Function to handle Main Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusMainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK) + app->Quit = ExitApplication(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusHelpFrameHandlewithMouse +// +// Description: Function to handle Help Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID EzportPlusHelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + + +} + +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusNavFrameHandlewithMouse +// +// Description: Function to handle Navigation Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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); +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusShowPasswordErrorMessageBox +// +// Description: Function to Display the password failed message box +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusShowPasswordSuccessMessageBox +// +// Description: Function to Display the password success message box +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: EzportPlusShowPasswordClearedMessageBox +// +// Description: Function to Display the password success message box +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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(); +// +//---------------------------------------------------------------------------- +// Procedure: _EzportPlusPopupPasswordActivate +// +// Description: function to set and activate a password +// +// Input: POPUP_PASSWORD_DATA *popuppassword +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _EzportPlusPopupPasswordHandleAction +// +// Description: function to handle the password actions +// +// Input: POPUP_PASSWORD_DATA *popuppassword, , ACTION_DATA *Data +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: ezportplus.h +// +// Description: Main header file for ezportplus style module. +// +// +//********************************************************************** +#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.c +// +// Description: Contains style override functions. +// +// +//********************************************************************** +#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 +}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleHandleControlOverflow +// +// Description: Function to handle contro overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInitializeFrame +// +// Description: Function to initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetNavToken +// +// Description: Function to get navigation frame token +// +// Input: UINT32 page number +// +// Output: UINT16 token +// +//---------------------------------------------------------------------------- +// +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) }; + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleAddAdditionalControls +// +// Description: Function to add additional controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleSelectFirstDisplayPage +// +// Description: Function to set first page display +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID OverRideStyleSelectFirstDisplayPage( VOID ) +{ + gApp->CurrentPage = 1; +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleUpdateVersionString +// +// Description: Function to update version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + } +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddSpacing +// +// Description: Function to add spacing +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddControl +// +// Description: Function to add controls +// +// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.h +// +// Description: Style override prototypes. +// +// +//********************************************************************** +//#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: stylecommon.c +// +// Description: Contains generic or default style functions. +// +// +//********************************************************************** +#include "minisetup.h" + +#if SETUP_STYLE_EZPORTPLUS + + +VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref ); +VOID UpdatePageFocusedItemHelp(PAGE_DATA *page); +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetSpecialColor +// +// Description: Function to get control special color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: GetWindowLevel +// +// Description: Function to get window level +// +// Input: UINT16 PageID +// +// Output: INTN Level +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +EFI_STATUS StyleGetWindowColor(UINT8 *Color, INTN Level, UINT8 WindowType) +{ + return EFI_SUCCESS ; + +} + +VOID GetMessageboxColorHook(UINT8 **Color); +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetMessageboxColor +// +// Description: Function to get control Messagebox color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleBeforeFrame +// +// Description: Function to alter frame styling before frame is drawn +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateFrameStrings +// +// Description: Function to update frame strings +// +// Input: PAGE_DATA *page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleInit( VOID ) +{ + SetDesiredTextMode(); + OverRideStyleInit(); // From ezportplus.c + +#ifdef STYLE_OEM_INIT // SDL + OEMStyleInit(); // OEM +#endif + MouseInit(); //EIP-84150 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleExit +// +// Description: Function to do style initialization on exit +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawPageBorder +// +// Description: Function to draw the page border +// +// Input: UINT32 page number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawHelpScrollBar +// +// Description: Function to draw the help frame scrollbar +// +// Input: MEMO_DATA *memo, UINT16 height +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page number, UINT32 frame number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleKey +// +// Description: Function to handle frame action keys +// +// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleMouse +// +// Description: Function to handle frame using mouse +// +// Input: FRAME_DATA *frame, +// MOUSE_INFO MouseInfo +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleTimer +// +// Description: Function to handle frame timer action +// +// Input: FRAME_DATA *frame, ACTION_DATA *action +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHandleControlOverflow +// +// Description: Function to handle control overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInitializeFrame +// +// Description: Function to Initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetNavToken +// +// Description: Function to get navigation token +// +// Input: UINT32 page +// +// Output: UINT16 token number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddAdditionalControls +// +// Description: Function to add additinal controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLanguagePage +// +// Description: Function to set Language page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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; + +// +//---------------------------------------------------------------------------- +// Procedure: StyleBootManagerPage +// +// Description: Function to set boot manager page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLabelCallback +// +// Description: Function to set label callback +// +// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleSelectFirstDisplayPage +// +// Description: Function to set the first display page +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleSelectFirstDisplayPage( VOID ) +{ + #ifdef STYLE_OEM_FIRST_PAGE + OEMStyleSelectFirstDisplayPage(); + #else + #ifdef STYLE_OVERRIDE_FIRST_PAGE + OverRideStyleSelectFirstDisplayPage(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddExtraPagesData +// +// Description: Function to add extra pages +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleAddExtraPagesData(VOID) +{ + #ifdef STYLE_OEM_ADD_EXTRA_PAGES + OEMStyleAddExtraPagesData(); + #else + #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES + OverRideStyleAddExtraPagesData(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetTextMode +// +// Description: Function to get text mode +// +// Input: UINTN Rows, UINTN Cols +// +// Output: UNNTN mode +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateVersionString +// +// Description: Function to set the version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleUpdateVersionString( VOID ) +{ + #ifdef STYLE_OEM_VERSION_STRING + OEMStyleUpdateVersionString(); + #else + #ifdef STYLE_OVERRIDE_VERSION_STRING + OverRideStyleUpdateVersionString(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameSetControlPositions +// +// Description: Function to set control positioning in a frame +// +// Input: FRAME_DATA *frame, UINT32 *pOtherEnd +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleOverRideComponent +// +// Description: Function to override component or control functionality +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleControlSubmenu +// +// Description: Function to initialize submenu control +// +// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHelpAreaScrollable +// +// Description: Function to get Help area scroll support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleHelpAreaScrollable(VOID) +{ + if(IsHelpAreaScrollBarSupport()) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetShadowSupport +// +// Description: Function to get shadow support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetShadowSupport(VOID) +{ + if(STYLE_SHADOW_SUPPORT) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBehavior +// +// Description: Function to get scroll behavior +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetScrollBehavior(VOID) +{ + return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetDateFormat +// +// Description: Function to get date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetDateFormat(VOID) +{ + #ifdef STYLE_OEM_DATE_FOMAT + return OEMStyleGetDateFormat(); + #else + return STYLE_DATE_FORMAT; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleShowDay +// +// Description: Function to show day in date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleShowDay(VOID) +{ + return STYLE_SHOW_DAY ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxRows +// +// Description: Function to max number of columns +// +// Input: VOID +// +// Output: STYLE_STD_MAX_ROWS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxRows(VOID) +{ + return STYLE_STD_MAX_ROWS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxCols +// +// Description: Function to get max number of rows +// +// Input: VOID +// +// Output: STYLE_STD_MAX_COLS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxCols(VOID) +{ + return STYLE_STD_MAX_COLS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetClearScreenColor +// +// Description: Function to Get Clear Screen Color +// +// Input: VOID +// +// Output: STYLE_CLEAR_SCREEN_COLOR +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetClearScreenColor(VOID) +{ + #ifdef STYLE_OVERRIDE_CLEAR_SCREEN_COLOR + return OverRideStyleGetClearScreenColor(); + #else + return STYLE_CLEAR_SCREEN_COLOR; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageLinkColor +// +// Description: Function to PageLink (Submenu) color +// +// Input: VOID +// +// Output: PAGE_LINK_FGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetPageLinkColor(VOID) +{ + #ifdef STYLE_OVERRIDE_PAGELINK_COLOR + return OverRideStyleGetPageLinkColor(); + #else + return PAGE_LINK_COLOR; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarColor +// +// Description: Function to get scrollbar color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_COLOR + return OverRideStyleGetScrollBarColor(); + #else + return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarUpArrowColor +// +// Description: Function to get scrollbar UpArrow Color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarUpArrowColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_UP_ARROW_COLOR + return OverRideStyleGetScrollBarUpArrowColor(); + #else + return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarDownArrowColor +// +// Description: Function to get scrollbar downarrow color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarDownArrowColor(VOID) +{ + #ifdef STYLE_OVERRIDE_SCROLLBAR_DOWN_ARROW_COLOR + return OverRideStyleGetScrollBarDownArrowColor(); + #else + return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ; + #endif +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 @@ + + 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" + 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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: alternate1.c +// +// Description: Main file for alternate1 style module. +// +// +//********************************************************************** +#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} +}; + + + +// +//---------------------------------------------------------------------------- +// Procedure: LegacyPageHandleAction +// +// Description: function to handle the page actions +// +// Input: PAGE_DATA *page, ACTION_DATA *action +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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; +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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; +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: LegacyMsgBoxInitialize +// +// Description: Function to Initialize Message Box, which uses the Popup functions. +// +// Input: MSGBOX_DATA *msgbox, VOID *data +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: LegacySubMenuInitialize +// +// Description: this function uses the initialize function of control +// and initializes the submenu. +// +// Input: SUBMENU_DATA *submenu, VOID *data +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: LegacySubMenuDraw +// +// Description: function to draw a sub-menu. +// +// Input: SUBMENU_DATA *submenu +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameIndexOf +// +// Description: Function to get frame index +// +// Input: UINT32 frameType +// +// Output: UINT32 index +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageFrames +// +// Description: Function to number of frames +// +// Input: UINT32 page +// +// Output: UINT32 number of frames +// +//---------------------------------------------------------------------------- +// +UINT32 StyleGetPageFrames( UINT32 page ) +{ + if ( page == 0 ) + return sizeof(_gStyleLegacyMainFrames) / sizeof(FRAME_INFO); + + return sizeof(_gStyleLegacySubFrames) / sizeof(FRAME_INFO); +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleDrawPageBorder +// +// Description: Function to draw page border +// +// Input: UINT32 page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page, UINT32 frame +// +// Output: VOID* +// +//---------------------------------------------------------------------------- +// +VOID *OverRideStyleGetFrameInitData( UINT32 page, UINT32 frame ) +{ + if ( page == 0 ) + return &_gStyleMainFrames[frame]; + + return &_gStyleSubFrames[frame]; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideComponent +// +// Description: Function to override component or control functionality +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameAddTitle +// +// Description: Function to add frame title +// +// Input: FRAME_DATA *frame, UINT32 frameType, CONTROL_INFO * dummy +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS StyleFrameAddTitle( FRAME_DATA *frame, UINT32 frameType,CONTROL_INFO * dummy ) +{ + return EFI_UNSUPPORTED; +} + +#endif /* SETUP_STYLE_LEGACY */ + +// +//---------------------------------------------------------------------------- +// Procedure: HandleEscKey +// +// Description: Function to handle ESC Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleSaveExitKey +// +// Description: Function to handle Save and Exit Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHandleSaveExitKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + app->Quit = SaveAndExit(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandlePrevValuesKey +// +// Description: Function to handle Load Previous value Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHandlePrevValuesKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + //if ( app->CurrentPage != 0 ) + LoadPreviousValues( TRUE ); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleFailsafeKey +// +// Description: Function to handle Load Failsafe values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHandleFailsafeKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + //if ( app->CurrentPage != 0 ) + LoadFailsafeDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleOptimalKey +// +// Description: Function to handle Load Optimal values Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHandleOptimalKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + //if ( app->CurrentPage != 0 ) + LoadOptimalDefaults(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandleHelpKey +// +// Description: Function to handle Help Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHandleHelpKey( APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie ) +{ + //if ( app->CurrentPage != 0 ) + ShowHelpMessageBox(); +} +// +//---------------------------------------------------------------------------- +// Procedure: HandlePrnScrnKey +// +// Description: Function to handle print screen Hotkey action +// +// Input: APPLICATION_DATA *app, HOTKEY_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: LegacyMainFrameHandlewithMouse +// +// Description: Function to handle Main Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyMainFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + if(app->Action->Input.Data.MouseInfo.ButtonStatus == TSEMOUSE_RIGHT_CLICK) + app->Quit = ExitApplication(); +} + +// +//---------------------------------------------------------------------------- +// Procedure: LegacyHelpFrameHandlewithMouse +// +// Description: Function to handle Help Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LegacyHelpFrameHandlewithMouse( APPLICATION_DATA *app, HOTCLICK_DATA *hotclick, VOID *cookie ) +{ + +} + +// +//---------------------------------------------------------------------------- +// Procedure: LegacyNavFrameHandlewithMouse +// +// Description: Function to handle Navigation Frame with Mouse +// +// Input: APPLICATION_DATA *app, HOTCLICK_DATA *hotkey, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: alternate1.h +// +// Description: Main header file for alternate1 style module. +// +// +//********************************************************************** +#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.c +// +// Description: Contains style override functions. +// +// +//********************************************************************** +#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 +}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleLabelCallback +// +// Description: Function to set label callback +// +// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; + } +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleFrameHandleKey +// +// Description: Function to handle action key +// +// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleHandleControlOverflow +// +// Description: Function to handle contro overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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}; +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleInitializeFrame +// +// Description: Function to initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleGetNavToken +// +// Description: Function to get navigation frame token +// +// Input: UINT32 page number +// +// Output: UINT16 token +// +//---------------------------------------------------------------------------- +// +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) }; + +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleAddAdditionalControls +// +// Description: Function to add additional controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleSelectFirstDisplayPage +// +// Description: Function to set first page display +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID OverRideStyleSelectFirstDisplayPage( VOID ) +{ + gApp->CurrentPage = 0; +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleUpdateVersionString +// +// Description: Function to update version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + } +} +// +//---------------------------------------------------------------------------- +// Procedure: OverRideStyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS OverRideStyleFrameDrawable( FRAME_DATA *frame ) +{ + EFI_STATUS Status = EFI_SUCCESS; + + if(!frame->FrameData.Drawable){ + Status = EFI_UNSUPPORTED; + } + return Status ; +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddSpacing +// +// Description: Function to add spacing +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleAddControl +// +// Description: Function to add controls +// +// Input: FRAME_DATA *frame, UINT16 type, VOID *data, UINT32 *controlNumber, BOOLEAN *focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: style.h +// +// Description: Style override prototypes. +// +// +//********************************************************************** +//#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 +//*****************************************************************// +//*****************************************************************// +// +// +// Name: stylecommon.c +// +// Description: Contains generic or default style functions. +// +// +//********************************************************************** +#include "minisetup.h" + +#if SETUP_STYLE_LEGACY + + +VOID _StyleControlSubmenu( CONTROL_INFO *control, UINT16 pageID, VOID *ref ); +VOID UpdatePageFocusedItemHelp(PAGE_DATA *page); +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetSpecialColor +// +// Description: Function to get control special color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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); +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetMessageboxColor +// +// Description: Function to get control Messagebox color +// +// Input: UINT16 ControlType, UINT8 *Color +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleBeforeFrame +// +// Description: Function to alter frame styling before frame is drawn +// +// Input: FRAME_DATA *frame +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateFrameStrings +// +// Description: Function to update frame strings +// +// Input: PAGE_DATA *page +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameDrawable +// +// Description: Function to determine if frame is drawable +// +// Input: FRAME_DATA *frame +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInit +// +// Description: Function to initialize style +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleInit( VOID ) +{ + SetDesiredTextMode(); + OverRideStyleInit(); // From ezport.c + +#ifdef STYLE_OEM_INIT // SDL + OEMStyleInit(); // OEM +#endif + MouseInit(); //EIP-84150 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleExit +// +// Description: Function to do style initialization on exit +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawPageBorder +// +// Description: Function to draw the page border +// +// Input: UINT32 page number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleDrawHelpScrollBar +// +// Description: Function to draw the help frame scrollbar +// +// Input: MEMO_DATA *memo, UINT16 height +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetFrameInitData +// +// Description: Function to get frame initialization data +// +// Input: UINT32 page number, UINT32 frame number +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleKey +// +// Description: Function to handle frame action keys +// +// Input: FRAME_DATA *frame, EFI_INPUT_KEY Key +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleMouse +// +// Description: Function to handle frame using mouse +// +// Input: FRAME_DATA *frame, +// MOUSE_INFO MouseInfo +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameHandleTimer +// +// Description: Function to handle frame timer action +// +// Input: FRAME_DATA *frame, ACTION_DATA *action +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHandleControlOverflow +// +// Description: Function to handle control overflow +// +// Input: FRAME_DATA *frame, CONTROL_DATA *control, UINT16 count +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleInitializeFrame +// +// Description: Function to Initialize frame +// +// Input: FRAME_DATA *frame, UINT32 frameType, PAGE_INFO *data +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetNavToken +// +// Description: Function to get navigation token +// +// Input: UINT32 page +// +// Output: UINT16 token number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddAdditionalControls +// +// Description: Function to add additinal controls +// +// Input: FRAME_DATA *frame, UINT32 controlNumber, BOOLEAN focus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLanguagePage +// +// Description: Function to set Language page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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; + +// +//---------------------------------------------------------------------------- +// Procedure: StyleBootManagerPage +// +// Description: Function to set boot manager page +// +// Input: SUBMENU_DATA *submenu +// +// Output: UINT16 page number +// +//---------------------------------------------------------------------------- +// +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 ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleLabelCallback +// +// Description: Function to set label callback +// +// Input: FRAME_DATA *frame, LABEL_DATA *label, VOID *cookie +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleSelectFirstDisplayPage +// +// Description: Function to set the first display page +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleSelectFirstDisplayPage( VOID ) +{ + #ifdef STYLE_OEM_FIRST_PAGE + OEMStyleSelectFirstDisplayPage(); + #else + #ifdef STYLE_OVERRIDE_FIRST_PAGE + OverRideStyleSelectFirstDisplayPage(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleAddExtraPagesData +// +// Description: Function to add extra pages +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleAddExtraPagesData(VOID) +{ + #ifdef STYLE_OEM_ADD_EXTRA_PAGES + OEMStyleAddExtraPagesData(); + #else + #ifdef STYLE_OVERRIDE_ADD_EXTRA_PAGES + OverRideStyleAddExtraPagesData(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetTextMode +// +// Description: Function to get text mode +// +// Input: UINTN Rows, UINTN Cols +// +// Output: UNNTN mode +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleUpdateVersionString +// +// Description: Function to set the version string +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID StyleUpdateVersionString( VOID ) +{ + #ifdef STYLE_OEM_VERSION_STRING + OEMStyleUpdateVersionString(); + #else + #ifdef STYLE_OVERRIDE_VERSION_STRING + OverRideStyleUpdateVersionString(); + #endif + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleFrameSetControlPositions +// +// Description: Function to set control positioning in a frame +// +// Input: FRAME_DATA *frame, UINT32 *pOtherEnd +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleOverRideComponent +// +// Description: Function to override component or control functionality +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// Procedure: _StyleControlSubmenu +// +// Description: Function to initialize submenu control +// +// Input: CONTROL_INFO control, UINT16 pageID, VOID *ref +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleHelpAreaScrollable +// +// Description: Function to get Help area scroll support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleHelpAreaScrollable(VOID) +{ + if(IsHelpAreaScrollBarSupport()) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetShadowSupport +// +// Description: Function to get shadow support +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetShadowSupport(VOID) +{ + if(STYLE_SHADOW_SUPPORT) + return TRUE ; + else + return FALSE; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBehavior +// +// Description: Function to get scroll behavior +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleGetScrollBehavior(VOID) +{ + return STYLE_SCROLLBAR_ROLLOVER ; // 0 - Item Limit, 1 - Rollover + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetDateFormat +// +// Description: Function to get date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetDateFormat(VOID) +{ + #ifdef STYLE_OEM_DATE_FOMAT + return OEMStyleGetDateFormat(); + #else + return STYLE_DATE_FORMAT; + #endif +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleShowDay +// +// Description: Function to show day in date format +// +// Input: VOID +// +// Output: BOOLEAN +// +//---------------------------------------------------------------------------- +// +BOOLEAN StyleShowDay(VOID) +{ + return STYLE_SHOW_DAY ; + +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxRows +// +// Description: Function to max number of columns +// +// Input: VOID +// +// Output: STYLE_STD_MAX_ROWS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxRows(VOID) +{ + return STYLE_STD_MAX_ROWS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetStdMaxCols +// +// Description: Function to get max number of rows +// +// Input: VOID +// +// Output: STYLE_STD_MAX_COLS +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetStdMaxCols(VOID) +{ + return STYLE_STD_MAX_COLS; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetClearScreenColor +// +// Description: Function to Get Clear Screen Color +// +// Input: VOID +// +// Output: STYLE_CLEAR_SCREEN_COLOR +// +//---------------------------------------------------------------------------- +// +UINTN StyleGetClearScreenColor(VOID) +{ + return STYLE_CLEAR_SCREEN_COLOR; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetPageLinkColor +// +// Description: Function to PageLink (Submenu) color +// +// Input: VOID +// +// Output: PAGE_LINK_FGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetPageLinkColor(VOID) +{ + UINT32 PageNum = gApp->CurrentPage ; + + if( PageNum == 0 ) + return EFI_YELLOW; + else + return PAGE_LINK_COLOR; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarColor +// +// Description: Function to get scrollbar color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarColor(VOID) +{ + return (SCROLLBAR_FGCOLOR | SCROLLBAR_BGCOLOR) ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarUpArrowColor +// +// Description: Function to get scrollbar UpArrow Color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarUpArrowColor(VOID) +{ + return (SCROLLBAR_UPARROW_FGCOLOR | SCROLLBAR_UPARROW_BGCOLOR) ; +} +// +//---------------------------------------------------------------------------- +// Procedure: StyleGetScrollBarDownArrowColor +// +// Description: Function to get scrollbar downarrow color +// +// Input: VOID +// +// Output: FGCOLOR|BGCOLOR +// +//---------------------------------------------------------------------------- +// +UINT8 StyleGetScrollBarDownArrowColor(VOID) +{ + return (SCROLLBAR_DOWNARROW_FGCOLOR | SCROLLBAR_DOWNARROW_BGCOLOR) ; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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. +// +// +//************************************************************************* +// +// +// Name: CtrlCond.C +// +// Description: +// +// +//************************************************************************* + +//--------------------------------------------------------------------------- +#include "minisetup.h" + +// +//---------------------------------------------------------------------------- +// Procedure: TsePasswordEncodeLocal +// +// Description: Function to encode the password string +// +// Parameter: CHAR16 *Password, UINTN MaxSize +// +// Return value: VOID +//---------------------------------------------------------------------------- +// +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 @@ + + name = "TSE Sources - PasswordEncode" + category = ModulePart + LocalRoot = "EDK\MiniSetup\PasswordEncode" + RefName = "TsePasswordEncode" +[files] +"TsePasswordEncode.sdl" +"TsePasswordEncode.mak" +"TsePasswordEncode.c" + \ 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 @@ + + 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" + 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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: bds.c +// +// Description: This file contains code for legacy boot device handling +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + + + +// +//---------------------------------------------------------------------------- +// Procedure: GetDevStr +// +// Description: function to get the device strings +// +// Input: UINT16 DevType +// +// Output: device string +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsSATADevice +// +// Description: function to check for SATA Devices +// +// Input: UINT16 *IdentifyDriveData - 512 bytes of device information +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: GetBusStr +// +// Description: function to get the bus type string +// +// Input: EFI_HANDLE Handle, UINTN index, HDD_INFO *HDDInfo +// +// Output: Bus string +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSBuildDevicePathName +// +// Description: function to build the bbs device path +// +// Input: CHAR16 *String, BBS_TABLE *info, UINTN index, HDD_INFO *HDDInfo +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: UpdateLegacyDevVariable +// +// Description: +// +// Input: UINT16 NoOfLegacyGroups +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups) +{ + VarSetNvramName( L"LegacyDev", &gLegacyDevGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, &NoOfLegacyGroups, sizeof(NoOfLegacyGroups) ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: BBSUpdateOrder +// +// Description: function to update Bbs device order +// +// Input: UINT16 *newOption,UINT32 *offset,UINTN *size, VOID **buffer +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: GetUefiDevPathString +// +// Description: function to get the device string using device path for UEFI options. +// +// Input: EFI_DEVICE_PATH_PROTOCOL *DevPath +// +// Output: Device string. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: UpdateBootVariables +// +// Description: Update the BootOrder,BBSOrder Cache From the NVRAM. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID UpdateBootVariables () +{ + VarUpdateVariable(VARIABLE_ID_BOOT_ORDER); + VarUpdateVariable(VARIABLE_ID_BBS_ORDER); +} + +//EIP70421 starts +// +//---------------------------------------------------------------------------- +// Procedure: UpdateDriverVariables +// +// Description: Update the DriverOrder Cache From the NVRAM. +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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) +// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: jpeg6.h +// +// Description: Header file for jpeg6 image format related code +// +//---------------------------------------------------------------------------- +// + +#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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: logo.c +// +// Description: This file contains code for advanced logo support +// +//---------------------------------------------------------------------------- +// + +#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); + +// +//---------------------------------------------------------------------------- +// Procedure: GetExtendedLogoType +// +// Description: function to get the type of extended logo +// +// Input: UINT8 *ImageData +// +// Output: LOGO_TYPE +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DoLogoAnimate +// +// Description: function to Handle logo animation +// +// Input: CO_ORD_ATTRIBUTE Attribute, +// INTN CoordinateX,INTN CoordinateY +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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) +// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: mydefs.h +// +// Description: Header file common definitions +// +//---------------------------------------------------------------------------- +// + +#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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: TseAdvanced.c +// +// Description: This file contains code to handle the Advanced TSE Operations +// +//---------------------------------------------------------------------------- +// + +#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; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: BootUpdateOrder +// +// Description: Function to update the boot/driver order +// +// Input: UINT16 *buffer +// UINT32 *offset +// UINTN *size +// VOID **realBuffer +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 +//---------------------------------------------------------------------------- +// Procedure: DriverUpdateOrder +// +// Description: Function to update the driver order +// +// Input: UINT16 *buffer +// UINT32 *offset +// UINTN *size +// VOID **realBuffer +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SubMenuAmiCallback +// +// Description: Function implemented to handle the Exit page +// options using Elinks. +// +// Input: UINT16 value - index of the exit page option +// +// Output: TRUE +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SubMenuHandleSpecialOp +// +// Description: Sub menu handle for Special operations. +// +// Input: Submenu data +// +// Output: Bool - Interpreted by the Caller. +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: InitApplicationData +// +// Description: function to initialize the application data +// +// Input: EFI_HANDLE ImageHandle +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: LoadUserDefaultsSilently +// +// Description: Function to load the user set defaults Silently +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: LoadUserDefaults +// +// Description: Function to load the user set defaults +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID LoadUserDefaults( VOID ) +{ + + if ( CallbackShowMessageBox( (UINTN)gLoadUserMsgBox, MSGBOX_TYPE_YESNO ) != MSGBOX_YES ) + return; + + LoadUserDefaultsSilently(); +} +// +//---------------------------------------------------------------------------- +// Procedure: SaveUserDefaultsSilently +// +// Description: Function to save the user set defaults Silently +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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 ); + +} +// +//---------------------------------------------------------------------------- +// Procedure: SaveUserDefaults +// +// Description: Function to save the user specified defaults +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID SaveUserDefaults( VOID ) +{ + + if ( CallbackShowMessageBox( (UINTN)gSaveUserMsgBox, MSGBOX_TYPE_YESNO ) != MSGBOX_YES ) + return; + + SaveUserDefaultsSilently(); +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SkipEscCode +// +// Description: function to perform the esc key operation +// +// Input: CHAR16 *string +// +// Output: string +// +//---------------------------------------------------------------------------- +// +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); +} +// +//---------------------------------------------------------------------------- +// Procedure: _CallbackGetValueEx +// +// Description: Callback function to get the message box return value +// +// Input: MSGBOX_DATA *msgbox +// +// Output: Message box return value +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// Procedure: ShowPostMsgBoxEx +// +// Description: Function to display the message box +// +// Input: CHAR16 *MsgBoxTitle, +// CHAR16 *Message, +// UINT8 MsgBoxType, +// UINT8 *pSelection +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; iInput.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; +} +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: ShowPostMsgBox +// +// Description: Function to display the message box +// +// Input: CHAR16 *MsgBoxTitle, +// CHAR16 *Message, +// UINT8 MsgBoxType, +// UINT8 *pSelection +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ; +// +//---------------------------------------------------------------------------- +// Procedure: _PostEditCallback +// +// Description: Callback function for text entry popup +// +// Input: VOID *container, VOID *object, VOID *cookie +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS _PostEditCallback(VOID *container, VOID *object, VOID *cookie) +{ + EFI_STATUS Status = EFI_SUCCESS; + +/* + if(cookie!=NULL) + { + res=0; + } + else + res=1; +*/ + return Status; +} +// +//---------------------------------------------------------------------------- +// Procedure: _PostEditDraw +// +// Description: Function to draw text entry edit box +// +// Input: POPUPEDIT_DATA *popup +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 ); +} +// +//---------------------------------------------------------------------------- +// Procedure: _PostPopupEditDraw +// +// Description: Function to draw text entry popup window +// +// Input: POPUPEDIT_DATA *PopupEdit +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// 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) +// +//---------------------------------------------------------------------------- +// +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; +} +// +//-------------------------------------------------------------------------- +// +// 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 +// +//-------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: _DisplayInfoCancelTimer +// +// Description: Timer notify fucntion +// +// Input: EFI_EVENT Event +// VOID *Context +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _DisplayInfoCancelTimer( EFI_EVENT Event, VOID *Context ) +{ + if ( gInfoBox != NULL ) + gMsgBox.Destroy( gInfoBox, TRUE ); + + gInfoBox = NULL; + + TimerStopTimer( &Event ); +} + +// +//---------------------------------------------------------------------------- +// Procedure: ShowInfoBox +// +// Description: fucntiont to display the information box +// +// Input: CHAR16 *InfoBoxTitle, +// CHAR16 *Message, +// UINTN TimeLimit, +// EFI_EVENT *RetEvent) +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: ActionReadKey +// +// Description: fucntion to handle the read key action +// +// Input: AMI_EFI_KEY_DATA *pAmiKey, +// UINT64 Timeout +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 + +} + +// +//---------------------------------------------------------------------------- +// Procedure: AMIReadKeyStroke +// +// Description: function to read a key stroke +// +// Input: EFI_INPUT_KEY *Key, +// AMI_EFI_KEY_DATA *KeyData +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: PopupEditHandlePassword +// +// Description: function to handle the popup password edit +// +// Input: VOID *pPopupEdit, +// VOID *pData +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: TseFramePwdCallbackIdePasswordUpdate +// +// Description: function to update the ide password +// +// Input: CONTROL_DATA *control, +// CHAR16 *saveData +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TsePopupPwdAuthenticateIDEPwd +// +// Description: Function to authenticate the IDE password +// +// Input: POPUP_PASSWORD_DATA *popuppassword, +// BOOLEAN *AbortUpdate, +// VOID *data +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TsePopupPwdUpdateIDEPwd +// +// Description: function to update the IDE password +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: IsLegacyOption +// +// Description: function to check for legacy option +// +// Input: UINT16 Option +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN IsLegacyOption(UINT16 Option) +{ + BOOT_DATA *pBootData; + + pBootData = BootGetBootData(Option); + + if(pBootData) + { + if(BBSValidDevicePath( pBootData->DevicePath )) + return TRUE; + } + + return FALSE; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ReGroupOptions +// +// Description: function to regroup the boot options +// +// Input: UINT16 *optionList, +// UINT16 *OrgOptionList +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 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 +// +//---------------------------------------------------------------------------- +// Procedure: TSEGetNVVariable +// +// Description: reads the NV Varaiable from Nram buffer using NVLib. +// +// Input: UINT32 variable, NVRAM_STORE_INFO *pInfo , UINTN *size +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: UpdateNVDefautls +// +// Description: Updated the Variable buffer with NVRam Defaults buffer. +// +// Input: UINT32 index, NVRAM_STORE_INFO *NvInfo, NVRAM_VARIABLE * VarPtr +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 + + +// +//---------------------------------------------------------------------------- +// Procedure: TseVarBuildAMIDefaults +// +// Description: function build the AMI defaults +// +// Input: None +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: TseBootNowinBootOrderInit +// +// Description: function build the AMI defaults +// +// Input: None +// +// Output: boot order string +// +//---------------------------------------------------------------------------- +// +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) + { + //gBootData[j].Option is not present in BootOrder; fill it + BootOrder[i] = gBootData[j].Option; + i++; + } + } + } + return BootOrder; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CheckShiftState +// +// Description: function to check the shift state value +// +// Input: None +// +// Output: 1 - valid shift state +// 0 - invalid shift state +// +//---------------------------------------------------------------------------- +// +BOOLEAN CheckShiftState(UINT32 KeyShiftState, UINT32 HotkeyState) +{ + if( KeyShiftState == HotkeyState) + return 1; + else + return 0; +} + +// +//---------------------------------------------------------------------------- +// Procedure: SupportPrintScreen +// +// Description: function to support the print screen. +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID SupportPrintScreen() +{ + EFI_GUID guid = AMITSE_PRINT_SCREEN_PRESS_GUID; + // Install the PrintScreen Notification. + EfiLibNamedEventSignal (&guid); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SupportPrintScreenEvent +// +// Description: function to check the print screen supprot event. +// +// Input: UINT16 ScanCode +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +BOOLEAN SupportPrintScreenEvent(UINT16 ScanCode) +{ + if( ScanCode == TSE_PRN_SCRN_KEY_SCAN ) + return 1; + else + return 0; +} + +// +//---------------------------------------------------------------------------- +// Procedure: IsToggleStateKey +// +// Description: function to check Is any of ToggleStateKey (CapsLock,Numlock ScrollLock) Keys pressed. +// +// Input: ACTION_DATA *Data +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 @@ + + 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" + 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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: dogif.c +// +// Description: This file contains code for gif image handling +// +//---------------------------------------------------------------------------- +// +#include + +// 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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: readbuf +// +// Description: Read the next byte from buffer +// +// Input: None +// +// Output: 0 .. 255 the byte +// -1 end of file +// +//---------------------------------------------------------------------------- +// +static int _inline readbuf( ) +{ + + if( unreadbuf == 0 ) + return -1; + + unreadbuf--; +#if TIANO + return (((int)*pcurbuf++)&0xff); +#else + return (int) *pcurbuf++; +#endif +} + +// +//---------------------------------------------------------------------------- +// Procedure: writepixel +// +// Description: Write a pixel at (X,Y) on the screen. +// +// Input: unsigned char Pixel +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +} + +// +//---------------------------------------------------------------------------- +// Procedure: ReadScreenDesc +// +// Description: Read the signature, the screen description, and the optional +// default color map. +// +// Input: None +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ReadImageDesc +// +// Description: Read the image description and the optional color map. +// +// Input: None +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: SkipObject +// +// Description: Skip over an extended GIF object. +// +// Input: None +// +// Output: TRUE/FALSE +// +//---------------------------------------------------------------------------- +// +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]; + } + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: dogifmgr.c +// +// Description: This file contains code for gif image handling +// +//---------------------------------------------------------------------------- +// + +#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); + +// +//---------------------------------------------------------------------------- +// Procedure: GetGifNextFrame +// +// Description: +// +// Input: VOID **UgaBlt , UINTN *GifDelay +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// + +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: NextFrame +// +// Description: function to get the next frame. +// +// Input: EFI_EVENT Event, VOID *Context +// +// Output: void +// +//---------------------------------------------------------------------------- +// + +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: DoGifAnimate +// +// Description: function to Handle gif logo animation +// +// Input: CO_ORD_ATTRIBUTE Attribute, +// INTN CoordinateX,INTN CoordinateY +// +// Output: None +// +//---------------------------------------------------------------------------- +// + +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); + } + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// + +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: CleanUpGif +// +// Description: Cleans the gif datas +// +// Input: void +// +// Output: void +// +//---------------------------------------------------------------------------- +// + +VOID CleanUpGif (VOID) +{ + while (NULL != GifEntries) + { + gBS->CloseEvent (GifEntries->GifAnimateData->GifEvent); + MemFreePointer( (VOID **)&GifEntries->GifAnimateData->UgaBltForGif); + MemFreePointer( (VOID **)&GifEntries->GifAnimateData->ImageBuffer); + GifEntries = GifEntries->Next; + } +} +// +//---------------------------------------------------------------------------- +// Procedure: SaveCleanUpGifDatas +// +// Description: Saves the structures used for preserving the gif images +// +// +// Input: GifDatas - Pointer to a pointer for GIF image structure +// +// Output: void +// +//---------------------------------------------------------------------------- +// + +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) +// +//*****************************************************************// +//*****************************************************************// +// +// +// Name: iJpeg.c +// +// Description: Adds jpeg Support. +// +// +//*****************************************************************// +#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); + + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: ipcx.c +// +// Description: This file contains code related to pcx image handling +// +//---------------------------------------------------------------------------- +// + +#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 + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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) +// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: jpeg.h +// +// Description: Header file for jpeg image format related code +// +//---------------------------------------------------------------------------- +// + +#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) +// +//*****************************************************************// +//*****************************************************************// +// +// +// Name: jpeg6.c +// +// Description: Support for JPEG decoding +// +// +//*****************************************************************// + +#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); + + +// +//---------------------------------------------------------------------------- +// Procedure: InitGlobals +// +// Description: Initializes required global variables +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +void InitGlobals(){ + diff_Y = 0; + diff_Cr = 0; + diff_Cb = 0; + bNumBitsRead = 8; + btempBitStreamByte = 0; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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]); + } + } + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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&0xff); + dwCoeffVal++; + } + } + + *pwValue = (WORD)dwCoeffVal; + return; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +void GetTables(BYTE bNumQT, BYTE bNumHT) +{ + int i,j; + + for(j=0;j +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; + +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +INT32 Check(INT32 n32ColorComp) +{ + n32ColorComp>>=14; + if(0x8000==(n32ColorComp&0x8000)) + n32ColorComp=0; + + if((n32ColorComp&0xffff)>255) + n32ColorComp=0x00ff;//mov CX,255 + + return n32ColorComp; +} + +// +//---------------------------------------------------------------------------- +// 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. +// +//---------------------------------------------------------------------------- +// +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; + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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++; + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: pcx.h +// +// Description: Header file for pcx image format related code +// +//---------------------------------------------------------------------------- +// + + +#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 +// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: pcx.c +// +// Description: This file contains code for pcx image handling +// +//---------------------------------------------------------------------------- +// + +#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); + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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; + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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)++; + } +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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++; + } + + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: png.c +// +// Description: This file contains code for png image handling +// +//---------------------------------------------------------------------------- +// + +#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; + + +// +//---------------------------------------------------------------------------- +// +// Name: PngGetUnsignedInt() +// +// Description: To get decimal values +// +// Input: const unsigned char dat[] +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +unsigned int PngGetUnsignedInt(const unsigned char dat[4]) +{ + return (unsigned)dat[3] + (unsigned)dat[2] * 0x100 + (unsigned)dat[1] * 0x10000 + (unsigned)dat[0] * 0x1000000; +} + +// +//---------------------------------------------------------------------------- +// +// Name: FindImageSize() +// +// Description: To find the PNG image size +// +// Input: none +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Header_Decode() +// +// Description: To Store the header values in the PngHeader variables +// +// Input: unsigned char dat[] +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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]; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Palette_Decode() +// +// Description: To store the PLTE data values in PngPalette variables +// +// Input: unsigned length,unsigned char dat[] +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Initialize() +// +// Description: to initialize the PngImageDecoder member variables +// +// Input: none +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: ReadChunk() +// +// Description: To Read all the chunk data +// +// Input: unsigned &length,unsigned char *&buf,unsigned &chunkType,unsigned &crc +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Paeth() +// +// Description: +// +// Input: unsigned int ua,unsigned int ub,unsigned int uc +// +// Output: unsigned char +// +//---------------------------------------------------------------------------- +// +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 + } +} + +// +//---------------------------------------------------------------------------- +// +// Name: Filter8() +// +// Description: +// +// Input: unsigned char curLine[],unsigned char prvLine[],int x,int y,int unitLng,int filter +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// +// Name: ShiftTwoLineBuf() +// +// Description: +// +// Input: none +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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; + } +} + +// +//---------------------------------------------------------------------------- +// +// Name: PrepareOutput() +// +// Description: To validate the colorType and bitDepth combination and prepare the output data +// +// Input: none +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Output() +// +// Description: To create the output values in the RGB format. +// +// Input: unsigned char dat +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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; + } + } +} + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// +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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: png.h +// +// Description: Header file for png image format related code +// +//---------------------------------------------------------------------------- +// + + +#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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: pnguncmp.c +// +// Description: This file contains code for pcx image handling +// +//---------------------------------------------------------------------------- +// + +#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); + + +// +//---------------------------------------------------------------------------- +// +// Name: GetNextBit() +// +// Description: To get the Next Bit +// +// Input: const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: GetNextMultiBit() +// +// Description: To get the Next multiple Bits. +// +// Input: const unsigned char dat[], unsigned *bytePtr, unsigned *bitPtr, unsigned n +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: MakeFixedHuffmanCode() +// +// Description: To make the fixed huffman code +// +// Input: unsigned hLength[288],unsigned hCode[288] +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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); + } +} + +// +//---------------------------------------------------------------------------- +// +// Name: MakeDynamicHuffmanCode() +// +// Description: To make the Dynamic Huffman Code +// +// Input: unsigned hLength[],unsigned hCode[],unsigned nLng,unsigned lng[] +// +// Output: none +// +//---------------------------------------------------------------------------- +// +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); + } +} + +// +//---------------------------------------------------------------------------- +// +// 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 +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: MakeHuffmanTree() +// +// Description: To create the huffman tree +// +// Input: unsigned n,unsigned hLength[],unsigned hCode[] +// +// Output: PngHuffmanTree +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: DeleteHuffmanTree() +// +// Description: Deleting the created Trees +// +// Input: PngHuffmanTree *node +// +// Output: String size +// +//---------------------------------------------------------------------------- +// +void DeleteHuffmanTree(PngHuffmanTree *node) +{ + if (node != NULL) + { + DeleteHuffmanTree(node->zero); //Delete the Huffman tree + DeleteHuffmanTree(node->one); + MemFreePointer( &node); + } +} + +// +//---------------------------------------------------------------------------- +// +// Name: GetCopyLength() +// +// Description: To Get the correct Copy Length +// +// Input: unsigned value,unsigned char dat[],unsigned &bytePtr,unsigned &bitPtr +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: GetBackwardDistance() +// +// Description: To get the Backward Distance +// +// Input: unsigned distCode,unsigned char dat[],unsigned &bytePtr,unsigned &bitPtr +// +// Output: unsigned int +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// +// Name: Uncompress() +// +// Description: Used to Uncompress the Image data and to convert the RGB format. +// +// Input: unsigned length,unsigned char dat[] +// +// Output: int +// +//---------------------------------------------------------------------------- +// +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. +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Special.c +// +// Description: This file contains code to handle special Operations +// +//---------------------------------------------------------------------------- +// + +#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 + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialGetIfrPtr +// +// Description: function to handle the operation of getting the Ifr Pointer. +// +// Input: VOID* conditional, +// UINT32 variable, +// GUID_INFO **guidInfo +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID *_SpecialGetIfrPtr( CONTROL_INFO *controlInfo, UINT32 * variable, GUID_INFO **guidInfo ) +{ + *variable = (UINT32)GetControlConditionVarId(controlInfo); + return UefiGetSpecialEqIDIfrPtr(controlInfo, variable, guidInfo); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SpecialGetValue +// +// Description: function to handle the operation of getting the Ifr Value. +// +// Input: CONTROL_DATA *control, +// GUID_INFO **guidInfo +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +// +UINT16 SpecialGetValue( CONTROL_DATA *control, GUID_INFO **guidInfo ) +{ + return UefiGetSpecialEqIDValue(&control->ControlData, guidInfo); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialGetValue +// +// Description: function to handle the operation of getting the Ifr Value. +// +// Input: CONTROL_INFO *controlinfo, +// GUID_INFO **guidInfo +// +// Output: UINT16 +// +//---------------------------------------------------------------------------- +// +UINT16 _SpecialGetValue( CONTROL_INFO *controlinfo, GUID_INFO **guidInfo ) +{ + return UefiGetSpecialEqIDValue(controlinfo, guidInfo); +} + + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialAddControl +// +// Description: function to Handle adding a control. +// +// Input: FRAME_DATA *frame , +// CONTROL_INFO *controlinfo, +// BOOLEAN *SetFocus +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +// +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; + +} +// +//---------------------------------------------------------------------------- +// Procedure: DoAddBootOptionFixup +// +// Description: +// +// Input: CONTROL_INFO *newControlInfo +// +// +// Output: None +// +//---------------------------------------------------------------------------- +// +VOID DoAddBootOptionFixup( CONTROL_INFO *newControlInfo ) +{ + _SpecialFixupAddBootOption(newControlInfo); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialAddMultipleControls +// +// Description: Adds Multiple controls for special controls +// +// Input: FRAME_DATA *frame , CONTROL_INFO *controlInfo, GUID_INFO *guidInfo, BOOLEAN *SetFocus +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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. +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialFixupLanguages +// +// Description: function to fixup the languages +// +// Input: CONTROL_INFO *control +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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; + +// +//---------------------------------------------------------------------------- +// Procedure: GetSpecialBootoptionToken +// +// Description: function to get the boot option token properly when loading the boot page +// +// Input: VOID* handle, UINTN Index +// +// Output: TOKEN +// +//---------------------------------------------------------------------------- +// +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 +// +//------------------------------------------------------------------------------------------- +// Procedure: _GetSpecialDriveroptionToken +// +// Description: function to get the boot option token properly when loading the boot page +// +// Input: VOID* handle, UINTN Index +// +// Output: TOKEN +// +//------------------------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialFixupBootOrder +// +// Description: function to fixup the Boot device order +// +// Input: CONTROL_INFO *control, +// UINT16 value +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialFixupDriverOrder +// +// Description: Function to fixup the driver order +// +// Input: CONTROL_INFO *control, +// UINT16 value +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); + } + } + } + +} + +// +//---------------------------------------------------------------------------- +// 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 +// +//---------------------------------------------------------------------------- +// +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); + } + } + } + +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialFixupBBSOrder +// +// Description: function to fixup the Legacy Boot device order +// +// Input: CONTROL_INFO *control, +// UINT16 value +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// Procedure: SpecialFixupDelBootOption +// +// Description: function to fixup the deletion of a boot device option +// +// Input: CONTROL_INFO *control, +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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); +} +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialFixupAddBootOption +// +// Description: function to fixup the adding of a boot device option +// +// Input: CONTROL_INFO *control, +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: SpecialFixupDelDriverOption +// +// Description: Function to fixup the deletion of a driver option +// +// Input: CONTROL_INFO *control, +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialExplodeControl +// +// Description: function to explode a perticular contorller +// +// Input: FRAME_DATA *frame, +// CONTROL_INFO *ctrlData, +// BOOLEAN *SetFocus +// +// Output: control Value +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: _SpecialControlExtras +// +// Description: special handling of extra operations +// +// Input: CONTROL_DATA *ctrlData +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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; iActive & 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; + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: SpecialUpdatePageControls +// +// Description: special fucntion to update the page controls +// +// Input: UINT32 CurrentPage +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +// +//*****************************************************************// +//*****************************************************************// +// +//---------------------------------------------------------------------------- +// +// Name: Special.h +// +// Description: Header file for TSE special controls like AMI callback controls +// +// +//---------------------------------------------------------------------------- +// +#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 +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: Action.c +// +// Description: This file contains code to handle different actions. +// +//---------------------------------------------------------------------------- +// + +#include "minisetup.h" + +/////////////////////////////////// +//VARIABLES DECLARATION +////////////////////////////////// +ACTION_METHODS gAction = +{ + ActionCreate, + ActionDestroy, + ActionGetAction, + ActionClearAction +}; +/////////////////////////////////// +//FUNCTIONS DECLARATION +////////////////////////////////// +EFI_STATUS _ActionReadMouse(MOUSE_INFO *MouseInfo); +BOOLEAN FlushKeysAfterRead(void); + +// +//---------------------------------------------------------------------------- +// Procedure: ActionCreate +// +// Description: Function to create an action. +// +// Input: ACTION_DATA **object +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ActionDestroy +// +// Description: Function to destroy an action. +// +// Input: ACTION_DATA *action, BOOLEAN freeMem +// +// Output: status +// +//---------------------------------------------------------------------------- +// +EFI_STATUS ActionDestroy( ACTION_DATA *action, BOOLEAN freeMem ) +{ + TimerStopTimer( &action->TimerEvent ); + + if ( freeMem ) + MemFreePointer( (VOID **)&action ); + + return EFI_SUCCESS; +} + +// +//---------------------------------------------------------------------------- +// Procedure: ActionGetAction +// +// Description: Function to get an action. +// +// Input: ACTION_DATA *action +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: ActionClearAction +// +// Description: Function to clear actions +// +// Input: ACTION_DATA *action +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +EFI_STATUS ActionClearAction( ACTION_DATA *action ) +{ + MemSet( &action->Input, sizeof(ACTION_INPUT), 0 ); + return EFI_SUCCESS; +} + +// +// Internal functions +// +// +//---------------------------------------------------------------------------- +// Procedure: _ActionReadKey +// +// Description: Function to read a key. +// +// Input: AMI_EFI_KEY_DATA *pAmiKey, UINT64 Timeout +// +// Output: status +// +//---------------------------------------------------------------------------- +// +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; +} +// +//---------------------------------------------------------------------------- +// Procedure: _ActionTimer +// +// Description: Function action timer +// +// Input: EFI_EVENT Event, VOID *Context +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _ActionTimer( EFI_EVENT Event, VOID *Context ) +{ + (*(UINT32 *)Context)++; +} +// +//---------------------------------------------------------------------------- +// Procedure: _ActionInstallTimer +// +// Description: Function to install action timer +// +// Input: ACTION_DATA *action, UINT64 TriggerTime +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +VOID _ActionInstallTimer( ACTION_DATA *action, UINT64 TriggerTime ) +{ + TimerCreateTimer( &action->TimerEvent, _ActionTimer, &action->TimerCount, TimerPeriodic, TriggerTime, EFI_TPL_CALLBACK ); +} +// +//---------------------------------------------------------------------------- +// Procedure: _ActionReadMouse +// +// Description: Function to get mouse action +// +// Input: MOUSE_INFO *MouseInfo +// +// Output: STATUS +// +//---------------------------------------------------------------------------- +// +//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 +// +// +//*****************************************************************// +//*****************************************************************// + +// +//---------------------------------------------------------------------------- +// +// Name: AddBootOption.c +// +// Description: This file contains code to handle the Add boot option operation. +// +//---------------------------------------------------------------------------- +// + +#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); + +// +//---------------------------------------------------------------------------- +// Procedure: TseUpdateAddDeleteBootVar +// +// Description: Function to update add and delete boot variables +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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 +// +//---------------------------------------------------------------------------- +// Procedure: TseUpdateAddDeleteDriverVar +// +// Description: Function to update add and delete driver variables +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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)); +} + +// +//---------------------------------------------------------------------------- +// Procedure: _GetFsLists +// +// Description: function to get the file system details +// +// Input: None +// +// Output: None +// +//---------------------------------------------------------------------------- +// +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;iOpenProtocol ( + 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 +}; + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +/* +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); +} +*/ + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +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); +} + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +UINTN _UnknownToStr( + EFI_DEVICE_PATH_PROTOCOL *Path, + UINT16 *Str + ) +{ + return SPrint(Str,0,DefaultDevicePath,Path->Type,Path->SubType); +} + + +// +//---------------------------------------------------------------------------- +// 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: +// +//---------------------------------------------------------------------------- +// +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 +// +//-------------------------------------------------------------------------------------------- +// 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 +// +//------------------------------------------------------------------------------------------- +// +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; + } + } + } +} + +// +//---------------------------------------------------------------------------- +// Procedure: BootAddBootOption +// +// Description: Function to add boot option +// +// Input: VOID +// +// Output: VOID +// +//---------------------------------------------------------------------------- +// +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;iLabel ); + 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