1 /******************************************************************************
3 * Module Name: exdebug - Support for stores to the AML Debug Object
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
49 #define _COMPONENT ACPI_EXECUTER
50 ACPI_MODULE_NAME ("exdebug")
53 #ifndef ACPI_NO_ERROR_MESSAGES
54 /*******************************************************************************
56 * FUNCTION: AcpiExDoDebugObject
58 * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
59 * Level - Indentation level (used for packages)
60 * Index - Current package element, zero if not pkg
64 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
67 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
69 * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
70 * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
71 * operational case, stores to the debug object are ignored but can be easily
72 * enabled if necessary.
74 ******************************************************************************/
78 ACPI_OPERAND_OBJECT *SourceDesc,
84 ACPI_OPERAND_OBJECT *ObjectDesc;
88 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
91 /* Output must be enabled via the DebugObject global or the DbgLevel */
93 if (!AcpiGbl_EnableAmlDebugObject &&
94 !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
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.
104 Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
108 * Print line header as long as we are not in the middle of an
111 if (!((Level > 0) && Index == 0))
113 AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
116 /* Display the index for package output only */
120 AcpiOsPrintf ("(%.2u) ", Index-1);
125 AcpiOsPrintf ("[Null Object]\n");
129 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
131 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
133 if (!AcpiUtValidInternalObject (SourceDesc))
135 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
139 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
141 AcpiOsPrintf ("%s: %p\n",
142 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
151 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
153 switch (SourceDesc->Common.Type)
155 case ACPI_TYPE_INTEGER:
157 /* Output correct integer width */
159 if (AcpiGbl_IntegerByteWidth == 4)
161 AcpiOsPrintf ("0x%8.8X\n",
162 (UINT32) SourceDesc->Integer.Value);
166 AcpiOsPrintf ("0x%8.8X%8.8X\n",
167 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
171 case ACPI_TYPE_BUFFER:
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);
179 case ACPI_TYPE_STRING:
181 AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
182 SourceDesc->String.Length, SourceDesc->String.Pointer);
185 case ACPI_TYPE_PACKAGE:
187 AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
188 SourceDesc->Package.Count);
190 /* Output the entire contents of the package */
192 for (i = 0; i < SourceDesc->Package.Count; i++)
194 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
199 case ACPI_TYPE_LOCAL_REFERENCE:
201 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
203 /* Decode the reference */
205 switch (SourceDesc->Reference.Class)
207 case ACPI_REFCLASS_INDEX:
209 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
212 case ACPI_REFCLASS_TABLE:
214 /* Case for DdbHandle */
216 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
226 /* Check for valid node first, then valid object */
228 if (SourceDesc->Reference.Node)
230 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
231 ACPI_DESC_TYPE_NAMED)
233 AcpiOsPrintf (" %p - Not a valid namespace node\n",
234 SourceDesc->Reference.Node);
238 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
239 (SourceDesc->Reference.Node)->Name.Ascii);
241 switch ((SourceDesc->Reference.Node)->Type)
243 /* These types have no attached object */
245 case ACPI_TYPE_DEVICE:
246 AcpiOsPrintf ("Device\n");
249 case ACPI_TYPE_THERMAL:
250 AcpiOsPrintf ("Thermal Zone\n");
255 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
261 else if (SourceDesc->Reference.Object)
263 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
264 ACPI_DESC_TYPE_NAMED)
266 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
267 SourceDesc->Reference.Object)->Object,
272 ObjectDesc = SourceDesc->Reference.Object;
273 Value = SourceDesc->Reference.Value;
275 switch (ObjectDesc->Common.Type)
277 case ACPI_TYPE_BUFFER:
279 AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
280 Value, *SourceDesc->Reference.IndexPointer);
283 case ACPI_TYPE_STRING:
285 AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
286 Value, *SourceDesc->Reference.IndexPointer,
287 *SourceDesc->Reference.IndexPointer);
290 case ACPI_TYPE_PACKAGE:
292 AcpiOsPrintf ("Package[%u] = ", Value);
293 AcpiExDoDebugObject (*SourceDesc->Reference.Where,
299 AcpiOsPrintf ("Unknown Reference object type %X\n",
300 ObjectDesc->Common.Type);
309 AcpiOsPrintf ("%p\n", SourceDesc);
313 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));