Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: dsmthdat - control method arguments and local variables |
| 4 | * |
| 5 | ******************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2006, 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/acdispat.h> |
| 46 | #include <acpi/amlcode.h> |
| 47 | #include <acpi/acnamesp.h> |
| 48 | #include <acpi/acinterp.h> |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define _COMPONENT ACPI_DISPATCHER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | ACPI_MODULE_NAME("dsmthdat") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 53 | /* Local prototypes */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 55 | acpi_ds_method_data_delete_value(u16 opcode, |
| 56 | u32 index, struct acpi_walk_state *walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 57 | |
| 58 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 59 | acpi_ds_method_data_set_value(u16 opcode, |
| 60 | u32 index, |
| 61 | union acpi_operand_object *object, |
| 62 | struct acpi_walk_state *walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 63 | |
| 64 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
| 65 | acpi_object_type |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 66 | acpi_ds_method_data_get_type(u16 opcode, |
| 67 | u32 index, struct acpi_walk_state *walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 68 | #endif |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /******************************************************************************* |
| 71 | * |
| 72 | * FUNCTION: acpi_ds_method_data_init |
| 73 | * |
| 74 | * PARAMETERS: walk_state - Current walk state object |
| 75 | * |
| 76 | * RETURN: Status |
| 77 | * |
| 78 | * DESCRIPTION: Initialize the data structures that hold the method's arguments |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 79 | * and locals. The data struct is an array of namespace nodes for |
| 80 | * each - this allows ref_of and de_ref_of to work properly for these |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | * special data types. |
| 82 | * |
| 83 | * NOTES: walk_state fields are initialized to zero by the |
| 84 | * ACPI_MEM_CALLOCATE(). |
| 85 | * |
| 86 | * A pseudo-Namespace Node is assigned to each argument and local |
| 87 | * so that ref_of() can return a pointer to the Node. |
| 88 | * |
| 89 | ******************************************************************************/ |
| 90 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 91 | void acpi_ds_method_data_init(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 93 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 95 | ACPI_FUNCTION_TRACE("ds_method_data_init"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* Init the method arguments */ |
| 98 | |
| 99 | for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 100 | ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | NAMEOF_ARG_NTE); |
| 102 | walk_state->arguments[i].name.integer |= (i << 24); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 103 | walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED; |
| 104 | walk_state->arguments[i].type = ACPI_TYPE_ANY; |
| 105 | walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | |
| 106 | ANOBJ_METHOD_ARG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* Init the method locals */ |
| 110 | |
| 111 | for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 112 | ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | NAMEOF_LOCAL_NTE); |
| 114 | |
| 115 | walk_state->local_variables[i].name.integer |= (i << 24); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | walk_state->local_variables[i].descriptor = |
| 117 | ACPI_DESC_TYPE_NAMED; |
| 118 | walk_state->local_variables[i].type = ACPI_TYPE_ANY; |
| 119 | walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | |
| 120 | ANOBJ_METHOD_LOCAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | return_VOID; |
| 124 | } |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /******************************************************************************* |
| 127 | * |
| 128 | * FUNCTION: acpi_ds_method_data_delete_all |
| 129 | * |
| 130 | * PARAMETERS: walk_state - Current walk state object |
| 131 | * |
| 132 | * RETURN: None |
| 133 | * |
| 134 | * DESCRIPTION: Delete method locals and arguments. Arguments are only |
| 135 | * deleted if this method was called from another method. |
| 136 | * |
| 137 | ******************************************************************************/ |
| 138 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 139 | void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | u32 index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | ACPI_FUNCTION_TRACE("ds_method_data_delete_all"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
| 145 | /* Detach the locals */ |
| 146 | |
| 147 | for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) { |
| 148 | if (walk_state->local_variables[index].object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 149 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n", |
| 150 | index, |
| 151 | walk_state->local_variables[index]. |
| 152 | object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
| 154 | /* Detach object (if present) and remove a reference */ |
| 155 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | acpi_ns_detach_object(&walk_state-> |
| 157 | local_variables[index]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
| 161 | /* Detach the arguments */ |
| 162 | |
| 163 | for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) { |
| 164 | if (walk_state->arguments[index].object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", |
| 166 | index, |
| 167 | walk_state->arguments[index].object)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
| 169 | /* Detach object (if present) and remove a reference */ |
| 170 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | acpi_ns_detach_object(&walk_state->arguments[index]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
| 175 | return_VOID; |
| 176 | } |
| 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /******************************************************************************* |
| 179 | * |
| 180 | * FUNCTION: acpi_ds_method_data_init_args |
| 181 | * |
| 182 | * PARAMETERS: *Params - Pointer to a parameter list for the method |
| 183 | * max_param_count - The arg count for this method |
| 184 | * walk_state - Current walk state object |
| 185 | * |
| 186 | * RETURN: Status |
| 187 | * |
| 188 | * DESCRIPTION: Initialize arguments for a method. The parameter list is a list |
| 189 | * of ACPI operand objects, either null terminated or whose length |
| 190 | * is defined by max_param_count. |
| 191 | * |
| 192 | ******************************************************************************/ |
| 193 | |
| 194 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 195 | acpi_ds_method_data_init_args(union acpi_operand_object **params, |
| 196 | u32 max_param_count, |
| 197 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 199 | acpi_status status; |
| 200 | u32 index = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | ACPI_FUNCTION_TRACE_PTR("ds_method_data_init_args", params); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | if (!params) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 206 | "No param list passed to method\n")); |
| 207 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 210 | /* Copy passed parameters into the new method stack frame */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 212 | while ((index < ACPI_METHOD_NUM_ARGS) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | (index < max_param_count) && params[index]) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | /* |
| 215 | * A valid parameter. |
| 216 | * Store the argument in the method/walk descriptor. |
| 217 | * Do not copy the arg in order to implement call by reference |
| 218 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 219 | status = acpi_ds_method_data_set_value(AML_ARG_OP, index, |
| 220 | params[index], |
| 221 | walk_state); |
| 222 | if (ACPI_FAILURE(status)) { |
| 223 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | index++; |
| 227 | } |
| 228 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 229 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index)); |
| 230 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | /******************************************************************************* |
| 234 | * |
| 235 | * FUNCTION: acpi_ds_method_data_get_node |
| 236 | * |
| 237 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 238 | * Index - Which Local or Arg whose type to get |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | * walk_state - Current walk state object |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 240 | * Node - Where the node is returned. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 242 | * RETURN: Status and node |
| 243 | * |
| 244 | * DESCRIPTION: Get the Node associated with a local or arg. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | * |
| 246 | ******************************************************************************/ |
| 247 | |
| 248 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 249 | acpi_ds_method_data_get_node(u16 opcode, |
| 250 | u32 index, |
| 251 | struct acpi_walk_state *walk_state, |
| 252 | struct acpi_namespace_node **node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | ACPI_FUNCTION_TRACE("ds_method_data_get_node"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | /* |
| 257 | * Method Locals and Arguments are supported |
| 258 | */ |
| 259 | switch (opcode) { |
| 260 | case AML_LOCAL_OP: |
| 261 | |
| 262 | if (index > ACPI_METHOD_MAX_LOCAL) { |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 263 | ACPI_REPORT_ERROR(("Local index %d is invalid (max %d)\n", index, ACPI_METHOD_MAX_LOCAL)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 264 | return_ACPI_STATUS(AE_AML_INVALID_INDEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /* Return a pointer to the pseudo-node */ |
| 268 | |
| 269 | *node = &walk_state->local_variables[index]; |
| 270 | break; |
| 271 | |
| 272 | case AML_ARG_OP: |
| 273 | |
| 274 | if (index > ACPI_METHOD_MAX_ARG) { |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 275 | ACPI_REPORT_ERROR(("Arg index %d is invalid (max %d)\n", |
| 276 | index, ACPI_METHOD_MAX_ARG)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | return_ACPI_STATUS(AE_AML_INVALID_INDEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /* Return a pointer to the pseudo-node */ |
| 281 | |
| 282 | *node = &walk_state->arguments[index]; |
| 283 | break; |
| 284 | |
| 285 | default: |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 286 | ACPI_REPORT_ERROR(("Opcode %d is invalid\n", opcode)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 290 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | /******************************************************************************* |
| 294 | * |
| 295 | * FUNCTION: acpi_ds_method_data_set_value |
| 296 | * |
| 297 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 298 | * Index - Which Local or Arg to get |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | * Object - Object to be inserted into the stack entry |
| 300 | * walk_state - Current walk state object |
| 301 | * |
| 302 | * RETURN: Status |
| 303 | * |
| 304 | * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. |
| 305 | * Note: There is no "implicit conversion" for locals. |
| 306 | * |
| 307 | ******************************************************************************/ |
| 308 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 309 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | acpi_ds_method_data_set_value(u16 opcode, |
| 311 | u32 index, |
| 312 | union acpi_operand_object *object, |
| 313 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 315 | acpi_status status; |
| 316 | struct acpi_namespace_node *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | ACPI_FUNCTION_TRACE("ds_method_data_set_value"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 320 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 321 | "new_obj %p Opcode %X, Refs=%d [%s]\n", object, |
| 322 | opcode, object->common.reference_count, |
| 323 | acpi_ut_get_type_name(object->common.type))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
| 325 | /* Get the namespace node for the arg/local */ |
| 326 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 327 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 328 | if (ACPI_FAILURE(status)) { |
| 329 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /* |
| 333 | * Increment ref count so object can't be deleted while installed. |
| 334 | * NOTE: We do not copy the object in order to preserve the call by |
| 335 | * reference semantics of ACPI Control Method invocation. |
| 336 | * (See ACPI specification 2.0_c) |
| 337 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | acpi_ut_add_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | /* Install the object */ |
| 341 | |
| 342 | node->object = object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | /******************************************************************************* |
| 347 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | * FUNCTION: acpi_ds_method_data_get_value |
| 349 | * |
| 350 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 351 | * Index - which local_var or argument to get |
| 352 | * walk_state - Current walk state object |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 353 | * dest_desc - Where Arg or Local value is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | * |
| 355 | * RETURN: Status |
| 356 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 357 | * DESCRIPTION: Retrieve value of selected Arg or Local for this method |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * Used only in acpi_ex_resolve_to_value(). |
| 359 | * |
| 360 | ******************************************************************************/ |
| 361 | |
| 362 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | acpi_ds_method_data_get_value(u16 opcode, |
| 364 | u32 index, |
| 365 | struct acpi_walk_state *walk_state, |
| 366 | union acpi_operand_object **dest_desc) |
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 | acpi_status status; |
| 369 | struct acpi_namespace_node *node; |
| 370 | union acpi_operand_object *object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 372 | ACPI_FUNCTION_TRACE("ds_method_data_get_value"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
| 374 | /* Validate the object descriptor */ |
| 375 | |
| 376 | if (!dest_desc) { |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 377 | ACPI_REPORT_ERROR(("Null object descriptor pointer\n")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /* Get the namespace node for the arg/local */ |
| 382 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 383 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 384 | if (ACPI_FAILURE(status)) { |
| 385 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /* Get the object from the node */ |
| 389 | |
| 390 | object = node->object; |
| 391 | |
| 392 | /* Examine the returned object, it must be valid. */ |
| 393 | |
| 394 | if (!object) { |
| 395 | /* |
| 396 | * Index points to uninitialized object. |
| 397 | * This means that either 1) The expected argument was |
| 398 | * not passed to the method, or 2) A local variable |
| 399 | * was referenced by the method (via the ASL) |
| 400 | * before it was initialized. Either case is an error. |
| 401 | */ |
| 402 | |
| 403 | /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ |
| 404 | |
| 405 | if (acpi_gbl_enable_interpreter_slack) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 406 | object = |
| 407 | acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | if (!object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 409 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | object->integer.value = 0; |
| 413 | node->object = object; |
| 414 | } |
| 415 | |
| 416 | /* Otherwise, return the error */ |
| 417 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 418 | else |
| 419 | switch (opcode) { |
| 420 | case AML_ARG_OP: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 422 | ACPI_REPORT_ERROR(("Uninitialized Arg[%d] at node %p\n", index, node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 424 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); |
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 | case AML_LOCAL_OP: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 428 | ACPI_REPORT_ERROR(("Uninitialized Local[%d] at node %p\n", index, node)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 430 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 432 | default: |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 433 | ACPI_REPORT_ERROR(("Not a Arg/Local opcode: %X\n", opcode)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 434 | return_ACPI_STATUS(AE_AML_INTERNAL); |
| 435 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | /* |
| 439 | * The Index points to an initialized and valid object. |
| 440 | * Return an additional reference to the object |
| 441 | */ |
| 442 | *dest_desc = object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 443 | acpi_ut_add_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | } |
| 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | /******************************************************************************* |
| 449 | * |
| 450 | * FUNCTION: acpi_ds_method_data_delete_value |
| 451 | * |
| 452 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 453 | * Index - which local_var or argument to delete |
| 454 | * walk_state - Current walk state object |
| 455 | * |
| 456 | * RETURN: None |
| 457 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 458 | * DESCRIPTION: Delete the entry at Opcode:Index. Inserts |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | * a null into the stack slot after the object is deleted. |
| 460 | * |
| 461 | ******************************************************************************/ |
| 462 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 463 | static void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 464 | acpi_ds_method_data_delete_value(u16 opcode, |
| 465 | u32 index, struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 467 | acpi_status status; |
| 468 | struct acpi_namespace_node *node; |
| 469 | union acpi_operand_object *object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 471 | ACPI_FUNCTION_TRACE("ds_method_data_delete_value"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
| 473 | /* Get the namespace node for the arg/local */ |
| 474 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 475 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 476 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | return_VOID; |
| 478 | } |
| 479 | |
| 480 | /* Get the associated object */ |
| 481 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 482 | object = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
| 484 | /* |
| 485 | * Undefine the Arg or Local by setting its descriptor |
| 486 | * pointer to NULL. Locals/Args can contain both |
| 487 | * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs |
| 488 | */ |
| 489 | node->object = NULL; |
| 490 | |
| 491 | if ((object) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 492 | (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | /* |
| 494 | * There is a valid object. |
| 495 | * Decrement the reference count by one to balance the |
| 496 | * increment when the object was stored. |
| 497 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 498 | acpi_ut_remove_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | return_VOID; |
| 502 | } |
| 503 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | /******************************************************************************* |
| 505 | * |
| 506 | * FUNCTION: acpi_ds_store_object_to_local |
| 507 | * |
| 508 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 509 | * Index - Which Local or Arg to set |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | * obj_desc - Value to be stored |
| 511 | * walk_state - Current walk state |
| 512 | * |
| 513 | * RETURN: Status |
| 514 | * |
| 515 | * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed |
| 516 | * as the new value for the Arg or Local and the reference count |
| 517 | * for obj_desc is incremented. |
| 518 | * |
| 519 | ******************************************************************************/ |
| 520 | |
| 521 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 522 | acpi_ds_store_object_to_local(u16 opcode, |
| 523 | u32 index, |
| 524 | union acpi_operand_object *obj_desc, |
| 525 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 527 | acpi_status status; |
| 528 | struct acpi_namespace_node *node; |
| 529 | union acpi_operand_object *current_obj_desc; |
| 530 | union acpi_operand_object *new_obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 532 | ACPI_FUNCTION_TRACE("ds_store_object_to_local"); |
| 533 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", |
| 534 | opcode, index, obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
| 536 | /* Parameter validation */ |
| 537 | |
| 538 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 539 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | /* Get the namespace node for the arg/local */ |
| 543 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 544 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 545 | if (ACPI_FAILURE(status)) { |
| 546 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 549 | current_obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | if (current_obj_desc == obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 551 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n", |
| 552 | obj_desc)); |
| 553 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /* |
| 557 | * If the reference count on the object is more than one, we must |
| 558 | * take a copy of the object before we store. A reference count |
| 559 | * of exactly 1 means that the object was just created during the |
| 560 | * evaluation of an expression, and we can safely use it since it |
| 561 | * is not used anywhere else. |
| 562 | */ |
| 563 | new_obj_desc = obj_desc; |
| 564 | if (obj_desc->common.reference_count > 1) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 565 | status = |
| 566 | acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc, |
| 567 | walk_state); |
| 568 | if (ACPI_FAILURE(status)) { |
| 569 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
| 573 | /* |
| 574 | * If there is an object already in this slot, we either |
| 575 | * have to delete it, or if this is an argument and there |
| 576 | * is an object reference stored there, we have to do |
| 577 | * an indirect store! |
| 578 | */ |
| 579 | if (current_obj_desc) { |
| 580 | /* |
| 581 | * Check for an indirect store if an argument |
| 582 | * contains an object reference (stored as an Node). |
| 583 | * We don't allow this automatic dereferencing for |
| 584 | * locals, since a store to a local should overwrite |
| 585 | * anything there, including an object reference. |
| 586 | * |
| 587 | * If both Arg0 and Local0 contain ref_of (Local4): |
| 588 | * |
| 589 | * Store (1, Arg0) - Causes indirect store to local4 |
| 590 | * Store (1, Local0) - Stores 1 in local0, overwriting |
| 591 | * the reference to local4 |
| 592 | * Store (1, de_refof (Local0)) - Causes indirect store to local4 |
| 593 | * |
| 594 | * Weird, but true. |
| 595 | */ |
| 596 | if (opcode == AML_ARG_OP) { |
| 597 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 598 | * If we have a valid reference object that came from ref_of(), |
| 599 | * do the indirect store |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 601 | if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) == |
| 602 | ACPI_DESC_TYPE_OPERAND) |
| 603 | && (current_obj_desc->common.type == |
| 604 | ACPI_TYPE_LOCAL_REFERENCE) |
| 605 | && (current_obj_desc->reference.opcode == |
| 606 | AML_REF_OF_OP)) { |
| 607 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 608 | "Arg (%p) is an obj_ref(Node), storing in node %p\n", |
| 609 | new_obj_desc, |
| 610 | current_obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | |
| 612 | /* |
| 613 | * Store this object to the Node (perform the indirect store) |
| 614 | * NOTE: No implicit conversion is performed, as per the ACPI |
| 615 | * specification rules on storing to Locals/Args. |
| 616 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 617 | status = |
| 618 | acpi_ex_store_object_to_node(new_obj_desc, |
| 619 | current_obj_desc-> |
| 620 | reference. |
| 621 | object, |
| 622 | walk_state, |
| 623 | ACPI_NO_IMPLICIT_CONVERSION); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
| 625 | /* Remove local reference if we copied the object above */ |
| 626 | |
| 627 | if (new_obj_desc != obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 628 | acpi_ut_remove_reference(new_obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 630 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | } |
| 632 | } |
| 633 | |
| 634 | /* |
| 635 | * Delete the existing object |
| 636 | * before storing the new one |
| 637 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 638 | acpi_ds_method_data_delete_value(opcode, index, walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | /* |
| 642 | * Install the Obj descriptor (*new_obj_desc) into |
| 643 | * the descriptor for the Arg or Local. |
| 644 | * (increments the object reference count by one) |
| 645 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 646 | status = |
| 647 | acpi_ds_method_data_set_value(opcode, index, new_obj_desc, |
| 648 | walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
| 650 | /* Remove local reference if we copied the object above */ |
| 651 | |
| 652 | if (new_obj_desc != obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 653 | acpi_ut_remove_reference(new_obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | } |
| 655 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 656 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 659 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
| 660 | /******************************************************************************* |
| 661 | * |
| 662 | * FUNCTION: acpi_ds_method_data_get_type |
| 663 | * |
| 664 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 665 | * Index - Which Local or Arg whose type to get |
| 666 | * walk_state - Current walk state object |
| 667 | * |
| 668 | * RETURN: Data type of current value of the selected Arg or Local |
| 669 | * |
| 670 | * DESCRIPTION: Get the type of the object stored in the Local or Arg |
| 671 | * |
| 672 | ******************************************************************************/ |
| 673 | |
| 674 | acpi_object_type |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 675 | acpi_ds_method_data_get_type(u16 opcode, |
| 676 | u32 index, struct acpi_walk_state *walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 677 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 678 | acpi_status status; |
| 679 | struct acpi_namespace_node *node; |
| 680 | union acpi_operand_object *object; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 681 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 682 | ACPI_FUNCTION_TRACE("ds_method_data_get_type"); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 683 | |
| 684 | /* Get the namespace node for the arg/local */ |
| 685 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 686 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 687 | if (ACPI_FAILURE(status)) { |
| 688 | return_VALUE((ACPI_TYPE_NOT_FOUND)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | /* Get the object */ |
| 692 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 693 | object = acpi_ns_get_attached_object(node); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 694 | if (!object) { |
| 695 | /* Uninitialized local/arg, return TYPE_ANY */ |
| 696 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 697 | return_VALUE(ACPI_TYPE_ANY); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 698 | } |
| 699 | |
| 700 | /* Get the object type */ |
| 701 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 702 | return_VALUE(ACPI_GET_OBJECT_TYPE(object)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 703 | } |
| 704 | #endif |