Fixed compatibility of output.
[AROS.git] / arch / all-pc / acpica / source / components / executer / exdebug.c
blob9db779fb3e2dc32b0d3038e30ba300431d8927c5
1 /******************************************************************************
3 * Module Name: exdebug - Support for stores to the AML Debug Object
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #define __EXDEBUG_C__
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acinterp.h"
51 #define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exdebug")
55 #ifndef ACPI_NO_ERROR_MESSAGES
56 /*******************************************************************************
58 * FUNCTION: AcpiExDoDebugObject
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
64 * RETURN: None
66 * DESCRIPTION: Handles stores to the AML Debug Object. For example:
67 * Store(INT1, Debug)
69 * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
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.
76 ******************************************************************************/
78 void
79 AcpiExDoDebugObject (
80 ACPI_OPERAND_OBJECT *SourceDesc,
81 UINT32 Level,
82 UINT32 Index)
84 UINT32 i;
87 ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
90 /* Output must be enabled via the DebugObject global or the DbgLevel */
92 if (!AcpiGbl_EnableAmlDebugObject &&
93 !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
95 return_VOID;
99 * Print line header as long as we are not in the middle of an
100 * object display
102 if (!((Level > 0) && Index == 0))
104 AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
107 /* Display the index for package output only */
109 if (Index > 0)
111 AcpiOsPrintf ("(%.2u) ", Index-1);
114 if (!SourceDesc)
116 AcpiOsPrintf ("[Null Object]\n");
117 return_VOID;
120 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
122 AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
124 if (!AcpiUtValidInternalObject (SourceDesc))
126 AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
127 return_VOID;
130 else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
132 AcpiOsPrintf ("%s: %p\n",
133 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
134 SourceDesc);
135 return_VOID;
137 else
139 return_VOID;
142 /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
144 switch (SourceDesc->Common.Type)
146 case ACPI_TYPE_INTEGER:
148 /* Output correct integer width */
150 if (AcpiGbl_IntegerByteWidth == 4)
152 AcpiOsPrintf ("0x%8.8X\n",
153 (UINT32) SourceDesc->Integer.Value);
155 else
157 AcpiOsPrintf ("0x%8.8X%8.8X\n",
158 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
160 break;
162 case ACPI_TYPE_BUFFER:
164 AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
165 AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
166 (SourceDesc->Buffer.Length < 256) ?
167 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
168 break;
170 case ACPI_TYPE_STRING:
172 AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
173 SourceDesc->String.Length, SourceDesc->String.Pointer);
174 break;
176 case ACPI_TYPE_PACKAGE:
178 AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
179 SourceDesc->Package.Count);
181 /* Output the entire contents of the package */
183 for (i = 0; i < SourceDesc->Package.Count; i++)
185 AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
186 Level+4, i+1);
188 break;
190 case ACPI_TYPE_LOCAL_REFERENCE:
192 AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
194 /* Decode the reference */
196 switch (SourceDesc->Reference.Class)
198 case ACPI_REFCLASS_INDEX:
200 AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
201 break;
203 case ACPI_REFCLASS_TABLE:
205 /* Case for DdbHandle */
207 AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
208 return_VOID;
210 default:
212 break;
215 AcpiOsPrintf (" ");
217 /* Check for valid node first, then valid object */
219 if (SourceDesc->Reference.Node)
221 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
222 ACPI_DESC_TYPE_NAMED)
224 AcpiOsPrintf (" %p - Not a valid namespace node\n",
225 SourceDesc->Reference.Node);
227 else
229 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
230 (SourceDesc->Reference.Node)->Name.Ascii);
232 switch ((SourceDesc->Reference.Node)->Type)
234 /* These types have no attached object */
236 case ACPI_TYPE_DEVICE:
237 AcpiOsPrintf ("Device\n");
238 break;
240 case ACPI_TYPE_THERMAL:
241 AcpiOsPrintf ("Thermal Zone\n");
242 break;
244 default:
246 AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
247 Level+4, 0);
248 break;
252 else if (SourceDesc->Reference.Object)
254 if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
255 ACPI_DESC_TYPE_NAMED)
257 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
258 SourceDesc->Reference.Object)->Object,
259 Level+4, 0);
261 else
263 AcpiExDoDebugObject (SourceDesc->Reference.Object,
264 Level+4, 0);
267 break;
269 default:
271 AcpiOsPrintf ("%p\n", SourceDesc);
272 break;
275 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
276 return_VOID;
278 #endif