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