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: dbmethod - Debug commands for control methods
^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 "acdispat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "acnamesp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "acdebug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "acpredef.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("dbmethod")
^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 acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) acpi_db_walk_for_execute(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 			 u32 nesting_level, void *context, void **return_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * FUNCTION:    acpi_db_set_method_breakpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * PARAMETERS:  location            - AML offset of breakpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *              walk_state          - Current walk info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *              op                  - Current Op (from parse walk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * DESCRIPTION: Set a breakpoint in a control method at the specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *              AML offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^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) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) acpi_db_set_method_breakpoint(char *location,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			      struct acpi_walk_state *walk_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			      union acpi_parse_object *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	u32 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u32 aml_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		acpi_os_printf("There is no method currently executing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	/* Get and verify the breakpoint address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	address = strtoul(location, NULL, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	aml_offset = (u32)ACPI_PTR_DIFF(op->common.aml,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 					walk_state->parser_state.aml_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	if (address <= aml_offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		acpi_os_printf("Breakpoint %X is beyond current address %X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			       address, aml_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* Save breakpoint in current walk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	walk_state->user_breakpoint = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	acpi_os_printf("Breakpoint set at AML offset %X\n", address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * FUNCTION:    acpi_db_set_method_call_breakpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * PARAMETERS:  op                  - Current Op (from parse walk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * DESCRIPTION: Set a breakpoint in a control method at the specified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  *              AML offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		acpi_os_printf("There is no method currently executing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		return;
^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) 	acpi_gbl_step_to_next_call = TRUE;
^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_set_method_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * PARAMETERS:  type_arg        - L for local, A for argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  *              index_arg       - which one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  *              value_arg       - Value to set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * DESCRIPTION: Set a local or argument for the running control method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *              NOTE: only object supported is Number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	char type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	u32 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct acpi_walk_state *walk_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	/* Validate type_arg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	acpi_ut_strupr(type_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	type = type_arg[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if ((type != 'L') && (type != 'A') && (type != 'N')) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		acpi_os_printf("Invalid SET operand: %s\n", type_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	value = strtoul(value_arg, NULL, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	if (type == 'N') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		node = acpi_db_convert_to_node(index_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		if (!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			return;
^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) 		if (node->type != ACPI_TYPE_INTEGER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			acpi_os_printf("Can only set Integer nodes\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		obj_desc = node->object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		obj_desc->integer.value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		return;
^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) 	/* Get the index and value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	index = strtoul(index_arg, NULL, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	walk_state = acpi_ds_get_current_walk_state(acpi_gbl_current_walk_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	if (!walk_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		acpi_os_printf("There is no method currently executing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/* Create and initialize the new object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	obj_desc = acpi_ut_create_integer_object((u64)value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (!obj_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		acpi_os_printf("Could not create an internal object\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/* Store the new object into the target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	case 'A':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		/* Set a method argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		if (index > ACPI_METHOD_MAX_ARG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			acpi_os_printf("Arg%u - Invalid argument name\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 				       index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		status = acpi_ds_store_object_to_local(ACPI_REFCLASS_ARG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 						       index, obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 						       walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		obj_desc = walk_state->arguments[index].object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		acpi_os_printf("Arg%u: ", index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		acpi_db_display_internal_object(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	case 'L':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		/* Set a method local */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		if (index > ACPI_METHOD_MAX_LOCAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			acpi_os_printf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			    ("Local%u - Invalid local variable name\n", index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		status = acpi_ds_store_object_to_local(ACPI_REFCLASS_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 						       index, obj_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 						       walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		obj_desc = walk_state->local_variables[index].object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		acpi_os_printf("Local%u: ", index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		acpi_db_display_internal_object(obj_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	acpi_ut_remove_reference(obj_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) #ifdef ACPI_DISASSEMBLER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * FUNCTION:    acpi_db_disassemble_aml
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  * PARAMETERS:  statements          - Number of statements to disassemble
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *              op                  - Current Op (from parse walk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  *              of statements specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  *
^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) void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	u32 num_statements = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		acpi_os_printf("There is no method currently executing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (statements) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		num_statements = strtoul(statements, NULL, 0);
^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) 	acpi_dm_disassemble(NULL, op, num_statements);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * FUNCTION:    acpi_db_disassemble_method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)  * PARAMETERS:  name            - Name of control method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  *              of statements specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) acpi_status acpi_db_disassemble_method(char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	union acpi_parse_object *op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct acpi_walk_state *walk_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	union acpi_operand_object *obj_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	struct acpi_namespace_node *method;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	method = acpi_db_convert_to_node(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	if (!method) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		return (AE_BAD_PARAMETER);
^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) 	if (method->type != ACPI_TYPE_METHOD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		ACPI_ERROR((AE_INFO, "%s (%s): Object must be a control method",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			    name, acpi_ut_get_type_name(method->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		return (AE_BAD_PARAMETER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	obj_desc = method->object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	op = acpi_ps_create_scope_op(obj_desc->method.aml_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	if (!op) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	/* Create and initialize a new walk state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	walk_state = acpi_ds_create_walk_state(0, op, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (!walk_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		return (AE_NO_MEMORY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	status = acpi_ds_init_aml_walk(walk_state, op, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 				       obj_desc->method.aml_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				       obj_desc->method.aml_length, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				       ACPI_IMODE_LOAD_PASS1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	walk_state->owner_id = obj_desc->method.owner_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	/* Push start scope on scope stack and make it current */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	status = acpi_ds_scope_stack_push(method, method->type, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		return (status);
^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) 	/* Parse the entire method AML including deferred operators */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	walk_state->parse_flags &= ~ACPI_PARSE_DELETE_TREE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	walk_state->parse_flags |= ACPI_PARSE_DISASSEMBLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	status = acpi_ps_parse_aml(walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	(void)acpi_dm_parse_deferred_ops(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	/* Now we can disassemble the method */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	acpi_gbl_dm_opt_verbose = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	acpi_dm_disassemble(NULL, op, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	acpi_gbl_dm_opt_verbose = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	acpi_ps_delete_parse_tree(op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	/* Method cleanup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	acpi_ns_delete_namespace_subtree(method);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	acpi_ut_release_owner_id(&obj_desc->method.owner_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  * FUNCTION:    acpi_db_evaluate_object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  * PARAMETERS:  node                - Namespace node for the object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  * DESCRIPTION: Main execution function for the Evaluate/Execute/All debugger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  *              commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static acpi_status acpi_db_evaluate_object(struct acpi_namespace_node *node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	char *pathname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	struct acpi_device_info *obj_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	struct acpi_object_list param_objects;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	union acpi_object params[ACPI_METHOD_NUM_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	struct acpi_buffer return_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	pathname = acpi_ns_get_external_pathname(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if (!pathname) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	/* Get the object info for number of method parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	status = acpi_get_object_info(node, &obj_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		ACPI_FREE(pathname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	param_objects.pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	param_objects.count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (obj_info->type == ACPI_TYPE_METHOD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		/* Setup default parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		for (i = 0; i < obj_info->param_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			params[i].type = ACPI_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			params[i].integer.value = 1;
^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) 		param_objects.pointer = params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		param_objects.count = obj_info->param_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	ACPI_FREE(obj_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	return_obj.pointer = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	return_obj.length = ACPI_ALLOCATE_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	/* Do the actual method execution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	acpi_gbl_method_executing = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	status = acpi_evaluate_object(node, NULL, &param_objects, &return_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	acpi_gbl_method_executing = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	acpi_os_printf("%-32s returned %s\n", pathname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		       acpi_format_exception(status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	if (return_obj.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		acpi_os_printf("Evaluation of %s returned object %p, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			       "external buffer length %X\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			       pathname, return_obj.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			       (u32)return_obj.length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		acpi_db_dump_external_object(return_obj.pointer, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		acpi_os_printf("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	ACPI_FREE(pathname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	/* Ignore status from method execution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	/* Update count, check if we have executed enough methods */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^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)  * FUNCTION:    acpi_db_walk_for_execute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  * PARAMETERS:  Callback from walk_namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)  * DESCRIPTION: Batch execution function. Evaluates all "predefined" objects --
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)  *              the nameseg begins with an underscore.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) acpi_db_walk_for_execute(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			 u32 nesting_level, void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	struct acpi_namespace_node *node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	    (struct acpi_namespace_node *)obj_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	struct acpi_db_execute_walk *info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	    (struct acpi_db_execute_walk *)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	const union acpi_predefined_info *predefined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	predefined = acpi_ut_match_predefined_method(node->name.ascii);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	if (!predefined) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	acpi_db_evaluate_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	/* Ignore status from object evaluation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	/* Update count, check if we have executed enough methods */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	info->count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	if (info->count >= info->max_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 		status = AE_CTRL_TERMINATE;
^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) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  * FUNCTION:    acpi_db_walk_for_execute_all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)  * PARAMETERS:  Callback from walk_namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)  * DESCRIPTION: Batch execution function. Evaluates all objects whose path ends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)  *              with the nameseg "Info->NameSeg". Used for the "ALL" command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) acpi_db_walk_for_execute_all(acpi_handle obj_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			     u32 nesting_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 			     void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	struct acpi_namespace_node *node =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	    (struct acpi_namespace_node *)obj_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	struct acpi_db_execute_walk *info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	    (struct acpi_db_execute_walk *)context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	if (!ACPI_COMPARE_NAMESEG(node->name.ascii, info->name_seg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	if (node->type == ACPI_TYPE_LOCAL_SCOPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		return (AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	/* Now evaluate the input object (node) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	acpi_db_evaluate_object(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	/* Ignore status from method execution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	/* Update count of executed methods/objects */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	info->count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	return (status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^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)  * FUNCTION:    acpi_db_evaluate_predefined_names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)  * DESCRIPTION: Namespace batch execution. Execute predefined names in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  *              namespace, up to the max count, if specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) void acpi_db_evaluate_predefined_names(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	struct acpi_db_execute_walk info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	info.count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	info.max_count = ACPI_UINT32_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	/* Search all nodes in namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 				  ACPI_UINT32_MAX, acpi_db_walk_for_execute,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 				  NULL, (void *)&info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	acpi_os_printf("Evaluated %u predefined names in the namespace\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		       info.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^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)  * FUNCTION:    acpi_db_evaluate_all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)  * PARAMETERS:  none_acpi_gbl_db_method_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)  * DESCRIPTION: Namespace batch execution. Implements the "ALL" command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)  *              Execute all namepaths whose final nameseg matches the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)  *              input nameseg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) void acpi_db_evaluate_all(char *name_seg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	struct acpi_db_execute_walk info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	info.count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	info.max_count = ACPI_UINT32_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	ACPI_COPY_NAMESEG(info.name_seg, name_seg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	info.name_seg[ACPI_NAMESEG_SIZE] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	/* Search all nodes in namespace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	(void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 				  ACPI_UINT32_MAX, acpi_db_walk_for_execute_all,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 				  NULL, (void *)&info, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	acpi_os_printf("Evaluated %u names in the namespace\n", info.count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }