1 /******************************************************************************
3 * Module Name: exdebug - Support for stores to the AML Debug Object
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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))
99 /* Null string or newline -- don't emit the line header */
102 (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) &&
103 (SourceDesc->Common.Type == ACPI_TYPE_STRING))
105 if ((SourceDesc->String.Length == 0) ||
106 ((SourceDesc->String.Length == 1) &&
107 (*SourceDesc->String.Pointer == '\n')))
115 * Print line header as long as we are not in the middle of an
118 if (!((Level > 0) && Index == 0))
120 if (AcpiGbl_DisplayDebugTimer)
123 * We will emit the current timer value (in microseconds) with each
124 * debug output. Only need the lower 26 bits. This allows for 67
125 * million microseconds or 67 seconds before rollover.
127 * Convert 100 nanosecond units to microseconds
129 Timer = ((UINT32) AcpiOsGetTimer () / 10);
132 AcpiOsPrintf ("[ACPI Debug T=0x%8.8X] %*s", Timer, Level, " ");
136 AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
140 /* Display the index for package output only */
144 AcpiOsPrintf ("(%.2u) ", Index - 1);
149 AcpiOsPrintf ("[Null Object]\n");
153 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
155 /* No object type prefix needed for integers and strings */
157 if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
158 (SourceDesc->Common.Type != ACPI_TYPE_STRING))
160 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
163 if (!AcpiUtValidInternalObject (SourceDesc))
165 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
169 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
171 AcpiOsPrintf ("%s (Node %p)\n",
172 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
181 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
183 switch (SourceDesc->Common.Type)
185 case ACPI_TYPE_INTEGER:
187 /* Output correct integer width */
189 if (AcpiGbl_IntegerByteWidth == 4)
191 AcpiOsPrintf ("0x%8.8X\n",
192 (UINT32) SourceDesc->Integer.Value);
196 AcpiOsPrintf ("0x%8.8X%8.8X\n",
197 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
201 case ACPI_TYPE_BUFFER:
203 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
204 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
205 (SourceDesc->Buffer.Length < 256) ?
206 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
209 case ACPI_TYPE_STRING:
211 AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer);
214 case ACPI_TYPE_PACKAGE:
216 AcpiOsPrintf ("(Contains 0x%.2X Elements):\n",
217 SourceDesc->Package.Count);
219 /* Output the entire contents of the package */
221 for (i = 0; i < SourceDesc->Package.Count; i++)
223 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
228 case ACPI_TYPE_LOCAL_REFERENCE:
230 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
232 /* Decode the reference */
234 switch (SourceDesc->Reference.Class)
236 case ACPI_REFCLASS_INDEX:
238 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
241 case ACPI_REFCLASS_TABLE:
243 /* Case for DdbHandle */
245 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
255 /* Check for valid node first, then valid object */
257 if (SourceDesc->Reference.Node)
259 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
260 ACPI_DESC_TYPE_NAMED)
262 AcpiOsPrintf (" %p - Not a valid namespace node\n",
263 SourceDesc->Reference.Node);
267 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
268 (SourceDesc->Reference.Node)->Name.Ascii);
270 switch ((SourceDesc->Reference.Node)->Type)
272 /* These types have no attached object */
274 case ACPI_TYPE_DEVICE:
275 AcpiOsPrintf ("Device\n");
278 case ACPI_TYPE_THERMAL:
279 AcpiOsPrintf ("Thermal Zone\n");
284 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
290 else if (SourceDesc->Reference.Object)
292 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
293 ACPI_DESC_TYPE_NAMED)
295 /* Reference object is a namespace node */
297 AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT,
298 SourceDesc->Reference.Object),
303 ObjectDesc = SourceDesc->Reference.Object;
304 Value = SourceDesc->Reference.Value;
306 switch (ObjectDesc->Common.Type)
308 case ACPI_TYPE_BUFFER:
310 AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
311 Value, *SourceDesc->Reference.IndexPointer);
314 case ACPI_TYPE_STRING:
316 AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
317 Value, *SourceDesc->Reference.IndexPointer,
318 *SourceDesc->Reference.IndexPointer);
321 case ACPI_TYPE_PACKAGE:
323 AcpiOsPrintf ("Package[%u] = ", Value);
324 if (!(*SourceDesc->Reference.Where))
326 AcpiOsPrintf ("[Uninitialized Package Element]\n");
330 AcpiExDoDebugObject (*SourceDesc->Reference.Where,
337 AcpiOsPrintf ("Unknown Reference object type %X\n",
338 ObjectDesc->Common.Type);
347 AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc);
351 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));