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,
86 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
89 /* Output must be enabled via the DebugObject global or the DbgLevel */
91 if (!AcpiGbl_EnableAmlDebugObject &&
92 !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
98 * We will emit the current timer value (in microseconds) with each
99 * debug output. Only need the lower 26 bits. This allows for 67
100 * million microseconds or 67 seconds before rollover.
102 Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
106 * Print line header as long as we are not in the middle of an
109 if (!((Level > 0) && Index == 0))
111 AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
114 /* Display the index for package output only */
118 AcpiOsPrintf ("(%.2u) ", Index-1);
123 AcpiOsPrintf ("[Null Object]\n");
127 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
129 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
131 if (!AcpiUtValidInternalObject (SourceDesc))
133 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
137 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
139 AcpiOsPrintf ("%s: %p\n",
140 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
149 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
151 switch (SourceDesc->Common.Type)
153 case ACPI_TYPE_INTEGER:
155 /* Output correct integer width */
157 if (AcpiGbl_IntegerByteWidth == 4)
159 AcpiOsPrintf ("0x%8.8X\n",
160 (UINT32) SourceDesc->Integer.Value);
164 AcpiOsPrintf ("0x%8.8X%8.8X\n",
165 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
169 case ACPI_TYPE_BUFFER:
171 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
172 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
173 (SourceDesc->Buffer.Length < 256) ?
174 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
177 case ACPI_TYPE_STRING:
179 AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
180 SourceDesc->String.Length, SourceDesc->String.Pointer);
183 case ACPI_TYPE_PACKAGE:
185 AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
186 SourceDesc->Package.Count);
188 /* Output the entire contents of the package */
190 for (i = 0; i < SourceDesc->Package.Count; i++)
192 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
197 case ACPI_TYPE_LOCAL_REFERENCE:
199 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
201 /* Decode the reference */
203 switch (SourceDesc->Reference.Class)
205 case ACPI_REFCLASS_INDEX:
207 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
210 case ACPI_REFCLASS_TABLE:
212 /* Case for DdbHandle */
214 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
224 /* Check for valid node first, then valid object */
226 if (SourceDesc->Reference.Node)
228 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
229 ACPI_DESC_TYPE_NAMED)
231 AcpiOsPrintf (" %p - Not a valid namespace node\n",
232 SourceDesc->Reference.Node);
236 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
237 (SourceDesc->Reference.Node)->Name.Ascii);
239 switch ((SourceDesc->Reference.Node)->Type)
241 /* These types have no attached object */
243 case ACPI_TYPE_DEVICE:
244 AcpiOsPrintf ("Device\n");
247 case ACPI_TYPE_THERMAL:
248 AcpiOsPrintf ("Thermal Zone\n");
253 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
259 else if (SourceDesc->Reference.Object)
261 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
262 ACPI_DESC_TYPE_NAMED)
264 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
265 SourceDesc->Reference.Object)->Object,
270 AcpiExDoDebugObject (SourceDesc->Reference.Object,
278 AcpiOsPrintf ("%p\n", SourceDesc);
282 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));