| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
|  | 2 | * | 
|  | 3 | * Module Name: dsobject - Dispatcher object management routines | 
|  | 4 | * | 
|  | 5 | *****************************************************************************/ | 
|  | 6 |  | 
|  | 7 | /* | 
| Bob Moore | 6c9deb7 | 2007-02-02 19:48:24 +0300 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2007, R. Byron Moore | 
| 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> | 
|  | 45 | #include <acpi/acparser.h> | 
|  | 46 | #include <acpi/amlcode.h> | 
|  | 47 | #include <acpi/acdispat.h> | 
|  | 48 | #include <acpi/acnamesp.h> | 
|  | 49 | #include <acpi/acinterp.h> | 
|  | 50 |  | 
|  | 51 | #define _COMPONENT          ACPI_DISPATCHER | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("dsobject") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [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_ds_build_internal_object(struct acpi_walk_state *walk_state, | 
|  | 57 | union acpi_parse_object *op, | 
|  | 58 | union acpi_operand_object **obj_desc_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 |  | 
|  | 60 | #ifndef ACPI_NO_METHOD_EXECUTION | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 61 | /******************************************************************************* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | * | 
|  | 63 | * FUNCTION:    acpi_ds_build_internal_object | 
|  | 64 | * | 
|  | 65 | * PARAMETERS:  walk_state      - Current walk state | 
|  | 66 | *              Op              - Parser object to be translated | 
|  | 67 | *              obj_desc_ptr    - Where the ACPI internal object is returned | 
|  | 68 | * | 
|  | 69 | * RETURN:      Status | 
|  | 70 | * | 
|  | 71 | * DESCRIPTION: Translate a parser Op object to the equivalent namespace object | 
|  | 72 | *              Simple objects are any objects other than a package object! | 
|  | 73 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 74 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 76 | static acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 77 | acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, | 
|  | 78 | union acpi_parse_object *op, | 
|  | 79 | union acpi_operand_object **obj_desc_ptr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 81 | union acpi_operand_object *obj_desc; | 
|  | 82 | acpi_status status; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 84 | ACPI_FUNCTION_TRACE(ds_build_internal_object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 |  | 
|  | 86 | *obj_desc_ptr = NULL; | 
|  | 87 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | 
|  | 88 | /* | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 89 | * This is a named object reference. If this name was | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | * previously looked up in the namespace, it was stored in this op. | 
|  | 91 | * Otherwise, go ahead and look it up now | 
|  | 92 | */ | 
|  | 93 | if (!op->common.node) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 94 | status = acpi_ns_lookup(walk_state->scope_info, | 
|  | 95 | op->common.value.string, | 
|  | 96 | ACPI_TYPE_ANY, | 
|  | 97 | ACPI_IMODE_EXECUTE, | 
|  | 98 | ACPI_NS_SEARCH_PARENT | | 
|  | 99 | ACPI_NS_DONT_OPEN_SCOPE, NULL, | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 100 | ACPI_CAST_INDIRECT_PTR(struct | 
|  | 101 | acpi_namespace_node, | 
|  | 102 | &(op-> | 
|  | 103 | common. | 
|  | 104 | node))); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 105 | if (ACPI_FAILURE(status)) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 106 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 107 | /* Check if we are resolving a named reference within a package */ | 
|  | 108 |  | 
|  | 109 | if ((status == AE_NOT_FOUND) | 
|  | 110 | && (acpi_gbl_enable_interpreter_slack) | 
|  | 111 | && | 
|  | 112 | ((op->common.parent->common.aml_opcode == | 
|  | 113 | AML_PACKAGE_OP) | 
|  | 114 | || (op->common.parent->common.aml_opcode == | 
|  | 115 | AML_VAR_PACKAGE_OP))) { | 
|  | 116 | /* | 
|  | 117 | * We didn't find the target and we are populating elements | 
|  | 118 | * of a package - ignore if slack enabled. Some ASL code | 
|  | 119 | * contains dangling invalid references in packages and | 
|  | 120 | * expects that no exception will be issued. Leave the | 
|  | 121 | * element as a null element. It cannot be used, but it | 
|  | 122 | * can be overwritten by subsequent ASL code - this is | 
|  | 123 | * typically the case. | 
|  | 124 | */ | 
|  | 125 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
|  | 126 | "Ignoring unresolved reference in package [%4.4s]\n", | 
|  | 127 | walk_state-> | 
|  | 128 | scope_info->scope. | 
|  | 129 | node->name.ascii)); | 
|  | 130 |  | 
|  | 131 | return_ACPI_STATUS(AE_OK); | 
|  | 132 | } else { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 133 | ACPI_ERROR_NAMESPACE(op->common.value. | 
|  | 134 | string, status); | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 135 | } | 
|  | 136 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 137 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } | 
|  | 139 | } | 
| Bob Moore | 152c300 | 2007-10-17 16:10:18 -0400 | [diff] [blame^] | 140 |  | 
|  | 141 | /* Special object resolution for elements of a package */ | 
|  | 142 |  | 
|  | 143 | if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) || | 
|  | 144 | (op->common.parent->common.aml_opcode == | 
|  | 145 | AML_VAR_PACKAGE_OP)) { | 
|  | 146 | /* | 
|  | 147 | * Attempt to resolve the node to a value before we insert it into | 
|  | 148 | * the package. If this is a reference to a common data type, | 
|  | 149 | * resolve it immediately. According to the ACPI spec, package | 
|  | 150 | * elements can only be "data objects" or method references. | 
|  | 151 | * Attempt to resolve to an Integer, Buffer, String or Package. | 
|  | 152 | * If cannot, return the named reference (for things like Devices, | 
|  | 153 | * Methods, etc.) Buffer Fields and Fields will resolve to simple | 
|  | 154 | * objects (int/buf/str/pkg). | 
|  | 155 | * | 
|  | 156 | * NOTE: References to things like Devices, Methods, Mutexes, etc. | 
|  | 157 | * will remain as named references. This behavior is not described | 
|  | 158 | * in the ACPI spec, but it appears to be an oversight. | 
|  | 159 | */ | 
|  | 160 | obj_desc = (union acpi_operand_object *)op->common.node; | 
|  | 161 |  | 
|  | 162 | status = | 
|  | 163 | acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR | 
|  | 164 | (struct | 
|  | 165 | acpi_namespace_node, | 
|  | 166 | &obj_desc), | 
|  | 167 | walk_state); | 
|  | 168 | if (ACPI_FAILURE(status)) { | 
|  | 169 | return_ACPI_STATUS(status); | 
|  | 170 | } | 
|  | 171 |  | 
|  | 172 | switch (op->common.node->type) { | 
|  | 173 | /* | 
|  | 174 | * For these types, we need the actual node, not the subobject. | 
|  | 175 | * However, the subobject got an extra reference count above. | 
|  | 176 | */ | 
|  | 177 | case ACPI_TYPE_MUTEX: | 
|  | 178 | case ACPI_TYPE_METHOD: | 
|  | 179 | case ACPI_TYPE_POWER: | 
|  | 180 | case ACPI_TYPE_PROCESSOR: | 
|  | 181 | case ACPI_TYPE_EVENT: | 
|  | 182 | case ACPI_TYPE_REGION: | 
|  | 183 | case ACPI_TYPE_DEVICE: | 
|  | 184 | case ACPI_TYPE_THERMAL: | 
|  | 185 |  | 
|  | 186 | obj_desc = | 
|  | 187 | (union acpi_operand_object *)op->common. | 
|  | 188 | node; | 
|  | 189 | break; | 
|  | 190 |  | 
|  | 191 | default: | 
|  | 192 | break; | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 | /* | 
|  | 196 | * If above resolved to an operand object, we are done. Otherwise, | 
|  | 197 | * we have a NS node, we must create the package entry as a named | 
|  | 198 | * reference. | 
|  | 199 | */ | 
|  | 200 | if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != | 
|  | 201 | ACPI_DESC_TYPE_NAMED) { | 
|  | 202 | goto exit; | 
|  | 203 | } | 
|  | 204 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | } | 
|  | 206 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 207 | /* Create and init a new internal ACPI object */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 209 | obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info | 
|  | 210 | (op->common.aml_opcode))-> | 
|  | 211 | object_type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | if (!obj_desc) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } | 
|  | 215 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 216 | status = | 
|  | 217 | acpi_ds_init_object_from_op(walk_state, op, op->common.aml_opcode, | 
|  | 218 | &obj_desc); | 
|  | 219 | if (ACPI_FAILURE(status)) { | 
|  | 220 | acpi_ut_remove_reference(obj_desc); | 
|  | 221 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | } | 
|  | 223 |  | 
| Bob Moore | 152c300 | 2007-10-17 16:10:18 -0400 | [diff] [blame^] | 224 | exit: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | *obj_desc_ptr = obj_desc; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } | 
|  | 228 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 229 | /******************************************************************************* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | * | 
|  | 231 | * FUNCTION:    acpi_ds_build_internal_buffer_obj | 
|  | 232 | * | 
|  | 233 | * PARAMETERS:  walk_state      - Current walk state | 
|  | 234 | *              Op              - Parser object to be translated | 
|  | 235 | *              buffer_length   - Length of the buffer | 
|  | 236 | *              obj_desc_ptr    - Where the ACPI internal object is returned | 
|  | 237 | * | 
|  | 238 | * RETURN:      Status | 
|  | 239 | * | 
|  | 240 | * DESCRIPTION: Translate a parser Op package object to the equivalent | 
|  | 241 | *              namespace object | 
|  | 242 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 243 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 |  | 
|  | 245 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 246 | acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, | 
|  | 247 | union acpi_parse_object *op, | 
|  | 248 | u32 buffer_length, | 
|  | 249 | union acpi_operand_object **obj_desc_ptr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | union acpi_parse_object *arg; | 
|  | 252 | union acpi_operand_object *obj_desc; | 
|  | 253 | union acpi_parse_object *byte_list; | 
|  | 254 | u32 byte_list_length = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 256 | ACPI_FUNCTION_TRACE(ds_build_internal_buffer_obj); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 258 | /* | 
|  | 259 | * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". | 
|  | 260 | * The buffer object already exists (from the NS node), otherwise it must | 
|  | 261 | * be created. | 
|  | 262 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | obj_desc = *obj_desc_ptr; | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 264 | if (!obj_desc) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 265 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | /* Create a new buffer object */ | 
|  | 267 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | *obj_desc_ptr = obj_desc; | 
|  | 270 | if (!obj_desc) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 271 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } | 
|  | 273 | } | 
|  | 274 |  | 
|  | 275 | /* | 
|  | 276 | * Second arg is the buffer data (optional) byte_list can be either | 
|  | 277 | * individual bytes or a string initializer.  In either case, a | 
|  | 278 | * byte_list appears in the AML. | 
|  | 279 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 280 | arg = op->common.value.arg;	/* skip first arg */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 |  | 
|  | 282 | byte_list = arg->named.next; | 
|  | 283 | if (byte_list) { | 
|  | 284 | if (byte_list->common.aml_opcode != AML_INT_BYTELIST_OP) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 285 | ACPI_ERROR((AE_INFO, | 
|  | 286 | "Expecting bytelist, got AML opcode %X in op %p", | 
|  | 287 | byte_list->common.aml_opcode, byte_list)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 289 | acpi_ut_remove_reference(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | return (AE_TYPE); | 
|  | 291 | } | 
|  | 292 |  | 
|  | 293 | byte_list_length = (u32) byte_list->common.value.integer; | 
|  | 294 | } | 
|  | 295 |  | 
|  | 296 | /* | 
|  | 297 | * The buffer length (number of bytes) will be the larger of: | 
|  | 298 | * 1) The specified buffer length and | 
|  | 299 | * 2) The length of the initializer byte list | 
|  | 300 | */ | 
|  | 301 | obj_desc->buffer.length = buffer_length; | 
|  | 302 | if (byte_list_length > buffer_length) { | 
|  | 303 | obj_desc->buffer.length = byte_list_length; | 
|  | 304 | } | 
|  | 305 |  | 
|  | 306 | /* Allocate the buffer */ | 
|  | 307 |  | 
|  | 308 | if (obj_desc->buffer.length == 0) { | 
|  | 309 | obj_desc->buffer.pointer = NULL; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 
|  | 311 | "Buffer defined with zero length in AML, creating\n")); | 
|  | 312 | } else { | 
|  | 313 | obj_desc->buffer.pointer = | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 314 | ACPI_ALLOCATE_ZEROED(obj_desc->buffer.length); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | if (!obj_desc->buffer.pointer) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | acpi_ut_delete_object_desc(obj_desc); | 
|  | 317 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | } | 
|  | 319 |  | 
|  | 320 | /* Initialize buffer from the byte_list (if present) */ | 
|  | 321 |  | 
|  | 322 | if (byte_list) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 323 | ACPI_MEMCPY(obj_desc->buffer.pointer, | 
|  | 324 | byte_list->named.data, byte_list_length); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } | 
|  | 326 | } | 
|  | 327 |  | 
|  | 328 | obj_desc->buffer.flags |= AOPOBJ_DATA_VALID; | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 329 | op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 330 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | } | 
|  | 332 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 333 | /******************************************************************************* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | * | 
|  | 335 | * FUNCTION:    acpi_ds_build_internal_package_obj | 
|  | 336 | * | 
|  | 337 | * PARAMETERS:  walk_state      - Current walk state | 
|  | 338 | *              Op              - Parser object to be translated | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 339 | *              element_count   - Number of elements in the package - this is | 
|  | 340 | *                                the num_elements argument to Package() | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | *              obj_desc_ptr    - Where the ACPI internal object is returned | 
|  | 342 | * | 
|  | 343 | * RETURN:      Status | 
|  | 344 | * | 
|  | 345 | * DESCRIPTION: Translate a parser Op package object to the equivalent | 
|  | 346 | *              namespace object | 
|  | 347 | * | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 348 | * NOTE: The number of elements in the package will be always be the num_elements | 
|  | 349 | * count, regardless of the number of elements in the package list. If | 
|  | 350 | * num_elements is smaller, only that many package list elements are used. | 
|  | 351 | * if num_elements is larger, the Package object is padded out with | 
|  | 352 | * objects of type Uninitialized (as per ACPI spec.) | 
|  | 353 | * | 
|  | 354 | * Even though the ASL compilers do not allow num_elements to be smaller | 
|  | 355 | * than the Package list length (for the fixed length package opcode), some | 
|  | 356 | * BIOS code modifies the AML on the fly to adjust the num_elements, and | 
|  | 357 | * this code compensates for that. This also provides compatibility with | 
|  | 358 | * other AML interpreters. | 
|  | 359 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 360 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 |  | 
|  | 362 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, | 
|  | 364 | union acpi_parse_object *op, | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 365 | u32 element_count, | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 366 | union acpi_operand_object **obj_desc_ptr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | union acpi_parse_object *arg; | 
|  | 369 | union acpi_parse_object *parent; | 
|  | 370 | union acpi_operand_object *obj_desc = NULL; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | acpi_status status = AE_OK; | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 372 | acpi_native_uint i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 374 | ACPI_FUNCTION_TRACE(ds_build_internal_package_obj); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 |  | 
|  | 376 | /* Find the parent of a possibly nested package */ | 
|  | 377 |  | 
|  | 378 | parent = op->common.parent; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 379 | while ((parent->common.aml_opcode == AML_PACKAGE_OP) || | 
|  | 380 | (parent->common.aml_opcode == AML_VAR_PACKAGE_OP)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | parent = parent->common.parent; | 
|  | 382 | } | 
|  | 383 |  | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 384 | /* | 
|  | 385 | * If we are evaluating a Named package object "Name (xxxx, Package)", | 
|  | 386 | * the package object already exists, otherwise it must be created. | 
|  | 387 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | obj_desc = *obj_desc_ptr; | 
| Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 389 | if (!obj_desc) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | *obj_desc_ptr = obj_desc; | 
|  | 392 | if (!obj_desc) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | } | 
|  | 395 |  | 
|  | 396 | obj_desc->package.node = parent->common.node; | 
|  | 397 | } | 
|  | 398 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | /* | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 400 | * Allocate the element array (array of pointers to the individual | 
|  | 401 | * objects) based on the num_elements parameter. Add an extra pointer slot | 
|  | 402 | * so that the list is always null terminated. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | */ | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 404 | obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size) | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 405 | element_count + | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 406 | 1) * sizeof(void *)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 |  | 
|  | 408 | if (!obj_desc->package.elements) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | acpi_ut_delete_object_desc(obj_desc); | 
|  | 410 | return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | } | 
|  | 412 |  | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 413 | obj_desc->package.count = element_count; | 
|  | 414 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | /* | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 416 | * Initialize the elements of the package, up to the num_elements count. | 
|  | 417 | * Package is automatically padded with uninitialized (NULL) elements | 
|  | 418 | * if num_elements is greater than the package list length. Likewise, | 
|  | 419 | * Package is truncated if num_elements is less than the list length. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | arg = op->common.value.arg; | 
|  | 422 | arg = arg->common.next; | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 423 | for (i = 0; arg && (i < element_count); i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) { | 
| Bob Moore | 152c300 | 2007-10-17 16:10:18 -0400 | [diff] [blame^] | 425 | if (arg->common.node->type == ACPI_TYPE_METHOD) { | 
|  | 426 | /* | 
|  | 427 | * A method reference "looks" to the parser to be a method | 
|  | 428 | * invocation, so we special case it here | 
|  | 429 | */ | 
|  | 430 | arg->common.aml_opcode = AML_INT_NAMEPATH_OP; | 
|  | 431 | status = | 
|  | 432 | acpi_ds_build_internal_object(walk_state, | 
|  | 433 | arg, | 
|  | 434 | &obj_desc-> | 
|  | 435 | package. | 
|  | 436 | elements[i]); | 
|  | 437 | } else { | 
|  | 438 | /* This package element is already built, just get it */ | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 439 |  | 
| Bob Moore | 152c300 | 2007-10-17 16:10:18 -0400 | [diff] [blame^] | 440 | obj_desc->package.elements[i] = | 
|  | 441 | ACPI_CAST_PTR(union acpi_operand_object, | 
|  | 442 | arg->common.node); | 
|  | 443 | } | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 444 | } else { | 
|  | 445 | status = acpi_ds_build_internal_object(walk_state, arg, | 
|  | 446 | &obj_desc-> | 
|  | 447 | package. | 
|  | 448 | elements[i]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | arg = arg->common.next; | 
|  | 451 | } | 
|  | 452 |  | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 453 | if (!arg) { | 
|  | 454 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
|  | 455 | "Package List length larger than NumElements count (%X), truncated\n", | 
|  | 456 | element_count)); | 
|  | 457 | } | 
|  | 458 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | obj_desc->package.flags |= AOPOBJ_DATA_VALID; | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 460 | op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 461 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | } | 
|  | 463 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 464 | /******************************************************************************* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | * | 
|  | 466 | * FUNCTION:    acpi_ds_create_node | 
|  | 467 | * | 
|  | 468 | * PARAMETERS:  walk_state      - Current walk state | 
|  | 469 | *              Node            - NS Node to be initialized | 
|  | 470 | *              Op              - Parser object to be translated | 
|  | 471 | * | 
|  | 472 | * RETURN:      Status | 
|  | 473 | * | 
|  | 474 | * DESCRIPTION: Create the object to be associated with a namespace node | 
|  | 475 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 476 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 |  | 
|  | 478 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | acpi_ds_create_node(struct acpi_walk_state *walk_state, | 
|  | 480 | struct acpi_namespace_node *node, | 
|  | 481 | union acpi_parse_object *op) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 483 | acpi_status status; | 
|  | 484 | union acpi_operand_object *obj_desc; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 486 | ACPI_FUNCTION_TRACE_PTR(ds_create_node, op); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 |  | 
|  | 488 | /* | 
|  | 489 | * Because of the execution pass through the non-control-method | 
|  | 490 | * parts of the table, we can arrive here twice.  Only init | 
|  | 491 | * the named object node the first time through | 
|  | 492 | */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 493 | if (acpi_ns_get_attached_object(node)) { | 
|  | 494 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | } | 
|  | 496 |  | 
|  | 497 | if (!op->common.value.arg) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 498 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | /* No arguments, there is nothing to do */ | 
|  | 500 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | } | 
|  | 503 |  | 
|  | 504 | /* Build an internal object for the argument(s) */ | 
|  | 505 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 506 | status = acpi_ds_build_internal_object(walk_state, op->common.value.arg, | 
|  | 507 | &obj_desc); | 
|  | 508 | if (ACPI_FAILURE(status)) { | 
|  | 509 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } | 
|  | 511 |  | 
|  | 512 | /* Re-type the object according to its argument */ | 
|  | 513 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 514 | node->type = ACPI_GET_OBJECT_TYPE(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 |  | 
|  | 516 | /* Attach obj to node */ | 
|  | 517 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 518 | status = acpi_ns_attach_object(node, obj_desc, node->type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 |  | 
|  | 520 | /* Remove local reference to the object */ | 
|  | 521 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 522 | acpi_ut_remove_reference(obj_desc); | 
|  | 523 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | } | 
|  | 525 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 526 | #endif				/* ACPI_NO_METHOD_EXECUTION */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 528 | /******************************************************************************* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | * | 
|  | 530 | * FUNCTION:    acpi_ds_init_object_from_op | 
|  | 531 | * | 
|  | 532 | * PARAMETERS:  walk_state      - Current walk state | 
|  | 533 | *              Op              - Parser op used to init the internal object | 
|  | 534 | *              Opcode          - AML opcode associated with the object | 
|  | 535 | *              ret_obj_desc    - Namespace object to be initialized | 
|  | 536 | * | 
|  | 537 | * RETURN:      Status | 
|  | 538 | * | 
|  | 539 | * DESCRIPTION: Initialize a namespace object from a parser Op and its | 
|  | 540 | *              associated arguments.  The namespace object is a more compact | 
|  | 541 | *              representation of the Op and its arguments. | 
|  | 542 | * | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 543 | ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 |  | 
|  | 545 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 546 | acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, | 
|  | 547 | union acpi_parse_object *op, | 
|  | 548 | u16 opcode, | 
|  | 549 | union acpi_operand_object **ret_obj_desc) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 551 | const struct acpi_opcode_info *op_info; | 
|  | 552 | union acpi_operand_object *obj_desc; | 
|  | 553 | acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 555 | ACPI_FUNCTION_TRACE(ds_init_object_from_op); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 |  | 
|  | 557 | obj_desc = *ret_obj_desc; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 558 | op_info = acpi_ps_get_opcode_info(opcode); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | if (op_info->class == AML_CLASS_UNKNOWN) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 560 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | /* Unknown opcode */ | 
|  | 562 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 563 | return_ACPI_STATUS(AE_TYPE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | } | 
|  | 565 |  | 
|  | 566 | /* Perform per-object initialization */ | 
|  | 567 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 568 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | case ACPI_TYPE_BUFFER: | 
|  | 570 |  | 
|  | 571 | /* | 
|  | 572 | * Defer evaluation of Buffer term_arg operand | 
|  | 573 | */ | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 574 | obj_desc->buffer.node = | 
|  | 575 | ACPI_CAST_PTR(struct acpi_namespace_node, | 
|  | 576 | walk_state->operands[0]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | obj_desc->buffer.aml_start = op->named.data; | 
|  | 578 | obj_desc->buffer.aml_length = op->named.length; | 
|  | 579 | break; | 
|  | 580 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | case ACPI_TYPE_PACKAGE: | 
|  | 582 |  | 
|  | 583 | /* | 
|  | 584 | * Defer evaluation of Package term_arg operand | 
|  | 585 | */ | 
| Bob Moore | 8f9337c | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 586 | obj_desc->package.node = | 
|  | 587 | ACPI_CAST_PTR(struct acpi_namespace_node, | 
|  | 588 | walk_state->operands[0]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | obj_desc->package.aml_start = op->named.data; | 
|  | 590 | obj_desc->package.aml_length = op->named.length; | 
|  | 591 | break; | 
|  | 592 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | case ACPI_TYPE_INTEGER: | 
|  | 594 |  | 
|  | 595 | switch (op_info->type) { | 
|  | 596 | case AML_TYPE_CONSTANT: | 
|  | 597 | /* | 
|  | 598 | * Resolve AML Constants here - AND ONLY HERE! | 
|  | 599 | * All constants are integers. | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 600 | * We mark the integer with a flag that indicates that it started | 
|  | 601 | * life as a constant -- so that stores to constants will perform | 
|  | 602 | * as expected (noop). zero_op is used as a placeholder for optional | 
|  | 603 | * target operands. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | */ | 
|  | 605 | obj_desc->common.flags = AOPOBJ_AML_CONSTANT; | 
|  | 606 |  | 
|  | 607 | switch (opcode) { | 
|  | 608 | case AML_ZERO_OP: | 
|  | 609 |  | 
|  | 610 | obj_desc->integer.value = 0; | 
|  | 611 | break; | 
|  | 612 |  | 
|  | 613 | case AML_ONE_OP: | 
|  | 614 |  | 
|  | 615 | obj_desc->integer.value = 1; | 
|  | 616 | break; | 
|  | 617 |  | 
|  | 618 | case AML_ONES_OP: | 
|  | 619 |  | 
|  | 620 | obj_desc->integer.value = ACPI_INTEGER_MAX; | 
|  | 621 |  | 
|  | 622 | /* Truncate value if we are executing from a 32-bit ACPI table */ | 
|  | 623 |  | 
|  | 624 | #ifndef ACPI_NO_METHOD_EXECUTION | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 625 | acpi_ex_truncate_for32bit_table(obj_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | #endif | 
|  | 627 | break; | 
|  | 628 |  | 
|  | 629 | case AML_REVISION_OP: | 
|  | 630 |  | 
|  | 631 | obj_desc->integer.value = ACPI_CA_VERSION; | 
|  | 632 | break; | 
|  | 633 |  | 
|  | 634 | default: | 
|  | 635 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 636 | ACPI_ERROR((AE_INFO, | 
|  | 637 | "Unknown constant opcode %X", | 
|  | 638 | opcode)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | status = AE_AML_OPERAND_TYPE; | 
|  | 640 | break; | 
|  | 641 | } | 
|  | 642 | break; | 
|  | 643 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | case AML_TYPE_LITERAL: | 
|  | 645 |  | 
|  | 646 | obj_desc->integer.value = op->common.value.integer; | 
| Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 647 | #ifndef ACPI_NO_METHOD_EXECUTION | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | acpi_ex_truncate_for32bit_table(obj_desc); | 
| Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 649 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | break; | 
|  | 651 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | default: | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 653 | ACPI_ERROR((AE_INFO, "Unknown Integer type %X", | 
|  | 654 | op_info->type)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | status = AE_AML_OPERAND_TYPE; | 
|  | 656 | break; | 
|  | 657 | } | 
|  | 658 | break; | 
|  | 659 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | case ACPI_TYPE_STRING: | 
|  | 661 |  | 
|  | 662 | obj_desc->string.pointer = op->common.value.string; | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 663 | obj_desc->string.length = | 
|  | 664 | (u32) ACPI_STRLEN(op->common.value.string); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 |  | 
|  | 666 | /* | 
|  | 667 | * The string is contained in the ACPI table, don't ever try | 
|  | 668 | * to delete it | 
|  | 669 | */ | 
|  | 670 | obj_desc->common.flags |= AOPOBJ_STATIC_POINTER; | 
|  | 671 | break; | 
|  | 672 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | case ACPI_TYPE_METHOD: | 
|  | 674 | break; | 
|  | 675 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | case ACPI_TYPE_LOCAL_REFERENCE: | 
|  | 677 |  | 
|  | 678 | switch (op_info->type) { | 
|  | 679 | case AML_TYPE_LOCAL_VARIABLE: | 
|  | 680 |  | 
|  | 681 | /* Split the opcode into a base opcode + offset */ | 
|  | 682 |  | 
|  | 683 | obj_desc->reference.opcode = AML_LOCAL_OP; | 
|  | 684 | obj_desc->reference.offset = opcode - AML_LOCAL_OP; | 
|  | 685 |  | 
|  | 686 | #ifndef ACPI_NO_METHOD_EXECUTION | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 687 | status = acpi_ds_method_data_get_node(AML_LOCAL_OP, | 
|  | 688 | obj_desc-> | 
|  | 689 | reference.offset, | 
|  | 690 | walk_state, | 
|  | 691 | (struct | 
|  | 692 | acpi_namespace_node | 
|  | 693 | **)&obj_desc-> | 
|  | 694 | reference.object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | #endif | 
|  | 696 | break; | 
|  | 697 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | case AML_TYPE_METHOD_ARGUMENT: | 
|  | 699 |  | 
|  | 700 | /* Split the opcode into a base opcode + offset */ | 
|  | 701 |  | 
|  | 702 | obj_desc->reference.opcode = AML_ARG_OP; | 
|  | 703 | obj_desc->reference.offset = opcode - AML_ARG_OP; | 
|  | 704 |  | 
|  | 705 | #ifndef ACPI_NO_METHOD_EXECUTION | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 706 | status = acpi_ds_method_data_get_node(AML_ARG_OP, | 
|  | 707 | obj_desc-> | 
|  | 708 | reference.offset, | 
|  | 709 | walk_state, | 
|  | 710 | (struct | 
|  | 711 | acpi_namespace_node | 
|  | 712 | **)&obj_desc-> | 
|  | 713 | reference.object); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | #endif | 
|  | 715 | break; | 
|  | 716 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 717 | default:	/* Other literals, etc.. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 |  | 
|  | 719 | if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 720 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | /* Node was saved in Op */ | 
|  | 722 |  | 
|  | 723 | obj_desc->reference.node = op->common.node; | 
|  | 724 | } | 
|  | 725 |  | 
|  | 726 | obj_desc->reference.opcode = opcode; | 
|  | 727 | break; | 
|  | 728 | } | 
|  | 729 | break; | 
|  | 730 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | default: | 
|  | 732 |  | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 733 | ACPI_ERROR((AE_INFO, "Unimplemented data type: %X", | 
|  | 734 | ACPI_GET_OBJECT_TYPE(obj_desc))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 |  | 
|  | 736 | status = AE_AML_OPERAND_TYPE; | 
|  | 737 | break; | 
|  | 738 | } | 
|  | 739 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 740 | return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | } |