TianoCore EDK2 master
Loading...
Searching...
No Matches
AmlMethodParser.c
Go to the documentation of this file.
1
10
11#include <AmlCoreInterface.h>
14#include <Parser/AmlParser.h>
15#include <Tree/AmlNode.h>
16#include <Tree/AmlTree.h>
17#include <String/AmlString.h>
18
31EFIAPI
33 IN AML_NAMESPACE_REF_NODE *NameSpaceRefNode
34 )
35{
36 if (NameSpaceRefNode == NULL) {
37 ASSERT (0);
38 return EFI_INVALID_PARAMETER;
39 }
40
41 if (NameSpaceRefNode->RawAbsolutePath != NULL) {
42 FreePool ((CHAR8 *)NameSpaceRefNode->RawAbsolutePath);
43 } else {
44 ASSERT (0);
45 return EFI_INVALID_PARAMETER;
46 }
47
48 FreePool (NameSpaceRefNode);
49 return EFI_SUCCESS;
50}
51
60EFIAPI
62 IN LIST_ENTRY *NameSpaceRefList
63 )
64{
65 EFI_STATUS Status;
66 LIST_ENTRY *CurrentLink;
67
68 if (NameSpaceRefList == NULL) {
69 ASSERT (0);
70 return EFI_INVALID_PARAMETER;
71 }
72
73 while (!IsListEmpty (NameSpaceRefList)) {
74 CurrentLink = NameSpaceRefList->ForwardLink;
75 RemoveEntryList (CurrentLink);
77 (AML_NAMESPACE_REF_NODE *)CurrentLink
78 );
79 if (EFI_ERROR (Status)) {
80 ASSERT (0);
81 return Status;
82 }
83 } // while
84
85 return EFI_SUCCESS;
86}
87
105STATIC
107EFIAPI
109 IN CONST AML_OBJECT_NODE *ObjectNode,
110 IN CONST CHAR8 *RawAbsolutePath,
111 IN UINT32 RawAbsolutePathSize,
112 OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr
113 )
114{
115 AML_NAMESPACE_REF_NODE *NameSpaceRefNode;
116
117 if (!AmlNodeHasAttribute (ObjectNode, AML_IN_NAMESPACE) ||
118 (RawAbsolutePath == NULL) ||
119 (RawAbsolutePathSize == 0) ||
120 (NameSpaceRefNodePtr == NULL))
121 {
122 ASSERT (0);
123 return EFI_INVALID_PARAMETER;
124 }
125
126 NameSpaceRefNode = AllocateZeroPool (sizeof (AML_NAMESPACE_REF_NODE));
127 if (NameSpaceRefNode == NULL) {
128 ASSERT (0);
129 return EFI_OUT_OF_RESOURCES;
130 }
131
132 NameSpaceRefNode->RawAbsolutePathSize = RawAbsolutePathSize;
133 NameSpaceRefNode->RawAbsolutePath = AllocateCopyPool (
134 RawAbsolutePathSize,
135 RawAbsolutePath
136 );
137 if (NameSpaceRefNode->RawAbsolutePath == NULL) {
138 FreePool (NameSpaceRefNode);
139 ASSERT (0);
140 return EFI_OUT_OF_RESOURCES;
141 }
142
143 InitializeListHead (&NameSpaceRefNode->Link);
144
145 NameSpaceRefNode->NodeRef = ObjectNode;
146 *NameSpaceRefNodePtr = NameSpaceRefNode;
147
148 return EFI_SUCCESS;
149}
150
151#if !defined (MDEPKG_NDEBUG)
152
157VOID
158EFIAPI
160 IN CONST LIST_ENTRY *NameSpaceRefList
161 )
162{
163 LIST_ENTRY *CurrLink;
164 AML_NAMESPACE_REF_NODE *CurrNameSpaceNode;
165
166 if (NameSpaceRefList == NULL) {
167 ASSERT (0);
168 return;
169 }
170
171 DEBUG ((DEBUG_INFO, "AmlMethodParser: List of available raw AML paths:\n"));
172
173 CurrLink = NameSpaceRefList->ForwardLink;
174 while (CurrLink != NameSpaceRefList) {
175 CurrNameSpaceNode = (AML_NAMESPACE_REF_NODE *)CurrLink;
176
177 AMLDBG_PRINT_CHARS (
178 DEBUG_INFO,
179 CurrNameSpaceNode->RawAbsolutePath,
180 CurrNameSpaceNode->RawAbsolutePathSize
181 );
182 DEBUG ((DEBUG_INFO, "\n"));
183
184 CurrLink = CurrLink->ForwardLink;
185 }
186
187 DEBUG ((DEBUG_INFO, "\n"));
188}
189
190#endif // MDEPKG_NDEBUG
191
215STATIC
217EFIAPI
219 IN CONST AML_STREAM *FStream,
220 OUT AML_STREAM *RawPathNameBStream
221 )
222{
223 EFI_STATUS Status;
224
225 UINT8 *RawPathBuffer;
226 CONST CHAR8 *Buffer;
227
228 UINT32 Root;
229 UINT32 ParentPrefix;
230 UINT32 SegCount;
231
232 if (!IS_STREAM (FStream) ||
233 IS_END_OF_STREAM (FStream) ||
234 !IS_STREAM_FORWARD (FStream) ||
235 (RawPathNameBStream == NULL))
236 {
237 ASSERT (0);
238 return EFI_INVALID_PARAMETER;
239 }
240
241 Buffer = (CONST CHAR8 *)AmlStreamGetCurrPos (FStream);
242 if (Buffer == NULL) {
243 ASSERT (0);
244 return EFI_INVALID_PARAMETER;
245 }
246
247 // Parse the NameString information.
248 Status = AmlParseNameStringInfo (
249 Buffer,
250 &Root,
251 &ParentPrefix,
252 &SegCount
253 );
254 if (EFI_ERROR (Status)) {
255 ASSERT (0);
256 return Status;
257 }
258
259 // Get the beginning of the raw NameString.
260 RawPathBuffer = (UINT8 *)AmlGetFirstNameSeg (
261 Buffer,
262 Root,
263 ParentPrefix
264 );
265 if (RawPathBuffer == NULL) {
266 ASSERT (0);
267 return EFI_INVALID_PARAMETER;
268 }
269
270 // Initialize a backward stream containing the raw path.
271 Status = AmlStreamInit (
272 RawPathNameBStream,
273 RawPathBuffer,
274 (SegCount * AML_NAME_SEG_SIZE),
276 );
277 ASSERT_EFI_ERROR (Status);
278
279 return Status;
280}
281
314STATIC
316EFIAPI
319 OUT AML_NODE_HEADER **OutNamedNode
320 )
321{
322 EFI_STATUS Status;
323 CONST AML_NODE_HEADER *NameSpaceNode;
324
325 if ((!IS_AML_OBJECT_NODE (Node) &&
326 !IS_AML_ROOT_NODE (Node)) ||
327 (OutNamedNode == NULL))
328 {
329 ASSERT (0);
330 return EFI_INVALID_PARAMETER;
331 }
332
333 // If Node is not the root node and doesn't have a name defined yet,
334 // get the ancestor NameSpace node.
335 while (!IS_AML_ROOT_NODE (Node) &&
337 (CONST AML_OBJECT_NODE *)Node,
339 ) &&
341 {
343 Node,
344 (AML_NODE_HEADER **)&NameSpaceNode
345 );
346 if (EFI_ERROR (Status)) {
347 ASSERT (0);
348 return Status;
349 }
350
351 // The NameSpaceNode may not have its name defined as yet. In this
352 // case get the next ancestor node.
353 Node = NameSpaceNode;
354 }
355
356 *OutNamedNode = (AML_NODE_HEADER *)Node;
357
358 return EFI_SUCCESS;
359}
360
385STATIC
387EFIAPI
389 IN CONST AML_NODE_HEADER *ParentNode,
390 IN CONST AML_STREAM *PathnameFStream,
391 IN OUT AML_STREAM *AbsolutePathBStream
392 )
393{
394 EFI_STATUS Status;
395
396 AML_NODE_HEADER *NamedParentNode;
397 UINT8 *RawPathBuffer;
398 CONST CHAR8 *CurrPos;
399
400 UINT32 Root;
401 UINT32 ParentPrefix;
402 UINT32 SegCount;
403
404 if ((!IS_AML_OBJECT_NODE (ParentNode) &&
405 !IS_AML_ROOT_NODE (ParentNode)) ||
406 !IS_STREAM (PathnameFStream) ||
407 IS_END_OF_STREAM (PathnameFStream) ||
408 !IS_STREAM_FORWARD (PathnameFStream) ||
409 !IS_STREAM (AbsolutePathBStream) ||
410 IS_END_OF_STREAM (AbsolutePathBStream) ||
411 !IS_STREAM_BACKWARD (AbsolutePathBStream))
412 {
413 ASSERT (0);
414 return EFI_INVALID_PARAMETER;
415 }
416
417 CurrPos = (CONST CHAR8 *)AmlStreamGetCurrPos (PathnameFStream);
418 if (CurrPos == NULL) {
419 ASSERT (0);
420 return EFI_INVALID_PARAMETER;
421 }
422
423 // Parse the NameString information.
424 Status = AmlParseNameStringInfo (
425 CurrPos,
426 &Root,
427 &ParentPrefix,
428 &SegCount
429 );
430 if (EFI_ERROR (Status)) {
431 ASSERT (0);
432 return Status;
433 }
434
435 // Copy the method invocation raw relative path at the end of the Stream.
436 if (SegCount != 0) {
437 // Get the beginning of the raw NameString.
438 RawPathBuffer = (UINT8 *)AmlGetFirstNameSeg (
439 CurrPos,
440 Root,
441 ParentPrefix
442 );
443
444 Status = AmlStreamWrite (
445 AbsolutePathBStream,
446 RawPathBuffer,
447 SegCount * AML_NAME_SEG_SIZE
448 );
449 if (EFI_ERROR (Status)) {
450 ASSERT (0);
451 return Status;
452 }
453 }
454
455 // If the pathname contained an absolute path, this is finished, return.
456 if (Root) {
457 return Status;
458 }
459
460 // Get the first named node of the parent node in its hierarchy.
461 Status = AmlGetFirstNamedAncestorNode (ParentNode, &NamedParentNode);
462 if (EFI_ERROR (Status)) {
463 ASSERT (0);
464 return Status;
465 }
466
467 // Build the raw absolute path of the namespace node.
468 Status = AmlGetRawNameSpacePath (
469 NamedParentNode,
470 ParentPrefix,
471 AbsolutePathBStream
472 );
473 ASSERT_EFI_ERROR (Status);
474
475 return Status;
476}
477
493STATIC
495EFIAPI
497 IN CONST AML_STREAM *RawFStream1,
498 IN CONST AML_STREAM *RawFStream2,
499 OUT UINT32 *CompareCount
500 )
501{
502 EFI_STATUS Status;
503 UINT32 Index;
504
505 AML_STREAM RawFStream1Clone;
506 AML_STREAM RawFStream2Clone;
507 UINT32 Stream1Size;
508 UINT32 Stream2Size;
509 UINT32 CompareLen;
510
511 // Raw NameStrings have a size that is a multiple of the size of NameSegs.
512 if (!IS_STREAM (RawFStream1) ||
513 IS_END_OF_STREAM (RawFStream1) ||
514 !IS_STREAM_FORWARD (RawFStream1) ||
515 !IS_STREAM (RawFStream2) ||
516 IS_END_OF_STREAM (RawFStream2) ||
517 (CompareCount == NULL))
518 {
519 ASSERT (0);
520 return EFI_INVALID_PARAMETER;
521 }
522
523 Stream1Size = AmlStreamGetFreeSpace (RawFStream1);
524 if ((Stream1Size & (AML_NAME_SEG_SIZE - 1)) != 0) {
525 ASSERT (0);
526 return EFI_INVALID_PARAMETER;
527 }
528
529 Stream2Size = AmlStreamGetFreeSpace (RawFStream2);
530 if ((Stream2Size & (AML_NAME_SEG_SIZE - 1)) != 0) {
531 ASSERT (0);
532 return EFI_INVALID_PARAMETER;
533 }
534
535 Status = AmlStreamClone (RawFStream1, &RawFStream1Clone);
536 if (EFI_ERROR (Status)) {
537 ASSERT (0);
538 return Status;
539 }
540
541 Status = AmlStreamClone (RawFStream2, &RawFStream2Clone);
542 if (EFI_ERROR (Status)) {
543 ASSERT (0);
544 return Status;
545 }
546
547 CompareLen = MIN (Stream1Size, Stream2Size);
548 Index = 0;
549 // Check there is enough space for a NameSeg in both Stream1 and Stream2.
550 while (Index < CompareLen) {
551 if (!AmlStreamCmp (
552 &RawFStream1Clone,
553 &RawFStream2Clone,
554 AML_NAME_SEG_SIZE
555 )
556 )
557 {
558 // NameSegs are different. Break.
559 break;
560 }
561
562 Status = AmlStreamProgress (&RawFStream1Clone, AML_NAME_SEG_SIZE);
563 if (EFI_ERROR (Status)) {
564 ASSERT (0);
565 return Status;
566 }
567
568 Status = AmlStreamProgress (&RawFStream2Clone, AML_NAME_SEG_SIZE);
569 if (EFI_ERROR (Status)) {
570 ASSERT (0);
571 return Status;
572 }
573
574 Index += AML_NAME_SEG_SIZE;
575 }
576
577 *CompareCount = Index;
578
579 return EFI_SUCCESS;
580}
581
609STATIC
611EFIAPI
613 IN CONST AML_OBJECT_NODE *AliasNode,
614 IN CONST LIST_ENTRY *NameSpaceRefList,
615 OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode
616 )
617{
618 EFI_STATUS Status;
619 AML_STREAM SourceAliasFStream;
620 CONST AML_DATA_NODE *DataNode;
621
622 if (!AmlNodeCompareOpCode (AliasNode, AML_ALIAS_OP, 0) ||
623 (NameSpaceRefList == NULL) ||
624 (OutNameSpaceRefNode == NULL))
625 {
626 ASSERT (0);
627 return EFI_INVALID_PARAMETER;
628 }
629
630 // The aliased NameString (the source name) is the first fixed argument,
631 // cf. ACPI6.3 spec, s19.6.4: Alias (SourceObject, AliasObject)
633 (AML_OBJECT_NODE *)AliasNode,
635 );
636 if (DataNode == NULL) {
637 ASSERT (0);
638 return EFI_INVALID_PARAMETER;
639 }
640
641 // Initialize a stream on the source alias NameString.
642 Status = AmlStreamInit (
643 &SourceAliasFStream,
644 DataNode->Buffer,
645 DataNode->Size,
647 );
648 if (EFI_ERROR (Status)) {
649 ASSERT (0);
650 return Status;
651 }
652
653 // Recursively check whether the source alias NameString
654 // is a method invocation.
655 Status = AmlIsMethodInvocation (
656 AmlGetParent ((AML_NODE_HEADER *)AliasNode),
657 &SourceAliasFStream,
658 NameSpaceRefList,
659 OutNameSpaceRefNode
660 );
661 if (EFI_ERROR (Status)) {
662 ASSERT (0);
663 }
664
665 return Status;
666}
667
721STATIC
723EFIAPI
725 IN CONST AML_STREAM *RawAbsolutePathFStream,
726 IN CONST AML_STREAM *RawPathNameBStream,
727 IN CONST LIST_ENTRY *NameSpaceRefList,
728 OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode
729 )
730{
731 EFI_STATUS Status;
732
733 LIST_ENTRY *NextLink;
734
735 // To resolve a pathname, scope levels need to be compared.
736 UINT32 NameSegScopeCount;
737 UINT32 PathNameSegScopeCount;
738 UINT32 ProbedScopeCount;
739 UINT32 BestScopeCount;
740
741 AML_STREAM ProbedRawAbsoluteFStream;
742 AML_STREAM ProbedRawAbsoluteBStream;
743
744 AML_NAMESPACE_REF_NODE *ProbedNameSpaceRefNode;
745 AML_NAMESPACE_REF_NODE *BestNameSpaceRefNode;
746
747 if (!IS_STREAM (RawAbsolutePathFStream) ||
748 IS_END_OF_STREAM (RawAbsolutePathFStream) ||
749 !IS_STREAM_FORWARD (RawAbsolutePathFStream) ||
750 ((AmlStreamGetIndex (RawAbsolutePathFStream) &
751 (AML_NAME_SEG_SIZE - 1)) != 0) ||
752 !IS_STREAM (RawPathNameBStream) ||
753 IS_END_OF_STREAM (RawPathNameBStream) ||
754 !IS_STREAM_BACKWARD (RawPathNameBStream) ||
755 ((AmlStreamGetIndex (RawPathNameBStream) &
756 (AML_NAME_SEG_SIZE - 1)) != 0) ||
757 (NameSpaceRefList == NULL) ||
758 (OutNameSpaceRefNode == NULL))
759 {
760 ASSERT (0);
761 return EFI_INVALID_PARAMETER;
762 }
763
764 DEBUG ((DEBUG_VERBOSE, "AmlMethodParser: Checking absolute name: "));
765 AMLDBG_PRINT_CHARS (
766 DEBUG_VERBOSE,
767 (CONST CHAR8 *)AmlStreamGetCurrPos (RawAbsolutePathFStream),
768 AmlStreamGetMaxBufferSize (RawAbsolutePathFStream)
769 );
770 DEBUG ((DEBUG_VERBOSE, ".\n"));
771
772 BestNameSpaceRefNode = NULL;
773 BestScopeCount = 0;
774 NameSegScopeCount = AmlStreamGetMaxBufferSize (RawAbsolutePathFStream);
775 PathNameSegScopeCount = AmlStreamGetMaxBufferSize (RawPathNameBStream);
776
777 // Iterate through the raw AML absolute path to find the best match.
778 DEBUG ((DEBUG_VERBOSE, "AmlMethodParser: Comparing with: "));
779 NextLink = NameSpaceRefList->ForwardLink;
780 while (NextLink != NameSpaceRefList) {
781 ProbedNameSpaceRefNode = (AML_NAMESPACE_REF_NODE *)NextLink;
782
783 // Print the raw absolute path of the probed node.
784 AMLDBG_PRINT_CHARS (
785 DEBUG_VERBOSE,
786 ProbedNameSpaceRefNode->RawAbsolutePath,
787 ProbedNameSpaceRefNode->RawAbsolutePathSize
788 );
789 DEBUG ((DEBUG_VERBOSE, "; "));
790
791 // If the raw AML absolute path of the probed node is longer than the
792 // searched pathname, continue.
793 // E.g.: The method call \MET0 cannot resolve to a method defined at
794 // \AAAA.MET0. The method definition is out of scope.
795 if (PathNameSegScopeCount > ProbedNameSpaceRefNode->RawAbsolutePathSize) {
796 NextLink = NextLink->ForwardLink;
797 continue;
798 }
799
800 // Initialize a backward stream for the probed node.
801 // This stream is used to compare the ending of the pathnames.
802 // E.g. if the method searched ends with "MET0", pathnames not ending with
803 // "MET0" should be skipped.
804 Status = AmlStreamInit (
805 &ProbedRawAbsoluteBStream,
806 (UINT8 *)ProbedNameSpaceRefNode->RawAbsolutePath,
807 ProbedNameSpaceRefNode->RawAbsolutePathSize,
809 );
810 if (EFI_ERROR (Status)) {
811 ASSERT (0);
812 return Status;
813 }
814
815 // Compare the pathname endings. If they don't match, continue.
816 if (!AmlStreamCmp (
817 RawPathNameBStream,
818 &ProbedRawAbsoluteBStream,
819 AmlStreamGetMaxBufferSize (RawPathNameBStream)
820 ))
821 {
822 NextLink = NextLink->ForwardLink;
823 continue;
824 }
825
826 // Initialize a forward stream for the probed node.
827 // This stream is used to count how many scope levels from the root
828 // are common with the probed node. The more there are, the better it is.
829 // E.g.: For the method invocation \AAAA.BBBB.MET0, if there are 2
830 // pathnames ending with MET0:
831 // - \AAAA.MET0 has 1 NameSeg in common with \AAAA.BBBB.MET0
832 // from the root (this is "AAAA");
833 // - \MET0 has 0 NameSeg in common with \AAAA.BBBB.MET0
834 // from the root;
835 // Thus, the best match is \AAAA.MET0.
836 Status = AmlStreamInit (
837 &ProbedRawAbsoluteFStream,
838 (UINT8 *)ProbedNameSpaceRefNode->RawAbsolutePath,
839 ProbedNameSpaceRefNode->RawAbsolutePathSize,
841 );
842 if (EFI_ERROR (Status)) {
843 ASSERT (0);
844 return Status;
845 }
846
847 // Count how many namespace levels are in common from the root.
848 Status = AmlCompareRawNameString (
849 RawAbsolutePathFStream,
850 &ProbedRawAbsoluteFStream,
851 &ProbedScopeCount
852 );
853 if (EFI_ERROR (Status)) {
854 ASSERT (0);
855 return EFI_INVALID_PARAMETER;
856 }
857
858 if (ProbedScopeCount == NameSegScopeCount) {
859 // This is a perfect match. Exit the loop.
860 BestNameSpaceRefNode = ProbedNameSpaceRefNode;
861 break;
862 } else if (ProbedScopeCount > BestScopeCount) {
863 // The probed node has more scope levels in common than the
864 // last best match. Update the best match.
865 BestScopeCount = ProbedScopeCount;
866 BestNameSpaceRefNode = ProbedNameSpaceRefNode;
867 } else if (ProbedScopeCount == BestScopeCount) {
868 // The probed node has the same number of scope levels in
869 // common as the last best match.
870 if (ProbedScopeCount == 0) {
871 // There was not best match previously. Set it.
872 BestNameSpaceRefNode = ProbedNameSpaceRefNode;
873 } else {
874 // (ProbedScopeCount != 0)
875 // If there is an equivalent candidate, the best has the shortest
876 // absolute path. Indeed, a similar ProbedScopeCount and a longer
877 // path means the definition is out of the scope.
878 // E.g.: For the method invocation \AAAA.BBBB.MET0, if there are 2
879 // pathnames ending with MET0:
880 // - \AAAA.MET0 has 1 NameSegs in common with \AAAA.BBBB.MET0
881 // from the root (this is "AAAA");
882 // - \AAAA.CCCC.MET0 has 1 NameSegs in common with
883 // \AAAA.BBBB.MET0 from the root (this is "AAAA");
884 // As \AAAA.CCCC.MET0 is longer than \AAAA.MET0, it means that
885 // the pathname could have matched on more NameSegs, but it
886 // didn't because it is out of scope.
887 // Thus, the best match is \AAAA.MET0.
888 if (AmlStreamGetIndex (&ProbedRawAbsoluteFStream) <
889 BestNameSpaceRefNode->RawAbsolutePathSize)
890 {
891 BestScopeCount = ProbedScopeCount;
892 BestNameSpaceRefNode = ProbedNameSpaceRefNode;
893 } else if (AmlStreamGetIndex (&ProbedRawAbsoluteFStream) ==
894 BestNameSpaceRefNode->RawAbsolutePathSize)
895 {
896 ASSERT (0);
897 return EFI_INVALID_PARAMETER;
898 }
899 }
900 }
901
902 NextLink = NextLink->ForwardLink;
903 }
904
905 DEBUG ((DEBUG_VERBOSE, "\n"));
906
907 // Check whether the BestNameSpaceRefNode is a method definition.
908 if (BestNameSpaceRefNode != NULL) {
909 if (AmlIsMethodDefinitionNode (BestNameSpaceRefNode->NodeRef)) {
910 *OutNameSpaceRefNode = BestNameSpaceRefNode;
911 } else if (AmlNodeCompareOpCode (
912 BestNameSpaceRefNode->NodeRef,
913 AML_ALIAS_OP,
914 0
915 ))
916 {
917 // The path matches an alias. Resolve the alias and check whether
918 // this is a method defintion.
919 Status = AmlResolveAliasMethod (
920 BestNameSpaceRefNode->NodeRef,
921 NameSpaceRefList,
922 OutNameSpaceRefNode
923 );
924 if (EFI_ERROR (Status)) {
925 ASSERT (0);
926 return Status;
927 }
928 }
929 } else {
930 // If no, return NULL, even if a matching pathname has been found.
931 *OutNameSpaceRefNode = NULL;
932 }
933
934 return EFI_SUCCESS;
935}
936
964EFIAPI
966 IN CONST AML_NODE_HEADER *ParentNode,
967 IN CONST AML_STREAM *FStream,
968 IN CONST LIST_ENTRY *NameSpaceRefList,
969 OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode
970 )
971{
972 EFI_STATUS Status;
973
974 AML_STREAM RawPathNameBStream;
975 AML_STREAM RawAbsolutePathFStream;
976
977 AML_STREAM RawAbsolutePathBStream;
978 UINT8 *RawAbsolutePathBuffer;
979 UINT32 RawAbsolutePathBufferSize;
980
981 AML_NAMESPACE_REF_NODE *NameSpaceRefNode;
982
983 if ((!IS_AML_OBJECT_NODE (ParentNode) &&
984 !IS_AML_ROOT_NODE (ParentNode)) ||
985 !IS_STREAM (FStream) ||
986 IS_END_OF_STREAM (FStream) ||
987 !IS_STREAM_FORWARD (FStream) ||
988 (NameSpaceRefList == NULL) ||
989 (OutNameSpaceRefNode == NULL))
990 {
991 ASSERT (0);
992 return EFI_INVALID_PARAMETER;
993 }
994
995 // There cannot be a method invocation in a field list. Return.
997 (CONST AML_OBJECT_NODE *)ParentNode,
999 ))
1000 {
1001 *OutNameSpaceRefNode = NULL;
1002 return EFI_SUCCESS;
1003 }
1004
1005 // Allocate memory for the raw absolute path.
1006 RawAbsolutePathBufferSize = MAX_AML_NAMESTRING_SIZE;
1007 RawAbsolutePathBuffer = AllocateZeroPool (RawAbsolutePathBufferSize);
1008 if (RawAbsolutePathBuffer == NULL) {
1009 ASSERT (0);
1010 return EFI_OUT_OF_RESOURCES;
1011 }
1012
1013 // Initialize a backward stream to get the raw absolute path.
1014 Status = AmlStreamInit (
1015 &RawAbsolutePathBStream,
1016 RawAbsolutePathBuffer,
1017 RawAbsolutePathBufferSize,
1019 );
1020 if (EFI_ERROR (Status)) {
1021 ASSERT (0);
1022 goto exit_handler;
1023 }
1024
1025 // Build the raw AML absolute path of the namespace node.
1027 ParentNode,
1028 FStream,
1029 &RawAbsolutePathBStream
1030 );
1031 if (EFI_ERROR (Status)) {
1032 ASSERT (0);
1033 goto exit_handler;
1034 }
1035
1036 // If this is the root path: it cannot be a method invocation. Just return.
1037 if (AmlStreamGetIndex (&RawAbsolutePathBStream) == 0) {
1038 DEBUG ((
1039 DEBUG_VERBOSE,
1040 "AmlMethodParser: "
1041 "Root node cannot be a method invocation\n"
1042 ));
1043 *OutNameSpaceRefNode = NULL;
1044 Status = EFI_SUCCESS;
1045 goto exit_handler;
1046 }
1047
1048 // Create a forward stream for the raw absolute path.
1049 // This forward stream only contains the raw absolute path with
1050 // no extra free space.
1051 Status = AmlStreamInit (
1052 &RawAbsolutePathFStream,
1053 AmlStreamGetCurrPos (&RawAbsolutePathBStream),
1054 AmlStreamGetIndex (&RawAbsolutePathBStream),
1056 );
1057 if (EFI_ERROR (Status)) {
1058 ASSERT (0);
1059 goto exit_handler;
1060 }
1061
1062 // Create a backward stream for the node name.
1063 Status = AmlInitRawPathBStream (
1064 FStream,
1065 &RawPathNameBStream
1066 );
1067 if (EFI_ERROR (Status)) {
1068 ASSERT (0);
1069 return Status;
1070 }
1071
1072 // Go through the NameSpaceRefList elements to check for
1073 // a corresponding method definition.
1074 NameSpaceRefNode = NULL;
1075 Status = AmlFindMethodDefinition (
1076 &RawAbsolutePathFStream,
1077 &RawPathNameBStream,
1078 NameSpaceRefList,
1079 &NameSpaceRefNode
1080 );
1081 if (EFI_ERROR (Status)) {
1082 ASSERT (0);
1083 goto exit_handler;
1084 }
1085
1086 #if !defined (MDEPKG_NDEBUG)
1087 // Print whether a method definition has been found.
1088 if (NameSpaceRefNode != NULL) {
1089 DEBUG ((
1090 DEBUG_VERBOSE,
1091 "AmlMethodParser: Corresponding method definition: "
1092 ));
1093 AMLDBG_PRINT_CHARS (
1094 DEBUG_VERBOSE,
1095 NameSpaceRefNode->RawAbsolutePath,
1096 NameSpaceRefNode->RawAbsolutePathSize
1097 );
1098 DEBUG ((DEBUG_VERBOSE, ".\n"));
1099 } else {
1100 DEBUG ((DEBUG_VERBOSE, "AmlMethodParser: No method definition found.\n"));
1101 }
1102
1103 #endif // MDEPKG_NDEBUG
1104
1105 *OutNameSpaceRefNode = NameSpaceRefNode;
1106
1107exit_handler:
1108 // Free allocated memory.
1109 FreePool (RawAbsolutePathBuffer);
1110 return Status;
1111}
1112
1129EFIAPI
1131 IN CONST AML_OBJECT_NODE *Node,
1132 IN OUT LIST_ENTRY *NameSpaceRefList
1133 )
1134{
1135 EFI_STATUS Status;
1136 AML_NAMESPACE_REF_NODE *NameSpaceRefNode;
1137
1138 AML_STREAM NodeNameFStream;
1139 EAML_PARSE_INDEX NameIndex;
1140 CONST AML_DATA_NODE *NameNode;
1141
1142 AML_STREAM RawAbsolutePathBStream;
1143 UINT32 RawAbsolutePathBStreamSize;
1144
1145 CHAR8 *AbsolutePathBuffer;
1146 UINT32 AbsolutePathBufferSize;
1147
1148 CONST AML_NODE_HEADER *ParentNode;
1149
1151 (NameSpaceRefList == NULL))
1152 {
1153 ASSERT (0);
1154 return EFI_INVALID_PARAMETER;
1155 }
1156
1157 // Allocate a buffer to get the raw AML absolute pathname of the
1158 // namespace node.
1159 AbsolutePathBufferSize = MAX_AML_NAMESTRING_SIZE;
1160 AbsolutePathBuffer = AllocateZeroPool (AbsolutePathBufferSize);
1161 if (AbsolutePathBuffer == NULL) {
1162 ASSERT (0);
1163 return EFI_OUT_OF_RESOURCES;
1164 }
1165
1166 Status = AmlStreamInit (
1167 &RawAbsolutePathBStream,
1168 (UINT8 *)AbsolutePathBuffer,
1169 AbsolutePathBufferSize,
1171 );
1172 if (EFI_ERROR (Status)) {
1173 ASSERT (0);
1174 Status = EFI_INVALID_PARAMETER;
1175 goto exit_handler;
1176 }
1177
1178 // Get the index where the name of the Node is stored in its
1179 // fixed list of arguments.
1180 Status = AmlNodeGetNameIndex (Node, &NameIndex);
1181 if (EFI_ERROR (Status)) {
1182 ASSERT (0);
1183 Status = EFI_INVALID_PARAMETER;
1184 goto exit_handler;
1185 }
1186
1187 // Get the Node name.
1189 (AML_OBJECT_NODE *)Node,
1190 NameIndex
1191 );
1192 if (!IS_AML_DATA_NODE (NameNode) ||
1193 (NameNode->DataType != EAmlNodeDataTypeNameString))
1194 {
1195 ASSERT (0);
1196 Status = EFI_INVALID_PARAMETER;
1197 goto exit_handler;
1198 }
1199
1200 // Initialize a stream on the node name of the namespace node.
1201 // This is an AML NameString.
1202 Status = AmlStreamInit (
1203 &NodeNameFStream,
1204 NameNode->Buffer,
1205 NameNode->Size,
1207 );
1208 if (EFI_ERROR (Status)) {
1209 ASSERT (0);
1210 Status = EFI_INVALID_PARAMETER;
1211 goto exit_handler;
1212 }
1213
1214 ParentNode = AmlGetParent ((AML_NODE_HEADER *)Node);
1215 if (ParentNode == NULL) {
1216 ASSERT (0);
1217 Status = EFI_INVALID_PARAMETER;
1218 goto exit_handler;
1219 }
1220
1221 // Build the raw AML absolute path of the namespace node.
1223 ParentNode,
1224 &NodeNameFStream,
1225 &RawAbsolutePathBStream
1226 );
1227 if (EFI_ERROR (Status)) {
1228 ASSERT (0);
1229 goto exit_handler;
1230 }
1231
1232 RawAbsolutePathBStreamSize = AmlStreamGetIndex (&RawAbsolutePathBStream);
1233 // This is the root path: this cannot be a method invocation.
1234 if (RawAbsolutePathBStreamSize == 0) {
1235 Status = EFI_SUCCESS;
1236 goto exit_handler;
1237 }
1238
1239 // Create a NameSpace reference node.
1240 Status = AmlCreateMethodRefNode (
1241 Node,
1242 (CONST CHAR8 *)AmlStreamGetCurrPos (&RawAbsolutePathBStream),
1243 RawAbsolutePathBStreamSize,
1244 &NameSpaceRefNode
1245 );
1246 if (EFI_ERROR (Status)) {
1247 ASSERT (0);
1248 goto exit_handler;
1249 }
1250
1251 // Add the created NameSpaceRefNode to the list.
1252 InsertTailList (NameSpaceRefList, &NameSpaceRefNode->Link);
1253
1254 DEBUG ((
1255 DEBUG_VERBOSE,
1256 "AmlMethodParser: Adding namespace reference with name:\n"
1257 ));
1258 AMLDBG_PRINT_CHARS (
1259 DEBUG_VERBOSE,
1260 (CONST CHAR8 *)AmlStreamGetCurrPos (&RawAbsolutePathBStream),
1261 AmlStreamGetIndex (&RawAbsolutePathBStream)
1262 );
1263 DEBUG ((DEBUG_VERBOSE, "\n"));
1264
1265exit_handler:
1266 // Free allocated memory.
1267 FreePool (AbsolutePathBuffer);
1268
1269 return Status;
1270}
1271
1301EFIAPI
1303 IN CONST AML_NAMESPACE_REF_NODE *NameSpaceRefNode,
1304 IN AML_DATA_NODE *MethodInvocationName,
1305 OUT AML_OBJECT_NODE **MethodInvocationNodePtr
1306 )
1307{
1308 EFI_STATUS Status;
1309
1310 UINT8 ArgCount;
1311 AML_DATA_NODE *ArgCountNode;
1312 AML_NODE_HEADER **FixedArgs;
1313 AML_OBJECT_NODE *MethodDefinitionNode;
1314 AML_OBJECT_NODE *MethodInvocationNode;
1315
1316 if ((NameSpaceRefNode == NULL) ||
1317 !AmlIsMethodDefinitionNode (NameSpaceRefNode->NodeRef) ||
1318 !IS_AML_DATA_NODE (MethodInvocationName) ||
1319 (MethodInvocationName->DataType != EAmlNodeDataTypeNameString) ||
1320 (MethodInvocationNodePtr == NULL))
1321 {
1322 ASSERT (0);
1323 return EFI_INVALID_PARAMETER;
1324 }
1325
1326 // Get the number of arguments of the method.
1327 MethodDefinitionNode = (AML_OBJECT_NODE *)NameSpaceRefNode->NodeRef;
1328 FixedArgs = MethodDefinitionNode->FixedArgs;
1329 // The method definition is an actual method definition.
1330 if (AmlNodeCompareOpCode (MethodDefinitionNode, AML_METHOD_OP, 0)) {
1331 // Cf ACPI 6.3 specification:
1332 // DefMethod := MethodOp PkgLength NameString MethodFlags TermList
1333 // MethodOp := 0x14
1334 // MethodFlags := ByteData bit 0-2: ArgCount (0-7)
1335 // bit 3: SerializeFlag
1336 // 0 NotSerialized
1337 // 1 Serialized
1338 // bit 4-7: SyncLevel (0x00-0x0f)
1339
1340 // Read the MethodFlags to decode the ArgCount.
1341 ArgCountNode = (AML_DATA_NODE *)FixedArgs[EAmlParseIndexTerm1];
1342 ArgCount = *((UINT8 *)ArgCountNode->Buffer) & 0x7;
1343 } else if (AmlNodeCompareOpCode (MethodDefinitionNode, AML_EXTERNAL_OP, 0)) {
1344 // The method definition is an external statement.
1345 // Cf ACPI 6.3 specification:
1346 // DefExternal := ExternalOp NameString ObjectType ArgumentCount
1347 // ExternalOp := 0x15
1348 // ObjectType := ByteData
1349 // ArgumentCount := ByteData (0 - 7)
1350
1351 // Read the ArgumentCount.
1352 ArgCountNode = (AML_DATA_NODE *)FixedArgs[EAmlParseIndexTerm2];
1353 ArgCount = *((UINT8 *)ArgCountNode->Buffer);
1354 } else {
1355 ASSERT (0);
1356 return EFI_INVALID_PARAMETER;
1357 }
1358
1359 // Create the object node for the method invocation.
1360 // MethodInvocation := MethodInvocationOp NameString ArgumentCount
1361 // MethodInvocationOp := Pseudo Opcode for Method Invocation
1362 // NameString := Method Name
1363 // ArgumentCount := ByteData (0 - 7)
1364 Status = AmlCreateObjectNode (
1366 0,
1367 &MethodInvocationNode
1368 );
1369 if (EFI_ERROR (Status)) {
1370 ASSERT (0);
1371 return Status;
1372 }
1373
1374 // The first fixed argument is the method name.
1375 Status = AmlSetFixedArgument (
1376 MethodInvocationNode,
1378 (AML_NODE_HEADER *)MethodInvocationName
1379 );
1380 if (EFI_ERROR (Status)) {
1381 ASSERT (0);
1382 goto error_handler;
1383 }
1384
1385 // Create a data node holding the number of arguments
1386 // of the method invocation.
1387 ArgCountNode = NULL;
1388 Status = AmlCreateDataNode (
1390 &ArgCount,
1391 sizeof (UINT8),
1392 &ArgCountNode
1393 );
1394 if (EFI_ERROR (Status)) {
1395 ASSERT (0);
1396 goto error_handler;
1397 }
1398
1399 // The second fixed argument is the number of arguments.
1400 Status = AmlSetFixedArgument (
1401 MethodInvocationNode,
1403 (AML_NODE_HEADER *)ArgCountNode
1404 );
1405 if (EFI_ERROR (Status)) {
1406 ASSERT (0);
1407 goto error_handler;
1408 }
1409
1410 *MethodInvocationNodePtr = MethodInvocationNode;
1411 return Status;
1412
1413error_handler:
1414 // Delete the sub-tree: the method invocation name is already attached.
1415 AmlDeleteTree ((AML_NODE_HEADER *)MethodInvocationNode);
1416 if (ArgCountNode != NULL) {
1417 AmlDeleteNode ((AML_NODE_HEADER *)ArgCountNode);
1418 }
1419
1420 return Status;
1421}
1422
1442EFIAPI
1444 IN CONST AML_OBJECT_NODE *MethodInvocationNode,
1445 OUT BOOLEAN *IsMethodInvocation,
1446 OUT UINT8 *ArgCount
1447 )
1448{
1449 AML_DATA_NODE *NumArgsNode;
1450
1451 if (!IS_AML_NODE_VALID (MethodInvocationNode) ||
1452 (IsMethodInvocation == NULL) ||
1453 (ArgCount == NULL))
1454 {
1455 ASSERT (0);
1456 return EFI_INVALID_PARAMETER;
1457 }
1458
1459 // Check whether MethodInvocationNode is a method invocation.
1460 if (!AmlNodeCompareOpCode (MethodInvocationNode, AML_METHOD_INVOC_OP, 0)) {
1461 *IsMethodInvocation = FALSE;
1462 *ArgCount = 0;
1463 return EFI_SUCCESS;
1464 }
1465
1466 // MethodInvocation := MethodInvocationOp NameString ArgumentCount
1467 // MethodInvocationOp := Pseudo Opcode for Method Invocation
1468 // NameString := Method Name
1469 // ArgumentCount := ByteData (0 - 7)
1470 NumArgsNode = (AML_DATA_NODE *)AmlGetFixedArgument (
1471 (AML_OBJECT_NODE *)MethodInvocationNode,
1473 );
1474 if (!IS_AML_NODE_VALID (NumArgsNode) ||
1475 (NumArgsNode->Buffer == NULL) ||
1476 (NumArgsNode->DataType != EAmlNodeDataTypeUInt) ||
1477 (NumArgsNode->Size != 1))
1478 {
1479 ASSERT (0);
1480 return EFI_INVALID_PARAMETER;
1481 }
1482
1483 *ArgCount = *NumArgsNode->Buffer;
1484
1485 *IsMethodInvocation = TRUE;
1486 return EFI_SUCCESS;
1487}
#define AML_IN_NAMESPACE
Definition: Aml.h:98
#define AML_HAS_FIELD_LIST
Definition: Aml.h:88
STATIC EFI_STATUS EFIAPI AmlInitRawPathBStream(IN CONST AML_STREAM *FStream, OUT AML_STREAM *RawPathNameBStream)
EFI_STATUS EFIAPI AmlCreateMethodInvocationNode(IN CONST AML_NAMESPACE_REF_NODE *NameSpaceRefNode, IN AML_DATA_NODE *MethodInvocationName, OUT AML_OBJECT_NODE **MethodInvocationNodePtr)
STATIC EFI_STATUS EFIAPI AmlDeleteNameSpaceRefNode(IN AML_NAMESPACE_REF_NODE *NameSpaceRefNode)
STATIC EFI_STATUS EFIAPI AmlFindMethodDefinition(IN CONST AML_STREAM *RawAbsolutePathFStream, IN CONST AML_STREAM *RawPathNameBStream, IN CONST LIST_ENTRY *NameSpaceRefList, OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode)
STATIC EFI_STATUS EFIAPI AmlCompareRawNameString(IN CONST AML_STREAM *RawFStream1, IN CONST AML_STREAM *RawFStream2, OUT UINT32 *CompareCount)
STATIC EFI_STATUS EFIAPI AmlResolveAliasMethod(IN CONST AML_OBJECT_NODE *AliasNode, IN CONST LIST_ENTRY *NameSpaceRefList, OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode)
STATIC EFI_STATUS EFIAPI AmlBuildRawMethodAbsolutePath(IN CONST AML_NODE_HEADER *ParentNode, IN CONST AML_STREAM *PathnameFStream, IN OUT AML_STREAM *AbsolutePathBStream)
EFI_STATUS EFIAPI AmlGetMethodInvocationArgCount(IN CONST AML_OBJECT_NODE *MethodInvocationNode, OUT BOOLEAN *IsMethodInvocation, OUT UINT8 *ArgCount)
STATIC EFI_STATUS EFIAPI AmlGetFirstNamedAncestorNode(IN CONST AML_NODE_HEADER *Node, OUT AML_NODE_HEADER **OutNamedNode)
EFI_STATUS EFIAPI AmlAddNameSpaceReference(IN CONST AML_OBJECT_NODE *Node, IN OUT LIST_ENTRY *NameSpaceRefList)
EFI_STATUS EFIAPI AmlIsMethodInvocation(IN CONST AML_NODE_HEADER *ParentNode, IN CONST AML_STREAM *FStream, IN CONST LIST_ENTRY *NameSpaceRefList, OUT AML_NAMESPACE_REF_NODE **OutNameSpaceRefNode)
VOID EFIAPI AmlDbgPrintNameSpaceRefList(IN CONST LIST_ENTRY *NameSpaceRefList)
STATIC EFI_STATUS EFIAPI AmlCreateMethodRefNode(IN CONST AML_OBJECT_NODE *ObjectNode, IN CONST CHAR8 *RawAbsolutePath, IN UINT32 RawAbsolutePathSize, OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr)
EFI_STATUS EFIAPI AmlDeleteNameSpaceRefList(IN LIST_ENTRY *NameSpaceRefList)
BOOLEAN EFIAPI AmlIsMethodDefinitionNode(IN CONST AML_OBJECT_NODE *Node)
Definition: AmlNode.c:570
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 AmlDeleteNode(IN AML_NODE_HEADER *Node)
Definition: AmlNode.c:339
BOOLEAN EFIAPI AmlNodeHasAttribute(IN CONST AML_OBJECT_NODE *ObjectNode, IN AML_OP_ATTRIBUTE Attribute)
Definition: AmlNode.c:430
CHAR8 *EFIAPI AmlNodeGetName(IN CONST AML_OBJECT_NODE *ObjectNode)
Definition: AmlNode.c:663
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 AmlNodeGetNameIndex(IN CONST AML_OBJECT_NODE *ObjectNode, OUT EAML_PARSE_INDEX *Index)
Definition: AmlNode.c:621
#define IS_AML_ROOT_NODE(Node)
#define IS_AML_OBJECT_NODE(Node)
#define IS_AML_DATA_NODE(Node)
#define IS_AML_NODE_VALID(Node)
UINT32 EFIAPI AmlStreamGetMaxBufferSize(IN CONST AML_STREAM *Stream)
Definition: AmlStream.c:167
UINT32 EFIAPI AmlStreamGetIndex(IN CONST AML_STREAM *Stream)
Definition: AmlStream.c:222
UINT32 EFIAPI AmlStreamGetFreeSpace(IN CONST AML_STREAM *Stream)
Definition: AmlStream.c:292
EFI_STATUS EFIAPI AmlStreamProgress(IN AML_STREAM *Stream, IN UINT32 Offset)
Definition: AmlStream.c:324
EFI_STATUS EFIAPI AmlStreamClone(IN CONST AML_STREAM *Stream, OUT AML_STREAM *ClonedStream)
Definition: AmlStream.c:63
EFI_STATUS EFIAPI AmlStreamWrite(IN AML_STREAM *Stream, IN CONST UINT8 *Buffer, IN UINT32 Size)
Definition: AmlStream.c:512
UINT8 *EFIAPI AmlStreamGetCurrPos(IN CONST AML_STREAM *Stream)
Definition: AmlStream.c:264
BOOLEAN EFIAPI AmlStreamCmp(IN CONST AML_STREAM *Stream1, IN CONST AML_STREAM *Stream2, IN UINT32 Size)
Definition: AmlStream.c:569
EFI_STATUS EFIAPI AmlStreamInit(IN OUT AML_STREAM *Stream, IN UINT8 *Buffer, IN UINT32 MaxBufferSize, IN EAML_STREAM_DIRECTION Direction)
Definition: AmlStream.c:25
#define IS_STREAM_FORWARD(Stream)
Definition: AmlStream.h:91
@ EAmlStreamDirectionForward
Definition: AmlStream.h:20
@ EAmlStreamDirectionBackward
Definition: AmlStream.h:22
#define IS_STREAM(Stream)
Definition: AmlStream.h:69
#define IS_STREAM_BACKWARD(Stream)
Definition: AmlStream.h:101
#define IS_END_OF_STREAM(Stream)
Definition: AmlStream.h:80
EFI_STATUS EFIAPI AmlSetFixedArgument(IN AML_OBJECT_NODE *ObjectNode, IN EAML_PARSE_INDEX Index, IN AML_NODE_HEADER *NewNode)
Definition: AmlTree.c:168
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
CONST AML_BYTE_ENCODING *EFIAPI AmlGetByteEncodingByOpCode(IN UINT8 OpCode, IN UINT8 SubOpCode)
Definition: Aml.c:347
EFI_STATUS EFIAPI AmlGetRawNameSpacePath(IN CONST AML_NODE_HEADER *Node, IN UINT32 InputParent, OUT AML_STREAM *RawAbsPathBStream)
Definition: AmlNameSpace.c:422
EFI_STATUS EFIAPI AmlGetFirstAncestorNameSpaceNode(IN CONST AML_NODE_HEADER *Node, OUT AML_NODE_HEADER **OutNode)
Definition: AmlNameSpace.c:142
EFI_STATUS EFIAPI AmlParseNameStringInfo(IN CONST CHAR8 *Buffer, OUT UINT32 *Root, OUT UINT32 *ParentPrefix, OUT UINT32 *SegCount)
Definition: AmlString.c:371
CONST CHAR8 *EFIAPI AmlGetFirstNameSeg(IN CONST CHAR8 *AmlPath, IN UINT32 Root, IN UINT32 ParentPrefix)
Definition: AmlString.c:1021
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define MIN(a, b)
Definition: Base.h:1007
#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
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
AML_NODE_HANDLE EFIAPI AmlGetParent(IN AML_NODE_HANDLE Node)
AML_NODE_HANDLE EFIAPI AmlGetFixedArgument(IN AML_OBJECT_NODE_HANDLE ObjectNode, IN EAML_PARSE_INDEX Index)
#define AML_METHOD_INVOC_OP
Definition: AmlDefines.h:120
enum EAmlParseIndex EAML_PARSE_INDEX
#define MAX_AML_NAMESTRING_SIZE
Definition: AmlDefines.h:87
@ EAmlParseIndexTerm1
Second fixed argument index.
Definition: AmlDefines.h:66
@ EAmlParseIndexTerm0
First fixed argument index.
Definition: AmlDefines.h:65
@ EAmlParseIndexTerm2
Third fixed argument index.
Definition: AmlDefines.h:67
@ EAmlNodeDataTypeUInt
Definition: AmlDefines.h:41
@ EAmlNodeDataTypeNameString
Definition: AmlDefines.h:37
EFI_STATUS EFIAPI AmlDeleteTree(IN AML_NODE_HANDLE Node)
EAML_NODE_DATA_TYPE DataType
UINT8 * Buffer
Buffer containing the data stored by this node.
UINT32 Size
Size of the Buffer.
CONST AML_OBJECT_NODE * NodeRef
CONST CHAR8 * RawAbsolutePath
UINT32 RawAbsolutePathSize
Size of the raw AML absolute pathname buffer.
AML_NODE_HEADER * FixedArgs[EAmlParseIndexMax]
UINT8 * Buffer
Pointer to a buffer.
Definition: AmlStream.h:34