linux/drivers/acpi/acpica/dbutils.c

// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/*******************************************************************************
 *
 * Module Name: dbutils - AML debugger utilities
 *
 ******************************************************************************/

#include <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
#include "acdebug.h"

#define _COMPONENT
ACPI_MODULE_NAME("dbutils")

/* Local prototypes */
#ifdef ACPI_OBSOLETE_FUNCTIONS
acpi_status acpi_db_second_pass_parse(union acpi_parse_object *root);

void acpi_db_dump_buffer(u32 address);
#endif

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_match_argument
 *
 * PARAMETERS:  user_argument           - User command line
 *              arguments               - Array of commands to match against
 *
 * RETURN:      Index into command array or ACPI_TYPE_NOT_FOUND if not found
 *
 * DESCRIPTION: Search command array for a command match
 *
 ******************************************************************************/

acpi_object_type
acpi_db_match_argument(char *user_argument,
		       struct acpi_db_argument_info *arguments)
{}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_set_output_destination
 *
 * PARAMETERS:  output_flags        - Current flags word
 *
 * RETURN:      None
 *
 * DESCRIPTION: Set the current destination for debugger output. Also sets
 *              the debug output level accordingly.
 *
 ******************************************************************************/

void acpi_db_set_output_destination(u32 output_flags)
{}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_dump_external_object
 *
 * PARAMETERS:  obj_desc        - External ACPI object to dump
 *              level           - Nesting level.
 *
 * RETURN:      None
 *
 * DESCRIPTION: Dump the contents of an ACPI external object
 *
 ******************************************************************************/

void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level)
{}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_prep_namestring
 *
 * PARAMETERS:  name            - String to prepare
 *
 * RETURN:      None
 *
 * DESCRIPTION: Translate all forward slashes and dots to backslashes.
 *
 ******************************************************************************/

void acpi_db_prep_namestring(char *name)
{}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_local_ns_lookup
 *
 * PARAMETERS:  name            - Name to lookup
 *
 * RETURN:      Pointer to a namespace node, null on failure
 *
 * DESCRIPTION: Lookup a name in the ACPI namespace
 *
 * Note: Currently begins search from the root. Could be enhanced to use
 * the current prefix (scope) node as the search beginning point.
 *
 ******************************************************************************/

struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name)
{}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_uint32_to_hex_string
 *
 * PARAMETERS:  value           - The value to be converted to string
 *              buffer          - Buffer for result (not less than 11 bytes)
 *
 * RETURN:      None
 *
 * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
 *
 * NOTE: It is the caller's responsibility to ensure that the length of buffer
 *       is sufficient.
 *
 ******************************************************************************/

void acpi_db_uint32_to_hex_string(u32 value, char *buffer)
{}

#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
 *
 * FUNCTION:    acpi_db_second_pass_parse
 *
 * PARAMETERS:  root            - Root of the parse tree
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until
 *              second pass to parse the control methods
 *
 ******************************************************************************/

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);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_dump_buffer
 *
 * PARAMETERS:  address             - Pointer to the buffer
 *
 * RETURN:      None
 *
 * DESCRIPTION: Print a portion of a buffer
 *
 ******************************************************************************/

void acpi_db_dump_buffer(u32 address)
{

	acpi_os_printf("\nLocation %X:\n", address);

	acpi_dbg_level |= ACPI_LV_TABLES;
	acpi_ut_debug_dump_buffer(ACPI_TO_POINTER(address), 64, DB_BYTE_DISPLAY,
				  ACPI_UINT32_MAX);
}
#endif