1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
|
/** @file
AML Lib.
Copyright (c) 2019 - 2026, Arm Limited. All rights reserved.<BR>
Copyright (C) 2023 - 2026, Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#pragma once
/**
@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 <AcpiObjects.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;
/** Method parameter types
Possible values are:
0 - AmlMethodParamTypeInteger
1 - AmlMethodParamTypeString
2 - AmlMethodParamTypeArg
3 - AmlMethodParamTypeLocal
4 - AmlMethodParamTypeBuffer
@par Reference(s)
- ACPI 6.5, s20.2.5 "Term Objects Encoding"
**/
typedef enum {
AmlMethodParamTypeInteger = 0,
AmlMethodParamTypeString = 1,
AmlMethodParamTypeArg = 2,
AmlMethodParamTypeLocal = 3,
AmlMethodParamTypeBuffer = 4
} AML_METHOD_PARAM_TYPE;
/** AML Method parameter data
holds the AML method parameter data.
**/
typedef union {
UINT8 Arg;
UINT8 Local;
UINT64 Integer;
VOID *Buffer;
} AML_METHOD_PARAM_DATA;
/** AML Field access types. */
typedef enum {
AmlFieldAccessAny = 0,
AmlFieldAccessByte = 1,
AmlFieldAccessWord = 2,
AmlFieldAccessDWord = 3,
AmlFieldAccessQWord = 4,
AmlFieldAccessBuffer = 5
} AML_FIELD_ACCESS_TYPE;
/** AML Field lock rules. */
typedef enum {
AmlFieldNoLock = 0,
AmlFieldLock = 1
} AML_FIELD_LOCK_RULE;
/** AML Field update rules. */
typedef enum {
AmlFieldUpdatePreserve = 0,
AmlFieldUpdateWriteAsOnes = 1,
AmlFieldUpdateWriteAsZeros = 2
} AML_FIELD_UPDATE_RULE;
/** structure to hold AML method parameter types
Type - Type of parameter
Data - holds data of parameter
if Type is AmlMethodParamTypeInteger
then Data is of type Integer to hold integer value.
if Type is AmlMethodParamTypeString
then Data contains null terminated string.
If Type is AmlMethodParamTypeArg
then Data contains the Argument number,
0 to 6 are supported value.
If Type is AmlMethodParamTypeLocal
then Data contains the Local variable number,
0 to 7 are supported value.
If Type is AmlMethodParamTypeBuffer
then Data.Buffer points to a UINT8 byte array and
DataSize holds the byte count of that array.
DataSize - byte count when Type is AmlMethodParamTypeBuffer; unused otherwise.
**/
typedef struct {
AML_METHOD_PARAM_TYPE Type;
AML_METHOD_PARAM_DATA Data;
UINTN DataSize;
} AML_METHOD_PARAM;
/** structure to hold Notify method parameter types.
NotifyObject - Notify Object parameter.
Only NameString, Local and Arg types are supported.
NotifyValue - Notify Value parameter.
Must be an integer value.
**/
typedef struct {
AML_METHOD_PARAM NotifyObject;
UINT8 NotifyValue;
} AML_NOTIFY_PARAM;
/** 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 CONST 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 CONST 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 DWord resource data node.
@ingroup UserApis
@param [in] DWordRdNode Pointer a DWord 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
AmlUpdateRdDWord (
IN AML_DATA_NODE_HANDLE DWordRdNode,
IN UINT32 BaseAddress,
IN UINT32 BaseAddressLength
);
/** Update the base address and length of a Word resource data node.
@ingroup UserApis
@param [in] WordRdNode Pointer a Word 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
AmlUpdateRdWord (
IN AML_DATA_NODE_HANDLE WordRdNode,
IN UINT16 BaseAddress,
IN UINT16 BaseAddressLength
);
/** 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 UINT16 AddressGranularity,
IN UINT16 AddressMinimum,
IN UINT16 AddressMaximum,
IN UINT16 AddressTranslation,
IN UINT16 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 "WordIO ()" ASL function.
The Resource Data effectively created is a Word Address Space Resource
Data. Cf ACPI 6.5:
- s6.4.3.5.3 "Word Address Space Descriptor".
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.
@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
AmlCodeGenRdWordIo (
IN BOOLEAN IsResourceConsumer,
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
IN UINT8 IsaRanges,
IN UINT16 AddressGranularity,
IN UINT16 AddressMinimum,
IN UINT16 AddressMaximum,
IN UINT16 AddressTranslation,
IN UINT16 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 "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
);
/** Code generation for the "IO ()" ASL function.
The Resource Data effectively created is a IO Resource
Data. Cf ACPI 6.5:
- s19.6.65 IO (IO Resource Descriptor Macro)
- s6.4.2.5 I/O Port Descriptor
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.
@param [in] IsDecoder16 Decoder parameter.
TRUE if 16-bit decoder.
FALSE if 10-bit decoder.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] Alignment Alignment.
@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] NewRdNode If provided and success,
contain the created node.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdIo (
IN BOOLEAN IsDecoder16,
IN UINT16 AddressMinimum,
IN UINT16 AddressMaximum,
IN UINT8 Alignment,
IN UINT8 RangeLength,
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 CONST 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 an OperationRegion object node.
AmlCodeGenOperationRegion (
"REG0",
RegionSpace,
RegionOffset,
RegionLength,
ParentNode,
NewObjectNode
);
generates an OperationRegion equivalent to:
OperationRegion (
REG0,
RegionSpace,
RegionOffset,
RegionLength
)
where RegionSpace, RegionOffset, and RegionLength represent the values
supplied to the function.
@ingroup CodeGenApis
@param [in] RegionName Name of the OperationRegion.
Must be a NULL-terminated ASL NameString.
The input string is copied.
@param [in] RegionSpace Address space containing the region.
@param [in] RegionOffset Integer value used as the region offset.
For SystemMemory, this is normally the physical
base address of the region.
@param [in] RegionLength Integer length of the region in bytes.
@param [in] ParentNode Optional parent node to which the OperationRegion
is appended.
@param [out] NewObjectNode Optional pointer that receives the created
OperationRegion node.
@retval EFI_SUCCESS The OperationRegion was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenOperationRegion (
IN CONST CHAR8 *RegionName,
IN UINT8 RegionSpace,
IN UINT64 RegionOffset,
IN UINT64 RegionLength,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for an empty Field object node.
AmlCodeGenField (
"REG0",
AmlFieldAccessDWord,
AmlFieldNoLock,
AmlFieldUpdatePreserve,
ParentNode,
NewObjectNode
);
is equivalent to:
Field (REG0, DWordAcc, NoLock, Preserve)
{
}
Field elements can subsequently be appended to the returned Field node.
@ingroup CodeGenApis
@param [in] RegionName Name of the associated OperationRegion.
Must be a NULL-terminated ASL NameString.
The input string is copied.
@param [in] AccessType Access width used for the Field.
@param [in] LockRule Field locking rule.
@param [in] UpdateRule Field update rule.
@param [in] ParentNode Optional parent node to which the Field is
appended.
@param [out] NewObjectNode Optional pointer that receives the created
Field node.
@retval EFI_SUCCESS The Field was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenField (
IN CONST CHAR8 *RegionName,
IN AML_FIELD_ACCESS_TYPE AccessType,
IN AML_FIELD_LOCK_RULE LockRule,
IN AML_FIELD_UPDATE_RULE UpdateRule,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a ReservedField element (ASL: Offset ()).
AmlCodeGenFieldElemReserved (64, ParentNode, NewObjectNode);
is equivalent to the following ASL code when the current Field position
is zero:
Offset (0x08),
Adds an unnamed reserved range of ReservedBitLength bits to a Field
list.
A ReservedField can be used to implement an ASL Offset() declaration.
The caller is responsible for calculating the number of bits between
the current Field position and the requested byte offset.
@ingroup CodeGenApis
@param [in] ReservedBitLength Number of bits in the reserved range.
@param [in] ParentNode Field node to which the ReservedField is
appended.
@param [out] NewObjectNode Optional pointer that receives the created
ReservedField node.
@retval EFI_SUCCESS The ReservedField was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenFieldElemReserved (
IN UINT32 ReservedBitLength,
IN AML_OBJECT_NODE_HANDLE ParentNode,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a NamedField element.
AmlCodeGenFieldElemNamed (
"FLD0",
32,
ParentNode,
NewObjectNode
);
is equivalent to the following element in an ASL Field declaration:
FLD0, 32
@ingroup CodeGenApis
@param [in] FieldName Name of the field element. This must be a valid
ASL NameSeg containing at most four characters.
The input string is copied.
@param [in] FieldBitLength Length of the field element in bits.
@param [in] ParentNode Field node to which the NamedField is appended.
@param [out] NewObjectNode Optional pointer that receives the created
NamedField node.
@retval EFI_SUCCESS The NamedField was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenFieldElemNamed (
IN CONST CHAR8 *FieldName,
IN UINT32 FieldBitLength,
IN AML_OBJECT_NODE_HANDLE ParentNode,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a Store operation with a typed source and a
named target.
AML_METHOD_PARAM Source;
Source.Type = AmlMethodParamTypeInteger;
Source.Data.Integer = 1;
Source.DataSize = 0;
AmlCodeGenStoreToName (
Source,
"FLD0",
ParentNode,
NewObjectNode
);
is equivalent to:
Store (One, FLD0)
Integer, method argument, and local variable sources are supported.
@ingroup CodeGenApis
@param [in] Source Source operand to store.
@param [in] TargetName NameString identifying the target object.
The input string is copied.
@param [in] ParentNode Optional parent executable statement node.
@param [out] NewObjectNode Optional pointer that receives the created
Store node.
@retval EFI_SUCCESS The Store object was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenStoreToName (
IN AML_METHOD_PARAM Source,
IN CONST CHAR8 *TargetName,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for an If object.
Creates an If object using PredicateNode as its predicate. Additional
executable statements can subsequently be appended to the returned node.
AmlCodeGenIf (
PredicateNode,
ParentNode,
NewObjectNode
);
is equivalent to:
If (Predicate)
{
}
The function takes ownership of PredicateNode.
@ingroup CodeGenApis
@param [in] PredicateNode AML node representing the If predicate.
The node is deleted if an error occurs.
@param [in] ParentNode Optional parent executable statement node.
@param [out] NewObjectNode Optional pointer that receives the created
If node.
@retval EFI_SUCCESS The If object was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenIf (
IN AML_NODE_HANDLE PredicateNode,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation for a logical equality expression.
AML_METHOD_PARAM LeftOperand = { 0 };
AML_METHOD_PARAM RightOperand = { 0 };
LeftOperand.Type = AmlMethodParamTypeArg;
LeftOperand.Data.Arg = 0;
RightOperand.Type = AmlMethodParamTypeInteger;
RightOperand.Data.Integer = 1;
AmlCodeGenEqual (
LeftOperand,
RightOperand,
ParentNode,
NewObjectNode
);
is equivalent to:
LEqual (Arg0, One)
Integer, method argument, and local variable operands are supported.
@ingroup CodeGenApis
@param [in] LeftOperand Left operand of the equality expression.
@param [in] RightOperand Right operand of the equality expression.
@param [in] ParentNode Optional parent node.
@param [out] NewObjectNode On success, receives the created equality node.
@retval EFI_SUCCESS The equality expression was created
successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenEqual (
IN AML_METHOD_PARAM LeftOperand,
IN AML_METHOD_PARAM RightOperand,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** 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 object node.
AmlCodeGenMethod ("MET0", 1, TRUE, 3, ParentNode, NewObjectNode) is
equivalent of the following ASL code:
Method(MET0, 1, Serialized, 3) {}
ACPI 6.4, s20.2.5.2 "Named Objects Encoding":
DefMethod := MethodOp PkgLength NameString MethodFlags TermList
MethodOp := 0x14
The ASL parameters "ReturnType" and "ParameterTypes" are not asked
in this function. They are optional parameters in ASL.
@ingroup CodeGenApis
@param [in] NameString 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] 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
AmlCodeGenMethod (
IN CONST CHAR8 *NameString,
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.
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.
@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] 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 Buffer.
AmlCodeGenMethodRetBuffer (
"_MAT", ReturnedBuffer, ReturnedBufferSize, 1, TRUE, 0, ParentNode, NewObjectNode
);
is equivalent of the following ASL code:
Method(_MAT, 1, Serialized, 0) {
Return (Buffer (ReturnedBufferSize) {...})
}
To return an empty buffer, call the function with
(ReturnedBuffer=NULL, ReturnedBufferSize=0).
@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] ReturnedBuffer The buffer returned by the method.
The input buffer is copied.
NULL if an empty buffer is returned.
@param [in] ReturnedBufferSize Size of ReturnedBuffer.
Must be 0 if ReturnedBuffer is NULL.
@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
AmlCodeGenMethodRetBuffer (
IN CONST CHAR8 *MethodNameString,
IN CONST UINT8 *ReturnedBuffer,
IN UINT32 ReturnedBufferSize,
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.
@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] 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 CONST 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 CONST 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.
@ingroup CodeGenApis
@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 CONST CHAR8 *NameString,
IN AML_OBJECT_NODE_HANDLE NamedNode
);
/** Add an integer value to the named package node.
AmlCodeGenNamePackage ("_CID", NULL, &PackageNode);
AmlGetEisaIdFromString ("PNP0A03", &EisaId);
AmlAddIntegerToNamedPackage (EisaId, NameNode);
AmlGetEisaIdFromString ("PNP0A08", &EisaId);
AmlAddIntegerToNamedPackage (EisaId, NameNode);
equivalent of the following ASL code:
Name (_CID, Package (0x02) // _CID: Compatible ID
{
EisaId ("PNP0A03"),
EisaId ("PNP0A08")
})
The package is added at the tail of the list of the input package node
name:
Name ("NamePackageNode", Package () {
[Pre-existing package entries],
[Newly created integer entry]
})
@ingroup CodeGenApis
@param [in] Integer Integer value that need to be added to package node.
@param [in, out] NameNode Package named node to add the object to.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@retval Others Error occurred during the operation.
**/
EFI_STATUS
EFIAPI
AmlAddIntegerToNamedPackage (
IN UINT32 Integer,
IN OUT AML_OBJECT_NODE_HANDLE NameNode
);
/** AML code generation to invoke/call another method.
This method is a subset implementation of MethodInvocation
defined in the ACPI specification 6.5,
section 20.2.5 "Term Objects Encoding".
Added integer, string, ArgObj and LocalObj support.
Example 1:
AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode, &NewObjectNode);
is equivalent to the following ASL code:
MET0 ();
Example 2:
AML_METHOD_PARAM Param[4];
Param[0].Data.Integer = 0x100;
Param[0].Type = AmlMethodParamTypeInteger;
Param[1].Data.Buffer = "TEST";
Param[1].Type = AmlMethodParamTypeString;
Param[2].Data.Arg = 0;
Param[2].Type = AmlMethodParamTypeArg;
Param[3].Data.Local = 2;
Param[3].Type = AmlMethodParamTypeLocal;
AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode, &NewObjectNode);
is equivalent to the following ASL code:
MET0 (0x100, "TEST", Arg0, Local2);
Example 3:
AML_METHOD_PARAM Param[2];
Param[0].Data.Arg = 0;
Param[0].Type = AmlMethodParamTypeArg;
Param[1].Data.Integer = 0x100;
Param[1].Type = AmlMethodParamTypeInteger;
AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode, &NewObjectNode);
is equivalent to the following ASL code:
Method (MET2, 2, Serialized)
{
MET3 (Arg0, 0x0100)
}
@ingroup CodeGenApis
@param [in] MethodNameString The method name to be called or invoked.
@param [in] NumArgs Number of arguments to be passed,
0 to 7 are permissible values.
@param [in] Parameters Contains the parameter data.
@param [in] ParentNode The parent node to which the method invocation
nodes are attached.
@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
AmlCodeGenInvokeMethod (
IN CONST CHAR8 *MethodNameString,
IN UINT8 NumArgs,
IN AML_METHOD_PARAM *Parameters OPTIONAL,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** Create a _PSD node.
Creates and optionally adds the following node
Name(_PSD, Package()
{
NumEntries, // Integer
Revision, // Integer
Domain, // Integer
CoordType, // Integer
NumProc, // Integer
})
Cf. ACPI 6.5, s8.4.5.5 _PSD (P-State Dependency)
@ingroup CodeGenApis
@param [in] PsdInfo PsdInfo object
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewPsdNode 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
AmlCreatePsdNode (
IN AML_PSD_INFO *PsdInfo,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewPsdNode OPTIONAL
);
/** Create a _CST node.
AmlCreateCstNode ("_CST", 0, 1, ParentNode, &CstNode) is
equivalent of the following ASL code:
Name (_CST, Package (
0 // Count
))
This function doesn't define any CST state. As shown above, the count
of _CST state is set to 0.
The AmlAddCstState () function allows to add CST states.
Cf ACPI 6.5 specification, s8.4.1.1 _CST (C States)
@ingroup CodeGenApis
@param [in] CstNameString The new CST 's object name.
Must be a NULL-terminated ASL NameString
e.g.: "_CST", "DEV0.CSTP", etc.
The input string is copied.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewCstNode 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
AmlCreateCstNode (
IN CONST CHAR8 *CstNameString,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewCstNode OPTIONAL
);
/** Add an _CST state to a CST node created using AmlCreateCstNode.
AmlAddCstState increments the Count of CST states in the CST node by one,
and adds the following package:
Package {
Register // Buffer (Resource Descriptor)
Type // Integer (BYTE)
Latency // Integer (WORD)
Power // Integer (DWORD)
}
Cf ACPI 6.5 specification, s8.4.1.1 _CST (C States).
@ingroup CodeGenApis
@param [in] CstInfo CstInfo object
@param [in] CstNode Cst node created with the function
AmlCreateCstNode to which the new CST
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
AmlAddCstState (
IN AML_CST_INFO *CstInfo,
IN AML_OBJECT_NODE_HANDLE CstNode
);
/** Create a _CSD node.
Generates and optionally appends the following node:
Name (_CSD, Package()
{
Package () {
NumEntries, // Integer
Revision, // Integer (BYTE)
Domain, // Integer (DWORD)
CoordType, // Integer (DWORD)
NumProcessors, // Integer (DWORD)
Index // Integer (DWORD)
}
Package () {
NumEntries, // Integer
Revision, // Integer (BYTE)
Domain, // Integer (DWORD)
CoordType, // Integer (DWORD)
NumProcessors, // Integer (DWORD)
Index // Integer (DWORD)
}
...
})
Cf. ACPI 6.5, s8.4.1.2 _CSD (C-State Dependency).
@ingroup CodeGenApis
@param [in] CsdInfo CsdInfo object
@param [in] NumEntries Number of packages to be created.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewCsdNode 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
AmlCreateCsdNode (
IN AML_CSD_INFO *CsdInfo,
IN UINT32 NumEntries,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewCsdNode OPTIONAL
);
/** Create _PCT node
Generates and optionally appends the following node:
Name (_PCT, Package()
{
ControlRegister // Buffer (Resource Descriptor (Register))
StatusRegister // Buffer (Resource Descriptor (Register))
})
Cf. ACPI 6.5, s8.4.5.1 _PCT (Processor Control).
@ingroup CodeGenApis
@param [in] PctInfo PctInfo object
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewPctNode 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
AmlCreatePctNode (
IN AML_PCT_INFO *PctInfo,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewPctNode OPTIONAL
);
/** Create _PSS node
Generates and optionally appends the following node:
Name (_PSS, Package()
{
Package () {
CoreFrequency // Integer (DWORD)
Power // Integer (DWORD)
Latency // Integer (DWORD)
BusMasterLatency // Integer (DWORD)
Control // Integer (DWORD)
Status // Integer (DWORD)
}
Package () {
CoreFrequency // Integer (DWORD)
Power // Integer (DWORD)
Latency // Integer (DWORD)
BusMasterLatency // Integer (DWORD)
Control // Integer (DWORD)
Status // Integer (DWORD)
}
...
})
Cf. ACPI 6.5, s8.4.5.2 _PSS (Processor Supported Performance States).
@ingroup CodeGenApis
@param [in] PssInfo Array of PssInfo object
@param [in] NumPackages Number of packages to be created.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewPssNode 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
AmlCreatePssNode (
IN AML_PSS_INFO *PssInfo,
IN UINT32 NumPackages,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewPssNode OPTIONAL
);
/** Code generation for the IRQ Descriptor.
The Resource Data effectively created is an IRQ Resource
Data. Cf ACPI 6.5 specification:
- s6.4.2.1 "IRQ Descriptor"
- s19.6.66 "IRQ (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] IsEdgeTriggered The interrupt is edge triggered or
level triggered.
@param [in] IsActiveLow The interrupt is active-high or active-low.
@param [in] IsShared The interrupt can be shared with other
devices or not (Exclusive).
@param [in] IrqList List of IRQ numbers. Must be non-NULL.
@param [in] IrqCount Number of IRQs in IrqList. Must be > 0 and <= 16.
@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 various Other errors as indicated.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdIrq (
IN BOOLEAN IsEdgeTriggered,
IN BOOLEAN IsActiveLow,
IN BOOLEAN IsShared,
IN UINT8 *IrqList,
IN UINT8 IrqCount,
IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL,
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the UARTSerialBusV2() ASL macro.
The Resource Data effectively created is a UART Serial Bus Connection
Resource Descriptor Resource Data.
Cf ACPI 6.5:
- s19.6.143 UARTSerialBusV2
(UART Serial Bus Connection Resource Descriptor Version 2 Macro)
- s6.4.3.8.2.3 UART Serial Bus Connection Resource Descriptor
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] InitialBaudRate Initial baud rate.
@param [in] BitsPerByte Number of bits per byte.
Optional, default is 8.
@param [in] StopBits Number of stop bits.
Optional, default is 1.
@param [in] LinesInUse Number of lines in use.
@param [in] IsBigEndian Indicates whether the bit transfer is big-endian.
Optional, default is FALSE (little-endian).
@param [in] Parity Parity format used.
Optional, default is no parity.
@param [in] FlowControl Flow control protocol used.
Optional, default is no flow control.
@param [in] ReceiveBufferSize Size of the receive buffer.
@param [in] TransmitBufferSize Size of the transmit buffer.
@param [in] ResourceSource Name of source resource used.
@param [in] ResourceSourceLength Length of the Resource Source.
@param [in] ResourceSourceIndex Resource Source index.
Optional, default is 0.
@param [in] ResourceUsage Resource usage, TRUE for consumer,
FALSE for producer.
Optional, default is TRUE (consumer).
@param [in] IsShared Indicates whether the resource is shared.
Optional, default is FALSE (exclusive).
@param [in] VendorDefinedData Vendor defined data.
Optional, can be NULL.
@param [in] VendorDefinedDataLength Length of the vendor defined data.
@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 various Various failure values of called functions.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdUartSerialBusV2 (
IN UINT32 InitialBaudRate,
IN UINT8 *BitsPerByte OPTIONAL,
IN UINT8 *StopBits OPTIONAL,
IN UINT8 LinesInUse,
IN BOOLEAN *IsBigEndian OPTIONAL,
IN UINT8 *Parity OPTIONAL,
IN UINT8 *FlowControl OPTIONAL,
IN UINT16 ReceiveBufferSize,
IN UINT16 TransmitBufferSize,
IN CHAR8 *ResourceSource,
IN UINT16 ResourceSourceLength,
IN UINT8 *ResourceSourceIndex OPTIONAL,
IN BOOLEAN *ResourceUsage OPTIONAL,
IN BOOLEAN *IsShared OPTIONAL,
IN UINT8 *VendorDefinedData OPTIONAL,
IN UINT16 VendorDefinedDataLength,
IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL,
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** AML code generation for a Notify object.
Generates one of:
Notify (NameString, Value)
Notify (Local, Value)
Notify (Arg, Value)
@ingroup CodeGenApis
@param [in] NotifyObjectParam Object to be notified.
@param [in] NotifyValue Notification value.
@param [in] ParentNode Optional parent executable statement node.
@param [out] NewObjectNode Optional pointer that receives the created
Notify node.
@retval EFI_SUCCESS The Notify object was created successfully.
@retval EFI_INVALID_PARAMETER An input parameter is invalid.
@retval EFI_OUT_OF_RESOURCES Memory allocation failed.
**/
EFI_STATUS
EFIAPI
AmlCodeGenNotify (
IN AML_METHOD_PARAM NotifyObjectParam,
IN UINT8 NotifyValue,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation to create a method with Notify call.
Example 1:
AmlCodeGenMethodNotifyList ("_L01", FALSE, 0, 0, NULL, ParentNode, NewObjectNode);
is equivalent to the following ASL code:
Method (_L01, 0, NotSerialize)
{
}
Example 2:
AML_METHOD_PARAM Notify[2];
Notify[0].NotifyObject.Type = AmlMethodParamTypeString;
Notify[0].NotifyObject.Data.Buffer = (VOID*)"XCD0";
Notify[0].NotifyObject.DataSize = 4;
Notify[0].NotifyValue = 2;
Notify[1].NotifyObject.Type = AmlMethodParamTypeString;
Notify[1].NotifyObject.Data.Buffer = (VOID*)"XCD1";
Notify[1].NotifyObject.DataSize = 4;
Notify[1].NotifyValue = 2;
AmlCodeGenMethodNotifyList ("_L02", FALSE, 0, 2, Notify, ParentNode, NewObjectNode);
is equivalent to the following ASL code:
Method (_L02, 0, NotSerialize)
{
Notify ("XCD0", 2)
Notify ("XCD1", 2)
}
Ref : ACPI 6.6, s19.6.95 Notify (Notify Object of Event):
Object must be a reference to a device, processor, or thermal zone object.
Note:
This code cannot validate whether the referenced object is a valid device,
processor, or thermal zone object.
It assumes that NameString, Local, and Arg objects reference valid device,
processor, or thermal zone objects.
@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] 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] NotifyParamCount Number of Notify parameters
@param [in] NotifyParameters Array of Notify parameters
@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
AmlCodeGenMethodNotifyList (
IN CONST CHAR8 *MethodNameString,
IN BOOLEAN IsSerialized,
IN UINT8 SyncLevel,
IN UINT32 NotifyParamCount,
IN AML_NOTIFY_PARAM *NotifyParameters OPTIONAL,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
/** AML code generation to Return Method invocation.
This method is a subset implementation of MethodInvocation
defined in the ACPI specification 6.5,
section 20.2.5 "Term Objects Encoding".
Added integer, string, ArgObj and LocalObj support.
Example 1:
AmlCodeGenReturnInvokeMethod ("MET0", 0, NULL, ParentNode, &NewObjectNode);
is equivalent to the following ASL code:
Return (MET0 () )
Example 2:
AML_METHOD_PARAM Param[4];
Param[0].Data.Integer = 0x100;
Param[0].Type = AmlMethodParamTypeInteger;
Param[1].Data.Buffer = "TEST";
Param[1].Type = AmlMethodParamTypeString;
Param[2].Data.Arg = 0;
Param[2].Type = AmlMethodParamTypeArg;
Param[3].Data.Local = 2;
Param[3].Type = AmlMethodParamTypeLocal;
AmlCodeGenReturnInvokeMethod ("MET0", 4, Param, ParentNode, &NewObjectNode);
is equivalent to the following ASL code:
Return (MET0 (0x100, "TEST", Arg0, Local2) )
Example 3:
AML_METHOD_PARAM Param[2];
Param[0].Data.Arg = 0;
Param[0].Type = AmlMethodParamTypeArg;
Param[1].Data.Integer = 0x100;
Param[1].Type = AmlMethodParamTypeInteger;
AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0,
ParentNode, &MethodNode);
AmlCodeGenReturnInvokeMethod ("MET3", 2, Param, MethodNode, &NewObjectNode);
is equivalent to the following ASL code:
Method (MET2, 2, Serialized)
{
Return (MET3 (Arg0, 0x0100) )
}
@ingroup CodeGenApis
@param [in] MethodNameString The method name to be returned.
@param [in] NumArgs Number of arguments to be passed,
0 to 7 are permissible values.
@param [in] Parameters Contains the parameter data.
@param [in] ParentNode The parent node to which the method return
nodes are attached.
@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
AmlCodeGenReturnInvokeMethod (
IN CONST CHAR8 *MethodNameString,
IN UINT8 NumArgs,
IN AML_METHOD_PARAM *Parameters OPTIONAL,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
|