Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: dswstate - Dispatcher parse tree walk management routines |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/acparser.h> |
| 46 | #include <acpi/acdispat.h> |
| 47 | #include <acpi/acnamesp.h> |
| 48 | |
| 49 | #define _COMPONENT ACPI_DISPATCHER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 50 | ACPI_MODULE_NAME("dswstate") |
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 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 55 | acpi_ds_result_insert(void *object, |
| 56 | u32 index, struct acpi_walk_state *walk_state); |
| 57 | |
| 58 | acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state *walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 60 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 61 | acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, |
| 62 | struct acpi_walk_state *walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 64 | void *acpi_ds_obj_stack_get_value(u32 index, |
| 65 | struct acpi_walk_state *walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 66 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 68 | #ifdef ACPI_FUTURE_USAGE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /******************************************************************************* |
| 71 | * |
| 72 | * FUNCTION: acpi_ds_result_remove |
| 73 | * |
| 74 | * PARAMETERS: Object - Where to return the popped object |
| 75 | * Index - Where to extract the object |
| 76 | * walk_state - Current Walk state |
| 77 | * |
| 78 | * RETURN: Status |
| 79 | * |
| 80 | * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In |
| 81 | * other words, this is a FIFO. |
| 82 | * |
| 83 | ******************************************************************************/ |
| 84 | |
| 85 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 86 | acpi_ds_result_remove(union acpi_operand_object **object, |
| 87 | u32 index, struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 89 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 91 | ACPI_FUNCTION_NAME("ds_result_remove"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | state = walk_state->results; |
| 94 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 95 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 96 | "No result object pushed! State=%p\n", |
| 97 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | return (AE_NOT_EXIST); |
| 99 | } |
| 100 | |
| 101 | if (index >= ACPI_OBJ_MAX_OPERAND) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 102 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 103 | "Index out of range: %X State=%p Num=%X\n", |
| 104 | index, walk_state, |
| 105 | state->results.num_results)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /* Check for a valid result object */ |
| 109 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 110 | if (!state->results.obj_desc[index]) { |
| 111 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 112 | "Null operand! State=%p #Ops=%X, Index=%X\n", |
| 113 | walk_state, state->results.num_results, |
| 114 | index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | return (AE_AML_NO_RETURN_VALUE); |
| 116 | } |
| 117 | |
| 118 | /* Remove the object */ |
| 119 | |
| 120 | state->results.num_results--; |
| 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 122 | *object = state->results.obj_desc[index]; |
| 123 | state->results.obj_desc[index] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 125 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 126 | "Obj=%p [%s] Index=%X State=%p Num=%X\n", |
| 127 | *object, |
| 128 | (*object) ? acpi_ut_get_object_type_name(*object) : |
| 129 | "NULL", index, walk_state, |
| 130 | state->results.num_results)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
| 132 | return (AE_OK); |
| 133 | } |
| 134 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 135 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | /******************************************************************************* |
| 138 | * |
| 139 | * FUNCTION: acpi_ds_result_pop |
| 140 | * |
| 141 | * PARAMETERS: Object - Where to return the popped object |
| 142 | * walk_state - Current Walk state |
| 143 | * |
| 144 | * RETURN: Status |
| 145 | * |
| 146 | * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In |
| 147 | * other words, this is a FIFO. |
| 148 | * |
| 149 | ******************************************************************************/ |
| 150 | |
| 151 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 152 | acpi_ds_result_pop(union acpi_operand_object ** object, |
| 153 | struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 155 | acpi_native_uint index; |
| 156 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 158 | ACPI_FUNCTION_NAME("ds_result_pop"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
| 160 | state = walk_state->results; |
| 161 | if (!state) { |
| 162 | return (AE_OK); |
| 163 | } |
| 164 | |
| 165 | if (!state->results.num_results) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 166 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 167 | "Result stack is empty! State=%p\n", |
| 168 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | return (AE_AML_NO_RETURN_VALUE); |
| 170 | } |
| 171 | |
| 172 | /* Remove top element */ |
| 173 | |
| 174 | state->results.num_results--; |
| 175 | |
| 176 | for (index = ACPI_OBJ_NUM_OPERANDS; index; index--) { |
| 177 | /* Check for a valid result object */ |
| 178 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 179 | if (state->results.obj_desc[index - 1]) { |
| 180 | *object = state->results.obj_desc[index - 1]; |
| 181 | state->results.obj_desc[index - 1] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 183 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 184 | "Obj=%p [%s] Index=%X State=%p Num=%X\n", |
| 185 | *object, |
| 186 | (*object) ? |
| 187 | acpi_ut_get_object_type_name(*object) |
| 188 | : "NULL", (u32) index - 1, walk_state, |
| 189 | state->results.num_results)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
| 191 | return (AE_OK); |
| 192 | } |
| 193 | } |
| 194 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 195 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 196 | "No result objects! State=%p\n", walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | return (AE_AML_NO_RETURN_VALUE); |
| 198 | } |
| 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | /******************************************************************************* |
| 201 | * |
| 202 | * FUNCTION: acpi_ds_result_pop_from_bottom |
| 203 | * |
| 204 | * PARAMETERS: Object - Where to return the popped object |
| 205 | * walk_state - Current Walk state |
| 206 | * |
| 207 | * RETURN: Status |
| 208 | * |
| 209 | * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In |
| 210 | * other words, this is a FIFO. |
| 211 | * |
| 212 | ******************************************************************************/ |
| 213 | |
| 214 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 215 | acpi_ds_result_pop_from_bottom(union acpi_operand_object ** object, |
| 216 | struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 218 | acpi_native_uint index; |
| 219 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 221 | ACPI_FUNCTION_NAME("ds_result_pop_from_bottom"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | |
| 223 | state = walk_state->results; |
| 224 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 225 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 226 | "Warning: No result object pushed! State=%p\n", |
| 227 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | return (AE_NOT_EXIST); |
| 229 | } |
| 230 | |
| 231 | if (!state->results.num_results) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 232 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 233 | "No result objects! State=%p\n", walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | return (AE_AML_NO_RETURN_VALUE); |
| 235 | } |
| 236 | |
| 237 | /* Remove Bottom element */ |
| 238 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 239 | *object = state->results.obj_desc[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
| 241 | /* Push entire stack down one element */ |
| 242 | |
| 243 | for (index = 0; index < state->results.num_results; index++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 244 | state->results.obj_desc[index] = |
| 245 | state->results.obj_desc[index + 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | state->results.num_results--; |
| 249 | |
| 250 | /* Check for a valid result object */ |
| 251 | |
| 252 | if (!*object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 253 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 254 | "Null operand! State=%p #Ops=%X Index=%X\n", |
| 255 | walk_state, state->results.num_results, |
| 256 | (u32) index)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | return (AE_AML_NO_RETURN_VALUE); |
| 258 | } |
| 259 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 260 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", |
| 261 | *object, |
| 262 | (*object) ? acpi_ut_get_object_type_name(*object) : |
| 263 | "NULL", state, walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
| 265 | return (AE_OK); |
| 266 | } |
| 267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | /******************************************************************************* |
| 269 | * |
| 270 | * FUNCTION: acpi_ds_result_push |
| 271 | * |
| 272 | * PARAMETERS: Object - Where to return the popped object |
| 273 | * walk_state - Current Walk state |
| 274 | * |
| 275 | * RETURN: Status |
| 276 | * |
| 277 | * DESCRIPTION: Push an object onto the current result stack |
| 278 | * |
| 279 | ******************************************************************************/ |
| 280 | |
| 281 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 282 | acpi_ds_result_push(union acpi_operand_object * object, |
| 283 | struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 285 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 287 | ACPI_FUNCTION_NAME("ds_result_push"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
| 289 | state = walk_state->results; |
| 290 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 291 | ACPI_REPORT_ERROR(("No result stack frame during push\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | return (AE_AML_INTERNAL); |
| 293 | } |
| 294 | |
| 295 | if (state->results.num_results == ACPI_OBJ_NUM_OPERANDS) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 296 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 297 | "Result stack overflow: Obj=%p State=%p Num=%X\n", |
| 298 | object, walk_state, |
| 299 | state->results.num_results)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | return (AE_STACK_OVERFLOW); |
| 301 | } |
| 302 | |
| 303 | if (!object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 304 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 305 | "Null Object! Obj=%p State=%p Num=%X\n", |
| 306 | object, walk_state, |
| 307 | state->results.num_results)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | return (AE_BAD_PARAMETER); |
| 309 | } |
| 310 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 311 | state->results.obj_desc[state->results.num_results] = object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | state->results.num_results++; |
| 313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 314 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", |
| 315 | object, |
| 316 | object ? |
| 317 | acpi_ut_get_object_type_name((union |
| 318 | acpi_operand_object *) |
| 319 | object) : "NULL", |
| 320 | walk_state, state->results.num_results, |
| 321 | walk_state->current_result)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
| 323 | return (AE_OK); |
| 324 | } |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | /******************************************************************************* |
| 327 | * |
| 328 | * FUNCTION: acpi_ds_result_stack_push |
| 329 | * |
| 330 | * PARAMETERS: walk_state - Current Walk state |
| 331 | * |
| 332 | * RETURN: Status |
| 333 | * |
| 334 | * DESCRIPTION: Push an object onto the walk_state result stack. |
| 335 | * |
| 336 | ******************************************************************************/ |
| 337 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 338 | acpi_status acpi_ds_result_stack_push(struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 340 | union acpi_generic_state *state; |
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_FUNCTION_NAME("ds_result_stack_push"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 344 | state = acpi_ut_create_generic_state(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | if (!state) { |
| 346 | return (AE_NO_MEMORY); |
| 347 | } |
| 348 | |
| 349 | state->common.data_type = ACPI_DESC_TYPE_STATE_RESULT; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 350 | acpi_ut_push_generic_state(&walk_state->results, state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 352 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Results=%p State=%p\n", |
| 353 | state, walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
| 355 | return (AE_OK); |
| 356 | } |
| 357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | /******************************************************************************* |
| 359 | * |
| 360 | * FUNCTION: acpi_ds_result_stack_pop |
| 361 | * |
| 362 | * PARAMETERS: walk_state - Current Walk state |
| 363 | * |
| 364 | * RETURN: Status |
| 365 | * |
| 366 | * DESCRIPTION: Pop an object off of the walk_state result stack. |
| 367 | * |
| 368 | ******************************************************************************/ |
| 369 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 370 | acpi_status acpi_ds_result_stack_pop(struct acpi_walk_state * walk_state) |
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 | union acpi_generic_state *state; |
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_FUNCTION_NAME("ds_result_stack_pop"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
| 376 | /* Check for stack underflow */ |
| 377 | |
| 378 | if (walk_state->results == NULL) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 379 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Underflow - State=%p\n", |
| 380 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | return (AE_AML_NO_OPERAND); |
| 382 | } |
| 383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 384 | state = acpi_ut_pop_generic_state(&walk_state->results); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 386 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 387 | "Result=%p remaining_results=%X State=%p\n", |
| 388 | state, state->results.num_results, walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 390 | acpi_ut_delete_generic_state(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
| 392 | return (AE_OK); |
| 393 | } |
| 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | /******************************************************************************* |
| 396 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | * FUNCTION: acpi_ds_obj_stack_push |
| 398 | * |
| 399 | * PARAMETERS: Object - Object to push |
| 400 | * walk_state - Current Walk state |
| 401 | * |
| 402 | * RETURN: Status |
| 403 | * |
| 404 | * DESCRIPTION: Push an object onto this walk's object/operand stack |
| 405 | * |
| 406 | ******************************************************************************/ |
| 407 | |
| 408 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 409 | acpi_ds_obj_stack_push(void *object, struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 411 | ACPI_FUNCTION_NAME("ds_obj_stack_push"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | |
| 413 | /* Check for stack overflow */ |
| 414 | |
| 415 | if (walk_state->num_operands >= ACPI_OBJ_NUM_OPERANDS) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 416 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 417 | "overflow! Obj=%p State=%p #Ops=%X\n", |
| 418 | object, walk_state, |
| 419 | walk_state->num_operands)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | return (AE_STACK_OVERFLOW); |
| 421 | } |
| 422 | |
| 423 | /* Put the object onto the stack */ |
| 424 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 425 | walk_state->operands[walk_state->num_operands] = object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | walk_state->num_operands++; |
| 427 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 428 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", |
| 429 | object, |
| 430 | acpi_ut_get_object_type_name((union |
| 431 | acpi_operand_object *) |
| 432 | object), walk_state, |
| 433 | walk_state->num_operands)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | |
| 435 | return (AE_OK); |
| 436 | } |
| 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | /******************************************************************************* |
| 439 | * |
| 440 | * FUNCTION: acpi_ds_obj_stack_pop |
| 441 | * |
| 442 | * PARAMETERS: pop_count - Number of objects/entries to pop |
| 443 | * walk_state - Current Walk state |
| 444 | * |
| 445 | * RETURN: Status |
| 446 | * |
| 447 | * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT |
| 448 | * deleted by this routine. |
| 449 | * |
| 450 | ******************************************************************************/ |
| 451 | |
| 452 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 453 | acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 455 | u32 i; |
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 | ACPI_FUNCTION_NAME("ds_obj_stack_pop"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | |
| 459 | for (i = 0; i < pop_count; i++) { |
| 460 | /* Check for stack underflow */ |
| 461 | |
| 462 | if (walk_state->num_operands == 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 463 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 464 | "Underflow! Count=%X State=%p #Ops=%X\n", |
| 465 | pop_count, walk_state, |
| 466 | walk_state->num_operands)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | return (AE_STACK_UNDERFLOW); |
| 468 | } |
| 469 | |
| 470 | /* Just set the stack entry to null */ |
| 471 | |
| 472 | walk_state->num_operands--; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 473 | walk_state->operands[walk_state->num_operands] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 476 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | pop_count, walk_state, walk_state->num_operands)); |
| 478 | |
| 479 | return (AE_OK); |
| 480 | } |
| 481 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | /******************************************************************************* |
| 483 | * |
| 484 | * FUNCTION: acpi_ds_obj_stack_pop_and_delete |
| 485 | * |
| 486 | * PARAMETERS: pop_count - Number of objects/entries to pop |
| 487 | * walk_state - Current Walk state |
| 488 | * |
| 489 | * RETURN: Status |
| 490 | * |
| 491 | * DESCRIPTION: Pop this walk's object stack and delete each object that is |
| 492 | * popped off. |
| 493 | * |
| 494 | ******************************************************************************/ |
| 495 | |
| 496 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 497 | acpi_ds_obj_stack_pop_and_delete(u32 pop_count, |
| 498 | struct acpi_walk_state * walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 500 | u32 i; |
| 501 | union acpi_operand_object *obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 503 | ACPI_FUNCTION_NAME("ds_obj_stack_pop_and_delete"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | for (i = 0; i < pop_count; i++) { |
| 506 | /* Check for stack underflow */ |
| 507 | |
| 508 | if (walk_state->num_operands == 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 509 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 510 | "Underflow! Count=%X State=%p #Ops=%X\n", |
| 511 | pop_count, walk_state, |
| 512 | walk_state->num_operands)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | return (AE_STACK_UNDERFLOW); |
| 514 | } |
| 515 | |
| 516 | /* Pop the stack and delete an object if present in this stack entry */ |
| 517 | |
| 518 | walk_state->num_operands--; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 519 | obj_desc = walk_state->operands[walk_state->num_operands]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | if (obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 521 | acpi_ut_remove_reference(walk_state-> |
| 522 | operands[walk_state-> |
| 523 | num_operands]); |
| 524 | walk_state->operands[walk_state->num_operands] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } |
| 526 | } |
| 527 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 528 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | pop_count, walk_state, walk_state->num_operands)); |
| 530 | |
| 531 | return (AE_OK); |
| 532 | } |
| 533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | /******************************************************************************* |
| 535 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | * FUNCTION: acpi_ds_get_current_walk_state |
| 537 | * |
| 538 | * PARAMETERS: Thread - Get current active state for this Thread |
| 539 | * |
| 540 | * RETURN: Pointer to the current walk state |
| 541 | * |
| 542 | * DESCRIPTION: Get the walk state that is at the head of the list (the "current" |
| 543 | * walk state.) |
| 544 | * |
| 545 | ******************************************************************************/ |
| 546 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 547 | struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state |
| 548 | *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 550 | ACPI_FUNCTION_NAME("ds_get_current_walk_state"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
| 552 | if (!thread) { |
| 553 | return (NULL); |
| 554 | } |
| 555 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 556 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Current walk_state %p\n", |
| 557 | thread->walk_state_list)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
| 559 | return (thread->walk_state_list); |
| 560 | } |
| 561 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | /******************************************************************************* |
| 563 | * |
| 564 | * FUNCTION: acpi_ds_push_walk_state |
| 565 | * |
| 566 | * PARAMETERS: walk_state - State to push |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 567 | * Thread - Thread state object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | * |
| 569 | * RETURN: None |
| 570 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 571 | * DESCRIPTION: Place the Thread state at the head of the state list. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | * |
| 573 | ******************************************************************************/ |
| 574 | |
| 575 | void |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 576 | acpi_ds_push_walk_state(struct acpi_walk_state *walk_state, |
| 577 | struct acpi_thread_state *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 579 | ACPI_FUNCTION_TRACE("ds_push_walk_state"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 581 | walk_state->next = thread->walk_state_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | thread->walk_state_list = walk_state; |
| 583 | |
| 584 | return_VOID; |
| 585 | } |
| 586 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | /******************************************************************************* |
| 588 | * |
| 589 | * FUNCTION: acpi_ds_pop_walk_state |
| 590 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 591 | * PARAMETERS: Thread - Current thread state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 593 | * RETURN: A walk_state object popped from the thread's stack |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | * |
| 595 | * DESCRIPTION: Remove and return the walkstate object that is at the head of |
| 596 | * the walk stack for the given walk list. NULL indicates that |
| 597 | * the list is empty. |
| 598 | * |
| 599 | ******************************************************************************/ |
| 600 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 601 | struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 603 | struct acpi_walk_state *walk_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 605 | ACPI_FUNCTION_TRACE("ds_pop_walk_state"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
| 607 | walk_state = thread->walk_state_list; |
| 608 | |
| 609 | if (walk_state) { |
| 610 | /* Next walk state becomes the current walk state */ |
| 611 | |
| 612 | thread->walk_state_list = walk_state->next; |
| 613 | |
| 614 | /* |
| 615 | * Don't clear the NEXT field, this serves as an indicator |
| 616 | * that there is a parent WALK STATE |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 617 | * Do Not: walk_state->Next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | */ |
| 619 | } |
| 620 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 621 | return_PTR(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | } |
| 623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | /******************************************************************************* |
| 625 | * |
| 626 | * FUNCTION: acpi_ds_create_walk_state |
| 627 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 628 | * PARAMETERS: owner_id - ID for object creation |
| 629 | * Origin - Starting point for this walk |
| 630 | * mth_desc - Method object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | * Thread - Current thread state |
| 632 | * |
| 633 | * RETURN: Pointer to the new walk state. |
| 634 | * |
| 635 | * DESCRIPTION: Allocate and initialize a new walk state. The current walk |
| 636 | * state is set to this new state. |
| 637 | * |
| 638 | ******************************************************************************/ |
| 639 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 640 | struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, |
| 641 | union acpi_parse_object |
| 642 | *origin, |
| 643 | union acpi_operand_object |
| 644 | *mth_desc, |
| 645 | struct acpi_thread_state |
| 646 | *thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 648 | struct acpi_walk_state *walk_state; |
| 649 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 651 | ACPI_FUNCTION_TRACE("ds_create_walk_state"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 653 | walk_state = ACPI_MEM_CALLOCATE(sizeof(struct acpi_walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | if (!walk_state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 655 | return_PTR(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | } |
| 657 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 658 | walk_state->data_type = ACPI_DESC_TYPE_WALK; |
| 659 | walk_state->owner_id = owner_id; |
| 660 | walk_state->origin = origin; |
| 661 | walk_state->method_desc = mth_desc; |
| 662 | walk_state->thread = thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
| 664 | walk_state->parser_state.start_op = origin; |
| 665 | |
| 666 | /* Init the method args/local */ |
| 667 | |
| 668 | #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 669 | acpi_ds_method_data_init(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | #endif |
| 671 | |
| 672 | /* Create an initial result stack entry */ |
| 673 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 674 | status = acpi_ds_result_stack_push(walk_state); |
| 675 | if (ACPI_FAILURE(status)) { |
| 676 | ACPI_MEM_FREE(walk_state); |
| 677 | return_PTR(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | /* Put the new state at the head of the walk list */ |
| 681 | |
| 682 | if (thread) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 683 | acpi_ds_push_walk_state(walk_state, thread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | } |
| 685 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 686 | return_PTR(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | } |
| 688 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | /******************************************************************************* |
| 690 | * |
| 691 | * FUNCTION: acpi_ds_init_aml_walk |
| 692 | * |
| 693 | * PARAMETERS: walk_state - New state to be initialized |
| 694 | * Op - Current parse op |
| 695 | * method_node - Control method NS node, if any |
| 696 | * aml_start - Start of AML |
| 697 | * aml_length - Length of AML |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 698 | * Info - Method info block (params, etc.) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | * pass_number - 1, 2, or 3 |
| 700 | * |
| 701 | * RETURN: Status |
| 702 | * |
| 703 | * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk |
| 704 | * |
| 705 | ******************************************************************************/ |
| 706 | |
| 707 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 708 | acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state, |
| 709 | union acpi_parse_object *op, |
| 710 | struct acpi_namespace_node *method_node, |
| 711 | u8 * aml_start, |
| 712 | u32 aml_length, |
| 713 | struct acpi_parameter_info *info, u8 pass_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 715 | acpi_status status; |
| 716 | struct acpi_parse_state *parser_state = &walk_state->parser_state; |
| 717 | union acpi_parse_object *extra_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 719 | ACPI_FUNCTION_TRACE("ds_init_aml_walk"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 721 | walk_state->parser_state.aml = |
| 722 | walk_state->parser_state.aml_start = aml_start; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | walk_state->parser_state.aml_end = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 724 | walk_state->parser_state.pkg_end = aml_start + aml_length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
| 726 | /* The next_op of the next_walk will be the beginning of the method */ |
| 727 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 728 | walk_state->next_op = NULL; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 729 | walk_state->pass_number = pass_number; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | |
| 731 | if (info) { |
| 732 | if (info->parameter_type == ACPI_PARAM_GPE) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 733 | walk_state->gpe_event_info = |
| 734 | ACPI_CAST_PTR(struct acpi_gpe_event_info, |
| 735 | info->parameters); |
| 736 | } else { |
| 737 | walk_state->params = info->parameters; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 738 | walk_state->caller_return_desc = &info->return_object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | } |
| 740 | } |
| 741 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 742 | status = acpi_ps_init_scope(&walk_state->parser_state, op); |
| 743 | if (ACPI_FAILURE(status)) { |
| 744 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | if (method_node) { |
| 748 | walk_state->parser_state.start_node = method_node; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 749 | walk_state->walk_type = ACPI_WALK_METHOD; |
| 750 | walk_state->method_node = method_node; |
| 751 | walk_state->method_desc = |
| 752 | acpi_ns_get_attached_object(method_node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | |
| 754 | /* Push start scope on scope stack and make it current */ |
| 755 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 756 | status = |
| 757 | acpi_ds_scope_stack_push(method_node, ACPI_TYPE_METHOD, |
| 758 | walk_state); |
| 759 | if (ACPI_FAILURE(status)) { |
| 760 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
| 762 | |
| 763 | /* Init the method arguments */ |
| 764 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 765 | status = acpi_ds_method_data_init_args(walk_state->params, |
| 766 | ACPI_METHOD_NUM_ARGS, |
| 767 | walk_state); |
| 768 | if (ACPI_FAILURE(status)) { |
| 769 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 771 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | /* |
| 773 | * Setup the current scope. |
| 774 | * Find a Named Op that has a namespace node associated with it. |
| 775 | * search upwards from this Op. Current scope is the first |
| 776 | * Op with a namespace node. |
| 777 | */ |
| 778 | extra_op = parser_state->start_op; |
| 779 | while (extra_op && !extra_op->common.node) { |
| 780 | extra_op = extra_op->common.parent; |
| 781 | } |
| 782 | |
| 783 | if (!extra_op) { |
| 784 | parser_state->start_node = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 785 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | parser_state->start_node = extra_op->common.node; |
| 787 | } |
| 788 | |
| 789 | if (parser_state->start_node) { |
| 790 | /* Push start scope on scope stack and make it current */ |
| 791 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 792 | status = |
| 793 | acpi_ds_scope_stack_push(parser_state->start_node, |
| 794 | parser_state->start_node-> |
| 795 | type, walk_state); |
| 796 | if (ACPI_FAILURE(status)) { |
| 797 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 802 | status = acpi_ds_init_callbacks(walk_state, pass_number); |
| 803 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | } |
| 805 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | /******************************************************************************* |
| 807 | * |
| 808 | * FUNCTION: acpi_ds_delete_walk_state |
| 809 | * |
| 810 | * PARAMETERS: walk_state - State to delete |
| 811 | * |
| 812 | * RETURN: Status |
| 813 | * |
| 814 | * DESCRIPTION: Delete a walk state including all internal data structures |
| 815 | * |
| 816 | ******************************************************************************/ |
| 817 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 818 | void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 820 | union acpi_generic_state *state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 822 | ACPI_FUNCTION_TRACE_PTR("ds_delete_walk_state", walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | |
| 824 | if (!walk_state) { |
| 825 | return; |
| 826 | } |
| 827 | |
| 828 | if (walk_state->data_type != ACPI_DESC_TYPE_WALK) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 829 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 830 | "%p is not a valid walk state\n", |
| 831 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | return; |
| 833 | } |
| 834 | |
| 835 | if (walk_state->parser_state.scope) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 836 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 837 | "%p walk still has a scope list\n", |
| 838 | walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | /* Always must free any linked control states */ |
| 842 | |
| 843 | while (walk_state->control_state) { |
| 844 | state = walk_state->control_state; |
| 845 | walk_state->control_state = state->common.next; |
| 846 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 847 | acpi_ut_delete_generic_state(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | /* Always must free any linked parse states */ |
| 851 | |
| 852 | while (walk_state->scope_info) { |
| 853 | state = walk_state->scope_info; |
| 854 | walk_state->scope_info = state->common.next; |
| 855 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 856 | acpi_ut_delete_generic_state(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | /* Always must free any stacked result states */ |
| 860 | |
| 861 | while (walk_state->results) { |
| 862 | state = walk_state->results; |
| 863 | walk_state->results = state->common.next; |
| 864 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 865 | acpi_ut_delete_generic_state(state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 866 | } |
| 867 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 868 | ACPI_MEM_FREE(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | return_VOID; |
| 870 | } |
| 871 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 872 | #ifdef ACPI_OBSOLETE_FUNCTIONS |
| 873 | /******************************************************************************* |
| 874 | * |
| 875 | * FUNCTION: acpi_ds_result_insert |
| 876 | * |
| 877 | * PARAMETERS: Object - Object to push |
| 878 | * Index - Where to insert the object |
| 879 | * walk_state - Current Walk state |
| 880 | * |
| 881 | * RETURN: Status |
| 882 | * |
| 883 | * DESCRIPTION: Insert an object onto this walk's result stack |
| 884 | * |
| 885 | ******************************************************************************/ |
| 886 | |
| 887 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 888 | acpi_ds_result_insert(void *object, |
| 889 | u32 index, struct acpi_walk_state *walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 890 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 891 | union acpi_generic_state *state; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 892 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 893 | ACPI_FUNCTION_NAME("ds_result_insert"); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 894 | |
| 895 | state = walk_state->results; |
| 896 | if (!state) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 897 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 898 | "No result object pushed! State=%p\n", |
| 899 | walk_state)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 900 | return (AE_NOT_EXIST); |
| 901 | } |
| 902 | |
| 903 | if (index >= ACPI_OBJ_NUM_OPERANDS) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 904 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 905 | "Index out of range: %X Obj=%p State=%p Num=%X\n", |
| 906 | index, object, walk_state, |
| 907 | state->results.num_results)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 908 | return (AE_BAD_PARAMETER); |
| 909 | } |
| 910 | |
| 911 | if (!object) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 912 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 913 | "Null Object! Index=%X Obj=%p State=%p Num=%X\n", |
| 914 | index, object, walk_state, |
| 915 | state->results.num_results)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 916 | return (AE_BAD_PARAMETER); |
| 917 | } |
| 918 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 919 | state->results.obj_desc[index] = object; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 920 | state->results.num_results++; |
| 921 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 922 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
| 923 | "Obj=%p [%s] State=%p Num=%X Cur=%X\n", |
| 924 | object, |
| 925 | object ? |
| 926 | acpi_ut_get_object_type_name((union |
| 927 | acpi_operand_object *) |
| 928 | object) : "NULL", |
| 929 | walk_state, state->results.num_results, |
| 930 | walk_state->current_result)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 931 | |
| 932 | return (AE_OK); |
| 933 | } |
| 934 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 935 | /******************************************************************************* |
| 936 | * |
| 937 | * FUNCTION: acpi_ds_obj_stack_delete_all |
| 938 | * |
| 939 | * PARAMETERS: walk_state - Current Walk state |
| 940 | * |
| 941 | * RETURN: Status |
| 942 | * |
| 943 | * DESCRIPTION: Clear the object stack by deleting all objects that are on it. |
| 944 | * Should be used with great care, if at all! |
| 945 | * |
| 946 | ******************************************************************************/ |
| 947 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 948 | acpi_status acpi_ds_obj_stack_delete_all(struct acpi_walk_state * walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 949 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 950 | u32 i; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 951 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 952 | ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_delete_all", walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 953 | |
| 954 | /* The stack size is configurable, but fixed */ |
| 955 | |
| 956 | for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) { |
| 957 | if (walk_state->operands[i]) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 958 | acpi_ut_remove_reference(walk_state->operands[i]); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 959 | walk_state->operands[i] = NULL; |
| 960 | } |
| 961 | } |
| 962 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 963 | return_ACPI_STATUS(AE_OK); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 964 | } |
| 965 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 966 | /******************************************************************************* |
| 967 | * |
| 968 | * FUNCTION: acpi_ds_obj_stack_pop_object |
| 969 | * |
| 970 | * PARAMETERS: Object - Where to return the popped object |
| 971 | * walk_state - Current Walk state |
| 972 | * |
| 973 | * RETURN: Status |
| 974 | * |
| 975 | * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT |
| 976 | * deleted by this routine. |
| 977 | * |
| 978 | ******************************************************************************/ |
| 979 | |
| 980 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 981 | acpi_ds_obj_stack_pop_object(union acpi_operand_object **object, |
| 982 | struct acpi_walk_state *walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 983 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 984 | ACPI_FUNCTION_NAME("ds_obj_stack_pop_object"); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 985 | |
| 986 | /* Check for stack underflow */ |
| 987 | |
| 988 | if (walk_state->num_operands == 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 989 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 990 | "Missing operand/stack empty! State=%p #Ops=%X\n", |
| 991 | walk_state, walk_state->num_operands)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 992 | *object = NULL; |
| 993 | return (AE_AML_NO_OPERAND); |
| 994 | } |
| 995 | |
| 996 | /* Pop the stack */ |
| 997 | |
| 998 | walk_state->num_operands--; |
| 999 | |
| 1000 | /* Check for a valid operand */ |
| 1001 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1002 | if (!walk_state->operands[walk_state->num_operands]) { |
| 1003 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
| 1004 | "Null operand! State=%p #Ops=%X\n", |
| 1005 | walk_state, walk_state->num_operands)); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1006 | *object = NULL; |
| 1007 | return (AE_AML_NO_OPERAND); |
| 1008 | } |
| 1009 | |
| 1010 | /* Get operand and set stack entry to null */ |
| 1011 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1012 | *object = walk_state->operands[walk_state->num_operands]; |
| 1013 | walk_state->operands[walk_state->num_operands] = NULL; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1014 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1015 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", |
| 1016 | *object, acpi_ut_get_object_type_name(*object), |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1017 | walk_state, walk_state->num_operands)); |
| 1018 | |
| 1019 | return (AE_OK); |
| 1020 | } |
| 1021 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1022 | /******************************************************************************* |
| 1023 | * |
| 1024 | * FUNCTION: acpi_ds_obj_stack_get_value |
| 1025 | * |
| 1026 | * PARAMETERS: Index - Stack index whose value is desired. Based |
| 1027 | * on the top of the stack (index=0 == top) |
| 1028 | * walk_state - Current Walk state |
| 1029 | * |
| 1030 | * RETURN: Pointer to the requested operand |
| 1031 | * |
| 1032 | * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must |
| 1033 | * be within the range of the current stack pointer. |
| 1034 | * |
| 1035 | ******************************************************************************/ |
| 1036 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1037 | void *acpi_ds_obj_stack_get_value(u32 index, struct acpi_walk_state *walk_state) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1038 | { |
| 1039 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1040 | ACPI_FUNCTION_TRACE_PTR("ds_obj_stack_get_value", walk_state); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1041 | |
| 1042 | /* Can't do it if the stack is empty */ |
| 1043 | |
| 1044 | if (walk_state->num_operands == 0) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1045 | return_PTR(NULL); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | /* or if the index is past the top of the stack */ |
| 1049 | |
| 1050 | if (index > (walk_state->num_operands - (u32) 1)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1051 | return_PTR(NULL); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1052 | } |
| 1053 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame^] | 1054 | return_PTR(walk_state-> |
| 1055 | operands[(acpi_native_uint) (walk_state->num_operands - 1) - |
| 1056 | index]); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1057 | } |
| 1058 | #endif |