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 | a8357b0 | 2010-01-22 19:07:36 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "acdispat.h" |
| 47 | #include "acnamesp.h" |
| 48 | #include "acinterp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 55 | acpi_ds_method_data_delete_value(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 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 |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 59 | acpi_ds_method_data_set_value(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 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 |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 84 | * ACPI_ALLOCATE_ZEROED(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -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); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 103 | walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 104 | walk_state->arguments[i].type = ACPI_TYPE_ANY; |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 105 | walk_state->arguments[i].flags = |
| 106 | ANOBJ_END_OF_PEER_LIST | 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); |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 116 | walk_state->local_variables[i].descriptor_type = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | ACPI_DESC_TYPE_NAMED; |
| 118 | walk_state->local_variables[i].type = ACPI_TYPE_ANY; |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 119 | walk_state->local_variables[i].flags = |
| 120 | ANOBJ_END_OF_PEER_LIST | 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 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -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 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -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 | */ |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 219 | status = acpi_ds_method_data_set_value(ACPI_REFCLASS_ARG, index, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 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 | * |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 237 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
| 238 | * ACPI_REFCLASS_ARG |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 239 | * Index - Which Local or Arg whose type to get |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | * walk_state - Current walk state object |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 241 | * Node - Where the node is returned. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 243 | * RETURN: Status and node |
| 244 | * |
| 245 | * DESCRIPTION: Get the Node associated with a local or arg. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | * |
| 247 | ******************************************************************************/ |
| 248 | |
| 249 | acpi_status |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 250 | acpi_ds_method_data_get_node(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | u32 index, |
| 252 | struct acpi_walk_state *walk_state, |
| 253 | struct acpi_namespace_node **node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 255 | ACPI_FUNCTION_TRACE(ds_method_data_get_node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
| 257 | /* |
| 258 | * Method Locals and Arguments are supported |
| 259 | */ |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 260 | switch (type) { |
| 261 | case ACPI_REFCLASS_LOCAL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | if (index > ACPI_METHOD_MAX_LOCAL) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 264 | ACPI_ERROR((AE_INFO, |
| 265 | "Local index %d is invalid (max %d)", |
| 266 | index, ACPI_METHOD_MAX_LOCAL)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 267 | return_ACPI_STATUS(AE_AML_INVALID_INDEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /* Return a pointer to the pseudo-node */ |
| 271 | |
| 272 | *node = &walk_state->local_variables[index]; |
| 273 | break; |
| 274 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 275 | case ACPI_REFCLASS_ARG: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | if (index > ACPI_METHOD_MAX_ARG) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 278 | ACPI_ERROR((AE_INFO, |
| 279 | "Arg index %d is invalid (max %d)", |
| 280 | index, ACPI_METHOD_MAX_ARG)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 281 | return_ACPI_STATUS(AE_AML_INVALID_INDEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | /* Return a pointer to the pseudo-node */ |
| 285 | |
| 286 | *node = &walk_state->arguments[index]; |
| 287 | break; |
| 288 | |
| 289 | default: |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 290 | ACPI_ERROR((AE_INFO, "Type %d is invalid", type)); |
| 291 | return_ACPI_STATUS(AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | /******************************************************************************* |
| 298 | * |
| 299 | * FUNCTION: acpi_ds_method_data_set_value |
| 300 | * |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 301 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
| 302 | * ACPI_REFCLASS_ARG |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 303 | * Index - Which Local or Arg to get |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | * Object - Object to be inserted into the stack entry |
| 305 | * walk_state - Current walk state object |
| 306 | * |
| 307 | * RETURN: Status |
| 308 | * |
| 309 | * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. |
| 310 | * Note: There is no "implicit conversion" for locals. |
| 311 | * |
| 312 | ******************************************************************************/ |
| 313 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 314 | static acpi_status |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 315 | acpi_ds_method_data_set_value(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | u32 index, |
| 317 | union acpi_operand_object *object, |
| 318 | struct acpi_walk_state *walk_state) |
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_status status; |
| 321 | struct acpi_namespace_node *node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 323 | ACPI_FUNCTION_TRACE(ds_method_data_set_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 325 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 326 | "NewObj %p Type %2.2X, Refs=%d [%s]\n", object, |
| 327 | type, object->common.reference_count, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 328 | acpi_ut_get_type_name(object->common.type))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
| 330 | /* Get the namespace node for the arg/local */ |
| 331 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 332 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | if (ACPI_FAILURE(status)) { |
| 334 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /* |
| 338 | * Increment ref count so object can't be deleted while installed. |
| 339 | * NOTE: We do not copy the object in order to preserve the call by |
| 340 | * reference semantics of ACPI Control Method invocation. |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 341 | * (See ACPI Specification 2.0_c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | acpi_ut_add_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | /* Install the object */ |
| 346 | |
| 347 | node->object = object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 348 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | /******************************************************************************* |
| 352 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | * FUNCTION: acpi_ds_method_data_get_value |
| 354 | * |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 355 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
| 356 | * ACPI_REFCLASS_ARG |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 357 | * Index - Which local_var or argument to get |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * walk_state - Current walk state object |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 359 | * dest_desc - Where Arg or Local value is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | * |
| 361 | * RETURN: Status |
| 362 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 363 | * DESCRIPTION: Retrieve value of selected Arg or Local for this method |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | * Used only in acpi_ex_resolve_to_value(). |
| 365 | * |
| 366 | ******************************************************************************/ |
| 367 | |
| 368 | acpi_status |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 369 | acpi_ds_method_data_get_value(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 370 | u32 index, |
| 371 | struct acpi_walk_state *walk_state, |
| 372 | union acpi_operand_object **dest_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 374 | acpi_status status; |
| 375 | struct acpi_namespace_node *node; |
| 376 | union acpi_operand_object *object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 378 | ACPI_FUNCTION_TRACE(ds_method_data_get_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
| 380 | /* Validate the object descriptor */ |
| 381 | |
| 382 | if (!dest_desc) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 383 | ACPI_ERROR((AE_INFO, "Null object descriptor pointer")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 384 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* Get the namespace node for the arg/local */ |
| 388 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 389 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | if (ACPI_FAILURE(status)) { |
| 391 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | /* Get the object from the node */ |
| 395 | |
| 396 | object = node->object; |
| 397 | |
| 398 | /* Examine the returned object, it must be valid. */ |
| 399 | |
| 400 | if (!object) { |
| 401 | /* |
| 402 | * Index points to uninitialized object. |
| 403 | * This means that either 1) The expected argument was |
| 404 | * not passed to the method, or 2) A local variable |
| 405 | * was referenced by the method (via the ASL) |
| 406 | * before it was initialized. Either case is an error. |
| 407 | */ |
| 408 | |
| 409 | /* If slack enabled, init the local_x/arg_x to an Integer of value zero */ |
| 410 | |
| 411 | if (acpi_gbl_enable_interpreter_slack) { |
Bob Moore | dc95a27 | 2009-11-12 09:52:45 +0800 | [diff] [blame] | 412 | object = acpi_ut_create_integer_object((u64) 0); |
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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | node->object = object; |
| 418 | } |
| 419 | |
| 420 | /* Otherwise, return the error */ |
| 421 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 422 | else |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 423 | switch (type) { |
| 424 | case ACPI_REFCLASS_ARG: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 426 | ACPI_ERROR((AE_INFO, |
| 427 | "Uninitialized Arg[%d] at node %p", |
| 428 | 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_ARG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 432 | case ACPI_REFCLASS_LOCAL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | |
Bob Moore | e678902 | 2009-09-03 09:58:14 +0800 | [diff] [blame] | 434 | /* |
| 435 | * No error message for this case, will be trapped again later to |
| 436 | * detect and ignore cases of Store(local_x,local_x) |
| 437 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 438 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 440 | default: |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 441 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 442 | ACPI_ERROR((AE_INFO, |
| 443 | "Not a Arg/Local opcode: %X", |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 444 | type)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | return_ACPI_STATUS(AE_AML_INTERNAL); |
| 446 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | /* |
| 450 | * The Index points to an initialized and valid object. |
| 451 | * Return an additional reference to the object |
| 452 | */ |
| 453 | *dest_desc = object; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 454 | acpi_ut_add_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 456 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | } |
| 458 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | /******************************************************************************* |
| 460 | * |
| 461 | * FUNCTION: acpi_ds_method_data_delete_value |
| 462 | * |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 463 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
| 464 | * ACPI_REFCLASS_ARG |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 465 | * Index - Which local_var or argument to delete |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | * walk_state - Current walk state object |
| 467 | * |
| 468 | * RETURN: None |
| 469 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 470 | * DESCRIPTION: Delete the entry at Opcode:Index. Inserts |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | * a null into the stack slot after the object is deleted. |
| 472 | * |
| 473 | ******************************************************************************/ |
| 474 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 475 | static void |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 476 | acpi_ds_method_data_delete_value(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 477 | u32 index, struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 479 | acpi_status status; |
| 480 | struct acpi_namespace_node *node; |
| 481 | union acpi_operand_object *object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 483 | ACPI_FUNCTION_TRACE(ds_method_data_delete_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
| 485 | /* Get the namespace node for the arg/local */ |
| 486 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 487 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 488 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | return_VOID; |
| 490 | } |
| 491 | |
| 492 | /* Get the associated object */ |
| 493 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | object = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | |
| 496 | /* |
| 497 | * Undefine the Arg or Local by setting its descriptor |
| 498 | * pointer to NULL. Locals/Args can contain both |
| 499 | * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs |
| 500 | */ |
| 501 | node->object = NULL; |
| 502 | |
| 503 | if ((object) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | /* |
| 506 | * There is a valid object. |
| 507 | * Decrement the reference count by one to balance the |
| 508 | * increment when the object was stored. |
| 509 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 510 | acpi_ut_remove_reference(object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | return_VOID; |
| 514 | } |
| 515 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | /******************************************************************************* |
| 517 | * |
| 518 | * FUNCTION: acpi_ds_store_object_to_local |
| 519 | * |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 520 | * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or |
| 521 | * ACPI_REFCLASS_ARG |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 522 | * Index - Which Local or Arg to set |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | * obj_desc - Value to be stored |
| 524 | * walk_state - Current walk state |
| 525 | * |
| 526 | * RETURN: Status |
| 527 | * |
| 528 | * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed |
| 529 | * as the new value for the Arg or Local and the reference count |
| 530 | * for obj_desc is incremented. |
| 531 | * |
| 532 | ******************************************************************************/ |
| 533 | |
| 534 | acpi_status |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 535 | acpi_ds_store_object_to_local(u8 type, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 536 | u32 index, |
| 537 | union acpi_operand_object *obj_desc, |
| 538 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 540 | acpi_status status; |
| 541 | struct acpi_namespace_node *node; |
| 542 | union acpi_operand_object *current_obj_desc; |
| 543 | union acpi_operand_object *new_obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 545 | ACPI_FUNCTION_TRACE(ds_store_object_to_local); |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 546 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", |
| 547 | type, index, obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
| 549 | /* Parameter validation */ |
| 550 | |
| 551 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 552 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | /* Get the namespace node for the arg/local */ |
| 556 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 557 | status = acpi_ds_method_data_get_node(type, index, walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 558 | if (ACPI_FAILURE(status)) { |
| 559 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 562 | current_obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | if (current_obj_desc == obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 564 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n", |
| 565 | obj_desc)); |
| 566 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /* |
| 570 | * If the reference count on the object is more than one, we must |
| 571 | * take a copy of the object before we store. A reference count |
| 572 | * of exactly 1 means that the object was just created during the |
| 573 | * evaluation of an expression, and we can safely use it since it |
| 574 | * is not used anywhere else. |
| 575 | */ |
| 576 | new_obj_desc = obj_desc; |
| 577 | if (obj_desc->common.reference_count > 1) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 578 | status = |
| 579 | acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc, |
| 580 | walk_state); |
| 581 | if (ACPI_FAILURE(status)) { |
| 582 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | } |
| 584 | } |
| 585 | |
| 586 | /* |
| 587 | * If there is an object already in this slot, we either |
| 588 | * have to delete it, or if this is an argument and there |
| 589 | * is an object reference stored there, we have to do |
| 590 | * an indirect store! |
| 591 | */ |
| 592 | if (current_obj_desc) { |
| 593 | /* |
| 594 | * Check for an indirect store if an argument |
| 595 | * contains an object reference (stored as an Node). |
| 596 | * We don't allow this automatic dereferencing for |
| 597 | * locals, since a store to a local should overwrite |
| 598 | * anything there, including an object reference. |
| 599 | * |
| 600 | * If both Arg0 and Local0 contain ref_of (Local4): |
| 601 | * |
| 602 | * Store (1, Arg0) - Causes indirect store to local4 |
| 603 | * Store (1, Local0) - Stores 1 in local0, overwriting |
| 604 | * the reference to local4 |
| 605 | * Store (1, de_refof (Local0)) - Causes indirect store to local4 |
| 606 | * |
| 607 | * Weird, but true. |
| 608 | */ |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 609 | if (type == ACPI_REFCLASS_ARG) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 611 | * If we have a valid reference object that came from ref_of(), |
| 612 | * do the indirect store |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 614 | if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) == |
| 615 | ACPI_DESC_TYPE_OPERAND) |
| 616 | && (current_obj_desc->common.type == |
| 617 | ACPI_TYPE_LOCAL_REFERENCE) |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 618 | && (current_obj_desc->reference.class == |
| 619 | ACPI_REFCLASS_REFOF)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 621 | "Arg (%p) is an ObjRef(Node), storing in node %p\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 622 | new_obj_desc, |
| 623 | current_obj_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | |
| 625 | /* |
| 626 | * Store this object to the Node (perform the indirect store) |
| 627 | * NOTE: No implicit conversion is performed, as per the ACPI |
| 628 | * specification rules on storing to Locals/Args. |
| 629 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 630 | status = |
| 631 | acpi_ex_store_object_to_node(new_obj_desc, |
| 632 | current_obj_desc-> |
| 633 | reference. |
| 634 | object, |
| 635 | walk_state, |
| 636 | ACPI_NO_IMPLICIT_CONVERSION); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | |
| 638 | /* Remove local reference if we copied the object above */ |
| 639 | |
| 640 | if (new_obj_desc != obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 641 | acpi_ut_remove_reference(new_obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 643 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } |
| 645 | } |
| 646 | |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 647 | /* Delete the existing object before storing the new one */ |
| 648 | |
| 649 | acpi_ds_method_data_delete_value(type, index, walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | /* |
| 653 | * Install the Obj descriptor (*new_obj_desc) into |
| 654 | * the descriptor for the Arg or Local. |
| 655 | * (increments the object reference count by one) |
| 656 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 657 | status = |
Bob Moore | 1044f1f | 2008-09-27 11:08:41 +0800 | [diff] [blame] | 658 | acpi_ds_method_data_set_value(type, index, new_obj_desc, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 659 | walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | /* Remove local reference if we copied the object above */ |
| 662 | |
| 663 | if (new_obj_desc != obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 664 | acpi_ut_remove_reference(new_obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | } |
| 666 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 667 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | } |
| 669 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 670 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
| 671 | /******************************************************************************* |
| 672 | * |
| 673 | * FUNCTION: acpi_ds_method_data_get_type |
| 674 | * |
| 675 | * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP |
| 676 | * Index - Which Local or Arg whose type to get |
| 677 | * walk_state - Current walk state object |
| 678 | * |
| 679 | * RETURN: Data type of current value of the selected Arg or Local |
| 680 | * |
| 681 | * DESCRIPTION: Get the type of the object stored in the Local or Arg |
| 682 | * |
| 683 | ******************************************************************************/ |
| 684 | |
| 685 | acpi_object_type |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 686 | acpi_ds_method_data_get_type(u16 opcode, |
| 687 | u32 index, struct acpi_walk_state *walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 688 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | acpi_status status; |
| 690 | struct acpi_namespace_node *node; |
| 691 | union acpi_operand_object *object; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 692 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 693 | ACPI_FUNCTION_TRACE(ds_method_data_get_type); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 694 | |
| 695 | /* Get the namespace node for the arg/local */ |
| 696 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 697 | status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); |
| 698 | if (ACPI_FAILURE(status)) { |
| 699 | return_VALUE((ACPI_TYPE_NOT_FOUND)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | /* Get the object */ |
| 703 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 704 | object = acpi_ns_get_attached_object(node); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 705 | if (!object) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 706 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 707 | /* Uninitialized local/arg, return TYPE_ANY */ |
| 708 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 709 | return_VALUE(ACPI_TYPE_ANY); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | /* Get the object type */ |
| 713 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 714 | return_VALUE(object->type); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 715 | } |
| 716 | #endif |