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