/*******************************************************************************
*
* Module Name: dbcmds - Miscellaneous debug commands and output routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2018, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include <acpi/acpi.h>
#include "accommon.h"
#include "acevents.h"
#include "acdebug.h"
#include "acnamesp.h"
#include "acresrc.h"
#include "actables.h"
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME("dbcmds")
/* Local prototypes */
static void
acpi_dm_compare_aml_resources(u8 *aml1_buffer,
acpi_rsdesc_size aml1_buffer_length,
u8 *aml2_buffer,
acpi_rsdesc_size aml2_buffer_length);
static acpi_status
acpi_dm_test_resource_conversion(struct acpi_namespace_node *node, char *name);
static acpi_status
acpi_db_resource_callback(struct acpi_resource *resource, void *context);
static acpi_status
acpi_db_device_resources(acpi_handle obj_handle,
u32 nesting_level, void *context, void **return_value);
static void acpi_db_do_one_sleep_state(u8 sleep_state);
static char *acpi_db_trace_method_name = NULL;
/*******************************************************************************
*
* FUNCTION: acpi_db_convert_to_node
*
* PARAMETERS: in_string - String to convert
*
* RETURN: Pointer to a NS node
*
* DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
* alphanumeric strings.
*
******************************************************************************/
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);
}
/*******************************************************************************
*
* FUNCTION: acpi_db_sleep
*
* PARAMETERS: object_arg - Desired sleep state (0-5). NULL means
* invoke all possible sleep states.
*
* RETURN: Status
*
* DESCRIPTION: Simulate sleep/wake sequences
*
******************************************************************************/
acpi_status acpi_db_sleep(char *object_arg)
{
u8 sleep_state;
u32 i;
ACPI_FUNCTION_TRACE(acpi_db_sleep);
/* Null input (no arguments) means to invoke all sleep states */
if (!object_arg) {
acpi_os_printf("Invoking all possible sleep states, 0-%d\n",
ACPI_S_STATES_MAX);
for (i = 0;