exdebug.c revision 1.4 1 /******************************************************************************
2 *
3 * Module Name: exdebug - Support for stores to the AML Debug Object
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __EXDEBUG_C__
45
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acinterp.h"
49
50
51 #define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdebug")
53
54
55 #ifndef ACPI_NO_ERROR_MESSAGES
56 /*******************************************************************************
57 *
58 * FUNCTION: AcpiExDoDebugObject
59 *
60 * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
61 * Level - Indentation level (used for packages)
62 * Index - Current package element, zero if not pkg
63 *
64 * RETURN: None
65 *
66 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
67 * Store(INT1, Debug)
68 *
69 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
70 *
71 * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set.
72 * Thus, in the normal operational case, stores to the debug object are
73 * ignored but can be easily enabled if necessary.
74 *
75 ******************************************************************************/
76
77 void
78 AcpiExDoDebugObject (
79 ACPI_OPERAND_OBJECT *SourceDesc,
80 UINT32 Level,
81 UINT32 Index)
82 {
83 UINT32 i;
84
85
86 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
87
88
89 /* Output must be enabled via the DebugObject global */
90
91 if (!AcpiGbl_EnableAmlDebugObject)
92 {
93 return_VOID;
94 }
95
96 /*
97 * Print line header as long as we are not in the middle of an
98 * object display
99 */
100 if (!((Level > 0) && Index == 0))
101 {
102 AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
103 }
104
105 /* Display the index for package output only */
106
107 if (Index > 0)
108 {
109 AcpiOsPrintf ("(%.2u) ", Index-1);
110 }
111
112 if (!SourceDesc)
113 {
114 AcpiOsPrintf ("[Null Object]\n");
115 return_VOID;
116 }
117
118 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
119 {
120 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
121
122 if (!AcpiUtValidInternalObject (SourceDesc))
123 {
124 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
125 return_VOID;
126 }
127 }
128 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
129 {
130 AcpiOsPrintf ("%s: %p\n",
131 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
132 SourceDesc);
133 return_VOID;
134 }
135 else
136 {
137 return_VOID;
138 }
139
140 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
141
142 switch (SourceDesc->Common.Type)
143 {
144 case ACPI_TYPE_INTEGER:
145
146 /* Output correct integer width */
147
148 if (AcpiGbl_IntegerByteWidth == 4)
149 {
150 AcpiOsPrintf ("0x%8.8X\n",
151 (UINT32) SourceDesc->Integer.Value);
152 }
153 else
154 {
155 AcpiOsPrintf ("0x%8.8X%8.8X\n",
156 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
157 }
158 break;
159
160 case ACPI_TYPE_BUFFER:
161
162 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
163 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
164 (SourceDesc->Buffer.Length < 256) ?
165 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
166 break;
167
168 case ACPI_TYPE_STRING:
169
170 AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
171 SourceDesc->String.Length, SourceDesc->String.Pointer);
172 break;
173
174 case ACPI_TYPE_PACKAGE:
175
176 AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
177 SourceDesc->Package.Count);
178
179 /* Output the entire contents of the package */
180
181 for (i = 0; i < SourceDesc->Package.Count; i++)
182 {
183 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
184 Level+4, i+1);
185 }
186 break;
187
188 case ACPI_TYPE_LOCAL_REFERENCE:
189
190 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
191
192 /* Decode the reference */
193
194 switch (SourceDesc->Reference.Class)
195 {
196 case ACPI_REFCLASS_INDEX:
197
198 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
199 break;
200
201 case ACPI_REFCLASS_TABLE:
202
203 /* Case for DdbHandle */
204
205 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
206 return_VOID;
207
208 default:
209
210 break;
211 }
212
213 AcpiOsPrintf (" ");
214
215 /* Check for valid node first, then valid object */
216
217 if (SourceDesc->Reference.Node)
218 {
219 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
220 ACPI_DESC_TYPE_NAMED)
221 {
222 AcpiOsPrintf (" %p - Not a valid namespace node\n",
223 SourceDesc->Reference.Node);
224 }
225 else
226 {
227 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
228 (SourceDesc->Reference.Node)->Name.Ascii);
229
230 switch ((SourceDesc->Reference.Node)->Type)
231 {
232 /* These types have no attached object */
233
234 case ACPI_TYPE_DEVICE:
235 AcpiOsPrintf ("Device\n");
236 break;
237
238 case ACPI_TYPE_THERMAL:
239 AcpiOsPrintf ("Thermal Zone\n");
240 break;
241
242 default:
243
244 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
245 Level+4, 0);
246 break;
247 }
248 }
249 }
250 else if (SourceDesc->Reference.Object)
251 {
252 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
253 ACPI_DESC_TYPE_NAMED)
254 {
255 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
256 SourceDesc->Reference.Object)->Object,
257 Level+4, 0);
258 }
259 else
260 {
261 AcpiExDoDebugObject (SourceDesc->Reference.Object,
262 Level+4, 0);
263 }
264 }
265 break;
266
267 default:
268
269 AcpiOsPrintf ("%p\n", SourceDesc);
270 break;
271 }
272
273 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
274 return_VOID;
275 }
276 #endif
277