exdump.c 24.6 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 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 45 46 47 48 49 50
/******************************************************************************
 *
 * Module Name: exdump - Interpreter debug output routines
 *
 *****************************************************************************/

/*
 * Copyright (C) 2000 - 2005, R. Byron Moore
 * 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>
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#include <acpi/acnamesp.h>
#include <acpi/acparser.h>

#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 58
/* Local prototypes */
#ifdef ACPI_FUTURE_USAGE
L
Len Brown 已提交
59
static void acpi_ex_out_string(char *title, char *value);
R
Robert Moore 已提交
60

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

L
Len Brown 已提交
63
static void acpi_ex_out_integer(char *title, u32 value);
R
Robert Moore 已提交
64

L
Len Brown 已提交
65
static void acpi_ex_out_address(char *title, acpi_physical_address value);
R
Robert Moore 已提交
66

L
Len Brown 已提交
67
static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc);
68 69

static void
L
Len Brown 已提交
70 71
acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index);
#endif				/* ACPI_FUTURE_USAGE */
L
Linus Torvalds 已提交
72

R
Robert Moore 已提交
73
/*******************************************************************************
L
Linus Torvalds 已提交
74 75 76
 *
 * FUNCTION:    acpi_ex_dump_operand
 *
R
Robert Moore 已提交
77 78
 * PARAMETERS:  *obj_desc       - Pointer to entry to be dumped
 *              Depth           - Current nesting depth
L
Linus Torvalds 已提交
79 80 81 82 83
 *
 * RETURN:      None
 *
 * DESCRIPTION: Dump an operand object
 *
R
Robert Moore 已提交
84
 ******************************************************************************/
L
Linus Torvalds 已提交
85

L
Len Brown 已提交
86
void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
L
Linus Torvalds 已提交
87
{
L
Len Brown 已提交
88 89
	u32 length;
	u32 index;
L
Linus Torvalds 已提交
90

L
Len Brown 已提交
91
	ACPI_FUNCTION_NAME("ex_dump_operand")
L
Linus Torvalds 已提交
92

L
Len Brown 已提交
93 94 95
	    if (!
		((ACPI_LV_EXEC & acpi_dbg_level)
		 && (_COMPONENT & acpi_dbg_layer))) {
L
Linus Torvalds 已提交
96 97 98 99
		return;
	}

	if (!obj_desc) {
R
Robert Moore 已提交
100 101
		/* This could be a null element of a package */

L
Len Brown 已提交
102
		ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Null Object Descriptor\n"));
L
Linus Torvalds 已提交
103 104 105
		return;
	}

L
Len Brown 已提交
106 107 108 109
	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 已提交
110 111 112
		return;
	}

L
Len Brown 已提交
113 114 115 116 117 118
	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 已提交
119 120 121 122 123 124
		return;
	}

	/* obj_desc is a valid object */

	if (depth > 0) {
L
Len Brown 已提交
125 126 127 128
		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 已提交
129 130
	}

R
Robert Moore 已提交
131 132
	/* Decode object type */

L
Len Brown 已提交
133
	switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
L
Linus Torvalds 已提交
134 135 136 137 138
	case ACPI_TYPE_LOCAL_REFERENCE:

		switch (obj_desc->reference.opcode) {
		case AML_DEBUG_OP:

L
Len Brown 已提交
139
			acpi_os_printf("Reference: Debug\n");
L
Linus Torvalds 已提交
140 141 142 143
			break;

		case AML_NAME_OP:

L
Len Brown 已提交
144 145 146 147 148
			ACPI_DUMP_PATHNAME(obj_desc->reference.object,
					   "Reference: Name: ", ACPI_LV_INFO,
					   _COMPONENT);
			ACPI_DUMP_ENTRY(obj_desc->reference.object,
					ACPI_LV_INFO);
L
Linus Torvalds 已提交
149 150 151 152
			break;

		case AML_INDEX_OP:

L
Len Brown 已提交
153 154
			acpi_os_printf("Reference: Index %p\n",
				       obj_desc->reference.object);
L
Linus Torvalds 已提交
155 156 157 158
			break;

		case AML_REF_OF_OP:

L
Len Brown 已提交
159 160
			acpi_os_printf("Reference: (ref_of) %p\n",
				       obj_desc->reference.object);
L
Linus Torvalds 已提交
161 162 163 164
			break;

		case AML_ARG_OP:

L
Len Brown 已提交
165 166
			acpi_os_printf("Reference: Arg%d",
				       obj_desc->reference.offset);
L
Linus Torvalds 已提交
167

L
Len Brown 已提交
168
			if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
L
Linus Torvalds 已提交
169 170
				/* Value is an Integer */

L
Len Brown 已提交
171 172 173 174
				acpi_os_printf(" value is [%8.8X%8.8x]",
					       ACPI_FORMAT_UINT64(obj_desc->
								  integer.
								  value));
L
Linus Torvalds 已提交
175 176
			}

L
Len Brown 已提交
177
			acpi_os_printf("\n");
L
Linus Torvalds 已提交
178 179 180 181
			break;

		case AML_LOCAL_OP:

L
Len Brown 已提交
182 183
			acpi_os_printf("Reference: Local%d",
				       obj_desc->reference.offset);
L
Linus Torvalds 已提交
184

L
Len Brown 已提交
185
			if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
L
Linus Torvalds 已提交
186 187 188

				/* Value is an Integer */

L
Len Brown 已提交
189 190 191 192
				acpi_os_printf(" value is [%8.8X%8.8x]",
					       ACPI_FORMAT_UINT64(obj_desc->
								  integer.
								  value));
L
Linus Torvalds 已提交
193 194
			}

L
Len Brown 已提交
195
			acpi_os_printf("\n");
L
Linus Torvalds 已提交
196 197 198 199
			break;

		case AML_INT_NAMEPATH_OP:

L
Len Brown 已提交
200 201
			acpi_os_printf("Reference.Node->Name %X\n",
				       obj_desc->reference.node->name.integer);
L
Linus Torvalds 已提交
202 203 204 205 206 207
			break;

		default:

			/* Unknown opcode */

L
Len Brown 已提交
208 209
			acpi_os_printf("Unknown Reference opcode=%X\n",
				       obj_desc->reference.opcode);
L
Linus Torvalds 已提交
210 211 212 213 214 215 216
			break;

		}
		break;

	case ACPI_TYPE_BUFFER:

L
Len Brown 已提交
217 218 219
		acpi_os_printf("Buffer len %X @ %p \n",
			       obj_desc->buffer.length,
			       obj_desc->buffer.pointer);
L
Linus Torvalds 已提交
220 221 222 223 224 225 226 227 228

		length = obj_desc->buffer.length;
		if (length > 64) {
			length = 64;
		}

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

		if (obj_desc->buffer.pointer) {
L
Len Brown 已提交
229
			acpi_os_printf("Buffer Contents: ");
L
Linus Torvalds 已提交
230 231

			for (index = 0; index < length; index++) {
L
Len Brown 已提交
232 233
				acpi_os_printf(" %02x",
					       obj_desc->buffer.pointer[index]);
L
Linus Torvalds 已提交
234
			}
L
Len Brown 已提交
235
			acpi_os_printf("\n");
L
Linus Torvalds 已提交
236 237 238 239 240
		}
		break;

	case ACPI_TYPE_INTEGER:

L
Len Brown 已提交
241 242
		acpi_os_printf("Integer %8.8X%8.8X\n",
			       ACPI_FORMAT_UINT64(obj_desc->integer.value));
L
Linus Torvalds 已提交
243 244 245 246
		break;

	case ACPI_TYPE_PACKAGE:

L
Len Brown 已提交
247 248 249
		acpi_os_printf("Package [Len %X] element_array %p\n",
			       obj_desc->package.count,
			       obj_desc->package.elements);
L
Linus Torvalds 已提交
250 251 252 253 254 255

		/*
		 * 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 已提交
256 257 258 259 260 261
		    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 已提交
262 263 264 265 266 267
			}
		}
		break;

	case ACPI_TYPE_REGION:

L
Len Brown 已提交
268 269 270 271
		acpi_os_printf("Region %s (%X)",
			       acpi_ut_get_region_name(obj_desc->region.
						       space_id),
			       obj_desc->region.space_id);
L
Linus Torvalds 已提交
272 273 274 275 276 277

		/*
		 * If the address and length have not been evaluated,
		 * don't print them.
		 */
		if (!(obj_desc->region.flags & AOPOBJ_DATA_VALID)) {
L
Len Brown 已提交
278 279 280 281 282 283
			acpi_os_printf("\n");
		} else {
			acpi_os_printf(" base %8.8X%8.8X Length %X\n",
				       ACPI_FORMAT_UINT64(obj_desc->region.
							  address),
				       obj_desc->region.length);
L
Linus Torvalds 已提交
284 285 286 287 288
		}
		break;

	case ACPI_TYPE_STRING:

L
Len Brown 已提交
289 290 291
		acpi_os_printf("String length %X @ %p ",
			       obj_desc->string.length,
			       obj_desc->string.pointer);
R
Robert Moore 已提交
292

L
Len Brown 已提交
293 294
		acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
		acpi_os_printf("\n");
L
Linus Torvalds 已提交
295 296 297 298
		break;

	case ACPI_TYPE_LOCAL_BANK_FIELD:

L
Len Brown 已提交
299
		acpi_os_printf("bank_field\n");
L
Linus Torvalds 已提交
300 301 302 303
		break;

	case ACPI_TYPE_LOCAL_REGION_FIELD:

L
Len Brown 已提交
304 305 306 307 308 309 310 311
		acpi_os_printf
		    ("region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
		     obj_desc->field.bit_length,
		     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 已提交
312

L
Len Brown 已提交
313
		acpi_ex_dump_operand(obj_desc->field.region_obj, depth + 1);
L
Linus Torvalds 已提交
314 315 316 317
		break;

	case ACPI_TYPE_LOCAL_INDEX_FIELD:

L
Len Brown 已提交
318
		acpi_os_printf("index_field\n");
L
Linus Torvalds 已提交
319 320 321 322
		break;

	case ACPI_TYPE_BUFFER_FIELD:

L
Len Brown 已提交
323 324 325 326
		acpi_os_printf("buffer_field: %X bits at byte %X bit %X of \n",
			       obj_desc->buffer_field.bit_length,
			       obj_desc->buffer_field.base_byte_offset,
			       obj_desc->buffer_field.start_field_bit_offset);
L
Linus Torvalds 已提交
327 328

		if (!obj_desc->buffer_field.buffer_obj) {
L
Len Brown 已提交
329 330 331 332 333 334 335 336
			ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "*NULL* \n"));
		} else
		    if (ACPI_GET_OBJECT_TYPE(obj_desc->buffer_field.buffer_obj)
			!= ACPI_TYPE_BUFFER) {
			acpi_os_printf("*not a Buffer* \n");
		} else {
			acpi_ex_dump_operand(obj_desc->buffer_field.buffer_obj,
					     depth + 1);
L
Linus Torvalds 已提交
337 338 339 340 341
		}
		break;

	case ACPI_TYPE_EVENT:

L
Len Brown 已提交
342
		acpi_os_printf("Event\n");
L
Linus Torvalds 已提交
343 344 345 346
		break;

	case ACPI_TYPE_METHOD:

L
Len Brown 已提交
347 348 349 350
		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 已提交
351 352 353 354
		break;

	case ACPI_TYPE_MUTEX:

L
Len Brown 已提交
355
		acpi_os_printf("Mutex\n");
L
Linus Torvalds 已提交
356 357 358 359
		break;

	case ACPI_TYPE_DEVICE:

L
Len Brown 已提交
360
		acpi_os_printf("Device\n");
L
Linus Torvalds 已提交
361 362 363 364
		break;

	case ACPI_TYPE_POWER:

L
Len Brown 已提交
365
		acpi_os_printf("Power\n");
L
Linus Torvalds 已提交
366 367 368 369
		break;

	case ACPI_TYPE_PROCESSOR:

L
Len Brown 已提交
370
		acpi_os_printf("Processor\n");
L
Linus Torvalds 已提交
371 372 373 374
		break;

	case ACPI_TYPE_THERMAL:

L
Len Brown 已提交
375
		acpi_os_printf("Thermal\n");
L
Linus Torvalds 已提交
376 377 378 379 380
		break;

	default:
		/* Unknown Type */

L
Len Brown 已提交
381 382
		acpi_os_printf("Unknown Type %X\n",
			       ACPI_GET_OBJECT_TYPE(obj_desc));
L
Linus Torvalds 已提交
383 384 385 386 387 388
		break;
	}

	return;
}

R
Robert Moore 已提交
389
/*******************************************************************************
L
Linus Torvalds 已提交
390 391 392 393 394 395 396 397 398 399 400 401 402
 *
 * FUNCTION:    acpi_ex_dump_operands
 *
 * PARAMETERS:  Operands            - Operand list
 *              interpreter_mode    - Load or Exec
 *              Ident               - Identification
 *              num_levels          - # of stack entries to dump above line
 *              Note                - Output notation
 *              module_name         - Caller's module name
 *              line_number         - Caller's invocation line number
 *
 * DESCRIPTION: Dump the object stack
 *
R
Robert Moore 已提交
403
 ******************************************************************************/
L
Linus Torvalds 已提交
404 405

void
L
Len Brown 已提交
406 407 408 409 410
acpi_ex_dump_operands(union acpi_operand_object **operands,
		      acpi_interpreter_mode interpreter_mode,
		      char *ident,
		      u32 num_levels,
		      char *note, char *module_name, u32 line_number)
L
Linus Torvalds 已提交
411
{
L
Len Brown 已提交
412
	acpi_native_uint i;
L
Linus Torvalds 已提交
413

L
Len Brown 已提交
414
	ACPI_FUNCTION_NAME("ex_dump_operands");
L
Linus Torvalds 已提交
415 416 417 418 419 420 421 422 423

	if (!ident) {
		ident = "?";
	}

	if (!note) {
		note = "?";
	}

L
Len Brown 已提交
424 425 426
	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
			  "************* Operand Stack Contents (Opcode [%s], %d Operands)\n",
			  ident, num_levels));
L
Linus Torvalds 已提交
427 428 429 430 431 432 433 434

	if (num_levels == 0) {
		num_levels = 1;
	}

	/* Dump the operand stack starting at the top */

	for (i = 0; num_levels > 0; i--, num_levels--) {
L
Len Brown 已提交
435
		acpi_ex_dump_operand(operands[i], 0);
L
Linus Torvalds 已提交
436 437
	}

L
Len Brown 已提交
438 439 440
	ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
			  "************* Operand Stack dump from %s(%d), %s\n",
			  module_name, line_number, note));
L
Linus Torvalds 已提交
441 442 443 444
	return;
}

#ifdef ACPI_FUTURE_USAGE
R
Robert Moore 已提交
445
/*******************************************************************************
L
Linus Torvalds 已提交
446
 *
R
Robert Moore 已提交
447
 * FUNCTION:    acpi_ex_out* functions
L
Linus Torvalds 已提交
448 449 450 451 452 453 454 455
 *
 * PARAMETERS:  Title               - Descriptive text
 *              Value               - Value to be displayed
 *
 * DESCRIPTION: Object dump output formatting functions.  These functions
 *              reduce the number of format strings required and keeps them
 *              all in one place for easy modification.
 *
R
Robert Moore 已提交
456
 ******************************************************************************/
L
Linus Torvalds 已提交
457

L
Len Brown 已提交
458
static void acpi_ex_out_string(char *title, char *value)
L
Linus Torvalds 已提交
459
{
L
Len Brown 已提交
460
	acpi_os_printf("%20s : %s\n", title, value);
L
Linus Torvalds 已提交
461 462
}

L
Len Brown 已提交
463
static void acpi_ex_out_pointer(char *title, void *value)
L
Linus Torvalds 已提交
464
{
L
Len Brown 已提交
465
	acpi_os_printf("%20s : %p\n", title, value);
L
Linus Torvalds 已提交
466 467
}

L
Len Brown 已提交
468
static void acpi_ex_out_integer(char *title, u32 value)
L
Linus Torvalds 已提交
469
{
L
Len Brown 已提交
470
	acpi_os_printf("%20s : %.2X\n", title, value);
L
Linus Torvalds 已提交
471 472
}

L
Len Brown 已提交
473
static void acpi_ex_out_address(char *title, acpi_physical_address value)
L
Linus Torvalds 已提交
474 475 476
{

#if ACPI_MACHINE_WIDTH == 16
L
Len Brown 已提交
477
	acpi_os_printf("%20s : %p\n", title, value);
L
Linus Torvalds 已提交
478
#else
L
Len Brown 已提交
479
	acpi_os_printf("%20s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
L
Linus Torvalds 已提交
480 481 482
#endif
}

R
Robert Moore 已提交
483
/*******************************************************************************
L
Linus Torvalds 已提交
484 485 486 487
 *
 * FUNCTION:    acpi_ex_dump_node
 *
 * PARAMETERS:  *Node               - Descriptor to dump
R
Robert Moore 已提交
488
 *              Flags               - Force display if TRUE
L
Linus Torvalds 已提交
489 490 491
 *
 * DESCRIPTION: Dumps the members of the given.Node
 *
R
Robert Moore 已提交
492
 ******************************************************************************/
L
Linus Torvalds 已提交
493

L
Len Brown 已提交
494
void acpi_ex_dump_node(struct acpi_namespace_node *node, u32 flags)
L
Linus Torvalds 已提交
495 496
{

L
Len Brown 已提交
497
	ACPI_FUNCTION_ENTRY();
L
Linus Torvalds 已提交
498 499

	if (!flags) {
L
Len Brown 已提交
500 501 502
		if (!
		    ((ACPI_LV_OBJECTS & acpi_dbg_level)
		     && (_COMPONENT & acpi_dbg_layer))) {
L
Linus Torvalds 已提交
503 504 505 506
			return;
		}
	}

L
Len Brown 已提交
507 508 509 510 511 512 513 514 515 516
	acpi_os_printf("%20s : %4.4s\n", "Name", acpi_ut_get_node_name(node));
	acpi_ex_out_string("Type", acpi_ut_get_type_name(node->type));
	acpi_ex_out_integer("Flags", node->flags);
	acpi_ex_out_integer("Owner Id", node->owner_id);
	acpi_ex_out_integer("Reference Count", node->reference_count);
	acpi_ex_out_pointer("Attached Object",
			    acpi_ns_get_attached_object(node));
	acpi_ex_out_pointer("child_list", node->child);
	acpi_ex_out_pointer("next_peer", node->peer);
	acpi_ex_out_pointer("Parent", acpi_ns_get_parent_node(node));
L
Linus Torvalds 已提交
517 518
}

519 520 521 522 523 524 525 526 527 528
/*******************************************************************************
 *
 * FUNCTION:    acpi_ex_dump_reference
 *
 * PARAMETERS:  Object              - Descriptor to dump
 *
 * DESCRIPTION: Dumps a reference object
 *
 ******************************************************************************/

L
Len Brown 已提交
529
static void acpi_ex_dump_reference(union acpi_operand_object *obj_desc)
530
{
L
Len Brown 已提交
531 532
	struct acpi_buffer ret_buf;
	acpi_status status;
533 534

	if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) {
L
Len Brown 已提交
535
		acpi_os_printf("Named Object %p ", obj_desc->reference.node);
536
		ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
L
Len Brown 已提交
537 538 539 540 541 542 543 544
		status =
		    acpi_ns_handle_to_pathname(obj_desc->reference.node,
					       &ret_buf);
		if (ACPI_FAILURE(status)) {
			acpi_os_printf("Could not convert name to pathname\n");
		} else {
			acpi_os_printf("%s\n", (char *)ret_buf.pointer);
			ACPI_MEM_FREE(ret_buf.pointer);
545
		}
L
Len Brown 已提交
546 547 548
	} else if (obj_desc->reference.object) {
		acpi_os_printf("\nReferenced Object: %p\n",
			       obj_desc->reference.object);
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
	}
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_ex_dump_package
 *
 * PARAMETERS:  Object              - Descriptor to dump
 *              Level               - Indentation Level
 *              Index               - Package index for this object
 *
 * DESCRIPTION: Dumps the elements of the package
 *
 ******************************************************************************/

static void
L
Len Brown 已提交
565
acpi_ex_dump_package(union acpi_operand_object *obj_desc, u32 level, u32 index)
566
{
L
Len Brown 已提交
567
	u32 i;
568 569 570 571 572

	/* Indentation and index output */

	if (level > 0) {
		for (i = 0; i < level; i++) {
L
Len Brown 已提交
573
			acpi_os_printf(" ");
574 575
		}

L
Len Brown 已提交
576
		acpi_os_printf("[%.2d] ", index);
577 578
	}

L
Len Brown 已提交
579
	acpi_os_printf("%p ", obj_desc);
580 581 582 583

	/* Null package elements are allowed */

	if (!obj_desc) {
L
Len Brown 已提交
584
		acpi_os_printf("[Null Object]\n");
585 586 587 588 589
		return;
	}

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

L
Len Brown 已提交
590
	switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
591 592
	case ACPI_TYPE_INTEGER:

L
Len Brown 已提交
593 594
		acpi_os_printf("[Integer] = %8.8X%8.8X\n",
			       ACPI_FORMAT_UINT64(obj_desc->integer.value));
595 596 597 598
		break;

	case ACPI_TYPE_STRING:

L
Len Brown 已提交
599
		acpi_os_printf("[String] Value: ");
600
		for (i = 0; i < obj_desc->string.length; i++) {
L
Len Brown 已提交
601
			acpi_os_printf("%c", obj_desc->string.pointer[i]);
602
		}
L
Len Brown 已提交
603
		acpi_os_printf("\n");
604 605 606 607
		break;

	case ACPI_TYPE_BUFFER:

L
Len Brown 已提交
608 609
		acpi_os_printf("[Buffer] Length %.2X = ",
			       obj_desc->buffer.length);
610
		if (obj_desc->buffer.length) {
L
Len Brown 已提交
611 612 613 614 615
			acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer,
					    obj_desc->buffer.length,
					    DB_DWORD_DISPLAY, _COMPONENT);
		} else {
			acpi_os_printf("\n");
616 617 618 619 620
		}
		break;

	case ACPI_TYPE_PACKAGE:

L
Len Brown 已提交
621 622
		acpi_os_printf("[Package] Contains %d Elements: \n",
			       obj_desc->package.count);
623 624

		for (i = 0; i < obj_desc->package.count; i++) {
L
Len Brown 已提交
625 626
			acpi_ex_dump_package(obj_desc->package.elements[i],
					     level + 1, i);
627 628 629 630 631
		}
		break;

	case ACPI_TYPE_LOCAL_REFERENCE:

L
Len Brown 已提交
632 633
		acpi_os_printf("[Object Reference] ");
		acpi_ex_dump_reference(obj_desc);
634 635 636 637
		break;

	default:

L
Len Brown 已提交
638 639
		acpi_os_printf("[Unknown Type] %X\n",
			       ACPI_GET_OBJECT_TYPE(obj_desc));
640 641 642 643
		break;
	}
}

R
Robert Moore 已提交
644
/*******************************************************************************
L
Linus Torvalds 已提交
645 646 647
 *
 * FUNCTION:    acpi_ex_dump_object_descriptor
 *
648
 * PARAMETERS:  Object              - Descriptor to dump
R
Robert Moore 已提交
649
 *              Flags               - Force display if TRUE
L
Linus Torvalds 已提交
650 651 652
 *
 * DESCRIPTION: Dumps the members of the object descriptor given.
 *
R
Robert Moore 已提交
653
 ******************************************************************************/
L
Linus Torvalds 已提交
654 655

void
L
Len Brown 已提交
656
acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
L
Linus Torvalds 已提交
657
{
L
Len Brown 已提交
658
	ACPI_FUNCTION_TRACE("ex_dump_object_descriptor");
L
Linus Torvalds 已提交
659

R
Robert Moore 已提交
660 661 662 663
	if (!obj_desc) {
		return_VOID;
	}

L
Linus Torvalds 已提交
664
	if (!flags) {
L
Len Brown 已提交
665 666 667
		if (!
		    ((ACPI_LV_OBJECTS & acpi_dbg_level)
		     && (_COMPONENT & acpi_dbg_layer))) {
L
Linus Torvalds 已提交
668 669 670 671
			return_VOID;
		}
	}

L
Len Brown 已提交
672 673 674 675 676 677 678 679
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == ACPI_DESC_TYPE_NAMED) {
		acpi_ex_dump_node((struct acpi_namespace_node *)obj_desc,
				  flags);
		acpi_os_printf("\nAttached Object (%p):\n",
			       ((struct acpi_namespace_node *)obj_desc)->
			       object);
		acpi_ex_dump_object_descriptor(((struct acpi_namespace_node *)
						obj_desc)->object, flags);
L
Linus Torvalds 已提交
680 681 682
		return_VOID;
	}

L
Len Brown 已提交
683 684 685 686
	if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) {
		acpi_os_printf
		    ("ex_dump_object_descriptor: %p is not an ACPI operand object: [%s]\n",
		     obj_desc, acpi_ut_get_descriptor_name(obj_desc));
L
Linus Torvalds 已提交
687 688 689 690 691
		return_VOID;
	}

	/* Common Fields */

L
Len Brown 已提交
692 693 694 695
	acpi_ex_out_string("Type", acpi_ut_get_object_type_name(obj_desc));
	acpi_ex_out_integer("Reference Count",
			    obj_desc->common.reference_count);
	acpi_ex_out_integer("Flags", obj_desc->common.flags);
L
Linus Torvalds 已提交
696 697 698

	/* Object-specific Fields */

L
Len Brown 已提交
699
	switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
L
Linus Torvalds 已提交
700 701
	case ACPI_TYPE_INTEGER:

L
Len Brown 已提交
702 703
		acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
			       ACPI_FORMAT_UINT64(obj_desc->integer.value));
L
Linus Torvalds 已提交
704 705 706 707
		break;

	case ACPI_TYPE_STRING:

L
Len Brown 已提交
708
		acpi_ex_out_integer("Length", obj_desc->string.length);
L
Linus Torvalds 已提交
709

L
Len Brown 已提交
710 711 712 713
		acpi_os_printf("%20s : %p ", "Pointer",
			       obj_desc->string.pointer);
		acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
		acpi_os_printf("\n");
L
Linus Torvalds 已提交
714 715 716 717
		break;

	case ACPI_TYPE_BUFFER:

L
Len Brown 已提交
718 719 720 721
		acpi_ex_out_integer("Length", obj_desc->buffer.length);
		acpi_ex_out_pointer("Pointer", obj_desc->buffer.pointer);
		ACPI_DUMP_BUFFER(obj_desc->buffer.pointer,
				 obj_desc->buffer.length);
L
Linus Torvalds 已提交
722 723 724 725
		break;

	case ACPI_TYPE_PACKAGE:

L
Len Brown 已提交
726 727 728
		acpi_ex_out_integer("Flags", obj_desc->package.flags);
		acpi_ex_out_integer("Elements", obj_desc->package.count);
		acpi_ex_out_pointer("Element List", obj_desc->package.elements);
L
Linus Torvalds 已提交
729 730 731

		/* Dump the package contents */

L
Len Brown 已提交
732 733
		acpi_os_printf("\nPackage Contents:\n");
		acpi_ex_dump_package(obj_desc, 0, 0);
L
Linus Torvalds 已提交
734 735 736 737
		break;

	case ACPI_TYPE_DEVICE:

L
Len Brown 已提交
738 739 740 741 742
		acpi_ex_out_pointer("Handler", obj_desc->device.handler);
		acpi_ex_out_pointer("system_notify",
				    obj_desc->device.system_notify);
		acpi_ex_out_pointer("device_notify",
				    obj_desc->device.device_notify);
L
Linus Torvalds 已提交
743 744 745 746
		break;

	case ACPI_TYPE_EVENT:

L
Len Brown 已提交
747
		acpi_ex_out_pointer("Semaphore", obj_desc->event.semaphore);
L
Linus Torvalds 已提交
748 749 750 751
		break;

	case ACPI_TYPE_METHOD:

L
Len Brown 已提交
752 753 754 755 756 757 758 759
		acpi_ex_out_integer("param_count",
				    obj_desc->method.param_count);
		acpi_ex_out_integer("Concurrency",
				    obj_desc->method.concurrency);
		acpi_ex_out_pointer("Semaphore", obj_desc->method.semaphore);
		acpi_ex_out_integer("owner_id", obj_desc->method.owner_id);
		acpi_ex_out_integer("aml_length", obj_desc->method.aml_length);
		acpi_ex_out_pointer("aml_start", obj_desc->method.aml_start);
L
Linus Torvalds 已提交
760 761 762 763
		break;

	case ACPI_TYPE_MUTEX:

L
Len Brown 已提交
764 765 766 767 768 769
		acpi_ex_out_integer("sync_level", obj_desc->mutex.sync_level);
		acpi_ex_out_pointer("owner_thread",
				    obj_desc->mutex.owner_thread);
		acpi_ex_out_integer("acquire_depth",
				    obj_desc->mutex.acquisition_depth);
		acpi_ex_out_pointer("Semaphore", obj_desc->mutex.semaphore);
L
Linus Torvalds 已提交
770 771 772 773
		break;

	case ACPI_TYPE_REGION:

L
Len Brown 已提交
774 775 776 777 778 779
		acpi_ex_out_integer("space_id", obj_desc->region.space_id);
		acpi_ex_out_integer("Flags", obj_desc->region.flags);
		acpi_ex_out_address("Address", obj_desc->region.address);
		acpi_ex_out_integer("Length", obj_desc->region.length);
		acpi_ex_out_pointer("Handler", obj_desc->region.handler);
		acpi_ex_out_pointer("Next", obj_desc->region.next);
L
Linus Torvalds 已提交
780 781 782 783
		break;

	case ACPI_TYPE_POWER:

L
Len Brown 已提交
784 785 786 787 788 789 790 791
		acpi_ex_out_integer("system_level",
				    obj_desc->power_resource.system_level);
		acpi_ex_out_integer("resource_order",
				    obj_desc->power_resource.resource_order);
		acpi_ex_out_pointer("system_notify",
				    obj_desc->power_resource.system_notify);
		acpi_ex_out_pointer("device_notify",
				    obj_desc->power_resource.device_notify);
L
Linus Torvalds 已提交
792 793 794 795
		break;

	case ACPI_TYPE_PROCESSOR:

L
Len Brown 已提交
796 797 798 799 800 801 802 803 804 805 806
		acpi_ex_out_integer("Processor ID",
				    obj_desc->processor.proc_id);
		acpi_ex_out_integer("Length", obj_desc->processor.length);
		acpi_ex_out_address("Address",
				    (acpi_physical_address) obj_desc->processor.
				    address);
		acpi_ex_out_pointer("system_notify",
				    obj_desc->processor.system_notify);
		acpi_ex_out_pointer("device_notify",
				    obj_desc->processor.device_notify);
		acpi_ex_out_pointer("Handler", obj_desc->processor.handler);
L
Linus Torvalds 已提交
807 808 809 810
		break;

	case ACPI_TYPE_THERMAL:

L
Len Brown 已提交
811 812 813 814 815
		acpi_ex_out_pointer("system_notify",
				    obj_desc->thermal_zone.system_notify);
		acpi_ex_out_pointer("device_notify",
				    obj_desc->thermal_zone.device_notify);
		acpi_ex_out_pointer("Handler", obj_desc->thermal_zone.handler);
L
Linus Torvalds 已提交
816 817 818 819 820 821 822
		break;

	case ACPI_TYPE_BUFFER_FIELD:
	case ACPI_TYPE_LOCAL_REGION_FIELD:
	case ACPI_TYPE_LOCAL_BANK_FIELD:
	case ACPI_TYPE_LOCAL_INDEX_FIELD:

L
Len Brown 已提交
823 824 825 826 827 828 829 830 831 832 833 834 835 836
		acpi_ex_out_integer("field_flags",
				    obj_desc->common_field.field_flags);
		acpi_ex_out_integer("access_byte_width",
				    obj_desc->common_field.access_byte_width);
		acpi_ex_out_integer("bit_length",
				    obj_desc->common_field.bit_length);
		acpi_ex_out_integer("fld_bit_offset",
				    obj_desc->common_field.
				    start_field_bit_offset);
		acpi_ex_out_integer("base_byte_offset",
				    obj_desc->common_field.base_byte_offset);
		acpi_ex_out_pointer("parent_node", obj_desc->common_field.node);

		switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
L
Linus Torvalds 已提交
837
		case ACPI_TYPE_BUFFER_FIELD:
L
Len Brown 已提交
838 839
			acpi_ex_out_pointer("buffer_obj",
					    obj_desc->buffer_field.buffer_obj);
L
Linus Torvalds 已提交
840 841 842
			break;

		case ACPI_TYPE_LOCAL_REGION_FIELD:
L
Len Brown 已提交
843 844
			acpi_ex_out_pointer("region_obj",
					    obj_desc->field.region_obj);
L
Linus Torvalds 已提交
845 846 847
			break;

		case ACPI_TYPE_LOCAL_BANK_FIELD:
L
Len Brown 已提交
848 849 850 851 852 853
			acpi_ex_out_integer("Value",
					    obj_desc->bank_field.value);
			acpi_ex_out_pointer("region_obj",
					    obj_desc->bank_field.region_obj);
			acpi_ex_out_pointer("bank_obj",
					    obj_desc->bank_field.bank_obj);
L
Linus Torvalds 已提交
854 855 856
			break;

		case ACPI_TYPE_LOCAL_INDEX_FIELD:
L
Len Brown 已提交
857 858 859 860 861 862
			acpi_ex_out_integer("Value",
					    obj_desc->index_field.value);
			acpi_ex_out_pointer("Index",
					    obj_desc->index_field.index_obj);
			acpi_ex_out_pointer("Data",
					    obj_desc->index_field.data_obj);
L
Linus Torvalds 已提交
863 864 865 866 867 868 869 870 871 872
			break;

		default:
			/* All object types covered above */
			break;
		}
		break;

	case ACPI_TYPE_LOCAL_REFERENCE:

L
Len Brown 已提交
873 874 875 876 877 878 879 880 881
		acpi_ex_out_integer("target_type",
				    obj_desc->reference.target_type);
		acpi_ex_out_string("Opcode",
				   (acpi_ps_get_opcode_info
				    (obj_desc->reference.opcode))->name);
		acpi_ex_out_integer("Offset", obj_desc->reference.offset);
		acpi_ex_out_pointer("obj_desc", obj_desc->reference.object);
		acpi_ex_out_pointer("Node", obj_desc->reference.node);
		acpi_ex_out_pointer("Where", obj_desc->reference.where);
R
Robert Moore 已提交
882

L
Len Brown 已提交
883
		acpi_ex_dump_reference(obj_desc);
L
Linus Torvalds 已提交
884 885 886 887
		break;

	case ACPI_TYPE_LOCAL_ADDRESS_HANDLER:

L
Len Brown 已提交
888 889 890 891 892 893 894
		acpi_ex_out_integer("space_id",
				    obj_desc->address_space.space_id);
		acpi_ex_out_pointer("Next", obj_desc->address_space.next);
		acpi_ex_out_pointer("region_list",
				    obj_desc->address_space.region_list);
		acpi_ex_out_pointer("Node", obj_desc->address_space.node);
		acpi_ex_out_pointer("Context", obj_desc->address_space.context);
L
Linus Torvalds 已提交
895 896 897 898
		break;

	case ACPI_TYPE_LOCAL_NOTIFY:

L
Len Brown 已提交
899 900
		acpi_ex_out_pointer("Node", obj_desc->notify.node);
		acpi_ex_out_pointer("Context", obj_desc->notify.context);
L
Linus Torvalds 已提交
901 902 903 904 905 906 907 908
		break;

	case ACPI_TYPE_LOCAL_ALIAS:
	case ACPI_TYPE_LOCAL_METHOD_ALIAS:
	case ACPI_TYPE_LOCAL_EXTRA:
	case ACPI_TYPE_LOCAL_DATA:
	default:

L
Len Brown 已提交
909 910 911
		acpi_os_printf
		    ("ex_dump_object_descriptor: Display not implemented for object type %s\n",
		     acpi_ut_get_object_type_name(obj_desc));
L
Linus Torvalds 已提交
912 913 914 915 916 917
		break;
	}

	return_VOID;
}

L
Len Brown 已提交
918
#endif				/*  ACPI_FUTURE_USAGE  */
L
Linus Torvalds 已提交
919
#endif