exdump.c 33.9 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7
/******************************************************************************
 *
 * Module Name: exdump - Interpreter debug output routines
 *
 *****************************************************************************/

/*
8
 * Copyright (C) 2000 - 2015, Intel Corp.
L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    substantially similar to the "NO WARRANTY" disclaimer below
 *    ("Disclaimer") and any redistribution must be conditioned upon
 *    including a substantially similar Disclaimer requirement for further
 *    binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 */

#include <acpi/acpi.h>
L
Len Brown 已提交
45 46 47 48
#include "accommon.h"
#include "acinterp.h"
#include "amlcode.h"
#include "acnamesp.h"
L
Linus Torvalds 已提交
49 50

#define _COMPONENT          ACPI_EXECUTER
L
Len Brown 已提交
51
ACPI_MODULE_NAME("exdump")
L
Linus Torvalds 已提交
52

53 54 55 56
/*
 * The following routines are used for debug output only
 */
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
R
Robert Moore 已提交
57
/* Local prototypes */
L
Len Brown 已提交
58
static void acpi_ex_out_string(char *title, char *value);
R
Robert Moore 已提交
59

L
Len Brown 已提交
60
static void acpi_ex_out_pointer(char *title, void *value);
R
Robert Moore 已提交
61

B
Bob Moore 已提交
62 63 64 65
static void
acpi_ex_dump_object(union acpi_operand_object *obj_desc,
		    struct acpi_exdump_info *info);

B
Bob Moore 已提交
66
static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc);
67 68

static void
B
Bob Moore 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
			 u32 level, u32 index);

/*******************************************************************************
 *
 * Object Descriptor info tables
 *
 * Note: The first table entry must be an INIT opcode and must contain
 * the table length (number of table entries)
 *
 ******************************************************************************/

static struct acpi_exdump_info acpi_ex_dump_integer[2] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_integer), NULL},
	{ACPI_EXD_UINT64, ACPI_EXD_OFFSET(integer.value), "Value"}
};

static struct acpi_exdump_info acpi_ex_dump_string[4] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_string), NULL},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(string.length), "Length"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(string.pointer), "Pointer"},
	{ACPI_EXD_STRING, 0, NULL}
};

93
static struct acpi_exdump_info acpi_ex_dump_buffer[5] = {
B
Bob Moore 已提交
94 95 96
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer), NULL},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(buffer.length), "Length"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer.pointer), "Pointer"},
97
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(buffer.node), "Parent Node"},
B
Bob Moore 已提交
98 99 100
	{ACPI_EXD_BUFFER, 0, NULL}
};

101
static struct acpi_exdump_info acpi_ex_dump_package[6] = {
B
Bob Moore 已提交
102
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_package), NULL},
103
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(package.node), "Parent Node"},
B
Bob Moore 已提交
104 105 106 107 108 109 110 111
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(package.flags), "Flags"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(package.count), "Elements"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(package.elements), "Element List"},
	{ACPI_EXD_PACKAGE, 0, NULL}
};

static struct acpi_exdump_info acpi_ex_dump_device[4] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_device), NULL},
112
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[0]),
B
Bob Moore 已提交
113
	 "System Notify"},
114
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(device.notify_list[1]),
115 116
	 "Device Notify"},
	{ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(device.handler), "Handler"}
B
Bob Moore 已提交
117 118 119 120
};

static struct acpi_exdump_info acpi_ex_dump_event[2] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
B
Bob Moore 已提交
121
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
B
Bob Moore 已提交
122 123
};

124
static struct acpi_exdump_info acpi_ex_dump_method[9] = {
B
Bob Moore 已提交
125
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
126
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.info_flags), "Info Flags"},
127 128
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count),
	 "Parameter Count"},
B
Bob Moore 已提交
129 130
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
B
Bob Moore 已提交
131
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
B
Bob Moore 已提交
132
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
B
Bob Moore 已提交
133 134 135 136
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
};

137
static struct acpi_exdump_info acpi_ex_dump_mutex[6] = {
B
Bob Moore 已提交
138 139
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
140 141
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.original_sync_level),
	 "Original Sync Level"},
142
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
B
Bob Moore 已提交
143 144
	{ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
	 "Acquire Depth"},
B
Bob Moore 已提交
145
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
B
Bob Moore 已提交
146 147
};

148
static struct acpi_exdump_info acpi_ex_dump_region[8] = {
B
Bob Moore 已提交
149 150 151
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region), NULL},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.space_id), "Space Id"},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(region.flags), "Flags"},
152
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(region.node), "Parent Node"},
B
Bob Moore 已提交
153 154
	{ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(region.address), "Address"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(region.length), "Length"},
155
	{ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(region.handler), "Handler"},
B
Bob Moore 已提交
156 157 158
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(region.next), "Next"}
};

159
static struct acpi_exdump_info acpi_ex_dump_power[6] = {
B
Bob Moore 已提交
160 161 162 163 164
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_power), NULL},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.system_level),
	 "System Level"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(power_resource.resource_order),
	 "Resource Order"},
165
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[0]),
B
Bob Moore 已提交
166
	 "System Notify"},
167
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.notify_list[1]),
168 169
	 "Device Notify"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(power_resource.handler), "Handler"}
B
Bob Moore 已提交
170 171 172 173
};

static struct acpi_exdump_info acpi_ex_dump_processor[7] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_processor), NULL},
174 175
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.proc_id), "Processor ID"},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(processor.length), "Length"},
B
Bob Moore 已提交
176
	{ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET(processor.address), "Address"},
177
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[0]),
B
Bob Moore 已提交
178
	 "System Notify"},
179
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.notify_list[1]),
B
Bob Moore 已提交
180 181 182 183 184 185
	 "Device Notify"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(processor.handler), "Handler"}
};

static struct acpi_exdump_info acpi_ex_dump_thermal[4] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_thermal), NULL},
186
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[0]),
B
Bob Moore 已提交
187
	 "System Notify"},
188
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.notify_list[1]),
B
Bob Moore 已提交
189 190 191 192 193 194 195 196 197 198 199
	 "Device Notify"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(thermal_zone.handler), "Handler"}
};

static struct acpi_exdump_info acpi_ex_dump_buffer_field[3] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_buffer_field), NULL},
	{ACPI_EXD_FIELD, 0, NULL},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(buffer_field.buffer_obj),
	 "Buffer Object"}
};

200
static struct acpi_exdump_info acpi_ex_dump_region_field[5] = {
B
Bob Moore 已提交
201 202
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_region_field), NULL},
	{ACPI_EXD_FIELD, 0, NULL},
203 204 205 206
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(field.access_length), "AccessLength"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.region_obj), "Region Object"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(field.resource_buffer),
	 "ResourceBuffer"}
B
Bob Moore 已提交
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
};

static struct acpi_exdump_info acpi_ex_dump_bank_field[5] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
	{ACPI_EXD_FIELD, 0, NULL},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(bank_field.value), "Value"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.region_obj),
	 "Region Object"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(bank_field.bank_obj), "Bank Object"}
};

static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_bank_field), NULL},
	{ACPI_EXD_FIELD, 0, NULL},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(index_field.value), "Value"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.index_obj),
	 "Index Object"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
};

227
static struct acpi_exdump_info acpi_ex_dump_reference[8] = {
B
Bob Moore 已提交
228
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
229
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.class), "Class"},
B
Bob Moore 已提交
230
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
231
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"},
B
Bob Moore 已提交
232
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
233
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(reference.node), "Node"},
B
Bob Moore 已提交
234 235 236 237 238 239 240 241
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
	{ACPI_EXD_REFERENCE, 0, NULL}
};

static struct acpi_exdump_info acpi_ex_dump_address_handler[6] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_address_handler),
	 NULL},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(address_space.space_id), "Space Id"},
242 243
	{ACPI_EXD_HDLR_LIST, ACPI_EXD_OFFSET(address_space.next), "Next"},
	{ACPI_EXD_RGN_LIST, ACPI_EXD_OFFSET(address_space.region_list),
B
Bob Moore 已提交
244
	 "Region List"},
245
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(address_space.node), "Node"},
B
Bob Moore 已提交
246 247 248
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(address_space.context), "Context"}
};

249
static struct acpi_exdump_info acpi_ex_dump_notify[7] = {
B
Bob Moore 已提交
250
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_notify), NULL},
251
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(notify.node), "Node"},
252 253 254 255 256 257
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(notify.handler_type), "Handler Type"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.handler), "Handler"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.context), "Context"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[0]),
	 "Next System Notify"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(notify.next[1]), "Next Device Notify"}
B
Bob Moore 已提交
258 259
};

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
static struct acpi_exdump_info acpi_ex_dump_extra[6] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_extra), NULL},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.method_REG), "_REG Method"},
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(extra.scope_node), "Scope Node"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.region_context),
	 "Region Context"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(extra.aml_start), "Aml Start"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(extra.aml_length), "Aml Length"}
};

static struct acpi_exdump_info acpi_ex_dump_data[3] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_data), NULL},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.handler), "Handler"},
	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(data.pointer), "Raw Data"}
};

B
Bob Moore 已提交
276 277
/* Miscellaneous tables */

278
static struct acpi_exdump_info acpi_ex_dump_common[5] = {
B
Bob Moore 已提交
279 280 281 282
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_common), NULL},
	{ACPI_EXD_TYPE, 0, NULL},
	{ACPI_EXD_UINT16, ACPI_EXD_OFFSET(common.reference_count),
	 "Reference Count"},
283 284
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common.flags), "Flags"},
	{ACPI_EXD_LIST, ACPI_EXD_OFFSET(common.next_object), "Object List"}
B
Bob Moore 已提交
285 286 287 288 289 290 291 292 293 294 295 296 297 298
};

static struct acpi_exdump_info acpi_ex_dump_field_common[7] = {
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_field_common), NULL},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.field_flags),
	 "Field Flags"},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.access_byte_width),
	 "Access Byte Width"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.bit_length),
	 "Bit Length"},
	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(common_field.start_field_bit_offset),
	 "Field Bit Offset"},
	{ACPI_EXD_UINT32, ACPI_EXD_OFFSET(common_field.base_byte_offset),
	 "Base Byte Offset"},
299
	{ACPI_EXD_NODE, ACPI_EXD_OFFSET(common_field.node), "Parent Node"}
B
Bob Moore 已提交
300 301
};

302
static struct acpi_exdump_info acpi_ex_dump_node[7] = {
B
Bob Moore 已提交
303 304 305
	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_node), NULL},
	{ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(flags), "Flags"},
	{ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET(owner_id), "Owner Id"},
306 307 308 309
	{ACPI_EXD_LIST, ACPI_EXD_NSOFFSET(object), "Object List"},
	{ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(parent), "Parent"},
	{ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(child), "Child"},
	{ACPI_EXD_NODE, ACPI_EXD_NSOFFSET(peer), "Peer"}
B
Bob Moore 已提交
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
};

/* Dispatch table, indexed by object type */

static struct acpi_exdump_info *acpi_ex_dump_info[] = {
	NULL,
	acpi_ex_dump_integer,
	acpi_ex_dump_string,
	acpi_ex_dump_buffer,
	acpi_ex_dump_package,
	NULL,
	acpi_ex_dump_device,
	acpi_ex_dump_event,
	acpi_ex_dump_method,
	acpi_ex_dump_mutex,
	acpi_ex_dump_region,
	acpi_ex_dump_power,
	acpi_ex_dump_processor,
	acpi_ex_dump_thermal,
	acpi_ex_dump_buffer_field,
	NULL,
	NULL,
	acpi_ex_dump_region_field,
	acpi_ex_dump_bank_field,
	acpi_ex_dump_index_field,
	acpi_ex_dump_reference,
	NULL,
	NULL,
	acpi_ex_dump_notify,
	acpi_ex_dump_address_handler,
	NULL,
	NULL,
342 343 344
	NULL,
	acpi_ex_dump_extra,
	acpi_ex_dump_data
B
Bob Moore 已提交
345 346 347 348 349 350 351
};

/*******************************************************************************
 *
 * FUNCTION:    acpi_ex_dump_object
 *
 * PARAMETERS:  obj_desc            - Descriptor to dump
352
 *              info                - Info table corresponding to this object
B
Bob Moore 已提交
353 354 355 356 357 358 359 360 361 362 363 364 365 366
 *                                    type
 *
 * RETURN:      None
 *
 * DESCRIPTION: Walk the info table for this object
 *
 ******************************************************************************/

static void
acpi_ex_dump_object(union acpi_operand_object *obj_desc,
		    struct acpi_exdump_info *info)
{
	u8 *target;
	char *name;
367
	const char *reference_name;
B
Bob Moore 已提交
368
	u8 count;
369 370 371 372
	union acpi_operand_object *start;
	union acpi_operand_object *data = NULL;
	union acpi_operand_object *next;
	struct acpi_namespace_node *node;
B
Bob Moore 已提交
373 374 375

	if (!info) {
		acpi_os_printf
B
Bob Moore 已提交
376
		    ("ExDumpObject: Display not implemented for object type %s\n",
B
Bob Moore 已提交
377 378 379 380 381 382 383 384 385
		     acpi_ut_get_object_type_name(obj_desc));
		return;
	}

	/* First table entry must contain the table length (# of table entries) */

	count = info->offset;

	while (count) {
B
Bob Moore 已提交
386
		target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
B
Bob Moore 已提交
387 388 389 390
		name = info->name;

		switch (info->opcode) {
		case ACPI_EXD_INIT:
391

B
Bob Moore 已提交
392 393 394
			break;

		case ACPI_EXD_TYPE:
395

396 397 398
			acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
				       obj_desc->common.type,
				       acpi_ut_get_object_type_name(obj_desc));
B
Bob Moore 已提交
399 400 401 402 403 404 405 406 407 408
			break;

		case ACPI_EXD_UINT8:

			acpi_os_printf("%20s : %2.2X\n", name, *target);
			break;

		case ACPI_EXD_UINT16:

			acpi_os_printf("%20s : %4.4X\n", name,
B
Bob Moore 已提交
409
				       ACPI_GET16(target));
B
Bob Moore 已提交
410 411 412 413 414
			break;

		case ACPI_EXD_UINT32:

			acpi_os_printf("%20s : %8.8X\n", name,
B
Bob Moore 已提交
415
				       ACPI_GET32(target));
B
Bob Moore 已提交
416 417 418 419 420
			break;

		case ACPI_EXD_UINT64:

			acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
B
Bob Moore 已提交
421
				       ACPI_FORMAT_UINT64(ACPI_GET64(target)));
B
Bob Moore 已提交
422 423 424
			break;

		case ACPI_EXD_POINTER:
425
		case ACPI_EXD_ADDRESS:
B
Bob Moore 已提交
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

			acpi_ex_out_pointer(name,
					    *ACPI_CAST_PTR(void *, target));
			break;

		case ACPI_EXD_STRING:

			acpi_ut_print_string(obj_desc->string.pointer,
					     ACPI_UINT8_MAX);
			acpi_os_printf("\n");
			break;

		case ACPI_EXD_BUFFER:

			ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
					 obj_desc->buffer.length);
			break;

		case ACPI_EXD_PACKAGE:

			/* Dump the package contents */

			acpi_os_printf("\nPackage Contents:\n");
			acpi_ex_dump_package_obj(obj_desc, 0, 0);
			break;

		case ACPI_EXD_FIELD:

			acpi_ex_dump_object(obj_desc,
					    acpi_ex_dump_field_common);
			break;

		case ACPI_EXD_REFERENCE:

460
			reference_name = acpi_ut_get_reference_name(obj_desc);
461
			acpi_ex_out_string("Class Name",
462
					   ACPI_CAST_PTR(char, reference_name));
B
Bob Moore 已提交
463 464 465
			acpi_ex_dump_reference_obj(obj_desc);
			break;

466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
		case ACPI_EXD_LIST:

			start = *ACPI_CAST_PTR(void *, target);
			next = start;

			acpi_os_printf("%20s : %p", name, next);
			if (next) {
				acpi_os_printf("(%s %2.2X)",
					       acpi_ut_get_object_type_name
					       (next), next->common.type);

				while (next->common.next_object) {
					if ((next->common.type ==
					     ACPI_TYPE_LOCAL_DATA) && !data) {
						data = next;
					}

					next = next->common.next_object;
					acpi_os_printf("->%p(%s %2.2X)", next,
						       acpi_ut_get_object_type_name
						       (next),
						       next->common.type);

					if ((next == start) || (next == data)) {
						acpi_os_printf
						    ("\n**** Error: Object list appears to be circular linked");
						break;
					}
				}
			}

497
			acpi_os_printf("\n");
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
			break;

		case ACPI_EXD_HDLR_LIST:

			start = *ACPI_CAST_PTR(void *, target);
			next = start;

			acpi_os_printf("%20s : %p", name, next);
			if (next) {
				acpi_os_printf("(%s %2.2X)",
					       acpi_ut_get_object_type_name
					       (next), next->common.type);

				while (next->address_space.next) {
					if ((next->common.type ==
					     ACPI_TYPE_LOCAL_DATA) && !data) {
						data = next;
					}

					next = next->address_space.next;
					acpi_os_printf("->%p(%s %2.2X)", next,
						       acpi_ut_get_object_type_name
						       (next),
						       next->common.type);

					if ((next == start) || (next == data)) {
						acpi_os_printf
						    ("\n**** Error: Handler list appears to be circular linked");
						break;
					}
				}
			}

531
			acpi_os_printf("\n");
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
			break;

		case ACPI_EXD_RGN_LIST:

			start = *ACPI_CAST_PTR(void *, target);
			next = start;

			acpi_os_printf("%20s : %p", name, next);
			if (next) {
				acpi_os_printf("(%s %2.2X)",
					       acpi_ut_get_object_type_name
					       (next), next->common.type);

				while (next->region.next) {
					if ((next->common.type ==
					     ACPI_TYPE_LOCAL_DATA) && !data) {
						data = next;
					}

					next = next->region.next;
					acpi_os_printf("->%p(%s %2.2X)", next,
						       acpi_ut_get_object_type_name
						       (next),
						       next->common.type);

					if ((next == start) || (next == data)) {
						acpi_os_printf
						    ("\n**** Error: Region list appears to be circular linked");
						break;
					}
				}
			}

565
			acpi_os_printf("\n");
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
			break;

		case ACPI_EXD_NODE:

			node =
			    *ACPI_CAST_PTR(struct acpi_namespace_node *,
					   target);

			acpi_os_printf("%20s : %p", name, node);
			if (node) {
				acpi_os_printf(" [%4.4s]", node->name.ascii);
			}
			acpi_os_printf("\n");
			break;

B
Bob Moore 已提交
581
		default:
582

B
Bob Moore 已提交
583 584 585 586 587 588 589 590 591
			acpi_os_printf("**** Invalid table opcode [%X] ****\n",
				       info->opcode);
			return;
		}

		info++;
		count--;
	}
}
L
Linus Torvalds 已提交
592

R
Robert Moore 已提交
593
/*******************************************************************************
L
Linus Torvalds 已提交
594 595 596
 *
 * FUNCTION:    acpi_ex_dump_operand
 *
R
Robert Moore 已提交
597
 * PARAMETERS:  *obj_desc       - Pointer to entry to be dumped
598
 *              depth           - Current nesting depth
L
Linus Torvalds 已提交
599 600 601 602 603
 *
 * RETURN:      None
 *
 * DESCRIPTION: Dump an operand object
 *
R
Robert Moore 已提交
604
 ******************************************************************************/
L
Linus Torvalds 已提交
605

L
Len Brown 已提交
606
void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
L
Linus Torvalds 已提交
607
{
L
Len Brown 已提交
608 609
	u32 length;
	u32 index;
L
Linus Torvalds 已提交
610

B
Bob Moore 已提交
611
	ACPI_FUNCTION_NAME(ex_dump_operand)
L
Linus Torvalds 已提交
612

613 614
	    /* Check if debug output enabled */
	    if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_EXEC, _COMPONENT)) {
L
Linus Torvalds 已提交
615 616 617 618
		return;
	}

	if (!obj_desc) {
B
Bob Moore 已提交
619

R
Robert Moore 已提交
620 621
		/* This could be a null element of a package */

L
Len Brown 已提交
622
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
L
Linus Torvalds 已提交
623 624 625
		return;
	}

L
Len Brown 已提交
626 627 628 629
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p Namespace Node: ",
				  obj_desc));
		ACPI_DUMP_ENTRY(obj_desc, ACPI_LV_EXEC);
L
Linus Torvalds 已提交
630 631 632
		return;
	}

L
Len Brown 已提交
633 634 635 636 637 638
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
				  "%p is not a node or operand object: [%s]\n",
				  obj_desc,
				  acpi_ut_get_descriptor_name(obj_desc)));
		ACPI_DUMP_BUFFER(obj_desc, sizeof(union acpi_operand_object));
L
Linus Torvalds 已提交
639 640 641 642 643 644
		return;
	}

	/* obj_desc is a valid object */

	if (depth > 0) {
L
Len Brown 已提交
645 646 647 648
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%*s[%u] %p ",
				  depth, " ", depth, obj_desc));
	} else {
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%p ", obj_desc));
L
Linus Torvalds 已提交
649 650
	}

R
Robert Moore 已提交
651 652
	/* Decode object type */

653
	switch (obj_desc->common.type) {
L
Linus Torvalds 已提交
654 655
	case ACPI_TYPE_LOCAL_REFERENCE:

656 657 658 659 660
		acpi_os_printf("Reference: [%s] ",
			       acpi_ut_get_reference_name(obj_desc));

		switch (obj_desc->reference.class) {
		case ACPI_REFCLASS_DEBUG:
L
Linus Torvalds 已提交
661

662
			acpi_os_printf("\n");
L
Linus Torvalds 已提交
663 664
			break;

665
		case ACPI_REFCLASS_INDEX:
L
Linus Torvalds 已提交
666

667
			acpi_os_printf("%p\n", obj_desc->reference.object);
L
Linus Torvalds 已提交
668 669
			break;

670
		case ACPI_REFCLASS_TABLE:
671

672
			acpi_os_printf("Table Index %X\n",
673
				       obj_desc->reference.value);
674 675
			break;

676
		case ACPI_REFCLASS_REFOF:
L
Linus Torvalds 已提交
677

678
			acpi_os_printf("%p [%s]\n", obj_desc->reference.object,
B
Bob Moore 已提交
679 680
				       acpi_ut_get_type_name(((union
							       acpi_operand_object
681 682
							       *)
							      obj_desc->
B
Bob Moore 已提交
683 684 685
							      reference.
							      object)->common.
							     type));
L
Linus Torvalds 已提交
686 687
			break;

688
		case ACPI_REFCLASS_NAME:
L
Linus Torvalds 已提交
689

690 691
			acpi_os_printf("- [%4.4s]\n",
				       obj_desc->reference.node->name.ascii);
L
Linus Torvalds 已提交
692 693
			break;

694
		case ACPI_REFCLASS_ARG:
695
		case ACPI_REFCLASS_LOCAL:
L
Linus Torvalds 已提交
696

697
			acpi_os_printf("%X\n", obj_desc->reference.value);
L
Linus Torvalds 已提交
698 699
			break;

700
		default:	/* Unknown reference class */
L
Linus Torvalds 已提交
701

702
			acpi_os_printf("%2.2X\n", obj_desc->reference.class);
L
Linus Torvalds 已提交
703 704 705 706 707 708
			break;
		}
		break;

	case ACPI_TYPE_BUFFER:

709
		acpi_os_printf("Buffer length %.2X @ %p\n",
L
Len Brown 已提交
710 711
			       obj_desc->buffer.length,
			       obj_desc->buffer.pointer);
L
Linus Torvalds 已提交
712 713 714 715

		/* Debug only -- dump the buffer contents */

		if (obj_desc->buffer.pointer) {
716 717 718
			length = obj_desc->buffer.length;
			if (length > 128) {
				length = 128;
L
Linus Torvalds 已提交
719
			}
720 721 722 723 724

			acpi_os_printf
			    ("Buffer Contents: (displaying length 0x%.2X)\n",
			     length);
			ACPI_DUMP_BUFFER(obj_desc->buffer.pointer, length);
L
Linus Torvalds 已提交
725 726 727 728 729
		}
		break;

	case ACPI_TYPE_INTEGER:

L
Len Brown 已提交
730 731
		acpi_os_printf("Integer %8.8X%8.8X\n",
			       ACPI_FORMAT_UINT64(obj_desc->integer.value));
L
Linus Torvalds 已提交
732 733 734 735
		break;

	case ACPI_TYPE_PACKAGE:

B
Bob Moore 已提交
736
		acpi_os_printf("Package [Len %X] ElementArray %p\n",
L
Len Brown 已提交
737 738
			       obj_desc->package.count,
			       obj_desc->package.elements);
L
Linus Torvalds 已提交
739 740 741 742 743 744

		/*
		 * If elements exist, package element pointer is valid,
		 * and debug_level exceeds 1, dump package's elements.
		 */
		if (obj_desc->package.count &&
L
Len Brown 已提交
745 746 747 748 749 750
		    obj_desc->package.elements && acpi_dbg_level > 1) {
			for (index = 0; index < obj_desc->package.count;
			     index++) {
				acpi_ex_dump_operand(obj_desc->package.
						     elements[index],
						     depth + 1);
L
Linus Torvalds 已提交
751 752 753 754 755 756
			}
		}
		break;

	case ACPI_TYPE_REGION:

L
Len Brown 已提交
757 758 759 760
		acpi_os_printf("Region %s (%X)",
			       acpi_ut_get_region_name(obj_desc->region.
						       space_id),
			       obj_desc->region.space_id);
L
Linus Torvalds 已提交
761 762 763 764 765 766

		/*
		 * If the address and length have not been evaluated,
		 * don't print them.
		 */
		if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
L
Len Brown 已提交
767 768 769
			acpi_os_printf("\n");
		} else {
			acpi_os_printf(" base %8.8X%8.8X Length %X\n",
770 771
				       ACPI_FORMAT_UINT64(obj_desc->region.
							  address),
L
Len Brown 已提交
772
				       obj_desc->region.length);
L
Linus Torvalds 已提交
773 774 775 776 777
		}
		break;

	case ACPI_TYPE_STRING:

L
Len Brown 已提交
778 779 780
		acpi_os_printf("String length %X @ %p ",
			       obj_desc->string.length,
			       obj_desc->string.pointer);
R
Robert Moore 已提交
781

L
Len Brown 已提交
782 783
		acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
		acpi_os_printf("\n");
L
Linus Torvalds 已提交
784 785 786 787
		break;

	case ACPI_TYPE_LOCAL_BANK_FIELD:

B
Bob Moore 已提交
788
		acpi_os_printf("BankField\n");
L
Linus Torvalds 已提交
789 790 791 792
		break;

	case ACPI_TYPE_LOCAL_REGION_FIELD:

L
Len Brown 已提交
793
		acpi_os_printf
794 795
		    ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at "
		     "byte=%X bit=%X of below:\n", obj_desc->field.bit_length,
L
Len Brown 已提交
796 797 798 799 800
		     obj_desc->field.access_byte_width,
		     obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
		     obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
		     obj_desc->field.base_byte_offset,
		     obj_desc->field.start_field_bit_offset);
R
Robert Moore 已提交
801

L
Len Brown 已提交
802
		acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
L
Linus Torvalds 已提交
803 804 805 806
		break;

	case ACPI_TYPE_LOCAL_INDEX_FIELD:

B
Bob Moore 已提交
807
		acpi_os_printf("IndexField\n");
L
Linus Torvalds 已提交
808 809 810 811
		break;

	case ACPI_TYPE_BUFFER_FIELD:

B
Bob Moore 已提交
812
		acpi_os_printf("BufferField: %X bits at byte %X bit %X of\n",
L
Len Brown 已提交
813 814 815
			       obj_desc->buffer_field.bit_length,
			       obj_desc->buffer_field.base_byte_offset,
			       obj_desc->buffer_field.start_field_bit_offset);
L
Linus Torvalds 已提交
816 817

		if (!obj_desc->buffer_field.buffer_obj) {
B
Bob Moore 已提交
818
			ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL*\n"));
819 820
		} else if ((obj_desc->buffer_field.buffer_obj)->common.type !=
			   ACPI_TYPE_BUFFER) {
B
Bob Moore 已提交
821
			acpi_os_printf("*not a Buffer*\n");
L
Len Brown 已提交
822 823 824
		} else {
			acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
					     depth + 1);
L
Linus Torvalds 已提交
825 826 827 828 829
		}
		break;

	case ACPI_TYPE_EVENT:

L
Len Brown 已提交
830
		acpi_os_printf("Event\n");
L
Linus Torvalds 已提交
831 832 833 834
		break;

	case ACPI_TYPE_METHOD:

L
Len Brown 已提交
835 836 837 838
		acpi_os_printf("Method(%X) @ %p:%X\n",
			       obj_desc->method.param_count,
			       obj_desc->method.aml_start,
			       obj_desc->method.aml_length);
L
Linus Torvalds 已提交
839 840 841 842
		break;

	case ACPI_TYPE_MUTEX:

L
Len Brown 已提交
843
		acpi_os_printf("Mutex\n");
L
Linus Torvalds 已提交
844 845 846 847
		break;

	case ACPI_TYPE_DEVICE:

L
Len Brown 已提交
848
		acpi_os_printf("Device\n");
L
Linus Torvalds 已提交
849 850 851 852
		break;

	case ACPI_TYPE_POWER:

L
Len Brown 已提交
853
		acpi_os_printf("Power\n");
L
Linus Torvalds 已提交
854 855 856 857
		break;

	case ACPI_TYPE_PROCESSOR:

L
Len Brown 已提交
858
		acpi_os_printf("Processor\n");
L
Linus Torvalds 已提交
859 860 861 862
		break;

	case ACPI_TYPE_THERMAL:

L
Len Brown 已提交
863
		acpi_os_printf("Thermal\n");
L
Linus Torvalds 已提交
864 865 866
		break;

	default:
867

L
Linus Torvalds 已提交
868 869
		/* Unknown Type */

870
		acpi_os_printf("Unknown Type %X\n", obj_desc->common.type);
L
Linus Torvalds 已提交
871 872 873 874 875 876
		break;
	}

	return;
}

R
Robert Moore 已提交
877
/*******************************************************************************
L
Linus Torvalds 已提交
878 879 880
 *
 * FUNCTION:    acpi_ex_dump_operands
 *
881
 * PARAMETERS:  operands            - A list of Operand objects
882 883
 *		opcode_name	    - AML opcode name
 *		num_operands	    - Operand count for this opcode
L
Linus Torvalds 已提交
884
 *
885
 * DESCRIPTION: Dump the operands associated with the opcode
L
Linus Torvalds 已提交
886
 *
R
Robert Moore 已提交
887
 ******************************************************************************/
L
Linus Torvalds 已提交
888 889

void
L
Len Brown 已提交
890
acpi_ex_dump_operands(union acpi_operand_object **operands,
891
		      const char *opcode_name, u32 num_operands)
L
Linus Torvalds 已提交
892
{
B
Bob Moore 已提交
893
	ACPI_FUNCTION_NAME(ex_dump_operands);
L
Linus Torvalds 已提交
894

895 896
	if (!opcode_name) {
		opcode_name = "UNKNOWN";
L
Linus Torvalds 已提交
897 898
	}

L
Len Brown 已提交
899
	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
900
			  "**** Start operand dump for opcode [%s], %u operands\n",
901
			  opcode_name, num_operands));
L
Linus Torvalds 已提交
902

903 904
	if (num_operands == 0) {
		num_operands = 1;
L
Linus Torvalds 已提交
905 906
	}

907
	/* Dump the individual operands */
L
Linus Torvalds 已提交
908

909 910 911 912
	while (num_operands) {
		acpi_ex_dump_operand(*operands, 0);
		operands++;
		num_operands--;
L
Linus Torvalds 已提交
913 914
	}

L
Len Brown 已提交
915
	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
916
			  "**** End operand dump for [%s]\n", opcode_name));
L
Linus Torvalds 已提交
917 918 919
	return;
}

R
Robert Moore 已提交
920
/*******************************************************************************
L
Linus Torvalds 已提交
921
 *
R
Robert Moore 已提交
922
 * FUNCTION:    acpi_ex_out* functions
L
Linus Torvalds 已提交
923
 *
924 925
 * PARAMETERS:  title               - Descriptive text
 *              value               - Value to be displayed
L
Linus Torvalds 已提交
926
 *
927
 * DESCRIPTION: Object dump output formatting functions. These functions
L
Linus Torvalds 已提交
928 929 930
 *              reduce the number of format strings required and keeps them
 *              all in one place for easy modification.
 *
R
Robert Moore 已提交
931
 ******************************************************************************/
L
Linus Torvalds 已提交
932

L
Len Brown 已提交
933
static void acpi_ex_out_string(char *title, char *value)
L
Linus Torvalds 已提交
934
{
L
Len Brown 已提交
935
	acpi_os_printf("%20s : %s\n", title, value);
L
Linus Torvalds 已提交
936 937
}

L
Len Brown 已提交
938
static void acpi_ex_out_pointer(char *title, void *value)
L
Linus Torvalds 已提交
939
{
L
Len Brown 已提交
940
	acpi_os_printf("%20s : %p\n", title, value);
L
Linus Torvalds 已提交
941 942
}

R
Robert Moore 已提交
943
/*******************************************************************************
L
Linus Torvalds 已提交
944
 *
B
Bob Moore 已提交
945
 * FUNCTION:    acpi_ex_dump_namespace_node
L
Linus Torvalds 已提交
946
 *
947 948
 * PARAMETERS:  node                - Descriptor to dump
 *              flags               - Force display if TRUE
L
Linus Torvalds 已提交
949 950 951
 *
 * DESCRIPTION: Dumps the members of the given.Node
 *
R
Robert Moore 已提交
952
 ******************************************************************************/
L
Linus Torvalds 已提交
953

B
Bob Moore 已提交
954
void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
L
Linus Torvalds 已提交
955 956
{

L
Len Brown 已提交
957
	ACPI_FUNCTION_ENTRY();
L
Linus Torvalds 已提交
958 959

	if (!flags) {
960 961 962 963

		/* Check if debug output enabled */

		if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
L
Linus Torvalds 已提交
964 965 966 967
			return;
		}
	}

L
Len Brown 已提交
968
	acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
969 970
	acpi_os_printf("%20s : %2.2X [%s]\n", "Type",
		       node->type, acpi_ut_get_type_name(node->type));
B
Bob Moore 已提交
971 972 973

	acpi_ex_dump_object(ACPI_CAST_PTR(union acpi_operand_object, node),
			    acpi_ex_dump_node);
L
Linus Torvalds 已提交
974 975
}

976 977
/*******************************************************************************
 *
B
Bob Moore 已提交
978
 * FUNCTION:    acpi_ex_dump_reference_obj
979
 *
980
 * PARAMETERS:  object              - Descriptor to dump
981 982 983 984 985
 *
 * DESCRIPTION: Dumps a reference object
 *
 ******************************************************************************/

B
Bob Moore 已提交
986
static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
987
{
L
Len Brown 已提交
988 989
	struct acpi_buffer ret_buf;
	acpi_status status;
990

B
Bob Moore 已提交
991 992
	ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;

993 994
	if (obj_desc->reference.class == ACPI_REFCLASS_NAME) {
		acpi_os_printf(" %p ", obj_desc->reference.node);
B
Bob Moore 已提交
995

L
Len Brown 已提交
996 997 998 999
		status =
		    acpi_ns_handle_to_pathname(obj_desc->reference.node,
					       &ret_buf);
		if (ACPI_FAILURE(status)) {
B
Bob Moore 已提交
1000
			acpi_os_printf(" Could not convert name to pathname\n");
L
Len Brown 已提交
1001 1002
		} else {
			acpi_os_printf("%s\n", (char *)ret_buf.pointer);
B
Bob Moore 已提交
1003
			ACPI_FREE(ret_buf.pointer);
1004
		}
L
Len Brown 已提交
1005
	} else if (obj_desc->reference.object) {
B
Bob Moore 已提交
1006 1007
		if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) ==
		    ACPI_DESC_TYPE_OPERAND) {
1008 1009
			acpi_os_printf(" Target: %p",
				       obj_desc->reference.object);
1010 1011
			if (obj_desc->reference.class == ACPI_REFCLASS_TABLE) {
				acpi_os_printf(" Table Index: %X\n",
1012
					       obj_desc->reference.value);
1013
			} else {
1014 1015
				acpi_os_printf(" Target: %p [%s]\n",
					       obj_desc->reference.object,
1016 1017 1018 1019 1020 1021 1022 1023 1024
					       acpi_ut_get_type_name(((union
								       acpi_operand_object
								       *)
								      obj_desc->
								      reference.
								      object)->
								     common.
								     type));
			}
B
Bob Moore 已提交
1025 1026 1027 1028
		} else {
			acpi_os_printf(" Target: %p\n",
				       obj_desc->reference.object);
		}
1029 1030 1031 1032 1033
	}
}

/*******************************************************************************
 *
B
Bob Moore 已提交
1034
 * FUNCTION:    acpi_ex_dump_package_obj
1035
 *
B
Bob Moore 已提交
1036
 * PARAMETERS:  obj_desc            - Descriptor to dump
1037 1038
 *              level               - Indentation Level
 *              index               - Package index for this object
1039 1040 1041 1042 1043 1044
 *
 * DESCRIPTION: Dumps the elements of the package
 *
 ******************************************************************************/

static void
B
Bob Moore 已提交
1045 1046
acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
			 u32 level, u32 index)
1047
{
L
Len Brown 已提交
1048
	u32 i;
1049 1050 1051 1052 1053

	/* Indentation and index output */

	if (level > 0) {
		for (i = 0; i < level; i++) {
L
Len Brown 已提交
1054
			acpi_os_printf(" ");
1055 1056
		}

L
Len Brown 已提交
1057
		acpi_os_printf("[%.2d] ", index);
1058 1059
	}

L
Len Brown 已提交
1060
	acpi_os_printf("%p ", obj_desc);
1061 1062 1063 1064

	/* Null package elements are allowed */

	if (!obj_desc) {
L
Len Brown 已提交
1065
		acpi_os_printf("[Null Object]\n");
1066 1067 1068 1069 1070
		return;
	}

	/* Packages may only contain a few object types */

1071
	switch (obj_desc->common.type) {
1072 1073
	case ACPI_TYPE_INTEGER:

L
Len Brown 已提交
1074 1075
		acpi_os_printf("[Integer] = %8.8X%8.8X\n",
			       ACPI_FORMAT_UINT64(obj_desc->integer.value));
1076 1077 1078 1079
		break;

	case ACPI_TYPE_STRING:

L
Len Brown 已提交
1080
		acpi_os_printf("[String] Value: ");
1081
		acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
L
Len Brown 已提交
1082
		acpi_os_printf("\n");
1083 1084 1085 1086
		break;

	case ACPI_TYPE_BUFFER:

L
Len Brown 已提交
1087 1088
		acpi_os_printf("[Buffer] Length %.2X = ",
			       obj_desc->buffer.length);
1089
		if (obj_desc->buffer.length) {
1090 1091 1092 1093 1094
			acpi_ut_debug_dump_buffer(ACPI_CAST_PTR
						  (u8,
						   obj_desc->buffer.pointer),
						  obj_desc->buffer.length,
						  DB_DWORD_DISPLAY, _COMPONENT);
L
Len Brown 已提交
1095 1096
		} else {
			acpi_os_printf("\n");
1097 1098 1099 1100 1101
		}
		break;

	case ACPI_TYPE_PACKAGE:

1102
		acpi_os_printf("[Package] Contains %u Elements:\n",
L
Len Brown 已提交
1103
			       obj_desc->package.count);
1104 1105

		for (i = 0; i < obj_desc->package.count; i++) {
B
Bob Moore 已提交
1106 1107
			acpi_ex_dump_package_obj(obj_desc->package.elements[i],
						 level + 1, i);
1108 1109 1110 1111 1112
		}
		break;

	case ACPI_TYPE_LOCAL_REFERENCE:

1113 1114 1115
		acpi_os_printf("[Object Reference] Type [%s] %2.2X",
			       acpi_ut_get_reference_name(obj_desc),
			       obj_desc->reference.class);
B
Bob Moore 已提交
1116
		acpi_ex_dump_reference_obj(obj_desc);
1117 1118 1119 1120
		break;

	default:

1121
		acpi_os_printf("[Unknown Type] %X\n", obj_desc->common.type);
1122 1123 1124 1125
		break;
	}
}

R
Robert Moore 已提交
1126
/*******************************************************************************
L
Linus Torvalds 已提交
1127 1128 1129
 *
 * FUNCTION:    acpi_ex_dump_object_descriptor
 *
B
Bob Moore 已提交
1130
 * PARAMETERS:  obj_desc            - Descriptor to dump
1131
 *              flags               - Force display if TRUE
L
Linus Torvalds 已提交
1132 1133 1134
 *
 * DESCRIPTION: Dumps the members of the object descriptor given.
 *
R
Robert Moore 已提交
1135
 ******************************************************************************/
L
Linus Torvalds 已提交
1136 1137

void
L
Len Brown 已提交
1138
acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
L
Linus Torvalds 已提交
1139
{
B
Bob Moore 已提交
1140
	ACPI_FUNCTION_TRACE(ex_dump_object_descriptor);
L
Linus Torvalds 已提交
1141

R
Robert Moore 已提交
1142 1143 1144 1145
	if (!obj_desc) {
		return_VOID;
	}

L
Linus Torvalds 已提交
1146
	if (!flags) {
1147 1148 1149 1150

		/* Check if debug output enabled */

		if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
L
Linus Torvalds 已提交
1151 1152 1153 1154
			return_VOID;
		}
	}

L
Len Brown 已提交
1155
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
B
Bob Moore 已提交
1156 1157 1158
		acpi_ex_dump_namespace_node((struct acpi_namespace_node *)
					    obj_desc, flags);

L
Len Brown 已提交
1159 1160 1161
		acpi_os_printf("\nAttached Object (%p):\n",
			       ((struct acpi_namespace_node *)obj_desc)->
			       object);
B
Bob Moore 已提交
1162

1163 1164
		obj_desc = ((struct acpi_namespace_node *)obj_desc)->object;
		goto dump_object;
L
Linus Torvalds 已提交
1165 1166
	}

L
Len Brown 已提交
1167
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
1168 1169
		acpi_os_printf("%p is not an ACPI operand object: [%s]\n",
			       obj_desc, acpi_ut_get_descriptor_name(obj_desc));
L
Linus Torvalds 已提交
1170 1171 1172
		return_VOID;
	}

1173 1174 1175 1176 1177
	/* Validate the object type */

	if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
		acpi_os_printf("Not a known object type: %2.2X\n",
			       obj_desc->common.type);
B
Bob Moore 已提交
1178 1179
		return_VOID;
	}
L
Linus Torvalds 已提交
1180

1181 1182
dump_object:

B
Bob Moore 已提交
1183
	/* Common Fields */
L
Linus Torvalds 已提交
1184

B
Bob Moore 已提交
1185
	acpi_ex_dump_object(obj_desc, acpi_ex_dump_common);
L
Linus Torvalds 已提交
1186

B
Bob Moore 已提交
1187
	/* Object-specific fields */
L
Linus Torvalds 已提交
1188

B
Bob Moore 已提交
1189
	acpi_ex_dump_object(obj_desc, acpi_ex_dump_info[obj_desc->common.type]);
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205

	if (obj_desc->common.type == ACPI_TYPE_REGION) {
		obj_desc = obj_desc->common.next_object;
		if (obj_desc->common.type > ACPI_TYPE_LOCAL_MAX) {
			acpi_os_printf
			    ("Secondary object is not a known object type: %2.2X\n",
			     obj_desc->common.type);

			return_VOID;
		}

		acpi_os_printf("\nExtra attached Object (%p):\n", obj_desc);
		acpi_ex_dump_object(obj_desc,
				    acpi_ex_dump_info[obj_desc->common.type]);
	}

L
Linus Torvalds 已提交
1206 1207 1208 1209
	return_VOID;
}

#endif