^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: exoparg2 - AML execution - opcodes with 2 arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "acparser.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "acinterp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "acevents.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "amlcode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _COMPONENT ACPI_EXECUTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ACPI_MODULE_NAME("exoparg2")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Naming convention for AML interpreter execution routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * The routines that begin execution of AML opcodes are named with a common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * convention based upon the number of arguments, the number of target operands,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * and whether or not a value is returned:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * AcpiExOpcode_xA_yT_zR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Where:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * xA - ARGUMENTS: The number of arguments (input operands) that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * required for this opcode type (1 through 6 args).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * yT - TARGETS: The number of targets (output operands) that are required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * for this opcode type (0, 1, or 2 targets).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * zR - RETURN VALUE: Indicates whether this opcode type returns a value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * as the function return (0 or 1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * The AcpiExOpcode* functions are called via the Dispatcher component with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * fully resolved operands.
^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) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * FUNCTION: acpi_ex_opcode_2A_0T_0R
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * PARAMETERS: walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * DESCRIPTION: Execute opcode with two arguments, no target, and no return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * ALLOCATION: Deletes both operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct acpi_namespace_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_0T_0R,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) acpi_ps_get_opcode_name(walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* Examine the opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) case AML_NOTIFY_OP: /* Notify (notify_object, notify_value) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* The first operand is a namespace node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) node = (struct acpi_namespace_node *)operand[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Second value is the notify value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) value = (u32) operand[1]->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* Are notifies allowed on this object? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (!acpi_ev_is_notify_object(node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) "Unexpected notify object type [%s]",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) acpi_ut_get_type_name(node->type)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) status = AE_AML_OPERAND_TYPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^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) * Dispatch the notify to the appropriate handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * NOTE: the request is queued for execution after this method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * completes. The notify handlers are NOT invoked synchronously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * from this thread -- because handlers may in turn run other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * control methods.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) status = acpi_ev_queue_notify_request(node, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) status = AE_AML_BAD_OPCODE;
^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) return_ACPI_STATUS(status);
^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) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * FUNCTION: acpi_ex_opcode_2A_2T_1R
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * PARAMETERS: walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * and one implicit return value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) union acpi_operand_object *return_desc1 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) union acpi_operand_object *return_desc2 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_2T_1R,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) acpi_ps_get_opcode_name(walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /* Execute the opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) case AML_DIVIDE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Divide (Dividend, Divisor, remainder_result quotient_result) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return_desc1 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (!return_desc1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) goto cleanup;
^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) return_desc2 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) if (!return_desc2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Quotient to return_desc1, remainder to return_desc2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) status = acpi_ut_divide(operand[0]->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) operand[1]->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) &return_desc1->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) &return_desc2->integer.value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) status = AE_AML_BAD_OPCODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* Store the results to the target reference operands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) status = acpi_ex_store(return_desc2, operand[2], walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) status = acpi_ex_store(return_desc1, operand[3], walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * Since the remainder is not returned indirectly, remove a reference to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * it. Only the quotient is returned indirectly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) acpi_ut_remove_reference(return_desc2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* Delete the return object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) acpi_ut_remove_reference(return_desc1);
^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) /* Save return object (the remainder) on success */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) walk_state->result_obj = return_desc1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * FUNCTION: acpi_ex_opcode_2A_1T_1R
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * PARAMETERS: walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * DESCRIPTION: Execute opcode with two arguments, one target, and a return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) *
^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) acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) union acpi_operand_object *return_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) u64 index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) acpi_size length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) acpi_ps_get_opcode_name(walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* Execute the opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (walk_state->op_info->flags & AML_MATH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* All simple math opcodes (add, etc.) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) return_desc->integer.value =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) acpi_ex_do_math_op(walk_state->opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) operand[0]->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) operand[1]->integer.value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) goto store_result_to_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /* return_desc will contain the remainder */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) status = acpi_ut_divide(operand[0]->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) operand[1]->integer.value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) NULL, &return_desc->integer.value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) case AML_CONCATENATE_OP: /* Concatenate (Data1, Data2, Result) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) acpi_ex_do_concatenate(operand[0], operand[1], &return_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * Input object is guaranteed to be a buffer at this point (it may have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * been converted.) Copy the raw buffer data to a new object of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * type String.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * Get the length of the new string. It is the smallest of:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * 1) Length of the input buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * 2) Max length as specified in the to_string operator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * 3) Length of input buffer up to a zero byte (null terminator)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * NOTE: A length of zero is ok, and will create a zero-length, null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * terminated string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) while ((length < operand[0]->buffer.length) && /* Length of input buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) (length < operand[1]->integer.value) && /* Length operand */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) (operand[0]->buffer.pointer[length])) { /* Null terminator */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) length++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) /* Allocate a new string object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) return_desc = acpi_ut_create_string_object(length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * Copy the raw buffer data with no transform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * (NULL terminated already)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) memcpy(return_desc->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) operand[0]->buffer.pointer, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) case AML_CONCATENATE_TEMPLATE_OP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) acpi_ex_concat_template(operand[0], operand[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) &return_desc, walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) case AML_INDEX_OP: /* Index (Source Index Result) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /* Create the internal return object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) return_desc =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_REFERENCE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* Initialize the Index reference object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) index = operand[1]->integer.value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return_desc->reference.value = (u32) index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return_desc->reference.class = ACPI_REFCLASS_INDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * At this point, the Source operand is a String, Buffer, or Package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * Verify that the index is within range.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) switch ((operand[0])->common.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) case ACPI_TYPE_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) if (index >= operand[0]->string.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) length = operand[0]->string.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) status = AE_AML_STRING_LIMIT;
^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) return_desc->reference.target_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) ACPI_TYPE_BUFFER_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return_desc->reference.index_pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) &(operand[0]->buffer.pointer[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) case ACPI_TYPE_BUFFER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (index >= operand[0]->buffer.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) length = operand[0]->buffer.length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) status = AE_AML_BUFFER_LIMIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return_desc->reference.target_type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) ACPI_TYPE_BUFFER_FIELD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return_desc->reference.index_pointer =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) &(operand[0]->buffer.pointer[index]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) case ACPI_TYPE_PACKAGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (index >= operand[0]->package.count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) length = operand[0]->package.count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) status = AE_AML_PACKAGE_LIMIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return_desc->reference.where =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) &operand[0]->package.elements[index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) "Invalid object type: %X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) (operand[0])->common.type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) status = AE_AML_INTERNAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) /* Failure means that the Index was beyond the end of the object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ACPI_BIOS_EXCEPTION((AE_INFO, status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) ACPI_FORMAT_UINT64(index),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) (u32)length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) goto cleanup;
^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * Save the target object and add a reference to it for the life
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * of the index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) return_desc->reference.object = operand[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) acpi_ut_add_reference(operand[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /* Store the reference to the Target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) status = acpi_ex_store(return_desc, operand[2], walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /* Return the reference */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) walk_state->result_obj = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) status = AE_AML_BAD_OPCODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) break;
^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) store_result_to_target:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) * Store the result of the operation (which is now in return_desc) into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * the Target descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) status = acpi_ex_store(return_desc, operand[2], walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) goto cleanup;
^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 (!walk_state->result_obj) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) walk_state->result_obj = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /* Delete return object on error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) acpi_ut_remove_reference(return_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) walk_state->result_obj = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * FUNCTION: acpi_ex_opcode_2A_0T_1R
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * PARAMETERS: walk_state - Current walk state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * RETURN: Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) union acpi_operand_object **operand = &walk_state->operands[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) union acpi_operand_object *return_desc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) u8 logical_result = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_0T_1R,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) acpi_ps_get_opcode_name(walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) /* Create the internal return object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) if (!return_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) status = AE_NO_MEMORY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) goto cleanup;
^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) /* Execute the Opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) /* logical_op (Operand0, Operand1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) status = acpi_ex_do_logical_numeric_op(walk_state->opcode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) operand[0]->integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) operand[1]->integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) value, &logical_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) goto store_logical_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) } else if (walk_state->op_info->flags & AML_LOGICAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) /* logical_op (Operand0, Operand1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) status = acpi_ex_do_logical_op(walk_state->opcode, operand[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) operand[1], &logical_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) goto store_logical_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) switch (walk_state->opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) acpi_ex_acquire_mutex(operand[1], operand[0], walk_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (status == AE_TIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) logical_result = TRUE; /* TRUE = Acquire timed out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) case AML_WAIT_OP: /* Wait (event_object, Timeout) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) status = acpi_ex_system_wait_event(operand[1], operand[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if (status == AE_TIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) logical_result = TRUE; /* TRUE, Wait timed out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) walk_state->opcode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) status = AE_AML_BAD_OPCODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) goto cleanup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) store_logical_result:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * Set return value to according to logical_result. logical TRUE (all ones)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * Default is FALSE (zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) if (logical_result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) return_desc->integer.value = ACPI_UINT64_MAX;
^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) cleanup:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /* Delete return object on error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) acpi_ut_remove_reference(return_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) /* Save return object on success */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) walk_state->result_obj = return_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }