exdebug.c revision 1.1.1.4 1 /******************************************************************************
2 *
3 * Module Name: exdebug - Support for stores to the AML Debug Object
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, 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, or
72 * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
73 * operational case, stores to the debug object are ignored but can be easily
74 * enabled if necessary.
75 *
76 ******************************************************************************/
77
78 void
79 AcpiExDoDebugObject (
80 ACPI_OPERAND_OBJECT *SourceDesc,
81 UINT32 Level,
82 UINT32 Index)
83 {
84 UINT32 i;
85 UINT32 Timer;
86
87
88 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
89
90
91 /* Output must be enabled via the DebugObject global or the DbgLevel */
92
93 if (!AcpiGbl_EnableAmlDebugObject &&
94 !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
95 {
96 return_VOID;
97 }
98
99 /*
100 * We will emit the current timer value (in microseconds) with each
101 * debug output. Only need the lower 26 bits. This allows for 67
102 * million microseconds or 67 seconds before rollover.
103 */
104 Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
105 Timer &= 0x03FFFFFF;
106
107 /*
108 * Print line header as long as we are not in the middle of an
109 * object display
110 */
111 if (!((Level > 0) && Index == 0))
112 {
113 AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
114 }
115
116 /* Display the index for package output only */
117
118 if (Index > 0)
119 {
120 AcpiOsPrintf ("(%.2u) ", Index-1);
121 }
122
123 if (!SourceDesc)
124 {
125 AcpiOsPrintf ("[Null Object]\n");
126 return_VOID;
127 }
128
129 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
130 {
131 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
132
133 if (!AcpiUtValidInternalObject (SourceDesc))
134 {
135 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
136 return_VOID;
137 }
138 }
139 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
140 {
141 AcpiOsPrintf ("%s: %p\n",
142 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
143 SourceDesc);
144 return_VOID;
145 }
146 else
147 {
148 return_VOID;
149 }
150
151 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
152
153 switch (SourceDesc->Common.Type)
154 {
155 case ACPI_TYPE_INTEGER:
156
157 /* Output correct integer width */
158
159 if (AcpiGbl_IntegerByteWidth == 4)
160 {
161 AcpiOsPrintf ("0x%8.8X\n",
162 (UINT32) SourceDesc->Integer.Value);
163 }
164 else
165 {
166 AcpiOsPrintf ("0x%8.8X%8.8X\n",
167 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
168 }
169 break;
170
171 case ACPI_TYPE_BUFFER:
172
173 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
174 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
175 (SourceDesc->Buffer.Length < 256) ?
176 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
177 break;
178
179 case ACPI_TYPE_STRING:
180
181 AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
182 SourceDesc->String.Length, SourceDesc->String.Pointer);
183 break;
184
185 case ACPI_TYPE_PACKAGE:
186
187 AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
188 SourceDesc->Package.Count);
189
190 /* Output the entire contents of the package */
191
192 for (i = 0; i < SourceDesc->Package.Count; i++)
193 {
194 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
195 Level+4, i+1);
196 }
197 break;
198
199 case ACPI_TYPE_LOCAL_REFERENCE:
200
201 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
202
203 /* Decode the reference */
204
205 switch (SourceDesc->Reference.Class)
206 {
207 case ACPI_REFCLASS_INDEX:
208
209 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
210 break;
211
212 case ACPI_REFCLASS_TABLE:
213
214 /* Case for DdbHandle */
215
216 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
217 return_VOID;
218
219 default:
220
221 break;
222 }
223
224 AcpiOsPrintf (" ");
225
226 /* Check for valid node first, then valid object */
227
228 if (SourceDesc->Reference.Node)
229 {
230 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
231 ACPI_DESC_TYPE_NAMED)
232 {
233 AcpiOsPrintf (" %p - Not a valid namespace node\n",
234 SourceDesc->Reference.Node);
235 }
236 else
237 {
238 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
239 (SourceDesc->Reference.Node)->Name.Ascii);
240
241 switch ((SourceDesc->Reference.Node)->Type)
242 {
243 /* These types have no attached object */
244
245 case ACPI_TYPE_DEVICE:
246 AcpiOsPrintf ("Device\n");
247 break;
248
249 case ACPI_TYPE_THERMAL:
250 AcpiOsPrintf ("Thermal Zone\n");
251 break;
252
253 default:
254
255 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
256 Level+4, 0);
257 break;
258 }
259 }
260 }
261 else if (SourceDesc->Reference.Object)
262 {
263 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
264 ACPI_DESC_TYPE_NAMED)
265 {
266 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
267 SourceDesc->Reference.Object)->Object,
268 Level+4, 0);
269 }
270 else
271 {
272 AcpiExDoDebugObject (SourceDesc->Reference.Object,
273 Level+4, 0);
274 }
275 }
276 break;
277
278 default:
279
280 AcpiOsPrintf ("%p\n", SourceDesc);
281 break;
282 }
283
284 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
285 return_VOID;
286 }
287 #endif
288