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
|
/** @file
AML Lib.
Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef AML_LIB_H_
#define AML_LIB_H_
/**
@mainpage Dynamic AML Generation
@{
@par Summary
@{
ACPI tables are categorized as data tables and definition block
tables. Dynamic Tables Framework currently supports generation of ACPI
data tables. Generation of definition block tables is difficult as these
tables are encoded in ACPI Machine Language (AML), which has a complex
grammar.
Dynamic AML Generation is an extension to the Dynamic tables Framework.
One of the techniques used to simplify definition block generation is to
fixup a template SSDT table.
Dynamic AML aims to provide a framework that allows fixing up of an ACPI
SSDT template with appropriate information about the hardware.
This framework consists of an:
- AMLLib core that implements a rich set of interfaces to parse, traverse
and update AML data.
- AMLLib library APIs that provides interfaces to search and updates nodes
in the AML namespace.
@}
@}
*/
#include <AmlCpcInfo.h>
#include <IndustryStandard/Acpi.h>
#ifndef AML_HANDLE
/** Node handle.
*/
typedef void *AML_NODE_HANDLE;
/** Root Node handle.
*/
typedef void *AML_ROOT_NODE_HANDLE;
/** Object Node handle.
*/
typedef void *AML_OBJECT_NODE_HANDLE;
/** Data Node handle.
*/
typedef void *AML_DATA_NODE_HANDLE;
#endif // AML_HANDLE
/** Memory attributes, _MEM (2 bits)
Possible values are:
0-The memory is non-cacheable
1-The memory is cacheable (DEPRECATED)
2-The memory is cacheable and supports
write combining (DEPRECATED)
3-The memory is cacheable and prefetchable
@par Reference(s):
- ACPI 6.5, s6.4.3.5.5 "Resource Type Specific Flags"
**/
typedef enum {
AmlMemoryNonCacheable = 0,
AmlMemoryCacheable = 1,
AmlMemoryCacheableWriteCombine = 2,
AmlMemoryCacheablePrefetch = 3,
AmlMemoryCacheablityMax = 4
} AML_MEMORY_ATTRIBUTES_MEM;
/** Memory attributes, _MTP (2 bits)
Possible values are:
0-AddressRangeMemory
1-AddressRangeReserved
2-AddressRangeACPI
3-AddressRangeNVS
@par Reference(s):
- ACPI 6.5, s6.4.3.5.5 "Resource Type Specific Flags"
**/
typedef enum {
AmlAddressRangeMemory = 0,
AmlAddressRangeReserved = 1,
AmlAddressRangeACPI = 2,
AmlAddressRangeNVS = 3,
AmlAddressRangeMax = 4
} AML_MEMORY_ATTRIBUTES_MTP;
/** Parse the definition block.
The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
header and then parses the AML bytestream.
A tree structure is returned via the RootPtr.
The tree must be deleted with the AmlDeleteTree function.
@ingroup UserApis
@param [in] DefinitionBlock Pointer to the definition block.
@param [out] RootPtr Pointer to the root node of the AML tree.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_BUFFER_TOO_SMALL No space left in the buffer.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlParseDefinitionBlock (
IN CONST EFI_ACPI_DESCRIPTION_HEADER *DefinitionBlock,
OUT AML_ROOT_NODE_HANDLE *RootPtr
);
/** Serialize an AML definition block.
This functions allocates memory with the "AllocateZeroPool ()"
function. This memory is used to serialize the AML tree and is
returned in the Table.
@ingroup UserApis
@param [in] RootNode Root node of the tree.
@param [out] Table On return, hold the serialized
definition block.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlSerializeDefinitionBlock (
IN AML_ROOT_NODE_HANDLE RootNode,
OUT EFI_ACPI_DESCRIPTION_HEADER **Table
);
/** Clone a node and its children (clone a tree branch).
The cloned branch returned is not attached to any tree.
@ingroup UserApis
@param [in] Node Pointer to a node.
Node is the head of the branch to clone.
@param [out] ClonedNode Pointer holding the head of the created cloned
branch.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCloneTree (
IN AML_NODE_HANDLE Node,
OUT AML_NODE_HANDLE *ClonedNode
);
/** Delete a Node and its children.
The Node must be removed from the tree first,
or must be the root node.
@ingroup UserApis
@param [in] Node Pointer to the node to delete.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlDeleteTree (
IN AML_NODE_HANDLE Node
);
/** Detach the Node from the tree.
The function will fail if the Node is in its parent's fixed
argument list.
The Node is not deleted. The deletion is done separately
from the removal.
@ingroup UserApis
@param [in] Node Pointer to a Node.
Must be a data node or an object node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlDetachNode (
IN AML_NODE_HANDLE Node
);
/** Attach a node in an AML tree.
The node will be added as the last statement of the ParentNode.
E.g.:
ASL code corresponding to NewNode:
Name (_UID, 0)
ASL code corresponding to ParentNode:
Device (PCI0) {
Name(_HID, EISAID("PNP0A08"))
}
"AmlAttachNode (ParentNode, NewNode)" will result in:
ASL code:
Device (PCI0) {
Name(_HID, EISAID("PNP0A08"))
Name (_UID, 0)
}
@param [in] ParentNode Pointer to the parent node.
Must be a root or an object node.
@param [in] NewNode Pointer to the node to add.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlAttachNode (
IN AML_NODE_HANDLE ParentNode,
IN AML_NODE_HANDLE NewNode
);
/** Find a node in the AML namespace, given an ASL path and a reference Node.
- The AslPath can be an absolute path, or a relative path from the
reference Node;
- Node must be a root node or a namespace node;
- A root node is expected to be at the top of the tree.
E.g.:
For the following AML namespace, with the ReferenceNode being the node with
the name "AAAA":
- the node with the name "BBBB" can be found by looking for the ASL
path "BBBB";
- the root node can be found by looking for the ASL relative path "^",
or the absolute path "\\".
AML namespace:
\
\-AAAA <- ReferenceNode
\-BBBB
@ingroup NameSpaceApis
@param [in] ReferenceNode Reference node.
If a relative path is given, the
search is done from this node. If
an absolute path is given, the
search is done from the root node.
Must be a root node or an object
node which is part of the
namespace.
@param [in] AslPath ASL path to the searched node in
the namespace. An ASL path name is
NULL terminated. Can be a relative
or absolute path.
E.g.: "\\_SB.CLU0.CPU0" or "^CPU0"
@param [out] OutNode Pointer to the found node.
Contains NULL if not found.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_BUFFER_TOO_SMALL No space left in the buffer.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Out of memory.
**/
EFI_STATUS
EFIAPI
AmlFindNode (
IN AML_NODE_HANDLE ReferenceNode,
IN CHAR8 *AslPath,
OUT AML_NODE_HANDLE *OutNode
);
/**
@defgroup UserApis User APIs
@{
User APIs are implemented to ease most common actions that might be done
using the AmlLib. They allow to find specific objects like "_UID" or
"_CRS" and to update their value. It also shows what can be done using
AmlLib functions.
@}
*/
/** Update the name of a DeviceOp object node.
@ingroup UserApis
@param [in] DeviceOpNode Object node representing a Device.
Must have an OpCode=AML_NAME_OP, SubOpCode=0.
OpCode/SubOpCode.
DeviceOp object nodes are defined in ASL
using the "Device ()" function.
@param [in] NewNameString The new Device's name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlDeviceOpUpdateName (
IN AML_OBJECT_NODE_HANDLE DeviceOpNode,
IN CHAR8 *NewNameString
);
/** Update an integer value defined by a NameOp object node.
For compatibility reasons, the NameOpNode must initially
contain an integer.
@ingroup UserApis
@param [in] NameOpNode NameOp object node.
Must have an OpCode=AML_NAME_OP, SubOpCode=0.
NameOp object nodes are defined in ASL
using the "Name ()" function.
@param [in] NewInt New Integer value to assign.
Must be a UINT64.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlNameOpUpdateInteger (
IN AML_OBJECT_NODE_HANDLE NameOpNode,
IN UINT64 NewInt
);
/** Update a string value defined by a NameOp object node.
The NameOpNode must initially contain a string.
The EISAID ASL macro converts a string to an integer. This, it is
not accepted.
@ingroup UserApis
@param [in] NameOpNode NameOp object node.
Must have an OpCode=AML_NAME_OP, SubOpCode=0.
NameOp object nodes are defined in ASL
using the "Name ()" function.
@param [in] NewName New NULL terminated string to assign to
the NameOpNode.
The input string is copied.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlNameOpUpdateString (
IN AML_OBJECT_NODE_HANDLE NameOpNode,
IN CONST CHAR8 *NewName
);
/** Get the first Resource Data element contained in a named object.
In the following ASL code, the function will return the Resource Data
node corresponding to the "QWordMemory ()" ASL macro.
Name (_CRS, ResourceTemplate() {
QWordMemory (...) {...},
Interrupt (...) {...}
}
)
Note:
"_CRS" names defined as methods are not handled by this function.
They must be defined as names, using the "Name ()" statement.
@ingroup UserApis
@param [in] NameOpNode NameOp object node defining a named object.
Must have an OpCode=AML_NAME_OP, SubOpCode=0.
NameOp object nodes are defined in ASL
using the "Name ()" function.
@param [out] OutRdNode Pointer to the first Resource Data element of
the named object. A Resource Data element
is stored in a data node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlNameOpGetFirstRdNode (
IN AML_OBJECT_NODE_HANDLE NameOpNode,
OUT AML_DATA_NODE_HANDLE *OutRdNode
);
/** Get the Resource Data element following the CurrRdNode Resource Data.
In the following ASL code, if CurrRdNode corresponds to the first
"QWordMemory ()" ASL macro, the function will return the Resource Data
node corresponding to the "Interrupt ()" ASL macro.
Name (_CRS, ResourceTemplate() {
QwordMemory (...) {...},
Interrupt (...) {...}
}
)
Note:
"_CRS" names defined as methods are not handled by this function.
They must be defined as names, using the "Name ()" statement.
@ingroup UserApis
@param [in] CurrRdNode Pointer to the current Resource Data element of
the named object.
@param [out] OutRdNode Pointer to the Resource Data element following
the CurrRdNode.
Contain a NULL pointer if CurrRdNode is the
last Resource Data element in the list.
The "End Tag" is not considered as a resource
data element and is not returned.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlNameOpGetNextRdNode (
IN AML_DATA_NODE_HANDLE CurrRdNode,
OUT AML_DATA_NODE_HANDLE *OutRdNode
);
/** Update the first interrupt of an Interrupt resource data node.
The flags of the Interrupt resource data are left unchanged.
The InterruptRdNode corresponds to the Resource Data created by the
"Interrupt ()" ASL macro. It is an Extended Interrupt Resource Data.
See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor"
for more information about Extended Interrupt Resource Data.
@ingroup UserApis
@param [in] InterruptRdNode Pointer to the an extended interrupt
resource data node.
@param [in] Irq Interrupt value to update.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Out of resources.
**/
EFI_STATUS
EFIAPI
AmlUpdateRdInterrupt (
IN AML_DATA_NODE_HANDLE InterruptRdNode,
IN UINT32 Irq
);
/** Update the base address and length of a QWord resource data node.
@ingroup UserApis
@param [in] QWordRdNode Pointer a QWord resource data
node.
@param [in] BaseAddress Base address.
@param [in] BaseAddressLength Base address length.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Out of resources.
**/
EFI_STATUS
EFIAPI
AmlUpdateRdQWord (
IN AML_DATA_NODE_HANDLE QWordRdNode,
IN UINT64 BaseAddress,
IN UINT64 BaseAddressLength
);
/** Code generation for the "DWordIO ()" ASL function.
The Resource Data effectively created is a DWord Address Space Resource
Data. Cf ACPI 6.4:
- s6.4.3.5.2 "DWord Address Space Descriptor".
- s19.6.34 "DWordIO".
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
See ACPI 6.4 spec, s19.6.34 for more.
@param [in] IsResourceConsumer ResourceUsage parameter.
@param [in] IsMinFixed Minimum address is fixed.
@param [in] IsMaxFixed Maximum address is fixed.
@param [in] IsPosDecode Decode parameter
@param [in] IsaRanges Possible values are:
0-Reserved
1-NonISAOnly
2-ISAOnly
3-EntireRange
@param [in] AddressGranularity Address granularity.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] AddressTranslation Address translation.
@param [in] RangeLength Range length.
@param [in] ResourceSourceIndex Resource Source index.
Not supported. Must be 0.
@param [in] ResourceSource Resource Source.
Not supported. Must be NULL.
@param [in] IsDenseTranslation TranslationDensity parameter.
@param [in] IsTypeStatic TranslationType parameter.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdDWordIo (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
IN UINT8 IsaRanges,
IN UINT32 AddressGranularity,
IN UINT32 AddressMinimum,
IN UINT32 AddressMaximum,
IN UINT32 AddressTranslation,
IN UINT32 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN BOOLEAN IsDenseTranslation,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "DWordMemory ()" ASL function.
The Resource Data effectively created is a DWord Address Space Resource
Data. Cf ACPI 6.4:
- s6.4.3.5.2 "DWord Address Space Descriptor".
- s19.6.35 "DWordMemory".
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
See ACPI 6.4 spec, s19.6.35 for more.
@param [in] IsResourceConsumer ResourceUsage parameter.
@param [in] IsPosDecode Decode parameter
@param [in] IsMinFixed Minimum address is fixed.
@param [in] IsMaxFixed Maximum address is fixed.
@param [in] Cacheable Possible values are:
0-The memory is non-cacheable
1-The memory is cacheable
2-The memory is cacheable and supports
write combining
3-The memory is cacheable and prefetchable
@param [in] IsReadWrite ReadAndWrite parameter.
@param [in] AddressGranularity Address granularity.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] AddressTranslation Address translation.
@param [in] RangeLength Range length.
@param [in] ResourceSourceIndex Resource Source index.
Not supported. Must be 0.
@param [in] ResourceSource Resource Source.
Not supported. Must be NULL.
@param [in] MemoryRangeType Possible values are:
0-AddressRangeMemory
1-AddressRangeReserved
2-AddressRangeACPI
3-AddressRangeNVS
@param [in] IsTypeStatic TranslationType parameter.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdDWordMemory (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT32 AddressGranularity,
IN UINT32 AddressMinimum,
IN UINT32 AddressMaximum,
IN UINT32 AddressTranslation,
IN UINT32 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "Memory32Fixed ()" ASL macro.
The Resource Data effectively created is a 32-bit Memory Resource
Data. Cf ACPI 6.4:
- s19.6.83 "Memory Resource Descriptor Macro".
- s19.2.8 "Memory32FixedTerm".
See ACPI 6.4 spec, s19.2.8 for more.
@param [in] IsReadWrite ReadAndWrite parameter.
@param [in] Address AddressBase parameter.
@param [in] RangeLength Range length.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewMemNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdMemory32Fixed (
BOOLEAN IsReadWrite,
UINT32 Address,
UINT32 RangeLength,
AML_OBJECT_NODE_HANDLE NameOpNode,
AML_DATA_NODE_HANDLE *NewMemNode
);
/** Code generation for the "WordBusNumber ()" ASL function.
The Resource Data effectively created is a Word Address Space Resource
Data. Cf ACPI 6.4:
- s6.4.3.5.3 "Word Address Space Descriptor".
- s19.6.149 "WordBusNumber".
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
See ACPI 6.4 spec, s19.6.149 for more.
@param [in] IsResourceConsumer ResourceUsage parameter.
@param [in] IsMinFixed Minimum address is fixed.
@param [in] IsMaxFixed Maximum address is fixed.
@param [in] IsPosDecode Decode parameter
@param [in] AddressGranularity Address granularity.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] AddressTranslation Address translation.
@param [in] RangeLength Range length.
@param [in] ResourceSourceIndex Resource Source index.
Not supported. Must be 0.
@param [in] ResourceSource Resource Source.
Not supported. Must be NULL.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdWordBusNumber (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
IN UINT32 AddressGranularity,
IN UINT32 AddressMinimum,
IN UINT32 AddressMaximum,
IN UINT32 AddressTranslation,
IN UINT32 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "QWordIO ()" ASL function.
The Resource Data effectively created is a QWord Address Space Resource
Data. Cf ACPI 6.4:
- s6.4.3.5.1 "QWord Address Space Descriptor".
- s19.6.109 "QWordIO".
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
See ACPI 6.4 spec, s19.6.109 for more.
@param [in] IsResourceConsumer ResourceUsage parameter.
@param [in] IsMinFixed Minimum address is fixed.
@param [in] IsMaxFixed Maximum address is fixed.
@param [in] IsPosDecode Decode parameter
@param [in] IsaRanges Possible values are:
0-Reserved
1-NonISAOnly
2-ISAOnly
3-EntireRange
@param [in] AddressGranularity Address granularity.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] AddressTranslation Address translation.
@param [in] RangeLength Range length.
@param [in] ResourceSourceIndex Resource Source index.
Unused. Must be 0.
@param [in] ResourceSource Resource Source.
Unused. Must be NULL.
@param [in] IsDenseTranslation TranslationDensity parameter.
@param [in] IsTypeStatic TranslationType parameter.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdQWordIo (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
IN UINT8 IsaRanges,
IN UINT64 AddressGranularity,
IN UINT64 AddressMinimum,
IN UINT64 AddressMaximum,
IN UINT64 AddressTranslation,
IN UINT64 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN BOOLEAN IsDenseTranslation,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "QWordMemory ()" ASL function.
The Resource Data effectively created is a QWord Address Space Resource
Data. Cf ACPI 6.4:
- s6.4.3.5.1 "QWord Address Space Descriptor".
- s19.6.110 "QWordMemory".
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
See ACPI 6.4 spec, s19.6.110 for more.
@param [in] IsResourceConsumer ResourceUsage parameter.
@param [in] IsPosDecode Decode parameter.
@param [in] IsMinFixed Minimum address is fixed.
@param [in] IsMaxFixed Maximum address is fixed.
@param [in] Cacheable Possible values are:
0-The memory is non-cacheable
1-The memory is cacheable
2-The memory is cacheable and supports
write combining
3-The memory is cacheable and prefetchable
@param [in] IsReadWrite ReadAndWrite parameter.
@param [in] AddressGranularity Address granularity.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] AddressTranslation Address translation.
@param [in] RangeLength Range length.
@param [in] ResourceSourceIndex Resource Source index.
Not supported. Must be 0.
@param [in] ResourceSource Resource Source.
Not supported. Must be NULL.
@param [in] MemoryRangeType Possible values are:
0-AddressRangeMemory
1-AddressRangeReserved
2-AddressRangeACPI
3-AddressRangeNVS
@param [in] IsTypeStatic TranslationType parameter.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data
node to the list of resource data elements
of this node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdQWordMemory (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsPosDecode,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN AML_MEMORY_ATTRIBUTES_MEM Cacheable,
IN BOOLEAN IsReadWrite,
IN UINT64 AddressGranularity,
IN UINT64 AddressMinimum,
IN UINT64 AddressMaximum,
IN UINT64 AddressTranslation,
IN UINT64 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType,
IN BOOLEAN IsTypeStatic,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "Interrupt ()" ASL function.
The Resource Data effectively created is an Extended Interrupt Resource
Data. Cf ACPI 6.4:
- s6.4.3.6 "Extended Interrupt Descriptor"
- s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)"
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
@ingroup CodeGenApis
@param [in] ResourceConsumer The device consumes the specified interrupt
or produces it for use by a child device.
@param [in] EdgeTriggered The interrupt is edge triggered or
level triggered.
@param [in] ActiveLow The interrupt is active-high or active-low.
@param [in] Shared The interrupt can be shared with other
devices or not (Exclusive).
@param [in] IrqList Interrupt list. Must be non-NULL.
@param [in] IrqCount Interrupt count. Must be non-zero.
@param [in] NameOpNode NameOp object node defining a named object.
If provided, append the new resource data node
to the list of resource data elements of this
node.
@param [out] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Could not allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdInterrupt (
IN BOOLEAN ResourceConsumer,
IN BOOLEAN EdgeTriggered,
IN BOOLEAN ActiveLow,
IN BOOLEAN Shared,
IN UINT32 *IrqList,
IN UINT8 IrqCount,
IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL,
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** AML code generation for DefinitionBlock.
Create a Root Node handle.
It is the caller's responsibility to free the allocated memory
with the AmlDeleteTree function.
AmlCodeGenDefinitionBlock (TableSignature, OemId, TableID, OEMRevision) is
equivalent to the following ASL code:
DefinitionBlock (AMLFileName, TableSignature, ComplianceRevision,
OemId, TableID, OEMRevision) {}
with the ComplianceRevision set to 2 and the AMLFileName is ignored.
@ingroup CodeGenApis
@param[in] TableSignature 4-character ACPI signature.
Must be 'DSDT' or 'SSDT'.
@param[in] OemId 6-character string OEM identifier.
@param[in] OemTableId 8-character string OEM table identifier.
@param[in] OemRevision OEM revision number.
@param[out] DefinitionBlockTerm The ASL Term handle representing a
Definition Block.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenDefinitionBlock (
IN CONST CHAR8 *TableSignature,
IN CONST CHAR8 *OemId,
IN CONST CHAR8 *OemTableId,
IN UINT32 OemRevision,
OUT AML_ROOT_NODE_HANDLE *NewRootNode
);
/** AML code generation for a Name object node, containing a String.
AmlCodeGenNameString ("_HID", "HID0000", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Name(_HID, "HID0000")
@ingroup CodeGenApis
@param [in] NameString The new variable name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] String NULL terminated String to associate to the
NameString.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNameString (
IN CONST CHAR8 *NameString,
IN CHAR8 *String,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Name object node, containing an Integer.
AmlCodeGenNameInteger ("_UID", 1, ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Name(_UID, One)
@ingroup CodeGenApis
@param [in] NameString The new variable name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] Integer Integer to associate to the NameString.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNameInteger (
IN CONST CHAR8 *NameString,
IN UINT64 Integer,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Name object node, containing a Package.
AmlCodeGenNamePackage ("PKG0", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Name(PKG0, Package () {})
@ingroup CodeGenApis
@param [in] NameString The new variable name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNamePackage (
IN CONST CHAR8 *NameString,
IN AML_NODE_HANDLE ParentNode, OPTIONAL
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Name object node, containing a ResourceTemplate.
AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Name(PRS0, ResourceTemplate () {})
@ingroup CodeGenApis
@param [in] NameString The new variable name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNameResourceTemplate (
IN CONST CHAR8 *NameString,
IN AML_NODE_HANDLE ParentNode, OPTIONAL
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Name object node, containing a String.
AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Name(_STR, Unicode ("String"))
@ingroup CodeGenApis
@param [in] NameString The new variable name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] String NULL terminated Unicode String to associate to the
NameString.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNameUnicodeString (
IN CONST CHAR8 *NameString,
IN CHAR16 *String,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** Add a _PRT entry.
AmlCodeGenPrtEntry (0x0FFFF, 0, "LNKA", 0, PrtNameNode) is
equivalent of the following ASL code:
Package (4) {
0x0FFFF, // Address: Device address (([Device Id] << 16) | 0xFFFF).
0, // Pin: PCI pin number of the device (0-INTA, ...).
LNKA // Source: Name of the device that allocates the interrupt
// to which the above pin is connected.
0 // Source Index: Source is assumed to only describe one
// interrupt, so let it to index 0.
}
The package is added at the tail of the list of the input _PRT node
name:
Name (_PRT, Package () {
[Pre-existing _PRT entries],
[Newly created _PRT entry]
})
Cf. ACPI 6.4, s6.2.13 "_PRT (PCI Routing Table)"
@ingroup CodeGenApis
@param [in] Address Address. Cf ACPI 6.4 specification, Table 6.2:
"ADR Object Address Encodings":
High word-Device #, Low word-Function #. (for
example, device 3, function 2 is 0x00030002).
To refer to all the functions on a device #,
use a function number of FFFF).
@param [in] Pin PCI pin number of the device (0-INTA ... 3-INTD).
Must be between 0-3.
@param [in] LinkName Link Name, i.e. device in the AML NameSpace
describing the interrupt used.
The input string is copied.
@param [in] SourceIndex Source index or GSIV.
@param [in] PrtNameNode Prt Named node to add the object to ....
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlAddPrtEntry (
IN UINT32 Address,
IN UINT8 Pin,
IN CONST CHAR8 *LinkName,
IN UINT32 SourceIndex,
IN AML_OBJECT_NODE_HANDLE PrtNameNode
);
/** AML code generation for a Device object node.
AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Device(COM0) {}
@ingroup CodeGenApis
@param [in] NameString The new Device's name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenDevice (
IN CONST CHAR8 *NameString,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a ThermalZone object node.
AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
ThermalZone(TZ00) {}
@ingroup CodeGenApis
@param [in] NameString The new ThermalZone's name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenThermalZone (
IN CONST CHAR8 *NameString,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Scope object node.
AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Scope(_SB) {}
@ingroup CodeGenApis
@param [in] NameString The new Scope's name.
Must be a NULL-terminated ASL NameString
e.g.: "DEV0", "DV15.DEV0", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenScope (
IN CONST CHAR8 *NameString,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a method returning a NameString.
AmlCodeGenMethodRetNameString (
"MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode
);
is equivalent of the following ASL code:
Method(MET0, 1, Serialized, 3) {
Return (_CRS)
}
The ASL parameters "ReturnType" and "ParameterTypes" are not asked
in this function. They are optional parameters in ASL.
@ingroup CodeGenApis
@param [in] MethodNameString The new Method's name.
Must be a NULL-terminated ASL NameString
e.g.: "MET0", "_SB.MET0", etc.
The input string is copied.
@param [in] ReturnedNameString The name of the object returned by the
method. Optional parameter, can be:
- NULL (ignored).
- A NULL-terminated ASL NameString.
e.g.: "MET0", "_SB.MET0", etc.
The input string is copied.
@param [in] NumArgs Number of arguments.
Must be 0 <= NumArgs <= 6.
@param [in] IsSerialized TRUE is equivalent to Serialized.
FALSE is equivalent to NotSerialized.
Default is NotSerialized in ASL spec.
@param [in] SyncLevel Synchronization level for the method.
Must be 0 <= SyncLevel <= 15.
Default is 0 in ASL.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenMethodRetNameString (
IN CONST CHAR8 *MethodNameString,
IN CONST CHAR8 *ReturnedNameString OPTIONAL,
IN UINT8 NumArgs,
IN BOOLEAN IsSerialized,
IN UINT8 SyncLevel,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a method returning an Integer.
AmlCodeGenMethodRetInteger (
"_CBA", 0, 1, TRUE, 3, ParentNode, NewObjectNode
);
is equivalent of the following ASL code:
Method(_CBA, 1, Serialized, 3) {
Return (0)
}
The ASL parameters "ReturnType" and "ParameterTypes" are not asked
in this function. They are optional parameters in ASL.
@param [in] MethodNameString The new Method's name.
Must be a NULL-terminated ASL NameString
e.g.: "MET0", "_SB.MET0", etc.
The input string is copied.
@param [in] ReturnedInteger The value of the integer returned by the
method.
@param [in] NumArgs Number of arguments.
Must be 0 <= NumArgs <= 6.
@param [in] IsSerialized TRUE is equivalent to Serialized.
FALSE is equivalent to NotSerialized.
Default is NotSerialized in ASL spec.
@param [in] SyncLevel Synchronization level for the method.
Must be 0 <= SyncLevel <= 15.
Default is 0 in ASL.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenMethodRetInteger (
IN CONST CHAR8 *MethodNameString,
IN UINT64 ReturnedInteger,
IN UINT8 NumArgs,
IN BOOLEAN IsSerialized,
IN UINT8 SyncLevel,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a method returning a NameString that takes an
integer argument.
AmlCodeGenMethodRetNameStringIntegerArgument (
"MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode
);
is equivalent of the following ASL code:
Method(MET0, 1, Serialized, 3) {
Return (MET1 (5))
}
The ASL parameters "ReturnType" and "ParameterTypes" are not asked
in this function. They are optional parameters in ASL.
@param [in] MethodNameString The new Method's name.
Must be a NULL-terminated ASL NameString
e.g.: "MET0", "_SB.MET0", etc.
The input string is copied.
@param [in] ReturnedNameString The name of the object returned by the
method. Optional parameter, can be:
- NULL (ignored).
- A NULL-terminated ASL NameString.
e.g.: "MET0", "_SB.MET0", etc.
The input string is copied.
@param [in] NumArgs Number of arguments.
Must be 0 <= NumArgs <= 6.
@param [in] IsSerialized TRUE is equivalent to Serialized.
FALSE is equivalent to NotSerialized.
Default is NotSerialized in ASL spec.
@param [in] SyncLevel Synchronization level for the method.
Must be 0 <= SyncLevel <= 15.
Default is 0 in ASL.
@param [in] IntegerArgument Argument to pass to the NameString.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCodeGenMethodRetNameStringIntegerArgument (
IN CONST CHAR8 *MethodNameString,
IN CONST CHAR8 *ReturnedNameString OPTIONAL,
IN UINT8 NumArgs,
IN BOOLEAN IsSerialized,
IN UINT8 SyncLevel,
IN UINT64 IntegerArgument,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** Create a _LPI name.
AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is
equivalent of the following ASL code:
Name (_LPI, Package (
0, // Revision
1, // LevelId
0 // Count
))
This function doesn't define any LPI state. As shown above, the count
of _LPI state is set to 0.
The AmlAddLpiState () function must be used to add LPI states.
Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".
@ingroup CodeGenApis
@param [in] LpiNameString The new LPI 's object name.
Must be a NULL-terminated ASL NameString
e.g.: "_LPI", "DEV0.PLPI", etc.
The input string is copied.
@param [in] Revision Revision number of the _LPI states.
@param [in] LevelId A platform defined number that identifies the
level of hierarchy of the processor node to
which the LPI states apply.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewLpiNode If success, contains the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCreateLpiNode (
IN CONST CHAR8 *LpiNameString,
IN UINT16 Revision,
IN UINT64 LevelId,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewLpiNode OPTIONAL
);
/** Add an _LPI state to a LPI node created using AmlCreateLpiNode ().
AmlAddLpiState () increments the Count of LPI states in the LPI node by one,
and adds the following package:
Package() {
MinResidency,
WorstCaseWakeLatency,
Flags,
ArchFlags,
ResCntFreq,
EnableParentState,
(GenericRegisterDescriptor != NULL) ? // Entry method. If a
ResourceTemplate(GenericRegisterDescriptor) : // Register is given,
Integer, // use it. Use the
// Integer otherwise.
ResourceTemplate() { // NULL Residency Counter
Register (SystemMemory, 0, 0, 0, 0)
},
ResourceTemplate() { // NULL Usage Counter
Register (SystemMemory, 0, 0, 0, 0)
},
"" // NULL State Name
},
Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".
@ingroup CodeGenApis
@param [in] MinResidency Minimum Residency.
@param [in] WorstCaseWakeLatency Worst case wake-up latency.
@param [in] Flags Flags.
@param [in] ArchFlags Architectural flags.
@param [in] ResCntFreq Residency Counter Frequency.
@param [in] EnableParentState Enabled Parent State.
@param [in] GenericRegisterDescriptor Entry Method.
If not NULL, use this Register to
describe the entry method address.
@param [in] Integer Entry Method.
If GenericRegisterDescriptor is NULL,
take this value.
@param [in] ResidencyCounterRegister If not NULL, use it to populate the
residency counter register.
@param [in] UsageCounterRegister If not NULL, use it to populate the
usage counter register.
@param [in] StateName If not NULL, use it to populate the
state name.
@param [in] LpiNode Lpi node created with the function
AmlCreateLpiNode to which the new LPI
state is appended.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlAddLpiState (
IN UINT32 MinResidency,
IN UINT32 WorstCaseWakeLatency,
IN UINT32 Flags,
IN UINT32 ArchFlags,
IN UINT32 ResCntFreq,
IN UINT32 EnableParentState,
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *GenericRegisterDescriptor OPTIONAL,
IN UINT64 Integer OPTIONAL,
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *ResidencyCounterRegister OPTIONAL,
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *UsageCounterRegister OPTIONAL,
IN CHAR8 *StateName OPTIONAL,
IN AML_OBJECT_NODE_HANDLE LpiNode
);
/** AML code generation for a _DSD device data object.
AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is
equivalent of the following ASL code:
ToUUID(Uuid),
Package () {}
Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".
_DSD (Device Specific Data) Implementation Guide
https://github.com/UEFI/DSD-Guide
Per s3. "'Well-Known _DSD UUIDs and Data Structure Formats'"
If creating a Device Properties data then UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 should be used.
@param [in] Uuid The Uuid of the descriptor to be created
@param [in] DsdNode Node of the DSD Package.
@param [out] PackageNode If success, contains the created package node.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlAddDeviceDataDescriptorPackage (
IN CONST EFI_GUID *Uuid,
IN AML_OBJECT_NODE_HANDLE DsdNode,
OUT AML_OBJECT_NODE_HANDLE *PackageNode
);
/** AML code generation to add a package with a name and value,
to a parent package.
This is useful to build the _DSD package but can be used in other cases.
AmlAddNameIntegerPackage ("Name", Value, PackageNode) is
equivalent of the following ASL code:
Package (2) {"Name", Value}
Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".
@param [in] Name String to place in first entry of package
@param [in] Value Integer to place in second entry of package
@param [in] PackageNode Package to add new sub package to.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlAddNameIntegerPackage (
IN CHAR8 *Name,
IN UINT64 Value,
IN AML_OBJECT_NODE_HANDLE PackageNode
);
/** Create a _CPC node.
Creates and optionally adds the following node
Name(_CPC, Package()
{
NumEntries, // Integer
Revision, // Integer
HighestPerformance, // Integer or Buffer (Resource Descriptor)
NominalPerformance, // Integer or Buffer (Resource Descriptor)
LowestNonlinearPerformance, // Integer or Buffer (Resource Descriptor)
LowestPerformance, // Integer or Buffer (Resource Descriptor)
GuaranteedPerformanceRegister, // Buffer (Resource Descriptor)
DesiredPerformanceRegister , // Buffer (Resource Descriptor)
MinimumPerformanceRegister , // Buffer (Resource Descriptor)
MaximumPerformanceRegister , // Buffer (Resource Descriptor)
PerformanceReductionToleranceRegister, // Buffer (Resource Descriptor)
TimeWindowRegister, // Buffer (Resource Descriptor)
CounterWraparoundTime, // Integer or Buffer (Resource Descriptor)
ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)
DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)
PerformanceLimitedRegister, // Buffer (Resource Descriptor)
CPPCEnableRegister // Buffer (Resource Descriptor)
AutonomousSelectionEnable, // Integer or Buffer (Resource Descriptor)
AutonomousActivityWindowRegister, // Buffer (Resource Descriptor)
EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)
ReferencePerformance // Integer or Buffer (Resource Descriptor)
LowestFrequency, // Integer or Buffer (Resource Descriptor)
NominalFrequency // Integer or Buffer (Resource Descriptor)
})
If resource buffer is NULL then integer will be used.
Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)
@ingroup CodeGenApis
@param [in] CpcInfo CpcInfo object
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewCpcNode If success and provided, contains the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlCreateCpcNode (
IN AML_CPC_INFO *CpcInfo,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL
);
/** AML code generation to add a NameString to the package in a named node.
@param [in] NameString NameString to add
@param [in] NamedNode Node to add the string to the included package.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
**/
EFI_STATUS
EFIAPI
AmlAddNameStringToNamedPackage (
IN CHAR8 *NameString,
IN AML_OBJECT_NODE_HANDLE NamedNode
);
#endif // AML_LIB_H_
|