// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/*******************************************************************************
*
* Module Name: dbdisply - debug display commands
*
******************************************************************************/
#include <acpi/acpi.h>
#include "accommon.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "acparser.h"
#include "acinterp.h"
#include "acevents.h"
#include "acdebug.h"
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbdisply")
/* Local prototypes */
static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op);
static void *acpi_db_get_pointer(void *target);
static acpi_status
acpi_db_display_non_root_handlers(acpi_handle obj_handle,
u32 nesting_level,
void *context, void **return_value);
/*
* System handler information.
* Used for Handlers command, in acpi_db_display_handlers.
*/
#define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "
#define ACPI_HANDLER_NAME_STRING "%30s : "
#define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"
#define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"
#define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"
/* All predefined Address Space IDs */
static acpi_adr_space_type acpi_gbl_space_id_list[] = {
ACPI_ADR_SPACE_SYSTEM_MEMORY,
ACPI_ADR_SPACE_SYSTEM_IO,
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_ADR_SPACE_EC,
ACPI_ADR_SPACE_SMBUS,
ACPI_ADR_SPACE_CMOS,
ACPI_ADR_SPACE_PCI_BAR_TARGET,
ACPI_ADR_SPACE_IPMI,
ACPI_ADR_SPACE_GPIO,
ACPI_ADR_SPACE_GSBUS,
ACPI_ADR_SPACE_PLATFORM_COMM,
ACPI_ADR_SPACE_PLATFORM_RT,
ACPI_ADR_SPACE_DATA_TABLE,
ACPI_ADR_SPACE_FIXED_HARDWARE
};
/* Global handler information */
typedef struct acpi_handler_info {
void *handler;
char *name;
} acpi_handler_info;
static struct acpi_handler_info acpi_gbl_handler_list[] = {
{&acpi_gbl_global_notify[0].handler, "System Notifications"},
{&acpi_gbl_global_notify[1].handler, "Device Notifications"},
{&acpi_gbl_table_handler, "ACPI Table Events"},
{&acpi_gbl_exception_handler, "Control Method Exceptions"},
{&acpi_gbl_interface_handler, "OSI Invocations"}
};
/*******************************************************************************
*
* FUNCTION: acpi_db_get_pointer
*
* PARAMETERS: target - Pointer to string to be converted
*
* RETURN: Converted pointer
*
* DESCRIPTION: Convert an ascii pointer value to a real value
*
******************************************************************************/
static void *acpi_db_get_pointer(void *target)
{
void *obj_ptr;
acpi_size address;
address = strtoul(target, NULL, 16);
obj_ptr = ACPI_TO_POINTER(address);
return (obj_ptr);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_dump_parser_descriptor
*
* PARAMETERS: op - A parser Op descriptor
*
* RETURN: None
*
* DESCRIPTION: Display a formatted parser object
*
******************************************************************************/
static void acpi_db_dump_parser_descriptor(union acpi_parse_object *op)
{
const struct acpi_opcode_info *info;
info = acpi_ps_get_opcode_info(op->common.aml_opcode);
acpi_os_printf("Parser Op Descriptor:\n");
acpi_os_printf("%20.20s : %4.4X\n", "Opcode", op->common.aml_opcode);
ACPI_DEBUG_ONLY_MEMBERS(acpi_os_printf("%20.20s : %s\n", "Opcode Name",
info->name));
acpi_os_printf("%20.20s : %p\n", "Value/ArgList", op->common.value.arg);
acpi_os_printf("%20.20s : %p\n", "Parent", op->common.parent);
acpi_os_printf("%20.20s : %p\n", "NextOp", op->common.next);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_decode_and_display_object
*
* PARAMETERS: target - String with object to be displayed. Names
* and hex pointers are supported.
* output_type - Byte, Word, Dword, or Qword (B|W|D|Q)
*
* RETURN: None
*
* DESCRIPTION: Display a formatted ACPI object
*
******************************************************************************/
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 <