Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: dsfield - Dispatcher field routines |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 7735ca0 | 2017-02-08 11:00:08 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2017, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "amlcode.h" |
| 47 | #include "acdispat.h" |
| 48 | #include "acinterp.h" |
| 49 | #include "acnamesp.h" |
| 50 | #include "acparser.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #define _COMPONENT ACPI_DISPATCHER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | ACPI_MODULE_NAME("dsfield") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | /* Local prototypes */ |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 56 | #ifdef ACPI_ASL_COMPILER |
| 57 | #include "acdisasm.h" |
| 58 | static acpi_status |
| 59 | acpi_ds_create_external_region(acpi_status lookup_status, |
| 60 | union acpi_parse_object *op, |
| 61 | char *path, |
| 62 | struct acpi_walk_state *walk_state, |
| 63 | struct acpi_namespace_node **node); |
| 64 | #endif |
| 65 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 66 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 67 | acpi_ds_get_field_names(struct acpi_create_field_info *info, |
| 68 | struct acpi_walk_state *walk_state, |
| 69 | union acpi_parse_object *arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 71 | #ifdef ACPI_ASL_COMPILER |
| 72 | /******************************************************************************* |
| 73 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 74 | * FUNCTION: acpi_ds_create_external_region (iASL Disassembler only) |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 75 | * |
| 76 | * PARAMETERS: lookup_status - Status from ns_lookup operation |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 77 | * op - Op containing the Field definition and args |
| 78 | * path - Pathname of the region |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 79 | * ` walk_state - Current method state |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 80 | * node - Where the new region node is returned |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 81 | * |
| 82 | * RETURN: Status |
| 83 | * |
| 84 | * DESCRIPTION: Add region to the external list if NOT_FOUND. Create a new |
| 85 | * region node/object. |
| 86 | * |
| 87 | ******************************************************************************/ |
| 88 | |
| 89 | static acpi_status |
| 90 | acpi_ds_create_external_region(acpi_status lookup_status, |
| 91 | union acpi_parse_object *op, |
| 92 | char *path, |
| 93 | struct acpi_walk_state *walk_state, |
| 94 | struct acpi_namespace_node **node) |
| 95 | { |
| 96 | acpi_status status; |
| 97 | union acpi_operand_object *obj_desc; |
| 98 | |
| 99 | if (lookup_status != AE_NOT_FOUND) { |
| 100 | return (lookup_status); |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | * Table disassembly: |
| 105 | * operation_region not found. Generate an External for it, and |
| 106 | * insert the name into the namespace. |
| 107 | */ |
Bob Moore | 5af2b63 | 2014-01-08 13:43:18 +0800 | [diff] [blame] | 108 | acpi_dm_add_op_to_external_list(op, path, ACPI_TYPE_REGION, 0, 0); |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 109 | |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 110 | status = acpi_ns_lookup(walk_state->scope_info, path, ACPI_TYPE_REGION, |
| 111 | ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, |
| 112 | walk_state, node); |
| 113 | if (ACPI_FAILURE(status)) { |
| 114 | return (status); |
| 115 | } |
| 116 | |
| 117 | /* Must create and install a region object for the new node */ |
| 118 | |
| 119 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION); |
| 120 | if (!obj_desc) { |
| 121 | return (AE_NO_MEMORY); |
| 122 | } |
| 123 | |
| 124 | obj_desc->region.node = *node; |
| 125 | status = acpi_ns_attach_object(*node, obj_desc, ACPI_TYPE_REGION); |
| 126 | return (status); |
| 127 | } |
| 128 | #endif |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | /******************************************************************************* |
| 131 | * |
| 132 | * FUNCTION: acpi_ds_create_buffer_field |
| 133 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 134 | * PARAMETERS: op - Current parse op (create_XXField) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | * walk_state - Current state |
| 136 | * |
| 137 | * RETURN: Status |
| 138 | * |
| 139 | * DESCRIPTION: Execute the create_field operators: |
| 140 | * create_bit_field_op, |
| 141 | * create_byte_field_op, |
| 142 | * create_word_field_op, |
| 143 | * create_dword_field_op, |
| 144 | * create_qword_field_op, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 145 | * create_field_op (all of which define a field in a buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | * |
| 147 | ******************************************************************************/ |
| 148 | |
| 149 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 150 | acpi_ds_create_buffer_field(union acpi_parse_object *op, |
| 151 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | union acpi_parse_object *arg; |
| 154 | struct acpi_namespace_node *node; |
| 155 | acpi_status status; |
| 156 | union acpi_operand_object *obj_desc; |
| 157 | union acpi_operand_object *second_desc = NULL; |
| 158 | u32 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 160 | ACPI_FUNCTION_TRACE(ds_create_buffer_field); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 162 | /* |
| 163 | * Get the name_string argument (name of the new buffer_field) |
| 164 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | if (op->common.aml_opcode == AML_CREATE_FIELD_OP) { |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 166 | |
| 167 | /* For create_field, name is the 4th argument */ |
| 168 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | arg = acpi_ps_get_arg(op, 3); |
| 170 | } else { |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 171 | /* For all other create_XXXField operators, name is the 3rd argument */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 173 | arg = acpi_ps_get_arg(op, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | if (!arg) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 177 | return_ACPI_STATUS(AE_AML_NO_OPERAND); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | if (walk_state->deferred_node) { |
| 181 | node = walk_state->deferred_node; |
| 182 | status = AE_OK; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 183 | } else { |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 184 | /* Execute flag should always be set when this function is entered */ |
| 185 | |
| 186 | if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) { |
Bob Moore | 376a588 | 2017-08-03 14:27:28 +0800 | [diff] [blame] | 187 | ACPI_ERROR((AE_INFO, "Parse execute mode is not set")); |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 188 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 191 | /* Creating new namespace node, should not already exist */ |
| 192 | |
| 193 | flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | |
| 194 | ACPI_NS_ERROR_IF_FOUND; |
| 195 | |
Lin Ming | 7f0c826 | 2009-08-13 14:03:15 +0800 | [diff] [blame] | 196 | /* |
| 197 | * Mark node temporary if we are executing a normal control |
| 198 | * method. (Don't mark if this is a module-level code method) |
| 199 | */ |
| 200 | if (walk_state->method_node && |
| 201 | !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) { |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 202 | flags |= ACPI_NS_TEMPORARY; |
| 203 | } |
| 204 | |
| 205 | /* Enter the name_string into the namespace */ |
| 206 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 207 | status = acpi_ns_lookup(walk_state->scope_info, |
| 208 | arg->common.value.string, ACPI_TYPE_ANY, |
| 209 | ACPI_IMODE_LOAD_PASS1, flags, |
| 210 | walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 211 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 212 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 213 | arg->common.value.string, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 214 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | |
Bob Moore | 9c52657 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 218 | /* |
| 219 | * We could put the returned object (Node) on the object stack for later, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 220 | * but for now, we will put it in the "op" object that the parser uses, |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 221 | * so we can get it again at the end of this scope. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | */ |
| 223 | op->common.node = node; |
| 224 | |
| 225 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 226 | * If there is no object attached to the node, this node was just created |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 227 | * and we need to create the field object. Otherwise, this was a lookup |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 228 | * of an existing node and we don't want to create the field object again. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 230 | obj_desc = acpi_ns_get_attached_object(node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | if (obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | /* |
| 236 | * The Field definition is not fully parsed at this time. |
| 237 | * (We must save the address of the AML for the buffer and index operands) |
| 238 | */ |
| 239 | |
| 240 | /* Create the buffer field object */ |
| 241 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 242 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | if (!obj_desc) { |
| 244 | status = AE_NO_MEMORY; |
| 245 | goto cleanup; |
| 246 | } |
| 247 | |
| 248 | /* |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 249 | * Remember location in AML stream of the field unit opcode and operands |
| 250 | * -- since the buffer and index operands must be evaluated. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 252 | second_desc = obj_desc->common.next_object; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | second_desc->extra.aml_start = op->named.data; |
| 254 | second_desc->extra.aml_length = op->named.length; |
| 255 | obj_desc->buffer_field.node = node; |
| 256 | |
| 257 | /* Attach constructed field descriptors to parent node */ |
| 258 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 259 | status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD); |
| 260 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | goto cleanup; |
| 262 | } |
| 263 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 264 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
| 266 | /* Remove local reference to the object */ |
| 267 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | acpi_ut_remove_reference(obj_desc); |
| 269 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | /******************************************************************************* |
| 273 | * |
| 274 | * FUNCTION: acpi_ds_get_field_names |
| 275 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 276 | * PARAMETERS: info - create_field info structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | * ` walk_state - Current method state |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 278 | * arg - First parser arg for the field name list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | * |
| 280 | * RETURN: Status |
| 281 | * |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 282 | * DESCRIPTION: Process all named fields in a field declaration. Names are |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | * entered into the namespace. |
| 284 | * |
| 285 | ******************************************************************************/ |
| 286 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 287 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 288 | acpi_ds_get_field_names(struct acpi_create_field_info *info, |
| 289 | struct acpi_walk_state *walk_state, |
| 290 | union acpi_parse_object *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 292 | acpi_status status; |
Bob Moore | 5df7e6c | 2010-01-21 10:06:32 +0800 | [diff] [blame] | 293 | u64 position; |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 294 | union acpi_parse_object *child; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 296 | ACPI_FUNCTION_TRACE_PTR(ds_get_field_names, info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
| 298 | /* First field starts at bit zero */ |
| 299 | |
| 300 | info->field_bit_position = 0; |
| 301 | |
| 302 | /* Process all elements in the field list (of parse nodes) */ |
| 303 | |
| 304 | while (arg) { |
| 305 | /* |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 306 | * Four types of field elements are handled: |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 307 | * 1) name - Enters a new named field into the namespace |
| 308 | * 2) offset - specifies a bit offset |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 309 | * 3) access_as - changes the access mode/attributes |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 310 | * 4) connection - Associate a resource template with the field |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | */ |
| 312 | switch (arg->common.aml_opcode) { |
| 313 | case AML_INT_RESERVEDFIELD_OP: |
| 314 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 315 | position = (u64)info->field_bit_position + |
| 316 | (u64)arg->common.value.size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | |
| 318 | if (position > ACPI_UINT32_MAX) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 319 | ACPI_ERROR((AE_INFO, |
| 320 | "Bit offset within field too large (> 0xFFFFFFFF)")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 321 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | info->field_bit_position = (u32) position; |
| 325 | break; |
| 326 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | case AML_INT_ACCESSFIELD_OP: |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 328 | case AML_INT_EXTACCESSFIELD_OP: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | /* |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 330 | * Get new access_type, access_attribute, and access_length fields |
| 331 | * -- to be used for all field units that follow, until the |
| 332 | * end-of-field or another access_as keyword is encountered. |
| 333 | * NOTE. These three bytes are encoded in the integer value |
| 334 | * of the parseop for convenience. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 336 | * In field_flags, preserve the flag bits other than the |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 337 | * ACCESS_TYPE bits. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | */ |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 339 | |
| 340 | /* access_type (byte_acc, word_acc, etc.) */ |
| 341 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 342 | info->field_flags = (u8) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | ((info-> |
| 344 | field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 345 | ((u8)((u32)(arg->common.value.integer & 0x07)))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 347 | /* access_attribute (attrib_quick, attrib_byte, etc.) */ |
| 348 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 349 | info->attribute = (u8) |
| 350 | ((arg->common.value.integer >> 8) & 0xFF); |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 351 | |
| 352 | /* access_length (for serial/buffer protocols) */ |
| 353 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 354 | info->access_length = (u8) |
| 355 | ((arg->common.value.integer >> 16) & 0xFF); |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 356 | break; |
| 357 | |
| 358 | case AML_INT_CONNECTION_OP: |
| 359 | /* |
| 360 | * Clear any previous connection. New connection is used for all |
| 361 | * fields that follow, similar to access_as |
| 362 | */ |
| 363 | info->resource_buffer = NULL; |
| 364 | info->connection_node = NULL; |
Bob Moore | 75ec6e5 | 2014-09-23 10:35:47 +0800 | [diff] [blame] | 365 | info->pin_number_index = 0; |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 366 | |
| 367 | /* |
| 368 | * A Connection() is either an actual resource descriptor (buffer) |
| 369 | * or a named reference to a resource template |
| 370 | */ |
| 371 | child = arg->common.value.arg; |
| 372 | if (child->common.aml_opcode == AML_INT_BYTELIST_OP) { |
| 373 | info->resource_buffer = child->named.data; |
| 374 | info->resource_length = |
| 375 | (u16)child->named.value.integer; |
| 376 | } else { |
| 377 | /* Lookup the Connection() namepath, it should already exist */ |
| 378 | |
| 379 | status = acpi_ns_lookup(walk_state->scope_info, |
| 380 | child->common.value. |
| 381 | name, ACPI_TYPE_ANY, |
| 382 | ACPI_IMODE_EXECUTE, |
| 383 | ACPI_NS_DONT_OPEN_SCOPE, |
| 384 | walk_state, |
| 385 | &info->connection_node); |
| 386 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 387 | ACPI_ERROR_NAMESPACE(walk_state-> |
| 388 | scope_info, |
| 389 | child->common. |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 390 | value.name, |
| 391 | status); |
| 392 | return_ACPI_STATUS(status); |
| 393 | } |
| 394 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | break; |
| 396 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | case AML_INT_NAMEDFIELD_OP: |
| 398 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 399 | /* Lookup the name, it should already exist */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 401 | status = acpi_ns_lookup(walk_state->scope_info, |
| 402 | (char *)&arg->named.name, |
| 403 | info->field_type, |
| 404 | ACPI_IMODE_EXECUTE, |
| 405 | ACPI_NS_DONT_OPEN_SCOPE, |
| 406 | walk_state, &info->field_node); |
| 407 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 408 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 409 | (char *)&arg->named.name, |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 410 | status); |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 411 | return_ACPI_STATUS(status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 412 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | arg->common.node = info->field_node; |
| 414 | info->field_bit_length = arg->common.value.size; |
| 415 | |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 416 | /* |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 417 | * If there is no object attached to the node, this node was |
| 418 | * just created and we need to create the field object. |
| 419 | * Otherwise, this was a lookup of an existing node and we |
| 420 | * don't want to create the field object again. |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 421 | */ |
| 422 | if (!acpi_ns_get_attached_object |
| 423 | (info->field_node)) { |
| 424 | status = acpi_ex_prep_field_value(info); |
| 425 | if (ACPI_FAILURE(status)) { |
| 426 | return_ACPI_STATUS(status); |
| 427 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
| 431 | /* Keep track of bit position for the next field */ |
| 432 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 433 | position = (u64)info->field_bit_position + |
| 434 | (u64)arg->common.value.size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
| 436 | if (position > ACPI_UINT32_MAX) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 437 | ACPI_ERROR((AE_INFO, |
| 438 | "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", |
| 439 | ACPI_CAST_PTR(char, |
| 440 | &info->field_node-> |
| 441 | name))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 442 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | info->field_bit_position += info->field_bit_length; |
Bob Moore | 75ec6e5 | 2014-09-23 10:35:47 +0800 | [diff] [blame] | 446 | info->pin_number_index++; /* Index relative to previous Connection() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | break; |
| 448 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | default: |
| 450 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 451 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 452 | "Invalid opcode in field list: 0x%X", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 453 | arg->common.aml_opcode)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 454 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | arg = arg->common.next; |
| 458 | } |
| 459 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 460 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | } |
| 462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | /******************************************************************************* |
| 464 | * |
| 465 | * FUNCTION: acpi_ds_create_field |
| 466 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 467 | * PARAMETERS: op - Op containing the Field definition and args |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | * region_node - Object for the containing Operation Region |
| 469 | * ` walk_state - Current method state |
| 470 | * |
| 471 | * RETURN: Status |
| 472 | * |
| 473 | * DESCRIPTION: Create a new field in the specified operation region |
| 474 | * |
| 475 | ******************************************************************************/ |
| 476 | |
| 477 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 478 | acpi_ds_create_field(union acpi_parse_object *op, |
| 479 | struct acpi_namespace_node *region_node, |
| 480 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 482 | acpi_status status; |
| 483 | union acpi_parse_object *arg; |
| 484 | struct acpi_create_field_info info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 486 | ACPI_FUNCTION_TRACE_PTR(ds_create_field, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | |
| 488 | /* First arg is the name of the parent op_region (must already exist) */ |
| 489 | |
| 490 | arg = op->common.value.arg; |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 491 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | if (!region_node) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 493 | status = |
| 494 | acpi_ns_lookup(walk_state->scope_info, |
| 495 | arg->common.value.name, ACPI_TYPE_REGION, |
| 496 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, |
| 497 | walk_state, ®ion_node); |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 498 | #ifdef ACPI_ASL_COMPILER |
| 499 | status = acpi_ds_create_external_region(status, arg, |
| 500 | arg->common.value.name, |
| 501 | walk_state, |
| 502 | ®ion_node); |
| 503 | #endif |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 505 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 506 | arg->common.value.name, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 507 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 511 | memset(&info, 0, sizeof(struct acpi_create_field_info)); |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 512 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | /* Second arg is the field flags */ |
| 514 | |
| 515 | arg = arg->common.next; |
| 516 | info.field_flags = (u8) arg->common.value.integer; |
| 517 | info.attribute = 0; |
| 518 | |
| 519 | /* Each remaining arg is a Named Field */ |
| 520 | |
| 521 | info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD; |
| 522 | info.region_node = region_node; |
| 523 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 524 | status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 525 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } |
| 527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | /******************************************************************************* |
| 529 | * |
| 530 | * FUNCTION: acpi_ds_init_field_objects |
| 531 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 532 | * PARAMETERS: op - Op containing the Field definition and args |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | * ` walk_state - Current method state |
| 534 | * |
| 535 | * RETURN: Status |
| 536 | * |
| 537 | * DESCRIPTION: For each "Field Unit" name in the argument list that is |
| 538 | * part of the field declaration, enter the name into the |
| 539 | * namespace. |
| 540 | * |
| 541 | ******************************************************************************/ |
| 542 | |
| 543 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 544 | acpi_ds_init_field_objects(union acpi_parse_object *op, |
| 545 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 547 | acpi_status status; |
| 548 | union acpi_parse_object *arg = NULL; |
| 549 | struct acpi_namespace_node *node; |
| 550 | u8 type = 0; |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 551 | u32 flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 553 | ACPI_FUNCTION_TRACE_PTR(ds_init_field_objects, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 555 | /* Execute flag should always be set when this function is entered */ |
| 556 | |
| 557 | if (!(walk_state->parse_flags & ACPI_PARSE_EXECUTE)) { |
| 558 | if (walk_state->parse_flags & ACPI_PARSE_DEFERRED_OP) { |
| 559 | |
| 560 | /* bank_field Op is deferred, just return OK */ |
| 561 | |
| 562 | return_ACPI_STATUS(AE_OK); |
| 563 | } |
| 564 | |
Bob Moore | 376a588 | 2017-08-03 14:27:28 +0800 | [diff] [blame] | 565 | ACPI_ERROR((AE_INFO, "Parse deferred mode is not set")); |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 566 | return_ACPI_STATUS(AE_AML_INTERNAL); |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 567 | } |
| 568 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 569 | /* |
| 570 | * Get the field_list argument for this opcode. This is the start of the |
| 571 | * list of field elements. |
| 572 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | switch (walk_state->opcode) { |
| 574 | case AML_FIELD_OP: |
Chao Guan | 1d1ea1b7 | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 575 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 576 | arg = acpi_ps_get_arg(op, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | type = ACPI_TYPE_LOCAL_REGION_FIELD; |
| 578 | break; |
| 579 | |
| 580 | case AML_BANK_FIELD_OP: |
Chao Guan | 1d1ea1b7 | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 581 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 582 | arg = acpi_ps_get_arg(op, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | type = ACPI_TYPE_LOCAL_BANK_FIELD; |
| 584 | break; |
| 585 | |
| 586 | case AML_INDEX_FIELD_OP: |
Chao Guan | 1d1ea1b7 | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 587 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 588 | arg = acpi_ps_get_arg(op, 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | type = ACPI_TYPE_LOCAL_INDEX_FIELD; |
| 590 | break; |
| 591 | |
| 592 | default: |
Chao Guan | 1d1ea1b7 | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 593 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 594 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 597 | /* Creating new namespace node(s), should not already exist */ |
| 598 | |
| 599 | flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | |
| 600 | ACPI_NS_ERROR_IF_FOUND; |
| 601 | |
Lin Ming | 7f0c826 | 2009-08-13 14:03:15 +0800 | [diff] [blame] | 602 | /* |
| 603 | * Mark node(s) temporary if we are executing a normal control |
| 604 | * method. (Don't mark if this is a module-level code method) |
| 605 | */ |
| 606 | if (walk_state->method_node && |
| 607 | !(walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL)) { |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 608 | flags |= ACPI_NS_TEMPORARY; |
| 609 | } |
| 610 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | /* |
| 612 | * Walk the list of entries in the field_list |
Bob Moore | 7aa7d43 | 2008-06-10 13:00:32 +0800 | [diff] [blame] | 613 | * Note: field_list can be of zero length. In this case, Arg will be NULL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | */ |
| 615 | while (arg) { |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 616 | /* |
Bob Moore | 9ce8178 | 2011-11-16 13:39:07 +0800 | [diff] [blame] | 617 | * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested |
| 618 | * in the field names in order to enter them into the namespace. |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 619 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 621 | status = acpi_ns_lookup(walk_state->scope_info, |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 622 | (char *)&arg->named.name, type, |
| 623 | ACPI_IMODE_LOAD_PASS1, flags, |
| 624 | walk_state, &node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 625 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 626 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 627 | (char *)&arg->named.name, |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 628 | status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | if (status != AE_ALREADY_EXISTS) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 630 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | /* Name already exists, just ignore this error */ |
| 634 | |
| 635 | status = AE_OK; |
| 636 | } |
| 637 | |
| 638 | arg->common.node = node; |
| 639 | } |
| 640 | |
Bob Moore | cca97b8 | 2008-04-10 19:06:44 +0400 | [diff] [blame] | 641 | /* Get the next field element in the list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
| 643 | arg = arg->common.next; |
| 644 | } |
| 645 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 646 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
| 648 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | /******************************************************************************* |
| 650 | * |
| 651 | * FUNCTION: acpi_ds_create_bank_field |
| 652 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 653 | * PARAMETERS: op - Op containing the Field definition and args |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | * region_node - Object for the containing Operation Region |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 655 | * walk_state - Current method state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | * |
| 657 | * RETURN: Status |
| 658 | * |
| 659 | * DESCRIPTION: Create a new bank field in the specified operation region |
| 660 | * |
| 661 | ******************************************************************************/ |
| 662 | |
| 663 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 664 | acpi_ds_create_bank_field(union acpi_parse_object *op, |
| 665 | struct acpi_namespace_node *region_node, |
| 666 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 668 | acpi_status status; |
| 669 | union acpi_parse_object *arg; |
| 670 | struct acpi_create_field_info info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 672 | ACPI_FUNCTION_TRACE_PTR(ds_create_bank_field, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
| 674 | /* First arg is the name of the parent op_region (must already exist) */ |
| 675 | |
| 676 | arg = op->common.value.arg; |
| 677 | if (!region_node) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 678 | status = |
| 679 | acpi_ns_lookup(walk_state->scope_info, |
| 680 | arg->common.value.name, ACPI_TYPE_REGION, |
| 681 | ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, |
| 682 | walk_state, ®ion_node); |
Bob Moore | 6ccd7b5 | 2012-05-22 16:22:01 +0800 | [diff] [blame] | 683 | #ifdef ACPI_ASL_COMPILER |
| 684 | status = acpi_ds_create_external_region(status, arg, |
| 685 | arg->common.value.name, |
| 686 | walk_state, |
| 687 | ®ion_node); |
| 688 | #endif |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 690 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 691 | arg->common.value.name, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 692 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | |
| 696 | /* Second arg is the Bank Register (Field) (must already exist) */ |
| 697 | |
| 698 | arg = arg->common.next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 699 | status = |
| 700 | acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, |
| 701 | ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, |
| 702 | ACPI_NS_SEARCH_PARENT, walk_state, |
| 703 | &info.register_node); |
| 704 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 705 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 706 | arg->common.value.string, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 707 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | } |
| 709 | |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 710 | /* |
| 711 | * Third arg is the bank_value |
| 712 | * This arg is a term_arg, not a constant |
| 713 | * It will be evaluated later, by acpi_ds_eval_bank_field_operands |
| 714 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | arg = arg->common.next; |
Bob Moore | 9c52657 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 716 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | /* Fourth arg is the field flags */ |
| 718 | |
| 719 | arg = arg->common.next; |
| 720 | info.field_flags = (u8) arg->common.value.integer; |
| 721 | |
| 722 | /* Each remaining arg is a Named Field */ |
| 723 | |
| 724 | info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD; |
| 725 | info.region_node = region_node; |
| 726 | |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 727 | /* |
| 728 | * Use Info.data_register_node to store bank_field Op |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 729 | * It's safe because data_register_node will never be used when create |
| 730 | * bank field \we store aml_start and aml_length in the bank_field Op for |
| 731 | * late evaluation. Used in acpi_ex_prep_field_value(Info) |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 732 | * |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 733 | * TBD: Or, should we add a field in struct acpi_create_field_info, like |
| 734 | * "void *ParentOp"? |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 735 | */ |
| 736 | info.data_register_node = (struct acpi_namespace_node *)op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | |
Lin Ming | ef805d9 | 2008-04-10 19:06:41 +0400 | [diff] [blame] | 738 | status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 739 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | } |
| 741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | /******************************************************************************* |
| 743 | * |
| 744 | * FUNCTION: acpi_ds_create_index_field |
| 745 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 746 | * PARAMETERS: op - Op containing the Field definition and args |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | * region_node - Object for the containing Operation Region |
| 748 | * ` walk_state - Current method state |
| 749 | * |
| 750 | * RETURN: Status |
| 751 | * |
| 752 | * DESCRIPTION: Create a new index field in the specified operation region |
| 753 | * |
| 754 | ******************************************************************************/ |
| 755 | |
| 756 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 757 | acpi_ds_create_index_field(union acpi_parse_object *op, |
| 758 | struct acpi_namespace_node *region_node, |
| 759 | struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 761 | acpi_status status; |
| 762 | union acpi_parse_object *arg; |
| 763 | struct acpi_create_field_info info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 765 | ACPI_FUNCTION_TRACE_PTR(ds_create_index_field, op); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | |
| 767 | /* First arg is the name of the Index register (must already exist) */ |
| 768 | |
| 769 | arg = op->common.value.arg; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 770 | status = |
| 771 | acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, |
| 772 | ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, |
| 773 | ACPI_NS_SEARCH_PARENT, walk_state, |
| 774 | &info.register_node); |
| 775 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 776 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 777 | arg->common.value.string, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 778 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /* Second arg is the data register (must already exist) */ |
| 782 | |
| 783 | arg = arg->common.next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 784 | status = |
| 785 | acpi_ns_lookup(walk_state->scope_info, arg->common.value.string, |
| 786 | ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, |
| 787 | ACPI_NS_SEARCH_PARENT, walk_state, |
| 788 | &info.data_register_node); |
| 789 | if (ACPI_FAILURE(status)) { |
Bob Moore | 16ccf82 | 2017-11-17 15:42:22 -0800 | [diff] [blame] | 790 | ACPI_ERROR_NAMESPACE(walk_state->scope_info, |
| 791 | arg->common.value.string, status); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 792 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | /* Next arg is the field flags */ |
| 796 | |
| 797 | arg = arg->common.next; |
| 798 | info.field_flags = (u8) arg->common.value.integer; |
| 799 | |
| 800 | /* Each remaining arg is a Named Field */ |
| 801 | |
| 802 | info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD; |
| 803 | info.region_node = region_node; |
| 804 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 805 | status = acpi_ds_get_field_names(&info, walk_state, arg->common.next); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 806 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | } |