]>
git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTreeTraversal.h
4 Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef AML_TREE_TRAVERSAL_H_
10 #define AML_TREE_TRAVERSAL_H_
12 #include <AmlNodeDefines.h>
14 /** Get the next sibling node among the children of the input Node.
16 This function traverses the FixedArguments followed by the
17 VariableArguments at the same level in the hierarchy.
19 Fixed arguments are before variable arguments.
21 (Node) /-i # Child of fixed argument b
23 |- [a][b][c][d] # Fixed Arguments
24 |- {(e)->(f)->(g)} # Variable Arguments
26 \-h # Child of variable argument e
28 Traversal Order: a, b, c, d, e, f, g, NULL
31 @param [in] Node Pointer to a root node or an object node.
32 @param [in] ChildNode Get the node after the ChildNode.
34 @return The node after the ChildNode among the children of the input Node.
35 - If ChildNode is NULL, return the first available node among
36 the fixed argument list then variable list of arguments;
37 - If ChildNode is the last node of the fixed argument list,
38 return the first argument of the variable list of arguments;
39 - If ChildNode is the last node of the variable list of arguments,
46 IN CONST AML_NODE_HEADER
*Node
,
47 IN CONST AML_NODE_HEADER
*ChildNode
50 /** Get the previous sibling node among the children of the input Node.
52 This function traverses the FixedArguments followed by the
53 VariableArguments at the same level in the hierarchy.
55 Fixed arguments are before variable arguments.
57 (Node) /-i # Child of fixed argument b
59 |- [a][b][c][d] # Fixed Arguments
60 |- {(e)->(f)->(g)} # Variable Arguments
62 \-h # Child of variable argument e
64 Traversal Order: g, f, e, d, c, b, a, NULL
66 @param [in] Node The node to get the fixed argument from.
67 @param [in] ChildNode Get the node before the ChildNode.
69 @return The node before the ChildNode among the children of the input Node.
70 - If ChildNode is NULL, return the last available node among
71 the variable list of arguments then fixed argument list;
72 - If ChildNode is the first node of the variable list of arguments,
73 return the last argument of the fixed argument list;
74 - If ChildNode is the first node of the fixed argument list,
79 AmlGetPreviousSibling (
80 IN CONST AML_NODE_HEADER
*Node
,
81 IN CONST AML_NODE_HEADER
*ChildNode
84 /** Iterate through the nodes in the same order as the AML bytestream.
86 The iteration is similar to a depth-first path.
88 (Node) /-i # Child of fixed argument b
90 |- [a][b][c][d] # Fixed Arguments
91 |- {(e)->(f)->(g)} # Variable Arguments
93 \-h # Child of variable argument e
95 Traversal Order: a, b, i, c, d, e, h, f, g, NULL
96 Note: The branch i and h will be traversed if it has any children.
98 @param [in] Node Pointer to a node.
100 @return The next node in the AML bytestream order.
101 Return NULL if Node is the Node corresponding to the last
102 bytecode of the tree.
107 IN CONST AML_NODE_HEADER
*Node
110 /** Iterate through the nodes in the reverse order of the AML bytestream.
112 The iteration is similar to a depth-first path,
113 but done in a reverse order.
115 (Node) /-i # Child of fixed argument b
117 |- [a][b][c][d] # Fixed Arguments
118 |- {(e)->(f)->(g)} # Variable Arguments
120 \-h # Child of variable argument e
122 Traversal Order: g, f, h, e, d, c, i, b, a, NULL
123 Note: The branch i and h will be traversed if it has any children.
125 @param [in] Node Pointer to a node.
127 @return The previous node in the AML bytestream order.
128 Return NULL if Node is the Node corresponding to the last
129 bytecode of the tree.
134 IN CONST AML_NODE_HEADER
*Node
137 #endif // AML_TREE_TRAVERSAL_H_