TianoCore EDK2 master
Loading...
Searching...
No Matches
AmlCodeGen.c
Go to the documentation of this file.
1
10#include <AmlNodeDefines.h>
11
12#include <AcpiTableGenerator.h>
13
14#include <AmlCoreInterface.h>
15#include <AcpiObjects.h>
16#include <AmlEncoding/Aml.h>
17#include <Api/AmlApiHelper.h>
19#include <Tree/AmlNode.h>
20#include <Tree/AmlTree.h>
21#include <String/AmlString.h>
22#include <Utils/AmlUtility.h>
23
38EFIAPI
40 IN AML_OBJECT_NODE *Node,
41 IN AML_NODE_HEADER *ParentNode,
42 OUT AML_OBJECT_NODE **NewObjectNode
43 )
44{
45 EFI_STATUS Status;
46
47 if (NewObjectNode != NULL) {
48 *NewObjectNode = NULL;
49 }
50
51 // Add RdNode as the last element.
52 if (ParentNode != NULL) {
53 Status = AmlVarListAddTail (ParentNode, (AML_NODE_HEADER *)Node);
54 if (EFI_ERROR (Status)) {
55 ASSERT (0);
56 return Status;
57 }
58 }
59
60 if (NewObjectNode != NULL) {
61 *NewObjectNode = Node;
62 }
63
64 return EFI_SUCCESS;
65}
66
92EFIAPI
94 IN CONST CHAR8 *TableSignature,
95 IN CONST CHAR8 *OemId,
96 IN CONST CHAR8 *OemTableId,
97 IN UINT32 OemRevision,
98 OUT AML_ROOT_NODE **NewRootNode
99 )
100{
101 EFI_STATUS Status;
103
104 if ((TableSignature == NULL) ||
105 (OemId == NULL) ||
106 (OemTableId == NULL) ||
107 (NewRootNode == NULL))
108 {
109 ASSERT (0);
110 return EFI_INVALID_PARAMETER;
111 }
112
113 CopyMem (&AcpiHeader.Signature, TableSignature, 4);
114 AcpiHeader.Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
115 AcpiHeader.Revision = 2;
116 CopyMem (&AcpiHeader.OemId, OemId, 6);
117 CopyMem (&AcpiHeader.OemTableId, OemTableId, 8);
118 AcpiHeader.OemRevision = OemRevision;
119 AcpiHeader.CreatorId = TABLE_GENERATOR_CREATOR_ID;
120 AcpiHeader.CreatorRevision = CREATE_REVISION (1, 0);
121
122 Status = AmlCreateRootNode (&AcpiHeader, NewRootNode);
123 ASSERT_EFI_ERROR (Status);
124
125 return Status;
126}
127
138STATIC
140EFIAPI
142 IN CONST CHAR8 *String,
143 OUT AML_OBJECT_NODE **NewObjectNode
144 )
145{
146 EFI_STATUS Status;
147 AML_OBJECT_NODE *ObjectNode;
148 AML_DATA_NODE *DataNode;
149
150 if ((String == NULL) ||
151 (NewObjectNode == NULL))
152 {
153 ASSERT (0);
154 return EFI_INVALID_PARAMETER;
155 }
156
157 DataNode = NULL;
158
159 Status = AmlCreateObjectNode (
160 AmlGetByteEncodingByOpCode (AML_STRING_PREFIX, 0),
161 0,
162 &ObjectNode
163 );
164 if (EFI_ERROR (Status)) {
165 ASSERT (0);
166 return Status;
167 }
168
169 Status = AmlCreateDataNode (
171 (UINT8 *)String,
172 (UINT32)AsciiStrLen (String) + 1,
173 &DataNode
174 );
175 if (EFI_ERROR (Status)) {
176 ASSERT (0);
177 goto error_handler;
178 }
179
180 Status = AmlSetFixedArgument (
181 ObjectNode,
183 (AML_NODE_HEADER *)DataNode
184 );
185 if (EFI_ERROR (Status)) {
186 ASSERT (0);
187 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
188 goto error_handler;
189 }
190
191 *NewObjectNode = ObjectNode;
192 return Status;
193
194error_handler:
195 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
196 return Status;
197}
198
209STATIC
211EFIAPI
213 IN UINT64 Integer,
214 OUT AML_OBJECT_NODE **NewObjectNode
215 )
216{
217 EFI_STATUS Status;
218 INT8 ValueWidthDiff;
219
220 if (NewObjectNode == NULL) {
221 ASSERT (0);
222 return EFI_INVALID_PARAMETER;
223 }
224
225 // Create an object node containing Zero.
226 Status = AmlCreateObjectNode (
227 AmlGetByteEncodingByOpCode (AML_ZERO_OP, 0),
228 0,
229 NewObjectNode
230 );
231 if (EFI_ERROR (Status)) {
232 ASSERT (0);
233 return Status;
234 }
235
236 // Update the object node with integer value.
237 Status = AmlNodeSetIntegerValue (*NewObjectNode, Integer, &ValueWidthDiff);
238 if (EFI_ERROR (Status)) {
239 ASSERT (0);
240 AmlDeleteTree ((AML_NODE_HEADER *)*NewObjectNode);
241 }
242
243 return Status;
244}
245
258STATIC
260EFIAPI
262 OUT AML_OBJECT_NODE **NewObjectNode
263 )
264{
265 EFI_STATUS Status;
266 AML_DATA_NODE *DataNode;
267 UINT8 NodeCount;
268
269 if (NewObjectNode == NULL) {
270 ASSERT (0);
271 return EFI_INVALID_PARAMETER;
272 }
273
274 NodeCount = 0;
275
276 // Create an object node.
277 // PkgLen is 2:
278 // - one byte to store the PkgLength
279 // - one byte for the NumElements.
280 // Cf ACPI6.3, s20.2.5 "Term Objects Encoding"
281 // DefPackage := PackageOp PkgLength NumElements PackageElementList
282 // NumElements := ByteData
283 Status = AmlCreateObjectNode (
284 AmlGetByteEncodingByOpCode (AML_PACKAGE_OP, 0),
285 2,
286 NewObjectNode
287 );
288 if (EFI_ERROR (Status)) {
289 ASSERT (0);
290 return Status;
291 }
292
293 // NumElements is a ByteData.
294 Status = AmlCreateDataNode (
296 &NodeCount,
297 sizeof (NodeCount),
298 &DataNode
299 );
300 if (EFI_ERROR (Status)) {
301 ASSERT (0);
302 goto error_handler;
303 }
304
305 Status = AmlSetFixedArgument (
306 *NewObjectNode,
308 (AML_NODE_HEADER *)DataNode
309 );
310 if (EFI_ERROR (Status)) {
311 ASSERT (0);
312 goto error_handler;
313 }
314
315 return Status;
316
317error_handler:
318 AmlDeleteTree ((AML_NODE_HEADER *)*NewObjectNode);
319 if (DataNode != NULL) {
320 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
321 }
322
323 return Status;
324}
325
345STATIC
347EFIAPI
349 IN CONST UINT8 *Buffer OPTIONAL,
350 IN UINT32 BufferSize OPTIONAL,
351 OUT AML_OBJECT_NODE **NewObjectNode
352 )
353{
354 EFI_STATUS Status;
355 AML_OBJECT_NODE *BufferNode;
356 AML_OBJECT_NODE *BufferSizeNode;
357 UINT32 BufferSizeNodeSize;
358 AML_DATA_NODE *DataNode;
359 UINT32 PkgLen;
360
361 // Buffer and BufferSize must be either both set, or both clear.
362 if ((NewObjectNode == NULL) ||
363 ((Buffer == NULL) != (BufferSize == 0)))
364 {
365 ASSERT (0);
366 return EFI_INVALID_PARAMETER;
367 }
368
369 BufferNode = NULL;
370 DataNode = NULL;
371
372 // Cf ACPI 6.3 specification, s20.2.5.4 "Type 2 Opcodes Encoding"
373 // DefBuffer := BufferOp PkgLength BufferSize ByteList
374 // BufferOp := 0x11
375 // BufferSize := TermArg => Integer
376
377 Status = AmlCodeGenInteger (BufferSize, &BufferSizeNode);
378 if (EFI_ERROR (Status)) {
379 ASSERT (0);
380 return Status;
381 }
382
383 // Get the number of bytes required to encode the BufferSizeNode.
384 Status = AmlComputeSize (
385 (AML_NODE_HEADER *)BufferSizeNode,
386 &BufferSizeNodeSize
387 );
388 if (EFI_ERROR (Status)) {
389 ASSERT (0);
390 goto error_handler;
391 }
392
393 // Compute the size to write in the PkgLen.
394 Status = AmlComputePkgLength (BufferSizeNodeSize + BufferSize, &PkgLen);
395 if (EFI_ERROR (Status)) {
396 ASSERT (0);
397 goto error_handler;
398 }
399
400 // Create an object node for the buffer.
401 Status = AmlCreateObjectNode (
402 AmlGetByteEncodingByOpCode (AML_BUFFER_OP, 0),
403 PkgLen,
404 &BufferNode
405 );
406 if (EFI_ERROR (Status)) {
407 ASSERT (0);
408 goto error_handler;
409 }
410
411 // Set the BufferSizeNode as a fixed argument of the BufferNode.
412 Status = AmlSetFixedArgument (
413 BufferNode,
415 (AML_NODE_HEADER *)BufferSizeNode
416 );
417 if (EFI_ERROR (Status)) {
418 ASSERT (0);
419 goto error_handler;
420 }
421
422 // BufferSizeNode is now attached.
423 BufferSizeNode = NULL;
424
425 // If there is a buffer, create a DataNode and attach it to the BufferNode.
426 if (Buffer != NULL) {
427 Status = AmlCreateDataNode (
429 Buffer,
430 BufferSize,
431 &DataNode
432 );
433 if (EFI_ERROR (Status)) {
434 ASSERT (0);
435 goto error_handler;
436 }
437
438 Status = AmlVarListAddTail (
439 (AML_NODE_HEADER *)BufferNode,
440 (AML_NODE_HEADER *)DataNode
441 );
442 if (EFI_ERROR (Status)) {
443 ASSERT (0);
444 goto error_handler;
445 }
446 }
447
448 *NewObjectNode = BufferNode;
449 return Status;
450
451error_handler:
452 if (BufferSizeNode != NULL) {
453 AmlDeleteTree ((AML_NODE_HEADER *)BufferSizeNode);
454 }
455
456 if (BufferNode != NULL) {
457 AmlDeleteTree ((AML_NODE_HEADER *)BufferNode);
458 }
459
460 if (DataNode != NULL) {
461 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
462 }
463
464 return Status;
465}
466
485STATIC
487EFIAPI
489 OUT AML_OBJECT_NODE **NewObjectNode
490 )
491{
492 EFI_STATUS Status;
493 AML_OBJECT_NODE *BufferNode;
494
495 if (NewObjectNode == NULL) {
496 ASSERT (0);
497 return EFI_INVALID_PARAMETER;
498 }
499
500 // Create a BufferNode with an empty buffer.
501 Status = AmlCodeGenBuffer (NULL, 0, &BufferNode);
502 if (EFI_ERROR (Status)) {
503 ASSERT (0);
504 return Status;
505 }
506
507 // Create an EndTag resource data element and attach it to the Buffer.
508 Status = AmlCodeGenEndTag (0, BufferNode, NULL);
509 if (EFI_ERROR (Status)) {
510 ASSERT (0);
511 AmlDeleteTree ((AML_NODE_HEADER *)BufferNode);
512 return Status;
513 }
514
515 *NewObjectNode = BufferNode;
516 return Status;
517}
518
534STATIC
536EFIAPI
538 IN CONST CHAR8 *NameString,
539 IN AML_OBJECT_NODE *Object,
540 IN AML_NODE_HEADER *ParentNode OPTIONAL,
541 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
542 )
543{
544 EFI_STATUS Status;
545 AML_OBJECT_NODE *ObjectNode;
546 AML_DATA_NODE *DataNode;
547 CHAR8 *AmlNameString;
548 UINT32 AmlNameStringSize;
549
550 if ((NameString == NULL) ||
551 (Object == NULL) ||
552 ((ParentNode == NULL) && (NewObjectNode == NULL)))
553 {
554 ASSERT (0);
555 return EFI_INVALID_PARAMETER;
556 }
557
558 ObjectNode = NULL;
559 DataNode = NULL;
560 AmlNameString = NULL;
561
562 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
563 if (EFI_ERROR (Status)) {
564 ASSERT (0);
565 return Status;
566 }
567
568 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
569 if (EFI_ERROR (Status)) {
570 ASSERT (0);
571 goto error_handler1;
572 }
573
574 Status = AmlCreateObjectNode (
575 AmlGetByteEncodingByOpCode (AML_NAME_OP, 0),
576 0,
577 &ObjectNode
578 );
579 if (EFI_ERROR (Status)) {
580 ASSERT (0);
581 goto error_handler1;
582 }
583
584 Status = AmlCreateDataNode (
586 (UINT8 *)AmlNameString,
587 AmlNameStringSize,
588 &DataNode
589 );
590 if (EFI_ERROR (Status)) {
591 ASSERT (0);
592 goto error_handler2;
593 }
594
595 Status = AmlSetFixedArgument (
596 ObjectNode,
598 (AML_NODE_HEADER *)DataNode
599 );
600 if (EFI_ERROR (Status)) {
601 ASSERT (0);
602 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
603 goto error_handler2;
604 }
605
606 Status = AmlSetFixedArgument (
607 ObjectNode,
609 (AML_NODE_HEADER *)Object
610 );
611 if (EFI_ERROR (Status)) {
612 ASSERT (0);
613 goto error_handler2;
614 }
615
616 Status = LinkNode (
617 ObjectNode,
618 ParentNode,
619 NewObjectNode
620 );
621 if (EFI_ERROR (Status)) {
622 ASSERT (0);
623 goto error_handler2;
624 }
625
626 // Free AmlNameString before returning as it is copied
627 // in the call to AmlCreateDataNode().
628 goto error_handler1;
629
630error_handler2:
631 if (ObjectNode != NULL) {
632 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
633 }
634
635error_handler1:
636 if (AmlNameString != NULL) {
637 FreePool (AmlNameString);
638 }
639
640 return Status;
641}
642
664EFIAPI
666 IN CONST CHAR8 *NameString,
667 IN CONST CHAR8 *String,
668 IN AML_NODE_HEADER *ParentNode OPTIONAL,
669 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
670 )
671{
672 EFI_STATUS Status;
673 AML_OBJECT_NODE *ObjectNode;
674
675 if ((NameString == NULL) ||
676 (String == NULL) ||
677 ((ParentNode == NULL) && (NewObjectNode == NULL)))
678 {
679 ASSERT (0);
680 return EFI_INVALID_PARAMETER;
681 }
682
683 Status = AmlCodeGenString (String, &ObjectNode);
684 if (EFI_ERROR (Status)) {
685 ASSERT (0);
686 return Status;
687 }
688
689 Status = AmlCodeGenName (
690 NameString,
691 ObjectNode,
692 ParentNode,
693 NewObjectNode
694 );
695 if (EFI_ERROR (Status)) {
696 ASSERT (0);
697 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
698 }
699
700 return Status;
701}
702
723EFIAPI
725 IN CONST CHAR8 *NameString,
726 IN UINT64 Integer,
727 IN AML_NODE_HEADER *ParentNode OPTIONAL,
728 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
729 )
730{
731 EFI_STATUS Status;
732 AML_OBJECT_NODE *ObjectNode;
733
734 if ((NameString == NULL) ||
735 ((ParentNode == NULL) && (NewObjectNode == NULL)))
736 {
737 ASSERT (0);
738 return EFI_INVALID_PARAMETER;
739 }
740
741 Status = AmlCodeGenInteger (Integer, &ObjectNode);
742 if (EFI_ERROR (Status)) {
743 ASSERT (0);
744 return Status;
745 }
746
747 Status = AmlCodeGenName (
748 NameString,
749 ObjectNode,
750 ParentNode,
751 NewObjectNode
752 );
753 if (EFI_ERROR (Status)) {
754 ASSERT (0);
755 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
756 }
757
758 return Status;
759}
760
780EFIAPI
782 IN CONST CHAR8 *NameString,
783 IN AML_NODE_HEADER *ParentNode, OPTIONAL
784 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
785 )
786{
787 EFI_STATUS Status;
788 AML_OBJECT_NODE *PackageNode;
789
790 if ((NameString == NULL) ||
791 ((ParentNode == NULL) && (NewObjectNode == NULL)))
792 {
793 ASSERT (0);
794 return EFI_INVALID_PARAMETER;
795 }
796
797 Status = AmlCodeGenPackage (&PackageNode);
798 if (EFI_ERROR (Status)) {
799 ASSERT (0);
800 return Status;
801 }
802
803 Status = AmlCodeGenName (
804 NameString,
805 PackageNode,
806 ParentNode,
807 NewObjectNode
808 );
809 if (EFI_ERROR (Status)) {
810 ASSERT (0);
811 AmlDeleteTree ((AML_NODE_HEADER *)PackageNode);
812 }
813
814 return Status;
815}
816
836EFIAPI
838 IN CONST CHAR8 *NameString,
839 IN AML_NODE_HEADER *ParentNode, OPTIONAL
840 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
841 )
842{
843 EFI_STATUS Status;
844 AML_OBJECT_NODE *ResourceTemplateNode;
845
846 if ((NameString == NULL) ||
847 ((ParentNode == NULL) && (NewObjectNode == NULL)))
848 {
849 ASSERT (0);
850 return EFI_INVALID_PARAMETER;
851 }
852
853 Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode);
854 if (EFI_ERROR (Status)) {
855 ASSERT (0);
856 return Status;
857 }
858
859 Status = AmlCodeGenName (
860 NameString,
861 ResourceTemplateNode,
862 ParentNode,
863 NewObjectNode
864 );
865 if (EFI_ERROR (Status)) {
866 ASSERT (0);
867 AmlDeleteTree ((AML_NODE_HEADER *)ResourceTemplateNode);
868 }
869
870 return Status;
871}
872
896EFIAPI
898 IN CONST CHAR8 *NameString,
899 IN CHAR16 *String,
900 IN AML_NODE_HANDLE ParentNode OPTIONAL,
901 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
902 )
903{
904 EFI_STATUS Status;
905 AML_OBJECT_NODE *ObjectNode;
906 AML_DATA_NODE *DataNode;
907
908 if ((NameString == NULL) ||
909 (String == NULL) ||
910 ((ParentNode == NULL) && (NewObjectNode == NULL)))
911 {
912 ASSERT (0);
913 return EFI_INVALID_PARAMETER;
914 }
915
916 Status = AmlCodeGenBuffer (NULL, 0, &ObjectNode);
917 if (EFI_ERROR (Status)) {
918 ASSERT_EFI_ERROR (Status);
919 return Status;
920 }
921
922 Status = AmlCreateDataNode (
924 (CONST UINT8 *)String,
925 (UINT32)StrSize (String),
926 &DataNode
927 );
928 if (EFI_ERROR (Status)) {
929 ASSERT_EFI_ERROR (Status);
930 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
931 return Status;
932 }
933
934 Status = AmlVarListAddTail (
935 (AML_NODE_HEADER *)ObjectNode,
936 (AML_NODE_HEADER *)DataNode
937 );
938 if (EFI_ERROR (Status)) {
939 ASSERT_EFI_ERROR (Status);
940 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
941 AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
942 return Status;
943 }
944
945 Status = AmlCodeGenName (
946 NameString,
947 ObjectNode,
948 ParentNode,
949 NewObjectNode
950 );
951 if (EFI_ERROR (Status)) {
952 ASSERT (0);
953 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
954 }
955
956 return Status;
957}
958
1007EFIAPI
1009 IN UINT32 Address,
1010 IN UINT8 Pin,
1011 IN CONST CHAR8 *LinkName,
1012 IN UINT32 SourceIndex,
1013 IN AML_OBJECT_NODE_HANDLE PrtNameNode
1014 )
1015{
1016 EFI_STATUS Status;
1017 AML_OBJECT_NODE *PrtEntryList;
1018 AML_OBJECT_NODE *PackageNode;
1019 AML_OBJECT_NODE *NewElementNode;
1020
1021 CHAR8 *AmlNameString;
1022 UINT32 AmlNameStringSize;
1023 AML_DATA_NODE *DataNode;
1024
1025 if ((Pin > 3) ||
1026 (PrtNameNode == NULL) ||
1027 (AmlGetNodeType ((AML_NODE_HANDLE)PrtNameNode) != EAmlNodeObject) ||
1028 (!AmlNodeHasOpCode (PrtNameNode, AML_NAME_OP, 0)) ||
1029 !AmlNameOpCompareName (PrtNameNode, "_PRT"))
1030 {
1031 ASSERT (0);
1032 return EFI_INVALID_PARAMETER;
1033 }
1034
1035 NewElementNode = NULL;
1036 AmlNameString = NULL;
1037 DataNode = NULL;
1038
1039 // Get the Package object node of the _PRT node,
1040 // which is the 2nd fixed argument (i.e. index 1).
1042 PrtNameNode,
1044 );
1045 if ((PrtEntryList == NULL) ||
1046 (AmlGetNodeType ((AML_NODE_HANDLE)PrtEntryList) != EAmlNodeObject) ||
1047 (!AmlNodeHasOpCode (PrtEntryList, AML_PACKAGE_OP, 0)))
1048 {
1049 ASSERT (0);
1050 return EFI_INVALID_PARAMETER;
1051 }
1052
1053 // The new _PRT entry.
1054 Status = AmlCodeGenPackage (&PackageNode);
1055 if (EFI_ERROR (Status)) {
1056 ASSERT (0);
1057 return Status;
1058 }
1059
1060 Status = AmlCodeGenInteger (Address, &NewElementNode);
1061 if (EFI_ERROR (Status)) {
1062 ASSERT (0);
1063 goto error_handler;
1064 }
1065
1066 Status = AmlVarListAddTail (
1067 (AML_NODE_HANDLE)PackageNode,
1068 (AML_NODE_HANDLE)NewElementNode
1069 );
1070 if (EFI_ERROR (Status)) {
1071 ASSERT (0);
1072 goto error_handler;
1073 }
1074
1075 NewElementNode = NULL;
1076
1077 Status = AmlCodeGenInteger (Pin, &NewElementNode);
1078 if (EFI_ERROR (Status)) {
1079 ASSERT (0);
1080 goto error_handler;
1081 }
1082
1083 Status = AmlVarListAddTail (
1084 (AML_NODE_HANDLE)PackageNode,
1085 (AML_NODE_HANDLE)NewElementNode
1086 );
1087 if (EFI_ERROR (Status)) {
1088 ASSERT (0);
1089 goto error_handler;
1090 }
1091
1092 NewElementNode = NULL;
1093
1094 if (LinkName != NULL) {
1095 Status = ConvertAslNameToAmlName (LinkName, &AmlNameString);
1096 if (EFI_ERROR (Status)) {
1097 ASSERT_EFI_ERROR (Status);
1098 goto error_handler;
1099 }
1100
1101 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1102 if (EFI_ERROR (Status)) {
1103 ASSERT_EFI_ERROR (Status);
1104 goto error_handler;
1105 }
1106
1107 Status = AmlCreateDataNode (
1109 (UINT8 *)AmlNameString,
1110 AmlNameStringSize,
1111 &DataNode
1112 );
1113 if (EFI_ERROR (Status)) {
1114 ASSERT_EFI_ERROR (Status);
1115 goto error_handler;
1116 }
1117
1118 // AmlNameString will be freed be fore returning.
1119
1120 Status = AmlVarListAddTail (
1121 (AML_NODE_HANDLE)PackageNode,
1122 (AML_NODE_HANDLE)DataNode
1123 );
1124 if (EFI_ERROR (Status)) {
1125 ASSERT_EFI_ERROR (Status);
1126 goto error_handler;
1127 }
1128
1129 DataNode = NULL;
1130 } else {
1131 Status = AmlCodeGenInteger (0, &NewElementNode);
1132 if (EFI_ERROR (Status)) {
1133 ASSERT_EFI_ERROR (Status);
1134 goto error_handler;
1135 }
1136
1137 Status = AmlVarListAddTail (
1138 (AML_NODE_HANDLE)PackageNode,
1139 (AML_NODE_HANDLE)NewElementNode
1140 );
1141 if (EFI_ERROR (Status)) {
1142 ASSERT_EFI_ERROR (Status);
1143 goto error_handler;
1144 }
1145 }
1146
1147 Status = AmlCodeGenInteger (SourceIndex, &NewElementNode);
1148 if (EFI_ERROR (Status)) {
1149 ASSERT (0);
1150 goto error_handler;
1151 }
1152
1153 Status = AmlVarListAddTail (
1154 (AML_NODE_HANDLE)PackageNode,
1155 (AML_NODE_HANDLE)NewElementNode
1156 );
1157 if (EFI_ERROR (Status)) {
1158 ASSERT (0);
1159 goto error_handler;
1160 }
1161
1162 // Append to the list of _PRT entries.
1163 Status = AmlVarListAddTail (
1164 (AML_NODE_HANDLE)PrtEntryList,
1165 (AML_NODE_HANDLE)PackageNode
1166 );
1167 if (EFI_ERROR (Status)) {
1168 ASSERT (0);
1169 goto error_handler;
1170 }
1171
1172 // Free AmlNameString before returning as it is copied
1173 // in the call to AmlCreateDataNode().
1174 goto exit_handler;
1175
1176error_handler:
1177 AmlDeleteTree ((AML_NODE_HANDLE)PackageNode);
1178 if (NewElementNode != NULL) {
1179 AmlDeleteTree ((AML_NODE_HANDLE)NewElementNode);
1180 }
1181
1182 if (DataNode != NULL) {
1183 AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
1184 }
1185
1186exit_handler:
1187 if (AmlNameString != NULL) {
1188 FreePool (AmlNameString);
1189 }
1190
1191 return Status;
1192}
1193
1213EFIAPI
1215 IN CONST CHAR8 *NameString,
1216 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1217 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1218 )
1219{
1220 EFI_STATUS Status;
1221 AML_OBJECT_NODE *ObjectNode;
1222 AML_DATA_NODE *DataNode;
1223 CHAR8 *AmlNameString;
1224 UINT32 AmlNameStringSize;
1225
1226 if ((NameString == NULL) ||
1227 ((ParentNode == NULL) && (NewObjectNode == NULL)))
1228 {
1229 ASSERT (0);
1230 return EFI_INVALID_PARAMETER;
1231 }
1232
1233 ObjectNode = NULL;
1234 DataNode = NULL;
1235 AmlNameString = NULL;
1236
1237 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
1238 if (EFI_ERROR (Status)) {
1239 ASSERT (0);
1240 return Status;
1241 }
1242
1243 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1244 if (EFI_ERROR (Status)) {
1245 ASSERT (0);
1246 goto error_handler1;
1247 }
1248
1249 Status = AmlCreateObjectNode (
1250 AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_DEVICE_OP),
1251 AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),
1252 &ObjectNode
1253 );
1254 if (EFI_ERROR (Status)) {
1255 ASSERT (0);
1256 goto error_handler1;
1257 }
1258
1259 Status = AmlCreateDataNode (
1261 (UINT8 *)AmlNameString,
1262 AmlNameStringSize,
1263 &DataNode
1264 );
1265 if (EFI_ERROR (Status)) {
1266 ASSERT (0);
1267 goto error_handler2;
1268 }
1269
1270 Status = AmlSetFixedArgument (
1271 ObjectNode,
1273 (AML_NODE_HEADER *)DataNode
1274 );
1275 if (EFI_ERROR (Status)) {
1276 ASSERT (0);
1277 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
1278 goto error_handler2;
1279 }
1280
1281 Status = LinkNode (
1282 ObjectNode,
1283 ParentNode,
1284 NewObjectNode
1285 );
1286 if (EFI_ERROR (Status)) {
1287 ASSERT (0);
1288 goto error_handler2;
1289 }
1290
1291 // Free AmlNameString before returning as it is copied
1292 // in the call to AmlCreateDataNode().
1293 goto error_handler1;
1294
1295error_handler2:
1296 if (ObjectNode != NULL) {
1297 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
1298 }
1299
1300error_handler1:
1301 if (AmlNameString != NULL) {
1302 FreePool (AmlNameString);
1303 }
1304
1305 return Status;
1306}
1307
1329EFIAPI
1331 IN CONST CHAR8 *NameString,
1332 IN AML_NODE_HANDLE ParentNode OPTIONAL,
1333 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
1334 )
1335{
1336 EFI_STATUS Status;
1337 AML_OBJECT_NODE *ObjectNode;
1338 AML_DATA_NODE *DataNode;
1339 CHAR8 *AmlNameString;
1340 UINT32 AmlNameStringSize;
1341
1342 if ((NameString == NULL) ||
1343 ((ParentNode == NULL) && (NewObjectNode == NULL)))
1344 {
1345 ASSERT (0);
1346 return EFI_INVALID_PARAMETER;
1347 }
1348
1349 ObjectNode = NULL;
1350 DataNode = NULL;
1351 AmlNameString = NULL;
1352
1353 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
1354 if (EFI_ERROR (Status)) {
1355 ASSERT (0);
1356 return Status;
1357 }
1358
1359 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1360 if (EFI_ERROR (Status)) {
1361 ASSERT (0);
1362 goto error_handler1;
1363 }
1364
1365 Status = AmlCreateObjectNode (
1366 AmlGetByteEncodingByOpCode (AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP),
1367 AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),
1368 &ObjectNode
1369 );
1370 if (EFI_ERROR (Status)) {
1371 ASSERT (0);
1372 goto error_handler1;
1373 }
1374
1375 Status = AmlCreateDataNode (
1377 (UINT8 *)AmlNameString,
1378 AmlNameStringSize,
1379 &DataNode
1380 );
1381 if (EFI_ERROR (Status)) {
1382 ASSERT (0);
1383 goto error_handler2;
1384 }
1385
1386 Status = AmlSetFixedArgument (
1387 ObjectNode,
1389 (AML_NODE_HEADER *)DataNode
1390 );
1391 if (EFI_ERROR (Status)) {
1392 ASSERT (0);
1393 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
1394 goto error_handler2;
1395 }
1396
1397 Status = LinkNode (
1398 ObjectNode,
1399 ParentNode,
1400 NewObjectNode
1401 );
1402 if (EFI_ERROR (Status)) {
1403 ASSERT (0);
1404 goto error_handler2;
1405 }
1406
1407 // Free AmlNameString before returning as it is copied
1408 // in the call to AmlCreateDataNode().
1409 goto error_handler1;
1410
1411error_handler2:
1412 if (ObjectNode != NULL) {
1413 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
1414 }
1415
1416error_handler1:
1417 if (AmlNameString != NULL) {
1418 FreePool (AmlNameString);
1419 }
1420
1421 return Status;
1422}
1423
1443EFIAPI
1445 IN CONST CHAR8 *NameString,
1446 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1447 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1448 )
1449{
1450 EFI_STATUS Status;
1451 AML_OBJECT_NODE *ObjectNode;
1452 AML_DATA_NODE *DataNode;
1453 CHAR8 *AmlNameString;
1454 UINT32 AmlNameStringSize;
1455
1456 if ((NameString == NULL) ||
1457 ((ParentNode == NULL) && (NewObjectNode == NULL)))
1458 {
1459 ASSERT (0);
1460 return EFI_INVALID_PARAMETER;
1461 }
1462
1463 ObjectNode = NULL;
1464 DataNode = NULL;
1465 AmlNameString = NULL;
1466
1467 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
1468 if (EFI_ERROR (Status)) {
1469 ASSERT (0);
1470 return Status;
1471 }
1472
1473 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1474 if (EFI_ERROR (Status)) {
1475 ASSERT (0);
1476 goto error_handler1;
1477 }
1478
1479 Status = AmlCreateObjectNode (
1480 AmlGetByteEncodingByOpCode (AML_SCOPE_OP, 0),
1481 AmlNameStringSize + AmlComputePkgLengthWidth (AmlNameStringSize),
1482 &ObjectNode
1483 );
1484 if (EFI_ERROR (Status)) {
1485 ASSERT (0);
1486 goto error_handler1;
1487 }
1488
1489 Status = AmlCreateDataNode (
1491 (UINT8 *)AmlNameString,
1492 AmlNameStringSize,
1493 &DataNode
1494 );
1495 if (EFI_ERROR (Status)) {
1496 ASSERT (0);
1497 goto error_handler2;
1498 }
1499
1500 Status = AmlSetFixedArgument (
1501 ObjectNode,
1503 (AML_NODE_HEADER *)DataNode
1504 );
1505 if (EFI_ERROR (Status)) {
1506 ASSERT (0);
1507 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
1508 goto error_handler2;
1509 }
1510
1511 Status = LinkNode (
1512 ObjectNode,
1513 ParentNode,
1514 NewObjectNode
1515 );
1516 if (EFI_ERROR (Status)) {
1517 ASSERT (0);
1518 goto error_handler2;
1519 }
1520
1521 // Free AmlNameString before returning as it is copied
1522 // in the call to AmlCreateDataNode().
1523 goto error_handler1;
1524
1525error_handler2:
1526 if (ObjectNode != NULL) {
1527 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
1528 }
1529
1530error_handler1:
1531 if (AmlNameString != NULL) {
1532 FreePool (AmlNameString);
1533 }
1534
1535 return Status;
1536}
1537
1571STATIC
1573EFIAPI
1575 IN CONST CHAR8 *NameString,
1576 IN UINT8 NumArgs,
1577 IN BOOLEAN IsSerialized,
1578 IN UINT8 SyncLevel,
1579 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1580 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1581 )
1582{
1583 EFI_STATUS Status;
1584 UINT32 PkgLen;
1585 UINT8 Flags;
1586 AML_OBJECT_NODE *ObjectNode;
1587 AML_DATA_NODE *DataNode;
1588 CHAR8 *AmlNameString;
1589 UINT32 AmlNameStringSize;
1590
1591 if ((NameString == NULL) ||
1592 (NumArgs > 6) ||
1593 (SyncLevel > 15) ||
1594 ((ParentNode == NULL) && (NewObjectNode == NULL)))
1595 {
1596 ASSERT (0);
1597 return EFI_INVALID_PARAMETER;
1598 }
1599
1600 ObjectNode = NULL;
1601 DataNode = NULL;
1602
1603 // ACPI 6.4, s20.2.5.2 "Named Objects Encoding":
1604 // DefMethod := MethodOp PkgLength NameString MethodFlags TermList
1605 // MethodOp := 0x14
1606 // So:
1607 // 1- Create the NameString
1608 // 2- Compute the size to write in the PkgLen
1609 // 3- Create nodes for the NameString and Method object node
1610 // 4- Set the NameString DataNode as a fixed argument
1611 // 5- Create and link the MethodFlags node
1612
1613 // 1- Create the NameString
1614 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
1615 if (EFI_ERROR (Status)) {
1616 ASSERT (0);
1617 return Status;
1618 }
1619
1620 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1621 if (EFI_ERROR (Status)) {
1622 ASSERT (0);
1623 goto error_handler1;
1624 }
1625
1626 // 2- Compute the size to write in the PkgLen
1627 // Add 1 byte (ByteData) for MethodFlags.
1628 Status = AmlComputePkgLength (AmlNameStringSize + 1, &PkgLen);
1629 if (EFI_ERROR (Status)) {
1630 ASSERT (0);
1631 goto error_handler1;
1632 }
1633
1634 // 3- Create nodes for the NameString and Method object node
1635 Status = AmlCreateObjectNode (
1636 AmlGetByteEncodingByOpCode (AML_METHOD_OP, 0),
1637 PkgLen,
1638 &ObjectNode
1639 );
1640 if (EFI_ERROR (Status)) {
1641 ASSERT (0);
1642 goto error_handler1;
1643 }
1644
1645 Status = AmlCreateDataNode (
1647 (UINT8 *)AmlNameString,
1648 AmlNameStringSize,
1649 &DataNode
1650 );
1651 if (EFI_ERROR (Status)) {
1652 ASSERT (0);
1653 goto error_handler2;
1654 }
1655
1656 // 4- Set the NameString DataNode as a fixed argument
1657 Status = AmlSetFixedArgument (
1658 ObjectNode,
1660 (AML_NODE_HEADER *)DataNode
1661 );
1662 if (EFI_ERROR (Status)) {
1663 ASSERT (0);
1664 goto error_handler2;
1665 }
1666
1667 DataNode = NULL;
1668
1669 // 5- Create and link the MethodFlags node
1670 Flags = NumArgs |
1671 (IsSerialized ? BIT3 : 0) |
1672 (SyncLevel << 4);
1673
1674 Status = AmlCreateDataNode (EAmlNodeDataTypeUInt, &Flags, 1, &DataNode);
1675 if (EFI_ERROR (Status)) {
1676 ASSERT (0);
1677 goto error_handler2;
1678 }
1679
1680 Status = AmlSetFixedArgument (
1681 ObjectNode,
1683 (AML_NODE_HEADER *)DataNode
1684 );
1685 if (EFI_ERROR (Status)) {
1686 ASSERT (0);
1687 goto error_handler2;
1688 }
1689
1690 // Data node is attached so set the pointer to
1691 // NULL to ensure correct error handling.
1692 DataNode = NULL;
1693
1694 Status = LinkNode (
1695 ObjectNode,
1696 ParentNode,
1697 NewObjectNode
1698 );
1699 if (EFI_ERROR (Status)) {
1700 ASSERT (0);
1701 goto error_handler2;
1702 }
1703
1704 // Free AmlNameString before returning as it is copied
1705 // in the call to AmlCreateDataNode().
1706 goto error_handler1;
1707
1708error_handler2:
1709 if (ObjectNode != NULL) {
1710 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
1711 }
1712
1713 if (DataNode != NULL) {
1714 AmlDeleteTree ((AML_NODE_HEADER *)DataNode);
1715 }
1716
1717error_handler1:
1718 if (AmlNameString != NULL) {
1719 FreePool (AmlNameString);
1720 }
1721
1722 return Status;
1723}
1724
1754STATIC
1756EFIAPI
1758 IN AML_NODE_HEADER *ReturnNode,
1759 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1760 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1761 )
1762{
1763 EFI_STATUS Status;
1764 AML_OBJECT_NODE *ObjectNode;
1765
1766 if ((ReturnNode == NULL) ||
1767 ((ParentNode == NULL) && (NewObjectNode == NULL)) ||
1768 ((ParentNode != NULL) &&
1770 (AML_OBJECT_NODE *)ParentNode,
1771 AML_METHOD_OP,
1772 0
1773 )))
1774 {
1775 ASSERT (0);
1776 return EFI_INVALID_PARAMETER;
1777 }
1778
1779 Status = AmlCreateObjectNode (
1780 AmlGetByteEncodingByOpCode (AML_RETURN_OP, 0),
1781 0,
1782 &ObjectNode
1783 );
1784 if (EFI_ERROR (Status)) {
1785 ASSERT (0);
1786 goto error_handler;
1787 }
1788
1789 Status = AmlSetFixedArgument (
1790 ObjectNode,
1792 ReturnNode
1793 );
1794 if (EFI_ERROR (Status)) {
1795 ASSERT (0);
1796 goto error_handler;
1797 }
1798
1799 ReturnNode = NULL;
1800
1801 Status = LinkNode (
1802 ObjectNode,
1803 ParentNode,
1804 NewObjectNode
1805 );
1806 if (EFI_ERROR (Status)) {
1807 ASSERT (0);
1808 goto error_handler;
1809 }
1810
1811 return Status;
1812
1813error_handler:
1814 if (ReturnNode != NULL) {
1815 AmlDeleteTree (ReturnNode);
1816 }
1817
1818 if (ObjectNode != NULL) {
1819 AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode);
1820 }
1821
1822 return Status;
1823}
1824
1858STATIC
1860EFIAPI
1862 IN CONST CHAR8 *NameString,
1863 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1864 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1865 )
1866{
1867 EFI_STATUS Status;
1868 AML_DATA_NODE *DataNode;
1869 CHAR8 *AmlNameString;
1870 UINT32 AmlNameStringSize;
1871
1872 DataNode = NULL;
1873
1874 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
1875 if (EFI_ERROR (Status)) {
1876 ASSERT (0);
1877 return Status;
1878 }
1879
1880 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
1881 if (EFI_ERROR (Status)) {
1882 ASSERT (0);
1883 goto exit_handler;
1884 }
1885
1886 Status = AmlCreateDataNode (
1888 (UINT8 *)AmlNameString,
1889 AmlNameStringSize,
1890 &DataNode
1891 );
1892 if (EFI_ERROR (Status)) {
1893 ASSERT (0);
1894 goto exit_handler;
1895 }
1896
1897 // AmlCodeGenReturn() deletes DataNode if error.
1898 Status = AmlCodeGenReturn (
1899 (AML_NODE_HEADER *)DataNode,
1900 ParentNode,
1901 NewObjectNode
1902 );
1903 ASSERT_EFI_ERROR (Status);
1904
1905exit_handler:
1906 if (AmlNameString != NULL) {
1907 FreePool (AmlNameString);
1908 }
1909
1910 return Status;
1911}
1912
1940STATIC
1942EFIAPI
1944 IN UINT64 Integer,
1945 IN AML_NODE_HEADER *ParentNode OPTIONAL,
1946 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
1947 )
1948{
1949 EFI_STATUS Status;
1950 AML_OBJECT_NODE *IntNode;
1951
1952 IntNode = NULL;
1953
1954 Status = AmlCodeGenInteger (Integer, &IntNode);
1955 if (EFI_ERROR (Status)) {
1956 ASSERT (0);
1957 return Status;
1958 }
1959
1960 // AmlCodeGenReturn() deletes DataNode if error.
1961 Status = AmlCodeGenReturn (
1962 (AML_NODE_HEADER *)IntNode,
1963 ParentNode,
1964 NewObjectNode
1965 );
1966 ASSERT_EFI_ERROR (Status);
1967
1968 return Status;
1969}
1970
2005STATIC
2007EFIAPI
2009 IN CONST CHAR8 *NameString,
2010 IN UINT64 Integer,
2011 IN AML_NODE_HEADER *ParentNode OPTIONAL,
2012 OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL
2013 )
2014{
2015 EFI_STATUS Status;
2016 AML_DATA_NODE *DataNode;
2017 AML_OBJECT_NODE *IntNode;
2018 CHAR8 *AmlNameString;
2019 UINT32 AmlNameStringSize;
2020 AML_OBJECT_NODE *ObjectNode;
2021
2022 DataNode = NULL;
2023 IntNode = NULL;
2024 ObjectNode = NULL;
2025
2026 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
2027 if (EFI_ERROR (Status)) {
2028 ASSERT (0);
2029 return Status;
2030 }
2031
2032 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
2033 if (EFI_ERROR (Status)) {
2034 ASSERT (0);
2035 goto exit_handler;
2036 }
2037
2038 Status = AmlCodeGenInteger (Integer, &IntNode);
2039 if (EFI_ERROR (Status)) {
2040 ASSERT (0);
2041 goto exit_handler;
2042 }
2043
2044 Status = AmlCreateDataNode (
2046 (UINT8 *)AmlNameString,
2047 AmlNameStringSize,
2048 &DataNode
2049 );
2050 if (EFI_ERROR (Status)) {
2051 ASSERT (0);
2052 goto exit_handler1;
2053 }
2054
2055 // AmlCodeGenReturn() deletes DataNode if error.
2056 Status = AmlCodeGenReturn (
2057 (AML_NODE_HEADER *)DataNode,
2058 ParentNode,
2059 &ObjectNode
2060 );
2061 if (EFI_ERROR (Status)) {
2062 ASSERT (0);
2063 goto exit_handler1;
2064 }
2065
2066 Status = AmlVarListAddTail (
2067 (AML_NODE_HANDLE)ObjectNode,
2068 (AML_NODE_HANDLE)IntNode
2069 );
2070 if (EFI_ERROR (Status)) {
2071 // ObjectNode is already attached to ParentNode in AmlCodeGenReturn(),
2072 // so no need to free it here, it will be deleted when deleting the
2073 // ParentNode tree
2074 ASSERT (0);
2075 goto exit_handler1;
2076 }
2077
2078 if (NewObjectNode != 0) {
2079 *NewObjectNode = ObjectNode;
2080 }
2081
2082 goto exit_handler;
2083
2084exit_handler1:
2085 if (IntNode != NULL) {
2086 AmlDeleteTree ((AML_NODE_HANDLE)IntNode);
2087 }
2088
2089exit_handler:
2090 if (AmlNameString != NULL) {
2091 FreePool (AmlNameString);
2092 }
2093
2094 return Status;
2095}
2096
2137EFIAPI
2139 IN CONST CHAR8 *MethodNameString,
2140 IN CONST CHAR8 *ReturnedNameString OPTIONAL,
2141 IN UINT8 NumArgs,
2142 IN BOOLEAN IsSerialized,
2143 IN UINT8 SyncLevel,
2144 IN AML_NODE_HANDLE ParentNode OPTIONAL,
2145 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
2146 )
2147{
2148 EFI_STATUS Status;
2149 AML_OBJECT_NODE_HANDLE MethodNode;
2150
2151 if ((MethodNameString == NULL) ||
2152 ((ParentNode == NULL) && (NewObjectNode == NULL)))
2153 {
2154 ASSERT (0);
2155 return EFI_INVALID_PARAMETER;
2156 }
2157
2158 // Create a Method named MethodNameString.
2159 Status = AmlCodeGenMethod (
2160 MethodNameString,
2161 NumArgs,
2162 IsSerialized,
2163 SyncLevel,
2164 NULL,
2165 &MethodNode
2166 );
2167 if (EFI_ERROR (Status)) {
2168 ASSERT (0);
2169 return Status;
2170 }
2171
2172 // Return ReturnedNameString if provided.
2173 if (ReturnedNameString != NULL) {
2175 ReturnedNameString,
2176 (AML_NODE_HANDLE)MethodNode,
2177 NULL
2178 );
2179 if (EFI_ERROR (Status)) {
2180 ASSERT (0);
2181 goto error_handler;
2182 }
2183 }
2184
2185 Status = LinkNode (
2186 MethodNode,
2187 ParentNode,
2188 NewObjectNode
2189 );
2190 if (EFI_ERROR (Status)) {
2191 ASSERT (0);
2192 goto error_handler;
2193 }
2194
2195 return Status;
2196
2197error_handler:
2198 if (MethodNode != NULL) {
2199 AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
2200 }
2201
2202 return Status;
2203}
2204
2247EFIAPI
2249 IN CONST CHAR8 *MethodNameString,
2250 IN CONST CHAR8 *ReturnedNameString OPTIONAL,
2251 IN UINT8 NumArgs,
2252 IN BOOLEAN IsSerialized,
2253 IN UINT8 SyncLevel,
2254 IN UINT64 IntegerArgument,
2255 IN AML_NODE_HANDLE ParentNode OPTIONAL,
2256 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
2257 )
2258{
2259 EFI_STATUS Status;
2260 AML_OBJECT_NODE_HANDLE MethodNode;
2261
2262 if ((MethodNameString == NULL) ||
2263 ((ParentNode == NULL) && (NewObjectNode == NULL)))
2264 {
2265 ASSERT (0);
2266 return EFI_INVALID_PARAMETER;
2267 }
2268
2269 // Create a Method named MethodNameString.
2270 Status = AmlCodeGenMethod (
2271 MethodNameString,
2272 NumArgs,
2273 IsSerialized,
2274 SyncLevel,
2275 NULL,
2276 &MethodNode
2277 );
2278 if (EFI_ERROR (Status)) {
2279 ASSERT (0);
2280 return Status;
2281 }
2282
2283 // Return ReturnedNameString if provided.
2284 if (ReturnedNameString != NULL) {
2286 ReturnedNameString,
2287 IntegerArgument,
2288 (AML_NODE_HANDLE)MethodNode,
2289 NULL
2290 );
2291 if (EFI_ERROR (Status)) {
2292 ASSERT (0);
2293 goto error_handler;
2294 }
2295 }
2296
2297 Status = LinkNode (
2298 MethodNode,
2299 ParentNode,
2300 NewObjectNode
2301 );
2302 if (EFI_ERROR (Status)) {
2303 ASSERT (0);
2304 goto error_handler;
2305 }
2306
2307 return Status;
2308
2309error_handler:
2310 if (MethodNode != NULL) {
2311 AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
2312 }
2313
2314 return Status;
2315}
2316
2353EFIAPI
2355 IN CONST CHAR8 *MethodNameString,
2356 IN UINT64 ReturnedInteger,
2357 IN UINT8 NumArgs,
2358 IN BOOLEAN IsSerialized,
2359 IN UINT8 SyncLevel,
2360 IN AML_NODE_HANDLE ParentNode OPTIONAL,
2361 OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
2362 )
2363{
2364 EFI_STATUS Status;
2365 AML_OBJECT_NODE_HANDLE MethodNode;
2366
2367 if ((MethodNameString == NULL) ||
2368 ((ParentNode == NULL) && (NewObjectNode == NULL)))
2369 {
2370 ASSERT (0);
2371 return EFI_INVALID_PARAMETER;
2372 }
2373
2374 // Create a Method named MethodNameString.
2375 Status = AmlCodeGenMethod (
2376 MethodNameString,
2377 NumArgs,
2378 IsSerialized,
2379 SyncLevel,
2380 NULL,
2381 &MethodNode
2382 );
2383 if (EFI_ERROR (Status)) {
2384 ASSERT (0);
2385 return Status;
2386 }
2387
2388 Status = AmlCodeGenReturnInteger (
2389 ReturnedInteger,
2390 (AML_NODE_HANDLE)MethodNode,
2391 NULL
2392 );
2393 if (EFI_ERROR (Status)) {
2394 ASSERT (0);
2395 goto error_handler;
2396 }
2397
2398 Status = LinkNode (
2399 MethodNode,
2400 ParentNode,
2401 NewObjectNode
2402 );
2403 if (EFI_ERROR (Status)) {
2404 ASSERT (0);
2405 goto error_handler;
2406 }
2407
2408 return Status;
2409
2410error_handler:
2411 if (MethodNode != NULL) {
2412 AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
2413 }
2414
2415 return Status;
2416}
2417
2451EFIAPI
2453 IN CONST CHAR8 *LpiNameString,
2454 IN UINT16 Revision,
2455 IN UINT64 LevelId,
2456 IN AML_NODE_HANDLE ParentNode OPTIONAL,
2457 OUT AML_OBJECT_NODE_HANDLE *NewLpiNode OPTIONAL
2458 )
2459{
2460 EFI_STATUS Status;
2461 AML_OBJECT_NODE_HANDLE PackageNode;
2462 AML_OBJECT_NODE_HANDLE IntegerNode;
2463
2464 if ((LpiNameString == NULL) ||
2465 ((ParentNode == NULL) && (NewLpiNode == NULL)))
2466 {
2467 ASSERT (0);
2468 return EFI_INVALID_PARAMETER;
2469 }
2470
2471 IntegerNode = NULL;
2472
2473 Status = AmlCodeGenPackage (&PackageNode);
2474 if (EFI_ERROR (Status)) {
2475 ASSERT (0);
2476 return Status;
2477 }
2478
2479 // Create and attach Revision
2480 Status = AmlCodeGenInteger (Revision, &IntegerNode);
2481 if (EFI_ERROR (Status)) {
2482 ASSERT (0);
2483 IntegerNode = NULL;
2484 goto error_handler;
2485 }
2486
2487 Status = AmlVarListAddTail (
2488 (AML_NODE_HANDLE)PackageNode,
2489 (AML_NODE_HANDLE)IntegerNode
2490 );
2491 if (EFI_ERROR (Status)) {
2492 ASSERT (0);
2493 goto error_handler;
2494 }
2495
2496 IntegerNode = NULL;
2497
2498 // Create and attach LevelId
2499 Status = AmlCodeGenInteger (LevelId, &IntegerNode);
2500 if (EFI_ERROR (Status)) {
2501 ASSERT (0);
2502 IntegerNode = NULL;
2503 goto error_handler;
2504 }
2505
2506 Status = AmlVarListAddTail (
2507 (AML_NODE_HANDLE)PackageNode,
2508 (AML_NODE_HANDLE)IntegerNode
2509 );
2510 if (EFI_ERROR (Status)) {
2511 ASSERT (0);
2512 goto error_handler;
2513 }
2514
2515 IntegerNode = NULL;
2516
2517 // Create and attach Count. No LPI state is added, so 0.
2518 Status = AmlCodeGenInteger (0, &IntegerNode);
2519 if (EFI_ERROR (Status)) {
2520 ASSERT (0);
2521 IntegerNode = NULL;
2522 goto error_handler;
2523 }
2524
2525 Status = AmlVarListAddTail (
2526 (AML_NODE_HANDLE)PackageNode,
2527 (AML_NODE_HANDLE)IntegerNode
2528 );
2529 if (EFI_ERROR (Status)) {
2530 ASSERT (0);
2531 goto error_handler;
2532 }
2533
2534 IntegerNode = NULL;
2535
2536 Status = AmlCodeGenName (LpiNameString, PackageNode, ParentNode, NewLpiNode);
2537 if (EFI_ERROR (Status)) {
2538 ASSERT (0);
2539 goto error_handler;
2540 }
2541
2542 return Status;
2543
2544error_handler:
2545 AmlDeleteTree ((AML_NODE_HANDLE)PackageNode);
2546 if (IntegerNode != NULL) {
2547 AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);
2548 }
2549
2550 return Status;
2551}
2552
2606EFIAPI
2608 IN UINT32 MinResidency,
2609 IN UINT32 WorstCaseWakeLatency,
2610 IN UINT32 Flags,
2611 IN UINT32 ArchFlags,
2612 IN UINT32 ResCntFreq,
2613 IN UINT32 EnableParentState,
2614 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *GenericRegisterDescriptor OPTIONAL,
2615 IN UINT64 Integer OPTIONAL,
2616 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *ResidencyCounterRegister OPTIONAL,
2617 IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *UsageCounterRegister OPTIONAL,
2618 IN CONST CHAR8 *StateName OPTIONAL,
2620 )
2621{
2622 EFI_STATUS Status;
2623 AML_DATA_NODE_HANDLE RdNode;
2624 AML_OBJECT_NODE_HANDLE PackageNode;
2625 AML_OBJECT_NODE_HANDLE IntegerNode;
2626 AML_OBJECT_NODE_HANDLE StringNode;
2627 AML_OBJECT_NODE_HANDLE NewLpiPackageNode;
2628 AML_OBJECT_NODE_HANDLE ResourceTemplateNode;
2629
2630 UINT32 Index;
2631 AML_OBJECT_NODE_HANDLE CountNode;
2632 UINT64 Count;
2633
2634 if ((LpiNode == NULL) ||
2636 (!AmlNodeHasOpCode (LpiNode, AML_NAME_OP, 0)))
2637 {
2638 ASSERT (0);
2639 return EFI_INVALID_PARAMETER;
2640 }
2641
2642 RdNode = 0;
2643 StringNode = NULL;
2644 IntegerNode = NULL;
2645 ResourceTemplateNode = NULL;
2646
2647 // AmlCreateLpiNode () created a LPI container such as:
2648 // Name (_LPI, Package (
2649 // 0, // Revision
2650 // 1, // LevelId
2651 // 0 // Count
2652 // ))
2653 // Get the LPI container, a PackageOp object node stored as the 2nd fixed
2654 // argument (i.e. index 1) of LpiNode.
2656 LpiNode,
2658 );
2659 if ((PackageNode == NULL) ||
2660 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||
2661 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
2662 {
2663 ASSERT (0);
2664 return EFI_INVALID_PARAMETER;
2665 }
2666
2667 CountNode = NULL;
2668 // The third variable argument is the LPI Count node.
2669 for (Index = 0; Index < 3; Index++) {
2671 (AML_NODE_HANDLE)PackageNode,
2672 (AML_NODE_HANDLE)CountNode
2673 );
2674 if (CountNode == NULL) {
2675 ASSERT (0);
2676 return EFI_INVALID_PARAMETER;
2677 }
2678 }
2679
2680 Status = AmlNodeGetIntegerValue (CountNode, &Count);
2681 if (EFI_ERROR (Status)) {
2682 ASSERT (0);
2683 return Status;
2684 }
2685
2686 Status = AmlUpdateInteger (CountNode, Count + 1);
2687 if (EFI_ERROR (Status)) {
2688 ASSERT (0);
2689 return Status;
2690 }
2691
2692 Status = AmlCodeGenPackage (&NewLpiPackageNode);
2693 if (EFI_ERROR (Status)) {
2694 ASSERT (0);
2695 return Status;
2696 }
2697
2698 // MinResidency
2699 Status = AmlCodeGenInteger (MinResidency, &IntegerNode);
2700 if (EFI_ERROR (Status)) {
2701 ASSERT (0);
2702 IntegerNode = NULL;
2703 goto error_handler;
2704 }
2705
2706 Status = AmlVarListAddTail (
2707 (AML_NODE_HANDLE)NewLpiPackageNode,
2708 (AML_NODE_HANDLE)IntegerNode
2709 );
2710 if (EFI_ERROR (Status)) {
2711 ASSERT (0);
2712 goto error_handler;
2713 }
2714
2715 IntegerNode = NULL;
2716
2717 // WorstCaseWakeLatency
2718 Status = AmlCodeGenInteger (WorstCaseWakeLatency, &IntegerNode);
2719 if (EFI_ERROR (Status)) {
2720 ASSERT (0);
2721 IntegerNode = NULL;
2722 goto error_handler;
2723 }
2724
2725 Status = AmlVarListAddTail (
2726 (AML_NODE_HANDLE)NewLpiPackageNode,
2727 (AML_NODE_HANDLE)IntegerNode
2728 );
2729 if (EFI_ERROR (Status)) {
2730 ASSERT (0);
2731 goto error_handler;
2732 }
2733
2734 IntegerNode = NULL;
2735
2736 // Flags
2737 Status = AmlCodeGenInteger (Flags, &IntegerNode);
2738 if (EFI_ERROR (Status)) {
2739 ASSERT (0);
2740 IntegerNode = NULL;
2741 goto error_handler;
2742 }
2743
2744 Status = AmlVarListAddTail (
2745 (AML_NODE_HANDLE)NewLpiPackageNode,
2746 (AML_NODE_HANDLE)IntegerNode
2747 );
2748 if (EFI_ERROR (Status)) {
2749 ASSERT (0);
2750 goto error_handler;
2751 }
2752
2753 IntegerNode = NULL;
2754
2755 // ArchFlags
2756 Status = AmlCodeGenInteger (ArchFlags, &IntegerNode);
2757 if (EFI_ERROR (Status)) {
2758 ASSERT (0);
2759 IntegerNode = NULL;
2760 goto error_handler;
2761 }
2762
2763 Status = AmlVarListAddTail (
2764 (AML_NODE_HANDLE)NewLpiPackageNode,
2765 (AML_NODE_HANDLE)IntegerNode
2766 );
2767 if (EFI_ERROR (Status)) {
2768 ASSERT (0);
2769 goto error_handler;
2770 }
2771
2772 IntegerNode = NULL;
2773
2774 // ResCntFreq
2775 Status = AmlCodeGenInteger (ResCntFreq, &IntegerNode);
2776 if (EFI_ERROR (Status)) {
2777 ASSERT (0);
2778 IntegerNode = NULL;
2779 goto error_handler;
2780 }
2781
2782 Status = AmlVarListAddTail (
2783 (AML_NODE_HANDLE)NewLpiPackageNode,
2784 (AML_NODE_HANDLE)IntegerNode
2785 );
2786 if (EFI_ERROR (Status)) {
2787 ASSERT (0);
2788 goto error_handler;
2789 }
2790
2791 IntegerNode = NULL;
2792
2793 // EnableParentState
2794 Status = AmlCodeGenInteger (EnableParentState, &IntegerNode);
2795 if (EFI_ERROR (Status)) {
2796 ASSERT (0);
2797 IntegerNode = NULL;
2798 goto error_handler;
2799 }
2800
2801 Status = AmlVarListAddTail (
2802 (AML_NODE_HANDLE)NewLpiPackageNode,
2803 (AML_NODE_HANDLE)IntegerNode
2804 );
2805 if (EFI_ERROR (Status)) {
2806 ASSERT (0);
2807 goto error_handler;
2808 }
2809
2810 IntegerNode = NULL;
2811
2812 // Entry Method
2813 if (GenericRegisterDescriptor != NULL) {
2814 // Entry Method: As a Register resource data
2815 Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode);
2816 if (EFI_ERROR (Status)) {
2817 ASSERT (0);
2818 ResourceTemplateNode = NULL;
2819 goto error_handler;
2820 }
2821
2822 Status = AmlCodeGenRdRegister (
2823 GenericRegisterDescriptor->AddressSpaceId,
2824 GenericRegisterDescriptor->RegisterBitWidth,
2825 GenericRegisterDescriptor->RegisterBitOffset,
2826 GenericRegisterDescriptor->Address,
2827 GenericRegisterDescriptor->AccessSize,
2828 NULL,
2829 &RdNode
2830 );
2831 if (EFI_ERROR (Status)) {
2832 ASSERT (0);
2833 RdNode = NULL;
2834 goto error_handler;
2835 }
2836
2837 Status = AmlAppendRdNode (ResourceTemplateNode, RdNode);
2838 if (EFI_ERROR (Status)) {
2839 ASSERT (0);
2840 goto error_handler;
2841 }
2842
2843 RdNode = NULL;
2844
2845 Status = AmlVarListAddTail (
2846 (AML_NODE_HANDLE)NewLpiPackageNode,
2847 (AML_NODE_HANDLE)ResourceTemplateNode
2848 );
2849 if (EFI_ERROR (Status)) {
2850 ASSERT (0);
2851 goto error_handler;
2852 }
2853
2854 ResourceTemplateNode = NULL;
2855 } else {
2856 // Entry Method: As an integer
2857 Status = AmlCodeGenInteger (Integer, &IntegerNode);
2858 if (EFI_ERROR (Status)) {
2859 ASSERT (0);
2860 IntegerNode = NULL;
2861 goto error_handler;
2862 }
2863
2864 Status = AmlVarListAddTail (
2865 (AML_NODE_HANDLE)NewLpiPackageNode,
2866 (AML_NODE_HANDLE)IntegerNode
2867 );
2868 if (EFI_ERROR (Status)) {
2869 ASSERT (0);
2870 goto error_handler;
2871 }
2872
2873 IntegerNode = NULL;
2874 }
2875
2876 // Residency Counter Register.
2877 Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode);
2878 if (EFI_ERROR (Status)) {
2879 ASSERT (0);
2880 ResourceTemplateNode = NULL;
2881 goto error_handler;
2882 }
2883
2884 if (ResidencyCounterRegister != NULL) {
2885 Status = AmlCodeGenRdRegister (
2886 ResidencyCounterRegister->AddressSpaceId,
2887 ResidencyCounterRegister->RegisterBitWidth,
2888 ResidencyCounterRegister->RegisterBitOffset,
2889 ResidencyCounterRegister->Address,
2890 ResidencyCounterRegister->AccessSize,
2891 NULL,
2892 &RdNode
2893 );
2894 } else {
2895 Status = AmlCodeGenRdRegister (
2896 EFI_ACPI_6_4_SYSTEM_MEMORY,
2897 0,
2898 0,
2899 0,
2900 0,
2901 NULL,
2902 &RdNode
2903 );
2904 }
2905
2906 if (EFI_ERROR (Status)) {
2907 ASSERT (0);
2908 RdNode = NULL;
2909 goto error_handler;
2910 }
2911
2912 Status = AmlAppendRdNode (ResourceTemplateNode, RdNode);
2913 if (EFI_ERROR (Status)) {
2914 ASSERT (0);
2915 goto error_handler;
2916 }
2917
2918 RdNode = NULL;
2919
2920 Status = AmlVarListAddTail (
2921 (AML_NODE_HANDLE)NewLpiPackageNode,
2922 (AML_NODE_HANDLE)ResourceTemplateNode
2923 );
2924 if (EFI_ERROR (Status)) {
2925 ASSERT (0);
2926 goto error_handler;
2927 }
2928
2929 ResourceTemplateNode = NULL;
2930
2931 // Usage Counter Register.
2932 Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode);
2933 if (EFI_ERROR (Status)) {
2934 ASSERT (0);
2935 ResourceTemplateNode = NULL;
2936 goto error_handler;
2937 }
2938
2939 if (UsageCounterRegister != NULL) {
2940 Status = AmlCodeGenRdRegister (
2941 UsageCounterRegister->AddressSpaceId,
2942 UsageCounterRegister->RegisterBitWidth,
2943 UsageCounterRegister->RegisterBitOffset,
2944 UsageCounterRegister->Address,
2945 UsageCounterRegister->AccessSize,
2946 NULL,
2947 &RdNode
2948 );
2949 } else {
2950 Status = AmlCodeGenRdRegister (
2951 EFI_ACPI_6_4_SYSTEM_MEMORY,
2952 0,
2953 0,
2954 0,
2955 0,
2956 NULL,
2957 &RdNode
2958 );
2959 }
2960
2961 if (EFI_ERROR (Status)) {
2962 ASSERT (0);
2963 RdNode = NULL;
2964 goto error_handler;
2965 }
2966
2967 Status = AmlAppendRdNode (ResourceTemplateNode, RdNode);
2968 if (EFI_ERROR (Status)) {
2969 ASSERT (0);
2970 goto error_handler;
2971 }
2972
2973 RdNode = NULL;
2974
2975 Status = AmlVarListAddTail (
2976 (AML_NODE_HANDLE)NewLpiPackageNode,
2977 (AML_NODE_HANDLE)ResourceTemplateNode
2978 );
2979 if (EFI_ERROR (Status)) {
2980 ASSERT (0);
2981 goto error_handler;
2982 }
2983
2984 ResourceTemplateNode = NULL;
2985
2986 // State name.
2987 if (UsageCounterRegister != NULL) {
2988 Status = AmlCodeGenString (StateName, &StringNode);
2989 } else {
2990 Status = AmlCodeGenString ("", &StringNode);
2991 }
2992
2993 if (EFI_ERROR (Status)) {
2994 ASSERT (0);
2995 StringNode = NULL;
2996 goto error_handler;
2997 }
2998
2999 Status = AmlVarListAddTail (
3000 (AML_NODE_HANDLE)NewLpiPackageNode,
3001 (AML_NODE_HANDLE)StringNode
3002 );
3003 if (EFI_ERROR (Status)) {
3004 ASSERT (0);
3005 goto error_handler;
3006 }
3007
3008 StringNode = NULL;
3009
3010 // Add the new LPI state to the LpiNode.
3011 Status = AmlVarListAddTail (
3012 (AML_NODE_HANDLE)PackageNode,
3013 (AML_NODE_HANDLE)NewLpiPackageNode
3014 );
3015 if (EFI_ERROR (Status)) {
3016 ASSERT (0);
3017 goto error_handler;
3018 }
3019
3020 return Status;
3021
3022error_handler:
3023 if (RdNode != NULL) {
3025 }
3026
3027 if (NewLpiPackageNode != NULL) {
3028 AmlDeleteTree ((AML_NODE_HANDLE)NewLpiPackageNode);
3029 }
3030
3031 if (StringNode != NULL) {
3032 AmlDeleteTree ((AML_NODE_HANDLE)StringNode);
3033 }
3034
3035 if (IntegerNode != NULL) {
3036 AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);
3037 }
3038
3039 if (ResourceTemplateNode != NULL) {
3040 AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode);
3041 }
3042
3043 return Status;
3044}
3045
3069EFIAPI
3071 IN CONST EFI_GUID *Uuid,
3072 IN AML_OBJECT_NODE_HANDLE DsdNode,
3073 OUT AML_OBJECT_NODE_HANDLE *PackageNode
3074 )
3075{
3076 EFI_STATUS Status;
3077 AML_OBJECT_NODE *UuidNode;
3078 AML_DATA_NODE *UuidDataNode;
3079 AML_OBJECT_NODE_HANDLE DsdEntryList;
3080
3081 if ((Uuid == NULL) ||
3082 (PackageNode == NULL) ||
3084 (!AmlNodeHasOpCode (DsdNode, AML_NAME_OP, 0)) ||
3085 !AmlNameOpCompareName (DsdNode, "_DSD"))
3086 {
3087 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
3088 return EFI_INVALID_PARAMETER;
3089 }
3090
3091 // Get the Package object node of the _DSD node,
3092 // which is the 2nd fixed argument (i.e. index 1).
3094 DsdNode,
3096 );
3097 if ((DsdEntryList == NULL) ||
3098 (AmlGetNodeType ((AML_NODE_HANDLE)DsdEntryList) != EAmlNodeObject) ||
3099 (!AmlNodeHasOpCode (DsdEntryList, AML_PACKAGE_OP, 0)))
3100 {
3101 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
3102 return EFI_INVALID_PARAMETER;
3103 }
3104
3105 *PackageNode = NULL;
3106 UuidDataNode = NULL;
3107
3108 Status = AmlCodeGenBuffer (NULL, 0, &UuidNode);
3109 if (EFI_ERROR (Status)) {
3110 ASSERT_EFI_ERROR (Status);
3111 return Status;
3112 }
3113
3114 Status = AmlCreateDataNode (
3116 (CONST UINT8 *)Uuid,
3117 sizeof (EFI_GUID),
3118 &UuidDataNode
3119 );
3120 if (EFI_ERROR (Status)) {
3121 ASSERT_EFI_ERROR (Status);
3122 goto error_handler;
3123 }
3124
3125 Status = AmlVarListAddTail (
3126 (AML_NODE_HEADER *)UuidNode,
3127 (AML_NODE_HEADER *)UuidDataNode
3128 );
3129 if (EFI_ERROR (Status)) {
3130 ASSERT_EFI_ERROR (Status);
3131 goto error_handler;
3132 }
3133
3134 UuidDataNode = NULL;
3135
3136 // Append to the list of _DSD entries.
3137 Status = AmlVarListAddTail (
3138 (AML_NODE_HANDLE)DsdEntryList,
3139 (AML_NODE_HANDLE)UuidNode
3140 );
3141 if (EFI_ERROR (Status)) {
3142 ASSERT_EFI_ERROR (Status);
3143 goto error_handler;
3144 }
3145
3146 Status = AmlCodeGenPackage (PackageNode);
3147 if (EFI_ERROR (Status)) {
3148 ASSERT_EFI_ERROR (Status);
3149 goto error_handler_detach;
3150 }
3151
3152 // Append to the list of _DSD entries.
3153 Status = AmlVarListAddTail (
3154 (AML_NODE_HANDLE)DsdEntryList,
3155 (AML_NODE_HANDLE)*PackageNode
3156 );
3157 if (EFI_ERROR (Status)) {
3158 ASSERT_EFI_ERROR (Status);
3159 goto error_handler_detach;
3160 }
3161
3162 return Status;
3163
3164error_handler_detach:
3165 if (UuidNode != NULL) {
3166 AmlDetachNode ((AML_NODE_HANDLE)UuidNode);
3167 }
3168
3169error_handler:
3170 if (UuidNode != NULL) {
3171 AmlDeleteTree ((AML_NODE_HANDLE)UuidNode);
3172 }
3173
3174 if (*PackageNode != NULL) {
3175 AmlDeleteTree ((AML_NODE_HANDLE)*PackageNode);
3176 *PackageNode = NULL;
3177 }
3178
3179 if (UuidDataNode != NULL) {
3180 AmlDeleteTree ((AML_NODE_HANDLE)UuidDataNode);
3181 }
3182
3183 return Status;
3184}
3185
3205EFIAPI
3207 IN CONST CHAR8 *Name,
3208 IN UINT64 Value,
3209 IN AML_OBJECT_NODE_HANDLE PackageNode
3210 )
3211{
3212 EFI_STATUS Status;
3213 AML_OBJECT_NODE *NameNode;
3214 AML_OBJECT_NODE *ValueNode;
3215 AML_OBJECT_NODE *NewPackageNode;
3216
3217 if ((Name == NULL) ||
3218 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||
3219 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
3220 {
3221 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
3222 return EFI_INVALID_PARAMETER;
3223 }
3224
3225 NameNode = NULL;
3226 ValueNode = NULL;
3227
3228 // The new package entry.
3229 Status = AmlCodeGenPackage (&NewPackageNode);
3230 if (EFI_ERROR (Status)) {
3231 ASSERT_EFI_ERROR (Status);
3232 return Status;
3233 }
3234
3235 Status = AmlCodeGenString (Name, &NameNode);
3236 if (EFI_ERROR (Status)) {
3237 ASSERT_EFI_ERROR (Status);
3238 goto error_handler;
3239 }
3240
3241 Status = AmlVarListAddTail (
3242 (AML_NODE_HANDLE)NewPackageNode,
3243 (AML_NODE_HANDLE)NameNode
3244 );
3245 if (EFI_ERROR (Status)) {
3246 ASSERT_EFI_ERROR (Status);
3247 goto error_handler;
3248 }
3249
3250 NameNode = NULL;
3251
3252 Status = AmlCodeGenInteger (Value, &ValueNode);
3253 if (EFI_ERROR (Status)) {
3254 ASSERT_EFI_ERROR (Status);
3255 goto error_handler;
3256 }
3257
3258 Status = AmlVarListAddTail (
3259 (AML_NODE_HANDLE)NewPackageNode,
3260 (AML_NODE_HANDLE)ValueNode
3261 );
3262 if (EFI_ERROR (Status)) {
3263 ASSERT_EFI_ERROR (Status);
3264 goto error_handler;
3265 }
3266
3267 ValueNode = NULL;
3268
3269 Status = AmlVarListAddTail (
3270 (AML_NODE_HANDLE)PackageNode,
3271 (AML_NODE_HANDLE)NewPackageNode
3272 );
3273 if (EFI_ERROR (Status)) {
3274 ASSERT_EFI_ERROR (Status);
3275 goto error_handler;
3276 }
3277
3278 return Status;
3279
3280error_handler:
3281 if (NewPackageNode != NULL) {
3282 AmlDeleteTree ((AML_NODE_HANDLE)NewPackageNode);
3283 }
3284
3285 if (NameNode != NULL) {
3286 AmlDeleteTree ((AML_NODE_HANDLE)NameNode);
3287 }
3288
3289 if (ValueNode != NULL) {
3290 AmlDeleteTree ((AML_NODE_HANDLE)ValueNode);
3291 }
3292
3293 return Status;
3294}
3295
3308STATIC
3310EFIAPI
3313 IN AML_OBJECT_NODE_HANDLE PackageNode
3314 )
3315{
3316 EFI_STATUS Status;
3317 AML_DATA_NODE_HANDLE RdNode;
3318 AML_OBJECT_NODE_HANDLE ResourceTemplateNode;
3319
3320 RdNode = NULL;
3321
3322 Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode);
3323 if (EFI_ERROR (Status)) {
3324 ASSERT_EFI_ERROR (Status);
3325 return Status;
3326 }
3327
3328 if (Register != NULL) {
3329 Status = AmlCodeGenRdRegister (
3330 Register->AddressSpaceId,
3331 Register->RegisterBitWidth,
3332 Register->RegisterBitOffset,
3333 Register->Address,
3334 Register->AccessSize,
3335 NULL,
3336 &RdNode
3337 );
3338 } else {
3339 Status = AmlCodeGenRdRegister (
3340 EFI_ACPI_6_4_SYSTEM_MEMORY,
3341 0,
3342 0,
3343 0,
3344 0,
3345 NULL,
3346 &RdNode
3347 );
3348 }
3349
3350 if (EFI_ERROR (Status)) {
3351 ASSERT_EFI_ERROR (Status);
3352 goto error_handler;
3353 }
3354
3355 Status = AmlAppendRdNode (ResourceTemplateNode, RdNode);
3356 if (EFI_ERROR (Status)) {
3357 ASSERT_EFI_ERROR (Status);
3358 goto error_handler;
3359 }
3360
3361 RdNode = NULL;
3362
3363 Status = AmlVarListAddTail (
3364 (AML_NODE_HANDLE)PackageNode,
3365 (AML_NODE_HANDLE)ResourceTemplateNode
3366 );
3367 if (EFI_ERROR (Status)) {
3368 ASSERT_EFI_ERROR (Status);
3369 goto error_handler;
3370 }
3371
3372 return Status;
3373
3374error_handler:
3375 if (RdNode != NULL) {
3377 }
3378
3379 if (ResourceTemplateNode != NULL) {
3380 AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode);
3381 }
3382
3383 return Status;
3384}
3385
3393STATIC
3394BOOLEAN
3395EFIAPI
3398 )
3399{
3400 if ((Address == NULL) ||
3401 ((Address->AddressSpaceId == EFI_ACPI_6_4_SYSTEM_MEMORY) &&
3402 (Address->Address == 0x0)))
3403 {
3404 return TRUE;
3405 }
3406
3407 return FALSE;
3408}
3409
3422STATIC
3424EFIAPI
3427 IN UINT32 Integer,
3428 IN AML_OBJECT_NODE_HANDLE PackageNode
3429 )
3430{
3431 EFI_STATUS Status;
3432 AML_OBJECT_NODE_HANDLE IntegerNode;
3433
3434 IntegerNode = NULL;
3435
3437 Status = AmlAddRegisterToPackage (Register, PackageNode);
3438 } else {
3439 Status = AmlCodeGenInteger (Integer, &IntegerNode);
3440 if (EFI_ERROR (Status)) {
3441 ASSERT_EFI_ERROR (Status);
3442 return Status;
3443 }
3444
3445 Status = AmlVarListAddTail (
3446 (AML_NODE_HANDLE)PackageNode,
3447 (AML_NODE_HANDLE)IntegerNode
3448 );
3449 }
3450
3451 if (EFI_ERROR (Status)) {
3452 ASSERT_EFI_ERROR (Status);
3453 if (IntegerNode != NULL) {
3454 AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);
3455 }
3456 }
3457
3458 return Status;
3459}
3460
3507EFIAPI
3509 IN AML_CPC_INFO *CpcInfo,
3510 IN AML_NODE_HANDLE ParentNode OPTIONAL,
3511 OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL
3512 )
3513{
3514 EFI_STATUS Status;
3515 AML_OBJECT_NODE_HANDLE CpcNode;
3516 AML_OBJECT_NODE_HANDLE CpcPackage;
3517 UINT32 NumberOfEntries;
3518
3519 if ((CpcInfo == NULL) ||
3520 ((ParentNode == NULL) && (NewCpcNode == NULL)))
3521 {
3522 ASSERT (0);
3523 return EFI_INVALID_PARAMETER;
3524 }
3525
3526 // Revision 3 per ACPI 6.4 specification
3527 if (CpcInfo->Revision == EFI_ACPI_6_5_AML_CPC_REVISION) {
3528 // NumEntries 23 per ACPI 6.4 specification
3529 NumberOfEntries = 23;
3530 } else {
3531 ASSERT (0);
3532 return EFI_INVALID_PARAMETER;
3533 }
3534
3542 if (IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister) ||
3543 IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister) ||
3544 IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister))
3545 {
3546 if ((PcdGet64 (PcdDevelopmentPlatformRelaxations) & BIT0) != 0) {
3547 DEBUG ((
3548 DEBUG_WARN,
3549 "Missing PerformanceLimited|ReferencePerformanceCounter|"
3550 "DeliveredPerformanceCounter field in _CPC object\n"
3551 ));
3552 } else {
3553 ASSERT (0);
3554 return EFI_INVALID_PARAMETER;
3555 }
3556 }
3557
3558 if ((IsNullGenericAddress (&CpcInfo->HighestPerformanceBuffer) &&
3559 (CpcInfo->HighestPerformanceInteger == 0)) ||
3560 (IsNullGenericAddress (&CpcInfo->NominalPerformanceBuffer) &&
3561 (CpcInfo->NominalPerformanceInteger == 0)) ||
3562 (IsNullGenericAddress (&CpcInfo->LowestNonlinearPerformanceBuffer) &&
3563 (CpcInfo->LowestNonlinearPerformanceInteger == 0)) ||
3564 (IsNullGenericAddress (&CpcInfo->LowestPerformanceBuffer) &&
3565 (CpcInfo->LowestPerformanceInteger == 0)) ||
3566 IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister))
3567 {
3568 ASSERT (0);
3569 return EFI_INVALID_PARAMETER;
3570 }
3571
3572 CpcPackage = NULL;
3573
3574 Status = AmlCodeGenNamePackage ("_CPC", NULL, &CpcNode);
3575 if (EFI_ERROR (Status)) {
3576 ASSERT_EFI_ERROR (Status);
3577 return Status;
3578 }
3579
3580 // Get the Package object node of the _CPC node,
3581 // which is the 2nd fixed argument (i.e. index 1).
3583 CpcNode,
3585 );
3586 if ((CpcPackage == NULL) ||
3587 (AmlGetNodeType ((AML_NODE_HANDLE)CpcPackage) != EAmlNodeObject) ||
3588 (!AmlNodeHasOpCode (CpcPackage, AML_PACKAGE_OP, 0)))
3589 {
3590 ASSERT (0);
3591 Status = EFI_INVALID_PARAMETER;
3592 goto error_handler;
3593 }
3594
3596 NULL,
3597 NumberOfEntries,
3598 CpcPackage
3599 );
3600 if (EFI_ERROR (Status)) {
3601 ASSERT_EFI_ERROR (Status);
3602 goto error_handler;
3603 }
3604
3606 NULL,
3607 CpcInfo->Revision,
3608 CpcPackage
3609 );
3610 if (EFI_ERROR (Status)) {
3611 ASSERT_EFI_ERROR (Status);
3612 goto error_handler;
3613 }
3614
3616 &CpcInfo->HighestPerformanceBuffer,
3617 CpcInfo->HighestPerformanceInteger,
3618 CpcPackage
3619 );
3620 if (EFI_ERROR (Status)) {
3621 ASSERT_EFI_ERROR (Status);
3622 goto error_handler;
3623 }
3624
3626 &CpcInfo->NominalPerformanceBuffer,
3627 CpcInfo->NominalPerformanceInteger,
3628 CpcPackage
3629 );
3630 if (EFI_ERROR (Status)) {
3631 ASSERT_EFI_ERROR (Status);
3632 goto error_handler;
3633 }
3634
3636 &CpcInfo->LowestNonlinearPerformanceBuffer,
3637 CpcInfo->LowestNonlinearPerformanceInteger,
3638 CpcPackage
3639 );
3640 if (EFI_ERROR (Status)) {
3641 ASSERT_EFI_ERROR (Status);
3642 goto error_handler;
3643 }
3644
3646 &CpcInfo->LowestPerformanceBuffer,
3647 CpcInfo->LowestPerformanceInteger,
3648 CpcPackage
3649 );
3650 if (EFI_ERROR (Status)) {
3651 ASSERT_EFI_ERROR (Status);
3652 goto error_handler;
3653 }
3654
3655 Status = AmlAddRegisterToPackage (&CpcInfo->GuaranteedPerformanceRegister, CpcPackage);
3656 if (EFI_ERROR (Status)) {
3657 ASSERT_EFI_ERROR (Status);
3658 goto error_handler;
3659 }
3660
3661 Status = AmlAddRegisterToPackage (&CpcInfo->DesiredPerformanceRegister, CpcPackage);
3662 if (EFI_ERROR (Status)) {
3663 ASSERT_EFI_ERROR (Status);
3664 goto error_handler;
3665 }
3666
3667 Status = AmlAddRegisterToPackage (&CpcInfo->MinimumPerformanceRegister, CpcPackage);
3668 if (EFI_ERROR (Status)) {
3669 ASSERT_EFI_ERROR (Status);
3670 goto error_handler;
3671 }
3672
3673 Status = AmlAddRegisterToPackage (&CpcInfo->MaximumPerformanceRegister, CpcPackage);
3674 if (EFI_ERROR (Status)) {
3675 ASSERT_EFI_ERROR (Status);
3676 goto error_handler;
3677 }
3678
3679 Status = AmlAddRegisterToPackage (&CpcInfo->PerformanceReductionToleranceRegister, CpcPackage);
3680 if (EFI_ERROR (Status)) {
3681 ASSERT_EFI_ERROR (Status);
3682 goto error_handler;
3683 }
3684
3685 Status = AmlAddRegisterToPackage (&CpcInfo->TimeWindowRegister, CpcPackage);
3686 if (EFI_ERROR (Status)) {
3687 ASSERT_EFI_ERROR (Status);
3688 goto error_handler;
3689 }
3690
3692 &CpcInfo->CounterWraparoundTimeBuffer,
3693 CpcInfo->CounterWraparoundTimeInteger,
3694 CpcPackage
3695 );
3696 if (EFI_ERROR (Status)) {
3697 ASSERT_EFI_ERROR (Status);
3698 goto error_handler;
3699 }
3700
3701 Status = AmlAddRegisterToPackage (&CpcInfo->ReferencePerformanceCounterRegister, CpcPackage);
3702 if (EFI_ERROR (Status)) {
3703 ASSERT_EFI_ERROR (Status);
3704 goto error_handler;
3705 }
3706
3707 Status = AmlAddRegisterToPackage (&CpcInfo->DeliveredPerformanceCounterRegister, CpcPackage);
3708 if (EFI_ERROR (Status)) {
3709 ASSERT_EFI_ERROR (Status);
3710 goto error_handler;
3711 }
3712
3713 Status = AmlAddRegisterToPackage (&CpcInfo->PerformanceLimitedRegister, CpcPackage);
3714 if (EFI_ERROR (Status)) {
3715 ASSERT_EFI_ERROR (Status);
3716 goto error_handler;
3717 }
3718
3719 Status = AmlAddRegisterToPackage (&CpcInfo->CPPCEnableRegister, CpcPackage);
3720 if (EFI_ERROR (Status)) {
3721 ASSERT_EFI_ERROR (Status);
3722 goto error_handler;
3723 }
3724
3726 &CpcInfo->AutonomousSelectionEnableBuffer,
3727 CpcInfo->AutonomousSelectionEnableInteger,
3728 CpcPackage
3729 );
3730 if (EFI_ERROR (Status)) {
3731 ASSERT_EFI_ERROR (Status);
3732 goto error_handler;
3733 }
3734
3735 Status = AmlAddRegisterToPackage (&CpcInfo->AutonomousActivityWindowRegister, CpcPackage);
3736 if (EFI_ERROR (Status)) {
3737 ASSERT_EFI_ERROR (Status);
3738 goto error_handler;
3739 }
3740
3741 Status = AmlAddRegisterToPackage (&CpcInfo->EnergyPerformancePreferenceRegister, CpcPackage);
3742 if (EFI_ERROR (Status)) {
3743 ASSERT_EFI_ERROR (Status);
3744 goto error_handler;
3745 }
3746
3748 &CpcInfo->ReferencePerformanceBuffer,
3749 CpcInfo->ReferencePerformanceInteger,
3750 CpcPackage
3751 );
3752 if (EFI_ERROR (Status)) {
3753 ASSERT_EFI_ERROR (Status);
3754 goto error_handler;
3755 }
3756
3758 &CpcInfo->LowestFrequencyBuffer,
3759 CpcInfo->LowestFrequencyInteger,
3760 CpcPackage
3761 );
3762 if (EFI_ERROR (Status)) {
3763 ASSERT_EFI_ERROR (Status);
3764 goto error_handler;
3765 }
3766
3768 &CpcInfo->NominalFrequencyBuffer,
3769 CpcInfo->NominalFrequencyInteger,
3770 CpcPackage
3771 );
3772 if (EFI_ERROR (Status)) {
3773 ASSERT_EFI_ERROR (Status);
3774 goto error_handler;
3775 }
3776
3777 Status = LinkNode (CpcNode, ParentNode, NewCpcNode);
3778 if (EFI_ERROR (Status)) {
3779 ASSERT_EFI_ERROR (Status);
3780 goto error_handler;
3781 }
3782
3783 return Status;
3784
3785error_handler:
3786 AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);
3787 return Status;
3788}
3789
3801EFIAPI
3803 IN CONST CHAR8 *NameString,
3804 IN AML_OBJECT_NODE_HANDLE NamedNode
3805 )
3806{
3807 EFI_STATUS Status;
3808 AML_DATA_NODE *DataNode;
3809 CHAR8 *AmlNameString;
3810 UINT32 AmlNameStringSize;
3811 AML_OBJECT_NODE_HANDLE PackageNode;
3812
3813 DataNode = NULL;
3814
3815 if ((NamedNode == NULL) ||
3816 (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject) ||
3817 (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))
3818 {
3819 ASSERT (0);
3820 return EFI_INVALID_PARAMETER;
3821 }
3822
3824 NamedNode,
3826 );
3827 if ((PackageNode == NULL) ||
3828 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||
3829 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
3830 {
3831 ASSERT (0);
3832 return EFI_INVALID_PARAMETER;
3833 }
3834
3835 Status = ConvertAslNameToAmlName (NameString, &AmlNameString);
3836 if (EFI_ERROR (Status)) {
3837 ASSERT (0);
3838 return Status;
3839 }
3840
3841 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
3842 if (EFI_ERROR (Status)) {
3843 ASSERT (0);
3844 goto exit_handler;
3845 }
3846
3847 Status = AmlCreateDataNode (
3849 (UINT8 *)AmlNameString,
3850 AmlNameStringSize,
3851 &DataNode
3852 );
3853 if (EFI_ERROR (Status)) {
3854 ASSERT (0);
3855 goto exit_handler;
3856 }
3857
3858 Status = AmlVarListAddTail (
3859 (AML_NODE_HANDLE)PackageNode,
3860 (AML_NODE_HANDLE)DataNode
3861 );
3862 if (EFI_ERROR (Status)) {
3863 AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
3864 }
3865
3866exit_handler:
3867 if (AmlNameString != NULL) {
3868 FreePool (AmlNameString);
3869 }
3870
3871 return Status;
3872}
3873
3907EFIAPI
3909 IN UINT32 Integer,
3911 )
3912{
3913 EFI_STATUS Status;
3914 AML_OBJECT_NODE *PackageNode;
3915
3916 if (NameNode == NULL) {
3918 return EFI_INVALID_PARAMETER;
3919 }
3920
3922 NameNode,
3924 );
3925 if ((PackageNode == NULL) ||
3926 (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||
3927 (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))
3928 {
3930 return EFI_INVALID_PARAMETER;
3931 }
3932
3933 Status = AmlAddRegisterOrIntegerToPackage (NULL, Integer, PackageNode);
3934 if (EFI_ERROR (Status)) {
3935 ASSERT_EFI_ERROR (Status);
3936 }
3937
3938 return Status;
3939}
3940
3996EFIAPI
3998 IN CONST CHAR8 *MethodNameString,
3999 IN UINT8 NumArgs,
4000 IN AML_METHOD_PARAM *Parameters OPTIONAL,
4001 IN AML_NODE_HANDLE ParentNode
4002 )
4003{
4004 EFI_STATUS Status;
4005 UINT8 Index;
4006 CHAR8 *AmlNameString;
4007 UINT32 AmlNameStringSize;
4008 AML_DATA_NODE *DataNode;
4009 AML_OBJECT_NODE *ObjectNode;
4010 AML_NODE_HANDLE *NodeStream;
4011
4012 if ((MethodNameString == NULL) || (ParentNode == NULL)) {
4013 ASSERT (0);
4014 return EFI_INVALID_PARAMETER;
4015 }
4016
4017 if ((NumArgs > 7) ||
4018 ((Parameters == NULL) && (NumArgs > 0)))
4019 {
4020 ASSERT (0);
4021 return EFI_INVALID_PARAMETER;
4022 }
4023
4025 NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs + 1));
4026 if (NodeStream == NULL) {
4027 ASSERT (0);
4028 return EFI_OUT_OF_RESOURCES;
4029 }
4030
4032 Status = ConvertAslNameToAmlName (MethodNameString, &AmlNameString);
4033 if (EFI_ERROR (Status)) {
4034 ASSERT_EFI_ERROR (Status);
4035 goto exit_handler;
4036 }
4037
4038 Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
4039 if (EFI_ERROR (Status)) {
4040 ASSERT_EFI_ERROR (Status);
4041 FreePool (AmlNameString);
4042 goto exit_handler;
4043 }
4044
4045 DataNode = NULL;
4046 Status = AmlCreateDataNode (
4048 (UINT8 *)AmlNameString,
4049 AmlNameStringSize,
4050 &DataNode
4051 );
4052 FreePool (AmlNameString);
4053 if (EFI_ERROR (Status)) {
4054 ASSERT_EFI_ERROR (Status);
4055 goto exit_handler;
4056 }
4057
4058 NodeStream[0] = (AML_NODE_HANDLE)DataNode;
4059
4060 if (Parameters != NULL) {
4062 for (Index = 0; Index < NumArgs; Index++) {
4063 ObjectNode = NULL;
4064 switch (Parameters[Index].Type) {
4065 case AmlMethodParamTypeInteger:
4066 Status = AmlCodeGenInteger (
4067 Parameters[Index].Data.Integer,
4068 &ObjectNode
4069 );
4070 if (EFI_ERROR (Status)) {
4071 ASSERT_EFI_ERROR (Status);
4072 goto exit_handler;
4073 }
4074
4075 break;
4076 case AmlMethodParamTypeString:
4077 if (Parameters[Index].Data.Buffer == NULL) {
4078 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
4079 Status = EFI_INVALID_PARAMETER;
4080 goto exit_handler;
4081 }
4082
4083 Status = AmlCodeGenString (
4084 Parameters[Index].Data.Buffer,
4085 &ObjectNode
4086 );
4087 if (EFI_ERROR (Status)) {
4088 ASSERT_EFI_ERROR (Status);
4089 goto exit_handler;
4090 }
4091
4092 break;
4093 case AmlMethodParamTypeArg:
4094 if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) {
4095 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
4096 Status = EFI_INVALID_PARAMETER;
4097 goto exit_handler;
4098 }
4099
4100 Status = AmlCreateObjectNode (
4102 AML_ARG0 + Parameters[Index].Data.Arg,
4103 0
4104 ),
4105 0,
4106 &ObjectNode
4107 );
4108 if (EFI_ERROR (Status)) {
4109 ASSERT_EFI_ERROR (Status);
4110 goto exit_handler;
4111 }
4112
4113 break;
4114 case AmlMethodParamTypeLocal:
4115 if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) {
4116 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
4117 Status = EFI_INVALID_PARAMETER;
4118 goto exit_handler;
4119 }
4120
4121 Status = AmlCreateObjectNode (
4123 AML_LOCAL0 + Parameters[Index].Data.Local,
4124 0
4125 ),
4126 0,
4127 &ObjectNode
4128 );
4129 if (EFI_ERROR (Status)) {
4130 ASSERT_EFI_ERROR (Status);
4131 goto exit_handler;
4132 }
4133
4134 break;
4135 default:
4136 ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
4137 Status = EFI_INVALID_PARAMETER;
4138 goto exit_handler;
4139 } // switch
4140
4141 // Link the Object Node in the Node Stream.
4142 NodeStream[Index + 1] = (AML_NODE_HANDLE)ObjectNode;
4143 } // for
4144 }
4145
4147 for (Index = 0; Index <= NumArgs; Index++) {
4148 Status = AmlVarListAddTail (
4149 (AML_NODE_HANDLE)ParentNode,
4150 (AML_NODE_HANDLE)NodeStream[Index]
4151 );
4152 if (EFI_ERROR (Status)) {
4153 ASSERT_EFI_ERROR (Status);
4154 goto exit_handler_detach;
4155 }
4156 }
4157
4158 FreePool (NodeStream);
4159 return Status;
4160
4161exit_handler_detach:
4163 for ( ; Index > 0; Index--) {
4166 AmlDetachNode (NodeStream[Index-1]);
4167 }
4168
4169exit_handler:
4171 for (Index = 0; Index <= NumArgs; Index++) {
4172 if (NodeStream[Index] != 0) {
4173 AmlDeleteTree (NodeStream[Index]);
4174 }
4175 }
4176
4177 FreePool (NodeStream);
4178 return Status;
4179}
4180
4209EFIAPI
4211 IN AML_PSD_INFO *PsdInfo,
4212 IN AML_NODE_HANDLE ParentNode OPTIONAL,
4213 OUT AML_OBJECT_NODE_HANDLE *NewPsdNode OPTIONAL
4214 )
4215{
4216 EFI_STATUS Status;
4217 AML_OBJECT_NODE_HANDLE PsdNode;
4218 AML_OBJECT_NODE_HANDLE PsdParentPackage;
4219 AML_OBJECT_NODE_HANDLE PsdPackage;
4220 AML_OBJECT_NODE_HANDLE IntegerNode;
4221 UINT32 NumberOfEntries;
4222
4223 PsdParentPackage = NULL;
4224 PsdPackage = NULL;
4225
4226 if ((PsdInfo == NULL) ||
4227 ((ParentNode == NULL) && (NewPsdNode == NULL)))
4228 {
4229 Status = EFI_INVALID_PARAMETER;
4230 ASSERT_EFI_ERROR (Status);
4231 return Status;
4232 }
4233
4234 // Revision 3 per ACPI 6.5 specification
4235 if (PsdInfo->Revision == EFI_ACPI_6_5_AML_PSD_REVISION) {
4236 // NumEntries 5 per ACPI 6.5 specification
4237 NumberOfEntries = 5;
4238 } else {
4239 Status = EFI_INVALID_PARAMETER;
4240 ASSERT_EFI_ERROR (Status);
4241 return Status;
4242 }
4243
4244 if (((PsdInfo->CoordType != ACPI_AML_COORD_TYPE_SW_ALL) &&
4245 (PsdInfo->CoordType != ACPI_AML_COORD_TYPE_SW_ANY) &&
4246 (PsdInfo->CoordType != ACPI_AML_COORD_TYPE_HW_ALL)) ||
4247 (PsdInfo->NumProc == 0))
4248 {
4249 Status = EFI_INVALID_PARAMETER;
4250 ASSERT_EFI_ERROR (Status);
4251 return Status;
4252 }
4253
4254 Status = AmlCodeGenNamePackage ("_PSD", NULL, &PsdNode);
4255 if (EFI_ERROR (Status)) {
4256 ASSERT_EFI_ERROR (Status);
4257 return Status;
4258 }
4259
4260 // Get the Package object node of the _PSD node,
4261 // which is the 2nd fixed argument (i.e. index 1).
4262 PsdParentPackage = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (
4263 PsdNode,
4265 );
4266 if ((PsdParentPackage == NULL) ||
4267 (AmlGetNodeType ((AML_NODE_HANDLE)PsdParentPackage) != EAmlNodeObject) ||
4268 (!AmlNodeHasOpCode (PsdParentPackage, AML_PACKAGE_OP, 0)))
4269 {
4270 Status = EFI_INVALID_PARAMETER;
4271 ASSERT_EFI_ERROR (Status);
4272 goto error_handler;
4273 }
4274
4275 Status = AmlCodeGenPackage (&PsdPackage);
4276 if (EFI_ERROR (Status)) {
4277 ASSERT_EFI_ERROR (Status);
4278 goto error_handler;
4279 }
4280
4281 // NumEntries
4282 Status = AmlCodeGenInteger (NumberOfEntries, &IntegerNode);
4283 if (EFI_ERROR (Status)) {
4284 ASSERT_EFI_ERROR (Status);
4285 goto error_handler;
4286 }
4287
4288 Status = AmlVarListAddTail (
4289 (AML_NODE_HANDLE)PsdPackage,
4290 (AML_NODE_HANDLE)IntegerNode
4291 );
4292 if (EFI_ERROR (Status)) {
4293 ASSERT_EFI_ERROR (Status);
4294 FreePool (IntegerNode);
4295 goto error_handler;
4296 }
4297
4298 // Revision
4299 Status = AmlCodeGenInteger (PsdInfo->Revision, &IntegerNode);
4300 if (EFI_ERROR (Status)) {
4301 ASSERT_EFI_ERROR (Status);
4302 goto error_handler;
4303 }
4304
4305 Status = AmlVarListAddTail (
4306 (AML_NODE_HANDLE)PsdPackage,
4307 (AML_NODE_HANDLE)IntegerNode
4308 );
4309 if (EFI_ERROR (Status)) {
4310 ASSERT_EFI_ERROR (Status);
4311 FreePool (IntegerNode);
4312 goto error_handler;
4313 }
4314
4315 // Domain
4316 Status = AmlCodeGenInteger (PsdInfo->Domain, &IntegerNode);
4317 if (EFI_ERROR (Status)) {
4318 ASSERT_EFI_ERROR (Status);
4319 goto error_handler;
4320 }
4321
4322 Status = AmlVarListAddTail (
4323 (AML_NODE_HANDLE)PsdPackage,
4324 (AML_NODE_HANDLE)IntegerNode
4325 );
4326 if (EFI_ERROR (Status)) {
4327 ASSERT_EFI_ERROR (Status);
4328 FreePool (IntegerNode);
4329 goto error_handler;
4330 }
4331
4332 // CoordType
4333 Status = AmlCodeGenInteger (PsdInfo->CoordType, &IntegerNode);
4334 if (EFI_ERROR (Status)) {
4335 ASSERT_EFI_ERROR (Status);
4336 goto error_handler;
4337 }
4338
4339 Status = AmlVarListAddTail (
4340 (AML_NODE_HANDLE)PsdPackage,
4341 (AML_NODE_HANDLE)IntegerNode
4342 );
4343 if (EFI_ERROR (Status)) {
4344 ASSERT_EFI_ERROR (Status);
4345 FreePool (IntegerNode);
4346 goto error_handler;
4347 }
4348
4349 // Num Processors
4350 Status = AmlCodeGenInteger (PsdInfo->NumProc, &IntegerNode);
4351 if (EFI_ERROR (Status)) {
4352 ASSERT_EFI_ERROR (Status);
4353 goto error_handler;
4354 }
4355
4356 Status = AmlVarListAddTail (
4357 (AML_NODE_HANDLE)PsdPackage,
4358 (AML_NODE_HANDLE)IntegerNode
4359 );
4360 if (EFI_ERROR (Status)) {
4361 ASSERT_EFI_ERROR (Status);
4362 FreePool (IntegerNode);
4363 goto error_handler;
4364 }
4365
4366 Status = AmlVarListAddTail (
4367 (AML_NODE_HANDLE)PsdParentPackage,
4368 (AML_NODE_HANDLE)PsdPackage
4369 );
4370 if (EFI_ERROR (Status)) {
4371 ASSERT_EFI_ERROR (Status);
4372 goto error_handler;
4373 }
4374
4375 PsdPackage = NULL; // Prevent double free if error occurs after this point
4376
4377 Status = LinkNode (PsdNode, ParentNode, NewPsdNode);
4378 if (EFI_ERROR (Status)) {
4379 ASSERT_EFI_ERROR (Status);
4380 goto error_handler;
4381 }
4382
4383 return Status;
4384
4385error_handler:
4386 if (PsdPackage != NULL) {
4387 AmlDeleteTree ((AML_NODE_HANDLE)PsdPackage);
4388 }
4389
4390 if (PsdParentPackage != NULL) {
4391 AmlDeleteTree ((AML_NODE_HANDLE)PsdParentPackage);
4392 }
4393
4394 return Status;
4395}
#define ACPI_AML_COORD_TYPE_SW_ALL
Definition: Acpi30.h:24
#define EFI_ACPI_6_5_AML_CPC_REVISION
Definition: Acpi65.h:29
#define EFI_ACPI_6_5_AML_PSD_REVISION
Definition: Acpi65.h:24
#define TABLE_GENERATOR_CREATOR_ID
BOOLEAN EFIAPI AmlNameOpCompareName(IN AML_OBJECT_NODE_HANDLE NameOpNode, IN CHAR8 *AslName)
Definition: AmlApiHelper.c:46
BOOLEAN EFIAPI AmlNodeHasOpCode(IN AML_OBJECT_NODE_HANDLE ObjectNode, IN UINT8 OpCode, IN UINT8 SubOpCode)
Definition: AmlApiHelper.c:124
EFI_STATUS EFIAPI AmlCodeGenThermalZone(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1330
EFI_STATUS EFIAPI AmlCreateCpcNode(IN AML_CPC_INFO *CpcInfo, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL)
Definition: AmlCodeGen.c:3508
EFI_STATUS EFIAPI AmlCodeGenDefinitionBlock(IN CONST CHAR8 *TableSignature, IN CONST CHAR8 *OemId, IN CONST CHAR8 *OemTableId, IN UINT32 OemRevision, OUT AML_ROOT_NODE **NewRootNode)
Definition: AmlCodeGen.c:93
EFI_STATUS EFIAPI AmlAddNameIntegerPackage(IN CONST CHAR8 *Name, IN UINT64 Value, IN AML_OBJECT_NODE_HANDLE PackageNode)
Definition: AmlCodeGen.c:3206
EFI_STATUS EFIAPI AmlAddIntegerToNamedPackage(IN UINT32 Integer, IN OUT AML_OBJECT_NODE_HANDLE NameNode)
Definition: AmlCodeGen.c:3908
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)
Definition: AmlCodeGen.c:2607
STATIC EFI_STATUS EFIAPI LinkNode(IN AML_OBJECT_NODE *Node, IN AML_NODE_HEADER *ParentNode, OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:39
EFI_STATUS EFIAPI AmlCreatePsdNode(IN AML_PSD_INFO *PsdInfo, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewPsdNode OPTIONAL)
Definition: AmlCodeGen.c:4210
STATIC EFI_STATUS EFIAPI AmlCodeGenPackage(OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:261
EFI_STATUS EFIAPI AmlAddPrtEntry(IN UINT32 Address, IN UINT8 Pin, IN CONST CHAR8 *LinkName, IN UINT32 SourceIndex, IN AML_OBJECT_NODE_HANDLE PrtNameNode)
Definition: AmlCodeGen.c:1008
STATIC EFI_STATUS EFIAPI AmlCodeGenName(IN CONST CHAR8 *NameString, IN AML_OBJECT_NODE *Object, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:537
EFI_STATUS EFIAPI AmlCodeGenDevice(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1214
STATIC EFI_STATUS EFIAPI AmlCodeGenString(IN CONST CHAR8 *String, OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:141
STATIC EFI_STATUS EFIAPI AmlCodeGenBuffer(IN CONST UINT8 *Buffer OPTIONAL, IN UINT32 BufferSize OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:348
EFI_STATUS EFIAPI AmlAddNameStringToNamedPackage(IN CONST CHAR8 *NameString, IN AML_OBJECT_NODE_HANDLE NamedNode)
Definition: AmlCodeGen.c:3802
EFI_STATUS EFIAPI AmlCodeGenNameInteger(IN CONST CHAR8 *NameString, IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:724
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)
Definition: AmlCodeGen.c:2354
STATIC EFI_STATUS EFIAPI AmlCodeGenInteger(IN UINT64 Integer, OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:212
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnInteger(IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1943
STATIC EFI_STATUS EFIAPI AmlAddRegisterToPackage(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, IN AML_OBJECT_NODE_HANDLE PackageNode)
Definition: AmlCodeGen.c:3311
EFI_STATUS EFIAPI AmlAddDeviceDataDescriptorPackage(IN CONST EFI_GUID *Uuid, IN AML_OBJECT_NODE_HANDLE DsdNode, OUT AML_OBJECT_NODE_HANDLE *PackageNode)
Definition: AmlCodeGen.c:3070
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)
Definition: AmlCodeGen.c:2248
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)
Definition: AmlCodeGen.c:2452
EFI_STATUS EFIAPI AmlCodeGenNameUnicodeString(IN CONST CHAR8 *NameString, IN CHAR16 *String, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:897
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnNameStringIntegerArgument(IN CONST CHAR8 *NameString, IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:2008
STATIC BOOLEAN EFIAPI IsNullGenericAddress(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Address)
Definition: AmlCodeGen.c:3396
EFI_STATUS EFIAPI AmlCodeGenScope(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1444
EFI_STATUS EFIAPI AmlCodeGenInvokeMethod(IN CONST CHAR8 *MethodNameString, IN UINT8 NumArgs, IN AML_METHOD_PARAM *Parameters OPTIONAL, IN AML_NODE_HANDLE ParentNode)
Definition: AmlCodeGen.c:3997
STATIC EFI_STATUS EFIAPI AmlCodeGenMethod(IN CONST CHAR8 *NameString, IN UINT8 NumArgs, IN BOOLEAN IsSerialized, IN UINT8 SyncLevel, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1574
STATIC EFI_STATUS EFIAPI AmlAddRegisterOrIntegerToPackage(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, IN UINT32 Integer, IN AML_OBJECT_NODE_HANDLE PackageNode)
Definition: AmlCodeGen.c:3425
EFI_STATUS EFIAPI AmlCodeGenNamePackage(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode, OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:781
STATIC EFI_STATUS EFIAPI AmlCodeGenReturn(IN AML_NODE_HEADER *ReturnNode, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1757
STATIC EFI_STATUS EFIAPI AmlCodeGenResourceTemplate(OUT AML_OBJECT_NODE **NewObjectNode)
Definition: AmlCodeGen.c:488
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnNameString(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:1861
EFI_STATUS EFIAPI AmlCodeGenNameString(IN CONST CHAR8 *NameString, IN CONST CHAR8 *String, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:665
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)
Definition: AmlCodeGen.c:2138
EFI_STATUS EFIAPI AmlCodeGenNameResourceTemplate(IN CONST CHAR8 *NameString, IN AML_NODE_HEADER *ParentNode, OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL)
Definition: AmlCodeGen.c:837
EFI_STATUS EFIAPI AmlUpdateInteger(IN AML_OBJECT_NODE_HANDLE IntegerOpNode, IN UINT64 NewInteger)
EFI_STATUS EFIAPI AmlAppendRdNode(IN AML_OBJECT_NODE_HANDLE BufferOpNode, IN AML_DATA_NODE_HANDLE NewRdNode)
void * AML_DATA_NODE_HANDLE
Definition: AmlLib.h:59
void * AML_OBJECT_NODE_HANDLE
Definition: AmlLib.h:55
void * AML_NODE_HANDLE
Definition: AmlLib.h:47
BOOLEAN EFIAPI AmlNodeCompareOpCode(IN CONST AML_OBJECT_NODE *ObjectNode, IN UINT8 OpCode, IN UINT8 SubOpCode)
Definition: AmlNode.c:457
EFI_STATUS EFIAPI AmlCreateObjectNode(IN CONST AML_BYTE_ENCODING *AmlByteEncoding, IN UINT32 PkgLength, OUT AML_OBJECT_NODE **NewObjectNodePtr)
Definition: AmlNode.c:181
EFI_STATUS EFIAPI AmlCreateRootNode(IN CONST EFI_ACPI_DESCRIPTION_HEADER *SdtHeader, OUT AML_ROOT_NODE **NewRootNodePtr)
Definition: AmlNode.c:92
EFI_STATUS EFIAPI AmlCreateDataNode(IN EAML_NODE_DATA_TYPE DataType, IN CONST UINT8 *Data, IN UINT32 DataSize, OUT AML_DATA_NODE **NewDataNodePtr)
Definition: AmlNode.c:275
EFI_STATUS EFIAPI AmlCodeGenEndTag(IN UINT8 CheckSum OPTIONAL, IN AML_OBJECT_NODE *ParentNode OPTIONAL, OUT AML_DATA_NODE **NewRdNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenRdRegister(IN UINT8 AddressSpace, IN UINT8 BitWidth, IN UINT8 BitOffset, IN UINT64 Address, IN UINT8 AccessSize, IN AML_OBJECT_NODE_HANDLE NameOpNode OPTIONAL, OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL)
EFI_STATUS EFIAPI AmlSetFixedArgument(IN AML_OBJECT_NODE *ObjectNode, IN EAML_PARSE_INDEX Index, IN AML_NODE_HEADER *NewNode)
Definition: AmlTree.c:168
EFI_STATUS EFIAPI AmlNodeGetIntegerValue(IN AML_OBJECT_NODE *Node, OUT UINT64 *Value)
Definition: AmlUtility.c:206
EFI_STATUS EFIAPI AmlNodeSetIntegerValue(IN AML_OBJECT_NODE *Node, IN UINT64 NewValue, OUT INT8 *ValueWidthDiff)
Definition: AmlUtility.c:374
EFI_STATUS EFIAPI AmlComputeSize(IN CONST AML_NODE_HEADER *Node, IN OUT UINT32 *Size)
Definition: AmlUtility.c:169
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
Definition: String.c:641
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
CONST AML_BYTE_ENCODING *EFIAPI AmlGetByteEncodingByOpCode(IN UINT8 OpCode, IN UINT8 SubOpCode)
Definition: Aml.c:347
UINT8 EFIAPI AmlComputePkgLengthWidth(IN UINT32 Length)
Definition: Aml.c:799
EFI_STATUS EFIAPI AmlComputePkgLength(IN UINT32 Length, OUT UINT32 *PkgLen)
Definition: Aml.c:862
EFI_STATUS EFIAPI AmlGetNameStringSize(IN CONST CHAR8 *AmlPath, OUT UINT32 *AmlPathSizePtr)
Definition: AmlString.c:547
EFI_STATUS EFIAPI ConvertAslNameToAmlName(IN CONST CHAR8 *AslPath, OUT CHAR8 **OutAmlPath)
Definition: AmlString.c:598
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGet64(TokenName)
Definition: PcdLib.h:375
EFI_STATUS EFIAPI Register(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback)
#define CREATE_REVISION(Major, Minor)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
AML_NODE_HANDLE EFIAPI AmlGetFixedArgument(IN AML_OBJECT_NODE_HANDLE ObjectNode, IN EAML_PARSE_INDEX Index)
AML_NODE_HANDLE EFIAPI AmlGetNextVariableArgument(IN AML_NODE_HANDLE Node, IN AML_NODE_HANDLE CurrVarArg)
EAML_NODE_TYPE EFIAPI AmlGetNodeType(IN AML_NODE_HANDLE Node)
EFI_STATUS EFIAPI AmlVarListAddTail(IN AML_NODE_HANDLE ParentNode, IN AML_NODE_HANDLE NewNode)
@ EAmlParseIndexTerm1
Second fixed argument index.
Definition: AmlDefines.h:66
@ EAmlParseIndexTerm0
First fixed argument index.
Definition: AmlDefines.h:65
@ EAmlNodeObject
Definition: AmlDefines.h:174
@ EAmlNodeDataTypeRaw
Raw bytes contained in a buffer.
Definition: AmlDefines.h:43
@ EAmlNodeDataTypeString
EAmlString, NULL terminated string.
Definition: AmlDefines.h:40
@ EAmlNodeDataTypeUInt
Definition: AmlDefines.h:41
@ EAmlNodeDataTypeNameString
Definition: AmlDefines.h:37
EFI_STATUS EFIAPI AmlDeleteTree(IN AML_NODE_HANDLE Node)
EFI_STATUS EFIAPI AmlDetachNode(IN AML_NODE_HANDLE Node)
Definition: Base.h:213