summaryrefslogtreecommitdiffstats
path: root/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
blob: 3f89748572582200bfafca72e9e32708aad15fe6 (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
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
/** @file
  This file defines the encoding for the VFR (Visual Form Representation) language.
  IFR is primarily consumed by the EFI presentation engine, and produced by EFI
  internal application and drivers as well as all add-in card option-ROM drivers

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

  @par Revision Reference:
  These definitions are from UEFI 2.1 and 2.2.

**/

#ifndef __UEFI_INTERNAL_FORMREPRESENTATION_H__
#define __UEFI_INTERNAL_FORMREPRESENTATION_H__

#include <Guid/HiiFormMapMethodGuid.h>

///
/// The following types are currently defined:
///
typedef VOID    *EFI_HII_HANDLE;
typedef CHAR16  *EFI_STRING;
typedef UINT16  EFI_IMAGE_ID;
typedef UINT16  EFI_QUESTION_ID;
typedef UINT16  EFI_STRING_ID;
typedef UINT16  EFI_FORM_ID;
typedef UINT16  EFI_VARSTORE_ID;
typedef UINT16  EFI_ANIMATION_ID;

typedef UINT16 EFI_DEFAULT_ID;

typedef UINT32 EFI_HII_FONT_STYLE;

#pragma pack(1)

//
// Definitions for Package Lists and Package Headers
// Section 27.3.1
//

///
/// The header found at the start of each package list.
///
typedef struct {
  EFI_GUID    PackageListGuid;
  UINT32      PackageLength;
} EFI_HII_PACKAGE_LIST_HEADER;

///
/// The header found at the start of each package.
///
typedef struct {
  UINT32    Length : 24;
  UINT32    Type   : 8;
  // UINT8  Data[...];
} EFI_HII_PACKAGE_HEADER;

//
// Value of HII package type
//
#define EFI_HII_PACKAGE_TYPE_ALL           0x00
#define EFI_HII_PACKAGE_TYPE_GUID          0x01
#define EFI_HII_PACKAGE_FORMS              0x02
#define EFI_HII_PACKAGE_STRINGS            0x04
#define EFI_HII_PACKAGE_FONTS              0x05
#define EFI_HII_PACKAGE_IMAGES             0x06
#define EFI_HII_PACKAGE_SIMPLE_FONTS       0x07
#define EFI_HII_PACKAGE_DEVICE_PATH        0x08
#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT    0x09
#define EFI_HII_PACKAGE_ANIMATIONS         0x0A
#define EFI_HII_PACKAGE_END                0xDF
#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN  0xE0
#define EFI_HII_PACKAGE_TYPE_SYSTEM_END    0xFF

//
// Definitions for Simplified Font Package
//

///
/// Contents of EFI_NARROW_GLYPH.Attributes.
///@{
#define EFI_GLYPH_NON_SPACING  0x01
#define EFI_GLYPH_WIDE         0x02
#define EFI_GLYPH_HEIGHT       19
#define EFI_GLYPH_WIDTH        8
///@}

///
/// The EFI_NARROW_GLYPH has a preferred dimension (w x h) of 8 x 19 pixels.
///
typedef struct {
  ///
  /// The Unicode representation of the glyph. The term weight is the
  /// technical term for a character code.
  ///
  CHAR16    UnicodeWeight;
  ///
  /// The data element containing the glyph definitions.
  ///
  UINT8     Attributes;
  ///
  /// The column major glyph representation of the character. Bits
  /// with values of one indicate that the corresponding pixel is to be
  /// on when normally displayed; those with zero are off.
  ///
  UINT8     GlyphCol1[EFI_GLYPH_HEIGHT];
} EFI_NARROW_GLYPH;

///
/// The EFI_WIDE_GLYPH has a preferred dimension (w x h) of 16 x 19 pixels, which is large enough
/// to accommodate logographic characters.
///
typedef struct {
  ///
  /// The Unicode representation of the glyph. The term weight is the
  /// technical term for a character code.
  ///
  CHAR16    UnicodeWeight;
  ///
  /// The data element containing the glyph definitions.
  ///
  UINT8     Attributes;
  ///
  /// The column major glyph representation of the character. Bits
  /// with values of one indicate that the corresponding pixel is to be
  /// on when normally displayed; those with zero are off.
  ///
  UINT8     GlyphCol1[EFI_GLYPH_HEIGHT];
  ///
  /// The column major glyph representation of the character. Bits
  /// with values of one indicate that the corresponding pixel is to be
  /// on when normally displayed; those with zero are off.
  ///
  UINT8     GlyphCol2[EFI_GLYPH_HEIGHT];
  ///
  /// Ensures that sizeof (EFI_WIDE_GLYPH) is twice the
  /// sizeof (EFI_NARROW_GLYPH). The contents of Pad must
  /// be zero.
  ///
  UINT8     Pad[3];
} EFI_WIDE_GLYPH;

///
/// A simplified font package consists of a font header
/// followed by a series of glyph structures.
///
typedef struct _EFI_HII_SIMPLE_FONT_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  UINT16                    NumberOfNarrowGlyphs;
  UINT16                    NumberOfWideGlyphs;
  // EFI_NARROW_GLYPH       NarrowGlyphs[];
  // EFI_WIDE_GLYPH         WideGlyphs[];
} EFI_HII_SIMPLE_FONT_PACKAGE_HDR;

//
// Definitions for Font Package
// Section 27.3.3
//

//
// Value for font style
//
#define EFI_HII_FONT_STYLE_NORMAL     0x00000000
#define EFI_HII_FONT_STYLE_BOLD       0x00000001
#define EFI_HII_FONT_STYLE_ITALIC     0x00000002
#define EFI_HII_FONT_STYLE_EMBOSS     0x00010000
#define EFI_HII_FONT_STYLE_OUTLINE    0x00020000
#define EFI_HII_FONT_STYLE_SHADOW     0x00040000
#define EFI_HII_FONT_STYLE_UNDERLINE  0x00080000
#define EFI_HII_FONT_STYLE_DBL_UNDER  0x00100000

typedef struct _EFI_HII_GLYPH_INFO {
  UINT16    Width;
  UINT16    Height;
  INT16     OffsetX;
  INT16     OffsetY;
  INT16     AdvanceX;
} EFI_HII_GLYPH_INFO;

///
/// The fixed header consists of a standard record header,
/// then the character values in this section, the flags
/// (including the encoding method) and the offsets of the glyph
/// information, the glyph bitmaps and the character map.
///
typedef struct _EFI_HII_FONT_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  UINT32                    HdrSize;
  UINT32                    GlyphBlockOffset;
  EFI_HII_GLYPH_INFO        Cell;
  EFI_HII_FONT_STYLE        FontStyle;
  CHAR16                    FontFamily[1];
} EFI_HII_FONT_PACKAGE_HDR;

//
// Value of different glyph info block types
//
#define EFI_HII_GIBT_END                0x00
#define EFI_HII_GIBT_GLYPH              0x10
#define EFI_HII_GIBT_GLYPHS             0x11
#define EFI_HII_GIBT_GLYPH_DEFAULT      0x12
#define EFI_HII_GIBT_GLYPHS_DEFAULT     0x13
#define EFI_HII_GIBT_GLYPH_VARIABILITY  0x14
#define EFI_HII_GIBT_DUPLICATE          0x20
#define EFI_HII_GIBT_SKIP2              0x21
#define EFI_HII_GIBT_SKIP1              0x22
#define EFI_HII_GIBT_DEFAULTS           0x23
#define EFI_HII_GIBT_EXT1               0x30
#define EFI_HII_GIBT_EXT2               0x31
#define EFI_HII_GIBT_EXT4               0x32

typedef struct _EFI_HII_GLYPH_BLOCK {
  UINT8    BlockType;
} EFI_HII_GLYPH_BLOCK;

//
// Definition of different glyph info block types
//

typedef struct _EFI_HII_GIBT_DEFAULTS_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  EFI_HII_GLYPH_INFO     Cell;
} EFI_HII_GIBT_DEFAULTS_BLOCK;

typedef struct _EFI_HII_GIBT_DUPLICATE_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  CHAR16                 CharValue;
} EFI_HII_GIBT_DUPLICATE_BLOCK;

typedef struct _EFI_GLYPH_GIBT_END_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
} EFI_GLYPH_GIBT_END_BLOCK;

typedef struct _EFI_HII_GIBT_EXT1_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT8                  BlockType2;
  UINT8                  Length;
} EFI_HII_GIBT_EXT1_BLOCK;

typedef struct _EFI_HII_GIBT_EXT2_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT8                  BlockType2;
  UINT16                 Length;
} EFI_HII_GIBT_EXT2_BLOCK;

typedef struct _EFI_HII_GIBT_EXT4_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT8                  BlockType2;
  UINT32                 Length;
} EFI_HII_GIBT_EXT4_BLOCK;

typedef struct _EFI_HII_GIBT_GLYPH_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  EFI_HII_GLYPH_INFO     Cell;
  UINT8                  BitmapData[1];
} EFI_HII_GIBT_GLYPH_BLOCK;

typedef struct _EFI_HII_GIBT_GLYPHS_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  EFI_HII_GLYPH_INFO     Cell;
  UINT16                 Count;
  UINT8                  BitmapData[1];
} EFI_HII_GIBT_GLYPHS_BLOCK;

typedef struct _EFI_HII_GIBT_GLYPH_DEFAULT_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT8                  BitmapData[1];
} EFI_HII_GIBT_GLYPH_DEFAULT_BLOCK;

typedef struct _EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT16                 Count;
  UINT8                  BitmapData[1];
} EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK;

typedef struct _EFI_HII_GIBT_VARIABILITY_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  EFI_HII_GLYPH_INFO     Cell;
  UINT8                  GlyphPackInBits;
  UINT8                  BitmapData[1];
} EFI_HII_GIBT_VARIABILITY_BLOCK;

typedef struct _EFI_HII_GIBT_SKIP1_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT8                  SkipCount;
} EFI_HII_GIBT_SKIP1_BLOCK;

typedef struct _EFI_HII_GIBT_SKIP2_BLOCK {
  EFI_HII_GLYPH_BLOCK    Header;
  UINT16                 SkipCount;
} EFI_HII_GIBT_SKIP2_BLOCK;

//
// Definitions for Device Path Package
// Section 27.3.4
//

///
/// The device path package is used to carry a device path
/// associated with the package list.
///
typedef struct _EFI_HII_DEVICE_PATH_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  // EFI_DEVICE_PATH_PROTOCOL DevicePath[];
} EFI_HII_DEVICE_PATH_PACKAGE_HDR;

//
// Definitions for GUID Package
// Section 27.3.5
//

///
/// The GUID package is used to carry data where the format is defined by a GUID.
///
typedef struct _EFI_HII_GUID_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  EFI_GUID                  Guid;
  // Data per GUID definition may follow
} EFI_HII_GUID_PACKAGE_HDR;

//
// Definitions for String Package
// Section 27.3.6
//

#define UEFI_CONFIG_LANG    "x-UEFI"
#define UEFI_CONFIG_LANG_2  "x-i-UEFI"

///
/// The fixed header consists of a standard record header and then the string identifiers
/// contained in this section and the offsets of the string and language information.
///
typedef struct _EFI_HII_STRING_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  UINT32                    HdrSize;
  UINT32                    StringInfoOffset;
  CHAR16                    LanguageWindow[16];
  EFI_STRING_ID             LanguageName;
  CHAR8                     Language[1];
} EFI_HII_STRING_PACKAGE_HDR;

typedef struct {
  UINT8    BlockType;
} EFI_HII_STRING_BLOCK;

//
// Value of different string information block types
//
#define EFI_HII_SIBT_END                0x00
#define EFI_HII_SIBT_STRING_SCSU        0x10
#define EFI_HII_SIBT_STRING_SCSU_FONT   0x11
#define EFI_HII_SIBT_STRINGS_SCSU       0x12
#define EFI_HII_SIBT_STRINGS_SCSU_FONT  0x13
#define EFI_HII_SIBT_STRING_UCS2        0x14
#define EFI_HII_SIBT_STRING_UCS2_FONT   0x15
#define EFI_HII_SIBT_STRINGS_UCS2       0x16
#define EFI_HII_SIBT_STRINGS_UCS2_FONT  0x17
#define EFI_HII_SIBT_DUPLICATE          0x20
#define EFI_HII_SIBT_SKIP2              0x21
#define EFI_HII_SIBT_SKIP1              0x22
#define EFI_HII_SIBT_EXT1               0x30
#define EFI_HII_SIBT_EXT2               0x31
#define EFI_HII_SIBT_EXT4               0x32
#define EFI_HII_SIBT_FONT               0x40

//
// Definition of different string information block types
//

typedef struct _EFI_HII_SIBT_DUPLICATE_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  EFI_STRING_ID           StringId;
} EFI_HII_SIBT_DUPLICATE_BLOCK;

typedef struct _EFI_HII_SIBT_END_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
} EFI_HII_SIBT_END_BLOCK;

typedef struct _EFI_HII_SIBT_EXT1_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   BlockType2;
  UINT8                   Length;
} EFI_HII_SIBT_EXT1_BLOCK;

typedef struct _EFI_HII_SIBT_EXT2_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   BlockType2;
  UINT16                  Length;
} EFI_HII_SIBT_EXT2_BLOCK;

typedef struct _EFI_HII_SIBT_EXT4_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   BlockType2;
  UINT32                  Length;
} EFI_HII_SIBT_EXT4_BLOCK;

typedef struct _EFI_HII_SIBT_FONT_BLOCK {
  EFI_HII_SIBT_EXT2_BLOCK    Header;
  UINT8                      FontId;
  UINT16                     FontSize;
  EFI_HII_FONT_STYLE         FontStyle;
  CHAR16                     FontName[1];
} EFI_HII_SIBT_FONT_BLOCK;

typedef struct _EFI_HII_SIBT_SKIP1_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   SkipCount;
} EFI_HII_SIBT_SKIP1_BLOCK;

typedef struct _EFI_HII_SIBT_SKIP2_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT16                  SkipCount;
} EFI_HII_SIBT_SKIP2_BLOCK;

typedef struct _EFI_HII_SIBT_STRING_SCSU_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   StringText[1];
} EFI_HII_SIBT_STRING_SCSU_BLOCK;

typedef struct _EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   FontIdentifier;
  UINT8                   StringText[1];
} EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK;

typedef struct _EFI_HII_SIBT_STRINGS_SCSU_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT16                  StringCount;
  UINT8                   StringText[1];
} EFI_HII_SIBT_STRINGS_SCSU_BLOCK;

typedef struct _EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   FontIdentifier;
  UINT16                  StringCount;
  UINT8                   StringText[1];
} EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK;

typedef struct _EFI_HII_SIBT_STRING_UCS2_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  CHAR16                  StringText[1];
} EFI_HII_SIBT_STRING_UCS2_BLOCK;

typedef struct _EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   FontIdentifier;
  CHAR16                  StringText[1];
} EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK;

typedef struct _EFI_HII_SIBT_STRINGS_UCS2_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT16                  StringCount;
  CHAR16                  StringText[1];
} EFI_HII_SIBT_STRINGS_UCS2_BLOCK;

typedef struct _EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK {
  EFI_HII_STRING_BLOCK    Header;
  UINT8                   FontIdentifier;
  UINT16                  StringCount;
  CHAR16                  StringText[1];
} EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK;

//
// Definitions for Image Package
// Section 27.3.7
//

typedef struct _EFI_HII_IMAGE_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  UINT32                    ImageInfoOffset;
  UINT32                    PaletteInfoOffset;
} EFI_HII_IMAGE_PACKAGE_HDR;

typedef struct _EFI_HII_IMAGE_BLOCK {
  UINT8    BlockType;
} EFI_HII_IMAGE_BLOCK;

//
// Value of different image information block types
//
#define EFI_HII_IIBT_END                0x00
#define EFI_HII_IIBT_IMAGE_1BIT         0x10
#define EFI_HII_IIBT_IMAGE_1BIT_TRANS   0x11
#define EFI_HII_IIBT_IMAGE_4BIT         0x12
#define EFI_HII_IIBT_IMAGE_4BIT_TRANS   0x13
#define EFI_HII_IIBT_IMAGE_8BIT         0x14
#define EFI_HII_IIBT_IMAGE_8BIT_TRANS   0x15
#define EFI_HII_IIBT_IMAGE_24BIT        0x16
#define EFI_HII_IIBT_IMAGE_24BIT_TRANS  0x17
#define EFI_HII_IIBT_IMAGE_JPEG         0x18
#define EFI_HII_IIBT_IMAGE_PNG          0x19
#define EFI_HII_IIBT_DUPLICATE          0x20
#define EFI_HII_IIBT_SKIP2              0x21
#define EFI_HII_IIBT_SKIP1              0x22
#define EFI_HII_IIBT_EXT1               0x30
#define EFI_HII_IIBT_EXT2               0x31
#define EFI_HII_IIBT_EXT4               0x32

//
// Definition of different image information block types
//

typedef struct _EFI_HII_IIBT_END_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
} EFI_HII_IIBT_END_BLOCK;

typedef struct _EFI_HII_IIBT_EXT1_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT8                  BlockType2;
  UINT8                  Length;
} EFI_HII_IIBT_EXT1_BLOCK;

typedef struct _EFI_HII_IIBT_EXT2_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT8                  BlockType2;
  UINT16                 Length;
} EFI_HII_IIBT_EXT2_BLOCK;

typedef struct _EFI_HII_IIBT_EXT4_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT8                  BlockType2;
  UINT32                 Length;
} EFI_HII_IIBT_EXT4_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_1BIT_BASE {
  UINT16    Width;
  UINT16    Height;
  UINT8     Data[1];
} EFI_HII_IIBT_IMAGE_1BIT_BASE;

typedef struct _EFI_HII_IIBT_IMAGE_1BIT_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_1BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_1BIT_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_1BIT_TRANS_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_1BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_1BIT_TRANS_BLOCK;

typedef struct _EFI_HII_RGB_PIXEL {
  UINT8    b;
  UINT8    g;
  UINT8    r;
} EFI_HII_RGB_PIXEL;

typedef struct _EFI_HII_IIBT_IMAGE_24BIT_BASE {
  UINT16               Width;
  UINT16               Height;
  EFI_HII_RGB_PIXEL    Bitmap[1];
} EFI_HII_IIBT_IMAGE_24BIT_BASE;

typedef struct _EFI_HII_IIBT_IMAGE_24BIT_BLOCK {
  EFI_HII_IMAGE_BLOCK              Header;
  EFI_HII_IIBT_IMAGE_24BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_24BIT_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_24BIT_TRANS_BLOCK {
  EFI_HII_IMAGE_BLOCK              Header;
  EFI_HII_IIBT_IMAGE_24BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_24BIT_TRANS_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_4BIT_BASE {
  UINT16    Width;
  UINT16    Height;
  UINT8     Data[1];
} EFI_HII_IIBT_IMAGE_4BIT_BASE;

typedef struct _EFI_HII_IIBT_IMAGE_4BIT_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_4BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_4BIT_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_4BIT_TRANS_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_4BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_4BIT_TRANS_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_8BIT_BASE {
  UINT16    Width;
  UINT16    Height;
  UINT8     Data[1];
} EFI_HII_IIBT_IMAGE_8BIT_BASE;

typedef struct _EFI_HII_IIBT_IMAGE_8BIT_PALETTE_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_8BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_8BIT_BLOCK;

typedef struct _EFI_HII_IIBT_IMAGE_8BIT_TRANS_BLOCK {
  EFI_HII_IMAGE_BLOCK             Header;
  UINT8                           PaletteIndex;
  EFI_HII_IIBT_IMAGE_8BIT_BASE    Bitmap;
} EFI_HII_IIBT_IMAGE_8BIT_TRAN_BLOCK;

typedef struct _EFI_HII_IIBT_DUPLICATE_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  EFI_IMAGE_ID           ImageId;
} EFI_HII_IIBT_DUPLICATE_BLOCK;

typedef struct _EFI_HII_IIBT_JPEG_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT32                 Size;
  UINT8                  Data[1];
} EFI_HII_IIBT_JPEG_BLOCK;

typedef struct _EFI_HII_IIBT_PNG_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT32                 Size;
  UINT8                  Data[1];
} EFI_HII_IIBT_PNG_BLOCK;

typedef struct _EFI_HII_IIBT_SKIP1_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT8                  SkipCount;
} EFI_HII_IIBT_SKIP1_BLOCK;

typedef struct _EFI_HII_IIBT_SKIP2_BLOCK {
  EFI_HII_IMAGE_BLOCK    Header;
  UINT16                 SkipCount;
} EFI_HII_IIBT_SKIP2_BLOCK;

//
// Definitions for Palette Information
//

typedef struct _EFI_HII_IMAGE_PALETTE_INFO_HEADER {
  UINT16    PaletteCount;
} EFI_HII_IMAGE_PALETTE_INFO_HEADER;

typedef struct _EFI_HII_IMAGE_PALETTE_INFO {
  UINT16               PaletteSize;
  EFI_HII_RGB_PIXEL    PaletteValue[1];
} EFI_HII_IMAGE_PALETTE_INFO;

//
// Definitions for Forms Package
// Section 27.3.8
//

///
/// The Form package is used to carry form-based encoding data.
///
typedef struct _EFI_HII_FORM_PACKAGE_HDR {
  EFI_HII_PACKAGE_HEADER    Header;
  // EFI_IFR_OP_HEADER         OpCodeHeader;
  // More op-codes follow
} EFI_HII_FORM_PACKAGE_HDR;

typedef struct {
  UINT8    Hour;
  UINT8    Minute;
  UINT8    Second;
} EFI_HII_TIME;

typedef struct {
  UINT16    Year;
  UINT8     Month;
  UINT8     Day;
} EFI_HII_DATE;

typedef struct {
  EFI_QUESTION_ID    QuestionId;
  EFI_FORM_ID        FormId;
  EFI_GUID           FormSetGuid;
  EFI_STRING_ID      DevicePath;
} EFI_HII_REF;

typedef union {
  UINT8            u8;
  UINT16           u16;
  UINT32           u32;
  UINT64           u64;
  BOOLEAN          b;
  EFI_HII_TIME     time;
  EFI_HII_DATE     date;
  EFI_STRING_ID    string; ///< EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
  EFI_HII_REF      ref;    ///< EFI_IFR_TYPE_REF
  // UINT8 buffer[];      ///< EFI_IFR_TYPE_BUFFER
} EFI_IFR_TYPE_VALUE;

//
// IFR Opcodes
//
#define EFI_IFR_FORM_OP                 0x01
#define EFI_IFR_SUBTITLE_OP             0x02
#define EFI_IFR_TEXT_OP                 0x03
#define EFI_IFR_IMAGE_OP                0x04
#define EFI_IFR_ONE_OF_OP               0x05
#define EFI_IFR_CHECKBOX_OP             0x06
#define EFI_IFR_NUMERIC_OP              0x07
#define EFI_IFR_PASSWORD_OP             0x08
#define EFI_IFR_ONE_OF_OPTION_OP        0x09
#define EFI_IFR_SUPPRESS_IF_OP          0x0A
#define EFI_IFR_LOCKED_OP               0x0B
#define EFI_IFR_ACTION_OP               0x0C
#define EFI_IFR_RESET_BUTTON_OP         0x0D
#define EFI_IFR_FORM_SET_OP             0x0E
#define EFI_IFR_REF_OP                  0x0F
#define EFI_IFR_NO_SUBMIT_IF_OP         0x10
#define EFI_IFR_INCONSISTENT_IF_OP      0x11
#define EFI_IFR_EQ_ID_VAL_OP            0x12
#define EFI_IFR_EQ_ID_ID_OP             0x13
#define EFI_IFR_EQ_ID_VAL_LIST_OP       0x14
#define EFI_IFR_AND_OP                  0x15
#define EFI_IFR_OR_OP                   0x16
#define EFI_IFR_NOT_OP                  0x17
#define EFI_IFR_RULE_OP                 0x18
#define EFI_IFR_GRAY_OUT_IF_OP          0x19
#define EFI_IFR_DATE_OP                 0x1A
#define EFI_IFR_TIME_OP                 0x1B
#define EFI_IFR_STRING_OP               0x1C
#define EFI_IFR_REFRESH_OP              0x1D
#define EFI_IFR_DISABLE_IF_OP           0x1E
#define EFI_IFR_ANIMATION_OP            0x1F
#define EFI_IFR_TO_LOWER_OP             0x20
#define EFI_IFR_TO_UPPER_OP             0x21
#define EFI_IFR_MAP_OP                  0x22
#define EFI_IFR_ORDERED_LIST_OP         0x23
#define EFI_IFR_VARSTORE_OP             0x24
#define EFI_IFR_VARSTORE_NAME_VALUE_OP  0x25
#define EFI_IFR_VARSTORE_EFI_OP         0x26
#define EFI_IFR_VARSTORE_DEVICE_OP      0x27
#define EFI_IFR_VERSION_OP              0x28
#define EFI_IFR_END_OP                  0x29
#define EFI_IFR_MATCH_OP                0x2A
#define EFI_IFR_GET_OP                  0x2B
#define EFI_IFR_SET_OP                  0x2C
#define EFI_IFR_READ_OP                 0x2D
#define EFI_IFR_WRITE_OP                0x2E
#define EFI_IFR_EQUAL_OP                0x2F
#define EFI_IFR_NOT_EQUAL_OP            0x30
#define EFI_IFR_GREATER_THAN_OP         0x31
#define EFI_IFR_GREATER_EQUAL_OP        0x32
#define EFI_IFR_LESS_THAN_OP            0x33
#define EFI_IFR_LESS_EQUAL_OP           0x34
#define EFI_IFR_BITWISE_AND_OP          0x35
#define EFI_IFR_BITWISE_OR_OP           0x36
#define EFI_IFR_BITWISE_NOT_OP          0x37
#define EFI_IFR_SHIFT_LEFT_OP           0x38
#define EFI_IFR_SHIFT_RIGHT_OP          0x39
#define EFI_IFR_ADD_OP                  0x3A
#define EFI_IFR_SUBTRACT_OP             0x3B
#define EFI_IFR_MULTIPLY_OP             0x3C
#define EFI_IFR_DIVIDE_OP               0x3D
#define EFI_IFR_MODULO_OP               0x3E
#define EFI_IFR_RULE_REF_OP             0x3F
#define EFI_IFR_QUESTION_REF1_OP        0x40
#define EFI_IFR_QUESTION_REF2_OP        0x41
#define EFI_IFR_UINT8_OP                0x42
#define EFI_IFR_UINT16_OP               0x43
#define EFI_IFR_UINT32_OP               0x44
#define EFI_IFR_UINT64_OP               0x45
#define EFI_IFR_TRUE_OP                 0x46
#define EFI_IFR_FALSE_OP                0x47
#define EFI_IFR_TO_UINT_OP              0x48
#define EFI_IFR_TO_STRING_OP            0x49
#define EFI_IFR_TO_BOOLEAN_OP           0x4A
#define EFI_IFR_MID_OP                  0x4B
#define EFI_IFR_FIND_OP                 0x4C
#define EFI_IFR_TOKEN_OP                0x4D
#define EFI_IFR_STRING_REF1_OP          0x4E
#define EFI_IFR_STRING_REF2_OP          0x4F
#define EFI_IFR_CONDITIONAL_OP          0x50
#define EFI_IFR_QUESTION_REF3_OP        0x51
#define EFI_IFR_ZERO_OP                 0x52
#define EFI_IFR_ONE_OP                  0x53
#define EFI_IFR_ONES_OP                 0x54
#define EFI_IFR_UNDEFINED_OP            0x55
#define EFI_IFR_LENGTH_OP               0x56
#define EFI_IFR_DUP_OP                  0x57
#define EFI_IFR_THIS_OP                 0x58
#define EFI_IFR_SPAN_OP                 0x59
#define EFI_IFR_VALUE_OP                0x5A
#define EFI_IFR_DEFAULT_OP              0x5B
#define EFI_IFR_DEFAULTSTORE_OP         0x5C
#define EFI_IFR_FORM_MAP_OP             0x5D
#define EFI_IFR_CATENATE_OP             0x5E
#define EFI_IFR_GUID_OP                 0x5F
#define EFI_IFR_SECURITY_OP             0x60
#define EFI_IFR_MODAL_TAG_OP            0x61
#define EFI_IFR_REFRESH_ID_OP           0x62
#define EFI_IFR_WARNING_IF_OP           0x63
#define EFI_IFR_MATCH2_OP               0x64

//
// Definitions of IFR Standard Headers
// Section 27.3.8.2
//

typedef struct _EFI_IFR_OP_HEADER {
  UINT8    OpCode;
  UINT8    Length : 7;
  UINT8    Scope  : 1;
} EFI_IFR_OP_HEADER;

typedef struct _EFI_IFR_STATEMENT_HEADER {
  EFI_STRING_ID    Prompt;
  EFI_STRING_ID    Help;
} EFI_IFR_STATEMENT_HEADER;

typedef struct _EFI_IFR_QUESTION_HEADER {
  EFI_IFR_STATEMENT_HEADER    Header;
  EFI_QUESTION_ID             QuestionId;
  EFI_VARSTORE_ID             VarStoreId;
  union {
    EFI_STRING_ID    VarName;
    UINT16           VarOffset;
  }                        VarStoreInfo;
  UINT8                       Flags;
} EFI_IFR_QUESTION_HEADER;

//
// Flag values of EFI_IFR_QUESTION_HEADER
//
#define EFI_IFR_FLAG_READ_ONLY           0x01
#define EFI_IFR_FLAG_CALLBACK            0x04
#define EFI_IFR_FLAG_RESET_REQUIRED      0x10
#define EFI_IFR_FLAG_REST_STYLE          0x20
#define EFI_IFR_FLAG_RECONNECT_REQUIRED  0x40
#define EFI_IFR_FLAG_OPTIONS_ONLY        0x80

//
// Definition for Opcode Reference
// Section 27.3.8.3
//
typedef struct _EFI_IFR_DEFAULTSTORE {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        DefaultName;
  UINT16               DefaultId;
} EFI_IFR_DEFAULTSTORE;

//
// Default Identifier of default store
//
#define EFI_HII_DEFAULT_CLASS_STANDARD        0x0000
#define EFI_HII_DEFAULT_CLASS_MANUFACTURING   0x0001
#define EFI_HII_DEFAULT_CLASS_SAFE            0x0002
#define EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN  0x4000
#define EFI_HII_DEFAULT_CLASS_PLATFORM_END    0x7fff
#define EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN  0x8000
#define EFI_HII_DEFAULT_CLASS_HARDWARE_END    0xbfff
#define EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN  0xc000
#define EFI_HII_DEFAULT_CLASS_FIRMWARE_END    0xffff

typedef struct _EFI_IFR_VARSTORE {
  EFI_IFR_OP_HEADER    Header;
  EFI_GUID             Guid;
  EFI_VARSTORE_ID      VarStoreId;
  UINT16               Size;
  UINT8                Name[1];
} EFI_IFR_VARSTORE;

typedef struct _EFI_IFR_VARSTORE_EFI {
  EFI_IFR_OP_HEADER    Header;
  EFI_VARSTORE_ID      VarStoreId;
  EFI_GUID             Guid;
  UINT32               Attributes;
  UINT16               Size;
  UINT8                Name[1];
} EFI_IFR_VARSTORE_EFI;

typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {
  EFI_IFR_OP_HEADER    Header;
  EFI_VARSTORE_ID      VarStoreId;
  EFI_GUID             Guid;
} EFI_IFR_VARSTORE_NAME_VALUE;

typedef struct _EFI_IFR_FORM_SET {
  EFI_IFR_OP_HEADER    Header;
  EFI_GUID             Guid;
  EFI_STRING_ID        FormSetTitle;
  EFI_STRING_ID        Help;
  UINT8                Flags;
  // EFI_GUID              ClassGuid[];
} EFI_IFR_FORM_SET;

typedef struct _EFI_IFR_END {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_END;

typedef struct _EFI_IFR_FORM {
  EFI_IFR_OP_HEADER    Header;
  UINT16               FormId;
  EFI_STRING_ID        FormTitle;
} EFI_IFR_FORM;

typedef struct _EFI_IFR_IMAGE {
  EFI_IFR_OP_HEADER    Header;
  EFI_IMAGE_ID         Id;
} EFI_IFR_IMAGE;

typedef struct _EFI_IFR_MODAL_TAG {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MODAL_TAG;

typedef struct _EFI_IFR_LOCKED {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_LOCKED;

typedef struct _EFI_IFR_RULE {
  EFI_IFR_OP_HEADER    Header;
  UINT8                RuleId;
} EFI_IFR_RULE;

typedef struct _EFI_IFR_DEFAULT {
  EFI_IFR_OP_HEADER     Header;
  UINT16                DefaultId;
  UINT8                 Type;
  EFI_IFR_TYPE_VALUE    Value;
} EFI_IFR_DEFAULT;

typedef struct _EFI_IFR_DEFAULT_2 {
  EFI_IFR_OP_HEADER    Header;
  UINT16               DefaultId;
  UINT8                Type;
} EFI_IFR_DEFAULT_2;

typedef struct _EFI_IFR_VALUE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_VALUE;

typedef struct _EFI_IFR_SUBTITLE {
  EFI_IFR_OP_HEADER           Header;
  EFI_IFR_STATEMENT_HEADER    Statement;
  UINT8                       Flags;
} EFI_IFR_SUBTITLE;

#define EFI_IFR_FLAGS_HORIZONTAL  0x01

typedef struct _EFI_IFR_CHECKBOX {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      Flags;
} EFI_IFR_CHECKBOX;

#define EFI_IFR_CHECKBOX_DEFAULT      0x01
#define EFI_IFR_CHECKBOX_DEFAULT_MFG  0x02

typedef struct _EFI_IFR_TEXT {
  EFI_IFR_OP_HEADER           Header;
  EFI_IFR_STATEMENT_HEADER    Statement;
  EFI_STRING_ID               TextTwo;
} EFI_IFR_TEXT;

typedef struct _EFI_IFR_REF {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  EFI_FORM_ID                FormId;
} EFI_IFR_REF;

typedef struct _EFI_IFR_REF2 {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  EFI_FORM_ID                FormId;
  EFI_QUESTION_ID            QuestionId;
} EFI_IFR_REF2;

typedef struct _EFI_IFR_REF3 {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  EFI_FORM_ID                FormId;
  EFI_QUESTION_ID            QuestionId;
  EFI_GUID                   FormSetId;
} EFI_IFR_REF3;

typedef struct _EFI_IFR_REF4 {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  EFI_FORM_ID                FormId;
  EFI_QUESTION_ID            QuestionId;
  EFI_GUID                   FormSetId;
  EFI_STRING_ID              DevicePath;
} EFI_IFR_REF4;

typedef struct _EFI_IFR_REF5 {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
} EFI_IFR_REF5;

typedef struct _EFI_IFR_RESET_BUTTON {
  EFI_IFR_OP_HEADER           Header;
  EFI_IFR_STATEMENT_HEADER    Statement;
  EFI_DEFAULT_ID              DefaultId;
} EFI_IFR_RESET_BUTTON;

typedef struct _EFI_IFR_ACTION {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  EFI_STRING_ID              QuestionConfig;
} EFI_IFR_ACTION;

typedef struct _EFI_IFR_ACTION_1 {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
} EFI_IFR_ACTION_1;

typedef struct _EFI_IFR_DATE {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      Flags;
} EFI_IFR_DATE;

//
// Flags that describe the behavior of the question.
//
#define EFI_QF_DATE_YEAR_SUPPRESS   0x01
#define EFI_QF_DATE_MONTH_SUPPRESS  0x02
#define EFI_QF_DATE_DAY_SUPPRESS    0x04

#define EFI_QF_DATE_STORAGE         0x30
#define     QF_DATE_STORAGE_NORMAL  0x00
#define     QF_DATE_STORAGE_TIME    0x10
#define     QF_DATE_STORAGE_WAKEUP  0x20

typedef union {
  struct {
    UINT8    MinValue;
    UINT8    MaxValue;
    UINT8    Step;
  } u8;
  struct {
    UINT16    MinValue;
    UINT16    MaxValue;
    UINT16    Step;
  } u16;
  struct {
    UINT32    MinValue;
    UINT32    MaxValue;
    UINT32    Step;
  } u32;
  struct {
    UINT64    MinValue;
    UINT64    MaxValue;
    UINT64    Step;
  } u64;
} MINMAXSTEP_DATA;

typedef struct _EFI_IFR_NUMERIC {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      Flags;
  MINMAXSTEP_DATA            data;
} EFI_IFR_NUMERIC;

//
// Flags related to the numeric question
//
#define EFI_IFR_NUMERIC_SIZE      0x03
#define   EFI_IFR_NUMERIC_SIZE_1  0x00
#define   EFI_IFR_NUMERIC_SIZE_2  0x01
#define   EFI_IFR_NUMERIC_SIZE_4  0x02
#define   EFI_IFR_NUMERIC_SIZE_8  0x03

#define EFI_IFR_DISPLAY             0x30
#define   EFI_IFR_DISPLAY_INT_DEC   0x00
#define   EFI_IFR_DISPLAY_UINT_DEC  0x10
#define   EFI_IFR_DISPLAY_UINT_HEX  0x20

typedef struct _EFI_IFR_ONE_OF {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      Flags;
  MINMAXSTEP_DATA            data;
} EFI_IFR_ONE_OF;

typedef struct _EFI_IFR_STRING {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      MinSize;
  UINT8                      MaxSize;
  UINT8                      Flags;
} EFI_IFR_STRING;

#define EFI_IFR_STRING_MULTI_LINE  0x01

typedef struct _EFI_IFR_PASSWORD {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT16                     MinSize;
  UINT16                     MaxSize;
} EFI_IFR_PASSWORD;

typedef struct _EFI_IFR_ORDERED_LIST {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      MaxContainers;
  UINT8                      Flags;
} EFI_IFR_ORDERED_LIST;

#define EFI_IFR_UNIQUE_SET    0x01
#define EFI_IFR_NO_EMPTY_SET  0x02

typedef struct _EFI_IFR_TIME {
  EFI_IFR_OP_HEADER          Header;
  EFI_IFR_QUESTION_HEADER    Question;
  UINT8                      Flags;
} EFI_IFR_TIME;

//
// A bit-mask that determines which unique settings are active for this opcode.
//
#define QF_TIME_HOUR_SUPPRESS    0x01
#define QF_TIME_MINUTE_SUPPRESS  0x02
#define QF_TIME_SECOND_SUPPRESS  0x04

#define QF_TIME_STORAGE           0x30
#define   QF_TIME_STORAGE_NORMAL  0x00
#define   QF_TIME_STORAGE_TIME    0x10
#define   QF_TIME_STORAGE_WAKEUP  0x20

typedef struct _EFI_IFR_DISABLE_IF {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_DISABLE_IF;

typedef struct _EFI_IFR_SUPPRESS_IF {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_SUPPRESS_IF;

typedef struct _EFI_IFR_GRAY_OUT_IF {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_GRAY_OUT_IF;

typedef struct _EFI_IFR_INCONSISTENT_IF {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        Error;
} EFI_IFR_INCONSISTENT_IF;

typedef struct _EFI_IFR_NO_SUBMIT_IF {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        Error;
} EFI_IFR_NO_SUBMIT_IF;

typedef struct _EFI_IFR_WARNING_IF {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        Warning;
  UINT8                TimeOut;
} EFI_IFR_WARNING_IF;

typedef struct _EFI_IFR_REFRESH {
  EFI_IFR_OP_HEADER    Header;
  UINT8                RefreshInterval;
} EFI_IFR_REFRESH;

typedef struct _EFI_IFR_VARSTORE_DEVICE {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        DevicePath;
} EFI_IFR_VARSTORE_DEVICE;

typedef struct _EFI_IFR_ONE_OF_OPTION {
  EFI_IFR_OP_HEADER     Header;
  EFI_STRING_ID         Option;
  UINT8                 Flags;
  UINT8                 Type;
  EFI_IFR_TYPE_VALUE    Value;
} EFI_IFR_ONE_OF_OPTION;

//
// Types of the option's value.
//
#define EFI_IFR_TYPE_NUM_SIZE_8   0x00
#define EFI_IFR_TYPE_NUM_SIZE_16  0x01
#define EFI_IFR_TYPE_NUM_SIZE_32  0x02
#define EFI_IFR_TYPE_NUM_SIZE_64  0x03
#define EFI_IFR_TYPE_BOOLEAN      0x04
#define EFI_IFR_TYPE_TIME         0x05
#define EFI_IFR_TYPE_DATE         0x06
#define EFI_IFR_TYPE_STRING       0x07
#define EFI_IFR_TYPE_OTHER        0x08
#define EFI_IFR_TYPE_UNDEFINED    0x09
#define EFI_IFR_TYPE_ACTION       0x0A
#define EFI_IFR_TYPE_BUFFER       0x0B
#define EFI_IFR_TYPE_REF          0x0C

#define EFI_IFR_OPTION_DEFAULT      0x10
#define EFI_IFR_OPTION_DEFAULT_MFG  0x20

typedef struct _EFI_IFR_GUID {
  EFI_IFR_OP_HEADER    Header;
  EFI_GUID             Guid;
  // Optional Data Follows
} EFI_IFR_GUID;

typedef struct _EFI_IFR_REFRESH_ID {
  EFI_IFR_OP_HEADER    Header;
  EFI_GUID             RefreshEventGroupId;
} EFI_IFR_REFRESH_ID;

typedef struct _EFI_IFR_DUP {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_DUP;

typedef struct _EFI_IFR_EQ_ID_ID {
  EFI_IFR_OP_HEADER    Header;
  EFI_QUESTION_ID      QuestionId1;
  EFI_QUESTION_ID      QuestionId2;
} EFI_IFR_EQ_ID_ID;

typedef struct _EFI_IFR_EQ_ID_VAL {
  EFI_IFR_OP_HEADER    Header;
  EFI_QUESTION_ID      QuestionId;
  UINT16               Value;
} EFI_IFR_EQ_ID_VAL;

typedef struct _EFI_IFR_EQ_ID_VAL_LIST {
  EFI_IFR_OP_HEADER    Header;
  EFI_QUESTION_ID      QuestionId;
  UINT16               ListLength;
  UINT16               ValueList[1];
} EFI_IFR_EQ_ID_VAL_LIST;

typedef struct _EFI_IFR_UINT8 {
  EFI_IFR_OP_HEADER    Header;
  UINT8                Value;
} EFI_IFR_UINT8;

typedef struct _EFI_IFR_UINT16 {
  EFI_IFR_OP_HEADER    Header;
  UINT16               Value;
} EFI_IFR_UINT16;

typedef struct _EFI_IFR_UINT32 {
  EFI_IFR_OP_HEADER    Header;
  UINT32               Value;
} EFI_IFR_UINT32;

typedef struct _EFI_IFR_UINT64 {
  EFI_IFR_OP_HEADER    Header;
  UINT64               Value;
} EFI_IFR_UINT64;

typedef struct _EFI_IFR_QUESTION_REF1 {
  EFI_IFR_OP_HEADER    Header;
  EFI_QUESTION_ID      QuestionId;
} EFI_IFR_QUESTION_REF1;

typedef struct _EFI_IFR_QUESTION_REF2 {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_QUESTION_REF2;

typedef struct _EFI_IFR_QUESTION_REF3 {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_QUESTION_REF3;

typedef struct _EFI_IFR_QUESTION_REF3_2 {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        DevicePath;
} EFI_IFR_QUESTION_REF3_2;

typedef struct _EFI_IFR_QUESTION_REF3_3 {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        DevicePath;
  EFI_GUID             Guid;
} EFI_IFR_QUESTION_REF3_3;

typedef struct _EFI_IFR_RULE_REF {
  EFI_IFR_OP_HEADER    Header;
  UINT8                RuleId;
} EFI_IFR_RULE_REF;

typedef struct _EFI_IFR_STRING_REF1 {
  EFI_IFR_OP_HEADER    Header;
  EFI_STRING_ID        StringId;
} EFI_IFR_STRING_REF1;

typedef struct _EFI_IFR_STRING_REF2 {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_STRING_REF2;

typedef struct _EFI_IFR_THIS {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_THIS;

typedef struct _EFI_IFR_TRUE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TRUE;

typedef struct _EFI_IFR_FALSE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_FALSE;

typedef struct _EFI_IFR_ONE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_ONE;

typedef struct _EFI_IFR_ONES {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_ONES;

typedef struct _EFI_IFR_ZERO {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_ZERO;

typedef struct _EFI_IFR_UNDEFINED {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_UNDEFINED;

typedef struct _EFI_IFR_VERSION {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_VERSION;

typedef struct _EFI_IFR_LENGTH {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_LENGTH;

typedef struct _EFI_IFR_NOT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_NOT;

typedef struct _EFI_IFR_BITWISE_NOT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_BITWISE_NOT;

typedef struct _EFI_IFR_TO_BOOLEAN {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TO_BOOLEAN;

///
/// For EFI_IFR_TO_STRING, when converting from
/// unsigned integers, these flags control the format:
/// 0 = unsigned decimal.
/// 1 = signed decimal.
/// 2 = hexadecimal (lower-case alpha).
/// 3 = hexadecimal (upper-case alpha).
///@{
#define EFI_IFR_STRING_UNSIGNED_DEC   0
#define EFI_IFR_STRING_SIGNED_DEC     1
#define EFI_IFR_STRING_LOWERCASE_HEX  2
#define EFI_IFR_STRING_UPPERCASE_HEX  3
///@}

///
/// When converting from a buffer, these flags control the format:
/// 0 = ASCII.
/// 8 = Unicode.
///@{
#define EFI_IFR_STRING_ASCII    0
#define EFI_IFR_STRING_UNICODE  8
///@}

typedef struct _EFI_IFR_TO_STRING {
  EFI_IFR_OP_HEADER    Header;
  UINT8                Format;
} EFI_IFR_TO_STRING;

typedef struct _EFI_IFR_TO_UINT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TO_UINT;

typedef struct _EFI_IFR_TO_UPPER {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TO_UPPER;

typedef struct _EFI_IFR_TO_LOWER {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TO_LOWER;

typedef struct _EFI_IFR_ADD {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_ADD;

typedef struct _EFI_IFR_AND {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_AND;

typedef struct _EFI_IFR_BITWISE_AND {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_BITWISE_AND;

typedef struct _EFI_IFR_BITWISE_OR {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_BITWISE_OR;

typedef struct _EFI_IFR_CATENATE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_CATENATE;

typedef struct _EFI_IFR_DIVIDE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_DIVIDE;

typedef struct _EFI_IFR_EQUAL {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_EQUAL;

typedef struct _EFI_IFR_GREATER_EQUAL {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_GREATER_EQUAL;

typedef struct _EFI_IFR_GREATER_THAN {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_GREATER_THAN;

typedef struct _EFI_IFR_LESS_EQUAL {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_LESS_EQUAL;

typedef struct _EFI_IFR_LESS_THAN {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_LESS_THAN;

typedef struct _EFI_IFR_MATCH {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MATCH;

typedef struct _EFI_IFR_MATCH2 {
  EFI_IFR_OP_HEADER    Header;
  EFI_GUID             SyntaxType;
} EFI_IFR_MATCH2;

typedef struct _EFI_IFR_MULTIPLY {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MULTIPLY;

typedef struct _EFI_IFR_MODULO {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MODULO;

typedef struct _EFI_IFR_NOT_EQUAL {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_NOT_EQUAL;

typedef struct _EFI_IFR_OR {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_OR;

typedef struct _EFI_IFR_SHIFT_LEFT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_SHIFT_LEFT;

typedef struct _EFI_IFR_SHIFT_RIGHT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_SHIFT_RIGHT;

typedef struct _EFI_IFR_SUBTRACT {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_SUBTRACT;

typedef struct _EFI_IFR_CONDITIONAL {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_CONDITIONAL;

//
// Flags governing the matching criteria of EFI_IFR_FIND
//
#define EFI_IFR_FF_CASE_SENSITIVE    0x00
#define EFI_IFR_FF_CASE_INSENSITIVE  0x01

typedef struct _EFI_IFR_FIND {
  EFI_IFR_OP_HEADER    Header;
  UINT8                Format;
} EFI_IFR_FIND;

typedef struct _EFI_IFR_MID {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MID;

typedef struct _EFI_IFR_TOKEN {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_TOKEN;

//
// Flags specifying whether to find the first matching string
// or the first non-matching string.
//
#define EFI_IFR_FLAGS_FIRST_MATCHING      0x00
#define EFI_IFR_FLAGS_FIRST_NON_MATCHING  0x01

typedef struct _EFI_IFR_SPAN {
  EFI_IFR_OP_HEADER    Header;
  UINT8                Flags;
} EFI_IFR_SPAN;

typedef struct _EFI_IFR_SECURITY {
  ///
  /// Standard opcode header, where Header.Op = EFI_IFR_SECURITY_OP.
  ///
  EFI_IFR_OP_HEADER    Header;
  ///
  /// Security permission level.
  ///
  EFI_GUID             Permissions;
} EFI_IFR_SECURITY;

typedef struct _EFI_IFR_FORM_MAP_METHOD {
  ///
  /// The string identifier which provides the human-readable name of
  /// the configuration method for this standards map form.
  ///
  EFI_STRING_ID    MethodTitle;
  ///
  /// Identifier which uniquely specifies the configuration methods
  /// associated with this standards map form.
  ///
  EFI_GUID         MethodIdentifier;
} EFI_IFR_FORM_MAP_METHOD;

typedef struct _EFI_IFR_FORM_MAP {
  ///
  /// The sequence that defines the type of opcode as well as the length
  /// of the opcode being defined. Header.OpCode = EFI_IFR_FORM_MAP_OP.
  ///
  EFI_IFR_OP_HEADER    Header;
  ///
  /// The unique identifier for this particular form.
  ///
  EFI_FORM_ID          FormId;
  ///
  /// One or more configuration method's name and unique identifier.
  ///
  // EFI_IFR_FORM_MAP_METHOD  Methods[];
} EFI_IFR_FORM_MAP;

typedef struct _EFI_IFR_SET {
  ///
  /// The sequence that defines the type of opcode as well as the length
  /// of the opcode being defined. Header.OpCode = EFI_IFR_SET_OP.
  ///
  EFI_IFR_OP_HEADER    Header;
  ///
  /// Specifies the identifier of a previously declared variable store to
  /// use when storing the question's value.
  ///
  EFI_VARSTORE_ID      VarStoreId;
  union {
    ///
    /// A 16-bit Buffer Storage offset.
    ///
    EFI_STRING_ID    VarName;
    ///
    /// A Name Value or EFI Variable name (VarName).
    ///
    UINT16           VarOffset;
  }                  VarStoreInfo;
  ///
  /// Specifies the type used for storage.
  ///
  UINT8    VarStoreType;
} EFI_IFR_SET;

typedef struct _EFI_IFR_GET {
  ///
  /// The sequence that defines the type of opcode as well as the length
  /// of the opcode being defined. Header.OpCode = EFI_IFR_GET_OP.
  ///
  EFI_IFR_OP_HEADER    Header;
  ///
  /// Specifies the identifier of a previously declared variable store to
  /// use when retrieving the value.
  ///
  EFI_VARSTORE_ID      VarStoreId;
  union {
    ///
    /// A 16-bit Buffer Storage offset.
    ///
    EFI_STRING_ID    VarName;
    ///
    /// A Name Value or EFI Variable name (VarName).
    ///
    UINT16           VarOffset;
  }                  VarStoreInfo;
  ///
  /// Specifies the type used for storage.
  ///
  UINT8    VarStoreType;
} EFI_IFR_GET;

typedef struct _EFI_IFR_READ {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_READ;

typedef struct _EFI_IFR_WRITE {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_WRITE;

typedef struct _EFI_IFR_MAP {
  EFI_IFR_OP_HEADER    Header;
} EFI_IFR_MAP;
//
// Definitions for Keyboard Package
// Releated definitions are in Section of EFI_HII_DATABASE_PROTOCOL
//

///
/// Each enumeration values maps a physical key on a keyboard.
///
typedef enum {
  EfiKeyLCtrl,
  EfiKeyA0,
  EfiKeyLAlt,
  EfiKeySpaceBar,
  EfiKeyA2,
  EfiKeyA3,
  EfiKeyA4,
  EfiKeyRCtrl,
  EfiKeyLeftArrow,
  EfiKeyDownArrow,
  EfiKeyRightArrow,
  EfiKeyZero,
  EfiKeyPeriod,
  EfiKeyEnter,
  EfiKeyLShift,
  EfiKeyB0,
  EfiKeyB1,
  EfiKeyB2,
  EfiKeyB3,
  EfiKeyB4,
  EfiKeyB5,
  EfiKeyB6,
  EfiKeyB7,
  EfiKeyB8,
  EfiKeyB9,
  EfiKeyB10,
  EfiKeyRShift,
  EfiKeyUpArrow,
  EfiKeyOne,
  EfiKeyTwo,
  EfiKeyThree,
  EfiKeyCapsLock,
  EfiKeyC1,
  EfiKeyC2,
  EfiKeyC3,
  EfiKeyC4,
  EfiKeyC5,
  EfiKeyC6,
  EfiKeyC7,
  EfiKeyC8,
  EfiKeyC9,
  EfiKeyC10,
  EfiKeyC11,
  EfiKeyC12,
  EfiKeyFour,
  EfiKeyFive,
  EfiKeySix,
  EfiKeyPlus,
  EfiKeyTab,
  EfiKeyD1,
  EfiKeyD2,
  EfiKeyD3,
  EfiKeyD4,
  EfiKeyD5,
  EfiKeyD6,
  EfiKeyD7,
  EfiKeyD8,
  EfiKeyD9,
  EfiKeyD10,
  EfiKeyD11,
  EfiKeyD12,
  EfiKeyD13,
  EfiKeyDel,
  EfiKeyEnd,
  EfiKeyPgDn,
  EfiKeySeven,
  EfiKeyEight,
  EfiKeyNine,
  EfiKeyE0,
  EfiKeyE1,
  EfiKeyE2,
  EfiKeyE3,
  EfiKeyE4,
  EfiKeyE5,
  EfiKeyE6,
  EfiKeyE7,
  EfiKeyE8,
  EfiKeyE9,
  EfiKeyE10,
  EfiKeyE11,
  EfiKeyE12,
  EfiKeyBackSpace,
  EfiKeyIns,
  EfiKeyHome,
  EfiKeyPgUp,
  EfiKeyNLck,
  EfiKeySlash,
  EfiKeyAsterisk,
  EfiKeyMinus,
  EfiKeyEsc,
  EfiKeyF1,
  EfiKeyF2,
  EfiKeyF3,
  EfiKeyF4,
  EfiKeyF5,
  EfiKeyF6,
  EfiKeyF7,
  EfiKeyF8,
  EfiKeyF9,
  EfiKeyF10,
  EfiKeyF11,
  EfiKeyF12,
  EfiKeyPrint,
  EfiKeySLck,
  EfiKeyPause,
  EfiKeyIntl0,
  EfiKeyIntl1,
  EfiKeyIntl2,
  EfiKeyIntl3,
  EfiKeyIntl4,
  EfiKeyIntl5,
  EfiKeyIntl6,
  EfiKeyIntl7,
  EfiKeyIntl8,
  EfiKeyIntl9
} EFI_KEY;

typedef struct {
  ///
  /// Used to describe a physical key on a keyboard.
  ///
  EFI_KEY    Key;
  ///
  /// Unicode character code for the Key.
  ///
  CHAR16     Unicode;
  ///
  /// Unicode character code for the key with the shift key being held down.
  ///
  CHAR16     ShiftedUnicode;
  ///
  /// Unicode character code for the key with the Alt-GR being held down.
  ///
  CHAR16     AltGrUnicode;
  ///
  /// Unicode character code for the key with the Alt-GR and shift keys being held down.
  ///
  CHAR16     ShiftedAltGrUnicode;
  ///
  /// Modifier keys are defined to allow for special functionality that is not necessarily
  /// accomplished by a printable character. Many of these modifier keys are flags to toggle
  /// certain state bits on and off inside of a keyboard driver.
  ///
  UINT16     Modifier;
  UINT16     AffectedAttribute;
} EFI_KEY_DESCRIPTOR;

///
/// A key which is affected by all the standard shift modifiers.
/// Most keys would be expected to have this bit active.
///
#define EFI_AFFECTED_BY_STANDARD_SHIFT  0x0001

///
/// This key is affected by the caps lock so that if a keyboard driver
/// would need to disambiguate between a key which had a "1" defined
/// versus an "a" character.  Having this bit turned on would tell
/// the keyboard driver to use the appropriate shifted state or not.
///
#define EFI_AFFECTED_BY_CAPS_LOCK  0x0002

///
/// Similar to the case of CAPS lock, if this bit is active, the key
/// is affected by the num lock being turned on.
///
#define EFI_AFFECTED_BY_NUM_LOCK  0x0004

typedef struct {
  UINT16      LayoutLength;
  EFI_GUID    Guid;
  UINT32      LayoutDescriptorStringOffset;
  UINT8       DescriptorCount;
  // EFI_KEY_DESCRIPTOR    Descriptors[];
} EFI_HII_KEYBOARD_LAYOUT;

typedef struct {
  EFI_HII_PACKAGE_HEADER    Header;
  UINT16                    LayoutCount;
  // EFI_HII_KEYBOARD_LAYOUT Layout[];
} EFI_HII_KEYBOARD_PACKAGE_HDR;

//
// Modifier values
//
#define EFI_NULL_MODIFIER                 0x0000
#define EFI_LEFT_CONTROL_MODIFIER         0x0001
#define EFI_RIGHT_CONTROL_MODIFIER        0x0002
#define EFI_LEFT_ALT_MODIFIER             0x0003
#define EFI_RIGHT_ALT_MODIFIER            0x0004
#define EFI_ALT_GR_MODIFIER               0x0005
#define EFI_INSERT_MODIFIER               0x0006
#define EFI_DELETE_MODIFIER               0x0007
#define EFI_PAGE_DOWN_MODIFIER            0x0008
#define EFI_PAGE_UP_MODIFIER              0x0009
#define EFI_HOME_MODIFIER                 0x000A
#define EFI_END_MODIFIER                  0x000B
#define EFI_LEFT_SHIFT_MODIFIER           0x000C
#define EFI_RIGHT_SHIFT_MODIFIER          0x000D
#define EFI_CAPS_LOCK_MODIFIER            0x000E
#define EFI_NUM_LOCK_MODIFIER             0x000F
#define EFI_LEFT_ARROW_MODIFIER           0x0010
#define EFI_RIGHT_ARROW_MODIFIER          0x0011
#define EFI_DOWN_ARROW_MODIFIER           0x0012
#define EFI_UP_ARROW_MODIFIER             0x0013
#define EFI_NS_KEY_MODIFIER               0x0014
#define EFI_NS_KEY_DEPENDENCY_MODIFIER    0x0015
#define EFI_FUNCTION_KEY_ONE_MODIFIER     0x0016
#define EFI_FUNCTION_KEY_TWO_MODIFIER     0x0017
#define EFI_FUNCTION_KEY_THREE_MODIFIER   0x0018
#define EFI_FUNCTION_KEY_FOUR_MODIFIER    0x0019
#define EFI_FUNCTION_KEY_FIVE_MODIFIER    0x001A
#define EFI_FUNCTION_KEY_SIX_MODIFIER     0x001B
#define EFI_FUNCTION_KEY_SEVEN_MODIFIER   0x001C
#define EFI_FUNCTION_KEY_EIGHT_MODIFIER   0x001D
#define EFI_FUNCTION_KEY_NINE_MODIFIER    0x001E
#define EFI_FUNCTION_KEY_TEN_MODIFIER     0x001F
#define EFI_FUNCTION_KEY_ELEVEN_MODIFIER  0x0020
#define EFI_FUNCTION_KEY_TWELVE_MODIFIER  0x0021

//
// Keys that have multiple control functions based on modifier
// settings are handled in the keyboard driver implementation.
// For instance, PRINT_KEY might have a modifier held down and
// is still a nonprinting character, but might have an alternate
// control function like SYSREQUEST
//
#define EFI_PRINT_MODIFIER        0x0022
#define EFI_SYS_REQUEST_MODIFIER  0x0023
#define EFI_SCROLL_LOCK_MODIFIER  0x0024
#define EFI_PAUSE_MODIFIER        0x0025
#define EFI_BREAK_MODIFIER        0x0026

#define EFI_LEFT_LOGO_MODIFIER   0x0027
#define EFI_RIGHT_LOGO_MODIFIER  0x0028
#define EFI_MENU_MODIFIER        0x0029

///
/// Animation IFR opcode
///
typedef struct _EFI_IFR_ANIMATION {
  ///
  /// Standard opcode header, where Header.OpCode is
  /// EFI_IFR_ANIMATION_OP.
  ///
  EFI_IFR_OP_HEADER    Header;
  ///
  /// Animation identifier in the HII database.
  ///
  EFI_ANIMATION_ID     Id;
} EFI_IFR_ANIMATION;

///
/// HII animation package header.
///
typedef struct _EFI_HII_ANIMATION_PACKAGE_HDR {
  ///
  /// Standard package header, where Header.Type = EFI_HII_PACKAGE_ANIMATIONS.
  ///
  EFI_HII_PACKAGE_HEADER    Header;
  ///
  /// Offset, relative to this header, of the animation information. If
  /// this is zero, then there are no animation sequences in the package.
  ///
  UINT32                    AnimationInfoOffset;
} EFI_HII_ANIMATION_PACKAGE_HDR;

///
/// Animation information is encoded as a series of blocks,
/// with each block prefixed by a single byte header EFI_HII_ANIMATION_BLOCK.
///
typedef struct _EFI_HII_ANIMATION_BLOCK {
  UINT8    BlockType;
  // UINT8  BlockBody[];
} EFI_HII_ANIMATION_BLOCK;

///
/// Animation block types.
///
#define EFI_HII_AIBT_END                  0x00
#define EFI_HII_AIBT_OVERLAY_IMAGES       0x10
#define EFI_HII_AIBT_CLEAR_IMAGES         0x11
#define EFI_HII_AIBT_RESTORE_SCRN         0x12
#define EFI_HII_AIBT_OVERLAY_IMAGES_LOOP  0x18
#define EFI_HII_AIBT_CLEAR_IMAGES_LOOP    0x19
#define EFI_HII_AIBT_RESTORE_SCRN_LOOP    0x1A
#define EFI_HII_AIBT_DUPLICATE            0x20
#define EFI_HII_AIBT_SKIP2                0x21
#define EFI_HII_AIBT_SKIP1                0x22
#define EFI_HII_AIBT_EXT1                 0x30
#define EFI_HII_AIBT_EXT2                 0x31
#define EFI_HII_AIBT_EXT4                 0x32

///
/// Extended block headers used for variable sized animation records
/// which need an explicit length.
///

typedef struct _EFI_HII_AIBT_EXT1_BLOCK  {
  ///
  /// Standard animation header, where Header.BlockType = EFI_HII_AIBT_EXT1.
  ///
  EFI_HII_ANIMATION_BLOCK    Header;
  ///
  /// The block type.
  ///
  UINT8                      BlockType2;
  ///
  /// Size of the animation block, in bytes, including the animation block header.
  ///
  UINT8                      Length;
} EFI_HII_AIBT_EXT1_BLOCK;

typedef struct _EFI_HII_AIBT_EXT2_BLOCK {
  ///
  /// Standard animation header, where Header.BlockType = EFI_HII_AIBT_EXT2.
  ///
  EFI_HII_ANIMATION_BLOCK    Header;
  ///
  /// The block type
  ///
  UINT8                      BlockType2;
  ///
  /// Size of the animation block, in bytes, including the animation block header.
  ///
  UINT16                     Length;
} EFI_HII_AIBT_EXT2_BLOCK;

typedef struct _EFI_HII_AIBT_EXT4_BLOCK {
  ///
  /// Standard animation header, where Header.BlockType = EFI_HII_AIBT_EXT4.
  ///
  EFI_HII_ANIMATION_BLOCK    Header;
  ///
  /// The block type
  ///
  UINT8                      BlockType2;
  ///
  /// Size of the animation block, in bytes, including the animation block header.
  ///
  UINT32                     Length;
} EFI_HII_AIBT_EXT4_BLOCK;

typedef struct _EFI_HII_ANIMATION_CELL {
  ///
  /// The X offset from the upper left hand corner of the logical
  /// window to position the indexed image.
  ///
  UINT16          OffsetX;
  ///
  /// The Y offset from the upper left hand corner of the logical
  /// window to position the indexed image.
  ///
  UINT16          OffsetY;
  ///
  /// The image to display at the specified offset from the upper left
  /// hand corner of the logical window.
  ///
  EFI_IMAGE_ID    ImageId;
  ///
  /// The number of milliseconds to delay after displaying the indexed
  /// image and before continuing on to the next linked image.  If value
  /// is zero, no delay.
  ///
  UINT16          Delay;
} EFI_HII_ANIMATION_CELL;

///
/// An animation block to describe an animation sequence that does not cycle, and
/// where one image is simply displayed over the previous image.
///
typedef struct _EFI_HII_AIBT_OVERLAY_IMAGES_BLOCK {
  ///
  /// This is image that is to be reference by the image protocols, if the
  /// animation function is not supported or disabled. This image can
  /// be one particular image from the animation sequence (if any one
  /// of the animation frames has a complete image) or an alternate
  /// image that can be displayed alone. If the value is zero, no image
  /// is displayed.
  ///
  EFI_IMAGE_ID              DftImageId;
  ///
  /// The overall width of the set of images (logical window width).
  ///
  UINT16                    Width;
  ///
  /// The overall height of the set of images (logical window height).
  ///
  UINT16                    Height;
  ///
  /// The number of EFI_HII_ANIMATION_CELL contained in the
  /// animation sequence.
  ///
  UINT16                    CellCount;
  ///
  /// An array of CellCount animation cells.
  ///
  EFI_HII_ANIMATION_CELL    AnimationCell[1];
} EFI_HII_AIBT_OVERLAY_IMAGES_BLOCK;

///
/// An animation block to describe an animation sequence that does not cycle,
/// and where the logical window is cleared to the specified color before
/// the next image is displayed.
///
typedef struct _EFI_HII_AIBT_CLEAR_IMAGES_BLOCK {
  ///
  /// This is image that is to be reference by the image protocols, if the
  /// animation function is not supported or disabled. This image can
  /// be one particular image from the animation sequence (if any one
  /// of the animation frames has a complete image) or an alternate
  /// image that can be displayed alone. If the value is zero, no image
  /// is displayed.
  ///
  EFI_IMAGE_ID              DftImageId;
  ///
  /// The overall width of the set of images (logical window width).
  ///
  UINT16                    Width;
  ///
  /// The overall height of the set of images (logical window height).
  ///
  UINT16                    Height;
  ///
  /// The number of EFI_HII_ANIMATION_CELL contained in the
  /// animation sequence.
  ///
  UINT16                    CellCount;
  ///
  /// The color to clear the logical window to before displaying the
  /// indexed image.
  ///
  EFI_HII_RGB_PIXEL         BackgndColor;
  ///
  /// An array of CellCount animation cells.
  ///
  EFI_HII_ANIMATION_CELL    AnimationCell[1];
} EFI_HII_AIBT_CLEAR_IMAGES_BLOCK;

///
/// An animation block to describe an animation sequence that does not cycle,
/// and where the screen is restored to the original state before the next
/// image is displayed.
///
typedef struct _EFI_HII_AIBT_RESTORE_SCRN_BLOCK {
  ///
  /// This is image that is to be reference by the image protocols, if the
  /// animation function is not supported or disabled. This image can
  /// be one particular image from the animation sequence (if any one
  /// of the animation frames has a complete image) or an alternate
  /// image that can be displayed alone. If the value is zero, no image
  /// is displayed.
  ///
  EFI_IMAGE_ID              DftImageId;
  ///
  /// The overall width of the set of images (logical window width).
  ///
  UINT16                    Width;
  ///
  /// The overall height of the set of images (logical window height).
  ///
  UINT16                    Height;
  ///
  /// The number of EFI_HII_ANIMATION_CELL contained in the
  /// animation sequence.
  ///
  UINT16                    CellCount;
  ///
  /// An array of CellCount animation cells.
  ///
  EFI_HII_ANIMATION_CELL    AnimationCell[1];
} EFI_HII_AIBT_RESTORE_SCRN_BLOCK;

///
/// An animation block to describe an animation sequence that continuously cycles,
/// and where one image is simply displayed over the previous image.
///
typedef EFI_HII_AIBT_OVERLAY_IMAGES_BLOCK EFI_HII_AIBT_OVERLAY_IMAGES_LOOP_BLOCK;

///
/// An animation block to describe an animation sequence that continuously cycles,
/// and where the logical window is cleared to the specified color before
/// the next image is displayed.
///
typedef EFI_HII_AIBT_CLEAR_IMAGES_BLOCK EFI_HII_AIBT_CLEAR_IMAGES_LOOP_BLOCK;

///
/// An animation block to describe an animation sequence that continuously cycles,
/// and where the screen is restored to the original state before
/// the next image is displayed.
///
typedef EFI_HII_AIBT_RESTORE_SCRN_BLOCK EFI_HII_AIBT_RESTORE_SCRN_LOOP_BLOCK;

///
/// Assigns a new character value to a previously defined animation sequence.
///
typedef struct _EFI_HII_AIBT_DUPLICATE_BLOCK {
  ///
  /// The previously defined animation ID with the exact same
  /// animation information.
  ///
  EFI_ANIMATION_ID    AnimationId;
} EFI_HII_AIBT_DUPLICATE_BLOCK;

///
/// Skips animation IDs.
///
typedef struct _EFI_HII_AIBT_SKIP1_BLOCK {
  ///
  /// The unsigned 8-bit value to add to AnimationIdCurrent.
  ///
  UINT8    SkipCount;
} EFI_HII_AIBT_SKIP1_BLOCK;

///
/// Skips animation IDs.
///
typedef struct _EFI_HII_AIBT_SKIP2_BLOCK {
  ///
  /// The unsigned 16-bit value to add to AnimationIdCurrent.
  ///
  UINT16    SkipCount;
} EFI_HII_AIBT_SKIP2_BLOCK;

#pragma pack()

///
/// References to string tokens must use this macro to enable scanning for
/// token usages.
///
///
/// STRING_TOKEN is not defined in UEFI specification. But it is placed
/// here for the easy access by C files and VFR source files.
///
#define STRING_TOKEN(t)  t

///
/// IMAGE_TOKEN is not defined in UEFI specification. But it is placed
/// here for the easy access by C files and VFR source files.
///
#define IMAGE_TOKEN(t)  t

#endif