Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /****************************************************************************** |
| 3 | * |
Masanari Iida | 02582e9 | 2012-08-22 19:11:26 +0900 | [diff] [blame] | 4 | * Module Name: dsopcode - Dispatcher support for regions and fields |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Bob Moore | da6f832 | 2018-01-04 10:06:38 -0800 | [diff] [blame] | 6 | * Copyright (C) 2000 - 2018, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 8 | *****************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 11 | #include "accommon.h" |
| 12 | #include "acparser.h" |
| 13 | #include "amlcode.h" |
| 14 | #include "acdispat.h" |
| 15 | #include "acinterp.h" |
| 16 | #include "acnamesp.h" |
| 17 | #include "acevents.h" |
| 18 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #define _COMPONENT ACPI_DISPATCHER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 21 | ACPI_MODULE_NAME("dsopcode") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 23 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 24 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 25 | acpi_ds_init_buffer_field(u16 aml_opcode, |
| 26 | union acpi_operand_object *obj_desc, |
| 27 | union acpi_operand_object *buffer_desc, |
| 28 | union acpi_operand_object *offset_desc, |
| 29 | union acpi_operand_object *length_desc, |
| 30 | union acpi_operand_object *result_desc); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 31 | |
| 32 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | * FUNCTION: acpi_ds_initialize_region |
| 35 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 36 | * PARAMETERS: obj_handle - Region namespace node |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | * |
| 38 | * RETURN: Status |
| 39 | * |
| 40 | * DESCRIPTION: Front end to ev_initialize_region |
| 41 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 42 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 44 | acpi_status acpi_ds_initialize_region(acpi_handle obj_handle) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 46 | union acpi_operand_object *obj_desc; |
| 47 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | obj_desc = acpi_ns_get_attached_object(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | /* Namespace is NOT locked */ |
| 52 | |
Lv Zheng | 760235c | 2016-11-30 15:21:12 +0800 | [diff] [blame] | 53 | status = acpi_ev_initialize_region(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | return (status); |
| 55 | } |
| 56 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 57 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | * |
| 59 | * FUNCTION: acpi_ds_init_buffer_field |
| 60 | * |
| 61 | * PARAMETERS: aml_opcode - create_xxx_field |
| 62 | * obj_desc - buffer_field object |
| 63 | * buffer_desc - Host Buffer |
| 64 | * offset_desc - Offset into buffer |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 65 | * length_desc - Length of field (CREATE_FIELD_OP only) |
| 66 | * result_desc - Where to store the result |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | * |
| 68 | * RETURN: Status |
| 69 | * |
| 70 | * DESCRIPTION: Perform actual initialization of a buffer field |
| 71 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 72 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 74 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 75 | acpi_ds_init_buffer_field(u16 aml_opcode, |
| 76 | union acpi_operand_object *obj_desc, |
| 77 | union acpi_operand_object *buffer_desc, |
| 78 | union acpi_operand_object *offset_desc, |
| 79 | union acpi_operand_object *length_desc, |
| 80 | union acpi_operand_object *result_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | u32 offset; |
| 83 | u32 bit_offset; |
| 84 | u32 bit_count; |
| 85 | u8 field_flags; |
| 86 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 88 | ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | /* Host object must be a Buffer */ |
| 91 | |
Bob Moore | 3371c19 | 2009-02-18 14:44:03 +0800 | [diff] [blame] | 92 | if (buffer_desc->common.type != ACPI_TYPE_BUFFER) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 93 | ACPI_ERROR((AE_INFO, |
| 94 | "Target of Create Field is not a Buffer object - %s", |
| 95 | acpi_ut_get_object_type_name(buffer_desc))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | status = AE_AML_OPERAND_TYPE; |
| 98 | goto cleanup; |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * The last parameter to all of these opcodes (result_desc) started |
| 103 | * out as a name_string, and should therefore now be a NS node |
| 104 | * after resolution in acpi_ex_resolve_operands(). |
| 105 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 107 | ACPI_ERROR((AE_INFO, |
| 108 | "(%s) destination not a NS Node [%s]", |
| 109 | acpi_ps_get_opcode_name(aml_opcode), |
| 110 | acpi_ut_get_descriptor_name(result_desc))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | status = AE_AML_OPERAND_TYPE; |
| 113 | goto cleanup; |
| 114 | } |
| 115 | |
| 116 | offset = (u32) offset_desc->integer.value; |
| 117 | |
| 118 | /* |
| 119 | * Setup the Bit offsets and counts, according to the opcode |
| 120 | */ |
| 121 | switch (aml_opcode) { |
| 122 | case AML_CREATE_FIELD_OP: |
| 123 | |
| 124 | /* Offset is in bits, count is in bits */ |
| 125 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 126 | field_flags = AML_FIELD_ACCESS_BYTE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | bit_offset = offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 128 | bit_count = (u32) length_desc->integer.value; |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 129 | |
| 130 | /* Must have a valid (>0) bit count */ |
| 131 | |
| 132 | if (bit_count == 0) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 133 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 134 | "Attempt to CreateField of length zero")); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 135 | status = AE_AML_OPERAND_VALUE; |
| 136 | goto cleanup; |
| 137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | break; |
| 139 | |
| 140 | case AML_CREATE_BIT_FIELD_OP: |
| 141 | |
| 142 | /* Offset is in bits, Field is one bit */ |
| 143 | |
| 144 | bit_offset = offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | bit_count = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | field_flags = AML_FIELD_ACCESS_BYTE; |
| 147 | break; |
| 148 | |
| 149 | case AML_CREATE_BYTE_FIELD_OP: |
| 150 | |
| 151 | /* Offset is in bytes, field is one byte */ |
| 152 | |
| 153 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 154 | bit_count = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | field_flags = AML_FIELD_ACCESS_BYTE; |
| 156 | break; |
| 157 | |
| 158 | case AML_CREATE_WORD_FIELD_OP: |
| 159 | |
| 160 | /* Offset is in bytes, field is one word */ |
| 161 | |
| 162 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 163 | bit_count = 16; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | field_flags = AML_FIELD_ACCESS_WORD; |
| 165 | break; |
| 166 | |
| 167 | case AML_CREATE_DWORD_FIELD_OP: |
| 168 | |
| 169 | /* Offset is in bytes, field is one dword */ |
| 170 | |
| 171 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 172 | bit_count = 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | field_flags = AML_FIELD_ACCESS_DWORD; |
| 174 | break; |
| 175 | |
| 176 | case AML_CREATE_QWORD_FIELD_OP: |
| 177 | |
| 178 | /* Offset is in bytes, field is one qword */ |
| 179 | |
| 180 | bit_offset = 8 * offset; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 181 | bit_count = 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | field_flags = AML_FIELD_ACCESS_QWORD; |
| 183 | break; |
| 184 | |
| 185 | default: |
| 186 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 187 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 188 | "Unknown field creation opcode 0x%02X", |
| 189 | aml_opcode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | status = AE_AML_BAD_OPCODE; |
| 191 | goto cleanup; |
| 192 | } |
| 193 | |
| 194 | /* Entire field must fit within the current length of the buffer */ |
| 195 | |
Bob Moore | 5e2d9e9 | 2017-06-05 16:40:08 +0800 | [diff] [blame] | 196 | if ((bit_offset + bit_count) > (8 * (u32)buffer_desc->buffer.length)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 197 | ACPI_ERROR((AE_INFO, |
Bob Moore | 5e2d9e9 | 2017-06-05 16:40:08 +0800 | [diff] [blame] | 198 | "Field [%4.4s] at bit offset/length %u/%u " |
| 199 | "exceeds size of target Buffer (%u bits)", |
| 200 | acpi_ut_get_node_name(result_desc), bit_offset, |
| 201 | bit_count, 8 * (u32)buffer_desc->buffer.length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | status = AE_AML_BUFFER_LIMIT; |
| 203 | goto cleanup; |
| 204 | } |
| 205 | |
| 206 | /* |
| 207 | * Initialize areas of the field object that are common to all fields |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 208 | * For field_flags, use LOCK_RULE = 0 (NO_LOCK), |
| 209 | * UPDATE_RULE = 0 (UPDATE_PRESERVE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | */ |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 211 | status = |
| 212 | acpi_ex_prep_common_field_object(obj_desc, field_flags, 0, |
| 213 | bit_offset, bit_count); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 214 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | goto cleanup; |
| 216 | } |
| 217 | |
| 218 | obj_desc->buffer_field.buffer_obj = buffer_desc; |
| 219 | |
| 220 | /* Reference count for buffer_desc inherits obj_desc count */ |
| 221 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 222 | buffer_desc->common.reference_count = (u16) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | (buffer_desc->common.reference_count + |
| 224 | obj_desc->common.reference_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 226 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | /* Always delete the operands */ |
| 229 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 230 | acpi_ut_remove_reference(offset_desc); |
| 231 | acpi_ut_remove_reference(buffer_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
| 233 | if (aml_opcode == AML_CREATE_FIELD_OP) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 234 | acpi_ut_remove_reference(length_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /* On failure, delete the result descriptor */ |
| 238 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 239 | if (ACPI_FAILURE(status)) { |
| 240 | acpi_ut_remove_reference(result_desc); /* Result descriptor */ |
| 241 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* Now the address and length are valid for this buffer_field */ |
| 243 | |
| 244 | obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID; |
| 245 | } |
| 246 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 247 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 250 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | * |
| 252 | * FUNCTION: acpi_ds_eval_buffer_field_operands |
| 253 | * |
| 254 | * PARAMETERS: walk_state - Current walk |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 255 | * op - A valid buffer_field Op object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | * |
| 257 | * RETURN: Status |
| 258 | * |
| 259 | * DESCRIPTION: Get buffer_field Buffer and Index |
| 260 | * Called from acpi_ds_exec_end_op during buffer_field parse tree walk |
| 261 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 262 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 265 | acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state, |
| 266 | union acpi_parse_object *op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | acpi_status status; |
| 269 | union acpi_operand_object *obj_desc; |
| 270 | struct acpi_namespace_node *node; |
| 271 | union acpi_parse_object *next_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 273 | ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | |
| 275 | /* |
| 276 | * This is where we evaluate the address and length fields of the |
| 277 | * create_xxx_field declaration |
| 278 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | node = op->common.node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
| 281 | /* next_op points to the op that holds the Buffer */ |
| 282 | |
| 283 | next_op = op->common.value.arg; |
| 284 | |
| 285 | /* Evaluate/create the address and length operands */ |
| 286 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | status = acpi_ds_create_operands(walk_state, next_op); |
| 288 | if (ACPI_FAILURE(status)) { |
| 289 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 292 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /* Resolve the operands */ |
| 298 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 299 | status = |
| 300 | acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS, |
| 301 | walk_state); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 302 | if (ACPI_FAILURE(status)) { |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 303 | ACPI_ERROR((AE_INFO, "(%s) bad operand(s), status 0x%X", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 304 | acpi_ps_get_opcode_name(op->common.aml_opcode), |
| 305 | status)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /* Initialize the Buffer Field */ |
| 311 | |
| 312 | if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | /* NOTE: Slightly different operands for this opcode */ |
| 315 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | status = |
| 317 | acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, |
| 318 | walk_state->operands[0], |
| 319 | walk_state->operands[1], |
| 320 | walk_state->operands[2], |
| 321 | walk_state->operands[3]); |
| 322 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | /* All other, create_xxx_field opcodes */ |
| 324 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 325 | status = |
| 326 | acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc, |
| 327 | walk_state->operands[0], |
| 328 | walk_state->operands[1], NULL, |
| 329 | walk_state->operands[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 332 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 335 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | * |
| 337 | * FUNCTION: acpi_ds_eval_region_operands |
| 338 | * |
| 339 | * PARAMETERS: walk_state - Current walk |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 340 | * op - A valid region Op object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | * |
| 342 | * RETURN: Status |
| 343 | * |
| 344 | * DESCRIPTION: Get region address and length |
| 345 | * Called from acpi_ds_exec_end_op during op_region parse tree walk |
| 346 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 347 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
| 349 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 350 | acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state, |
| 351 | union acpi_parse_object *op) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | acpi_status status; |
| 354 | union acpi_operand_object *obj_desc; |
| 355 | union acpi_operand_object *operand_desc; |
| 356 | struct acpi_namespace_node *node; |
| 357 | union acpi_parse_object *next_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 359 | ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
| 361 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 362 | * This is where we evaluate the address and length fields of the |
| 363 | * op_region declaration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 365 | node = op->common.node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 367 | /* next_op points to the op that holds the space_ID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
| 369 | next_op = op->common.value.arg; |
| 370 | |
| 371 | /* next_op points to address op */ |
| 372 | |
| 373 | next_op = next_op->common.next; |
| 374 | |
| 375 | /* Evaluate/create the address and length operands */ |
| 376 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 377 | status = acpi_ds_create_operands(walk_state, next_op); |
| 378 | if (ACPI_FAILURE(status)) { |
| 379 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /* Resolve the length and address operands to numbers */ |
| 383 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 384 | status = |
| 385 | acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS, |
| 386 | walk_state); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 387 | if (ACPI_FAILURE(status)) { |
| 388 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 391 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /* |
| 397 | * Get the length operand and save it |
| 398 | * (at Top of stack) |
| 399 | */ |
| 400 | operand_desc = walk_state->operands[walk_state->num_operands - 1]; |
| 401 | |
| 402 | obj_desc->region.length = (u32) operand_desc->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 403 | acpi_ut_remove_reference(operand_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | |
| 405 | /* |
| 406 | * Get the address and save it |
| 407 | * (at top of stack - 1) |
| 408 | */ |
| 409 | operand_desc = walk_state->operands[walk_state->num_operands - 2]; |
| 410 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 411 | obj_desc->region.address = (acpi_physical_address) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | operand_desc->integer.value; |
| 413 | acpi_ut_remove_reference(operand_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 415 | 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] | 416 | obj_desc, |
Lv Zheng | 1d0a0b2 | 2015-04-13 11:48:52 +0800 | [diff] [blame] | 417 | ACPI_FORMAT_UINT64(obj_desc->region.address), |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 418 | obj_desc->region.length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Erik Schmauss | 4abb951 | 2018-10-17 14:09:35 -0700 | [diff] [blame] | 420 | status = acpi_ut_add_address_range(obj_desc->region.space_id, |
| 421 | obj_desc->region.address, |
| 422 | obj_desc->region.length, node); |
| 423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | /* Now the address and length are valid for this opregion */ |
| 425 | |
| 426 | obj_desc->region.flags |= AOPOBJ_DATA_VALID; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 427 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 430 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | * |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 432 | * FUNCTION: acpi_ds_eval_table_region_operands |
| 433 | * |
| 434 | * PARAMETERS: walk_state - Current walk |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 435 | * op - A valid region Op object |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 436 | * |
| 437 | * RETURN: Status |
| 438 | * |
Bob Moore | 9ad19ac4 | 2011-02-14 16:09:40 +0800 | [diff] [blame] | 439 | * DESCRIPTION: Get region address and length. |
| 440 | * Called from acpi_ds_exec_end_op during data_table_region parse |
| 441 | * tree walk. |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 442 | * |
| 443 | ******************************************************************************/ |
| 444 | |
| 445 | acpi_status |
| 446 | acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state, |
| 447 | union acpi_parse_object *op) |
| 448 | { |
| 449 | acpi_status status; |
| 450 | union acpi_operand_object *obj_desc; |
| 451 | union acpi_operand_object **operand; |
| 452 | struct acpi_namespace_node *node; |
| 453 | union acpi_parse_object *next_op; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 454 | struct acpi_table_header *table; |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 455 | u32 table_index; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 456 | |
| 457 | ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op); |
| 458 | |
| 459 | /* |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 460 | * This is where we evaluate the Signature string, oem_id string, |
| 461 | * and oem_table_id string of the Data Table Region declaration |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 462 | */ |
| 463 | node = op->common.node; |
| 464 | |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 465 | /* next_op points to Signature string op */ |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 466 | |
| 467 | next_op = op->common.value.arg; |
| 468 | |
| 469 | /* |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 470 | * Evaluate/create the Signature string, oem_id string, |
| 471 | * and oem_table_id string operands |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 472 | */ |
| 473 | status = acpi_ds_create_operands(walk_state, next_op); |
| 474 | if (ACPI_FAILURE(status)) { |
| 475 | return_ACPI_STATUS(status); |
| 476 | } |
| 477 | |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 478 | operand = &walk_state->operands[0]; |
| 479 | |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 480 | /* |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 481 | * Resolve the Signature string, oem_id string, |
| 482 | * and oem_table_id string operands |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 483 | */ |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 484 | status = |
| 485 | acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS, |
| 486 | walk_state); |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 487 | if (ACPI_FAILURE(status)) { |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 488 | goto cleanup; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 489 | } |
| 490 | |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 491 | /* Find the ACPI table */ |
| 492 | |
| 493 | status = acpi_tb_find_table(operand[0]->string.pointer, |
| 494 | operand[1]->string.pointer, |
| 495 | operand[2]->string.pointer, &table_index); |
| 496 | if (ACPI_FAILURE(status)) { |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 497 | if (status == AE_NOT_FOUND) { |
| 498 | ACPI_ERROR((AE_INFO, |
| 499 | "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT", |
| 500 | operand[0]->string.pointer, |
| 501 | operand[1]->string.pointer, |
| 502 | operand[2]->string.pointer)); |
| 503 | } |
| 504 | goto cleanup; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 505 | } |
| 506 | |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 507 | status = acpi_get_table_by_index(table_index, &table); |
| 508 | if (ACPI_FAILURE(status)) { |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 509 | goto cleanup; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | obj_desc = acpi_ns_get_attached_object(node); |
| 513 | if (!obj_desc) { |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 514 | status = AE_NOT_EXIST; |
| 515 | goto cleanup; |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 516 | } |
| 517 | |
Lv Zheng | 6d3fd3c | 2015-04-13 11:48:37 +0800 | [diff] [blame] | 518 | obj_desc->region.address = ACPI_PTR_TO_PHYSADDR(table); |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 519 | obj_desc->region.length = table->length; |
| 520 | |
| 521 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", |
| 522 | obj_desc, |
Lv Zheng | 1d0a0b2 | 2015-04-13 11:48:52 +0800 | [diff] [blame] | 523 | ACPI_FORMAT_UINT64(obj_desc->region.address), |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 524 | obj_desc->region.length)); |
| 525 | |
| 526 | /* Now the address and length are valid for this opregion */ |
| 527 | |
| 528 | obj_desc->region.flags |= AOPOBJ_DATA_VALID; |
| 529 | |
Bob Moore | 9f41fd8 | 2015-08-25 10:28:39 +0800 | [diff] [blame] | 530 | cleanup: |
| 531 | acpi_ut_remove_reference(operand[0]); |
| 532 | acpi_ut_remove_reference(operand[1]); |
| 533 | acpi_ut_remove_reference(operand[2]); |
| 534 | |
Lin Ming | 941f48b | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 535 | return_ACPI_STATUS(status); |
| 536 | } |
| 537 | |
| 538 | /******************************************************************************* |
| 539 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | * FUNCTION: acpi_ds_eval_data_object_operands |
| 541 | * |
| 542 | * PARAMETERS: walk_state - Current walk |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 543 | * op - A valid data_object Op object |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | * obj_desc - data_object |
| 545 | * |
| 546 | * RETURN: Status |
| 547 | * |
| 548 | * DESCRIPTION: Get the operands and complete the following data object types: |
| 549 | * Buffer, Package. |
| 550 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 551 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
| 553 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 554 | acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, |
| 555 | union acpi_parse_object *op, |
| 556 | union acpi_operand_object *obj_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 558 | acpi_status status; |
| 559 | union acpi_operand_object *arg_desc; |
| 560 | u32 length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 562 | ACPI_FUNCTION_TRACE(ds_eval_data_object_operands); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
| 564 | /* The first operand (for all of these data objects) is the length */ |
| 565 | |
Bob Moore | 773069d | 2008-04-10 19:06:36 +0400 | [diff] [blame] | 566 | /* |
| 567 | * Set proper index into operand stack for acpi_ds_obj_stack_push |
| 568 | * invoked inside acpi_ds_create_operand. |
| 569 | */ |
| 570 | walk_state->operand_index = walk_state->num_operands; |
| 571 | |
Bob Moore | a62a711 | 2017-08-03 14:27:22 +0800 | [diff] [blame] | 572 | /* Ignore if child is not valid */ |
| 573 | |
| 574 | if (!op->common.value.arg) { |
| 575 | ACPI_ERROR((AE_INFO, |
Bob Moore | 1ef6323 | 2018-02-15 13:09:28 -0800 | [diff] [blame] | 576 | "Missing child while evaluating opcode %4.4X, Op %p", |
| 577 | op->common.aml_opcode, op)); |
Bob Moore | a62a711 | 2017-08-03 14:27:22 +0800 | [diff] [blame] | 578 | return_ACPI_STATUS(AE_OK); |
| 579 | } |
| 580 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 581 | status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); |
| 582 | if (ACPI_FAILURE(status)) { |
| 583 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | } |
| 585 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 586 | status = acpi_ex_resolve_operands(walk_state->opcode, |
| 587 | &(walk_state-> |
| 588 | operands[walk_state->num_operands - |
| 589 | 1]), walk_state); |
| 590 | if (ACPI_FAILURE(status)) { |
| 591 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | /* Extract length operand */ |
| 595 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 596 | arg_desc = walk_state->operands[walk_state->num_operands - 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | length = (u32) arg_desc->integer.value; |
| 598 | |
| 599 | /* Cleanup for length operand */ |
| 600 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 601 | status = acpi_ds_obj_stack_pop(1, walk_state); |
| 602 | if (ACPI_FAILURE(status)) { |
| 603 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 606 | acpi_ut_remove_reference(arg_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
| 608 | /* |
| 609 | * Create the actual data object |
| 610 | */ |
| 611 | switch (op->common.aml_opcode) { |
| 612 | case AML_BUFFER_OP: |
| 613 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 614 | status = |
| 615 | acpi_ds_build_internal_buffer_obj(walk_state, op, length, |
| 616 | &obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | break; |
| 618 | |
| 619 | case AML_PACKAGE_OP: |
Bob Moore | 9ff5a21a | 2017-04-26 16:18:40 +0800 | [diff] [blame] | 620 | case AML_VARIABLE_PACKAGE_OP: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 622 | status = |
| 623 | acpi_ds_build_internal_package_obj(walk_state, op, length, |
| 624 | &obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | break; |
| 626 | |
| 627 | default: |
Chao Guan | 1d1ea1b7 | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 628 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 629 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | } |
| 631 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 632 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 634 | * 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] | 635 | * in this case, the return object will be stored in the parse tree |
| 636 | * for the package. |
| 637 | */ |
| 638 | if ((!op->common.parent) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 639 | ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) && |
| 640 | (op->common.parent->common.aml_opcode != |
Bob Moore | 9ff5a21a | 2017-04-26 16:18:40 +0800 | [diff] [blame] | 641 | AML_VARIABLE_PACKAGE_OP) |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 642 | && (op->common.parent->common.aml_opcode != |
| 643 | AML_NAME_OP))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | walk_state->result_obj = obj_desc; |
| 645 | } |
| 646 | } |
| 647 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 648 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | } |
| 650 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | /******************************************************************************* |
| 652 | * |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 653 | * FUNCTION: acpi_ds_eval_bank_field_operands |
| 654 | * |
| 655 | * PARAMETERS: walk_state - Current walk |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 656 | * op - A valid bank_field Op object |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 657 | * |
| 658 | * RETURN: Status |
| 659 | * |
| 660 | * DESCRIPTION: Get bank_field bank_value |
| 661 | * Called from acpi_ds_exec_end_op during bank_field parse tree walk |
| 662 | * |
| 663 | ******************************************************************************/ |
| 664 | |
| 665 | acpi_status |
| 666 | acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state, |
| 667 | union acpi_parse_object *op) |
| 668 | { |
| 669 | acpi_status status; |
| 670 | union acpi_operand_object *obj_desc; |
| 671 | union acpi_operand_object *operand_desc; |
| 672 | struct acpi_namespace_node *node; |
| 673 | union acpi_parse_object *next_op; |
| 674 | union acpi_parse_object *arg; |
| 675 | |
| 676 | ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op); |
| 677 | |
| 678 | /* |
| 679 | * This is where we evaluate the bank_value field of the |
| 680 | * bank_field declaration |
| 681 | */ |
| 682 | |
| 683 | /* next_op points to the op that holds the Region */ |
| 684 | |
| 685 | next_op = op->common.value.arg; |
| 686 | |
| 687 | /* next_op points to the op that holds the Bank Register */ |
| 688 | |
| 689 | next_op = next_op->common.next; |
| 690 | |
| 691 | /* next_op points to the op that holds the Bank Value */ |
| 692 | |
| 693 | next_op = next_op->common.next; |
| 694 | |
| 695 | /* |
| 696 | * Set proper index into operand stack for acpi_ds_obj_stack_push |
| 697 | * invoked inside acpi_ds_create_operand. |
| 698 | * |
| 699 | * We use walk_state->Operands[0] to store the evaluated bank_value |
| 700 | */ |
| 701 | walk_state->operand_index = 0; |
| 702 | |
| 703 | status = acpi_ds_create_operand(walk_state, next_op, 0); |
| 704 | if (ACPI_FAILURE(status)) { |
| 705 | return_ACPI_STATUS(status); |
| 706 | } |
| 707 | |
| 708 | status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state); |
| 709 | if (ACPI_FAILURE(status)) { |
| 710 | return_ACPI_STATUS(status); |
| 711 | } |
| 712 | |
Bob Moore | 71d993e | 2008-06-10 14:25:05 +0800 | [diff] [blame] | 713 | ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS, |
| 714 | acpi_ps_get_opcode_name(op->common.aml_opcode), 1); |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 715 | /* |
| 716 | * Get the bank_value operand and save it |
| 717 | * (at Top of stack) |
| 718 | */ |
| 719 | operand_desc = walk_state->operands[0]; |
| 720 | |
| 721 | /* Arg points to the start Bank Field */ |
| 722 | |
| 723 | arg = acpi_ps_get_arg(op, 4); |
| 724 | while (arg) { |
| 725 | |
| 726 | /* Ignore OFFSET and ACCESSAS terms here */ |
| 727 | |
| 728 | if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { |
| 729 | node = arg->common.node; |
| 730 | |
| 731 | obj_desc = acpi_ns_get_attached_object(node); |
| 732 | if (!obj_desc) { |
| 733 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 734 | } |
| 735 | |
| 736 | obj_desc->bank_field.value = |
| 737 | (u32) operand_desc->integer.value; |
| 738 | } |
| 739 | |
| 740 | /* Move to next field in the list */ |
| 741 | |
| 742 | arg = arg->common.next; |
| 743 | } |
| 744 | |
| 745 | acpi_ut_remove_reference(operand_desc); |
| 746 | return_ACPI_STATUS(status); |
| 747 | } |