Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: dsopcode - Dispatcher Op Region support and handling of |
| 4 | * "control" opcodes |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2008, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> |
| 46 | #include <acpi/acparser.h> |
| 47 | #include <acpi/amlcode.h> |
| 48 | #include <acpi/acdispat.h> |
| 49 | #include <acpi/acinterp.h> |
| 50 | #include <acpi/acnamesp.h> |
| 51 | #include <acpi/acevents.h> |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 52 | #include <acpi/actables.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | #define _COMPONENT ACPI_DISPATCHER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 55 | ACPI_MODULE_NAME("dsopcode") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 57 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 58 | static acpi_status |
| 59 | acpi_ds_execute_arguments(struct acpi_namespace_node *node, |
| 60 | struct acpi_namespace_node *scope_node, |
| 61 | u32 aml_length, u8 * aml_start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 63 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | acpi_ds_init_buffer_field(u16 aml_opcode, |
| 65 | union acpi_operand_object *obj_desc, |
| 66 | union acpi_operand_object *buffer_desc, |
| 67 | union acpi_operand_object *offset_desc, |
| 68 | union acpi_operand_object *length_desc, |
| 69 | union acpi_operand_object *result_desc); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 70 | |
| 71 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | * |
| 73 | * FUNCTION: acpi_ds_execute_arguments |
| 74 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 75 | * PARAMETERS: Node - Object NS node |
| 76 | * scope_node - Parent NS node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | * aml_length - Length of executable AML |
| 78 | * aml_start - Pointer to the AML |
| 79 | * |
| 80 | * RETURN: Status. |
| 81 | * |
| 82 | * DESCRIPTION: Late (deferred) execution of region or field arguments |
| 83 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 84 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 86 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 87 | acpi_ds_execute_arguments(struct acpi_namespace_node *node, |
| 88 | struct acpi_namespace_node *scope_node, |
| 89 | u32 aml_length, u8 * aml_start) |
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_status status; |
| 92 | union acpi_parse_object *op; |
| 93 | struct acpi_walk_state *walk_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 95 | ACPI_FUNCTION_TRACE(ds_execute_arguments); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * Allocate a new parser op to be the root of the parsed tree |
| 99 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 100 | op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | if (!op) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 102 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /* Save the Node for use in acpi_ps_parse_aml */ |
| 106 | |
| 107 | op->common.node = scope_node; |
| 108 | |
| 109 | /* Create and initialize a new parser state */ |
| 110 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 111 | walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | if (!walk_state) { |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 113 | status = AE_NO_MEMORY; |
| 114 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, |
Bob Moore | ec3153f | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 118 | aml_length, NULL, ACPI_IMODE_LOAD_PASS1); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | if (ACPI_FAILURE(status)) { |
| 120 | acpi_ds_delete_walk_state(walk_state); |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 121 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /* Mark this parse as a deferred opcode */ |
| 125 | |
| 126 | walk_state->parse_flags = ACPI_PARSE_DEFERRED_OP; |
| 127 | walk_state->deferred_node = node; |
| 128 | |
| 129 | /* Pass1: Parse the entire declaration */ |
| 130 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 131 | status = acpi_ps_parse_aml(walk_state); |
| 132 | if (ACPI_FAILURE(status)) { |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 133 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* Get and init the Op created above */ |
| 137 | |
| 138 | op->common.node = node; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 139 | acpi_ps_delete_parse_tree(op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | /* Evaluate the deferred arguments */ |
| 142 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | op = acpi_ps_alloc_op(AML_INT_EVAL_SUBTREE_OP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | if (!op) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | op->common.node = scope_node; |
| 149 | |
| 150 | /* Create and initialize a new parser state */ |
| 151 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | walk_state = acpi_ds_create_walk_state(0, NULL, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | if (!walk_state) { |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 154 | status = AE_NO_MEMORY; |
| 155 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* Execute the opcode and arguments */ |
| 159 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 160 | status = acpi_ds_init_aml_walk(walk_state, op, NULL, aml_start, |
Bob Moore | ec3153f | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 161 | aml_length, NULL, ACPI_IMODE_EXECUTE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 162 | if (ACPI_FAILURE(status)) { |
| 163 | acpi_ds_delete_walk_state(walk_state); |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 164 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | /* Mark this execution as a deferred opcode */ |
| 168 | |
| 169 | walk_state->deferred_node = node; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 170 | status = acpi_ps_parse_aml(walk_state); |
Robert Moore | 88ac00f | 2005-05-26 00:00:00 -0400 | [diff] [blame] | 171 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 172 | cleanup: |
| 173 | acpi_ps_delete_parse_tree(op); |
| 174 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 177 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | * |
| 179 | * FUNCTION: acpi_ds_get_buffer_field_arguments |
| 180 | * |
| 181 | * PARAMETERS: obj_desc - A valid buffer_field object |
| 182 | * |
| 183 | * RETURN: Status. |
| 184 | * |
| 185 | * DESCRIPTION: Get buffer_field Buffer and Index. This implements the late |
| 186 | * evaluation of these field attributes. |
| 187 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 188 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 191 | acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | union acpi_operand_object *extra_desc; |
| 194 | struct acpi_namespace_node *node; |
| 195 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 197 | ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_field_arguments, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 200 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | /* Get the AML pointer (method object) and buffer_field node */ |
| 204 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | extra_desc = acpi_ns_get_secondary_object(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | node = obj_desc->buffer_field.node; |
| 207 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 208 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
| 209 | (ACPI_TYPE_BUFFER_FIELD, node, NULL)); |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 210 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BufferField Arg Init\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | acpi_ut_get_node_name(node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
| 213 | /* Execute the AML code for the term_arg arguments */ |
| 214 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 215 | status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), |
| 216 | extra_desc->extra.aml_length, |
| 217 | extra_desc->extra.aml_start); |
| 218 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 221 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | * |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 223 | * FUNCTION: acpi_ds_get_bank_field_arguments |
| 224 | * |
| 225 | * PARAMETERS: obj_desc - A valid bank_field object |
| 226 | * |
| 227 | * RETURN: Status. |
| 228 | * |
| 229 | * DESCRIPTION: Get bank_field bank_value. This implements the late |
| 230 | * evaluation of these field attributes. |
| 231 | * |
| 232 | ******************************************************************************/ |
| 233 | |
| 234 | acpi_status |
| 235 | acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc) |
| 236 | { |
| 237 | union acpi_operand_object *extra_desc; |
| 238 | struct acpi_namespace_node *node; |
| 239 | acpi_status status; |
| 240 | |
| 241 | ACPI_FUNCTION_TRACE_PTR(ds_get_bank_field_arguments, obj_desc); |
| 242 | |
| 243 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
| 244 | return_ACPI_STATUS(AE_OK); |
| 245 | } |
| 246 | |
| 247 | /* Get the AML pointer (method object) and bank_field node */ |
| 248 | |
| 249 | extra_desc = acpi_ns_get_secondary_object(obj_desc); |
| 250 | node = obj_desc->bank_field.node; |
| 251 | |
| 252 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
| 253 | (ACPI_TYPE_LOCAL_BANK_FIELD, node, NULL)); |
| 254 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n", |
| 255 | acpi_ut_get_node_name(node))); |
| 256 | |
| 257 | /* Execute the AML code for the term_arg arguments */ |
| 258 | |
| 259 | status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), |
| 260 | extra_desc->extra.aml_length, |
| 261 | extra_desc->extra.aml_start); |
| 262 | return_ACPI_STATUS(status); |
| 263 | } |
| 264 | |
| 265 | /******************************************************************************* |
| 266 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | * FUNCTION: acpi_ds_get_buffer_arguments |
| 268 | * |
| 269 | * PARAMETERS: obj_desc - A valid Buffer object |
| 270 | * |
| 271 | * RETURN: Status. |
| 272 | * |
| 273 | * DESCRIPTION: Get Buffer length and initializer byte list. This implements |
| 274 | * the late evaluation of these attributes. |
| 275 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 276 | ******************************************************************************/ |
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 | acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc) |
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 | struct acpi_namespace_node *node; |
| 281 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 283 | ACPI_FUNCTION_TRACE_PTR(ds_get_buffer_arguments, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
| 285 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 286 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /* Get the Buffer node */ |
| 290 | |
| 291 | node = obj_desc->buffer.node; |
| 292 | if (!node) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 293 | ACPI_ERROR((AE_INFO, |
| 294 | "No pointer back to NS node in buffer obj %p", |
| 295 | obj_desc)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 299 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Buffer Arg Init\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | /* Execute the AML code for the term_arg arguments */ |
| 302 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | status = acpi_ds_execute_arguments(node, node, |
| 304 | obj_desc->buffer.aml_length, |
| 305 | obj_desc->buffer.aml_start); |
| 306 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 309 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | * |
| 311 | * FUNCTION: acpi_ds_get_package_arguments |
| 312 | * |
| 313 | * PARAMETERS: obj_desc - A valid Package object |
| 314 | * |
| 315 | * RETURN: Status. |
| 316 | * |
| 317 | * DESCRIPTION: Get Package length and initializer byte list. This implements |
| 318 | * the late evaluation of these attributes. |
| 319 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 320 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 322 | acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 324 | struct acpi_namespace_node *node; |
| 325 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 327 | ACPI_FUNCTION_TRACE_PTR(ds_get_package_arguments, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | if (obj_desc->common.flags & AOPOBJ_DATA_VALID) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 330 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | /* Get the Package node */ |
| 334 | |
| 335 | node = obj_desc->package.node; |
| 336 | if (!node) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 337 | ACPI_ERROR((AE_INFO, |
| 338 | "No pointer back to NS node in package %p", |
| 339 | obj_desc)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Package Arg Init\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | /* Execute the AML code for the term_arg arguments */ |
| 346 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 347 | status = acpi_ds_execute_arguments(node, node, |
| 348 | obj_desc->package.aml_length, |
| 349 | obj_desc->package.aml_start); |
| 350 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | /***************************************************************************** |
| 354 | * |
| 355 | * FUNCTION: acpi_ds_get_region_arguments |
| 356 | * |
| 357 | * PARAMETERS: obj_desc - A valid region object |
| 358 | * |
| 359 | * RETURN: Status. |
| 360 | * |
| 361 | * DESCRIPTION: Get region address and length. This implements the late |
| 362 | * evaluation of these region attributes. |
| 363 | * |
| 364 | ****************************************************************************/ |
| 365 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 366 | acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 368 | struct acpi_namespace_node *node; |
| 369 | acpi_status status; |
| 370 | union acpi_operand_object *extra_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 372 | ACPI_FUNCTION_TRACE_PTR(ds_get_region_arguments, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
| 374 | if (obj_desc->region.flags & AOPOBJ_DATA_VALID) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 375 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | extra_desc = acpi_ns_get_secondary_object(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | if (!extra_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 380 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /* Get the Region node */ |
| 384 | |
| 385 | node = obj_desc->region.node; |
| 386 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 387 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname |
| 388 | (ACPI_TYPE_REGION, node, NULL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 390 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[%4.4s] OpRegion Arg Init at AML %p\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | acpi_ut_get_node_name(node), |
| 392 | extra_desc->extra.aml_start)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
| 394 | /* Execute the argument AML */ |
| 395 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 396 | status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), |
| 397 | extra_desc->extra.aml_length, |
| 398 | extra_desc->extra.aml_start); |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 399 | if (ACPI_FAILURE(status)) { |
| 400 | return_ACPI_STATUS(status); |
| 401 | } |
| 402 | |
| 403 | /* Validate the region address/length via the host OS */ |
| 404 | |
| 405 | status = acpi_os_validate_address(obj_desc->region.space_id, |
| 406 | obj_desc->region.address, |
Thomas Renninger | df92e69 | 2008-02-04 23:31:22 -0800 | [diff] [blame] | 407 | (acpi_size) obj_desc->region.length, |
| 408 | acpi_ut_get_node_name(node)); |
| 409 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 410 | if (ACPI_FAILURE(status)) { |
| 411 | /* |
| 412 | * Invalid address/length. We will emit an error message and mark |
| 413 | * the region as invalid, so that it will cause an additional error if |
| 414 | * it is ever used. Then return AE_OK. |
| 415 | */ |
| 416 | ACPI_EXCEPTION((AE_INFO, status, |
| 417 | "During address validation of OpRegion [%4.4s]", |
| 418 | node->name.ascii)); |
| 419 | obj_desc->common.flags |= AOPOBJ_INVALID; |
| 420 | status = AE_OK; |
| 421 | } |
| 422 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 423 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 426 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | * |
| 428 | * FUNCTION: acpi_ds_initialize_region |
| 429 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 430 | * PARAMETERS: obj_handle - Region namespace node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | * |
| 432 | * RETURN: Status |
| 433 | * |
| 434 | * DESCRIPTION: Front end to ev_initialize_region |
| 435 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 436 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 438 | acpi_status acpi_ds_initialize_region(acpi_handle obj_handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 440 | union acpi_operand_object *obj_desc; |
| 441 | acpi_status status; |
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 | obj_desc = acpi_ns_get_attached_object(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | |
| 445 | /* Namespace is NOT locked */ |
| 446 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 447 | status = acpi_ev_initialize_region(obj_desc, FALSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | return (status); |
| 449 | } |
| 450 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 451 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | * |
| 453 | * FUNCTION: acpi_ds_init_buffer_field |
| 454 | * |
| 455 | * PARAMETERS: aml_opcode - create_xxx_field |
| 456 | * obj_desc - buffer_field object |
| 457 | * buffer_desc - Host Buffer |
| 458 | * offset_desc - Offset into buffer |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 459 | * length_desc - Length of field (CREATE_FIELD_OP only) |
| 460 | * result_desc - Where to store the result |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | * |
| 462 | * RETURN: Status |
| 463 | * |
| 464 | * DESCRIPTION: Perform actual initialization of a buffer field |
| 465 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 466 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 468 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 469 | acpi_ds_init_buffer_field(u16 aml_opcode, |
| 470 | union acpi_operand_object *obj_desc, |
| 471 | union acpi_operand_object *buffer_desc, |
| 472 | union acpi_operand_object *offset_desc, |
| 473 | union acpi_operand_object *length_desc, |
| 474 | union acpi_operand_object *result_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 476 | u32 offset; |
| 477 | u32 bit_offset; |
| 478 | u32 bit_count; |
| 479 | u8 field_flags; |
| 480 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 482 | ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | |
| 484 | /* Host object must be a Buffer */ |
| 485 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 486 | if (ACPI_GET_OBJECT_TYPE(buffer_desc) != ACPI_TYPE_BUFFER) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 487 | ACPI_ERROR((AE_INFO, |
| 488 | "Target of Create Field is not a Buffer object - %s", |
| 489 | acpi_ut_get_object_type_name(buffer_desc))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
| 491 | status = AE_AML_OPERAND_TYPE; |
| 492 | goto cleanup; |
| 493 | } |
| 494 | |
| 495 | /* |
| 496 | * The last parameter to all of these opcodes (result_desc) started |
| 497 | * out as a name_string, and should therefore now be a NS node |
| 498 | * after resolution in acpi_ex_resolve_operands(). |
| 499 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 500 | if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 501 | ACPI_ERROR((AE_INFO, |
| 502 | "(%s) destination not a NS Node [%s]", |
| 503 | acpi_ps_get_opcode_name(aml_opcode), |
| 504 | acpi_ut_get_descriptor_name(result_desc))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | status = AE_AML_OPERAND_TYPE; |
| 507 | goto cleanup; |
| 508 | } |
| 509 | |
| 510 | offset = (u32) offset_desc->integer.value; |
| 511 | |
| 512 | /* |
| 513 | * Setup the Bit offsets and counts, according to the opcode |
| 514 | */ |
| 515 | switch (aml_opcode) { |
| 516 | case AML_CREATE_FIELD_OP: |
| 517 | |
| 518 | /* Offset is in bits, count is in bits */ |
| 519 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 520 | field_flags = AML_FIELD_ACCESS_BYTE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | bit_offset = offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 522 | bit_count = (u32) length_desc->integer.value; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 523 | |
| 524 | /* Must have a valid (>0) bit count */ |
| 525 | |
| 526 | if (bit_count == 0) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 527 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 528 | "Attempt to CreateField of length zero")); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 529 | status = AE_AML_OPERAND_VALUE; |
| 530 | goto cleanup; |
| 531 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | break; |
| 533 | |
| 534 | case AML_CREATE_BIT_FIELD_OP: |
| 535 | |
| 536 | /* Offset is in bits, Field is one bit */ |
| 537 | |
| 538 | bit_offset = offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 539 | bit_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | field_flags = AML_FIELD_ACCESS_BYTE; |
| 541 | break; |
| 542 | |
| 543 | case AML_CREATE_BYTE_FIELD_OP: |
| 544 | |
| 545 | /* Offset is in bytes, field is one byte */ |
| 546 | |
| 547 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 548 | bit_count = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | field_flags = AML_FIELD_ACCESS_BYTE; |
| 550 | break; |
| 551 | |
| 552 | case AML_CREATE_WORD_FIELD_OP: |
| 553 | |
| 554 | /* Offset is in bytes, field is one word */ |
| 555 | |
| 556 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 557 | bit_count = 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | field_flags = AML_FIELD_ACCESS_WORD; |
| 559 | break; |
| 560 | |
| 561 | case AML_CREATE_DWORD_FIELD_OP: |
| 562 | |
| 563 | /* Offset is in bytes, field is one dword */ |
| 564 | |
| 565 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 566 | bit_count = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | field_flags = AML_FIELD_ACCESS_DWORD; |
| 568 | break; |
| 569 | |
| 570 | case AML_CREATE_QWORD_FIELD_OP: |
| 571 | |
| 572 | /* Offset is in bytes, field is one qword */ |
| 573 | |
| 574 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 575 | bit_count = 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | field_flags = AML_FIELD_ACCESS_QWORD; |
| 577 | break; |
| 578 | |
| 579 | default: |
| 580 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 581 | ACPI_ERROR((AE_INFO, |
| 582 | "Unknown field creation opcode %02x", aml_opcode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | status = AE_AML_BAD_OPCODE; |
| 584 | goto cleanup; |
| 585 | } |
| 586 | |
| 587 | /* Entire field must fit within the current length of the buffer */ |
| 588 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 589 | if ((bit_offset + bit_count) > (8 * (u32) buffer_desc->buffer.length)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 590 | ACPI_ERROR((AE_INFO, |
| 591 | "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", |
| 592 | acpi_ut_get_node_name(result_desc), |
| 593 | bit_offset + bit_count, |
| 594 | acpi_ut_get_node_name(buffer_desc->buffer.node), |
| 595 | 8 * (u32) buffer_desc->buffer.length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | status = AE_AML_BUFFER_LIMIT; |
| 597 | goto cleanup; |
| 598 | } |
| 599 | |
| 600 | /* |
| 601 | * Initialize areas of the field object that are common to all fields |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 602 | * For field_flags, use LOCK_RULE = 0 (NO_LOCK), |
| 603 | * UPDATE_RULE = 0 (UPDATE_PRESERVE) |
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 | status = acpi_ex_prep_common_field_object(obj_desc, field_flags, 0, |
| 606 | bit_offset, bit_count); |
| 607 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | goto cleanup; |
| 609 | } |
| 610 | |
| 611 | obj_desc->buffer_field.buffer_obj = buffer_desc; |
| 612 | |
| 613 | /* Reference count for buffer_desc inherits obj_desc count */ |
| 614 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 615 | buffer_desc->common.reference_count = (u16) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 616 | (buffer_desc->common.reference_count + |
| 617 | obj_desc->common.reference_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 619 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
| 621 | /* Always delete the operands */ |
| 622 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 623 | acpi_ut_remove_reference(offset_desc); |
| 624 | acpi_ut_remove_reference(buffer_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | |
| 626 | if (aml_opcode == AML_CREATE_FIELD_OP) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 627 | acpi_ut_remove_reference(length_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | /* On failure, delete the result descriptor */ |
| 631 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 632 | if (ACPI_FAILURE(status)) { |
| 633 | acpi_ut_remove_reference(result_desc); /* Result descriptor */ |
| 634 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | /* Now the address and length are valid for this buffer_field */ |
| 636 | |
| 637 | obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; |
| 638 | } |
| 639 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 640 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | } |
| 642 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 643 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | * |
| 645 | * FUNCTION: acpi_ds_eval_buffer_field_operands |
| 646 | * |
| 647 | * PARAMETERS: walk_state - Current walk |
| 648 | * Op - A valid buffer_field Op object |
| 649 | * |
| 650 | * RETURN: Status |
| 651 | * |
| 652 | * DESCRIPTION: Get buffer_field Buffer and Index |
| 653 | * Called from acpi_ds_exec_end_op during buffer_field parse tree walk |
| 654 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 655 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | |
| 657 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 658 | acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, |
| 659 | union acpi_parse_object *op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 661 | acpi_status status; |
| 662 | union acpi_operand_object *obj_desc; |
| 663 | struct acpi_namespace_node *node; |
| 664 | union acpi_parse_object *next_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 666 | ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | |
| 668 | /* |
| 669 | * This is where we evaluate the address and length fields of the |
| 670 | * create_xxx_field declaration |
| 671 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 672 | node = op->common.node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
| 674 | /* next_op points to the op that holds the Buffer */ |
| 675 | |
| 676 | next_op = op->common.value.arg; |
| 677 | |
| 678 | /* Evaluate/create the address and length operands */ |
| 679 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 680 | status = acpi_ds_create_operands(walk_state, next_op); |
| 681 | if (ACPI_FAILURE(status)) { |
| 682 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 685 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 687 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | /* Resolve the operands */ |
| 691 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 692 | status = acpi_ex_resolve_operands(op->common.aml_opcode, |
| 693 | ACPI_WALK_OPERANDS, walk_state); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 694 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 695 | ACPI_ERROR((AE_INFO, "(%s) bad operand(s) (%X)", |
| 696 | acpi_ps_get_opcode_name(op->common.aml_opcode), |
| 697 | status)); |
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 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | /* Initialize the Buffer Field */ |
| 703 | |
| 704 | if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 705 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | /* NOTE: Slightly different operands for this opcode */ |
| 707 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | status = |
| 709 | acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, |
| 710 | walk_state->operands[0], |
| 711 | walk_state->operands[1], |
| 712 | walk_state->operands[2], |
| 713 | walk_state->operands[3]); |
| 714 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | /* All other, create_xxx_field opcodes */ |
| 716 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 717 | status = |
| 718 | acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, |
| 719 | walk_state->operands[0], |
| 720 | walk_state->operands[1], NULL, |
| 721 | walk_state->operands[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | } |
| 723 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 724 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 727 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | * |
| 729 | * FUNCTION: acpi_ds_eval_region_operands |
| 730 | * |
| 731 | * PARAMETERS: walk_state - Current walk |
| 732 | * Op - A valid region Op object |
| 733 | * |
| 734 | * RETURN: Status |
| 735 | * |
| 736 | * DESCRIPTION: Get region address and length |
| 737 | * Called from acpi_ds_exec_end_op during op_region parse tree walk |
| 738 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 739 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | |
| 741 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 742 | acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state, |
| 743 | union acpi_parse_object *op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 745 | acpi_status status; |
| 746 | union acpi_operand_object *obj_desc; |
| 747 | union acpi_operand_object *operand_desc; |
| 748 | struct acpi_namespace_node *node; |
| 749 | union acpi_parse_object *next_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 751 | ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | |
| 753 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 754 | * This is where we evaluate the address and length fields of the |
| 755 | * op_region declaration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 757 | node = op->common.node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | |
| 759 | /* next_op points to the op that holds the space_iD */ |
| 760 | |
| 761 | next_op = op->common.value.arg; |
| 762 | |
| 763 | /* next_op points to address op */ |
| 764 | |
| 765 | next_op = next_op->common.next; |
| 766 | |
| 767 | /* Evaluate/create the address and length operands */ |
| 768 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 769 | status = acpi_ds_create_operands(walk_state, next_op); |
| 770 | if (ACPI_FAILURE(status)) { |
| 771 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | /* Resolve the length and address operands to numbers */ |
| 775 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 776 | status = acpi_ex_resolve_operands(op->common.aml_opcode, |
| 777 | ACPI_WALK_OPERANDS, walk_state); |
| 778 | if (ACPI_FAILURE(status)) { |
| 779 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | } |
| 781 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 782 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 784 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | /* |
| 788 | * Get the length operand and save it |
| 789 | * (at Top of stack) |
| 790 | */ |
| 791 | operand_desc = walk_state->operands[walk_state->num_operands - 1]; |
| 792 | |
| 793 | obj_desc->region.length = (u32) operand_desc->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 794 | acpi_ut_remove_reference(operand_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | |
| 796 | /* |
| 797 | * Get the address and save it |
| 798 | * (at top of stack - 1) |
| 799 | */ |
| 800 | operand_desc = walk_state->operands[walk_state->num_operands - 2]; |
| 801 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 802 | obj_desc->region.address = (acpi_physical_address) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 803 | operand_desc->integer.value; |
| 804 | acpi_ut_remove_reference(operand_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 806 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 807 | obj_desc, |
Bob Moore | b7f9f04 | 2008-04-10 19:06:40 +0400 | [diff] [blame] | 808 | ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 809 | obj_desc->region.length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | |
| 811 | /* Now the address and length are valid for this opregion */ |
| 812 | |
| 813 | obj_desc->region.flags |= AOPOBJ_DATA_VALID; |
| 814 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 815 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | } |
| 817 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 818 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | * |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 820 | * FUNCTION: acpi_ds_eval_table_region_operands |
| 821 | * |
| 822 | * PARAMETERS: walk_state - Current walk |
| 823 | * Op - A valid region Op object |
| 824 | * |
| 825 | * RETURN: Status |
| 826 | * |
| 827 | * DESCRIPTION: Get region address and length |
| 828 | * Called from acpi_ds_exec_end_op during data_table_region parse tree walk |
| 829 | * |
| 830 | ******************************************************************************/ |
| 831 | |
| 832 | acpi_status |
| 833 | acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state, |
| 834 | union acpi_parse_object *op) |
| 835 | { |
| 836 | acpi_status status; |
| 837 | union acpi_operand_object *obj_desc; |
| 838 | union acpi_operand_object **operand; |
| 839 | struct acpi_namespace_node *node; |
| 840 | union acpi_parse_object *next_op; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 841 | u32 table_index; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 842 | struct acpi_table_header *table; |
| 843 | |
| 844 | ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op); |
| 845 | |
| 846 | /* |
| 847 | * This is where we evaluate the signature_string and oem_iDString |
| 848 | * and oem_table_iDString of the data_table_region declaration |
| 849 | */ |
| 850 | node = op->common.node; |
| 851 | |
| 852 | /* next_op points to signature_string op */ |
| 853 | |
| 854 | next_op = op->common.value.arg; |
| 855 | |
| 856 | /* |
| 857 | * Evaluate/create the signature_string and oem_iDString |
| 858 | * and oem_table_iDString operands |
| 859 | */ |
| 860 | status = acpi_ds_create_operands(walk_state, next_op); |
| 861 | if (ACPI_FAILURE(status)) { |
| 862 | return_ACPI_STATUS(status); |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | * Resolve the signature_string and oem_iDString |
| 867 | * and oem_table_iDString operands |
| 868 | */ |
| 869 | status = acpi_ex_resolve_operands(op->common.aml_opcode, |
| 870 | ACPI_WALK_OPERANDS, walk_state); |
| 871 | if (ACPI_FAILURE(status)) { |
| 872 | return_ACPI_STATUS(status); |
| 873 | } |
| 874 | |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 875 | operand = &walk_state->operands[0]; |
| 876 | |
| 877 | /* Find the ACPI table */ |
| 878 | |
| 879 | status = acpi_tb_find_table(operand[0]->string.pointer, |
| 880 | operand[1]->string.pointer, |
| 881 | operand[2]->string.pointer, &table_index); |
| 882 | if (ACPI_FAILURE(status)) { |
| 883 | return_ACPI_STATUS(status); |
| 884 | } |
| 885 | |
| 886 | acpi_ut_remove_reference(operand[0]); |
| 887 | acpi_ut_remove_reference(operand[1]); |
| 888 | acpi_ut_remove_reference(operand[2]); |
| 889 | |
| 890 | status = acpi_get_table_by_index(table_index, &table); |
| 891 | if (ACPI_FAILURE(status)) { |
| 892 | return_ACPI_STATUS(status); |
| 893 | } |
| 894 | |
| 895 | obj_desc = acpi_ns_get_attached_object(node); |
| 896 | if (!obj_desc) { |
| 897 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 898 | } |
| 899 | |
| 900 | obj_desc->region.address = |
| 901 | (acpi_physical_address) ACPI_TO_INTEGER(table); |
| 902 | obj_desc->region.length = table->length; |
| 903 | |
| 904 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", |
| 905 | obj_desc, |
| 906 | ACPI_FORMAT_NATIVE_UINT(obj_desc->region.address), |
| 907 | obj_desc->region.length)); |
| 908 | |
| 909 | /* Now the address and length are valid for this opregion */ |
| 910 | |
| 911 | obj_desc->region.flags |= AOPOBJ_DATA_VALID; |
| 912 | |
| 913 | return_ACPI_STATUS(status); |
| 914 | } |
| 915 | |
| 916 | /******************************************************************************* |
| 917 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 918 | * FUNCTION: acpi_ds_eval_data_object_operands |
| 919 | * |
| 920 | * PARAMETERS: walk_state - Current walk |
| 921 | * Op - A valid data_object Op object |
| 922 | * obj_desc - data_object |
| 923 | * |
| 924 | * RETURN: Status |
| 925 | * |
| 926 | * DESCRIPTION: Get the operands and complete the following data object types: |
| 927 | * Buffer, Package. |
| 928 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 929 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | |
| 931 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 932 | acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, |
| 933 | union acpi_parse_object *op, |
| 934 | union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 936 | acpi_status status; |
| 937 | union acpi_operand_object *arg_desc; |
| 938 | u32 length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 940 | ACPI_FUNCTION_TRACE(ds_eval_data_object_operands); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 941 | |
| 942 | /* The first operand (for all of these data objects) is the length */ |
| 943 | |
Bob Moore | 773069d | 2008-04-10 19:06:36 +0400 | [diff] [blame] | 944 | /* |
| 945 | * Set proper index into operand stack for acpi_ds_obj_stack_push |
| 946 | * invoked inside acpi_ds_create_operand. |
| 947 | */ |
| 948 | walk_state->operand_index = walk_state->num_operands; |
| 949 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 950 | status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); |
| 951 | if (ACPI_FAILURE(status)) { |
| 952 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | } |
| 954 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 955 | status = acpi_ex_resolve_operands(walk_state->opcode, |
| 956 | &(walk_state-> |
| 957 | operands[walk_state->num_operands - |
| 958 | 1]), walk_state); |
| 959 | if (ACPI_FAILURE(status)) { |
| 960 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | /* Extract length operand */ |
| 964 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 965 | arg_desc = walk_state->operands[walk_state->num_operands - 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | length = (u32) arg_desc->integer.value; |
| 967 | |
| 968 | /* Cleanup for length operand */ |
| 969 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 970 | status = acpi_ds_obj_stack_pop(1, walk_state); |
| 971 | if (ACPI_FAILURE(status)) { |
| 972 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 975 | acpi_ut_remove_reference(arg_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | |
| 977 | /* |
| 978 | * Create the actual data object |
| 979 | */ |
| 980 | switch (op->common.aml_opcode) { |
| 981 | case AML_BUFFER_OP: |
| 982 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 983 | status = |
| 984 | acpi_ds_build_internal_buffer_obj(walk_state, op, length, |
| 985 | &obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | break; |
| 987 | |
| 988 | case AML_PACKAGE_OP: |
| 989 | case AML_VAR_PACKAGE_OP: |
| 990 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 991 | status = |
| 992 | acpi_ds_build_internal_package_obj(walk_state, op, length, |
| 993 | &obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | break; |
| 995 | |
| 996 | default: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 997 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | } |
| 999 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1000 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1001 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 1002 | * Return the object in the walk_state, unless the parent is a package - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | * in this case, the return object will be stored in the parse tree |
| 1004 | * for the package. |
| 1005 | */ |
| 1006 | if ((!op->common.parent) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1007 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && |
| 1008 | (op->common.parent->common.aml_opcode != |
| 1009 | AML_VAR_PACKAGE_OP) |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 1010 | && (op->common.parent->common.aml_opcode != AML_NAME_OP))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | walk_state->result_obj = obj_desc; |
| 1012 | } |
| 1013 | } |
| 1014 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1015 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | /******************************************************************************* |
| 1019 | * |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 1020 | * FUNCTION: acpi_ds_eval_bank_field_operands |
| 1021 | * |
| 1022 | * PARAMETERS: walk_state - Current walk |
| 1023 | * Op - A valid bank_field Op object |
| 1024 | * |
| 1025 | * RETURN: Status |
| 1026 | * |
| 1027 | * DESCRIPTION: Get bank_field bank_value |
| 1028 | * Called from acpi_ds_exec_end_op during bank_field parse tree walk |
| 1029 | * |
| 1030 | ******************************************************************************/ |
| 1031 | |
| 1032 | acpi_status |
| 1033 | acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state, |
| 1034 | union acpi_parse_object *op) |
| 1035 | { |
| 1036 | acpi_status status; |
| 1037 | union acpi_operand_object *obj_desc; |
| 1038 | union acpi_operand_object *operand_desc; |
| 1039 | struct acpi_namespace_node *node; |
| 1040 | union acpi_parse_object *next_op; |
| 1041 | union acpi_parse_object *arg; |
| 1042 | |
| 1043 | ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op); |
| 1044 | |
| 1045 | /* |
| 1046 | * This is where we evaluate the bank_value field of the |
| 1047 | * bank_field declaration |
| 1048 | */ |
| 1049 | |
| 1050 | /* next_op points to the op that holds the Region */ |
| 1051 | |
| 1052 | next_op = op->common.value.arg; |
| 1053 | |
| 1054 | /* next_op points to the op that holds the Bank Register */ |
| 1055 | |
| 1056 | next_op = next_op->common.next; |
| 1057 | |
| 1058 | /* next_op points to the op that holds the Bank Value */ |
| 1059 | |
| 1060 | next_op = next_op->common.next; |
| 1061 | |
| 1062 | /* |
| 1063 | * Set proper index into operand stack for acpi_ds_obj_stack_push |
| 1064 | * invoked inside acpi_ds_create_operand. |
| 1065 | * |
| 1066 | * We use walk_state->Operands[0] to store the evaluated bank_value |
| 1067 | */ |
| 1068 | walk_state->operand_index = 0; |
| 1069 | |
| 1070 | status = acpi_ds_create_operand(walk_state, next_op, 0); |
| 1071 | if (ACPI_FAILURE(status)) { |
| 1072 | return_ACPI_STATUS(status); |
| 1073 | } |
| 1074 | |
| 1075 | status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state); |
| 1076 | if (ACPI_FAILURE(status)) { |
| 1077 | return_ACPI_STATUS(status); |
| 1078 | } |
| 1079 | |
Bob Moore | 71d993e | 2008-06-10 14:25:05 +0800 | [diff] [blame] | 1080 | ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, |
| 1081 | acpi_ps_get_opcode_name(op->common.aml_opcode), 1); |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 1082 | /* |
| 1083 | * Get the bank_value operand and save it |
| 1084 | * (at Top of stack) |
| 1085 | */ |
| 1086 | operand_desc = walk_state->operands[0]; |
| 1087 | |
| 1088 | /* Arg points to the start Bank Field */ |
| 1089 | |
| 1090 | arg = acpi_ps_get_arg(op, 4); |
| 1091 | while (arg) { |
| 1092 | |
| 1093 | /* Ignore OFFSET and ACCESSAS terms here */ |
| 1094 | |
| 1095 | if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { |
| 1096 | node = arg->common.node; |
| 1097 | |
| 1098 | obj_desc = acpi_ns_get_attached_object(node); |
| 1099 | if (!obj_desc) { |
| 1100 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 1101 | } |
| 1102 | |
| 1103 | obj_desc->bank_field.value = |
| 1104 | (u32) operand_desc->integer.value; |
| 1105 | } |
| 1106 | |
| 1107 | /* Move to next field in the list */ |
| 1108 | |
| 1109 | arg = arg->common.next; |
| 1110 | } |
| 1111 | |
| 1112 | acpi_ut_remove_reference(operand_desc); |
| 1113 | return_ACPI_STATUS(status); |
| 1114 | } |
| 1115 | |
| 1116 | /******************************************************************************* |
| 1117 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1118 | * FUNCTION: acpi_ds_exec_begin_control_op |
| 1119 | * |
| 1120 | * PARAMETERS: walk_list - The list that owns the walk stack |
| 1121 | * Op - The control Op |
| 1122 | * |
| 1123 | * RETURN: Status |
| 1124 | * |
| 1125 | * DESCRIPTION: Handles all control ops encountered during control method |
| 1126 | * execution. |
| 1127 | * |
| 1128 | ******************************************************************************/ |
| 1129 | |
| 1130 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1131 | acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, |
| 1132 | union acpi_parse_object *op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1134 | acpi_status status = AE_OK; |
| 1135 | union acpi_generic_state *control_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1137 | ACPI_FUNCTION_NAME(ds_exec_begin_control_op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1139 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", op, |
| 1140 | op->common.aml_opcode, walk_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | |
| 1142 | switch (op->common.aml_opcode) { |
| 1143 | case AML_IF_OP: |
| 1144 | case AML_WHILE_OP: |
| 1145 | |
| 1146 | /* |
| 1147 | * IF/WHILE: Create a new control state to manage these |
| 1148 | * constructs. We need to manage these as a stack, in order |
| 1149 | * to handle nesting. |
| 1150 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1151 | control_state = acpi_ut_create_control_state(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | if (!control_state) { |
| 1153 | status = AE_NO_MEMORY; |
| 1154 | break; |
| 1155 | } |
| 1156 | /* |
| 1157 | * Save a pointer to the predicate for multiple executions |
| 1158 | * of a loop |
| 1159 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1160 | control_state->control.aml_predicate_start = |
| 1161 | walk_state->parser_state.aml - 1; |
| 1162 | control_state->control.package_end = |
| 1163 | walk_state->parser_state.pkg_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | control_state->control.opcode = op->common.aml_opcode; |
| 1165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | /* Push the control state on this walk's control stack */ |
| 1167 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1168 | acpi_ut_push_generic_state(&walk_state->control_state, |
| 1169 | control_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | break; |
| 1171 | |
| 1172 | case AML_ELSE_OP: |
| 1173 | |
| 1174 | /* Predicate is in the state object */ |
| 1175 | /* If predicate is true, the IF was executed, ignore ELSE part */ |
| 1176 | |
| 1177 | if (walk_state->last_predicate) { |
| 1178 | status = AE_CTRL_TRUE; |
| 1179 | } |
| 1180 | |
| 1181 | break; |
| 1182 | |
| 1183 | case AML_RETURN_OP: |
| 1184 | |
| 1185 | break; |
| 1186 | |
| 1187 | default: |
| 1188 | break; |
| 1189 | } |
| 1190 | |
| 1191 | return (status); |
| 1192 | } |
| 1193 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | /******************************************************************************* |
| 1195 | * |
| 1196 | * FUNCTION: acpi_ds_exec_end_control_op |
| 1197 | * |
| 1198 | * PARAMETERS: walk_list - The list that owns the walk stack |
| 1199 | * Op - The control Op |
| 1200 | * |
| 1201 | * RETURN: Status |
| 1202 | * |
| 1203 | * DESCRIPTION: Handles all control ops encountered during control method |
| 1204 | * execution. |
| 1205 | * |
| 1206 | ******************************************************************************/ |
| 1207 | |
| 1208 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1209 | acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, |
| 1210 | union acpi_parse_object * op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1212 | acpi_status status = AE_OK; |
| 1213 | union acpi_generic_state *control_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1215 | ACPI_FUNCTION_NAME(ds_exec_end_control_op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1216 | |
| 1217 | switch (op->common.aml_opcode) { |
| 1218 | case AML_IF_OP: |
| 1219 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1220 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", op)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
| 1222 | /* |
| 1223 | * Save the result of the predicate in case there is an |
| 1224 | * ELSE to come |
| 1225 | */ |
| 1226 | walk_state->last_predicate = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1227 | (u8) walk_state->control_state->common.value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | |
| 1229 | /* |
| 1230 | * Pop the control state that was created at the start |
| 1231 | * of the IF and free it |
| 1232 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1233 | control_state = |
| 1234 | acpi_ut_pop_generic_state(&walk_state->control_state); |
| 1235 | acpi_ut_delete_generic_state(control_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | break; |
| 1237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | case AML_ELSE_OP: |
| 1239 | |
| 1240 | break; |
| 1241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | case AML_WHILE_OP: |
| 1243 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1244 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1245 | |
| 1246 | if (walk_state->control_state->common.value) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | /* Predicate was true, go back and evaluate it again! */ |
| 1249 | |
| 1250 | status = AE_CTRL_PENDING; |
| 1251 | } |
| 1252 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1253 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
| 1254 | "[WHILE_OP] termination! Op=%p\n", op)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | |
| 1256 | /* Pop this control state and free it */ |
| 1257 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1258 | control_state = |
| 1259 | acpi_ut_pop_generic_state(&walk_state->control_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1261 | walk_state->aml_last_while = |
| 1262 | control_state->control.aml_predicate_start; |
| 1263 | acpi_ut_delete_generic_state(control_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | break; |
| 1265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1266 | case AML_RETURN_OP: |
| 1267 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1268 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
| 1269 | "[RETURN_OP] Op=%p Arg=%p\n", op, |
| 1270 | op->common.value.arg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | |
| 1272 | /* |
| 1273 | * One optional operand -- the return value |
| 1274 | * It can be either an immediate operand or a result that |
| 1275 | * has been bubbled up the tree |
| 1276 | */ |
| 1277 | if (op->common.value.arg) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | /* Since we have a real Return(), delete any implicit return */ |
| 1280 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1281 | acpi_ds_clear_implicit_return(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | |
| 1283 | /* Return statement has an immediate operand */ |
| 1284 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1285 | status = |
| 1286 | acpi_ds_create_operands(walk_state, |
| 1287 | op->common.value.arg); |
| 1288 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | return (status); |
| 1290 | } |
| 1291 | |
| 1292 | /* |
| 1293 | * If value being returned is a Reference (such as |
| 1294 | * an arg or local), resolve it now because it may |
| 1295 | * cease to exist at the end of the method. |
| 1296 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1297 | status = |
| 1298 | acpi_ex_resolve_to_value(&walk_state->operands[0], |
| 1299 | walk_state); |
| 1300 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | return (status); |
| 1302 | } |
| 1303 | |
| 1304 | /* |
| 1305 | * Get the return value and save as the last result |
| 1306 | * value. This is the only place where walk_state->return_desc |
| 1307 | * is set to anything other than zero! |
| 1308 | */ |
| 1309 | walk_state->return_desc = walk_state->operands[0]; |
Bob Moore | 773069d | 2008-04-10 19:06:36 +0400 | [diff] [blame] | 1310 | } else if (walk_state->result_count) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | /* Since we have a real Return(), delete any implicit return */ |
| 1313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1314 | acpi_ds_clear_implicit_return(walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | |
| 1316 | /* |
| 1317 | * The return value has come from a previous calculation. |
| 1318 | * |
| 1319 | * If value being returned is a Reference (such as |
| 1320 | * an arg or local), resolve it now because it may |
| 1321 | * cease to exist at the end of the method. |
| 1322 | * |
| 1323 | * Allow references created by the Index operator to return unchanged. |
| 1324 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1325 | if ((ACPI_GET_DESCRIPTOR_TYPE |
| 1326 | (walk_state->results->results.obj_desc[0]) == |
| 1327 | ACPI_DESC_TYPE_OPERAND) |
| 1328 | && |
| 1329 | (ACPI_GET_OBJECT_TYPE |
| 1330 | (walk_state->results->results.obj_desc[0]) == |
| 1331 | ACPI_TYPE_LOCAL_REFERENCE) |
| 1332 | && ((walk_state->results->results.obj_desc[0])-> |
| 1333 | reference.opcode != AML_INDEX_OP)) { |
| 1334 | status = |
| 1335 | acpi_ex_resolve_to_value(&walk_state-> |
| 1336 | results->results. |
| 1337 | obj_desc[0], |
| 1338 | walk_state); |
| 1339 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | return (status); |
| 1341 | } |
| 1342 | } |
| 1343 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1344 | walk_state->return_desc = |
| 1345 | walk_state->results->results.obj_desc[0]; |
| 1346 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | /* No return operand */ |
| 1348 | |
| 1349 | if (walk_state->num_operands) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1350 | acpi_ut_remove_reference(walk_state-> |
| 1351 | operands[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1354 | walk_state->operands[0] = NULL; |
| 1355 | walk_state->num_operands = 0; |
| 1356 | walk_state->return_desc = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1359 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1360 | "Completed RETURN_OP State=%p, RetVal=%p\n", |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1361 | walk_state, walk_state->return_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | |
| 1363 | /* End the control method execution right now */ |
| 1364 | |
| 1365 | status = AE_CTRL_TERMINATE; |
| 1366 | break; |
| 1367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | case AML_NOOP_OP: |
| 1369 | |
| 1370 | /* Just do nothing! */ |
| 1371 | break; |
| 1372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | case AML_BREAK_POINT_OP: |
| 1374 | |
| 1375 | /* Call up to the OS service layer to handle this */ |
| 1376 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1377 | status = |
| 1378 | acpi_os_signal(ACPI_SIGNAL_BREAKPOINT, |
| 1379 | "Executed AML Breakpoint opcode"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | |
| 1381 | /* If and when it returns, all done. */ |
| 1382 | |
| 1383 | break; |
| 1384 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1385 | case AML_BREAK_OP: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1386 | case AML_CONTINUE_OP: /* ACPI 2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | |
| 1388 | /* Pop and delete control states until we find a while */ |
| 1389 | |
| 1390 | while (walk_state->control_state && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1391 | (walk_state->control_state->control.opcode != |
| 1392 | AML_WHILE_OP)) { |
| 1393 | control_state = |
| 1394 | acpi_ut_pop_generic_state(&walk_state-> |
| 1395 | control_state); |
| 1396 | acpi_ut_delete_generic_state(control_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | /* No while found? */ |
| 1400 | |
| 1401 | if (!walk_state->control_state) { |
| 1402 | return (AE_AML_NO_WHILE); |
| 1403 | } |
| 1404 | |
| 1405 | /* Was: walk_state->aml_last_while = walk_state->control_state->Control.aml_predicate_start; */ |
| 1406 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1407 | walk_state->aml_last_while = |
| 1408 | walk_state->control_state->control.package_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | |
| 1410 | /* Return status depending on opcode */ |
| 1411 | |
| 1412 | if (op->common.aml_opcode == AML_BREAK_OP) { |
| 1413 | status = AE_CTRL_BREAK; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1414 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1415 | status = AE_CTRL_CONTINUE; |
| 1416 | } |
| 1417 | break; |
| 1418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | default: |
| 1420 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1421 | ACPI_ERROR((AE_INFO, "Unknown control opcode=%X Op=%p", |
| 1422 | op->common.aml_opcode, op)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | |
| 1424 | status = AE_AML_BAD_OPCODE; |
| 1425 | break; |
| 1426 | } |
| 1427 | |
| 1428 | return (status); |
| 1429 | } |