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