summaryrefslogtreecommitdiffstats
path: root/vendor/r-efi/src/hii.rs
blob: 340176b62fe6828f12ea71798a76e9f60abdea65 (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
//! Human Interface Infrastructure (HII)
//!
//! This module contains bindings and definitions copied from Section 33.3 of
//! the UEFI spec, as well as the core HII related definitions.

//
// Core HII Definitions
//

// This is the exception to the rule. It's defined in 34.8 (HII_DATABASE
// protocol), not 33.3, but it's used throughout the HII protocols, so it makes
// sense to be defined at the base.
pub type Handle = *mut core::ffi::c_void;

//
// 33.3.1 Package Lists and Package Headers
//

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct PackageHeader<const N: usize = 0> {
    pub length: [u8; 3],
    pub r#type: u8,
    pub data: [u8; N],
}

pub const PACKAGE_TYPE_ALL: u8 = 0x00;
pub const PACKAGE_TYPE_GUID: u8 = 0x01;
pub const PACKAGE_FORMS: u8 = 0x02;
pub const PACKAGE_STRINGS: u8 = 0x04;
pub const PACKAGE_FONTS: u8 = 0x05;
pub const PACKAGE_IMAGES: u8 = 0x06;
pub const PACKAGE_SIMPLE_FONTS: u8 = 0x07;
pub const PACKAGE_DEVICE_PATH: u8 = 0x08;
pub const PACKAGE_KEYBOARD_LAYOUT: u8 = 0x09;
pub const PACKAGE_ANIMATIONS: u8 = 0x0A;
pub const PACKAGE_END: u8 = 0xDF;
pub const PACKAGE_TYPE_SYSTEM_BEGIN: u8 = 0xE0;
pub const PACKAGE_TYPE_SYSTEM_END: u8 = 0xFF;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct PackageListHeader {
    pub package_list_guid: crate::base::Guid,
    pub package_length: u32,
}

//
// 33.3.3 Font Package
//

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct FontPackageHdr<const N: usize = 0> {
    pub header: PackageHeader,
    pub hdr_size: u32,
    pub glyph_block_offset: u32,
    pub cell: GlyphInfo,
    pub font_style: FontStyle,
    pub font_family: [crate::base::Char16; N],
}

pub type FontStyle = u32;

pub const FONT_STYLE_NORMAL: FontStyle = 0x00000000;
pub const FONT_STYLE_BOLD: FontStyle = 0x00000001;
pub const FONT_STYLE_ITALIC: FontStyle = 0x00000002;
pub const FONT_STYLE_EMBOSS: FontStyle = 0x00010000;
pub const FONT_STYLE_OUTLINE: FontStyle = 0x00020000;
pub const FONT_STYLE_SHADOW: FontStyle = 0x00040000;
pub const FONT_STYLE_UNDERLINE: FontStyle = 0x00080000;
pub const FONT_STYLE_DBL_UNDER: FontStyle = 0x00100000;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GlyphBlock<const N: usize = 0> {
    pub block_type: u8,
    pub block_body: [u8; N],
}

pub const GIBT_END: u8 = 0x00;
pub const GIBT_GLYPH: u8 = 0x10;
pub const GIBT_GLYPHS: u8 = 0x11;
pub const GIBT_GLYPH_DEFAULT: u8 = 0x12;
pub const GIBT_GLYPHS_DEFAULT: u8 = 0x13;
pub const GIBT_GLYPH_VARIABILITY: u8 = 0x14;
pub const GIBT_DUPLICATE: u8 = 0x20;
pub const GIBT_SKIP2: u8 = 0x21;
pub const GIBT_SKIP1: u8 = 0x22;
pub const GIBT_DEFAULTS: u8 = 0x23;
pub const GIBT_EXT1: u8 = 0x30;
pub const GIBT_EXT2: u8 = 0x31;
pub const GIBT_EXT4: u8 = 0x32;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GlyphInfo {
    pub width: u16,
    pub height: u16,
    pub offset_x: i16,
    pub offset_y: i16,
    pub advance_x: i16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtDefaultsBlock {
    pub header: GlyphBlock,
    pub cell: GlyphInfo,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtDuplicateBlock {
    pub header: GlyphBlock,
    pub char_value: crate::base::Char16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GlyphGibtEndBlock {
    pub header: GlyphBlock,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtExt1Block {
    pub header: GlyphBlock,
    pub block_type_2: u8,
    pub length: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtExt2Block {
    pub header: GlyphBlock,
    pub block_type_2: u8,
    pub length: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtExt4Block {
    pub header: GlyphBlock,
    pub block_type_2: u8,
    pub length: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtGlyphBlock<const N: usize = 0> {
    pub header: GlyphBlock,
    pub cell: GlyphInfo,
    pub bitmap_data: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtGlyphsBlock<const N: usize = 0> {
    pub header: GlyphBlock,
    pub cell: GlyphInfo,
    pub count: u16,
    pub bitmap_data: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtGlyphDefaultBlock<const N: usize = 0> {
    pub header: GlyphBlock,
    pub bitmap_data: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtGlypshDefaultBlock<const N: usize = 0> {
    pub header: GlyphBlock,
    pub count: u16,
    pub bitmap_data: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtSkip2Block {
    pub header: GlyphBlock,
    pub skip_count: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtSkip1Block {
    pub header: GlyphBlock,
    pub skip_count: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct GibtVariabilityBlock<const N: usize = 0> {
    pub header: GlyphBlock,
    pub cell: GlyphInfo,
    pub glyph_pack_in_bits: u8,
    pub bitmap_data: [u8; N],
}

//
// 33.3.8 Forms Package
//

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct FormPackageHdr {
    pub header: PackageHeader,
    pub op_code_header: IfrOpHeader,
    // Op-Codes Follow...
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrOpHeader {
    pub op_code: u8,
    pub length_and_scope: u8, // Length:7, Scope:1
}

pub type QuestionId = u16;
pub type ImageId = u16;
pub type StringId = u16;
pub type FormId = u16;
pub type VarstoreId = u16;
pub type AnimationId = u16;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrQuestionHeader {
    pub header: IfrStatementHeader,
    pub question_id: QuestionId,
    pub var_store_id: VarstoreId,
    pub var_store_info: IfrQuestionHeaderVarstoreInfo,
    pub flags: u8,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub union IfrQuestionHeaderVarstoreInfo {
    pub var_name: StringId,
    pub var_offset: u16,
}

pub const IFR_FLAG_READ_ONLY: u8 = 0x01;
pub const IFR_FLAG_CALLBACK: u8 = 0x04;
pub const IFR_FLAG_RESET_REQUIRED: u8 = 0x10;
pub const IFR_FLAG_REST_STYLE: u8 = 0x20;
pub const IFR_FLAG_RECONNECT_REQUIRED: u8 = 0x40;
pub const IFR_FLAG_OPTIONS_ONLY: u8 = 0x80;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrStatementHeader {
    pub prompt: StringId,
    pub help: StringId,
}

pub const IFR_FORM_OP: u8 = 0x01;
pub const IFR_SUBTITLE_OP: u8 = 0x02;
pub const IFR_TEXT_OP: u8 = 0x03;
pub const IFR_IMAGE_OP: u8 = 0x04;
pub const IFR_ONE_OF_OP: u8 = 0x05;
pub const IFR_CHECKBOX_OP: u8 = 0x06;
pub const IFR_NUMERIC_OP: u8 = 0x07;
pub const IFR_PASSWORD_OP: u8 = 0x08;
pub const IFR_ONE_OF_OPTION_OP: u8 = 0x09;
pub const IFR_SUPPRESS_IF_OP: u8 = 0x0A;
pub const IFR_LOCKED_OP: u8 = 0x0B;
pub const IFR_ACTION_OP: u8 = 0x0C;
pub const IFR_RESET_BUTTON_OP: u8 = 0x0D;
pub const IFR_FORM_SET_OP: u8 = 0x0E;
pub const IFR_REF_OP: u8 = 0x0F;
pub const IFR_NO_SUBMIT_IF_OP: u8 = 0x10;
pub const IFR_INCONSISTENT_IF_OP: u8 = 0x11;
pub const IFR_EQ_ID_VAL_OP: u8 = 0x12;
pub const IFR_EQ_ID_ID_OP: u8 = 0x13;
pub const IFR_EQ_ID_VAL_LIST_OP: u8 = 0x14;
pub const IFR_AND_OP: u8 = 0x15;
pub const IFR_OR_OP: u8 = 0x16;
pub const IFR_NOT_OP: u8 = 0x17;
pub const IFR_RULE_OP: u8 = 0x18;
pub const IFR_GRAY_OUT_IF_OP: u8 = 0x19;
pub const IFR_DATE_OP: u8 = 0x1A;
pub const IFR_TIME_OP: u8 = 0x1B;
pub const IFR_STRING_OP: u8 = 0x1C;
pub const IFR_REFRESH_OP: u8 = 0x1D;
pub const IFR_DISABLE_IF_OP: u8 = 0x1E;
pub const IFR_ANIMATION_OP: u8 = 0x1F;
pub const IFR_TO_LOWER_OP: u8 = 0x20;
pub const IFR_TO_UPPER_OP: u8 = 0x21;
pub const IFR_MAP_OP: u8 = 0x22;
pub const IFR_ORDERED_LIST_OP: u8 = 0x23;
pub const IFR_VARSTORE_OP: u8 = 0x24;
pub const IFR_VARSTORE_NAME_VALUE_OP: u8 = 0x25;
pub const IFR_VARSTORE_EFI_OP: u8 = 0x26;
pub const IFR_VARSTORE_DEVICE_OP: u8 = 0x27;
pub const IFR_VERSION_OP: u8 = 0x28;
pub const IFR_END_OP: u8 = 0x29;
pub const IFR_MATCH_OP: u8 = 0x2A;
pub const IFR_GET_OP: u8 = 0x2B;
pub const IFR_SET_OP: u8 = 0x2C;
pub const IFR_READ_OP: u8 = 0x2D;
pub const IFR_WRITE_OP: u8 = 0x2E;
pub const IFR_EQUAL_OP: u8 = 0x2F;
pub const IFR_NOT_EQUAL_OP: u8 = 0x30;
pub const IFR_GREATER_THAN_OP: u8 = 0x31;
pub const IFR_GREATER_EQUAL_OP: u8 = 0x32;
pub const IFR_LESS_THAN_OP: u8 = 0x33;
pub const IFR_LESS_EQUAL_OP: u8 = 0x34;
pub const IFR_BITWISE_AND_OP: u8 = 0x35;
pub const IFR_BITWISE_OR_OP: u8 = 0x36;
pub const IFR_BITWISE_NOT_OP: u8 = 0x37;
pub const IFR_SHIFT_LEFT_OP: u8 = 0x38;
pub const IFR_SHIFT_RIGHT_OP: u8 = 0x39;
pub const IFR_ADD_OP: u8 = 0x3A;
pub const IFR_SUBTRACT_OP: u8 = 0x3B;
pub const IFR_MULTIPLY_OP: u8 = 0x3C;
pub const IFR_DIVIDE_OP: u8 = 0x3D;
pub const IFR_MODULO_OP: u8 = 0x3E;
pub const IFR_RULE_REF_OP: u8 = 0x3F;
pub const IFR_QUESTION_REF1_OP: u8 = 0x40;
pub const IFR_QUESTION_REF2_OP: u8 = 0x41;
pub const IFR_UINT8_OP: u8 = 0x42;
pub const IFR_UINT16_OP: u8 = 0x43;
pub const IFR_UINT32_OP: u8 = 0x44;
pub const IFR_UINT64_OP: u8 = 0x45;
pub const IFR_TRUE_OP: u8 = 0x46;
pub const IFR_FALSE_OP: u8 = 0x47;
pub const IFR_TO_UINT_OP: u8 = 0x48;
pub const IFR_TO_STRING_OP: u8 = 0x49;
pub const IFR_TO_BOOLEAN_OP: u8 = 0x4A;
pub const IFR_MID_OP: u8 = 0x4B;
pub const IFR_FIND_OP: u8 = 0x4C;
pub const IFR_TOKEN_OP: u8 = 0x4D;
pub const IFR_STRING_REF1_OP: u8 = 0x4E;
pub const IFR_STRING_REF2_OP: u8 = 0x4F;
pub const IFR_CONDITIONAL_OP: u8 = 0x50;
pub const IFR_QUESTION_REF3_OP: u8 = 0x51;
pub const IFR_ZERO_OP: u8 = 0x52;
pub const IFR_ONE_OP: u8 = 0x53;
pub const IFR_ONES_OP: u8 = 0x54;
pub const IFR_UNDEFINED_OP: u8 = 0x55;
pub const IFR_LENGTH_OP: u8 = 0x56;
pub const IFR_DUP_OP: u8 = 0x57;
pub const IFR_THIS_OP: u8 = 0x58;
pub const IFR_SPAN_OP: u8 = 0x59;
pub const IFR_VALUE_OP: u8 = 0x5A;
pub const IFR_DEFAULT_OP: u8 = 0x5B;
pub const IFR_DEFAULTSTORE_OP: u8 = 0x5C;
pub const IFR_FORM_MAP_OP: u8 = 0x5D;
pub const IFR_CATENATE_OP: u8 = 0x5E;
pub const IFR_GUID_OP: u8 = 0x5F;
pub const IFR_SECURITY_OP: u8 = 0x60;
pub const IFR_MODAL_TAG_OP: u8 = 0x61;
pub const IFR_REFRESH_ID_OP: u8 = 0x62;
pub const IFR_WARNING_IF_OP: u8 = 0x63;
pub const IFR_MATCH2_OP: u8 = 0x64;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrAction {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub question_config: StringId,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrAction1 {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrAnimation {
    pub header: IfrOpHeader,
    pub id: AnimationId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrAdd {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrAnd {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrBitwiseAnd {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrBitwiseNot {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrBitwiseOr {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrCatenate {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrCheckbox {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub flags: u8,
}

pub const IFR_CHECKBOX_DEFAULT: u8 = 0x01;
pub const IFR_CHECKBOX_DEFAULT_MFG: u8 = 0x02;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrConditional {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrDate {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub flags: u8,
}

pub const QF_DATE_YEAR_SUPPRESS: u8 = 0x01;
pub const QF_DATE_MONTH_SUPPRESS: u8 = 0x02;
pub const QF_DATE_DAY_SUPPRESS: u8 = 0x04;
pub const QF_DATE_STORAGE: u8 = 0x30;

pub const QF_DATE_STORAGE_NORMAL: u8 = 0x00;
pub const QF_DATE_STORAGE_TIME: u8 = 0x10;
pub const QF_DATE_STORAGE_WAKEUP: u8 = 0x20;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrDefault {
    pub header: IfrOpHeader,
    pub default_id: u16,
    pub r#type: u8,
    pub value: IfrTypeValue,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrDefault2 {
    pub header: IfrOpHeader,
    pub default_id: u16,
    pub r#type: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrDefaultstore {
    pub header: IfrOpHeader,
    pub default_name: StringId,
    pub default_id: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrDisableIf {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrDivide {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrDup {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrEnd {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrEqual {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrEqIdId {
    pub header: IfrOpHeader,
    pub question_id_1: QuestionId,
    pub question_id_2: QuestionId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrEqIdValList<const N: usize = 0> {
    pub header: IfrOpHeader,
    pub question_id: QuestionId,
    pub list_length: u16,
    pub value_list: [u16; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrEqIdVal {
    pub header: IfrOpHeader,
    pub question_id: QuestionId,
    pub value: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrFalse {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrFind {
    pub header: IfrOpHeader,
    pub format: u8,
}

pub const IFR_FF_CASE_SENSITIVE: u8 = 0x00;
pub const IFR_FF_CASE_INSENSITIVE: u8 = 0x01;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrForm {
    pub header: IfrOpHeader,
    pub form_id: FormId,
    pub form_title: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrFormMapMethod {
    pub method_title: StringId,
    pub method_identifier: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrFormMap<const N: usize = 0> {
    pub header: IfrOpHeader,
    pub form_id: FormId,
    pub methods: [IfrFormMapMethod; N],
}

pub const STANDARD_FORM_GUID: crate::base::Guid = crate::base::Guid::from_fields(
    0x3bd2f4ec,
    0xe524,
    0x46e4,
    0xa9,
    0xd8,
    &[0x51, 0x01, 0x17, 0x42, 0x55, 0x62],
);

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrFormSet<const N: usize = 0> {
    pub header: IfrOpHeader,
    pub guid: crate::base::Guid,
    pub form_set_title: StringId,
    pub help: StringId,
    pub flags: u8,
    pub class_guid: [crate::base::Guid; N],
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrGet {
    pub header: IfrOpHeader,
    pub var_store_id: VarstoreId,
    pub var_store_info: IfrGetVarStoreInfo,
    pub var_store_type: u8,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub union IfrGetVarStoreInfo {
    pub var_name: StringId,
    pub var_offset: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrGrayOutIf {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrGreaterEqual {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrGreaterThan {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrGuid {
    pub header: IfrOpHeader,
    pub guid: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrImage {
    pub id: ImageId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrInconsistentIf {
    pub header: IfrOpHeader,
    pub error: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrLength {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrLessEqual {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrLessThan {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrLocked {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrMap {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrMatch {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrMid {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrModalTag {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrModulo {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrMultiply {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNot {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNotEqual {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNoSubmitIf {
    pub header: IfrOpHeader,
    pub error: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNumericDataU8 {
    pub min_value: u8,
    pub max_value: u8,
    pub step: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNumericDataU16 {
    pub min_value: u16,
    pub max_value: u16,
    pub step: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNumericDataU32 {
    pub min_value: u32,
    pub max_value: u32,
    pub step: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrNumericDataU64 {
    pub min_value: u64,
    pub max_value: u64,
    pub step: u64,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub union IfrNumericData {
    pub r#u8: IfrNumericDataU8,
    pub r#u16: IfrNumericDataU16,
    pub r#u32: IfrNumericDataU32,
    pub r#u64: IfrNumericDataU64,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrNumeric {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub flags: u8,
    pub data: IfrNumericData,
}

pub const IFR_NUMERIC_SIZE: u8 = 0x03;
pub const IFR_NUMERIC_SIZE_1: u8 = 0x00;
pub const IFR_NUMERIC_SIZE_2: u8 = 0x01;
pub const IFR_NUMERIC_SIZE_4: u8 = 0x02;
pub const IFR_NUMERIC_SIZE_8: u8 = 0x03;

pub const IFR_DISPLAY: u8 = 0x30;
pub const IFR_DISPLAY_INT_DEC: u8 = 0x00;
pub const IFR_DISPLAY_UINT_DEC: u8 = 0x10;
pub const IFR_DISPLAY_UINT_HEX: u8 = 0x20;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrOne {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrOnes {
    pub header: IfrOpHeader,
}

type IfrOneOfData = IfrNumericData;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrOneOf {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub flags: u8,
    pub data: IfrOneOfData,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrOneOfOption {
    pub header: IfrOpHeader,
    pub option: StringId,
    pub flags: u8,
    pub r#type: u8,
    pub value: IfrTypeValue,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub union IfrTypeValue<const N: usize = 0> {
    pub r#u8: u8,
    pub r#u16: u16,
    pub r#u32: u32,
    pub r#u64: u64,
    pub b: crate::base::Boolean,
    pub time: Time,
    pub date: Date,
    pub string: StringId,
    pub r#ref: Ref,
    pub buffer: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Time {
    pub hour: u8,
    pub minute: u8,
    pub second: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Date {
    pub year: u16,
    pub month: u8,
    pub day: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Ref {
    pub question_id: QuestionId,
    pub form_id: FormId,
    pub form_set_guid: crate::base::Guid,
    pub device_path: StringId,
}

pub const IFR_TYPE_NUM_SIZE_8: u8 = 0x00;
pub const IFR_TYPE_NUM_SIZE_16: u8 = 0x01;
pub const IFR_TYPE_NUM_SIZE_32: u8 = 0x02;
pub const IFR_TYPE_NUM_SIZE_64: u8 = 0x03;
pub const IFR_TYPE_BOOLEAN: u8 = 0x04;
pub const IFR_TYPE_TIME: u8 = 0x05;
pub const IFR_TYPE_DATE: u8 = 0x06;
pub const IFR_TYPE_STRING: u8 = 0x07;
pub const IFR_TYPE_OTHER: u8 = 0x08;
pub const IFR_TYPE_UNDEFINED: u8 = 0x09;
pub const IFR_TYPE_ACTION: u8 = 0x0A;
pub const IFR_TYPE_BUFFER: u8 = 0x0B;
pub const IFR_TYPE_REF: u8 = 0x0C;

pub const IFR_OPTION_DEFAULT: u8 = 0x10;
pub const IFR_OPTION_DEFAULT_MFG: u8 = 0x20;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrOr {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrOrderedList {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub max_containers: u8,
    pub flags: u8,
}

pub const IFR_UNIQUE_SET: u8 = 0x01;
pub const IFR_NO_EMPTY_SET: u8 = 0x02;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrPassword {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub min_size: u16,
    pub max_size: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrQuestionRef1 {
    pub header: IfrOpHeader,
    pub question_id: QuestionId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrQuestionRef2 {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrQuestionRef3 {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrQuestionRef32 {
    pub header: IfrOpHeader,
    pub device_path: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrQuestionRef33 {
    pub header: IfrOpHeader,
    pub device_path: StringId,
    pub guid: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrRead {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrRef {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub form_id: FormId,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrRef2 {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub form_id: FormId,
    pub question_id: QuestionId,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrRef3 {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub form_id: FormId,
    pub question_id: QuestionId,
    pub form_set_id: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrRef4 {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub form_id: FormId,
    pub question_id: QuestionId,
    pub form_set_id: crate::base::Guid,
    pub device_path: StringId,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrRef5 {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrRefresh {
    pub header: IfrOpHeader,
    pub refresh_interval: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrRefreshId {
    pub header: IfrOpHeader,
    pub refresh_event_group_id: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrResetButton {
    pub header: IfrOpHeader,
    pub statement: IfrStatementHeader,
    pub deafult_id: DefaultId,
}

pub type DefaultId = u16;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrRule {
    pub header: IfrOpHeader,
    pub rule_id: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrRuleRef {
    pub header: IfrOpHeader,
    pub rule_id: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrSecurity {
    pub header: IfrOpHeader,
    pub permissions: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub union IfrSetVarStoreInfo {
    pub var_name: StringId,
    pub var_offset: u16,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrSet {
    pub header: IfrOpHeader,
    pub var_store_id: VarstoreId,
    pub var_store_info: IfrSetVarStoreInfo,
    pub var_store_type: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrShiftLeft {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrShiftRight {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrSpan {
    pub header: IfrOpHeader,
    pub flags: u8,
}

pub const IFR_FLAGS_FIRST_MATCHING: u8 = 0x00;
pub const IFR_FLAGS_FIRST_NON_MATCHING: u8 = 0x01;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrString {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub min_size: u8,
    pub max_size: u8,
    pub flags: u8,
}

pub const IFR_STRING_MULTI_LINE: u8 = 0x01;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrStringRef1 {
    pub header: IfrOpHeader,
    pub string_id: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrStringRef2 {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrSubtitle {
    pub header: IfrOpHeader,
    pub statement: IfrStatementHeader,
    pub flags: u8,
}

pub const IFR_FLAGS_HORIZONTAL: u8 = 0x01;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrSubtract {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrSuppressIf {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrText {
    pub header: IfrOpHeader,
    pub statement: IfrStatementHeader,
    pub text_two: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrThis {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct IfrTime {
    pub header: IfrOpHeader,
    pub question: IfrQuestionHeader,
    pub flags: u8,
}

pub const QF_TIME_HOUR_SUPPRESS: u8 = 0x01;
pub const QF_TIME_MINUTE_SUPPRESS: u8 = 0x02;
pub const QF_TIME_SECOND_SUPPRESS: u8 = 0x04;
pub const QF_TIME_STORAGE: u8 = 0x30;

pub const QF_TIME_STORAGE_NORMAL: u8 = 0x00;
pub const QF_TIME_STORAGE_TIME: u8 = 0x10;
pub const QF_TIME_STORAGE_WAKEUP: u8 = 0x20;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToken {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToBoolean {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToLower {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToString {
    pub header: IfrOpHeader,
    pub format: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToUint {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrToUpper {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrTrue {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrUint8 {
    pub header: IfrOpHeader,
    pub value: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrUint16 {
    pub header: IfrOpHeader,
    pub value: u16,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrUint32 {
    pub header: IfrOpHeader,
    pub value: u32,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrUint64 {
    pub header: IfrOpHeader,
    pub value: u64,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrUndefined {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrValue {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrVarstore<const N: usize = 0> {
    pub header: IfrOpHeader,
    pub guid: crate::base::Guid,
    pub var_store_id: VarstoreId,
    pub size: u16,
    pub name: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrVarstoreNameValue {
    pub header: IfrOpHeader,
    pub var_store_id: VarstoreId,
    pub guid: crate::base::Guid,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrVarstoreEfi<const N: usize = 0> {
    pub header: IfrOpHeader,
    pub var_store_id: VarstoreId,
    pub guid: crate::base::Guid,
    pub attributes: u32,
    pub size: u16,
    pub name: [u8; N],
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrVarstoreDevice {
    pub header: IfrOpHeader,
    pub device_path: StringId,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrVersion {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrWrite {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrZero {
    pub header: IfrOpHeader,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrWarningIf {
    pub header: IfrOpHeader,
    pub warning: StringId,
    pub time_out: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct IfrMatch2 {
    pub header: IfrOpHeader,
    pub syntax_type: crate::base::Guid,
}