Ejemplo n.º 1
0
void acpi_db_display_resources(char *object_arg)
{
	struct acpi_namespace_node *node;

	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
	acpi_dbg_level |= ACPI_LV_RESOURCES;

	/* Asterisk means "display resources for all devices" */

	if (!object_arg || (!strcmp(object_arg, "*"))) {
		(void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
					  ACPI_UINT32_MAX,
					  acpi_db_device_resources, NULL, NULL,
					  NULL);
	} else {
		/* Convert string to object pointer */

		node = acpi_db_convert_to_node(object_arg);
		if (node) {
			if (node->type != ACPI_TYPE_DEVICE) {
				acpi_os_printf
				    ("%4.4s: Name is not a device object (%s)\n",
				     node->name.ascii,
				     acpi_ut_get_type_name(node->type));
			} else {
				(void)acpi_db_device_resources(node, 0, NULL,
							       NULL);
			}
		}
	}

	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 2
0
void acpi_db_dump_namespace(char *start_arg, char *depth_arg)
{
	acpi_handle subtree_entry = acpi_gbl_root_node;
	u32 max_depth = ACPI_UINT32_MAX;

	/* No argument given, just start at the root and dump entire namespace */

	if (start_arg) {
		subtree_entry = acpi_db_convert_to_node(start_arg);
		if (!subtree_entry) {
			return;
		}

		/* Now we can check for the depth argument */

		if (depth_arg) {
			max_depth = strtoul(depth_arg, NULL, 0);
		}
	}

	acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
	acpi_os_printf("ACPI Namespace (from %4.4s (%p) subtree):\n",
		       ((struct acpi_namespace_node *)subtree_entry)->name.
		       ascii, subtree_entry);

	/* Display the subtree */

	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_objects(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth,
			     ACPI_OWNER_ID_MAX, subtree_entry);
	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 3
0
void
acpi_db_execute_setup (
	db_method_info          *info)
{

	/* Catenate the current scope to the supplied name */

	info->pathname[0] = 0;
	if ((info->name[0] != '\\') &&
		(info->name[0] != '/')) {
		STRCAT (info->pathname, acpi_gbl_db_scope_buf);
	}

	STRCAT (info->pathname, info->name);
	acpi_db_prep_namestring (info->pathname);

	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("Executing %s\n", info->pathname);

	if (info->flags & EX_SINGLE_STEP) {
		acpi_gbl_cm_single_step = TRUE;
		acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
	}

	else {
		/* No single step, allow redirection to a file */

		acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
	}
}
Ejemplo n.º 4
0
acpi_status
acpi_db_display_objects (
	NATIVE_CHAR             *obj_type_arg,
	NATIVE_CHAR             *display_count_arg)
{
	acpi_object_type8       type;


	/* Get the object type */

	type = acpi_db_match_argument (obj_type_arg, acpi_db_object_types);
	if (type == ACPI_TYPE_NOT_FOUND) {
		acpi_os_printf ("Invalid or unsupported argument\n");
		return (AE_OK);
	}

	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("Objects of type [%s] defined in the current ACPI Namespace: \n", acpi_ut_get_type_name (type));

	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);

	/* Walk the namespace from the root */

	acpi_walk_namespace (type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
			   acpi_db_walk_for_specific_objects, (void *) &type, NULL);

	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
	return (AE_OK);
}
Ejemplo n.º 5
0
void
acpi_db_dump_namespace_by_owner (
	NATIVE_CHAR             *owner_arg,
	NATIVE_CHAR             *depth_arg)
{
	acpi_handle             subtree_entry = acpi_gbl_root_node;
	u32                     max_depth = ACPI_UINT32_MAX;
	u16                     owner_id;


	owner_id = (u16) STRTOUL (owner_arg, NULL, 0);


	/* Now we can check for the depth argument */

	if (depth_arg) {
		max_depth = STRTOUL (depth_arg, NULL, 0);
	}


	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("ACPI Namespace by owner %X:\n", owner_id);

	/* Display the subtree */

	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, owner_id, subtree_entry);
	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 6
0
void
acpi_db_dump_namespace (
	NATIVE_CHAR             *start_arg,
	NATIVE_CHAR             *depth_arg)
{
	acpi_handle             subtree_entry = acpi_gbl_root_node;
	u32                     max_depth = ACPI_UINT32_MAX;


	/* No argument given, just start at the root and dump entire namespace */

	if (start_arg) {
		/* Check if numeric argument, must be a Node */

		if ((start_arg[0] >= 0x30) && (start_arg[0] <= 0x39)) {
			subtree_entry = (acpi_handle) STRTOUL (start_arg, NULL, 16);
			if (!acpi_os_readable (subtree_entry, sizeof (acpi_namespace_node))) {
				acpi_os_printf ("Address %p is invalid in this address space\n", subtree_entry);
				return;
			}

			if (!VALID_DESCRIPTOR_TYPE ((subtree_entry), ACPI_DESC_TYPE_NAMED)) {
				acpi_os_printf ("Address %p is not a valid Named object\n", subtree_entry);
				return;
			}
		}

		/* Alpha argument */

		else {
			/* The parameter is a name string that must be resolved to a Named obj*/

			subtree_entry = acpi_db_local_ns_lookup (start_arg);
			if (!subtree_entry) {
				subtree_entry = acpi_gbl_root_node;
			}
		}

		/* Now we can check for the depth argument */

		if (depth_arg) {
			max_depth = STRTOUL (depth_arg, NULL, 0);
		}
	}


	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("ACPI Namespace (from %p subtree):\n", subtree_entry);

	/* Display the subtree */

	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_objects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, max_depth, ACPI_UINT32_MAX, subtree_entry);
	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 7
0
void acpi_db_display_template(char *buffer_arg)
{
	struct acpi_namespace_node *node;
	acpi_status status;
	struct acpi_buffer return_buffer;

	/* Translate buffer_arg to an Named object */

	node = acpi_db_convert_to_node(buffer_arg);
	if (!node || (node == acpi_gbl_root_node)) {
		acpi_os_printf("Invalid argument: %s\n", buffer_arg);
		return;
	}

	/* We must have a buffer object */

	if (node->type != ACPI_TYPE_BUFFER) {
		acpi_os_printf
		    ("Not a Buffer object, cannot be a template: %s\n",
		     buffer_arg);
		return;
	}

	return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
	return_buffer.pointer = acpi_gbl_db_buffer;

	/* Attempt to convert the raw buffer to a resource list */

	status = acpi_rs_create_resource_list(node->object, &return_buffer);

	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
	acpi_dbg_level |= ACPI_LV_RESOURCES;

	if (ACPI_FAILURE(status)) {
		acpi_os_printf
		    ("Could not convert Buffer to a resource list: %s, %s\n",
		     buffer_arg, acpi_format_exception(status));
		goto dump_buffer;
	}

	/* Now we can dump the resource list */

	acpi_rs_dump_resource_list(ACPI_CAST_PTR(struct acpi_resource,
						 return_buffer.pointer));

dump_buffer:
	acpi_os_printf("\nRaw data buffer:\n");
	acpi_ut_debug_dump_buffer((u8 *)node->object->buffer.pointer,
				  node->object->buffer.length,
				  DB_BYTE_DISPLAY, ACPI_UINT32_MAX);

	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
	return;
}
Ejemplo n.º 8
0
void acpi_db_dump_namespace_paths(void)
{

	acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
	acpi_os_printf("ACPI Namespace (from root):\n");

	/* Display the entire namespace */

	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
	acpi_ns_dump_object_paths(ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
				  ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX,
				  acpi_gbl_root_node);

	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 9
0
acpi_status acpi_db_find_name_in_namespace(char *name_arg)
{
	char acpi_name[5] = "____";
	char *acpi_name_ptr = acpi_name;

	if (strlen(name_arg) > ACPI_NAME_SIZE) {
		acpi_os_printf("Name must be no longer than 4 characters\n");
		return (AE_OK);
	}

	/* Pad out name with underscores as necessary to create a 4-char name */

	acpi_ut_strupr(name_arg);
	while (*name_arg) {
		*acpi_name_ptr = *name_arg;
		acpi_name_ptr++;
		name_arg++;
	}

	/* Walk the namespace from the root */

	(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
				  ACPI_UINT32_MAX, acpi_db_walk_and_match_name,
				  NULL, acpi_name, NULL);

	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
	return (AE_OK);
}
Ejemplo n.º 10
0
acpi_status acpi_db_user_commands(char prompt, union acpi_parse_object *op)
{
	acpi_status status = AE_OK;

	acpi_os_printf("\n");

	/* TBD: [Restructure] Need a separate command line buffer for step mode */

	while (!acpi_gbl_db_terminate_loop) {

		/* Force output to console until a command is entered */

		acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);

		/* Different prompt if method is executing */

		if (!acpi_gbl_method_executing) {
			acpi_os_printf("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
		} else {
			acpi_os_printf("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
		}

		/* Get the user input line */

		status = acpi_os_get_line(acpi_gbl_db_line_buf,
					  ACPI_DB_LINE_BUFFER_SIZE, NULL);
		if (ACPI_FAILURE(status)) {
			ACPI_EXCEPTION((AE_INFO, status,
					"While parsing command line"));
			return (status);
		}

		/* Check for single or multithreaded debug */

		if (acpi_gbl_debugger_configuration & DEBUGGER_MULTI_THREADED) {
			/*
			 * Signal the debug thread that we have a command to execute,
			 * and wait for the command to complete.
			 */
			acpi_os_release_mutex(acpi_gbl_db_command_ready);
			if (ACPI_FAILURE(status)) {
				return (status);
			}

			status =
			    acpi_os_acquire_mutex(acpi_gbl_db_command_complete,
						  ACPI_WAIT_FOREVER);
			if (ACPI_FAILURE(status)) {
				return (status);
			}
		} else {
			/* Just call to the command line interpreter */

			acpi_db_single_thread();
		}
	}

	return (status);
}
Ejemplo n.º 11
0
acpi_status
acpi_db_find_name_in_namespace (
	NATIVE_CHAR             *name_arg)
{

	if (STRLEN (name_arg) > 4) {
		acpi_os_printf ("Name must be no longer than 4 characters\n");
		return (AE_OK);
	}

	/* Walk the namespace from the root */

	acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
			   acpi_db_walk_and_match_name, name_arg, NULL);

	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
	return (AE_OK);
}
Ejemplo n.º 12
0
acpi_status
acpi_db_single_step (
	acpi_walk_state         *walk_state,
	acpi_parse_object       *op,
	u32                     opcode_class)
{
	acpi_parse_object       *next;
	acpi_status             status = AE_OK;
	u32                     original_debug_level;
	acpi_parse_object       *display_op;


	FUNCTION_ENTRY ();

	/* Is there a breakpoint set? */

	if (walk_state->method_breakpoint) {
		/* Check if the breakpoint has been reached or passed */

		if (walk_state->method_breakpoint <= op->aml_offset) {
			/* Hit the breakpoint, resume single step, reset breakpoint */

			acpi_os_printf ("***Break*** at AML offset %X\n", op->aml_offset);
			acpi_gbl_cm_single_step = TRUE;
			acpi_gbl_step_to_next_call = FALSE;
			walk_state->method_breakpoint = 0;
		}
	}

	/*
	 * Check if this is an opcode that we are interested in --
	 * namely, opcodes that have arguments
	 */
	if (op->opcode == AML_INT_NAMEDFIELD_OP) {
		return (AE_OK);
	}

	switch (opcode_class) {
	case AML_CLASS_UNKNOWN:
	case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */
		return (AE_OK);
		break;
	}

	/*
	 * Under certain debug conditions, display this opcode and its operands
	 */
	if ((acpi_gbl_db_output_to_file)        ||
		(acpi_gbl_cm_single_step)           ||
		(acpi_dbg_level & ACPI_LV_PARSE)) {
		if ((acpi_gbl_db_output_to_file)    ||
			(acpi_dbg_level & ACPI_LV_PARSE)) {
			acpi_os_printf ("\n[Aml_debug] Next AML Opcode to execute:\n");
		}

		/*
		 * Display this op (and only this op - zero out the NEXT field temporarily,
		 * and disable parser trace output for the duration of the display because
		 * we don't want the extraneous debug output)
		 */
		original_debug_level = acpi_dbg_level;
		acpi_dbg_level &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
		next = op->next;
		op->next = NULL;


		display_op = op;
		if (op->parent) {
			if ((op->parent->opcode == AML_IF_OP) ||
				(op->parent->opcode == AML_WHILE_OP)) {
				display_op = op->parent;
			}
		}

		/* Now we can display it */

		acpi_db_display_op (walk_state, display_op, ACPI_UINT32_MAX);

		if ((op->opcode == AML_IF_OP) ||
			(op->opcode == AML_WHILE_OP)) {
			if (walk_state->control_state->common.value) {
				acpi_os_printf ("Predicate was TRUE, executed block\n");
			}
			else {
				acpi_os_printf ("Predicate is FALSE, skipping block\n");
			}
		}

		else if (op->opcode == AML_ELSE_OP) {
			/* TBD */
		}

		/* Restore everything */

		op->next = next;
		acpi_os_printf ("\n");
		acpi_dbg_level = original_debug_level;
	}

	/* If we are not single stepping, just continue executing the method */

	if (!acpi_gbl_cm_single_step) {
		return (AE_OK);
	}


	/*
	 * If we are executing a step-to-call command,
	 * Check if this is a method call.
	 */
	if (acpi_gbl_step_to_next_call) {
		if (op->opcode != AML_INT_METHODCALL_OP) {
			/* Not a method call, just keep executing */

			return (AE_OK);
		}

		/* Found a method call, stop executing */

		acpi_gbl_step_to_next_call = FALSE;
	}


	/*
	 * If the next opcode is a method call, we will "step over" it
	 * by default.
	 */
	if (op->opcode == AML_INT_METHODCALL_OP) {
		acpi_gbl_cm_single_step = FALSE; /* No more single step while executing called method */

		/* Set the breakpoint on the call, it will stop execution as soon as we return */

		/* TBD: [Future] don't kill the user breakpoint! */

		walk_state->method_breakpoint = /* Op->Aml_offset + */ 1; /* Must be non-zero! */
	}


	/* TBD: [Investigate] what are the namespace locking issues here */

	/* Acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); */

	/* Go into the command loop and await next user command */

	acpi_gbl_method_executing = TRUE;
	status = AE_CTRL_TRUE;
	while (status == AE_CTRL_TRUE) {
		if (acpi_gbl_debugger_configuration == DEBUGGER_MULTI_THREADED) {
			/* Handshake with the front-end that gets user command lines */

			acpi_ut_release_mutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
			acpi_ut_acquire_mutex (ACPI_MTX_DEBUG_CMD_READY);
		}

		else {
			/* Single threaded, we must get a command line ourselves */

			/* Force output to console until a command is entered */

			acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);

			/* Different prompt if method is executing */

			if (!acpi_gbl_method_executing) {
				acpi_os_printf ("%1c ", DB_COMMAND_PROMPT);
			}
			else {
				acpi_os_printf ("%1c ", DB_EXECUTE_PROMPT);
			}

			/* Get the user input line */

			acpi_os_get_line (acpi_gbl_db_line_buf);
		}

		status = acpi_db_command_dispatch (acpi_gbl_db_line_buf, walk_state, op);
	}

	/* Acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); */

	/* User commands complete, continue execution of the interrupted method */

	return (status);
}
Ejemplo n.º 13
0
static acpi_status
acpi_db_start_command(struct acpi_walk_state *walk_state,
		      union acpi_parse_object *op)
{
	acpi_status status;

	/* TBD: [Investigate] are there namespace locking issues here? */

	/* acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); */

	/* Go into the command loop and await next user command */

	acpi_gbl_method_executing = TRUE;
	status = AE_CTRL_TRUE;
	while (status == AE_CTRL_TRUE) {
		if (acpi_gbl_debugger_configuration == DEBUGGER_MULTI_THREADED) {

			/* Handshake with the front-end that gets user command lines */

			acpi_os_release_mutex(acpi_gbl_db_command_complete);

			status =
			    acpi_os_acquire_mutex(acpi_gbl_db_command_ready,
						  ACPI_WAIT_FOREVER);
			if (ACPI_FAILURE(status)) {
				return (status);
			}
		} else {
			/* Single threaded, we must get a command line ourselves */

			/* Force output to console until a command is entered */

			acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);

			/* Different prompt if method is executing */

			if (!acpi_gbl_method_executing) {
				acpi_os_printf("%1c ",
					       ACPI_DEBUGGER_COMMAND_PROMPT);
			} else {
				acpi_os_printf("%1c ",
					       ACPI_DEBUGGER_EXECUTE_PROMPT);
			}

			/* Get the user input line */

			status = acpi_os_get_line(acpi_gbl_db_line_buf,
						  ACPI_DB_LINE_BUFFER_SIZE,
						  NULL);
			if (ACPI_FAILURE(status)) {
				ACPI_EXCEPTION((AE_INFO, status,
						"While parsing command line"));
				return (status);
			}
		}

		status =
		    acpi_db_command_dispatch(acpi_gbl_db_line_buf, walk_state,
					     op);
	}

	/* acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); */

	return (status);
}
Ejemplo n.º 14
0
acpi_status
acpi_db_command_dispatch(char *input_buffer,
			 struct acpi_walk_state * walk_state,
			 union acpi_parse_object * op)
{
	u32 temp;
	u32 command_index;
	u32 param_count;
	char *command_line;
	acpi_status status = AE_CTRL_TRUE;

	/* If acpi_terminate has been called, terminate this thread */

	if (acpi_gbl_db_terminate_loop) {
		return (AE_CTRL_TERMINATE);
	}

	/* Find command and add to the history buffer */

	param_count = acpi_db_get_line(input_buffer);
	command_index = acpi_db_match_command(acpi_gbl_db_args[0]);
	temp = 0;

	/*
	 * We don't want to add the !! command to the history buffer. It
	 * would cause an infinite loop because it would always be the
	 * previous command.
	 */
	if (command_index != CMD_HISTORY_LAST) {
		acpi_db_add_to_history(input_buffer);
	}

	/* Verify that we have the minimum number of params */

	if (param_count < acpi_gbl_db_commands[command_index].min_args) {
		acpi_os_printf
		    ("%u parameters entered, [%s] requires %u parameters\n",
		     param_count, acpi_gbl_db_commands[command_index].name,
		     acpi_gbl_db_commands[command_index].min_args);

		acpi_db_display_command_info(acpi_gbl_db_commands
					     [command_index].name, FALSE);
		return (AE_CTRL_TRUE);
	}

	/* Decode and dispatch the command */

	switch (command_index) {
	case CMD_NULL:

		if (op) {
			return (AE_OK);
		}
		break;

	case CMD_ALLOCATIONS:

#ifdef ACPI_DBG_TRACK_ALLOCATIONS
		acpi_ut_dump_allocations((u32)-1, NULL);
#endif
		break;

	case CMD_ARGS:
	case CMD_ARGUMENTS:

		acpi_db_display_arguments();
		break;

	case CMD_BREAKPOINT:

		acpi_db_set_method_breakpoint(acpi_gbl_db_args[1], walk_state,
					      op);
		break;

	case CMD_BUSINFO:

		acpi_db_get_bus_info();
		break;

	case CMD_CALL:

		acpi_db_set_method_call_breakpoint(op);
		status = AE_OK;
		break;

	case CMD_DEBUG:

		acpi_db_execute(acpi_gbl_db_args[1],
				&acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
				EX_SINGLE_STEP);
		break;

	case CMD_DISASSEMBLE:
	case CMD_DISASM:

		(void)acpi_db_disassemble_method(acpi_gbl_db_args[1]);
		break;

	case CMD_DUMP:

		acpi_db_decode_and_display_object(acpi_gbl_db_args[1],
						  acpi_gbl_db_args[2]);
		break;

	case CMD_EVALUATE:
	case CMD_EXECUTE:

		acpi_db_execute(acpi_gbl_db_args[1],
				&acpi_gbl_db_args[2], &acpi_gbl_db_arg_types[2],
				EX_NO_SINGLE_STEP);
		break;

	case CMD_FIND:

		status = acpi_db_find_name_in_namespace(acpi_gbl_db_args[1]);
		break;

	case CMD_GO:

		acpi_gbl_cm_single_step = FALSE;
		return (AE_OK);

	case CMD_HANDLERS:

		acpi_db_display_handlers();
		break;

	case CMD_HELP:
	case CMD_HELP2:

		acpi_db_display_help(acpi_gbl_db_args[1]);
		break;

	case CMD_HISTORY:

		acpi_db_display_history();
		break;

	case CMD_HISTORY_EXE:	/* ! command */

		command_line = acpi_db_get_from_history(acpi_gbl_db_args[1]);
		if (!command_line) {
			return (AE_CTRL_TRUE);
		}

		status = acpi_db_command_dispatch(command_line, walk_state, op);
		return (status);

	case CMD_HISTORY_LAST:	/* !! command */

		command_line = acpi_db_get_from_history(NULL);
		if (!command_line) {
			return (AE_CTRL_TRUE);
		}

		status = acpi_db_command_dispatch(command_line, walk_state, op);
		return (status);

	case CMD_INFORMATION:

		acpi_db_display_method_info(op);
		break;

	case CMD_INTEGRITY:

		acpi_db_check_integrity();
		break;

	case CMD_INTO:

		if (op) {
			acpi_gbl_cm_single_step = TRUE;
			return (AE_OK);
		}
		break;

	case CMD_LEVEL:

		if (param_count == 0) {
			acpi_os_printf
			    ("Current debug level for file output is:    %8.8lX\n",
			     acpi_gbl_db_debug_level);
			acpi_os_printf
			    ("Current debug level for console output is: %8.8lX\n",
			     acpi_gbl_db_console_debug_level);
		} else if (param_count == 2) {
			temp = acpi_gbl_db_console_debug_level;
			acpi_gbl_db_console_debug_level =
			    strtoul(acpi_gbl_db_args[1], NULL, 16);
			acpi_os_printf
			    ("Debug Level for console output was %8.8lX, now %8.8lX\n",
			     temp, acpi_gbl_db_console_debug_level);
		} else {
			temp = acpi_gbl_db_debug_level;
			acpi_gbl_db_debug_level =
			    strtoul(acpi_gbl_db_args[1], NULL, 16);
			acpi_os_printf
			    ("Debug Level for file output was %8.8lX, now %8.8lX\n",
			     temp, acpi_gbl_db_debug_level);
		}
		break;

	case CMD_LIST:

		acpi_db_disassemble_aml(acpi_gbl_db_args[1], op);
		break;

	case CMD_LOCKS:

		acpi_db_display_locks();
		break;

	case CMD_LOCALS:

		acpi_db_display_locals();
		break;

	case CMD_METHODS:

		status = acpi_db_display_objects("METHOD", acpi_gbl_db_args[1]);
		break;

	case CMD_NAMESPACE:

		acpi_db_dump_namespace(acpi_gbl_db_args[1],
				       acpi_gbl_db_args[2]);
		break;

	case CMD_NOTIFY:

		temp = strtoul(acpi_gbl_db_args[2], NULL, 0);
		acpi_db_send_notify(acpi_gbl_db_args[1], temp);
		break;

	case CMD_OBJECTS:

		acpi_ut_strupr(acpi_gbl_db_args[1]);
		status =
		    acpi_db_display_objects(acpi_gbl_db_args[1],
					    acpi_gbl_db_args[2]);
		break;

	case CMD_OSI:

		acpi_db_display_interfaces(acpi_gbl_db_args[1],
					   acpi_gbl_db_args[2]);
		break;

	case CMD_OWNER:

		acpi_db_dump_namespace_by_owner(acpi_gbl_db_args[1],
						acpi_gbl_db_args[2]);
		break;

	case CMD_PATHS:

		acpi_db_dump_namespace_paths();
		break;

	case CMD_PREFIX:

		acpi_db_set_scope(acpi_gbl_db_args[1]);
		break;

	case CMD_REFERENCES:

		acpi_db_find_references(acpi_gbl_db_args[1]);
		break;

	case CMD_RESOURCES:

		acpi_db_display_resources(acpi_gbl_db_args[1]);
		break;

	case CMD_RESULTS:

		acpi_db_display_results();
		break;

	case CMD_SET:

		acpi_db_set_method_data(acpi_gbl_db_args[1],
					acpi_gbl_db_args[2],
					acpi_gbl_db_args[3]);
		break;

	case CMD_STATS:

		status = acpi_db_display_statistics(acpi_gbl_db_args[1]);
		break;

	case CMD_STOP:

		return (AE_NOT_IMPLEMENTED);

	case CMD_TABLES:

		acpi_db_display_table_info(acpi_gbl_db_args[1]);
		break;

	case CMD_TEMPLATE:

		acpi_db_display_template(acpi_gbl_db_args[1]);
		break;

	case CMD_TRACE:

		acpi_db_trace(acpi_gbl_db_args[1], acpi_gbl_db_args[2],
			      acpi_gbl_db_args[3]);
		break;

	case CMD_TREE:

		acpi_db_display_calling_tree();
		break;

	case CMD_TYPE:

		acpi_db_display_object_type(acpi_gbl_db_args[1]);
		break;

#ifdef ACPI_APPLICATION

		/* Hardware simulation commands. */

	case CMD_ENABLEACPI:
#if (!ACPI_REDUCED_HARDWARE)

		status = acpi_enable();
		if (ACPI_FAILURE(status)) {
			acpi_os_printf("AcpiEnable failed (Status=%X)\n",
				       status);
			return (status);
		}
#endif				/* !ACPI_REDUCED_HARDWARE */
		break;

	case CMD_EVENT:

		acpi_os_printf("Event command not implemented\n");
		break;

	case CMD_GPE:

		acpi_db_generate_gpe(acpi_gbl_db_args[1], acpi_gbl_db_args[2]);
		break;

	case CMD_GPES:

		acpi_db_display_gpes();
		break;

	case CMD_SCI:

		acpi_db_generate_sci();
		break;

	case CMD_SLEEP:

		status = acpi_db_sleep(acpi_gbl_db_args[1]);
		break;

		/* File I/O commands. */

	case CMD_CLOSE:

		acpi_db_close_debug_file();
		break;

	case CMD_LOAD:{
			struct acpi_new_table_desc *list_head = NULL;

			status =
			    ac_get_all_tables_from_file(acpi_gbl_db_args[1],
							ACPI_GET_ALL_TABLES,
							&list_head);
			if (ACPI_SUCCESS(status)) {
				acpi_db_load_tables(list_head);
			}
		}
		break;

	case CMD_OPEN:

		acpi_db_open_debug_file(acpi_gbl_db_args[1]);
		break;

		/* User space commands. */

	case CMD_TERMINATE:

		acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
		acpi_ut_subsystem_shutdown();

		/*
		 * TBD: [Restructure] Need some way to re-initialize without
		 * re-creating the semaphores!
		 */

		acpi_gbl_db_terminate_loop = TRUE;
		/*  acpi_initialize (NULL); */
		break;

	case CMD_THREADS:

		acpi_db_create_execution_threads(acpi_gbl_db_args[1],
						 acpi_gbl_db_args[2],
						 acpi_gbl_db_args[3]);
		break;

		/* Debug test commands. */

	case CMD_PREDEFINED:

		acpi_db_check_predefined_names();
		break;

	case CMD_TEST:

		acpi_db_execute_test(acpi_gbl_db_args[1]);
		break;

	case CMD_UNLOAD:

		acpi_db_unload_acpi_table(acpi_gbl_db_args[1]);
		break;
#endif

	case CMD_EXIT:
	case CMD_QUIT:

		if (op) {
			acpi_os_printf("Method execution terminated\n");
			return (AE_CTRL_TERMINATE);
		}

		if (!acpi_gbl_db_output_to_file) {
			acpi_dbg_level = ACPI_DEBUG_DEFAULT;
		}
#ifdef ACPI_APPLICATION
		acpi_db_close_debug_file();
#endif
		acpi_gbl_db_terminate_loop = TRUE;
		return (AE_CTRL_TERMINATE);

	case CMD_NOT_FOUND:
	default:

		acpi_os_printf("%s: unknown command\n", acpi_gbl_db_args[0]);
		return (AE_CTRL_TRUE);
	}

	if (ACPI_SUCCESS(status)) {
		status = AE_CTRL_TRUE;
	}

	return (status);
}
Ejemplo n.º 15
0
void
acpi_db_create_execution_threads (
	NATIVE_CHAR             *num_threads_arg,
	NATIVE_CHAR             *num_loops_arg,
	NATIVE_CHAR             *method_name_arg)
{
	acpi_status             status;
	u32                     num_threads;
	u32                     num_loops;
	u32                     i;
	acpi_handle             thread_gate;


	/* Get the arguments */

	num_threads = STRTOUL (num_threads_arg, NULL, 0);
	num_loops = STRTOUL (num_loops_arg, NULL, 0);

	if (!num_threads || !num_loops) {
		acpi_os_printf ("Bad argument: Threads %X, Loops %X\n", num_threads, num_loops);
		return;
	}


	/* Create the synchronization semaphore */

	status = acpi_os_create_semaphore (1, 0, &thread_gate);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not create semaphore, %s\n", acpi_format_exception (status));
		return;
	}

	/* Setup the context to be passed to each thread */

	acpi_gbl_db_method_info.name = method_name_arg;
	acpi_gbl_db_method_info.args = NULL;
	acpi_gbl_db_method_info.flags = 0;
	acpi_gbl_db_method_info.num_loops = num_loops;
	acpi_gbl_db_method_info.thread_gate = thread_gate;

	acpi_db_execute_setup (&acpi_gbl_db_method_info);


	/* Create the threads */

	acpi_os_printf ("Creating %X threads to execute %X times each\n", num_threads, num_loops);

	for (i = 0; i < (num_threads); i++) {
		acpi_os_queue_for_execution (OSD_PRIORITY_MED, acpi_db_method_thread, &acpi_gbl_db_method_info);
	}


	/* Wait for all threads to complete */

	i = num_threads;
	while (i)   /* Brain damage for OSD implementations that only support wait of 1 unit */ {
		status = acpi_os_wait_semaphore (thread_gate, 1, WAIT_FOREVER);
		i--;
	}

	/* Cleanup and exit */

	acpi_os_delete_semaphore (thread_gate);

	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);
	acpi_os_printf ("All threads (%X) have completed\n", num_threads);
	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 16
0
void
acpi_db_execute (
	NATIVE_CHAR             *name,
	NATIVE_CHAR             **args,
	u32                     flags)
{
	acpi_status             status;
	acpi_buffer             return_obj;


#ifdef ACPI_DEBUG
	u32                     previous_allocations;
	u32                     allocations;


	/* Memory allocation tracking */

	previous_allocations = acpi_db_get_outstanding_allocations ();
#endif

	acpi_gbl_db_method_info.name = name;
	acpi_gbl_db_method_info.args = args;
	acpi_gbl_db_method_info.flags = flags;

	acpi_db_execute_setup (&acpi_gbl_db_method_info);
	status = acpi_db_execute_method (&acpi_gbl_db_method_info, &return_obj);

	/*
	 * Allow any handlers in separate threads to complete.
	 * (Such as Notify handlers invoked from AML executed above).
	 */
	acpi_os_sleep (0, 10);


#ifdef ACPI_DEBUG

	/* Memory allocation tracking */

	allocations = acpi_db_get_outstanding_allocations () - previous_allocations;

	acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT);

	if (allocations > 0) {
		acpi_os_printf ("Outstanding: %ld allocations after execution\n",
				  allocations);
	}
#endif

	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Execution of %s failed with status %s\n",
			acpi_gbl_db_method_info.pathname, acpi_format_exception (status));
	}

	else {
		/* Display a return object, if any */

		if (return_obj.length) {
			acpi_os_printf ("Execution of %s returned object %p Buflen %X\n",
				acpi_gbl_db_method_info.pathname, return_obj.pointer, return_obj.length);
			acpi_db_dump_object (return_obj.pointer, 1);
		}
	}

	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
}
Ejemplo n.º 17
0
acpi_status acpi_db_display_objects(char *obj_type_arg, char *display_count_arg)
{
	struct acpi_walk_info info;
	acpi_object_type type;
	struct acpi_object_info *object_info;
	u32 i;
	u32 total_objects = 0;

	/* No argument means display summary/count of all object types */

	if (!obj_type_arg) {
		object_info =
		    ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_object_info));

		/* Walk the namespace from the root */

		(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
					  ACPI_UINT32_MAX,
					  acpi_db_walk_for_object_counts, NULL,
					  (void *)object_info, NULL);

		acpi_os_printf("\nSummary of namespace objects:\n\n");

		for (i = 0; i < ACPI_TOTAL_TYPES; i++) {
			acpi_os_printf("%8u %s\n", object_info->types[i],
				       acpi_ut_get_type_name(i));

			total_objects += object_info->types[i];
		}

		acpi_os_printf("\n%8u Total namespace objects\n\n",
			       total_objects);

		ACPI_FREE(object_info);
		return (AE_OK);
	}

	/* Get the object type */

	type = acpi_db_match_argument(obj_type_arg, acpi_db_object_types);
	if (type == ACPI_TYPE_NOT_FOUND) {
		acpi_os_printf("Invalid or unsupported argument\n");
		return (AE_OK);
	}

	acpi_db_set_output_destination(ACPI_DB_DUPLICATE_OUTPUT);
	acpi_os_printf
	    ("Objects of type [%s] defined in the current ACPI Namespace:\n",
	     acpi_ut_get_type_name(type));

	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);

	info.count = 0;
	info.owner_id = ACPI_OWNER_ID_MAX;
	info.debug_level = ACPI_UINT32_MAX;
	info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;

	/* Walk the namespace from the root */

	(void)acpi_walk_namespace(type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
				  acpi_db_walk_for_specific_objects, NULL,
				  (void *)&info, NULL);

	acpi_os_printf
	    ("\nFound %u objects of type [%s] in the current ACPI Namespace\n",
	     info.count, acpi_ut_get_type_name(type));

	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
	return (AE_OK);
}
Ejemplo n.º 18
0
void
acpi_db_display_resources (
	NATIVE_CHAR             *object_arg)
{
#ifndef _IA16
	acpi_operand_object     *obj_desc;
	acpi_status             status;
	acpi_buffer             return_obj;


	acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT);

	/* Convert string to object pointer */

	obj_desc = (acpi_operand_object *) STRTOUL (object_arg, NULL, 16);

	/* Prepare for a return object of arbitrary size */

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;


	/* _PRT */

	acpi_os_printf ("Evaluating _PRT\n");

	status = acpi_evaluate_object (obj_desc, "_PRT", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _PRT: %s\n", acpi_format_exception (status));
		goto get_crs;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_irq_routing_table (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Get_irq_routing_table failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_irq_list ((u8 *) acpi_gbl_db_buffer);
	}


	/* _CRS */

get_crs:
	acpi_os_printf ("Evaluating _CRS\n");

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_evaluate_object (obj_desc, "_CRS", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _CRS: %s\n", acpi_format_exception (status));
		goto get_prs;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_current_resources (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Acpi_get_current_resources failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
	}


	/* _PRS */

get_prs:
	acpi_os_printf ("Evaluating _PRS\n");

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_evaluate_object (obj_desc, "_PRS", NULL, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Could not obtain _PRS: %s\n", acpi_format_exception (status));
		goto cleanup;
	}

	return_obj.pointer          = acpi_gbl_db_buffer;
	return_obj.length           = ACPI_DEBUG_BUFFER_SIZE;

	status = acpi_get_possible_resources (obj_desc, &return_obj);
	if (ACPI_FAILURE (status)) {
		acpi_os_printf ("Acpi_get_possible_resources failed: %s\n", acpi_format_exception (status));
	}

	else {
		acpi_rs_dump_resource_list ((acpi_resource *) acpi_gbl_db_buffer);
	}


cleanup:

	acpi_db_set_output_destination (DB_CONSOLE_OUTPUT);
	return;
#endif

}