acpi_status
acpi_tb_validate_table_header(struct acpi_table_header *table_header)
{
	acpi_name signature;

	ACPI_FUNCTION_ENTRY();

	/* Verify that this is a valid address */

	if (!acpi_os_readable(table_header, sizeof(struct acpi_table_header))) {
		ACPI_ERROR((AE_INFO,
			    "Cannot read table header at %p", table_header));

		return (AE_BAD_ADDRESS);
	}

	/* Ensure that the signature is 4 ASCII characters */

	ACPI_MOVE_32_TO_32(&signature, table_header->signature);
	if (!acpi_ut_valid_acpi_name(signature)) {
		ACPI_ERROR((AE_INFO,
			    "Table signature at %p [%p] has invalid characters",
			    table_header, &signature));

		ACPI_WARNING((AE_INFO, "Invalid table signature found: [%4.4s]",
			      ACPI_CAST_PTR(char, &signature)));

		ACPI_DUMP_BUFFER(table_header,
				 sizeof(struct acpi_table_header));
		return (AE_BAD_SIGNATURE);
	}
Esempio n. 2
0
ACPI_STATUS
acpi_tb_validate_table_header (
	ACPI_TABLE_HEADER       *table_header)
{
	ACPI_NAME               signature;


	/* Verify that this is a valid address */

	if (!acpi_os_readable (table_header, sizeof (ACPI_TABLE_HEADER))) {
		return (AE_BAD_ADDRESS);
	}


	/* Ensure that the signature is 4 ASCII characters */

	MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
	if (!acpi_cm_valid_acpi_name (signature)) {
		REPORT_WARNING (("Invalid table signature found\n"));
		return (AE_BAD_SIGNATURE);
	}


	/* Validate the table length */

	if (table_header->length < sizeof (ACPI_TABLE_HEADER)) {
		REPORT_WARNING (("Invalid table header length found\n"));
		return (AE_BAD_HEADER);
	}

	return (AE_OK);
}
Esempio n. 3
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);
}
Esempio n. 4
0
acpi_status
acpi_tb_validate_table_header (
	struct acpi_table_header        *table_header)
{
	acpi_name                       signature;


	ACPI_FUNCTION_NAME ("tb_validate_table_header");


	/* Verify that this is a valid address */

	if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Cannot read table header at %p\n", table_header));

		return (AE_BAD_ADDRESS);
	}

	/* Ensure that the signature is 4 ASCII characters */

	ACPI_MOVE_32_TO_32 (&signature, table_header->signature);
	if (!acpi_ut_valid_acpi_name (signature)) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Table signature at %p [%p] has invalid characters\n",
			table_header, &signature));

		ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n",
			(char *) &signature));

		ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
		return (AE_BAD_SIGNATURE);
	}

	/* Validate the table length */

	if (table_header->length < sizeof (struct acpi_table_header)) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Invalid length in table header %p name %4.4s\n",
			table_header, (char *) &signature));

		ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n",
			(u32) table_header->length));

		ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
		return (AE_BAD_HEADER);
	}

	return (AE_OK);
}
Esempio n. 5
0
struct acpi_namespace_node *acpi_db_convert_to_node(char *in_string)
{
	struct acpi_namespace_node *node;
	acpi_size address;

	if ((*in_string >= 0x30) && (*in_string <= 0x39)) {

		/* Numeric argument, convert */

		address = strtoul(in_string, NULL, 16);
		node = ACPI_TO_POINTER(address);
		if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
			acpi_os_printf("Address %p is invalid", node);
			return (NULL);
		}

		/* Make sure pointer is valid NS node */

		if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
			acpi_os_printf
			    ("Address %p is not a valid namespace node [%s]\n",
			     node, acpi_ut_get_descriptor_name(node));
			return (NULL);
		}
	} else {
		/*
		 * Alpha argument: The parameter is a name string that must be
		 * resolved to a Namespace object.
		 */
		node = acpi_db_local_ns_lookup(in_string);
		if (!node) {
			acpi_os_printf
			    ("Could not find [%s] in namespace, defaulting to root node\n",
			     in_string);
			node = acpi_gbl_root_node;
		}
	}

	return (node);
}
Esempio n. 6
0
void acpi_db_decode_and_display_object(char *target, char *output_type)
{
	void *obj_ptr;
	struct acpi_namespace_node *node;
	union acpi_operand_object *obj_desc;
	u32 display = DB_BYTE_DISPLAY;
	char buffer[80];
	struct acpi_buffer ret_buf;
	acpi_status status;
	u32 size;

	if (!target) {
		return;
	}

	/* Decode the output type */

	if (output_type) {
		acpi_ut_strupr(output_type);
		if (output_type[0] == 'W') {
			display = DB_WORD_DISPLAY;
		} else if (output_type[0] == 'D') {
			display = DB_DWORD_DISPLAY;
		} else if (output_type[0] == 'Q') {
			display = DB_QWORD_DISPLAY;
		}
	}

	ret_buf.length = sizeof(buffer);
	ret_buf.pointer = buffer;

	/* Differentiate between a number and a name */

	if ((target[0] >= 0x30) && (target[0] <= 0x39)) {
		obj_ptr = acpi_db_get_pointer(target);
		if (!acpi_os_readable(obj_ptr, 16)) {
			acpi_os_printf
			    ("Address %p is invalid in this address space\n",
			     obj_ptr);
			return;
		}

		/* Decode the object type */

		switch (ACPI_GET_DESCRIPTOR_TYPE(obj_ptr)) {
		case ACPI_DESC_TYPE_NAMED:

			/* This is a namespace Node */

			if (!acpi_os_readable
			    (obj_ptr, sizeof(struct acpi_namespace_node))) {
				acpi_os_printf
				    ("Cannot read entire Named object at address %p\n",
				     obj_ptr);
				return;
			}

			node = obj_ptr;
			goto dump_node;

		case ACPI_DESC_TYPE_OPERAND:

			/* This is a ACPI OPERAND OBJECT */

			if (!acpi_os_readable
			    (obj_ptr, sizeof(union acpi_operand_object))) {
				acpi_os_printf
				    ("Cannot read entire ACPI object at address %p\n",
				     obj_ptr);
				return;
			}

			acpi_ut_debug_dump_buffer(obj_ptr,
						  sizeof(union
							 acpi_operand_object),
						  display, ACPI_UINT32_MAX);
			acpi_ex_dump_object_descriptor(obj_ptr, 1);
			break;

		case ACPI_DESC_TYPE_PARSER:

			/* This is a Parser Op object */

			if (!acpi_os_readable
			    (obj_ptr, sizeof(union acpi_parse_object))) {
				acpi_os_printf
				    ("Cannot read entire Parser object at address %p\n",
				     obj_ptr);
				return;
			}

			acpi_ut_debug_dump_buffer(obj_ptr,
						  sizeof(union
							 acpi_parse_object),
						  display, ACPI_UINT32_MAX);
			acpi_db_dump_parser_descriptor((union acpi_parse_object
							*)obj_ptr);
			break;

		default:

			/* Is not a recognizeable object */

			acpi_os_printf
			    ("Not a known ACPI internal object, descriptor type %2.2X\n",
			     ACPI_GET_DESCRIPTOR_TYPE(obj_ptr));

			size = 16;
			if (acpi_os_readable(obj_ptr, 64)) {
				size = 64;
			}

			/* Just dump some memory */

			acpi_ut_debug_dump_buffer(obj_ptr, size, display,
						  ACPI_UINT32_MAX);
			break;
		}

		return;
	}

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

	node = acpi_db_local_ns_lookup(target);
	if (!node) {
		return;
	}

dump_node:
	/* Now dump the NS node */

	status = acpi_get_name(node, ACPI_FULL_PATHNAME_NO_TRAILING, &ret_buf);
	if (ACPI_FAILURE(status)) {
		acpi_os_printf("Could not convert name to pathname\n");
	}

	else {
		acpi_os_printf("Object (%p) Pathname: %s\n",
			       node, (char *)ret_buf.pointer);
	}

	if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
		acpi_os_printf("Invalid Named object at address %p\n", node);
		return;
	}

	acpi_ut_debug_dump_buffer((void *)node,
				  sizeof(struct acpi_namespace_node), display,
				  ACPI_UINT32_MAX);
	acpi_ex_dump_namespace_node(node, 1);

	obj_desc = acpi_ns_get_attached_object(node);
	if (obj_desc) {
		acpi_os_printf("\nAttached Object (%p):\n", obj_desc);
		if (!acpi_os_readable
		    (obj_desc, sizeof(union acpi_operand_object))) {
			acpi_os_printf
			    ("Invalid internal ACPI Object at address %p\n",
			     obj_desc);
			return;
		}

		acpi_ut_debug_dump_buffer((void *)obj_desc,
					  sizeof(union acpi_operand_object),
					  display, ACPI_UINT32_MAX);
		acpi_ex_dump_object_descriptor(obj_desc, 1);
	}
}