Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Module Name: dbcmds - Miscellaneous debug commands and output routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include "acdebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include "acresrc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #define _COMPONENT          ACPI_CA_DEBUGGER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) ACPI_MODULE_NAME("dbcmds")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) acpi_dm_compare_aml_resources(u8 *aml1_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 			      acpi_rsdesc_size aml1_buffer_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 			      u8 *aml2_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 			      acpi_rsdesc_size aml2_buffer_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) acpi_dm_test_resource_conversion(struct acpi_namespace_node *node, char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) acpi_db_resource_callback(struct acpi_resource *resource, void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) acpi_db_device_resources(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 			 u32 nesting_level, void *context, void **return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) static void acpi_db_do_one_sleep_state(u8 sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) static char *acpi_db_trace_method_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42)  * FUNCTION:    acpi_db_convert_to_node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44)  * PARAMETERS:  in_string           - String to convert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46)  * RETURN:      Pointer to a NS node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48)  * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49)  *              alphanumeric strings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) struct acpi_namespace_node *acpi_db_convert_to_node(char *in_string)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	acpi_size address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	if ((*in_string >= 0x30) && (*in_string <= 0x39)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 		/* Numeric argument, convert */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 		address = strtoul(in_string, NULL, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 		node = ACPI_TO_POINTER(address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 		if (!acpi_os_readable(node, sizeof(struct acpi_namespace_node))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 			acpi_os_printf("Address %p is invalid", node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 			return (NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 		/* Make sure pointer is valid NS node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 		if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 			acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 			    ("Address %p is not a valid namespace node [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 			     node, acpi_ut_get_descriptor_name(node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 			return (NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 		 * Alpha argument: The parameter is a name string that must be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 		 * resolved to a Namespace object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 		node = acpi_db_local_ns_lookup(in_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 		if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 			acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 			    ("Could not find [%s] in namespace, defaulting to root node\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 			     in_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 			node = acpi_gbl_root_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	return (node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96)  * FUNCTION:    acpi_db_sleep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98)  * PARAMETERS:  object_arg          - Desired sleep state (0-5). NULL means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99)  *                                    invoke all possible sleep states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103)  * DESCRIPTION: Simulate sleep/wake sequences
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) acpi_status acpi_db_sleep(char *object_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	u8 sleep_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	ACPI_FUNCTION_TRACE(acpi_db_sleep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	/* Null input (no arguments) means to invoke all sleep states */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	if (!object_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		acpi_os_printf("Invoking all possible sleep states, 0-%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 			       ACPI_S_STATES_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 		for (i = 0; i <= ACPI_S_STATES_MAX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 			acpi_db_do_one_sleep_state((u8)i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	/* Convert argument to binary and invoke the sleep state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	sleep_state = (u8)strtoul(object_arg, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	acpi_db_do_one_sleep_state(sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136)  * FUNCTION:    acpi_db_do_one_sleep_state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138)  * PARAMETERS:  sleep_state         - Desired sleep state (0-5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142)  * DESCRIPTION: Simulate a sleep/wake sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) static void acpi_db_do_one_sleep_state(u8 sleep_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	u8 sleep_type_a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	u8 sleep_type_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	/* Validate parameter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	if (sleep_state > ACPI_S_STATES_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 		acpi_os_printf("Sleep state %d out of range (%d max)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 			       sleep_state, ACPI_S_STATES_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	acpi_os_printf("\n---- Invoking sleep state S%d (%s):\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 		       sleep_state, acpi_gbl_sleep_state_names[sleep_state]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	/* Get the values for the sleep type registers (for display only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	    acpi_get_sleep_type_data(sleep_state, &sleep_type_a, &sleep_type_b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 		acpi_os_printf("Could not evaluate [%s] method, %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 			       acpi_gbl_sleep_state_names[sleep_state],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 			       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	    ("Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	     sleep_state, sleep_type_a, sleep_type_b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	/* Invoke the various sleep/wake interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	acpi_os_printf("**** Sleep: Prepare to sleep (S%d) ****\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 		       sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	status = acpi_enter_sleep_state_prep(sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 		goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	acpi_os_printf("**** Sleep: Going to sleep (S%d) ****\n", sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	status = acpi_enter_sleep_state(sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	acpi_os_printf("**** Wake: Prepare to return from sleep (S%d) ****\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 		       sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	status = acpi_leave_sleep_state_prep(sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 	acpi_os_printf("**** Wake: Return from sleep (S%d) ****\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 		       sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	status = acpi_leave_sleep_state(sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	ACPI_EXCEPTION((AE_INFO, status, "During invocation of sleep state S%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 			sleep_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216)  * FUNCTION:    acpi_db_display_locks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222)  * DESCRIPTION: Display information about internal mutexes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) void acpi_db_display_locks(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	for (i = 0; i < ACPI_MAX_MUTEX; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		acpi_os_printf("%26s : %s\n", acpi_ut_get_mutex_name(i),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 			       acpi_gbl_mutex_info[i].thread_id ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 			       ACPI_MUTEX_NOT_ACQUIRED ? "Locked" : "Unlocked");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239)  * FUNCTION:    acpi_db_display_table_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241)  * PARAMETERS:  table_arg           - Name of table to be displayed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245)  * DESCRIPTION: Display information about loaded tables. Current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246)  *              implementation displays all loaded tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) void acpi_db_display_table_info(char *table_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	struct acpi_table_desc *table_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	/* Header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	acpi_os_printf("Idx ID  Status Type                    "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 		       "TableHeader (Sig, Address, Length, Misc)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	/* Walk the entire root table list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		table_desc = &acpi_gbl_root_table_list.tables[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 		/* Index and Table ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 		acpi_os_printf("%3u %.2u ", i, table_desc->owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 		/* Decode the table flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 		if (!(table_desc->flags & ACPI_TABLE_IS_LOADED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 			acpi_os_printf("NotLoaded ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 			acpi_os_printf(" Loaded ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 		switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 			acpi_os_printf("External/virtual ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 			acpi_os_printf("Internal/physical ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 			acpi_os_printf("Internal/virtual ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 			acpi_os_printf("INVALID TYPE    ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 		/* Make sure that the table is mapped */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 		status = acpi_tb_validate_table(table_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 		/* Dump the table header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		if (table_desc->pointer) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 			acpi_tb_print_table_header(table_desc->address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 						   table_desc->pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 			/* If the pointer is null, the table has been unloaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 			ACPI_INFO(("%4.4s - Table has been unloaded",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 				   table_desc->signature.ascii));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323)  * FUNCTION:    acpi_db_unload_acpi_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325)  * PARAMETERS:  object_name         - Namespace pathname for an object that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326)  *                                    is owned by the table to be unloaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330)  * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331)  *              by the table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) void acpi_db_unload_acpi_table(char *object_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	/* Translate name to an Named object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	node = acpi_db_convert_to_node(object_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	status = acpi_unload_parent_table(ACPI_CAST_PTR(acpi_handle, node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 		acpi_os_printf("Parent of [%s] (%p) unloaded and uninstalled\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 			       object_name, node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		acpi_os_printf("%s, while unloading parent table of [%s]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 			       acpi_format_exception(status), object_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359)  * FUNCTION:    acpi_db_send_notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361)  * PARAMETERS:  name                - Name of ACPI object where to send notify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362)  *              value               - Value of the notify to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366)  * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367)  *              named object as an ACPI notify.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) void acpi_db_send_notify(char *name, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	/* Translate name to an Named object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	node = acpi_db_convert_to_node(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	/* Dispatch the notify if legal */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	if (acpi_ev_is_notify_object(node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		status = acpi_ev_queue_notify_request(node, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 			acpi_os_printf("Could not queue notify\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 		acpi_os_printf("Named object [%4.4s] Type %s, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 			       "must be Device/Thermal/Processor type\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 			       acpi_ut_get_node_name(node),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 			       acpi_ut_get_type_name(node->type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400)  * FUNCTION:    acpi_db_display_interfaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402)  * PARAMETERS:  action_arg          - Null, "install", or "remove"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403)  *              interface_name_arg  - Name for install/remove options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407)  * DESCRIPTION: Display or modify the global _OSI interface list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) void acpi_db_display_interfaces(char *action_arg, char *interface_name_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	struct acpi_interface_info *next_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	char *sub_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	/* If no arguments, just display current interface list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	if (!action_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		(void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 					    ACPI_WAIT_FOREVER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		next_interface = acpi_gbl_supported_interfaces;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		while (next_interface) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 			if (!(next_interface->flags & ACPI_OSI_INVALID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 				acpi_os_printf("%s\n", next_interface->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 			next_interface = next_interface->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		acpi_os_release_mutex(acpi_gbl_osi_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	/* If action_arg exists, so must interface_name_arg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	if (!interface_name_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 		acpi_os_printf("Missing Interface Name argument\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	/* Uppercase the action for match below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	acpi_ut_strupr(action_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	/* install - install an interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	sub_string = strstr("INSTALL", action_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	if (sub_string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		status = acpi_install_interface(interface_name_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 			acpi_os_printf("%s, while installing \"%s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 				       acpi_format_exception(status),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 				       interface_name_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	/* remove - remove an interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	sub_string = strstr("REMOVE", action_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	if (sub_string) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 		status = acpi_remove_interface(interface_name_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 			acpi_os_printf("%s, while removing \"%s\"\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 				       acpi_format_exception(status),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 				       interface_name_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	/* Invalid action_arg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	acpi_os_printf("Invalid action argument: %s\n", action_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481)  * FUNCTION:    acpi_db_display_template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483)  * PARAMETERS:  buffer_arg          - Buffer name or address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487)  * DESCRIPTION: Dump a buffer that contains a resource template
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) void acpi_db_display_template(char *buffer_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	struct acpi_buffer return_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	/* Translate buffer_arg to an Named object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	node = acpi_db_convert_to_node(buffer_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	if (!node || (node == acpi_gbl_root_node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		acpi_os_printf("Invalid argument: %s\n", buffer_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	/* We must have a buffer object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	if (node->type != ACPI_TYPE_BUFFER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 		    ("Not a Buffer object, cannot be a template: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 		     buffer_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	/* Attempt to convert the raw buffer to a resource list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	status = acpi_rs_create_resource_list(node->object, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	acpi_dbg_level |= ACPI_LV_RESOURCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		    ("Could not convert Buffer to a resource list: %s, %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		     buffer_arg, acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		goto dump_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	/* Now we can dump the resource list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 	acpi_rs_dump_resource_list(ACPI_CAST_PTR(struct acpi_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 						 return_buffer.pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) dump_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	acpi_os_printf("\nRaw data buffer:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	acpi_ut_debug_dump_buffer((u8 *)node->object->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 				  node->object->buffer.length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 				  DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548)  * FUNCTION:    acpi_dm_compare_aml_resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550)  * PARAMETERS:  aml1_buffer         - Contains first resource list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551)  *              aml1_buffer_length  - Length of first resource list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552)  *              aml2_buffer         - Contains second resource list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553)  *              aml2_buffer_length  - Length of second resource list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557)  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558)  *              order to isolate a miscompare to an individual resource)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) acpi_dm_compare_aml_resources(u8 *aml1_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 			      acpi_rsdesc_size aml1_buffer_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 			      u8 *aml2_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 			      acpi_rsdesc_size aml2_buffer_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	u8 *aml1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	u8 *aml2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	u8 *aml1_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	u8 *aml2_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	acpi_rsdesc_size aml1_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	acpi_rsdesc_size aml2_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	acpi_rsdesc_size offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	u8 resource_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	u32 count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	/* Compare overall buffer sizes (may be different due to size rounding) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	if (aml1_buffer_length != aml2_buffer_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		acpi_os_printf("**** Buffer length mismatch in converted "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 			       "AML: Original %X, New %X ****\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 			       aml1_buffer_length, aml2_buffer_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	aml1 = aml1_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	aml2 = aml2_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	aml1_end = aml1_buffer + aml1_buffer_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	aml2_end = aml2_buffer + aml2_buffer_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	/* Walk the descriptor lists, comparing each descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	while ((aml1 < aml1_end) && (aml2 < aml2_end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 		/* Get the lengths of each descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		aml1_length = acpi_ut_get_descriptor_length(aml1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		aml2_length = acpi_ut_get_descriptor_length(aml2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 		resource_type = acpi_ut_get_resource_type(aml1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		/* Check for descriptor length match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		if (aml1_length != aml2_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 			acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			    ("**** Length mismatch in descriptor [%.2X] type %2.2X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 			     "Offset %8.8X Len1 %X, Len2 %X ****\n", count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 			     resource_type, offset, aml1_length, aml2_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		/* Check for descriptor byte match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		else if (memcmp(aml1, aml2, aml1_length)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 			acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 			    ("**** Data mismatch in descriptor [%.2X] type %2.2X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 			     "Offset %8.8X ****\n", count, resource_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 			     offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 			for (i = 0; i < aml1_length; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 				if (aml1[i] != aml2[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 					acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 					    ("Mismatch at byte offset %.2X: is %2.2X, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 					     "should be %2.2X\n", i, aml2[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 					     aml1[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		/* Exit on end_tag descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		if (resource_type == ACPI_RESOURCE_NAME_END_TAG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 		/* Point to next descriptor in each buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 		count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 		offset += aml1_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 		aml1 += aml1_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		aml2 += aml2_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646)  * FUNCTION:    acpi_dm_test_resource_conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648)  * PARAMETERS:  node                - Parent device node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649)  *              name                - resource method name (_CRS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653)  * DESCRIPTION: Compare the original AML with a conversion of the AML to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654)  *              internal resource list, then back to AML.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) acpi_dm_test_resource_conversion(struct acpi_namespace_node *node, char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	struct acpi_buffer return_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	struct acpi_buffer resource_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	struct acpi_buffer new_aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	union acpi_object *original_aml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	acpi_os_printf("Resource Conversion Comparison:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	new_aml.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 	return_buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	resource_buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	/* Get the original _CRS AML resource template */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	status = acpi_evaluate_object(node, name, NULL, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		acpi_os_printf("Could not obtain %s: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 			       name, acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	/* Get the AML resource template, converted to internal resource structs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	status = acpi_get_current_resources(node, &resource_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		acpi_os_printf("AcpiGetCurrentResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 			       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 		goto exit1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	/* Convert internal resource list to external AML resource template */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	status = acpi_rs_create_aml_resources(&resource_buffer, &new_aml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		acpi_os_printf("AcpiRsCreateAmlResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 			       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		goto exit2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	/* Compare original AML to the newly created AML resource list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	original_aml = return_buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	acpi_dm_compare_aml_resources(original_aml->buffer.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 				      (acpi_rsdesc_size)original_aml->buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 				      length, new_aml.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 				      (acpi_rsdesc_size)new_aml.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	/* Cleanup and exit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	ACPI_FREE(new_aml.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) exit2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	ACPI_FREE(resource_buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) exit1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	ACPI_FREE(return_buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721)  * FUNCTION:    acpi_db_resource_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723)  * PARAMETERS:  acpi_walk_resource_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727)  * DESCRIPTION: Simple callback to exercise acpi_walk_resources and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728)  *              acpi_walk_resource_buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) acpi_db_resource_callback(struct acpi_resource *resource, void *context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741)  * FUNCTION:    acpi_db_device_resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743)  * PARAMETERS:  acpi_walk_callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747)  * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) acpi_db_device_resources(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 			 u32 nesting_level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	struct acpi_namespace_node *prt_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	struct acpi_namespace_node *crs_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	struct acpi_namespace_node *prs_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	struct acpi_namespace_node *aei_node = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	char *parent_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	struct acpi_buffer return_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	parent_path = acpi_ns_get_normalized_pathname(node, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	if (!parent_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	/* Get handles to the resource methods for this device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	(void)acpi_get_handle(node, METHOD_NAME__PRT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 			      ACPI_CAST_PTR(acpi_handle, &prt_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	(void)acpi_get_handle(node, METHOD_NAME__CRS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 			      ACPI_CAST_PTR(acpi_handle, &crs_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	(void)acpi_get_handle(node, METHOD_NAME__PRS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 			      ACPI_CAST_PTR(acpi_handle, &prs_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	(void)acpi_get_handle(node, METHOD_NAME__AEI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 			      ACPI_CAST_PTR(acpi_handle, &aei_node));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	if (!prt_node && !crs_node && !prs_node && !aei_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		goto cleanup;	/* Nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	acpi_os_printf("\nDevice: %s\n", parent_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	/* Prepare for a return object of arbitrary size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	/* _PRT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	if (prt_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		acpi_os_printf("Evaluating _PRT\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 		    acpi_evaluate_object(prt_node, NULL, NULL, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 			acpi_os_printf("Could not evaluate _PRT: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 			goto get_crs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		status = acpi_get_irq_routing_table(node, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 			acpi_os_printf("GetIrqRoutingTable failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 			goto get_crs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		acpi_rs_dump_irq_list(ACPI_CAST_PTR(u8, acpi_gbl_db_buffer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	/* _CRS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) get_crs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	if (crs_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 		acpi_os_printf("Evaluating _CRS\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 		    acpi_evaluate_object(crs_node, NULL, NULL, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 			acpi_os_printf("Could not evaluate _CRS: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 			goto get_prs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		/* This code exercises the acpi_walk_resources interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		status = acpi_walk_resources(node, METHOD_NAME__CRS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 					     acpi_db_resource_callback, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 			acpi_os_printf("AcpiWalkResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 			goto get_prs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 		/* Get the _CRS resource list (test ALLOCATE buffer) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		return_buffer.pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 		return_buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		status = acpi_get_current_resources(node, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 			acpi_os_printf("AcpiGetCurrentResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 			goto get_prs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		/* This code exercises the acpi_walk_resource_buffer interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		status = acpi_walk_resource_buffer(&return_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 						   acpi_db_resource_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 						   NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 			acpi_os_printf("AcpiWalkResourceBuffer failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 			goto end_crs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		/* Dump the _CRS resource list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 		acpi_rs_dump_resource_list(ACPI_CAST_PTR(struct acpi_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 							 return_buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 							 pointer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		 * Perform comparison of original AML to newly created AML. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		 * tests both the AML->Resource conversion and the Resource->AML
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		 * conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		(void)acpi_dm_test_resource_conversion(node, METHOD_NAME__CRS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 		/* Execute _SRS with the resource list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		acpi_os_printf("Evaluating _SRS\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		status = acpi_set_current_resources(node, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 			acpi_os_printf("AcpiSetCurrentResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 			goto end_crs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) end_crs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		ACPI_FREE(return_buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	/* _PRS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) get_prs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	if (prs_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 		acpi_os_printf("Evaluating _PRS\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		    acpi_evaluate_object(prs_node, NULL, NULL, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 			acpi_os_printf("Could not evaluate _PRS: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 			goto get_aei;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 		status = acpi_get_possible_resources(node, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 			acpi_os_printf("AcpiGetPossibleResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 			goto get_aei;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		acpi_rs_dump_resource_list(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 					   (struct acpi_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 					    acpi_gbl_db_buffer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	/* _AEI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) get_aei:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	if (aei_node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		acpi_os_printf("Evaluating _AEI\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 		    acpi_evaluate_object(aei_node, NULL, NULL, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 			acpi_os_printf("Could not evaluate _AEI: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		return_buffer.pointer = acpi_gbl_db_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		return_buffer.length = ACPI_DEBUG_BUFFER_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		status = acpi_get_event_resources(node, &return_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 			acpi_os_printf("AcpiGetEventResources failed: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 				       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 		acpi_rs_dump_resource_list(ACPI_CAST_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 					   (struct acpi_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 					    acpi_gbl_db_buffer));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	ACPI_FREE(parent_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967)  * FUNCTION:    acpi_db_display_resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969)  * PARAMETERS:  object_arg          - String object name or object pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970)  *                                    NULL or "*" means "display resources for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971)  *                                    all devices"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975)  * DESCRIPTION: Display the resource objects associated with a device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) void acpi_db_display_resources(char *object_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	acpi_db_set_output_destination(ACPI_DB_REDIRECTABLE_OUTPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	acpi_dbg_level |= ACPI_LV_RESOURCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	/* Asterisk means "display resources for all devices" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	if (!object_arg || (!strcmp(object_arg, "*"))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		(void)acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 					  ACPI_UINT32_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 					  acpi_db_device_resources, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 					  NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 		/* Convert string to object pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 		node = acpi_db_convert_to_node(object_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 		if (node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 			if (node->type != ACPI_TYPE_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 				acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 				    ("%4.4s: Name is not a device object (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 				     node->name.ascii,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 				     acpi_ut_get_type_name(node->type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 				(void)acpi_db_device_resources(node, 0, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 							       NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	acpi_db_set_output_destination(ACPI_DB_CONSOLE_OUTPUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) #if (!ACPI_REDUCED_HARDWARE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016)  * FUNCTION:    acpi_db_generate_gpe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)  * PARAMETERS:  gpe_arg             - Raw GPE number, ascii string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019)  *              block_arg           - GPE block number, ascii string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)  *                                    0 or 1 for FADT GPE blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)  * DESCRIPTION: Simulate firing of a GPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) void acpi_db_generate_gpe(char *gpe_arg, char *block_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	u32 block_number = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	u32 gpe_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	struct acpi_gpe_event_info *gpe_event_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	gpe_number = strtoul(gpe_arg, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	 * If no block arg, or block arg == 0 or 1, use the FADT-defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	 * GPE blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	if (block_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		block_number = strtoul(block_arg, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 		if (block_number == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 			block_number = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	gpe_event_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	    acpi_ev_get_gpe_event_info(ACPI_TO_POINTER(block_number),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 				       gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	if (!gpe_event_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 		acpi_os_printf("Invalid GPE\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	(void)acpi_ev_gpe_dispatch(NULL, gpe_event_info, gpe_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)  * FUNCTION:    acpi_db_generate_sci
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)  * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) void acpi_db_generate_sci(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	acpi_ev_sci_dispatch();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) #endif				/* !ACPI_REDUCED_HARDWARE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079)  * FUNCTION:    acpi_db_trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)  * PARAMETERS:  enable_arg          - ENABLE/AML to enable tracer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)  *                                    DISABLE to disable tracer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)  *              method_arg          - Method to trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)  *              once_arg            - Whether trace once
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)  * DESCRIPTION: Control method tracing facility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) void acpi_db_trace(char *enable_arg, char *method_arg, char *once_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	u32 debug_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	u32 debug_layer = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	u32 flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	acpi_ut_strupr(enable_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	acpi_ut_strupr(once_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	if (method_arg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 		if (acpi_db_trace_method_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 			ACPI_FREE(acpi_db_trace_method_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			acpi_db_trace_method_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 		acpi_db_trace_method_name =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 		    ACPI_ALLOCATE(strlen(method_arg) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 		if (!acpi_db_trace_method_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 			acpi_os_printf("Failed to allocate method name (%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 				       method_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		strcpy(acpi_db_trace_method_name, method_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	if (!strcmp(enable_arg, "ENABLE") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	    !strcmp(enable_arg, "METHOD") || !strcmp(enable_arg, "OPCODE")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 		if (!strcmp(enable_arg, "ENABLE")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 			/* Inherit current console settings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 			debug_level = acpi_gbl_db_console_debug_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 			debug_layer = acpi_dbg_layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 			/* Restrict console output to trace points only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 			debug_level = ACPI_LV_TRACE_POINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 			debug_layer = ACPI_EXECUTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 		flags = ACPI_TRACE_ENABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 		if (!strcmp(enable_arg, "OPCODE")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 			flags |= ACPI_TRACE_OPCODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 		if (once_arg && !strcmp(once_arg, "ONCE")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 			flags |= ACPI_TRACE_ONESHOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	(void)acpi_debug_trace(acpi_db_trace_method_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 			       debug_level, debug_layer, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }