summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg/Library/Common/AmlLib/AmlDbgPrint/AmlDbgPrint.h
blob: e6ed9bc3270a89fcf2a48d352b47e9157f8d12a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/** @file
  AML Debug Print.

  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
  Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>

  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef AML_PRINT_H_
#define AML_PRINT_H_

/* This header file does not include internal Node definition,
   i.e. AML_ROOT_NODE, AML_OBJECT_NODE, etc. The node definitions
   must be included by the caller file. The function prototypes must
   only expose AML_NODE_HANDLE, AML_ROOT_NODE_HANDLE, etc. node
   definitions.
   This allows to keep the functions defined here both internal and
   potentially external. If necessary, any function of this file can
   be exposed externally.
   The Api folder is internal to the AmlLib, but should only use these
   functions. They provide a "safe" way to interact with the AmlLib.
*/

#if !defined (MDEPKG_NDEBUG)

  #include <AmlInclude.h>

/**
  @defgroup DbgPrintApis Print APIs for debugging.
  @ingroup AMLLib
  @{
    Print APIs provide a way to print:
     - A buffer;
     - A (root/object/data) node;
     - An AML tree/branch;
     - The AML NameSpace from the root node.
  @}
*/

/** This function performs a raw data dump of the ACPI table.

  @param  [in]  Ptr     Pointer to the start of the table buffer.
  @param  [in]  Length  The length of the buffer.
**/
VOID
EFIAPI
AmlDbgDumpRaw (
  IN  CONST UINT8   *Ptr,
  IN        UINT32  Length
  );

/** Print Size chars at Buffer address.

  @ingroup DbgPrintApis

  @param  [in]  ErrorLevel    Error level for the DEBUG macro.
  @param  [in]  Buffer        Buffer containing the chars.
  @param  [in]  Size          Number of chars to print.
**/
VOID
EFIAPI
AmlDbgPrintChars (
  IN        UINT32  ErrorLevel,
  IN  CONST CHAR8   *Buffer,
  IN        UINT32  Size
  );

/** Print an AML NameSeg.
    Don't print trailing underscores ('_').

  @param  [in] Buffer   Buffer containing an AML NameSeg.
**/
VOID
EFIAPI
AmlDbgPrintNameSeg (
  IN  CONST CHAR8  *Buffer
  );

/** Print an AML NameString.

  @param  [in] Buffer   Buffer containing an AML NameString.
  @param  [in] NewLine  Print a newline char at the end of the NameString.
**/
VOID
EFIAPI
AmlDbgPrintNameString (
  IN  CONST CHAR8    *Buffer,
  IN        BOOLEAN  NewLine
  );

/** Print Node information.

  @ingroup DbgPrintApis

  @param  [in]  Node    Pointer to the Node to print.
                        Can be a root/object/data node.
**/
VOID
EFIAPI
AmlDbgPrintNode (
  IN  AML_NODE_HANDLE  Node
  );

/** Recursively print the subtree under the Node.

  @ingroup DbgPrintApis

  @param  [in]  Node    Pointer to the root of the subtree to print.
                        Can be a root/object/data node.
**/
VOID
EFIAPI
AmlDbgPrintTree (
  IN  AML_NODE_HANDLE  Node
  );

/** Print the absolute pathnames in the AML namespace of
    all the nodes in the tree starting from the Root node.

  @ingroup DbgPrintApis

  @param  [in]  RootNode    Pointer to a root node.

  @retval EFI_SUCCESS             The function completed successfully.
  @retval EFI_BUFFER_TOO_SMALL    No space left in the buffer.
  @retval EFI_INVALID_PARAMETER   Invalid parameter.
  @retval EFI_OUT_OF_RESOURCES    Out of memory.
**/
EFI_STATUS
EFIAPI
AmlDbgPrintNameSpace (
  IN  AML_ROOT_NODE_HANDLE  RootNode
  );

/* Macros to encapsulate Aml Debug Print APIs.
*/

#define AMLDBG_DUMP_RAW(Ptr, Length)                  \
          AmlDbgDumpRaw (Ptr, Length)

#define AMLDBG_PRINT_CHARS(ErrorLevel, Buffer, Size)  \
          AmlDbgPrintChars (ErrorLevel, Buffer, Size)

#define AMLDBG_PRINT_NAMESEG(Buffer)                  \
          AmlDbgPrintNameSeg (Buffer)

#define AMLDBG_PRINT_NAMESTR(Buffer, NewLine)          \
          AmlDbgPrintNameString (Buffer,NewLine)

#define AMLDBG_PRINT_NODE(Node)                       \
          AmlDbgPrintNode (Node)

#define AMLDBG_PRINT_TREE(Node)                       \
          AmlDbgPrintTree (Node)

#define AMLDBG_PRINT_NAMESPACE(RootNode)              \
          AmlDbgPrintNameSpace (RootNode)

#else

#define AMLDBG_DUMP_RAW(Ptr, Length)

#define AMLDBG_PRINT_CHARS(ErrorLevel, Buffer, Size)

#define AMLDBG_PRINT_NAMESEG(Buffer)

#define AMLDBG_PRINT_NAMESTR(Buffer, NewLine)

#define AMLDBG_PRINT_NODE(Node)

#define AMLDBG_PRINT_TREE(Node)

#define AMLDBG_PRINT_NAMESPACE(RootNode)

#endif // MDEPKG_NDEBUG

#endif // AML_PRINT_H_