1 /** @file
2   AML NameSpace.
3 
4   Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
5 
6   SPDX-License-Identifier: BSD-2-Clause-Patent
7 **/
8 
9 #ifndef AML_NAMESPACE_H_
10 #define AML_NAMESPACE_H_
11 
12 #include <AmlNodeDefines.h>
13 #include <Stream/AmlStream.h>
14 
15 /** Return the first AML namespace node up in the parent hierarchy.
16 
17     Return the root node if no namespace node is found is the hierarchy.
18 
19   @param  [in]  Node      Node to look at the parents from.
20                           If Node is the root node, OutNode is NULL.
21   @param  [out] OutNode   If a namespace node is found, pointer to the
22                           first namespace node of Node's parents.
23                           Stop at the root node otherwise.
24 
25   @retval EFI_SUCCESS             The function completed successfully.
26   @retval EFI_INVALID_PARAMETER   Invalid parameter.
27   **/
28 EFI_STATUS
29 EFIAPI
30 AmlGetFirstAncestorNameSpaceNode (
31   IN  CONST AML_NODE_HEADER   * Node,
32   OUT       AML_NODE_HEADER  ** OutNode
33   );
34 
35 /** Build the raw absolute AML pathname to Node and write it to a stream.
36 
37   A raw AML pathname is an AML pathname where the root char ('\'),
38   prefix chars ('^') and NameString prefix byte (e.g.: DualNamePrefix)
39   have been removed. A raw AML pathname is a list of concatenated
40   NameSegs.
41 
42   E.g.:
43   ASL absolute path:  "[RootChar]AAAA.BBBB.CCCC\0"
44   AML absolute path:  "[RootChar][MultiNamePrefix][3(NameSegs)]AAAABBBBCCCC"
45   Raw absolute path:  "AAAABBBBCCCC"
46 
47   @param  [in]   Node         Node to build the raw absolute path to
48                               Must be a root node, or a namespace node.
49   @param  [in]  InputParent   Skip InputParent AML namespace levels before
50                               starting building the raw absolute pathname.
51                               E.g.: - Node's name being "^AAAA.BBBB.CCCC";
52                                     - InputParent = 2;
53                                     "BBBB.CCCC" will be skipped (2
54                                     levels), and "^AAAA" will remain. The
55                                     first caret is not related to InputParent.
56   @param  [out]  RawAbsPathBStream  Backward stream to write the raw
57                                     pathname to.
58                                     If Node is the root node, the Stream data
59                                     Buffer will stay empty.
60                                     The stream must not be at its end.
61 
62   @retval EFI_SUCCESS             The function completed successfully.
63   @retval EFI_BUFFER_TOO_SMALL    No space left in the buffer.
64   @retval EFI_INVALID_PARAMETER   Invalid parameter.
65 **/
66 EFI_STATUS
67 EFIAPI
68 AmlGetRawNameSpacePath (
69   IN  CONST AML_NODE_HEADER   * Node,
70   IN        UINT32              InputParent,
71   OUT       AML_STREAM        * RawAbsPathBStream
72   );
73 
74 #endif // AML_NAMESPACE_H_
75