Exemple #1
0
static acpi_status
acpi_db_classify_one_object(acpi_handle obj_handle,
			    u32 nesting_level,
			    void *context, void **return_value)
{
	struct acpi_namespace_node *node;
	union acpi_operand_object *obj_desc;
	u32 type;

	acpi_gbl_num_nodes++;

	node = (struct acpi_namespace_node *)obj_handle;
	obj_desc = acpi_ns_get_attached_object(node);

	acpi_db_enumerate_object(obj_desc);

	type = node->type;
	if (type > ACPI_TYPE_NS_NODE_MAX) {
		acpi_gbl_node_type_count_misc++;
	} else {
		acpi_gbl_node_type_count[type]++;
	}

	return (AE_OK);

#ifdef ACPI_FUTURE_IMPLEMENTATION

	/* TBD: These need to be counted during the initial parsing phase */

	if (acpi_ps_is_named_op(op->opcode)) {
		num_nodes++;
	}

	if (is_method) {
		num_method_elements++;
	}

	num_grammar_elements++;
	op = acpi_ps_get_depth_next(root, op);

	size_of_parse_tree = (num_grammar_elements - num_method_elements) *
	    (u32)sizeof(union acpi_parse_object);
	size_of_method_trees =
	    num_method_elements * (u32)sizeof(union acpi_parse_object);
	size_of_node_entries =
	    num_nodes * (u32)sizeof(struct acpi_namespace_node);
	size_of_acpi_objects =
	    num_nodes * (u32)sizeof(union acpi_operand_object);
#endif
}
Exemple #2
0
acpi_status
acpi_db_second_pass_parse (
	acpi_parse_object       *root)
{
	acpi_parse_object       *op = root;
	acpi_parse2_object      *method;
	acpi_parse_object       *search_op;
	acpi_parse_object       *start_op;
	acpi_status             status = AE_OK;
	u32                     base_aml_offset;
	acpi_walk_state         *walk_state;


	FUNCTION_ENTRY ();


	acpi_os_printf ("Pass two parse ....\n");


	while (op) {
		if (op->opcode == AML_METHOD_OP) {
			method = (acpi_parse2_object *) op;

			walk_state = acpi_ds_create_walk_state (TABLE_ID_DSDT,
					   NULL, NULL, NULL);
			if (!walk_state) {
				return (AE_NO_MEMORY);
			}


			walk_state->parser_state.aml        =
			walk_state->parser_state.aml_start  = method->data;
			walk_state->parser_state.aml_end    =
			walk_state->parser_state.pkg_end    = method->data + method->length;
			walk_state->parser_state.start_scope = op;

			walk_state->descending_callback     = acpi_ds_load1_begin_op;
			walk_state->ascending_callback      = acpi_ds_load1_end_op;


			status = acpi_ps_parse_aml (walk_state);


			base_aml_offset = (method->value.arg)->aml_offset + 1;
			start_op = (method->value.arg)->next;
			search_op = start_op;

			while (search_op) {
				search_op->aml_offset += base_aml_offset;
				search_op = acpi_ps_get_depth_next (start_op, search_op);
			}

		}

		if (op->opcode == AML_REGION_OP) {
			/* TBD: [Investigate] this isn't quite the right thing to do! */
			/*
			 *
			 * Method = (ACPI_DEFERRED_OP *) Op;
			 * Status = Acpi_ps_parse_aml (Op, Method->Body, Method->Body_length);
			 */
		}

		if (ACPI_FAILURE (status)) {
			break;
		}

		op = acpi_ps_get_depth_next (root, op);
	}

	return (status);
}
Exemple #3
0
void acpi_db_display_method_info(union acpi_parse_object *start_op)
{
	struct acpi_walk_state *walk_state;
	union acpi_operand_object *obj_desc;
	struct acpi_namespace_node *node;
	union acpi_parse_object *root_op;
	union acpi_parse_object *op;
	const struct acpi_opcode_info *op_info;
	u32 num_ops = 0;
	u32 num_operands = 0;
	u32 num_operators = 0;
	u32 num_remaining_ops = 0;
	u32 num_remaining_operands = 0;
	u32 num_remaining_operators = 0;
	u8 count_remaining = FALSE;

	walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
	if (!walk_state) {
		acpi_os_printf("There is no method currently executing\n");
		return;
	}

	obj_desc = walk_state->method_desc;
	node = walk_state->method_node;

	acpi_os_printf("Currently executing control method is [%4.4s]\n",
		       acpi_ut_get_node_name(node));
	acpi_os_printf("%X Arguments, SyncLevel = %X\n",
		       (u32)obj_desc->method.param_count,
		       (u32)obj_desc->method.sync_level);

	root_op = start_op;
	while (root_op->common.parent) {
		root_op = root_op->common.parent;
	}

	op = root_op;

	while (op) {
		if (op == start_op) {
			count_remaining = TRUE;
		}

		num_ops++;
		if (count_remaining) {
			num_remaining_ops++;
		}

		/* Decode the opcode */

		op_info = acpi_ps_get_opcode_info(op->common.aml_opcode);
		switch (op_info->class) {
		case AML_CLASS_ARGUMENT:

			if (count_remaining) {
				num_remaining_operands++;
			}

			num_operands++;
			break;

		case AML_CLASS_UNKNOWN:

			/* Bad opcode or ASCII character */

			continue;

		default:

			if (count_remaining) {
				num_remaining_operators++;
			}

			num_operators++;
			break;
		}

		op = acpi_ps_get_depth_next(start_op, op);
	}

	acpi_os_printf
	    ("Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
	     num_ops, num_operators, num_operands);

	acpi_os_printf
	    ("Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
	     num_remaining_ops, num_remaining_operators,
	     num_remaining_operands);
}
Exemple #4
0
acpi_status acpi_db_second_pass_parse(union acpi_parse_object *root)
{
	union acpi_parse_object *op = root;
	union acpi_parse_object *method;
	union acpi_parse_object *search_op;
	union acpi_parse_object *start_op;
	acpi_status status = AE_OK;
	u32 base_aml_offset;
	struct acpi_walk_state *walk_state;

	ACPI_FUNCTION_ENTRY();

	acpi_os_printf("Pass two parse ....\n");

	while (op) {
		if (op->common.aml_opcode == AML_METHOD_OP) {
			method = op;

			/* Create a new walk state for the parse */

			walk_state =
			    acpi_ds_create_walk_state(0, NULL, NULL, NULL);
			if (!walk_state) {
				return (AE_NO_MEMORY);
			}

			/* Init the Walk State */

			walk_state->parser_state.aml =
			    walk_state->parser_state.aml_start =
			    method->named.data;
			walk_state->parser_state.aml_end =
			    walk_state->parser_state.pkg_end =
			    method->named.data + method->named.length;
			walk_state->parser_state.start_scope = op;

			walk_state->descending_callback =
			    acpi_ds_load1_begin_op;
			walk_state->ascending_callback = acpi_ds_load1_end_op;

			/* Perform the AML parse */

			status = acpi_ps_parse_aml(walk_state);

			base_aml_offset =
			    (method->common.value.arg)->common.aml_offset + 1;
			start_op = (method->common.value.arg)->common.next;
			search_op = start_op;

			while (search_op) {
				search_op->common.aml_offset += base_aml_offset;
				search_op =
				    acpi_ps_get_depth_next(start_op, search_op);
			}
		}

		if (op->common.aml_opcode == AML_REGION_OP) {

			/* TBD: [Investigate] this isn't quite the right thing to do! */
			/*
			 *
			 * Method = (ACPI_DEFERRED_OP *) Op;
			 * Status = acpi_ps_parse_aml (Op, Method->Body, Method->body_length);
			 */
		}

		if (ACPI_FAILURE(status)) {
			break;
		}

		op = acpi_ps_get_depth_next(root, op);
	}

	return (status);
}
Exemple #5
0
void
acpi_db_display_op (
	acpi_walk_state         *walk_state,
	acpi_parse_object       *origin,
	u32                     num_opcodes)
{
	acpi_parse_object       *op = origin;
	acpi_parse_object       *arg;
	acpi_parse_object       *depth;
	u32                     depth_count = 0;
	u32                     last_depth = 0;
	u32                     i;
	u32                     j;


	if (op) {
		while (op) {
			/* indentation */

			depth_count = 0;
			if (!acpi_gbl_db_opt_verbose) {
				depth_count++;
			}

			/* Determine the nesting depth of this argument */

			for (depth = op->parent; depth; depth = depth->parent) {
				arg = acpi_ps_get_arg (depth, 0);
				while (arg && arg != origin) {
					arg = arg->next;
				}

				if (arg) {
					break;
				}

				depth_count++;
			}


			/* Open a new block if we are nested further than last time */

			if (depth_count > last_depth) {
				VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth));
				for (i = 0; i < last_depth; i++) {
					acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
				}

				if (acpi_db_block_type (op) == BLOCK_PAREN) {
					acpi_os_printf ("(\n");
				}
				else {
					acpi_os_printf ("{\n");
				}
			}

			/* Close a block if we are nested less than last time */

			else if (depth_count < last_depth) {
				for (j = 0; j < (last_depth - depth_count); j++) {
					VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - j));
					for (i = 0; i < (last_depth - j - 1); i++) {
						acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
					}

					if (acpi_db_block_type (op) == BLOCK_PAREN) {
						acpi_os_printf (")\n");
					}
					else {
						acpi_os_printf ("}\n");
					}
				}
			}

			/* In verbose mode, print the AML offset, opcode and depth count */

			VERBOSE_PRINT ((DB_FULL_OP_INFO, (unsigned) op->aml_offset, op->opcode, depth_count));


			/* Indent the output according to the depth count */

			for (i = 0; i < depth_count; i++) {
				acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
			}


			/* Now print the opcode */

			acpi_db_display_opcode (walk_state, op);

			/* Resolve a name reference */

			if ((op->opcode == AML_INT_NAMEPATH_OP && op->value.name)  &&
				(op->parent) &&
				(acpi_gbl_db_opt_verbose)) {
				acpi_ps_display_object_pathname (walk_state, op);
			}

			acpi_os_printf ("\n");

			/* Get the next node in the tree */

			op = acpi_ps_get_depth_next (origin, op);
			last_depth = depth_count;

			num_opcodes--;
			if (!num_opcodes) {
				op = NULL;
			}
		}

		/* Close the last block(s) */

		depth_count = last_depth -1;
		for (i = 0; i < last_depth; i++) {
			VERBOSE_PRINT ((DB_NO_OP_INFO, last_depth - i));
			for (j = 0; j < depth_count; j++) {
				acpi_os_printf ("%s", acpi_gbl_db_disasm_indent);
			}
			acpi_os_printf ("}\n");
			depth_count--;
		}

	}

	else {
		acpi_db_display_opcode (walk_state, op);
	}
}