summaryrefslogtreecommitdiff
path: root/EDK/MiniSetup/BootOnly/minisetup.h
blob: cdd9a0e217b1264f1f4aa498494638d4a306918a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
//**                                                             **//
//**         (C)Copyright 2012, American Megatrends, Inc.        **//
//**                                                             **//
//**                     All Rights Reserved.                    **//
//**                                                             **//
//**   5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093  **//
//**                                                             **//
//**                     Phone (770)-246-8600                    **//
//**                                                             **//
//*****************************************************************//
//*****************************************************************//
//*****************************************************************//
// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $
//
// $Author: Premkumara $
//
// $Revision: 49 $
//
// $Date: 8/28/14 5:43a $
//
//*****************************************************************//
//*****************************************************************//
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/BootOnly/minisetup.h $
// 
// 49    8/28/14 5:43a Premkumara
// EIP-135253 Updating file name proper in #include
// 
// 48    2/11/14 7:56p Arunsb
// [TAG]	EIP125719
// [Category]	Improvement
// [Description]	The EfiCreateEventReadyToBoot is conflicted under
// UefiLib.h and EDKhelper.h.
// [Files]	boot.c
// 
// 47    10/18/12 5:58a Arunsb
// Updated for 2.16.1235 QA submission
// 
// 37    10/10/12 12:36p Arunsb
// Synched the source for v2.16.1232, backup with Aptio
// 
// 45    5/29/12 4:31a Arunsb
// [TAG]  		EIP91109
// [Category]  	Improvement
// [Description]  	Sync the Aptio IV source for AptioV
// 
// 44    5/28/12 5:39a Premkumara
// [TAG]  		EIP75236
// [Category]  	Improvement
// [Description]  	Add the support to control the GOP dependency in TSE
// notification.
// [Files]  		AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
// 
// 43    1/10/12 2:36a Arunsb
// [TAG]  		EIP77400
// [Category]  	Improvement
// [Description]  	Need to do "Clear Screen" whenever boot to EFI Shell
// [Files]  		Boot.c and minisetup.h
// 
// 42    12/08/11 12:34p Arunsb
// [TAG]  		EIP63190
// [Category]  	New Feature
// [Description]  	Security operations in BootOnly module instead of
// TSELite
// 
// 41    12/05/11 5:48a Rajashakerg
// [TAG]  		EIP76381 
// [Category]  	Improvement
// [Description]  	Performance: Improving variable data load and usage
// [Files]  		callback.c, minisetupext.c, variable.c, variable.h,
// minisetup.h, Hii.c, FormBrowser2.c
// 
// 40    12/01/11 5:36a Rajashakerg
// [TAG]  		EIP74963 
// [Category]  	Improvement
// [Description]  	MAX_MSGBOX_WIDTH cannot be overridden
// [Files]  		AMITSE.sdl, CommonHelper.c, minisetup.h, legacy.c,
// MessageBox.c, MessageBox.h, FormBrowser.c
// 
// 39    12/01/11 4:58a Arunsb
// // [TAG]  		EIP70175
// // [Category]  	Improvement
// // [Description]  	Removed unwanted declarations
// // [Files]  	                CommonHelper.c, postmgmtext.c
// 
// 38    11/21/11 10:44a Premkumara
// [TAG]  		EIP72610
// [Category]  	Improvement
// [Description]  	Moving TSE_MULTILINE_CONTROLS to Binary
// [Files]  		AMITSE-CommonHelper.c, AMITSE.sdl, 
// TSELITE-UefiAction.c, TseLite.sdl, Time.h, Text.c,
// SubMenu.c, ResetButton.c, PopupString.c, PopupSel.h, PopupSel.c, 
// PopupPassword.c, OrderListBox.c, Numeric.c, Label.c, Frame.c, Edit.c, 
// Date.h, Date.c, 
// LEGACY-Legacy.c,
// BOOTONLY- Minisetup.h
// 
// 37    11/21/11 5:47a Rajashakerg
// [TAG]  		EIP74591 
// [Category]  	Improvement
// [Description]  	Make MainSetupLoop as board module hook
// [Files]  		AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
// FormBrowser.c, FormBrowser2.c
// 
// 36    11/20/11 8:10a Premkumara
// [TAG]  		EIP70175
// [Category]  	Improvement
// [Description]  	Color of PopupPassword Window to validate password in
// GTSE style
// [Files]  	CommonHelper.c, postmgmtext.c, minisetup.h
// 
// 35    11/20/11 7:09a Rajashakerg
// [TAG]  		EIP62763
// [Category]  	Improvement
// [Description]  	Utilize the Improvements done from mouse driver in
// AMITSE
// [Files]  		HookAnchor.h, TseCommon.h, AMITSE.sdl, CommonHelper.c,
// commonoem.c, commonoem.h, buffer.c, globals.c, HookAnchor.c,
// minisetup.h, notify.c, postmgmt.c, protocol.c, ezport.c, stylecommon.c,
// Mouse.c, Action.c, Date.c, frame.c, MessageBox.c, minisetupext.c,
// minisetupext.h, numeric.c, numeric.h, page.c, PopupEdit.c, PopupEdit.h,
// PopupPassword.c, postmgmtext.c, time.c.
// 
// 34    11/14/11 2:43p Blaines
// [TAG] - EIP 75481
// [Category]- Function Request
// [Synopsis]- TSE debug print infrastructure.
// [Description]- Add TSE debug print info for basic functions such as
// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
// data. 
// [Files]
// AMITSE.sdl, AmiTSEStr.uni,  CommonHelper.c, commonoem.c, FakeTokens.c
// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
// Uefi21Wrapper.c, setupdbg.h
// 
// 33    11/13/11 12:32p Arunsb
// [TAG]  		EIP70421
// [Category]  	New Feature
// [Description]  	Support for driver order in TSE
// [Files]  		AMITSE.SDL, CommonHelper.c, setup.ini, uefisetup.ini,
// boot.c,
// minisetup.h, bbs.c, special.c, special.h, tseadvanced.c,
// addbootoption.c,
// callback.c, minisetupext.c, minisetupext.h, popupsel.c, popupsel.h,
// TseLitehelper.c, variable.c, Uefi21Wapper.c, AMIVfr.h, boot.h,
// TseElink.h, variable.h, 
// setup.h, Boot.vfr and Setup.uni
// 
// 32    10/31/11 9:45a Rajashakerg
// [TAG]  		EIP71120,71512 
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	BIOS gets stuck in infinite loop On enabling
// TSE_LOAD_OPTION_HIDDEN token,In first boot incorrect devices is
// disabled in Setup & BBS table but in second boot the correct device is
// disabled in both places.
// [Solution]  	Hidden option handled properly.
// [Files]  		TseLite\variable.c, TseLite\minisetupext.c, TseAdvanced.c,
// special.c, BootOnly\minisetup.h,BootOnly\boot.c, BootOnly\bbs.c
// 
// 31    7/19/11 10:50a Blaines
// [TAG] - EIP 63262
// [Category]- Defect
// [Symptom]- Setup page display problem on rose city.
// When SETUP_GROUP_DYNAMIC_PAGES is enabled and Network Stack is enabled,
// the "iSCSI" menu is listed as a dynamic page in advanced menu but only
// 3 of 4 "Port Configuration" pages shows up. The TSE dynamic page count
// is incorrect.
// 
// [Solution]- In the functions (RTIfrProcessRunTimeForms,
// HandleNewIFRPack, HandleRemoveIFRPack, HandleAddIFRPack), make sure the
// nvram cache is updated by calling
// VarUpdateVariable(VARIABLE_ID_DYNAMIC_PAGE_COUNT) when updating
// "DynamicPageCount" variable name. 
// .
// [Files] -  Hii.c, Minisetup.h, Variable.h
// 
// 30    7/01/11 5:19a Arunsb
// Driver health related declaration moved to tsedrvhealth.h.
// 
// 29    6/30/11 5:05a Premkumara
// [TAG]           EIP57661
// [Category]      New Feature
// [Description]   Resolve Build error with Driver Health protocol
// 
// 28    6/30/11 4:14a Arunsb
// [TAG]           EIP57661
// [Category]      New Feature
// [Description]   Boot manager algorithm for interaction with Driver
// Health protocol.
//                 2.0 & 2.1 compatibility added
// [Files]         amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
//                 commonhelper.c, uefisetup.ini, tsedrvhealth.h,
// amivfr.h, minisetupbin.mak,
//                 hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
// special.h, boot.h, minisetup.h,
//                 uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
// uefi21wapper.c.
// 
// 27    6/29/11 12:19p Rajashakerg
// [TAG]  		EIP47086, 62098 
// [Category]  	New Feature
// [Description]  	Right clicking from the Main page is not exiting from
// BIOS setup and the Mouse hotclicks.
// [Files]  		minisetup.h, Ezport\style.h,Ezport\EzportBin.sdl,
// Ezport\EzportBin.mak, Ezport\ezport.c, Ezport\EzportBin.cif,
// EzportPlus\style.h, EzportPlus\EzportPlusBin.sdl, EzportPlusBin.mak,
// EzportPlus\EzportPlusBin.cif, EzportPlus\ezportplus.c, Legacy\style.h,
// Legacy\EzportPlusBin.sdl, Legacy\LegacyBin.mak, Legacy\LegacyBin.cif,
// Legacy\legacy.c, TseLiteBin.sdl, TseLite.cif, Memo.c, frame.c,
// application.h, application.c, commonoem.h, CommonHelper.c
// 
// 26    6/23/11 4:06p Rajashakerg
// [TAG]  		EIP55762, 58925, 59971
// [Category]  	New Feature
// [Description]  	Support REF2,REF3 and REF4 in AMITSE
// Support direct form navigation path
// Improper layout of controls in the root page when Dynamic pages are
// added using the Legacy Setup Style	
// 
// [Files]  		setupdata.h, CommonHelper.c, AMITSE.sdl, Legacy\Legacy.c,
// Legacy\style.h, Legacy\style.h, frame.c, minisetupext.c,
// minisetupext.h, numeric.c, page.c Popupstring.c, Hii.c,
// Uefi21Wrapper.c, Parse.c Hii.c
// 
// 25    6/20/11 11:46a Rajashakerg
// [TAG]  		EIP59417
// [Category]  	New Feature
// [Description]  	Spport LOAD_OPTION_HIDDEN option in TSE 
// [Files]  		boot.h, AMITSE.sdl, CommonHelper.c, bbs.c, boot.c,
// minisetup.h, special.c, callback.c 
// 
// 24    3/28/11 11:40p Madhans
// [TAG]  		EIP50878
// [Category]  	Improvement
// [Description]  	Support to move the Control With Boot Order Change.
// [Files]  		AMITSE.sdl
// commonoem.c
// minisetup.h
// popupsel.c
// 
// 23    3/23/11 8:38p Blaines
// [TAG] - EIP 23601
// [Category]- Enhancement
// [Symptom]- Add support for OEM special controls.
// [Files] - AmiTse.sdl, CommonHelper.c, Setup.ini, UefiSetup.ini,
// AmiVfr.h, minisetup.h, minisetup.sdl, variable.c, special.c
// 
// 22    3/21/11 1:23a Rajashakerg
// [TAG]  		EIP53740
// [Category]  	Bug Fix
// [Severity]  	Normal
// [Symptom]  	Animation does not continue after the last frame of the
// logo.
// [RootCause]  	
// Animation is continued upto the last frame of the animated image
// [Solution]  	Fixed the issue by handling Gif image data to redraw image
// if all the frames are completed and if boottimeout is present. 	
// [Files]  		minisetup.h, dogif.c, dogifmgr.c
// 
// 21    3/15/11 5:14a Rajashakerg
// [TAG]  		EIP51671
// [Category]  	New Feature
// [Description]  	Boot overide menu devices are not disable  
// [Files]  		boot.c, minisetup.h, special.c, minisetupext.c, AMITSE.sdl,
// boot.h, CommonHelper.c 
// 
// 20    1/10/11 3:55p Mallikarjunanv
// Updated to work with respect to EDK Libraries
// 
// 19    12/29/10 2:27a Mallikarjunanv
// Updated the funcation name of the EIP:50479
// 
// 18    12/28/10 6:14p Mallikarjunanv
// [TAG]  		EIP41615
// [Category]  	New Feature
// [Description]  	Added the file browser support for the Add boot option
// reated controls
// [Files]  		AmiVfr.h, AmiTse.sdl, AmiTseStr.uni, CommonHelper.c,
// Faketokens.c, TseElinks.h, EdkHelper.h, minisetup.h, TseAdvanced.c,
// AddBootOption.c
// 
// 17    12/26/10 10:27a Mallikarjunanv
// [TAG]  		EIP50479
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	Calls to PostManagerProtocol->SwitchToPostScreen() after
// legacy option ROM execution cause CPU exception. 
// [RootCause]  	fter the notification, if the graphics driver uninstalled
// and reinstalled from core module then gGOP getting corrupted.
// [Solution]  	Updated gGop before using it in AMITSE.
// [Files]  		logo.c,minisetup.h, notify.c, postmgmt.c
// 
// 16    10/06/10 5:59p Madhans
// [TAG] - EIP 45620 
// [Category]- Enhancment
// [Severity]- Mordarate
// [Symptom]- TSE with TSE_CONTINUE_BOOT_NOW_ON_FAIL ON Not allows to boot
// to USB group of devices with customized BDS.
// [RootCause] - BBSTable does not contain the DeviceType called USB. Only
// in EFI Logical group is created in EFI variables.
// TSE was checking the DeviceType to set the priorities.
// [Solution]- TSE is changed to not check for DeviceType in BBSTable. But
// set the priorities based on LegacyDevOrder.
// [Files] - bbs.c commonhelper.c minisetup.h 
// 
// 15    10/05/10 5:38p Madhans
// [TAG] - EIP 45299 
// [Category]- Enhancment
// [Severity]- Minor
// [Symptom]- TSE by default saves the Disbaled BBS devices device path in
// NVRAM Varaiable "DisabledDevs" Variable. In Next boots it depend on
// this variable to consider the device as disabled inaddtion to
// LegacyDevOrder.
// Some BDS customized projects don't want this.
// [Solution]- TSE_SAVE_DISABLED_BBS_DEVICEPATH SDL token created to
// control this option. Bydefault It is Enabled.
// [Files] - callback.c bbs.c commonhelper.c minisetup.h AMITSE.sdl
// 
// 14    9/20/10 6:47p Madhans
// [TAG]    	EIP44542
// [Category]	BUILD ISSUE FIX
// [Symptom]	Build issues with TSE label (INT)4.6.2_TSE_2_10_1207_TEST
// when IdeSecurity and FastBoot modules added to the project
// [RootCause] -
// [Solution]	Build issues resolved
// [Files]		CommonHelper.c, Tsecommon.h, Hiilib.h, Boot.h, minisetup.h,
// bbs.c, special.c, Bds.c TseLitehelp
// 
// 13    9/16/10 8:38p Madhans
// Update for TSE 2.10. Refer Changelog.log for more details.
// 
// 28    9/08/10 6:53a Mallikarjunanv
// EIP-42080: TSE updates with respect to Fast Boot Support
// 
// 27    8/27/10 5:00a Mallikarjunanv
// EIP-39334: support to build TSE without the CSM module support
// 
// 26    4/07/10 6:24p Madhans
// post screen Sroll area support. TSE_POSTSCREEN_SCROLL_AREA SDL
// configures the area.
// 
// 25    4/02/10 4:37p Madhans
// To get ride of TSEOEM.H referance in TSE. Oem hearder files can be
// refered only in Tse Binary.
// 
// 24    3/23/10 5:08p Blaines
// Preseve the order of disabled BBS boot devices.
// 
// 23    2/26/10 7:06p Madhans
// Cleanup on formbrowrser.h
// 
// 3     2/26/10 3:36p Madhans
// Formbrowser.h need to be in Hii modules.
// 
// 21    2/17/10 1:02p Madhans
// minisetupstr.uni removed and Strings token are refered from
// AMITSEStrTokens.h
// 
// 20    2/15/10 10:10p Madhans
// To avoid Compilation issues
// 
// 19    2/11/10 7:14a Mallikarjunanv
// added Tse Advanced module dependency to include TseElinks.h
// 
// 18    2/04/10 12:03p Blaines
// EIP-28005
// 
// Added PostManagerSetAttribute to support display of text in color.
// Added support for handling string characters --- \n, \r.
// 
// 17    1/18/10 2:07a Mallikarjunanv
// EIP-28501: Updated for Keyboard scancode as password. Added a new Token
// SETUP_STORE_KEYCODE_PASSWORD to support the EFI key or Scan code as
// password
// 
// 16    1/09/10 5:26a Mallikarjunanv
// Updated TSE2.01 Release sources with coding standards
// 
// 15    1/04/10 10:40a Mallikarjunanv
// EIPs 27161/29095 - Added support for reserved boot option names and
// added support not to create empty boot option names
// 
// 14    10/28/09 5:37p Madhans
// 
// 13    9/24/09 9:41a Sudhirv
// EIP-24971: moved the dependency for TSE_CONTINUE_BOOT_NOW_ON_FAIL to
// Tse Binary
// 
// 12    9/17/09 9:04a Sudhirv
// Remove Load Driver Option from TSE 2.x as it will be handled from Core
// 
// 11    9/16/09 6:15p Madhans
// EIP 25416  : Support have 1/10 sec Timeout
// 
// 10    9/15/09 9:31a Sudhirv
// removed Version macros and added function declarations for Add Del boot
// option handling
// 
// 9     8/18/09 6:34p Blaines
// Support additional date styles
// 
// 8     8/17/09 12:21p Presannar
// Removed References to Tiano.h
// 
// 7     8/17/09 10:52a Presannar
// Added code to include EDKHelper.h
// Removed redefinition of structure LOGO_TYPE
// Added fn prototype for CleanUpExtendedLogoWrapper and
// DoLogoAnimateWrapper
// 
// 6     8/13/09 7:35a Mallikarjunanv
// eip:24971 - supporting tse features without tse sources
// 
// 5     7/30/09 7:49a Mallikarjunanv
// updated the code to move the exit page option elinks to Tse Binary - 
// included the new header file TseElinks.h to access all tse modules
// 
// 4     6/24/09 6:09p Madhans
// Made TSE_USE_EDK_LIBRARY=OFF to not to refer EDK module.
// 
// 3     6/16/09 2:16p Presannar
// Added File Headers for Header Files
// 
// 2     6/12/09 7:41p Presannar
// Initial implementation of coding standards
// 
// 1     6/04/09 8:05p Madhans
// 
// 3     5/13/09 2:22p Madhans
// To patch the version number in the Bootonly TSE. update the build
// number.
// 
// 2     5/07/09 10:35a Madhans
// Changes after Bin module
// 
// 9     5/06/09 12:31p Mallikarjunanv
// updated the version info
// 
// 8     5/05/09 3:11p Madhans
// Std Col default.
// 
// 7     5/01/09 9:45p Blaines
// Control and Label margin support changes
// 
// 6     4/28/09 9:39p Madhans
// Tse 2.0 Code complete Checkin.
// 
// 5     3/31/09 3:58p Madhans
// 
// 4     2/05/09 5:19p Madhans
// PostMgrStatus interface added.
// 
// 3     2/05/09 10:15a Madhans
// Style Module created.
// 
// 2     1/30/09 6:06p Madhans
// Function headers added. 
// 
// 1     12/18/08 7:58p Madhans
// Intial version of TSE Lite sources
//*****************************************************************//
//*****************************************************************//
//<AMI_FHDR_START>
//----------------------------------------------------------------------------
//
// Name:		MINISETUP.h
//
// Description:	Main header file takes care of TSE includes.
//
//----------------------------------------------------------------------------
//<AMI_FHDR_END>

#ifndef _MINISETUP_H_
#define	_MINISETUP_H_

#ifdef TSE_FOR_APTIO_4_50
#include <Token.h>
#else
#include "tokens.h"
#endif


#ifndef SETUP_USE_GUIDED_SECTION
#define SETUP_USE_GUIDED_SECTION 0
#endif

#ifndef SETUP_JPEG_LOGO_SUPPORT
#define SETUP_JPEG_LOGO_SUPPORT 0
#endif

#ifndef SETUP_PCX_LOGO_SUPPORT
#define SETUP_PCX_LOGO_SUPPORT 0
#endif

#ifndef SETUP_GIF_LOGO_SUPPORT
#define SETUP_GIF_LOGO_SUPPORT 0
#endif

#ifndef TSE_BOOT_NOW_IN_BOOT_ORDER
#define TSE_BOOT_NOW_IN_BOOT_ORDER 0
#endif

#if TSE_USE_EDK_LIBRARY
#include "Tiano.h" 

#include "EfiDriverLib.h"
#include "EfiPrintLib.h"

#include EFI_PROTOCOL_DEFINITION(FirmwareVolume)
#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem)
#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
// Between GOP and UGA draw protocols blt buffer structure remains
// the same. The difference is only in the name so we can safely
// typedef the new structure to old structure's name.
typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL;
#else
#include EFI_PROTOCOL_DEFINITION(UgaDraw)
#endif
#include EFI_PROTOCOL_DEFINITION(ConsoleControl)
#include EFI_PROTOCOL_DEFINITION(DevicePath)
#include EFI_PROTOCOL_DEFINITION(ComponentName)
#include EFI_PROTOCOL_DEFINITION(LegacyBios)
#include EFI_PROTOCOL_DEFINITION(LoadedImage)
#include EFI_PROTOCOL_DEFINITION(FileInfo)
#if EFI_SPECIFICATION_VERSION<=0x20000
#include EFI_PROTOCOL_DEFINITION(Hii)
#endif

#if SETUP_ITK_COMPATIBILITY
#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h"
#else
#include EFI_PROTOCOL_DEFINITION(EfiOEMBadging)
#endif
#include EFI_GUID_DEFINITION(Bmp)
INTN MemCmp( UINT8 *dest, UINT8 *src, UINTN size );

#define MSG_USB_WWID_CLASS_DP           MSG_USB_WWID_DP
#define MSG_USB_LOGICAL_UNIT_CLASS_DP   MSG_DEVICE_LOGICAL_UNIT_DP
#define MSG_USB_SATA_DP			        MSG_SATA_DP
#define MSG_USB_ISCSI_DP		        MSG_ISCSI_DP

#else //TSE_USE_EDK_LIBRARY

#include "Efi.h"

#include "Protocol/FirmwareVolume.h"
#include "Protocol/SimpleFileSystem.h"
#include "Protocol/SimpleTextOut.h"
#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
#include "Protocol/GraphicsOutput.h"
	// Between GOP and UGA draw protocols blt buffer structure remains
	// the same. The difference is only in the name so we can safely
	// typedef the new structure to old structure's name.
typedef EFI_GRAPHICS_OUTPUT_BLT_PIXEL EFI_UGA_PIXEL;
#else
#include "UgaDraw.h"
#endif

#include "Protocol/ConsoleControl.h"
#include "Protocol/DevicePath.h"
#include "Protocol/ComponentName.h"
//#include "LegacyBios.h"
#include "Protocol/LoadedImage.h"


#if SETUP_ITK_COMPATIBILITY
#include "..\ITK\OemBadgingSupport\EfiOEMBadging.h"
#else
#include "Protocol/EfiOemBadging.h" 
#endif

#include "Protocol/SimpleTextInEx.h"
//#include "LegacyBios.h"
#include "AmiDxeLib.h"  
#define EFI_DRIVER_ENTRY_POINT(a)

#include "EDKhelper.h"  

// EfiDriverlib
VOID *
EfiLibAllocateZeroPool (
  IN  UINTN   AllocationSize
  );

VOID
EfiStrCpy (
  IN CHAR16   *Destination,
  IN CHAR16   *Source
  );
UINTN
EfiDevicePathSize (
  IN EFI_DEVICE_PATH_PROTOCOL  *DevPath
  );
VOID *
EfiLibAllocatePool (
  IN  UINTN   AllocationSize
  );
EFI_STATUS
EFIAPI
TseEfiCreateEventReadyToBoot (
  IN EFI_TPL                      NotifyTpl,
  IN EFI_EVENT_NOTIFY             NotifyFunction,
  IN VOID                         *NotifyContext,
  OUT EFI_EVENT                   *ReadyToBootEvent
  );
EFI_STATUS
EfiLibReportStatusCode (
  IN EFI_STATUS_CODE_TYPE     Type,
  IN EFI_STATUS_CODE_VALUE    Value,
  IN UINT32                   Instance,
  IN EFI_GUID                 *CallerId OPTIONAL,
  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL
  );
EFI_DEVICE_PATH_PROTOCOL *
EfiFileDevicePath (
  IN EFI_HANDLE               Device  OPTIONAL,
  IN CHAR16                   *FileName
  );
EFI_STATUS
EfiLibNamedEventSignal (
  IN EFI_GUID            *Name
  );
EFI_DEVICE_PATH_PROTOCOL *
EfiAppendDevicePath (
  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,
  IN EFI_DEVICE_PATH_PROTOCOL  *Src2
  );

EFI_DEVICE_PATH_PROTOCOL        *
EfiAppendDevicePathNode (
  IN EFI_DEVICE_PATH_PROTOCOL  *Src1,
  IN EFI_DEVICE_PATH_PROTOCOL  *Src2
  );

VOID
EFIAPI
EfiInitializeFwVolDevicepathNode (
  IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH     *FvDevicePathNode,
  IN EFI_GUID                               *NameGuid
  );

UINTN
SPrint (
  OUT CHAR16        *Buffer,
  IN  UINTN         BufferSize,
  IN  CONST CHAR16  *Format,
  ...
  );
EFI_STATUS
EfiInitializeDriverLib (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
  );

VOID SetupDebugPrint(IN CONST CHAR8  *Format, ...) ;

extern EFI_SYSTEM_TABLE 	*gST;
extern EFI_BOOT_SERVICES 	*gBS;
extern EFI_RUNTIME_SERVICES 	*gRT;

#define EFI_TPL_APPLICATION 	TPL_APPLICATION
#define EFI_TPL_CALLBACK    	TPL_CALLBACK
#define EFI_TPL_NOTIFY      	TPL_NOTIFY
#define EFI_TPL_HIGH_LEVEL  	TPL_HIGH_LEVEL

#ifndef BBS_TYPE_FLOPPY
#define BBS_TYPE_FLOPPY           	BBS_FLOPPY
#endif
#ifndef BBS_TYPE_HARDDRIVE
#define BBS_TYPE_HARDDRIVE        	BBS_HARDDISK
#endif
#ifndef BBS_TYPE_CDROM
#define BBS_TYPE_CDROM            	BBS_CDROM
#endif
#ifndef BBS_TYPE_PCMCIA
#define BBS_TYPE_PCMCIA           	BBS_PCMCIA
#endif
#ifndef BBS_TYPE_USB
#define BBS_TYPE_USB              	BBS_USB
#endif
#ifndef BBS_TYPE_EMBEDDED_NETWORK
#define BBS_TYPE_EMBEDDED_NETWORK 	BBS_EMBED_NETWORK
#endif
#ifndef BBS_TYPE_BEV
#define BBS_TYPE_BEV              	BBS_BEV_DEVICE
#endif
#ifndef BBS_TYPE_UNKNOWN
#define BBS_TYPE_UNKNOWN          	BBS_UNKNOWN
#endif

#ifndef SCAN_NULL
#define SCAN_NULL       EFI_SCAN_NULL
#endif
#ifndef SCAN_UP
#define SCAN_UP         EFI_SCAN_UP
#endif
#ifndef SCAN_DOWN
#define SCAN_DOWN       EFI_SCAN_DN
#endif
#ifndef SCAN_RIGHT
#define SCAN_RIGHT      EFI_SCAN_RIGHT
#endif
#ifndef SCAN_LEFT
#define SCAN_LEFT       EFI_SCAN_LEFT
#endif
#ifndef SCAN_HOME
#define SCAN_HOME       EFI_SCAN_HOME
#endif
#ifndef SCAN_END
#define SCAN_END        EFI_SCAN_END
#endif
#ifndef SCAN_INSERT
#define SCAN_INSERT     EFI_SCAN_INS
#endif
#ifndef SCAN_DELETE
#define SCAN_DELETE     EFI_SCAN_DEL
#endif
#ifndef SCAN_PAGE_UP
#define SCAN_PAGE_UP    EFI_SCAN_PGUP
#endif
#ifndef SCAN_PAGE_DOWN
#define SCAN_PAGE_DOWN  EFI_SCAN_PGDN
#endif
#ifndef SCAN_F1
#define SCAN_F1         EFI_SCAN_F1
#endif
#ifndef SCAN_F2
#define SCAN_F2         EFI_SCAN_F2
#endif
#ifndef SCAN_F3
#define SCAN_F3         EFI_SCAN_F3
#endif
#ifndef SCAN_F4
#define SCAN_F4         EFI_SCAN_F4
#endif
#ifndef SCAN_F5
#define SCAN_F5         EFI_SCAN_F5
#endif
#ifndef SCAN_F6
#define SCAN_F6         EFI_SCAN_F6
#endif
#ifndef SCAN_F7
#define SCAN_F7         EFI_SCAN_F7
#endif
#ifndef SCAN_F8
#define SCAN_F8         EFI_SCAN_F8
#endif
#ifndef SCAN_F9
#define SCAN_F9         EFI_SCAN_F9
#endif
#ifndef SCAN_F10
#define SCAN_F10        EFI_SCAN_F10
#endif
#ifndef SCAN_F11
#define SCAN_F11        EFI_SCAN_F11
#endif
#ifndef SCAN_F12
#define SCAN_F12        EFI_SCAN_F12
#endif
#ifndef SCAN_ESC
#define SCAN_ESC        EFI_SCAN_ESC
#endif

#define CHAR_NULL             0x0000
#define CHAR_BACKSPACE        0x0008
#define CHAR_TAB              0x0009
#define CHAR_LINEFEED         0x000A
#define CHAR_CARRIAGE_RETURN  0x000D
#define GLYPH_WIDTH         8
#define GLYPH_HEIGHT        19
#define NARROW_CHAR         0xFFF0
#define WIDE_CHAR           0xFFF1
#define NON_BREAKING_CHAR   0xFFF2

// BMP
//
// Definitions for BMP files
//
#pragma pack(1)

typedef struct {
  UINT8   Blue;
  UINT8   Green;
  UINT8   Red;
  UINT8   Reserved;
} BMP_COLOR_MAP;

typedef struct {
  CHAR8         CharB;
  CHAR8         CharM;
  UINT32        Size;
  UINT16        Reserved[2];
  UINT32        ImageOffset;
  UINT32        HeaderSize;
  UINT32        PixelWidth;
  UINT32        PixelHeight;
  UINT16        Planes;       // Must be 1
  UINT16        BitPerPixel;  // 1, 4, 8, or 24
  UINT32        CompressionType;
  UINT32        ImageSize;    // Compressed image size in bytes
  UINT32        XPixelsPerMeter;
  UINT32        YPixelsPerMeter;
  UINT32        NumberOfColors;
  UINT32        ImportantColors;
} BMP_IMAGE_HEADER;

#pragma pack()

#define EFI_DEFAULT_BMP_LOGO_GUID \
  {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D}

extern EFI_GUID gEfiDefaultBmpLogoGuid;

///DEVICE PATH Definitions
#ifndef MSG_USB_WWID_CLASS_DP
#define MSG_USB_WWID_CLASS_DP		0x10
#endif
#ifndef MSG_USB_LOGICAL_UNIT_CLASS_DP
#define MSG_USB_LOGICAL_UNIT_CLASS_DP	0x11
#endif
#ifndef MSG_USB_SATA_DP
#define MSG_USB_SATA_DP			0x12
#endif
#ifndef MSG_USB_ISCSI_DP
#define MSG_USB_ISCSI_DP		0x13
#endif
#endif //TSE_USE_EDK_LIBRARY

//USB Class devices - Device path..
#define USB_PHY_DEV_CLASS 		0x05
#define USB_MASS_DEV_CLASS 		0x08

extern EFI_GUID  gEfiGlobalVariableGuid;

#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
#if TSE_USE_EDK_LIBRARY
#if EFI_SPECIFICATION_VERSION>=0x2000A
#define __UEFI_HII__H__
#include<EfiHii.h>
#else
#define __HII_PROTOCOL_H__
#endif
#endif //TSE_USE_EDK_LIBRARY
#include "Protocol/AmiKeyCode.h"
#else
#ifndef _AMI_EFI_KEY_DATA_
#define _AMI_EFI_KEY_DATA_
typedef struct {
  EFI_INPUT_KEY  Key;
} AMI_EFI_KEY_DATA;
#endif
#endif

#ifdef TSE_FOR_APTIO_4_50
#include "Include/Protocol/AMIPostMgr.h"
#else
#include "AMIPostMgr.h"
#endif

#include "amiver.h"

//handling version macros as tokens
//#define	TSE_MAJOR	0x02
//#define	TSE_MINOR	0x00
//#define	TSE_BUILD	0x1201

#define	MINI_SETUP_DATA_GUID		\
	{ 0xFE612B72, 0x203C, 0x47B1, 0x85, 0x60, 0xA6, 0x6D, 0x94, 0x6E, 0xB3, 0x71 }

#include "hiistring.h"
#include "string.h"
#include "protocol.h"
#include "variable.h"
#include "boot.h"
#include "AMILogo.h"
#include "bootflow.h"
#include "Timer.h"  

#ifdef TSE_FOR_APTIO_4_50
#include "AMITSEStrTokens.h"
#else
#include STRING_DEFINES_FILE
#endif

#ifdef TSE_FOR_APTIO_4_50
#include "Include/AMIVfr.h" 
#else
#include "AMIVFR.h"
#endif

#if TSE_APTIO_5_SUPPORT
#define AMITSE_TEXT(a) 	a
#else
#define AMITSE_TEXT(a) 	L##a
#endif

#include "bbs.h"

///for Hotkey customizations - 6/1/09
#if TSE_STYLE_SOURCES_SUPPORT
#include "HotkeyBin.h"
#include "HotclickBin.h" //EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
#endif

#if TSE_LITE_SOURCES_SUPPORT
#include "frame.h"
#include "Label.h"  
#include "hotkey.h"
#include "hotclick.h"//EIP:47086 - Right clicking from the Main page is not exiting from BIOS setup.
#include "minisetupext.h"
#endif 

#ifndef STRING_TOKEN
#define STRING_TOKEN(t) t
#endif

UINTN StyleGetTextMode( UINTN Rows, UINTN Cols );
VOID StyleUpdateVersionString( VOID );
UINTN StyleGetClearScreenColor(VOID);
UINT8 StyleGetPageLinkColor(VOID);
UINT8 StyleGetScrollBarColor(VOID);
UINT8 StyleGetScrollBarUpArrowColor(VOID);
UINT8 StyleGetScrollBarDownArrowColor(VOID);

UINTN StyleGetStdMaxRows(VOID);
UINTN StyleGetStdMaxCols(VOID);
VOID GetProgressColor(EFI_UGA_PIXEL * BGColor, EFI_UGA_PIXEL * BDRColor, EFI_UGA_PIXEL * FillColor);

#ifndef STYLE_FULL_MAX_ROWS
#define	STYLE_FULL_MAX_ROWS	31
#endif

#ifndef STYLE_FULL_MAX_COLS
#define	STYLE_FULL_MAX_COLS	100
#endif

#ifndef STYLE_STD_MAX_ROWS
#define	STYLE_STD_MAX_ROWS	24
#endif

#ifndef STYLE_STD_MAX_COLS
#define	STYLE_STD_MAX_COLS	80
#endif

#ifndef STYLE_MAX_COLS
#define	STYLE_MAX_COLS	STYLE_FULL_MAX_COLS
#endif

#ifndef STYLE_MAX_ROWS
#define	STYLE_MAX_ROWS	STYLE_FULL_MAX_ROWS
#endif

#define	MAX_ROWS		STYLE_MAX_ROWS
#define	MAX_COLS		STYLE_MAX_COLS
#define	MAX_DIMENSIONS	(STYLE_FULL_MAX_ROWS * STYLE_FULL_MAX_COLS)

#include "screen.h"

#include "commonoem.h"
#include "LogoLib.h"
#include "PwdLib.h"
#include "HiiLib.h"
#include "mem.h"
#include "HookAnchor.h"
#if TSE_ADVANCED_SUPPORT
#include "TseElinks.h"
#endif 
#ifdef TSE_FOR_APTIO_4_50
#include "AmiStatusCodes.h"
#else
#include "EfiStatusCode.h"
#endif

#ifndef BBS_TYPE_DEV
#ifdef BBS_TYPE_BEV
#define BBS_TYPE_DEV BBS_TYPE_BEV
#else
#define BBS_TYPE_DEV 0x80
#endif
#endif
/* B1DA0ADF-4F77-4070-A88E-BFFE1C60529A */
#define	MINI_SETUP_GUID	\
	{ 0xB1DA0ADF, 0x4F77, 0x4070, { 0xA8, 0x8E, 0xBF, 0xFE, 0x1C, 0x60, 0x52, 0x9A } }

#define	SETUP_VARIABLE_GUID	\
	{ 0xEC87D643, 0xEBA4, 0x4BB5, { 0xA1, 0xE5, 0x3F, 0x3E, 0x36, 0xB2, 0x0D, 0xA9 } }

/* 47C7B224-C42A-11D2-8E57-00A0C969723B */
#define ENVIRONMENT_VARIABLE_ID  \
  { 0x47c7b224, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }

// End Notifications


// Status code reporting - Defines >> Start
// Defined in AmiStatusCodes.h
// Redefining for Aptio 3.x 
#ifndef AMI_STATUS_CODE_CLASS
#define AMI_STATUS_CODE_CLASS 	EFI_OEM_SPECIFIC //0x8000
#endif

#ifndef AMI_DXE_BS_EC_INVALID_PASSWORD
#define AMI_DXE_BS_EC_INVALID_PASSWORD (AMI_STATUS_CODE_CLASS | 0x00000002)
#endif

#ifndef AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR
#define AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR (AMI_STATUS_CODE_CLASS | 0x00000003)
#endif

#ifndef AMI_DXE_BS_EC_BOOT_OPTION_FAILED
#define AMI_DXE_BS_EC_BOOT_OPTION_FAILED (AMI_STATUS_CODE_CLASS | 0x00000004)
#endif


#ifndef DXE_SETUP_VERIFYING_PASSWORD
#define DXE_SETUP_VERIFYING_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD)
#endif

#ifndef DXE_SETUP_START
#define DXE_SETUP_START (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP)
#endif

#ifndef DXE_SETUP_INPUT_WAIT
#define DXE_SETUP_INPUT_WAIT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_INPUT_WAIT)
#endif

#ifndef DXE_READY_TO_BOOT
#define DXE_READY_TO_BOOT (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
#endif

#ifndef DXE_INVALID_PASSWORD
#define DXE_INVALID_PASSWORD (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_INVALID_PASSWORD)
#endif

#ifndef DXE_BOOT_OPTION_LOAD_ERROR
#define DXE_BOOT_OPTION_LOAD_ERROR (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
#endif

#ifndef DXE_BOOT_OPTION_FAILED
#define DXE_BOOT_OPTION_FAILED (EFI_SOFTWARE_DXE_BS_DRIVER | AMI_DXE_BS_EC_BOOT_OPTION_FAILED)
#endif
// Status code reporting -Define >> End

#define NG_SIZE 	19
#define WG_SIZE		38

#ifdef EFI_NT_EMULATOR
#define	RUNTIME_DEBUG_SUPPORT
#define	RUNTIME_DEBUG(str)	{ if ( __RuntimeCheckDebugMode( str ) ) _asm int 3 }
#else
#undef RUNTIME_DEBUG_SUPPORT
#define	RUNTIME_DEBUG(str)
#endif

#ifndef STANDALONE_APPLICATION
#if APTIO_4_00 != 1 && SETUP_USE_GUIDED_SECTION !=1
extern SETUP_PKG					_SetupPackage;
#endif
#else
extern UINT8 DummySetupData[];
#endif


extern SCREEN_BUFFER				*gActiveBuffer;
extern SCREEN_BUFFER				*gFlushBuffer;
#ifdef USE_DEPRICATED_INTERFACE
extern UINT8						*STRING_ARRAY_NAME;
#else
#if APTIO_4_00
#else
extern UINT8						STRING_ARRAY_NAME[];
#endif
#endif
extern UINT8						*gApplicationData;
extern EFI_HANDLE					gImageHandle;
extern EFI_COMPONENT_NAME_PROTOCOL	gComponentName;
extern UINT16						gCheckboxTokens[];

extern BOOLEAN						gVariableChanged;
extern BOOLEAN						gResetRequired;

#if SETUP_USE_GRAPHICS_OUTPUT_PROTOCOL
extern EFI_GRAPHICS_OUTPUT_PROTOCOL	*gGOP;
#else
extern EFI_UGA_DRAW_PROTOCOL		*gUgaDraw;
#endif

#ifndef STANDALONE_APPLICATION
extern EFI_CONSOLE_CONTROL_PROTOCOL	*gConsoleControl;
#endif

//EIP75481  Support TSE debug print infrastructure

#define PRINT_UEFI		        1
#define PRINT_UEFI_CALLBACK	    2
#define PRINT_UEFI_NOTIFICATION 4
#define PRINT_UEFI_PARSE	    8

#if SUPPRESS_PRINT
    #define SETUP_DEBUG_TSE(format,...)
    #define SETUP_DEBUG_UEFI(format,...)
    #define SETUP_DEBUG_UEFI_PARSE(format,...)
    #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...)
    #define SETUP_DEBUG_UEFI_CALLBACK(format,...)
    #define SETUP_DEBUG_VAR(format,...)
#else //Else of SUPPRESS_PRINT
    #define SETUP_DEBUG_TSE(format,...) SetupDebugPrint(format, __VA_ARGS__)
    #define SETUP_DEBUG_UEFI(format,...) if((gDbgPrint & PRINT_UEFI)== PRINT_UEFI)SetupDebugPrint(format, __VA_ARGS__)
    #define SETUP_DEBUG_UEFI_PARSE(format,...) if((gDbgPrint & PRINT_UEFI_PARSE)== PRINT_UEFI_PARSE)SetupDebugPrint(format, __VA_ARGS__)
    #define SETUP_DEBUG_UEFI_NOTIFICATION(format,...) if((gDbgPrint & PRINT_UEFI_NOTIFICATION)== PRINT_UEFI_NOTIFICATION)SetupDebugPrint(format, __VA_ARGS__)
    #define SETUP_DEBUG_UEFI_CALLBACK(format,...) if((gDbgPrint & PRINT_UEFI_CALLBACK)== PRINT_UEFI_CALLBACK)SetupDebugPrint(format, __VA_ARGS__)
    #define SETUP_DEBUG_VAR(format,...) SetupDebugPrint(format, __VA_ARGS__)
#endif //End of SUPPRESS_PRINT
//EIP75481  


extern BOOLEAN						gQuietBoot;
extern BOOLEAN						gEnterSetup;
extern EFI_EVENT					gKeyTimer;
extern EFI_EVENT					gClickTimer;
extern UINT32						gPasswordType;

extern UINTN 						gPostStatus;

extern BOOT_DATA					*gBootData;

extern BOOT_DATA                    *gCurrLegacyBootData;

extern UINTN						gLangCount;
extern LANGUAGE_DATA				*gLanguages;

extern BOOLEAN						gSetupContextActive;
extern BOOLEAN						gPostMsgProtocolActive;
extern UINT8						gPostMgrAttribute;
extern AMI_VERSION					gVersion_TSE;
extern UINT32						gStartPage;

extern UINTN 						gLabelLeftMargin ;
extern UINTN 						gControlLeftPad ;
extern UINTN						gControlLeftMargin;
extern UINTN						gControlRightAreaWidth;

extern UINTN						gMaxRows;
extern UINTN						gMaxCols;
extern UINTN 						gPostManagerHandshakeCallIndex;
extern UINT16                       gDbgPrint ;

extern EFI_GUID _gBootFlowGuid;
extern BOOLEAN gDoNotBoot;

extern UINTN   gCurrIDESecPage;


#if TSE_USE_AMI_EFI_KEYCODE_PROTOCOL
extern EFI_GUID gAmiEfiKeycodeProtocolGuid;
#endif

//EIP-28501: To support SETUP_STORE_KEYCODE_PASSWORD options
#define PW_EFI_KEY		1
#define PW_SCAN_CODE	2

#define DATE_STYLE_MMDDYYYY		0
#define DATE_STYLE_YYYYDDMM		1
#define DATE_STYLE_DDMMYYYY		2
#define DATE_STYLE_YYYYMMDD		3

#define	TIMER_ONE_SECOND	(10 * 1000 * 1000)
#define	TIMER_HALF_SECOND	(TIMER_ONE_SECOND / 2)
#define TIMER_TENTH_SECOND  (TIMER_ONE_SECOND / 10)

#define	STRUCT_OFFSET(type, field)	(UINTN)&(((type *)0)->field)

typedef struct _PROGRESSBAR_INFO		//Structure containing global information used by progressbar handler
{
	UINTN			x;					//	ProgressBar Left Position
	UINTN			y;					//	ProgressBar Top Position
	UINTN			w;					//	ProgressBar width
	UINTN			h;					//	ProgressBar Height
	EFI_UGA_PIXEL	*backgroundColor;	//	ProgressBar Background Color
	EFI_UGA_PIXEL	*borderColor;		//	ProgressBar Border Color
	EFI_UGA_PIXEL	*fillColor;			//	ProgressBar Fill Color
	UINTN			delta;				//	Varies	increment
	UINTN			completed;			//	Varies	increment
	BOOLEAN			quiteBootActive;	//  True if quiteBoot is active	
	BOOLEAN			active;				//  True if progressbar has been initialized
}PROGRESSBAR_INFO;

extern PROGRESSBAR_INFO	*gProgress;

typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  ///
  /// Function Number (0 = First Function).
  ///
  UINT8                           FunctionNumber;
} AMITSE_PCCARD_DEVICE_PATH;

typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  ///
  /// Firmware file name
  ///
  EFI_GUID                        FvFileName;
} AMITSE_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;

typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  UINT32                          Tid;
} AMITSE_I2O_DEVICE_PATH;

typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  ///
  /// The MAC address for a network interface padded with 0s.
  ///
  EFI_MAC_ADDRESS                 MacAddress;
  ///
  /// Network interface type(i.e. 802.3, FDDI).
  ///
  UINT8                           IfType;
} AMITSE_MAC_ADDR_DEVICE_PATH;

typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  ///
  /// The HBA port number that facilitates the connection to the
  /// device or a port multiplier. The value 0xFFFF is reserved.
  ///
  UINT16                          HBAPortNumber;
  ///
  /// The Port multiplier port number that facilitates the connection
  /// to the device. Bit 15 should be set if the device is directly
  /// connected to the HBA.
  ///
  UINT16                          PortMultiplierPortNumber;
  ///
  /// Logical Unit Number.
  ///
  UINT16                          Lun;
} AMITSE_SATA_DEVICE_PATH;
typedef struct {
  EFI_DEVICE_PATH_PROTOCOL        Header;
  ///
  /// Network Protocol (0 = TCP, 1+ = reserved).
  ///
  UINT16                          NetworkProtocol;
  ///
  /// iSCSI Login Options.
  ///
  UINT16                          LoginOption;
  ///
  /// iSCSI Logical Unit Number.
  ///
  UINT64                          Lun;
  ///
  /// iSCSI Target Portal group tag the initiator intends
  /// to establish a session with.
  ///
  UINT16                          TargetPortalGroupTag;
  ///
  /// iSCSI NodeTarget Name. The length of the name
  /// is determined by subtracting the offset of this field from Length.
  ///
  /// CHAR8                        iSCSI Target Name.
} AMITSE_ISCSI_DEVICE_PATH;

// box.c 
VOID DrawLineWithAttribute( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type, UINT8 Attrib );
VOID DrawLine( UINTN Col, UINTN Row, UINTN Length, CHAR16 Type );
VOID DrawBorder( UINTN Left, UINTN Top, UINTN Width, UINTN Height );
VOID DrawWindow( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib, BOOLEAN Border, BOOLEAN Shadow );
VOID DrawBox( UINTN Left, UINTN Top, UINTN Width, UINTN Height, UINT8 Attrib );

// buffer.c
EFI_STATUS InitializeScreenBuffer( UINT8 attrib );
VOID SlowFlushLines( UINTN Top, UINTN Bottom );
VOID FlushLines( UINTN Top, UINTN Bottom );
VOID DoRealFlushLines();
void SetDesiredTextMode();


// logo.c
VOID CleanUpExtendedLogoWrapper();
VOID DoLogoAnimateWrapper(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY);
VOID DrawBltProgressBar(/*UINTN completed*/ );

VOID DrawProgressBarBorder(
    UINTN	x,
    UINTN	y,
	UINTN	w,
    UINTN	h,
	EFI_UGA_PIXEL *BltBuffer,
	UINTN	bw
    );

VOID DrawBlock(
    UINTN	x,
    UINTN	y,
	UINTN	w,
    UINTN	h,
	EFI_UGA_PIXEL *BltBuffer
    );


VOID DrawBltBuffer(
    EFI_UGA_PIXEL *UgaBlt,
    CO_ORD_ATTRIBUTE Attribute,
    UINTN Width,
    UINTN Height,
    INTN DestX,
    INTN DestY,
    UINTN BufferWidth
    );
EFI_STATUS GetScreenResolution(UINTN *ResX, UINTN *ResY);

typedef struct RefreshIdInfo{
    UINT8 *pEvent;
    UINT8 *pNotifyContext;
} REFRESH_ID_INFO;

// dobmpmgr.c
#if SETUP_BMP_LOGO_SUPPORT
EFI_STATUS ConvertBmpToUgaBlt (IN VOID *BmpImage, IN UINTN BmpImageSize, IN OUT VOID **UgaBlt,
		IN OUT UINTN  *UgaBltSize, OUT UINTN *PixelHeight, OUT UINTN *PixelWidth );
#endif

EFI_STATUS
ConvertAdvancedImageToUgaBlt (
  IN  VOID      *BmpImage,
  IN  UINTN     BmpImageSize,
  IN OUT VOID   **UgaBlt,
  IN OUT UINTN  *UgaBltSize,
  OUT UINTN     *PixelHeight,
  OUT UINTN     *PixelWidth,
  OUT BOOLEAN *Animate
);

VOID DoLogoAnimate(CO_ORD_ATTRIBUTE Attribute,INTN CoordinateX,INTN CoordinateY);
VOID CleanUpExtendedLogo(VOID);


// minisetup.c
BOOLEAN __RuntimeCheckDebugMode( CHAR16 *string );
VOID UIUpdateCallbackHook( VOID * Handle, UINT32 OldVariableCount  );//EIP 129750: UIUpdateCallback as board module hook
EFI_STATUS MainSetupLoopHook( VOID );//EIP74591: MainSetupLoop as board module hook
EFI_STATUS Handshake( VOID );
EFI_STATUS MiniSetupExit( EFI_STATUS Status );
EFI_STATUS MiniSetupEntry( VOID );

//EIP# 58925
extern UINT32 gNavStartPage ;
extern EFI_STATUS GetParentFormID(UINT16 ChildID, UINT16 *ParentID, UINT32 *StackIndex);
extern EFI_STATUS SetParentFormID(UINT16 ParentID, UINT16 TargetID);
extern VOID ResetNavStack();
//EIP# 58925

// notify.c
EFI_STATUS RegisterNotification( VOID );
VOID NotificationFunction( EFI_EVENT Event, VOID *Context );
VOID ActivateApplication( VOID );

//EIP-75236 Starts
VOID ActivateInput( VOID );
BOOLEAN  GetNotifyMaskValue (VOID);
BOOLEAN  IsDelayLogoTillInputSupported (VOID);
//EIP-75236 Ends

// postmgmt.c
VOID EncodePassword( CHAR16 *Password, UINTN MaxSize );
VOID CheckEnableQuietBoot( VOID );
//UINTN DrawAMILogo( VOID );
VOID InstallKeyHandlers( VOID );
VOID InstallClickHandlers( VOID );
VOID _DrawPasswordWindow(UINT16 PromptToken, UINTN PasswordLength, UINTN *CurrXPos, UINTN *CurrYPos);
VOID _ReportInBox(UINTN PasswordLength, UINT16 BoxToken, UINTN CurrXPos, UINTN CurrYPos, BOOLEAN bWaitForReturn);
EFI_STATUS _GetPassword(CHAR16 *PasswordEntered, UINTN PasswordLength, UINTN CurrXPos, UINTN CurrYPos, UINTN *TimeOut);

// helper functions
VOID * HelperGetVariable( UINT32 variable, CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size );
EFI_STATUS	InitApplicationData(EFI_HANDLE ImageHandle);
VOID MiniSetupUIExit(VOID);
VOID TSEIDEPasswordCheck();
VOID TSEIDEPasswordFreezeDevices();
VOID TSEUnlockHDD(VOID);
extern NVRAM_VARIABLE				*gVariableList;

// EIP 76381 : Performance Improving of variable data load and usage
extern NVRAM_VARIABLE *gCurrNvramVarList;
extern UINTN gCurrNvramVarCount;

#define	VARIABLE_ID_SETUP			0
#define	VARIABLE_ID_LANGUAGE		1
#define	VARIABLE_ID_BOOT_TIMEOUT	2
#define	VARIABLE_ID_USER_DEFAULTS	3
#define	VARIABLE_ID_ERROR_MANAGER	4
#define	VARIABLE_ID_AMITSESETUP     5
#define	VARIABLE_ID_IDE_SECURITY    6
#define VARIABLE_ID_BOOT_ORDER      7
#define VARIABLE_ID_BBS_ORDER       8
#define VARIABLE_ID_DEL_BOOT_OPTION 9
#define VARIABLE_ID_ADD_BOOT_OPTION 10
#define VARIABLE_ID_BOOT_MANAGER    11
#define VARIABLE_ID_BOOT_NOW        12
#define	VARIABLE_ID_LEGACY_DEV_INFO 13
#define	VARIABLE_ID_AMI_CALLBACK    14
#define	VARIABLE_ID_LEGACY_GROUP_INFO 15
#define	VARIABLE_ID_OEM_TSE_VAR		17
#define	VARIABLE_ID_DYNAMIC_PAGE_COUNT	18

UINT16 GetBootTimeOut(UINT16 DefaultValue);
EFI_STATUS UefiFormCallbackNVRead(CHAR16 *name, EFI_GUID *guid, UINT32 *attributes, UINTN *size, VOID **buffer);
EFI_STATUS UefiFormCallbackNVWrite(CHAR16 *name, EFI_GUID *guid, UINT32 attributes, VOID *buffer, UINTN size);
void UpdateAddDeleteBootVar(void);
UINT16 * BootNowinBootOrderInit(VOID);
BOOT_DATA * BootGetBootNowBootData(BOOT_DATA *bootData, UINT16 *BootOrder, UINTN i );
BOOLEAN NoVarStoreSupport(VOID);
BOOLEAN ItkSupport(VOID);
VOID UpdateLegacyDevVariable(UINT16 NoOfLegacyGroups);
VOID CsmBBSSetBootPriorities( BOOT_DATA *pBootData, UINT16 *pOrder, UINTN u16OrderCount);
CHAR16 *CsmBBSBootOptionName( BOOT_DATA *bootData);
EFI_STATUS CsmBBSSetBootNowPriority( BOOT_DATA *BootData,UINTN uiPrefferedDevice,BOOLEAN ShowAllBbsDev);
VOID CsmBBSGetDeviceList( VOID );
EFI_STATUS CsmBBSLaunchDevicePath( EFI_DEVICE_PATH_PROTOCOL *DevicePath );
EFI_STATUS 	InstallFormBrowserProtocol(EFI_HANDLE Handle);
VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle);
EFI_STATUS DoBbsPopupInit(VOID);
VOID MainSetupLoopInit(VOID);
UINTN TseGetANSIEscapeCode(CHAR16 *String,UINT8 *Bold,UINT8 *Foreground, UINT8 *Background);
CHAR16 *TseSkipEscCode(CHAR16 *String);
VOID DrawBootOnlyBbsPopupMenu( VOID );
VOID BbsBoot(VOID);
VOID BootGetLanguages();

extern BOOLEAN PlatformLangVerSupport();
extern BOOLEAN BootNowInBootOrderSupport();

VOID TseBootAddBootOption();
BOOLEAN CheckForAddDelBootOption();
VOID TSESpecialFixupDelBootOption(VOID *ControlInfo);
VOID TseDoAddBootOptionFixup(VOID *ControlInfo );
BOOLEAN TseDoBootDelBootOption(VOID *popupSel);
VOID TseDiscardAddDelBootOptions();
VOID TseSaveAddDelBootOptions();

// EIP-41615: Functions for the file browser support in add boot option
VOID TseLaunchFileSystem();

VOID TseBBSSetBootPriorities_BootOrder(UINT16 Priority); //EIP-24971: moved TSE_CONTINUE_BOOT_NOW_ON_FAIL support to Binary.

#define ___INTERNAL_CONVERT_TO_WSTRING___(a) L#a
#define CONVERT_TO_WSTRING(a) ___INTERNAL_CONVERT_TO_WSTRING___(a)

///Extended checks for Add/Delete Boot Option support
BOOLEAN IsUpdateBootOrderCursor();
BOOLEAN IsReservedBootOptionNamesEnable();
BOOLEAN IsPreservedDisabledBootOptionOrder();
EFI_STATUS FastBootLaunch(VOID);
extern BOOLEAN gIsSaveDisabledBBSDevicePath;
VOID UpdateGoPUgaDraw( VOID );//EIP:50479 : Function to Update gGop before using it in AMITSE.
//EIP:51671 Start
//Function declarations 
BOOLEAN IsBootDeviceEnabled( UINT16 value, BOOLEAN ShowAllBBSDev, BOOLEAN TseBootNowInBootOrde, BOOLEAN FromSetup);
BOOLEAN BootGetOptionStatus(BOOT_DATA *bootData, BOOLEAN FromSetup );
BOOLEAN BootGetBBSOptionStatus(BOOT_DATA *bootData, UINT16 value, BOOLEAN FromSetup,  BOOLEAN ShowAllBBSDev);
//EIP:51671 End
VOID RedrawGif(VOID);//EIP:53740 : Function to Redraw the Gif animated image.
BOOLEAN LoadOptionhidden(UINT16, BOOLEAN);	    //EIP:59417 - Fucntion Decleration to check the LOAD_OPTION_HIDDEN attribute for a boot option
EFI_STATUS TSEGetCoordinates(INT32 *x, INT32 *y, INT32 *z);
BOOLEAN CheckHiddenforBootDriverOption (UINT16, BOOLEAN);

//EIP70421 & 70422  Support for driver order starts
extern BOOT_DATA					*gDriverData;
void UpdateAddDeleteDriverVar (void);
VOID TseDriverAddDriverOption();
VOID TSESpecialFixupDelDriverOption (VOID *);
BOOLEAN TseDoDriverDelDriverOption(VOID *popupSel);
VOID TseDiscardAddDelDriverOptions();
VOID TseSaveAddDelDriverOptions();
//EIP70421 & 70422  Support for driver order ends
BOOLEAN  IsTSEMultilineControlSupported (VOID); //EIP-72610 Moved TSE_MULTILINE_CONTROLS to binary
UINT32 GetMsgboxWidth(VOID);//EIP74963 : MAX_MSGBOX_WIDTH macro changed as token and handled from binary
extern const UINTN TsePasswordLength;
VOID GetAMITSEVariable(AMITSESETUP **mSysConf,UINT8 **setup,UINTN *VarSize);
VOID NoVarStoreUpdateSystemAccess(UINT8 sysAccessValue);
VOID SetSystemAccessValueItk(UINT8 sysAccessValue);
VOID TSEStringReadLoopEntryHook(VOID);
VOID TSEStringReadLoopExitHook(VOID);
UINT32 PasswordAuthenticate( CHAR16 *Password );
EFI_STATUS AMIReadKeyStroke(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData);
EFI_STATUS HelperIsPasswordCharValid(EFI_INPUT_KEY *Key,AMI_EFI_KEY_DATA *KeyData,UINTN StrIndex,UINTN PasswordLength, CHAR16 *OutChar);
VOID TSEIDEUpdateConfig(VOID *ideSecConfig, UINTN value);
//EIP 77400
#define EFI_SHELL_PROTOCOL_GUID \
  { \
    0x47C7B223, 0xC42A, 0x11D2, 0x8E, 0x57, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \
  }
#endif /* _MINISETUP_H_ */

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**         (C)Copyright 2012, American Megatrends, Inc.             **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**     5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************