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