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
|
/** @file
The definition of CFormPkg's member function
Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "stdio.h"
#include "VfrFormPkg.h"
/*
* The definition of CFormPkg's member function
*/
SPendingAssign::SPendingAssign (
IN CHAR8 *Key,
IN VOID *Addr,
IN UINT32 Len,
IN UINT32 LineNo,
IN CONST CHAR8 *Msg
)
{
mKey = NULL;
mAddr = Addr;
mLen = Len;
mFlag = PENDING;
mLineNo = LineNo;
mMsg = NULL;
mNext = NULL;
if (Key != NULL) {
mKey = new CHAR8[strlen (Key) + 1];
if (mKey != NULL) {
strcpy (mKey, Key);
}
}
if (Msg != NULL) {
mMsg = new CHAR8[strlen (Msg) + 1];
if (mMsg != NULL) {
strcpy (mMsg, Msg);
}
}
}
SPendingAssign::~SPendingAssign (
VOID
)
{
if (mKey != NULL) {
delete mKey;
}
mAddr = NULL;
mLen = 0;
mLineNo = 0;
if (mMsg != NULL) {
delete mMsg;
}
mNext = NULL;
}
VOID
SPendingAssign::SetAddrAndLen (
IN VOID *Addr,
IN UINT32 LineNo
)
{
mAddr = Addr;
mLineNo = LineNo;
}
VOID
SPendingAssign::AssignValue (
IN VOID *Addr,
IN UINT32 Len
)
{
memcpy (mAddr, Addr, (mLen < Len ? mLen : Len));
mFlag = ASSIGNED;
}
CHAR8 *
SPendingAssign::GetKey (
VOID
)
{
return mKey;
}
CFormPkg::CFormPkg (
IN UINT32 BufferSize = 4096
)
{
CHAR8 *BufferStart;
CHAR8 *BufferEnd;
SBufferNode *Node;
mPkgLength = 0;
mBufferNodeQueueHead = NULL;
mCurrBufferNode = NULL;
Node = new SBufferNode;
if (Node == NULL) {
return ;
}
BufferStart = new CHAR8[BufferSize];
if (BufferStart == NULL) {
return;
}
BufferEnd = BufferStart + BufferSize;
memset (BufferStart, 0, BufferSize);
Node->mBufferStart = BufferStart;
Node->mBufferEnd = BufferEnd;
Node->mBufferFree = BufferStart;
Node->mNext = NULL;
mBufferSize = BufferSize;
mBufferNodeQueueHead = Node;
mBufferNodeQueueTail = Node;
mCurrBufferNode = Node;
}
CFormPkg::~CFormPkg ()
{
SBufferNode *pBNode;
SPendingAssign *pPNode;
while (mBufferNodeQueueHead != NULL) {
pBNode = mBufferNodeQueueHead;
mBufferNodeQueueHead = mBufferNodeQueueHead->mNext;
if (pBNode->mBufferStart != NULL) {
delete pBNode->mBufferStart;
delete pBNode;
}
}
mBufferNodeQueueTail = NULL;
mCurrBufferNode = NULL;
while (PendingAssignList != NULL) {
pPNode = PendingAssignList;
PendingAssignList = PendingAssignList->mNext;
delete pPNode;
}
PendingAssignList = NULL;
}
SBufferNode *
CFormPkg::CreateNewNode (
VOID
)
{
SBufferNode *Node;
Node = new SBufferNode;
if (Node == NULL) {
return NULL;
}
Node->mBufferStart = new CHAR8[mBufferSize];
if (Node->mBufferStart == NULL) {
delete Node;
return NULL;
} else {
memset (Node->mBufferStart, 0, mBufferSize);
Node->mBufferEnd = Node->mBufferStart + mBufferSize;
Node->mBufferFree = Node->mBufferStart;
Node->mNext = NULL;
}
return Node;
}
CHAR8 *
CFormPkg::IfrBinBufferGet (
IN UINT32 Len
)
{
CHAR8 *BinBuffer = NULL;
SBufferNode *Node = NULL;
if ((Len == 0) || (Len > mBufferSize)) {
return NULL;
}
if ((mCurrBufferNode->mBufferFree + Len) <= mCurrBufferNode->mBufferEnd) {
BinBuffer = mCurrBufferNode->mBufferFree;
mCurrBufferNode->mBufferFree += Len;
} else {
Node = CreateNewNode ();
if (Node == NULL) {
return NULL;
}
if (mBufferNodeQueueTail == NULL) {
mBufferNodeQueueHead = mBufferNodeQueueTail = Node;
} else {
mBufferNodeQueueTail->mNext = Node;
mBufferNodeQueueTail = Node;
}
mCurrBufferNode = Node;
//
// Now try again.
//
BinBuffer = mCurrBufferNode->mBufferFree;
mCurrBufferNode->mBufferFree += Len;
}
mPkgLength += Len;
return BinBuffer;
}
inline
UINT32
CFormPkg::GetPkgLength (
VOID
)
{
return mPkgLength;
}
VOID
CFormPkg::Open (
VOID
)
{
mReadBufferNode = mBufferNodeQueueHead;
mReadBufferOffset = 0;
}
VOID
CFormPkg::Close (
VOID
)
{
mReadBufferNode = NULL;
mReadBufferOffset = 0;
}
UINT32
CFormPkg::Read (
IN CHAR8 *Buffer,
IN UINT32 Size
)
{
UINT32 Index;
if ((Size == 0) || (Buffer == NULL)) {
return 0;
}
if (mReadBufferNode == NULL) {
return 0;
}
for (Index = 0; Index < Size; Index++) {
if ((mReadBufferNode->mBufferStart + mReadBufferOffset) < mReadBufferNode->mBufferFree) {
Buffer[Index] = mReadBufferNode->mBufferStart[mReadBufferOffset++];
} else {
if ((mReadBufferNode = mReadBufferNode->mNext) == NULL) {
return Index;
} else {
mReadBufferOffset = 0;
Index --;
}
}
}
return Size;
}
EFI_VFR_RETURN_CODE
CFormPkg::BuildPkgHdr (
OUT EFI_HII_PACKAGE_HEADER **PkgHdr
)
{
if (PkgHdr == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
if (((*PkgHdr) = new EFI_HII_PACKAGE_HEADER) == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
(*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;
(*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
CFormPkg::BuildPkg (
OUT PACKAGE_DATA &TBuffer
)
{
CHAR8 *Temp;
UINT32 Size;
CHAR8 Buffer[1024];
if (TBuffer.Buffer != NULL) {
delete TBuffer.Buffer;
}
TBuffer.Size = mPkgLength;
TBuffer.Buffer = NULL;
if (TBuffer.Size != 0) {
TBuffer.Buffer = new CHAR8[TBuffer.Size];
} else {
return VFR_RETURN_SUCCESS;
}
Temp = TBuffer.Buffer;
Open ();
while ((Size = Read (Buffer, 1024)) != 0) {
memcpy (Temp, Buffer, Size);
Temp += Size;
}
Close ();
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
CFormPkg::BuildPkg (
IN FILE *Output,
IN PACKAGE_DATA *PkgData
)
{
EFI_VFR_RETURN_CODE Ret;
CHAR8 Buffer[1024];
UINT32 Size;
EFI_HII_PACKAGE_HEADER *PkgHdr;
if (Output == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
if ((Ret = BuildPkgHdr(&PkgHdr)) != VFR_RETURN_SUCCESS) {
return Ret;
}
fwrite (PkgHdr, sizeof (EFI_HII_PACKAGE_HEADER), 1, Output);
delete PkgHdr;
if (PkgData == NULL) {
Open ();
while ((Size = Read (Buffer, 1024)) != 0) {
fwrite (Buffer, Size, 1, Output);
}
Close ();
} else {
fwrite (PkgData->Buffer, PkgData->Size, 1, Output);
}
return VFR_RETURN_SUCCESS;
}
VOID
CFormPkg::_WRITE_PKG_LINE (
IN FILE *pFile,
IN UINT32 LineBytes,
IN CONST CHAR8 *LineHeader,
IN CHAR8 *BlkBuf,
IN UINT32 BlkSize
)
{
UINT32 Index;
if ((pFile == NULL) || (LineHeader == NULL) || (BlkBuf == NULL)) {
return;
}
for (Index = 0; Index < BlkSize; Index++) {
if ((Index % LineBytes) == 0) {
fprintf (pFile, "\n%s", LineHeader);
}
fprintf (pFile, "0x%02X, ", (UINT8)BlkBuf[Index]);
}
}
VOID
CFormPkg::_WRITE_PKG_END (
IN FILE *pFile,
IN UINT32 LineBytes,
IN CONST CHAR8 *LineHeader,
IN CHAR8 *BlkBuf,
IN UINT32 BlkSize
)
{
UINT32 Index;
if ((BlkSize == 0) || (pFile == NULL) || (LineHeader == NULL) || (BlkBuf == NULL)) {
return;
}
for (Index = 0; Index < BlkSize - 1; Index++) {
if ((Index % LineBytes) == 0) {
fprintf (pFile, "\n%s", LineHeader);
}
fprintf (pFile, "0x%02X, ", (UINT8)BlkBuf[Index]);
}
if ((Index % LineBytes) == 0) {
fprintf (pFile, "\n%s", LineHeader);
}
fprintf (pFile, "0x%02X\n", (UINT8)BlkBuf[Index]);
}
#define BYTES_PRE_LINE 0x10
UINT32 gAdjustOpcodeOffset = 0;
BOOLEAN gNeedAdjustOpcode = FALSE;
UINT32 gAdjustOpcodeLen = 0;
EFI_VFR_RETURN_CODE
CFormPkg::GenCFile (
IN CHAR8 *BaseName,
IN FILE *pFile,
IN PACKAGE_DATA *PkgData
)
{
EFI_VFR_RETURN_CODE Ret;
CHAR8 Buffer[BYTES_PRE_LINE * 8];
EFI_HII_PACKAGE_HEADER *PkgHdr;
UINT32 PkgLength = 0;
UINT32 ReadSize = 0;
if ((BaseName == NULL) || (pFile == NULL)) {
return VFR_RETURN_FATAL_ERROR;
}
fprintf (pFile, "\nunsigned char %sBin[] = {\n", BaseName);
if ((Ret = BuildPkgHdr(&PkgHdr)) != VFR_RETURN_SUCCESS) {
return Ret;
}
//
// For framework vfr file, the extension framework header will be added.
//
if (VfrCompatibleMode) {
fprintf (pFile, " // FRAMEWORK PACKAGE HEADER Length\n");
PkgLength = PkgHdr->Length + sizeof (UINT32) + 2;
_WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, " ", (CHAR8 *)&PkgLength, sizeof (UINT32));
fprintf (pFile, "\n\n // FRAMEWORK PACKAGE HEADER Type\n");
PkgLength = 3;
_WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, " ", (CHAR8 *)&PkgLength, sizeof (UINT16));
} else {
fprintf (pFile, " // ARRAY LENGTH\n");
PkgLength = PkgHdr->Length + sizeof (UINT32);
_WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, " ", (CHAR8 *)&PkgLength, sizeof (UINT32));
}
fprintf (pFile, "\n\n // PACKAGE HEADER\n");
_WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, " ", (CHAR8 *)PkgHdr, sizeof (EFI_HII_PACKAGE_HEADER));
PkgLength = sizeof (EFI_HII_PACKAGE_HEADER);
fprintf (pFile, "\n\n // PACKAGE DATA\n");
if (PkgData == NULL) {
Open ();
while ((ReadSize = Read ((CHAR8 *)Buffer, BYTES_PRE_LINE * 8)) != 0) {
PkgLength += ReadSize;
if (PkgLength < PkgHdr->Length) {
_WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, " ", Buffer, ReadSize);
} else {
_WRITE_PKG_END (pFile, BYTES_PRE_LINE, " ", Buffer, ReadSize);
}
}
Close ();
} else {
if (PkgData->Size % BYTES_PRE_LINE != 0) {
PkgLength = PkgData->Size - (PkgData->Size % BYTES_PRE_LINE);
_WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, " ", PkgData->Buffer, PkgLength);
_WRITE_PKG_END (pFile, BYTES_PRE_LINE, " ", PkgData->Buffer + PkgLength, PkgData->Size % BYTES_PRE_LINE);
} else {
PkgLength = PkgData->Size - BYTES_PRE_LINE;
_WRITE_PKG_LINE (pFile, BYTES_PRE_LINE, " ", PkgData->Buffer, PkgLength);
_WRITE_PKG_END (pFile, BYTES_PRE_LINE, " ", PkgData->Buffer + PkgLength, BYTES_PRE_LINE);
}
}
delete PkgHdr;
fprintf (pFile, "\n};\n");
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
CFormPkg::AssignPending (
IN CHAR8 *Key,
IN VOID *ValAddr,
IN UINT32 ValLen,
IN UINT32 LineNo,
IN CONST CHAR8 *Msg
)
{
SPendingAssign *pNew;
pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);
if (pNew == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
pNew->mNext = PendingAssignList;
PendingAssignList = pNew;
return VFR_RETURN_SUCCESS;
}
VOID
CFormPkg::DoPendingAssign (
IN CHAR8 *Key,
IN VOID *ValAddr,
IN UINT32 ValLen
)
{
SPendingAssign *pNode;
if ((Key == NULL) || (ValAddr == NULL)) {
return;
}
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (strcmp (pNode->mKey, Key) == 0) {
pNode->AssignValue (ValAddr, ValLen);
}
}
}
bool
CFormPkg::HavePendingUnassigned (
VOID
)
{
SPendingAssign *pNode;
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
return TRUE;
}
}
return FALSE;
}
VOID
CFormPkg::PendingAssignPrintAll (
VOID
)
{
SPendingAssign *pNode;
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);
}
}
}
SBufferNode *
CFormPkg::GetBinBufferNodeForAddr (
IN CHAR8 *BinBuffAddr
)
{
SBufferNode *TmpNode;
TmpNode = mBufferNodeQueueHead;
while (TmpNode != NULL) {
if (TmpNode->mBufferStart <= BinBuffAddr && TmpNode->mBufferFree >= BinBuffAddr) {
return TmpNode;
}
TmpNode = TmpNode->mNext;
}
return NULL;
}
SBufferNode *
CFormPkg::GetNodeBefore(
IN SBufferNode *CurrentNode
)
{
SBufferNode *FirstNode = mBufferNodeQueueHead;
SBufferNode *LastNode = mBufferNodeQueueHead;
while (FirstNode != NULL) {
if (FirstNode == CurrentNode) {
break;
}
LastNode = FirstNode;
FirstNode = FirstNode->mNext;
}
if (FirstNode == NULL) {
LastNode = NULL;
}
return LastNode;
}
EFI_VFR_RETURN_CODE
CFormPkg::InsertNodeBefore(
IN SBufferNode *CurrentNode,
IN SBufferNode *NewNode
)
{
SBufferNode *LastNode = GetNodeBefore (CurrentNode);
if (LastNode == NULL) {
return VFR_RETURN_MISMATCHED;
}
NewNode->mNext = LastNode->mNext;
LastNode->mNext = NewNode;
return VFR_RETURN_SUCCESS;
}
CHAR8 *
CFormPkg::GetBufAddrBaseOnOffset (
IN UINT32 Offset
)
{
SBufferNode *TmpNode;
UINT32 TotalBufLen;
UINT32 CurrentBufLen;
TotalBufLen = 0;
for (TmpNode = mBufferNodeQueueHead; TmpNode != NULL; TmpNode = TmpNode->mNext) {
CurrentBufLen = TmpNode->mBufferFree - TmpNode->mBufferStart;
if (Offset >= TotalBufLen && Offset < TotalBufLen + CurrentBufLen) {
return TmpNode->mBufferStart + (Offset - TotalBufLen);
}
TotalBufLen += CurrentBufLen;
}
return NULL;
}
EFI_VFR_RETURN_CODE
CFormPkg::AdjustDynamicInsertOpcode (
IN CHAR8 *LastFormEndAddr,
IN CHAR8 *InsertOpcodeAddr
)
{
SBufferNode *LastFormEndNode;
SBufferNode *InsertOpcodeNode;
SBufferNode *NewRestoreNodeBegin;
SBufferNode *NewRestoreNodeEnd;
SBufferNode *NewLastEndNode;
SBufferNode *TmpNode;
UINT32 NeedRestoreCodeLen;
NewRestoreNodeEnd = NULL;
LastFormEndNode = GetBinBufferNodeForAddr(LastFormEndAddr);
InsertOpcodeNode = GetBinBufferNodeForAddr(InsertOpcodeAddr);
if (LastFormEndNode == InsertOpcodeNode) {
//
// Create New Node to save the restore opcode.
//
NeedRestoreCodeLen = InsertOpcodeAddr - LastFormEndAddr;
gAdjustOpcodeLen = NeedRestoreCodeLen;
NewRestoreNodeBegin = CreateNewNode ();
if (NewRestoreNodeBegin == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
memcpy (NewRestoreNodeBegin->mBufferFree, LastFormEndAddr, NeedRestoreCodeLen);
NewRestoreNodeBegin->mBufferFree += NeedRestoreCodeLen;
//
// Override the restore buffer data.
//
memcpy (LastFormEndAddr, InsertOpcodeAddr, InsertOpcodeNode->mBufferFree - InsertOpcodeAddr);
InsertOpcodeNode->mBufferFree -= NeedRestoreCodeLen;
memset (InsertOpcodeNode->mBufferFree, 0, NeedRestoreCodeLen);
} else {
//
// Create New Node to save the restore opcode.
//
NeedRestoreCodeLen = LastFormEndNode->mBufferFree - LastFormEndAddr;
gAdjustOpcodeLen = NeedRestoreCodeLen;
NewRestoreNodeBegin = CreateNewNode ();
if (NewRestoreNodeBegin == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
memcpy (NewRestoreNodeBegin->mBufferFree, LastFormEndAddr, NeedRestoreCodeLen);
NewRestoreNodeBegin->mBufferFree += NeedRestoreCodeLen;
//
// Override the restore buffer data.
//
LastFormEndNode->mBufferFree -= NeedRestoreCodeLen;
//
// Link the restore data to new node.
//
NewRestoreNodeBegin->mNext = LastFormEndNode->mNext;
//
// Count the Adjust opcode len.
//
TmpNode = LastFormEndNode->mNext;
while (TmpNode != InsertOpcodeNode) {
gAdjustOpcodeLen += TmpNode->mBufferFree - TmpNode->mBufferStart;
TmpNode = TmpNode->mNext;
}
//
// Create New Node to save the last node of restore opcode.
//
NeedRestoreCodeLen = InsertOpcodeAddr - InsertOpcodeNode->mBufferStart;
gAdjustOpcodeLen += NeedRestoreCodeLen;
if (NeedRestoreCodeLen > 0) {
NewRestoreNodeEnd = CreateNewNode ();
if (NewRestoreNodeEnd == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
memcpy (NewRestoreNodeEnd->mBufferFree, InsertOpcodeNode->mBufferStart, NeedRestoreCodeLen);
NewRestoreNodeEnd->mBufferFree += NeedRestoreCodeLen;
//
// Override the restore buffer data.
//
memcpy (InsertOpcodeNode->mBufferStart, InsertOpcodeAddr, InsertOpcodeNode->mBufferFree - InsertOpcodeAddr);
InsertOpcodeNode->mBufferFree -= InsertOpcodeAddr - InsertOpcodeNode->mBufferStart;
//
// Insert the last restore data node.
//
TmpNode = GetNodeBefore (InsertOpcodeNode);
if (TmpNode == LastFormEndNode) {
NewRestoreNodeBegin->mNext = NewRestoreNodeEnd;
} else {
TmpNode->mNext = NewRestoreNodeEnd;
}
//
// Connect the dynamic opcode node to the node before last form end node.
//
LastFormEndNode->mNext = InsertOpcodeNode;
}
}
if (mBufferNodeQueueTail->mBufferFree - mBufferNodeQueueTail->mBufferStart > 2) {
//
// End form set opcode all in the mBufferNodeQueueTail node.
//
NewLastEndNode = CreateNewNode ();
if (NewLastEndNode == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
NewLastEndNode->mBufferStart[0] = 0x29;
NewLastEndNode->mBufferStart[1] = 0x02;
NewLastEndNode->mBufferFree += 2;
mBufferNodeQueueTail->mBufferFree -= 2;
mBufferNodeQueueTail->mNext = NewRestoreNodeBegin;
if (NewRestoreNodeEnd != NULL) {
NewRestoreNodeEnd->mNext = NewLastEndNode;
} else {
NewRestoreNodeBegin->mNext = NewLastEndNode;
}
mBufferNodeQueueTail = NewLastEndNode;
} else if (mBufferNodeQueueTail->mBufferFree - mBufferNodeQueueTail->mBufferStart == 2) {
TmpNode = GetNodeBefore(mBufferNodeQueueTail);
TmpNode->mNext = NewRestoreNodeBegin;
if (NewRestoreNodeEnd != NULL) {
NewRestoreNodeEnd->mNext = mBufferNodeQueueTail;
} else {
NewRestoreNodeBegin->mNext = mBufferNodeQueueTail;
}
}
return VFR_RETURN_SUCCESS;
}
EFI_VFR_RETURN_CODE
CFormPkg::DeclarePendingQuestion (
IN CVfrVarDataTypeDB &lCVfrVarDataTypeDB,
IN CVfrDataStorage &lCVfrDataStorage,
IN CVfrQuestionDB &lCVfrQuestionDB,
IN EFI_GUID *LocalFormSetGuid,
IN UINT32 LineNo,
OUT CHAR8 **InsertOpcodeAddr
)
{
SPendingAssign *pNode;
CHAR8 *VarStr;
UINT32 ArrayIdx;
CHAR8 FName[MAX_NAME_LEN];
CHAR8 *SName;
CHAR8 *NewStr;
UINT32 ShrinkSize;
EFI_VFR_RETURN_CODE ReturnCode;
EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
//
// Declare all questions as Numeric in DisableIf True
//
// DisableIf
CIfrDisableIf DIObj;
DIObj.SetLineNo (LineNo);
*InsertOpcodeAddr = DIObj.GetObjBinAddr ();
//TrueOpcode
CIfrTrue TObj (LineNo);
// Declare Numeric qeustion for each undefined question.
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
CIfrNumeric CNObj;
EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
CNObj.SetLineNo (LineNo);
CNObj.SetPrompt (0x0);
CNObj.SetHelp (0x0);
//
// Register this question, assume it is normal question, not date or time question
//
VarStr = pNode->mKey;
ReturnCode = lCVfrQuestionDB.RegisterQuestion (NULL, VarStr, QId);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey);
return ReturnCode;
}
#ifdef VFREXP_DEBUG
printf ("Undefined Question name is %s and Id is 0x%x\n", VarStr, QId);
#endif
//
// Get Question Info, framework vfr VarName == StructName
//
ReturnCode = lCVfrVarDataTypeDB.ExtractFieldNameAndArrary (VarStr, FName, ArrayIdx);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", "Var string is not the valid C variable");
return ReturnCode;
}
//
// Get VarStoreType
//
ReturnCode = lCVfrDataStorage.GetVarStoreId (FName, &Info.mVarStoreId);
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, FName, "Error", "Var Store Type is not defined");
return ReturnCode;
}
VarStoreType = lCVfrDataStorage.GetVarStoreType (Info.mVarStoreId);
if (*VarStr == '\0' && ArrayIdx != INVALID_ARRAY_INDEX) {
ReturnCode = lCVfrDataStorage.GetNameVarStoreInfo (&Info, ArrayIdx);
} else {
if (VarStoreType == EFI_VFR_VARSTORE_EFI) {
ReturnCode = lCVfrDataStorage.GetEfiVarStoreInfo (&Info);
} else if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {
VarStr = pNode->mKey;
//convert VarStr with store name to VarStr with structure name
ReturnCode = lCVfrDataStorage.GetBufferVarStoreDataTypeName (Info.mVarStoreId, &SName);
if (ReturnCode == VFR_RETURN_SUCCESS) {
NewStr = new CHAR8[strlen (VarStr) + strlen (SName) + 1];
NewStr[0] = '\0';
strcpy (NewStr, SName);
strcat (NewStr, VarStr + strlen (FName));
ReturnCode = lCVfrVarDataTypeDB.GetDataFieldInfo (NewStr, Info.mInfo.mVarOffset, Info.mVarType, Info.mVarTotalSize);
delete NewStr;
}
} else {
ReturnCode = VFR_RETURN_UNSUPPORTED;
}
}
if (ReturnCode != VFR_RETURN_SUCCESS) {
gCVfrErrorHandle.HandleError (ReturnCode, pNode->mLineNo, pNode->mKey);
return ReturnCode;
}
CNObj.SetQuestionId (QId);
CNObj.SetVarStoreInfo (&Info);
//
// Numeric doesn't support BOOLEAN data type.
// BOOLEAN type has the same data size to UINT8.
//
if (Info.mVarType == EFI_IFR_TYPE_BOOLEAN) {
Info.mVarType = EFI_IFR_TYPE_NUM_SIZE_8;
}
CNObj.SetFlags (0, Info.mVarType);
//
// Use maximum value not to limit the vaild value for the undefined question.
//
switch (Info.mVarType) {
case EFI_IFR_TYPE_NUM_SIZE_64:
CNObj.SetMinMaxStepData ((UINT64) 0, (UINT64) -1 , (UINT64) 0);
ShrinkSize = 0;
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
CNObj.SetMinMaxStepData ((UINT32) 0, (UINT32) -1 , (UINT32) 0);
ShrinkSize = 12;
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
CNObj.SetMinMaxStepData ((UINT16) 0, (UINT16) -1 , (UINT16) 0);
ShrinkSize = 18;
break;
case EFI_IFR_TYPE_NUM_SIZE_8:
CNObj.SetMinMaxStepData ((UINT8) 0, (UINT8) -1 , (UINT8) 0);
ShrinkSize = 21;
break;
default:
break;
}
CNObj.ShrinkBinSize (ShrinkSize);
//
// For undefined Efi VarStore type question
// Append the extended guided opcode to contain VarName
//
if (VarStoreType == EFI_VFR_VARSTORE_EFI || VfrCompatibleMode) {
CIfrVarEqName CVNObj (QId, Info.mInfo.mVarName);
CVNObj.SetLineNo (LineNo);
}
//
// End for Numeric
//
CIfrEnd CEObj;
CEObj.SetLineNo (LineNo);
}
}
//
// End for DisableIf
//
CIfrEnd SEObj;
SEObj.SetLineNo (LineNo);
return VFR_RETURN_SUCCESS;
}
CFormPkg gCFormPkg;
SIfrRecord::SIfrRecord (
VOID
)
{
mIfrBinBuf = NULL;
mBinBufLen = 0;
mLineNo = 0xFFFFFFFF;
mOffset = 0xFFFFFFFF;
mNext = NULL;
}
SIfrRecord::~SIfrRecord (
VOID
)
{
if (mIfrBinBuf != NULL) {
//delete mIfrBinBuf;
mIfrBinBuf = NULL;
}
mLineNo = 0xFFFFFFFF;
mOffset = 0xFFFFFFFF;
mBinBufLen = 0;
mNext = NULL;
}
CIfrRecordInfoDB::CIfrRecordInfoDB (
VOID
)
{
mSwitch = TRUE;
mRecordCount = EFI_IFR_RECORDINFO_IDX_START;
mIfrRecordListHead = NULL;
mIfrRecordListTail = NULL;
}
CIfrRecordInfoDB::~CIfrRecordInfoDB (
VOID
)
{
SIfrRecord *pNode;
while (mIfrRecordListHead != NULL) {
pNode = mIfrRecordListHead;
mIfrRecordListHead = mIfrRecordListHead->mNext;
delete pNode;
}
}
SIfrRecord *
CIfrRecordInfoDB::GetRecordInfoFromIdx (
IN UINT32 RecordIdx
)
{
UINT32 Idx;
SIfrRecord *pNode = NULL;
if (RecordIdx == EFI_IFR_RECORDINFO_IDX_INVALUD) {
return NULL;
}
for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
(Idx != RecordIdx) && (pNode != NULL);
Idx++, pNode = pNode->mNext)
;
return pNode;
}
UINT32
CIfrRecordInfoDB::IfrRecordRegister (
IN UINT32 LineNo,
IN CHAR8 *IfrBinBuf,
IN UINT8 BinBufLen,
IN UINT32 Offset
)
{
SIfrRecord *pNew;
if (mSwitch == FALSE) {
return EFI_IFR_RECORDINFO_IDX_INVALUD;
}
if ((pNew = new SIfrRecord) == NULL) {
return EFI_IFR_RECORDINFO_IDX_INVALUD;
}
if (mIfrRecordListHead == NULL) {
mIfrRecordListHead = pNew;
mIfrRecordListTail = pNew;
} else {
mIfrRecordListTail->mNext = pNew;
mIfrRecordListTail = pNew;
}
mRecordCount++;
return mRecordCount;
}
VOID
CIfrRecordInfoDB::IfrRecordInfoUpdate (
IN UINT32 RecordIdx,
IN UINT32 LineNo,
IN CHAR8 *BinBuf,
IN UINT8 BinBufLen,
IN UINT32 Offset
)
{
SIfrRecord *pNode;
SIfrRecord *Prev;
if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {
return;
}
if (LineNo == 0) {
//
// Line number is not specified explicitly, try to use line number of previous opcode
//
Prev = GetRecordInfoFromIdx (RecordIdx - 1);
if (Prev != NULL) {
LineNo = Prev->mLineNo;
}
}
pNode->mLineNo = LineNo;
pNode->mOffset = Offset;
pNode->mBinBufLen = BinBufLen;
pNode->mIfrBinBuf = BinBuf;
}
VOID
CIfrRecordInfoDB::IfrRecordOutput (
OUT PACKAGE_DATA &TBuffer
)
{
CHAR8 *Temp;
SIfrRecord *pNode;
if (TBuffer.Buffer != NULL) {
delete TBuffer.Buffer;
}
TBuffer.Size = 0;
TBuffer.Buffer = NULL;
if (mSwitch == FALSE) {
return;
}
for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {
TBuffer.Size += pNode->mBinBufLen;
}
if (TBuffer.Size != 0) {
TBuffer.Buffer = new CHAR8[TBuffer.Size];
} else {
return;
}
Temp = TBuffer.Buffer;
for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mIfrBinBuf != NULL) {
memcpy (Temp, pNode->mIfrBinBuf, pNode->mBinBufLen);
Temp += pNode->mBinBufLen;
}
}
return;
}
VOID
CIfrRecordInfoDB::IfrRecordOutput (
IN FILE *File,
IN UINT32 LineNo
)
{
SIfrRecord *pNode;
UINT8 Index;
UINT32 TotalSize;
if (mSwitch == FALSE) {
return;
}
if (File == NULL) {
return;
}
TotalSize = 0;
for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mLineNo == LineNo || LineNo == 0) {
fprintf (File, ">%08X: ", pNode->mOffset);
TotalSize += pNode->mBinBufLen;
if (pNode->mIfrBinBuf != NULL) {
for (Index = 0; Index < pNode->mBinBufLen; Index++) {
fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));
}
}
fprintf (File, "\n");
}
}
if (LineNo == 0) {
fprintf (File, "\nTotal Size of all record is 0x%08X\n", TotalSize);
}
}
//
// for framework vfr file
// adjust opcode sequence for uefi IFR format
// adjust inconsistent and varstore into the right position.
//
BOOLEAN
CIfrRecordInfoDB::CheckQuestionOpCode (
IN UINT8 OpCode
)
{
switch (OpCode) {
case EFI_IFR_CHECKBOX_OP:
case EFI_IFR_NUMERIC_OP:
case EFI_IFR_PASSWORD_OP:
case EFI_IFR_ONE_OF_OP:
case EFI_IFR_ACTION_OP:
case EFI_IFR_STRING_OP:
case EFI_IFR_DATE_OP:
case EFI_IFR_TIME_OP:
case EFI_IFR_ORDERED_LIST_OP:
return TRUE;
default:
return FALSE;
}
}
BOOLEAN
CIfrRecordInfoDB::CheckIdOpCode (
IN UINT8 OpCode
)
{
switch (OpCode) {
case EFI_IFR_EQ_ID_VAL_OP:
case EFI_IFR_EQ_ID_ID_OP:
case EFI_IFR_EQ_ID_VAL_LIST_OP:
case EFI_IFR_QUESTION_REF1_OP:
return TRUE;
default:
return FALSE;
}
}
EFI_QUESTION_ID
CIfrRecordInfoDB::GetOpcodeQuestionId (
IN EFI_IFR_OP_HEADER *OpHead
)
{
EFI_IFR_QUESTION_HEADER *QuestionHead;
QuestionHead = (EFI_IFR_QUESTION_HEADER *) (OpHead + 1);
return QuestionHead->QuestionId;
}
SIfrRecord *
CIfrRecordInfoDB::GetRecordInfoFromOffset (
IN UINT32 Offset
)
{
SIfrRecord *pNode = NULL;
for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mOffset == Offset) {
return pNode;
}
}
return pNode;
}
/*
Add just the op code position.
From
| form end opcode + end of if opcode for form ... + Dynamic opcode + form set end opcode |
To
| Dynamic opcode + form end opcode + end of if opcode for form ... + form set end opcode |
*/
BOOLEAN
CIfrRecordInfoDB::IfrAdjustDynamicOpcodeInRecords (
VOID
)
{
UINT32 OpcodeOffset;
SIfrRecord *pNode, *pPreNode;
SIfrRecord *pStartNode, *pNodeBeforeStart;
SIfrRecord *pEndNode;
pStartNode = NULL;
pEndNode = NULL;
OpcodeOffset = 0;
//
// Base on the offset info to get the node.
//
for (pNode = mIfrRecordListHead; pNode->mNext != NULL; pPreNode = pNode,pNode = pNode->mNext) {
if (OpcodeOffset == gAdjustOpcodeOffset) {
pStartNode = pNode;
pNodeBeforeStart = pPreNode;
} else if (OpcodeOffset == gAdjustOpcodeOffset + gAdjustOpcodeLen) {
pEndNode = pPreNode;
}
OpcodeOffset += pNode->mBinBufLen;
}
//
// Check the value.
//
if (pEndNode == NULL || pStartNode == NULL) {
return FALSE;
}
//
// Adjust the node. pPreNode save the Node before mIfrRecordListTail
//
pNodeBeforeStart->mNext = pEndNode->mNext;
pPreNode->mNext = pStartNode;
pEndNode->mNext = mIfrRecordListTail;
return TRUE;
}
VOID
CIfrRecordInfoDB::IfrAdjustOffsetForRecord (
VOID
)
{
UINT32 OpcodeOffset;
SIfrRecord *pNode;
OpcodeOffset = 0;
for (pNode = mIfrRecordListHead; pNode != NULL; pNode = pNode->mNext) {
pNode->mOffset = OpcodeOffset;
OpcodeOffset += pNode->mBinBufLen;
}
}
EFI_VFR_RETURN_CODE
CIfrRecordInfoDB::IfrRecordAdjust (
VOID
)
{
SIfrRecord *pNode, *preNode;
SIfrRecord *uNode, *tNode;
EFI_IFR_OP_HEADER *OpHead, *tOpHead;
EFI_QUESTION_ID QuestionId;
UINT32 StackCount;
UINT32 QuestionScope;
UINT32 OpcodeOffset;
CHAR8 ErrorMsg[MAX_STRING_LEN] = {0, };
EFI_VFR_RETURN_CODE Status;
//
// Init local variable
//
Status = VFR_RETURN_SUCCESS;
pNode = mIfrRecordListHead;
preNode = pNode;
QuestionScope = 0;
while (pNode != NULL) {
OpHead = (EFI_IFR_OP_HEADER *) pNode->mIfrBinBuf;
//
// make sure the inconsistent opcode in question scope
//
if (QuestionScope > 0) {
QuestionScope += OpHead->Scope;
if (OpHead->OpCode == EFI_IFR_END_OP) {
QuestionScope --;
}
}
if (CheckQuestionOpCode (OpHead->OpCode)) {
QuestionScope = 1;
}
//
// for the inconsistent opcode not in question scope, adjust it
//
if (OpHead->OpCode == EFI_IFR_INCONSISTENT_IF_OP && QuestionScope == 0) {
//
// for inconsistent opcode not in question scope
//
//
// Count inconsistent opcode Scope
//
StackCount = OpHead->Scope;
QuestionId = EFI_QUESTION_ID_INVALID;
tNode = pNode;
while (tNode != NULL && StackCount > 0) {
tNode = tNode->mNext;
tOpHead = (EFI_IFR_OP_HEADER *) tNode->mIfrBinBuf;
//
// Calculate Scope Number
//
StackCount += tOpHead->Scope;
if (tOpHead->OpCode == EFI_IFR_END_OP) {
StackCount --;
}
//
// by IdEqual opcode to get QuestionId
//
if (QuestionId == EFI_QUESTION_ID_INVALID &&
CheckIdOpCode (tOpHead->OpCode)) {
QuestionId = *(EFI_QUESTION_ID *) (tOpHead + 1);
}
}
if (tNode == NULL || QuestionId == EFI_QUESTION_ID_INVALID) {
//
// report error; not found
//
sprintf (ErrorMsg, "Inconsistent OpCode Record list invalid QuestionId is 0x%X", QuestionId);
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", ErrorMsg);
Status = VFR_RETURN_MISMATCHED;
break;
}
//
// extract inconsistent opcode list
// pNode is Incosistent opcode, tNode is End Opcode
//
//
// insert inconsistent opcode list into the right question scope by questionid
//
for (uNode = mIfrRecordListHead; uNode != NULL; uNode = uNode->mNext) {
tOpHead = (EFI_IFR_OP_HEADER *) uNode->mIfrBinBuf;
if (CheckQuestionOpCode (tOpHead->OpCode) &&
(QuestionId == GetOpcodeQuestionId (tOpHead))) {
break;
}
}
//
// insert inconsistent opcode list and check LATE_CHECK flag
//
if (uNode != NULL) {
if ((((EFI_IFR_QUESTION_HEADER *)(tOpHead + 1))->Flags & 0x20) != 0) {
//
// if LATE_CHECK flag is set, change inconsistent to nosumbit
//
OpHead->OpCode = EFI_IFR_NO_SUBMIT_IF_OP;
}
//
// skip the default storage for Date and Time
//
if ((uNode->mNext != NULL) && (*uNode->mNext->mIfrBinBuf == EFI_IFR_DEFAULT_OP)) {
uNode = uNode->mNext;
}
preNode->mNext = tNode->mNext;
tNode->mNext = uNode->mNext;
uNode->mNext = pNode;
//
// reset pNode to head list, scan the whole list again.
//
pNode = mIfrRecordListHead;
preNode = pNode;
QuestionScope = 0;
continue;
} else {
//
// not found matched question id, report error
//
sprintf (ErrorMsg, "QuestionId required by Inconsistent OpCode is not found. QuestionId is 0x%X", QuestionId);
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", ErrorMsg);
Status = VFR_RETURN_MISMATCHED;
break;
}
} else if (OpHead->OpCode == EFI_IFR_VARSTORE_OP ||
OpHead->OpCode == EFI_IFR_VARSTORE_EFI_OP) {
//
// for new added group of varstore opcode
//
tNode = pNode;
while (tNode->mNext != NULL) {
tOpHead = (EFI_IFR_OP_HEADER *) tNode->mNext->mIfrBinBuf;
if (tOpHead->OpCode != EFI_IFR_VARSTORE_OP &&
tOpHead->OpCode != EFI_IFR_VARSTORE_EFI_OP) {
break;
}
tNode = tNode->mNext;
}
if (tNode->mNext == NULL) {
//
// invalid IfrCode, IfrCode end by EndOpCode
//
gCVfrErrorHandle.PrintMsg (0, NULL, "Error", "No found End Opcode in the end");
Status = VFR_RETURN_MISMATCHED;
break;
}
if (tOpHead->OpCode != EFI_IFR_END_OP) {
//
// not new added varstore, which are not needed to be adjust.
//
preNode = tNode;
pNode = tNode->mNext;
continue;
} else {
//
// move new added varstore opcode to the position befor form opcode
// varstore opcode between pNode and tNode
//
//
// search form opcode from begin
//
for (uNode = mIfrRecordListHead; uNode->mNext != NULL; uNode = uNode->mNext) {
tOpHead = (EFI_IFR_OP_HEADER *) uNode->mNext->mIfrBinBuf;
if (tOpHead->OpCode == EFI_IFR_FORM_OP) {
break;
}
}
//
// Insert varstore opcode beform form opcode if form opcode is found
//
if (uNode->mNext != NULL) {
preNode->mNext = tNode->mNext;
tNode->mNext = uNode->mNext;
uNode->mNext = pNode;
//
// reset pNode to head list, scan the whole list again.
//
pNode = mIfrRecordListHead;
preNode = pNode;
QuestionScope = 0;
continue;
} else {
//
// not found form, continue scan IfrRecord list
//
preNode = tNode;
pNode = tNode->mNext;
continue;
}
}
}
//
// next node
//
preNode = pNode;
pNode = pNode->mNext;
}
//
// Update Ifr Opcode Offset
//
if (Status == VFR_RETURN_SUCCESS) {
IfrAdjustOffsetForRecord ();
}
return Status;
}
CIfrRecordInfoDB gCIfrRecordInfoDB;
VOID
CIfrObj::_EMIT_PENDING_OBJ (
VOID
)
{
CHAR8 *ObjBinBuf = NULL;
//
// do nothing
//
if (!mDelayEmit || !gCreateOp) {
return;
}
mPkgOffset = gCFormPkg.GetPkgLength ();
//
// update data buffer to package data
//
ObjBinBuf = gCFormPkg.IfrBinBufferGet (mObjBinLen);
if (ObjBinBuf != NULL) {
memcpy (ObjBinBuf, mObjBinBuf, mObjBinLen);
}
//
// update bin buffer to package data buffer
//
if (mObjBinBuf != NULL) {
delete mObjBinBuf;
mObjBinBuf = ObjBinBuf;
}
mDelayEmit = FALSE;
}
/*
* The definition of CIfrObj's member function
*/
static struct {
UINT8 mSize;
UINT8 mScope;
} gOpcodeSizesScopeTable[] = {
{ 0, 0 }, // EFI_IFR_INVALID - 0x00
{ sizeof (EFI_IFR_FORM), 1 }, // EFI_IFR_FORM_OP
{ sizeof (EFI_IFR_SUBTITLE), 1 }, // EFI_IFR_SUBTITLE_OP
{ sizeof (EFI_IFR_TEXT), 0 }, // EFI_IFR_TEXT_OP
{ sizeof (EFI_IFR_IMAGE), 0 }, // EFI_IFR_IMAGE_OP
{ sizeof (EFI_IFR_ONE_OF), 1 }, // EFI_IFR_ONE_OF_OP - 0x05
{ sizeof (EFI_IFR_CHECKBOX), 1}, // EFI_IFR_CHECKBOX_OP
{ sizeof (EFI_IFR_NUMERIC), 1 }, // EFI_IFR_NUMERIC_OP
{ sizeof (EFI_IFR_PASSWORD), 1 }, // EFI_IFR_PASSWORD_OP
{ sizeof (EFI_IFR_ONE_OF_OPTION), 0 }, // EFI_IFR_ONE_OF_OPTION_OP
{ sizeof (EFI_IFR_SUPPRESS_IF), 1 }, // EFI_IFR_SUPPRESS_IF - 0x0A
{ sizeof (EFI_IFR_LOCKED), 0 }, // EFI_IFR_LOCKED_OP
{ sizeof (EFI_IFR_ACTION), 1 }, // EFI_IFR_ACTION_OP
{ sizeof (EFI_IFR_RESET_BUTTON), 1 }, // EFI_IFR_RESET_BUTTON_OP
{ sizeof (EFI_IFR_FORM_SET), 1 }, // EFI_IFR_FORM_SET_OP -0xE
{ sizeof (EFI_IFR_REF), 0 }, // EFI_IFR_REF_OP
{ sizeof (EFI_IFR_NO_SUBMIT_IF), 1}, // EFI_IFR_NO_SUBMIT_IF_OP -0x10
{ sizeof (EFI_IFR_INCONSISTENT_IF), 1 }, // EFI_IFR_INCONSISTENT_IF_OP
{ sizeof (EFI_IFR_EQ_ID_VAL), 0 }, // EFI_IFR_EQ_ID_VAL_OP
{ sizeof (EFI_IFR_EQ_ID_ID), 0 }, // EFI_IFR_EQ_ID_ID_OP
{ sizeof (EFI_IFR_EQ_ID_VAL_LIST), 0 }, // EFI_IFR_EQ_ID_LIST_OP - 0x14
{ sizeof (EFI_IFR_AND), 0 }, // EFI_IFR_AND_OP
{ sizeof (EFI_IFR_OR), 0 }, // EFI_IFR_OR_OP
{ sizeof (EFI_IFR_NOT), 0 }, // EFI_IFR_NOT_OP
{ sizeof (EFI_IFR_RULE), 1 }, // EFI_IFR_RULE_OP
{ sizeof (EFI_IFR_GRAY_OUT_IF), 1 }, // EFI_IFR_GRAYOUT_IF_OP - 0x19
{ sizeof (EFI_IFR_DATE), 1 }, // EFI_IFR_DATE_OP
{ sizeof (EFI_IFR_TIME), 1 }, // EFI_IFR_TIME_OP
{ sizeof (EFI_IFR_STRING), 1 }, // EFI_IFR_STRING_OP
{ sizeof (EFI_IFR_REFRESH), 0 }, // EFI_IFR_REFRESH_OP
{ sizeof (EFI_IFR_DISABLE_IF), 1 }, // EFI_IFR_DISABLE_IF_OP - 0x1E
{ 0, 0 }, // 0x1F
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
{ sizeof (EFI_IFR_TO_UPPER), 0 }, // EFI_IFR_TO_UPPER_OP - 0x21
{ sizeof (EFI_IFR_MAP), 1 }, // EFI_IFR_MAP - 0x22
{ sizeof (EFI_IFR_ORDERED_LIST), 1 }, // EFI_IFR_ORDERED_LIST_OP - 0x23
{ sizeof (EFI_IFR_VARSTORE), 0 }, // EFI_IFR_VARSTORE_OP
{ sizeof (EFI_IFR_VARSTORE_NAME_VALUE), 0 }, // EFI_IFR_VARSTORE_NAME_VALUE_OP
{ sizeof (EFI_IFR_VARSTORE_EFI), 0 }, // EFI_IFR_VARSTORE_EFI_OP
{ sizeof (EFI_IFR_VARSTORE_DEVICE), 1 }, // EFI_IFR_VARSTORE_DEVICE_OP
{ sizeof (EFI_IFR_VERSION), 0 }, // EFI_IFR_VERSION_OP - 0x28
{ sizeof (EFI_IFR_END), 0 }, // EFI_IFR_END_OP
{ sizeof (EFI_IFR_MATCH), 0 }, // EFI_IFR_MATCH_OP - 0x2A
{ sizeof (EFI_IFR_GET), 0 }, // EFI_IFR_GET - 0x2B
{ sizeof (EFI_IFR_SET), 0 }, // EFI_IFR_SET - 0x2C
{ sizeof (EFI_IFR_READ), 0 }, // EFI_IFR_READ - 0x2D
{ sizeof (EFI_IFR_WRITE), 0 }, // EFI_IFR_WRITE - 0x2E
{ sizeof (EFI_IFR_EQUAL), 0 }, // EFI_IFR_EQUAL_OP - 0x2F
{ sizeof (EFI_IFR_NOT_EQUAL), 0 }, // EFI_IFR_NOT_EQUAL_OP
{ sizeof (EFI_IFR_GREATER_THAN), 0 }, // EFI_IFR_GREATER_THAN_OP
{ sizeof (EFI_IFR_GREATER_EQUAL), 0 }, // EFI_IFR_GREATER_EQUAL_OP
{ sizeof (EFI_IFR_LESS_THAN), 0 }, // EFI_IFR_LESS_THAN_OP
{ sizeof (EFI_IFR_LESS_EQUAL), 0 }, // EFI_IFR_LESS_EQUAL_OP - 0x34
{ sizeof (EFI_IFR_BITWISE_AND), 0 }, // EFI_IFR_BITWISE_AND_OP
{ sizeof (EFI_IFR_BITWISE_OR), 0 }, // EFI_IFR_BITWISE_OR_OP
{ sizeof (EFI_IFR_BITWISE_NOT), 0 }, // EFI_IFR_BITWISE_NOT_OP
{ sizeof (EFI_IFR_SHIFT_LEFT), 0 }, // EFI_IFR_SHIFT_LEFT_OP
{ sizeof (EFI_IFR_SHIFT_RIGHT), 0 }, // EFI_IFR_SHIFT_RIGHT_OP
{ sizeof (EFI_IFR_ADD), 0 }, // EFI_IFR_ADD_OP - 0x3A
{ sizeof (EFI_IFR_SUBTRACT), 0 }, // EFI_IFR_SUBTRACT_OP
{ sizeof (EFI_IFR_MULTIPLY), 0 }, // EFI_IFR_MULTIPLY_OP
{ sizeof (EFI_IFR_DIVIDE), 0 }, // EFI_IFR_DIVIDE_OP
{ sizeof (EFI_IFR_MODULO), 0 }, // EFI_IFR_MODULO_OP - 0x3E
{ sizeof (EFI_IFR_RULE_REF), 0 }, // EFI_IFR_RULE_REF_OP
{ sizeof (EFI_IFR_QUESTION_REF1), 0 }, // EFI_IFR_QUESTION_REF1_OP
{ sizeof (EFI_IFR_QUESTION_REF2), 0 }, // EFI_IFR_QUESTION_REF2_OP - 0x41
{ sizeof (EFI_IFR_UINT8), 0}, // EFI_IFR_UINT8
{ sizeof (EFI_IFR_UINT16), 0}, // EFI_IFR_UINT16
{ sizeof (EFI_IFR_UINT32), 0}, // EFI_IFR_UINT32
{ sizeof (EFI_IFR_UINT64), 0}, // EFI_IFR_UTNT64
{ sizeof (EFI_IFR_TRUE), 0 }, // EFI_IFR_TRUE_OP - 0x46
{ sizeof (EFI_IFR_FALSE), 0 }, // EFI_IFR_FALSE_OP
{ sizeof (EFI_IFR_TO_UINT), 0 }, // EFI_IFR_TO_UINT_OP
{ sizeof (EFI_IFR_TO_STRING), 0 }, // EFI_IFR_TO_STRING_OP
{ sizeof (EFI_IFR_TO_BOOLEAN), 0 }, // EFI_IFR_TO_BOOLEAN_OP
{ sizeof (EFI_IFR_MID), 0 }, // EFI_IFR_MID_OP
{ sizeof (EFI_IFR_FIND), 0 }, // EFI_IFR_FIND_OP
{ sizeof (EFI_IFR_TOKEN), 0 }, // EFI_IFR_TOKEN_OP
{ sizeof (EFI_IFR_STRING_REF1), 0 }, // EFI_IFR_STRING_REF1_OP - 0x4E
{ sizeof (EFI_IFR_STRING_REF2), 0 }, // EFI_IFR_STRING_REF2_OP
{ sizeof (EFI_IFR_CONDITIONAL), 0 }, // EFI_IFR_CONDITIONAL_OP
{ sizeof (EFI_IFR_QUESTION_REF3), 0 }, // EFI_IFR_QUESTION_REF3_OP
{ sizeof (EFI_IFR_ZERO), 0 }, // EFI_IFR_ZERO_OP
{ sizeof (EFI_IFR_ONE), 0 }, // EFI_IFR_ONE_OP
{ sizeof (EFI_IFR_ONES), 0 }, // EFI_IFR_ONES_OP
{ sizeof (EFI_IFR_UNDEFINED), 0 }, // EFI_IFR_UNDEFINED_OP
{ sizeof (EFI_IFR_LENGTH), 0 }, // EFI_IFR_LENGTH_OP
{ sizeof (EFI_IFR_DUP), 0 }, // EFI_IFR_DUP_OP - 0x57
{ sizeof (EFI_IFR_THIS), 0 }, // EFI_IFR_THIS_OP
{ sizeof (EFI_IFR_SPAN), 0 }, // EFI_IFR_SPAN_OP
{ sizeof (EFI_IFR_VALUE), 1 }, // EFI_IFR_VALUE_OP
{ sizeof (EFI_IFR_DEFAULT), 0 }, // EFI_IFR_DEFAULT_OP
{ sizeof (EFI_IFR_DEFAULTSTORE), 0 }, // EFI_IFR_DEFAULTSTORE_OP - 0x5C
{ sizeof (EFI_IFR_FORM_MAP), 1}, // EFI_IFR_FORM_MAP_OP - 0x5D
{ sizeof (EFI_IFR_CATENATE), 0 }, // EFI_IFR_CATENATE_OP
{ sizeof (EFI_IFR_GUID), 0 }, // EFI_IFR_GUID_OP
{ sizeof (EFI_IFR_SECURITY), 0 }, // EFI_IFR_SECURITY_OP - 0x60
{ sizeof (EFI_IFR_MODAL_TAG), 0}, // EFI_IFR_MODAL_TAG_OP - 0x61
{ sizeof (EFI_IFR_REFRESH_ID), 0}, // EFI_IFR_REFRESH_ID_OP - 0x62
{ sizeof (EFI_IFR_WARNING_IF), 1}, // EFI_IFR_WARNING_IF_OP - 0x63
};
#ifdef CIFROBJ_DEUBG
static struct {
CHAR8 *mIfrName;
} gIfrObjPrintDebugTable[] = {
"EFI_IFR_INVALID", "EFI_IFR_FORM", "EFI_IFR_SUBTITLE", "EFI_IFR_TEXT", "EFI_IFR_IMAGE", "EFI_IFR_ONE_OF",
"EFI_IFR_CHECKBOX", "EFI_IFR_NUMERIC", "EFI_IFR_PASSWORD", "EFI_IFR_ONE_OF_OPTION", "EFI_IFR_SUPPRESS_IF", "EFI_IFR_LOCKED",
"EFI_IFR_ACTION", "EFI_IFR_RESET_BUTTON", "EFI_IFR_FORM_SET", "EFI_IFR_REF", "EFI_IFR_NO_SUBMIT_IF", "EFI_IFR_INCONSISTENT_IF",
"EFI_IFR_EQ_ID_VAL", "EFI_IFR_EQ_ID_ID", "EFI_IFR_EQ_ID_LIST", "EFI_IFR_AND", "EFI_IFR_OR", "EFI_IFR_NOT",
"EFI_IFR_RULE", "EFI_IFR_GRAY_OUT_IF", "EFI_IFR_DATE", "EFI_IFR_TIME", "EFI_IFR_STRING", "EFI_IFR_REFRESH",
"EFI_IFR_DISABLE_IF", "EFI_IFR_INVALID", "EFI_IFR_TO_LOWER", "EFI_IFR_TO_UPPER", "EFI_IFR_MAP", "EFI_IFR_ORDERED_LIST",
"EFI_IFR_VARSTORE", "EFI_IFR_VARSTORE_NAME_VALUE", "EFI_IFR_VARSTORE_EFI", "EFI_IFR_VARSTORE_DEVICE", "EFI_IFR_VERSION", "EFI_IFR_END",
"EFI_IFR_MATCH", "EFI_IFR_GET", "EFI_IFR_SET", "EFI_IFR_READ", "EFI_IFR_WRITE", "EFI_IFR_EQUAL",
"EFI_IFR_NOT_EQUAL", "EFI_IFR_GREATER_THAN", "EFI_IFR_GREATER_EQUAL", "EFI_IFR_LESS_THAN", "EFI_IFR_LESS_EQUAL", "EFI_IFR_BITWISE_AND",
"EFI_IFR_BITWISE_OR", "EFI_IFR_BITWISE_NOT", "EFI_IFR_SHIFT_LEFT", "EFI_IFR_SHIFT_RIGHT", "EFI_IFR_ADD", "EFI_IFR_SUBTRACT",
"EFI_IFR_MULTIPLY", "EFI_IFR_DIVIDE", "EFI_IFR_MODULO", "EFI_IFR_RULE_REF", "EFI_IFR_QUESTION_REF1", "EFI_IFR_QUESTION_REF2",
"EFI_IFR_UINT8", "EFI_IFR_UINT16", "EFI_IFR_UINT32", "EFI_IFR_UINT64", "EFI_IFR_TRUE", "EFI_IFR_FALSE",
"EFI_IFR_TO_UINT", "EFI_IFR_TO_STRING", "EFI_IFR_TO_BOOLEAN", "EFI_IFR_MID", "EFI_IFR_FIND", "EFI_IFR_TOKEN",
"EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2", "EFI_IFR_CONDITIONAL", "EFI_IFR_QUESTION_REF3", "EFI_IFR_ZERO", "EFI_IFR_ONE",
"EFI_IFR_ONES", "EFI_IFR_UNDEFINED", "EFI_IFR_LENGTH", "EFI_IFR_DUP", "EFI_IFR_THIS", "EFI_IFR_SPAN",
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_FORM_MAP", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
"EFI_IFR_SECURITY", "EFI_IFR_MODAL_TAG", "EFI_IFR_REFRESH_ID", "EFI_IFR_WARNING_IF",
};
VOID
CIFROBJ_DEBUG_PRINT (
IN UINT8 OpCode
)
{
printf ("======Create IFR [%s]\n", gIfrObjPrintDebugTable[OpCode].mIfrName);
}
#else
#define CIFROBJ_DEBUG_PRINT(OpCode)
#endif
BOOLEAN gCreateOp = TRUE;
CIfrObj::CIfrObj (
IN UINT8 OpCode,
OUT CHAR8 **IfrObj,
IN UINT8 ObjBinLen,
IN BOOLEAN DelayEmit
)
{
mDelayEmit = DelayEmit;
mPkgOffset = gCFormPkg.GetPkgLength ();
mObjBinLen = (ObjBinLen == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : ObjBinLen;
mObjBinBuf = ((DelayEmit == FALSE) && (gCreateOp == TRUE)) ? gCFormPkg.IfrBinBufferGet (mObjBinLen) : new CHAR8[EFI_IFR_MAX_LENGTH];
mRecordIdx = (gCreateOp == TRUE) ? gCIfrRecordInfoDB.IfrRecordRegister (0xFFFFFFFF, mObjBinBuf, mObjBinLen, mPkgOffset) : EFI_IFR_RECORDINFO_IDX_INVALUD;
if (IfrObj != NULL) {
*IfrObj = mObjBinBuf;
}
CIFROBJ_DEBUG_PRINT (OpCode);
}
CIfrObj::~CIfrObj (
VOID
)
{
if ((mDelayEmit == TRUE) && ((gCreateOp == TRUE))) {
_EMIT_PENDING_OBJ ();
}
gCIfrRecordInfoDB.IfrRecordInfoUpdate (mRecordIdx, mLineNo, mObjBinBuf, mObjBinLen, mPkgOffset);
}
/*
* The definition of CIfrObj's member function
*/
UINT8 gScopeCount = 0;
CIfrOpHeader::CIfrOpHeader (
IN UINT8 OpCode,
IN VOID *StartAddr,
IN UINT8 Length
) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
{
mHeader->OpCode = OpCode;
mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;
mHeader->Scope = (gOpcodeSizesScopeTable[OpCode].mScope + gScopeCount > 0) ? 1 : 0;
}
CIfrOpHeader::CIfrOpHeader (
IN CIfrOpHeader &OpHdr
)
{
mHeader = OpHdr.mHeader;
}
UINT32 CIfrFormId::FormIdBitMap[EFI_FREE_FORM_ID_BITMAP_SIZE] = {0, };
|