Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: exresop - AML Interpreter operand/object resolution |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "amlcode.h" |
| 47 | #include "acparser.h" |
| 48 | #include "acinterp.h" |
| 49 | #include "acnamesp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("exresop") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_ex_check_object_type(acpi_object_type type_needed, |
| 57 | acpi_object_type this_type, void *object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /******************************************************************************* |
| 60 | * |
| 61 | * FUNCTION: acpi_ex_check_object_type |
| 62 | * |
| 63 | * PARAMETERS: type_needed Object type needed |
| 64 | * this_type Actual object type |
| 65 | * Object Object pointer |
| 66 | * |
| 67 | * RETURN: Status |
| 68 | * |
| 69 | * DESCRIPTION: Check required type against actual type |
| 70 | * |
| 71 | ******************************************************************************/ |
| 72 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 73 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 74 | acpi_ex_check_object_type(acpi_object_type type_needed, |
| 75 | acpi_object_type this_type, void *object) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 77 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | if (type_needed == ACPI_TYPE_ANY) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | /* All types OK, so we don't perform any typechecks */ |
| 82 | |
| 83 | return (AE_OK); |
| 84 | } |
| 85 | |
| 86 | if (type_needed == ACPI_TYPE_LOCAL_REFERENCE) { |
| 87 | /* |
| 88 | * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 89 | * objects and thus allow them to be targets. (As per the ACPI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | * specification, a store to a constant is a noop.) |
| 91 | */ |
| 92 | if ((this_type == ACPI_TYPE_INTEGER) && |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 93 | (((union acpi_operand_object *)object)->common.flags & |
| 94 | AOPOBJ_AML_CONSTANT)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | return (AE_OK); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if (type_needed != this_type) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 100 | ACPI_ERROR((AE_INFO, |
| 101 | "Needed type [%s], found [%s] %p", |
| 102 | acpi_ut_get_type_name(type_needed), |
| 103 | acpi_ut_get_type_name(this_type), object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | return (AE_AML_OPERAND_TYPE); |
| 106 | } |
| 107 | |
| 108 | return (AE_OK); |
| 109 | } |
| 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | /******************************************************************************* |
| 112 | * |
| 113 | * FUNCTION: acpi_ex_resolve_operands |
| 114 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 115 | * PARAMETERS: opcode - Opcode being interpreted |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | * stack_ptr - Pointer to the operand stack to be |
| 117 | * resolved |
| 118 | * walk_state - Current state |
| 119 | * |
| 120 | * RETURN: Status |
| 121 | * |
| 122 | * DESCRIPTION: Convert multiple input operands to the types required by the |
| 123 | * target operator. |
| 124 | * |
| 125 | * Each 5-bit group in arg_types represents one required |
| 126 | * operand and indicates the required Type. The corresponding operand |
| 127 | * will be converted to the required type if possible, otherwise we |
| 128 | * abort with an exception. |
| 129 | * |
| 130 | ******************************************************************************/ |
| 131 | |
| 132 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 133 | acpi_ex_resolve_operands(u16 opcode, |
Lv Zheng | f5c1e1c | 2016-05-05 12:57:53 +0800 | [diff] [blame] | 134 | union acpi_operand_object **stack_ptr, |
| 135 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | union acpi_operand_object *obj_desc; |
| 138 | acpi_status status = AE_OK; |
| 139 | u8 object_type; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 140 | u32 arg_types; |
| 141 | const struct acpi_opcode_info *op_info; |
| 142 | u32 this_arg_type; |
| 143 | acpi_object_type type_needed; |
| 144 | u16 target_op = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 146 | ACPI_FUNCTION_TRACE_U32(ex_resolve_operands, opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 148 | op_info = acpi_ps_get_opcode_info(opcode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | if (op_info->class == AML_CLASS_UNKNOWN) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 150 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | arg_types = op_info->runtime_args; |
| 154 | if (arg_types == ARGI_INVALID_OPCODE) { |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 155 | ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X", opcode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 157 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 160 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 161 | "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 162 | opcode, op_info->name, arg_types)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * Normal exit is with (arg_types == 0) at end of argument list. |
| 166 | * Function will return an exception from within the loop upon |
| 167 | * finding an entry which is not (or cannot be converted |
| 168 | * to) the required type; if stack underflows; or upon |
| 169 | * finding a NULL stack entry (which should not happen). |
| 170 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | while (GET_CURRENT_ARG_TYPE(arg_types)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | if (!stack_ptr || !*stack_ptr) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 173 | ACPI_ERROR((AE_INFO, "Null stack entry at %p", |
| 174 | stack_ptr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 176 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | /* Extract useful items */ |
| 180 | |
| 181 | obj_desc = *stack_ptr; |
| 182 | |
| 183 | /* Decode the descriptor type */ |
| 184 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 185 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | case ACPI_DESC_TYPE_NAMED: |
| 187 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 188 | /* Namespace Node */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 190 | object_type = |
| 191 | ((struct acpi_namespace_node *)obj_desc)->type; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 192 | |
| 193 | /* |
| 194 | * Resolve an alias object. The construction of these objects |
| 195 | * guarantees that there is only one level of alias indirection; |
| 196 | * thus, the attached object is always the aliased namespace node |
| 197 | */ |
| 198 | if (object_type == ACPI_TYPE_LOCAL_ALIAS) { |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 199 | obj_desc = acpi_ns_get_attached_object((struct |
| 200 | acpi_namespace_node |
| 201 | *) |
| 202 | obj_desc); |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 203 | *stack_ptr = obj_desc; |
| 204 | object_type = |
| 205 | ((struct acpi_namespace_node *)obj_desc)-> |
| 206 | type; |
| 207 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | break; |
| 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | case ACPI_DESC_TYPE_OPERAND: |
| 211 | |
| 212 | /* ACPI internal object */ |
| 213 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 214 | object_type = obj_desc->common.type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
| 216 | /* Check for bad acpi_object_type */ |
| 217 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 218 | if (!acpi_ut_valid_object_type(object_type)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 219 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 220 | "Bad operand object type [0x%X]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 221 | object_type)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 227 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 228 | /* Validate the Reference */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 229 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 230 | switch (obj_desc->reference.class) { |
| 231 | case ACPI_REFCLASS_DEBUG: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 233 | target_op = AML_DEBUG_OP; |
| 234 | |
| 235 | /*lint -fallthrough */ |
| 236 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 237 | case ACPI_REFCLASS_ARG: |
| 238 | case ACPI_REFCLASS_LOCAL: |
| 239 | case ACPI_REFCLASS_INDEX: |
| 240 | case ACPI_REFCLASS_REFOF: |
| 241 | case ACPI_REFCLASS_TABLE: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ |
| 242 | case ACPI_REFCLASS_NAME: /* Reference to a named object */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 244 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 245 | "Operand is a Reference, Class [%s] %2.2X\n", |
| 246 | acpi_ut_get_reference_name |
| 247 | (obj_desc), |
| 248 | obj_desc->reference. |
| 249 | class)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | break; |
| 251 | |
| 252 | default: |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 253 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 254 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 255 | "Unknown Reference Class 0x%2.2X in %p", |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 256 | obj_desc->reference.class, |
| 257 | obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 259 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | break; |
| 263 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | default: |
| 265 | |
| 266 | /* Invalid descriptor */ |
| 267 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 268 | ACPI_ERROR((AE_INFO, "Invalid descriptor %p [%s]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 269 | obj_desc, |
| 270 | acpi_ut_get_descriptor_name(obj_desc))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 275 | /* Get one argument type, point to the next */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | this_arg_type = GET_CURRENT_ARG_TYPE(arg_types); |
| 278 | INCREMENT_ARG_LIST(arg_types); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
| 280 | /* |
| 281 | * Handle cases where the object does not need to be |
| 282 | * resolved to a value |
| 283 | */ |
| 284 | switch (this_arg_type) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 285 | case ARGI_REF_OR_STRING: /* Can be a String or Reference */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | if ((ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 288 | ACPI_DESC_TYPE_OPERAND) && |
| 289 | (obj_desc->common.type == ACPI_TYPE_STRING)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 291 | * String found - the string references a named object and |
| 292 | * must be resolved to a node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | */ |
| 294 | goto next_operand; |
| 295 | } |
| 296 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 297 | /* |
| 298 | * Else not a string - fall through to the normal Reference |
| 299 | * case below |
| 300 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | /*lint -fallthrough */ |
| 302 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | case ARGI_REFERENCE: /* References: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | case ARGI_INTEGER_REF: |
| 305 | case ARGI_OBJECT_REF: |
| 306 | case ARGI_DEVICE_REF: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ |
| 308 | case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 309 | case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ |
Bob Moore | a5922a1 | 2015-10-19 10:24:58 +0800 | [diff] [blame] | 310 | case ARGI_STORE_TARGET: |
| 311 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 312 | /* |
| 313 | * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE |
| 314 | * A Namespace Node is OK as-is |
| 315 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) == |
| 317 | ACPI_DESC_TYPE_NAMED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | goto next_operand; |
| 319 | } |
| 320 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 321 | status = |
| 322 | acpi_ex_check_object_type(ACPI_TYPE_LOCAL_REFERENCE, |
| 323 | object_type, obj_desc); |
| 324 | if (ACPI_FAILURE(status)) { |
| 325 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | goto next_operand; |
| 328 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 329 | case ARGI_DATAREFOBJ: /* Store operator only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | /* |
| 331 | * We don't want to resolve index_op reference objects during |
| 332 | * a store because this would be an implicit de_ref_of operation. |
| 333 | * Instead, we just want to store the reference object. |
| 334 | * -- All others must be resolved below. |
| 335 | */ |
| 336 | if ((opcode == AML_STORE_OP) && |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 337 | ((*stack_ptr)->common.type == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | ACPI_TYPE_LOCAL_REFERENCE) |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 339 | && ((*stack_ptr)->reference.class == |
| 340 | ACPI_REFCLASS_INDEX)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | goto next_operand; |
| 342 | } |
| 343 | break; |
| 344 | |
| 345 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | /* All cases covered above */ |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | break; |
| 350 | } |
| 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | /* |
| 353 | * Resolve this object to a value |
| 354 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 355 | status = acpi_ex_resolve_to_value(stack_ptr, walk_state); |
| 356 | if (ACPI_FAILURE(status)) { |
| 357 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | /* Get the resolved object */ |
| 361 | |
| 362 | obj_desc = *stack_ptr; |
| 363 | |
| 364 | /* |
| 365 | * Check the resulting object (value) type |
| 366 | */ |
| 367 | switch (this_arg_type) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | /* |
| 369 | * For the simple cases, only one type of resolved object |
| 370 | * is allowed |
| 371 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | case ARGI_MUTEX: |
| 373 | |
| 374 | /* Need an operand of type ACPI_TYPE_MUTEX */ |
| 375 | |
| 376 | type_needed = ACPI_TYPE_MUTEX; |
| 377 | break; |
| 378 | |
| 379 | case ARGI_EVENT: |
| 380 | |
| 381 | /* Need an operand of type ACPI_TYPE_EVENT */ |
| 382 | |
| 383 | type_needed = ACPI_TYPE_EVENT; |
| 384 | break; |
| 385 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 386 | case ARGI_PACKAGE: /* Package */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | /* Need an operand of type ACPI_TYPE_PACKAGE */ |
| 389 | |
| 390 | type_needed = ACPI_TYPE_PACKAGE; |
| 391 | break; |
| 392 | |
| 393 | case ARGI_ANYTYPE: |
| 394 | |
| 395 | /* Any operand type will do */ |
| 396 | |
| 397 | type_needed = ACPI_TYPE_ANY; |
| 398 | break; |
| 399 | |
| 400 | case ARGI_DDBHANDLE: |
| 401 | |
| 402 | /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ |
| 403 | |
| 404 | type_needed = ACPI_TYPE_LOCAL_REFERENCE; |
| 405 | break; |
| 406 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 407 | /* |
| 408 | * The more complex cases allow multiple resolved object types |
| 409 | */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 410 | case ARGI_INTEGER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
| 412 | /* |
| 413 | * Need an operand of type ACPI_TYPE_INTEGER, |
| 414 | * But we can implicitly convert from a STRING or BUFFER |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 415 | * aka - "Implicit Source Operand Conversion" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 417 | status = |
| 418 | acpi_ex_convert_to_integer(obj_desc, stack_ptr, 16); |
| 419 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | if (status == AE_TYPE) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 421 | ACPI_ERROR((AE_INFO, |
| 422 | "Needed [Integer/String/Buffer], found [%s] %p", |
| 423 | acpi_ut_get_object_type_name |
| 424 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 426 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } |
| 428 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 429 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 431 | |
| 432 | if (obj_desc != *stack_ptr) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | acpi_ut_remove_reference(obj_desc); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 434 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | goto next_operand; |
| 436 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | case ARGI_BUFFER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | /* |
| 439 | * Need an operand of type ACPI_TYPE_BUFFER, |
| 440 | * But we can implicitly convert from a STRING or INTEGER |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 441 | * aka - "Implicit Source Operand Conversion" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 443 | status = acpi_ex_convert_to_buffer(obj_desc, stack_ptr); |
| 444 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | if (status == AE_TYPE) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 446 | ACPI_ERROR((AE_INFO, |
| 447 | "Needed [Integer/String/Buffer], found [%s] %p", |
| 448 | acpi_ut_get_object_type_name |
| 449 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 451 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 454 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 456 | |
| 457 | if (obj_desc != *stack_ptr) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 458 | acpi_ut_remove_reference(obj_desc); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 459 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | goto next_operand; |
| 461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | case ARGI_STRING: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | /* |
| 464 | * Need an operand of type ACPI_TYPE_STRING, |
| 465 | * But we can implicitly convert from a BUFFER or INTEGER |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 466 | * aka - "Implicit Source Operand Conversion" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | */ |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 468 | status = |
| 469 | acpi_ex_convert_to_string(obj_desc, stack_ptr, |
| 470 | ACPI_IMPLICIT_CONVERT_HEX); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 471 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | if (status == AE_TYPE) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 473 | ACPI_ERROR((AE_INFO, |
| 474 | "Needed [Integer/String/Buffer], found [%s] %p", |
| 475 | acpi_ut_get_object_type_name |
| 476 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 478 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 481 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 483 | |
| 484 | if (obj_desc != *stack_ptr) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 485 | acpi_ut_remove_reference(obj_desc); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 486 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | goto next_operand; |
| 488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | case ARGI_COMPUTEDATA: |
| 490 | |
| 491 | /* Need an operand of type INTEGER, STRING or BUFFER */ |
| 492 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 493 | switch (obj_desc->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | case ACPI_TYPE_INTEGER: |
| 495 | case ACPI_TYPE_STRING: |
| 496 | case ACPI_TYPE_BUFFER: |
| 497 | |
| 498 | /* Valid operand */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 499 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
| 501 | default: |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 502 | ACPI_ERROR((AE_INFO, |
| 503 | "Needed [Integer/String/Buffer], found [%s] %p", |
| 504 | acpi_ut_get_object_type_name |
| 505 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 507 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | } |
| 509 | goto next_operand; |
| 510 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | case ARGI_BUFFER_OR_STRING: |
| 512 | |
| 513 | /* Need an operand of type STRING or BUFFER */ |
| 514 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 515 | switch (obj_desc->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | case ACPI_TYPE_STRING: |
| 517 | case ACPI_TYPE_BUFFER: |
| 518 | |
| 519 | /* Valid operand */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 520 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
| 522 | case ACPI_TYPE_INTEGER: |
| 523 | |
| 524 | /* Highest priority conversion is to type Buffer */ |
| 525 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 526 | status = |
| 527 | acpi_ex_convert_to_buffer(obj_desc, |
| 528 | stack_ptr); |
| 529 | if (ACPI_FAILURE(status)) { |
| 530 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | } |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 532 | |
| 533 | if (obj_desc != *stack_ptr) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 534 | acpi_ut_remove_reference(obj_desc); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 535 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | break; |
| 537 | |
| 538 | default: |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 539 | ACPI_ERROR((AE_INFO, |
| 540 | "Needed [Integer/String/Buffer], found [%s] %p", |
| 541 | acpi_ut_get_object_type_name |
| 542 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 544 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | } |
| 546 | goto next_operand; |
| 547 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | case ARGI_DATAOBJECT: |
| 549 | /* |
| 550 | * ARGI_DATAOBJECT is only used by the size_of operator. |
| 551 | * Need a buffer, string, package, or ref_of reference. |
| 552 | * |
| 553 | * The only reference allowed here is a direct reference to |
| 554 | * a namespace node. |
| 555 | */ |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 556 | switch (obj_desc->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | case ACPI_TYPE_PACKAGE: |
| 558 | case ACPI_TYPE_STRING: |
| 559 | case ACPI_TYPE_BUFFER: |
| 560 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 561 | |
| 562 | /* Valid operand */ |
| 563 | break; |
| 564 | |
| 565 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 566 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 567 | ACPI_ERROR((AE_INFO, |
| 568 | "Needed [Buffer/String/Package/Reference], found [%s] %p", |
| 569 | acpi_ut_get_object_type_name |
| 570 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 572 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | } |
| 574 | goto next_operand; |
| 575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | case ARGI_COMPLEXOBJ: |
| 577 | |
| 578 | /* Need a buffer or package or (ACPI 2.0) String */ |
| 579 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 580 | switch (obj_desc->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | case ACPI_TYPE_PACKAGE: |
| 582 | case ACPI_TYPE_STRING: |
| 583 | case ACPI_TYPE_BUFFER: |
| 584 | |
| 585 | /* Valid operand */ |
| 586 | break; |
| 587 | |
| 588 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 589 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 590 | ACPI_ERROR((AE_INFO, |
| 591 | "Needed [Buffer/String/Package], found [%s] %p", |
| 592 | acpi_ut_get_object_type_name |
| 593 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 595 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | } |
| 597 | goto next_operand; |
| 598 | |
Alexey Starikovskiy | a6823e1 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 599 | case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 601 | /* |
| 602 | * Need an operand of type REGION or a BUFFER |
| 603 | * (which could be a resolved region field) |
| 604 | */ |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 605 | switch (obj_desc->common.type) { |
Alexey Starikovskiy | a6823e1 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 606 | case ACPI_TYPE_BUFFER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | case ACPI_TYPE_REGION: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
| 609 | /* Valid operand */ |
| 610 | break; |
| 611 | |
| 612 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 613 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 614 | ACPI_ERROR((AE_INFO, |
Alexey Starikovskiy | a6823e1 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 615 | "Needed [Region/Buffer], found [%s] %p", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 616 | acpi_ut_get_object_type_name |
| 617 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 619 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | } |
| 621 | goto next_operand; |
| 622 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | case ARGI_DATAREFOBJ: |
| 624 | |
| 625 | /* Used by the Store() operator only */ |
| 626 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 627 | switch (obj_desc->common.type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | case ACPI_TYPE_INTEGER: |
| 629 | case ACPI_TYPE_PACKAGE: |
| 630 | case ACPI_TYPE_STRING: |
| 631 | case ACPI_TYPE_BUFFER: |
| 632 | case ACPI_TYPE_BUFFER_FIELD: |
| 633 | case ACPI_TYPE_LOCAL_REFERENCE: |
| 634 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
| 635 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
| 636 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
| 637 | case ACPI_TYPE_DDB_HANDLE: |
| 638 | |
| 639 | /* Valid operand */ |
| 640 | break; |
| 641 | |
| 642 | default: |
| 643 | |
| 644 | if (acpi_gbl_enable_interpreter_slack) { |
| 645 | /* |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 646 | * Enable original behavior of Store(), allowing any |
| 647 | * and all objects as the source operand. The ACPI |
| 648 | * spec does not allow this, however. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | */ |
| 650 | break; |
| 651 | } |
| 652 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 653 | if (target_op == AML_DEBUG_OP) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 654 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 655 | /* Allow store of any object to the Debug object */ |
| 656 | |
| 657 | break; |
| 658 | } |
| 659 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 660 | ACPI_ERROR((AE_INFO, |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 661 | "Needed Integer/Buffer/String/Package/Ref/Ddb]" |
| 662 | ", found [%s] %p", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 663 | acpi_ut_get_object_type_name |
| 664 | (obj_desc), obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 666 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | } |
| 668 | goto next_operand; |
| 669 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | default: |
| 671 | |
| 672 | /* Unknown type */ |
| 673 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 674 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 675 | "Internal - Unknown ARGI (required operand) type 0x%X", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 676 | this_arg_type)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 678 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /* |
| 682 | * Make sure that the original object was resolved to the |
| 683 | * required object type (Simple cases only). |
| 684 | */ |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 685 | status = |
| 686 | acpi_ex_check_object_type(type_needed, |
| 687 | (*stack_ptr)->common.type, |
| 688 | *stack_ptr); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | if (ACPI_FAILURE(status)) { |
| 690 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | } |
| 692 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 693 | next_operand: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | /* |
| 695 | * If more operands needed, decrement stack_ptr to point |
| 696 | * to next operand on stack |
| 697 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 698 | if (GET_CURRENT_ARG_TYPE(arg_types)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | stack_ptr--; |
| 700 | } |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 701 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | |
Bob Moore | 71d993e | 2008-06-10 14:25:05 +0800 | [diff] [blame] | 703 | ACPI_DUMP_OPERANDS(walk_state->operands, |
| 704 | acpi_ps_get_opcode_name(opcode), |
| 705 | walk_state->num_operands); |
| 706 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 707 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | } |