blob: f3a008ff1eae977c2b9006c41f263d6c5943a081 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: dsfield - Dispatcher field routines
4 *
5 *****************************************************************************/
6
7/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/amlcode.h>
46#include <acpi/acdispat.h>
47#include <acpi/acinterp.h>
48#include <acpi/acnamesp.h>
49#include <acpi/acparser.h>
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define _COMPONENT ACPI_DISPATCHER
Len Brown4be44fc2005-08-05 00:44:28 -040052ACPI_MODULE_NAME("dsfield")
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Robert Moore44f6c012005-04-18 22:49:35 -040054/* Local prototypes */
Robert Moore44f6c012005-04-18 22:49:35 -040055static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040056acpi_ds_get_field_names(struct acpi_create_field_info *info,
57 struct acpi_walk_state *walk_state,
58 union acpi_parse_object *arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60/*******************************************************************************
61 *
62 * FUNCTION: acpi_ds_create_buffer_field
63 *
Robert Moore44f6c012005-04-18 22:49:35 -040064 * PARAMETERS: Op - Current parse op (create_xXField)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 * walk_state - Current state
66 *
67 * RETURN: Status
68 *
69 * DESCRIPTION: Execute the create_field operators:
70 * create_bit_field_op,
71 * create_byte_field_op,
72 * create_word_field_op,
73 * create_dword_field_op,
74 * create_qword_field_op,
Robert Moore44f6c012005-04-18 22:49:35 -040075 * create_field_op (all of which define a field in a buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 *
77 ******************************************************************************/
78
79acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040080acpi_ds_create_buffer_field(union acpi_parse_object *op,
81 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Len Brown4be44fc2005-08-05 00:44:28 -040083 union acpi_parse_object *arg;
84 struct acpi_namespace_node *node;
85 acpi_status status;
86 union acpi_operand_object *obj_desc;
87 union acpi_operand_object *second_desc = NULL;
88 u32 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Len Brown4be44fc2005-08-05 00:44:28 -040090 ACPI_FUNCTION_TRACE("ds_create_buffer_field");
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92 /* Get the name_string argument */
93
94 if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
Len Brown4be44fc2005-08-05 00:44:28 -040095 arg = acpi_ps_get_arg(op, 3);
96 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 /* Create Bit/Byte/Word/Dword field */
98
Len Brown4be44fc2005-08-05 00:44:28 -040099 arg = acpi_ps_get_arg(op, 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 }
101
102 if (!arg) {
Len Brown4be44fc2005-08-05 00:44:28 -0400103 return_ACPI_STATUS(AE_AML_NO_OPERAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105
106 if (walk_state->deferred_node) {
107 node = walk_state->deferred_node;
108 status = AE_OK;
Len Brown4be44fc2005-08-05 00:44:28 -0400109 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 /*
111 * During the load phase, we want to enter the name of the field into
112 * the namespace. During the execute phase (when we evaluate the size
113 * operand), we want to lookup the name
114 */
115 if (walk_state->parse_flags & ACPI_PARSE_EXECUTE) {
116 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
Len Brown4be44fc2005-08-05 00:44:28 -0400117 } else {
Robert Moore44f6c012005-04-18 22:49:35 -0400118 flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
Len Brown4be44fc2005-08-05 00:44:28 -0400119 ACPI_NS_ERROR_IF_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 }
121
122 /*
123 * Enter the name_string into the namespace
124 */
Len Brown4be44fc2005-08-05 00:44:28 -0400125 status =
126 acpi_ns_lookup(walk_state->scope_info,
127 arg->common.value.string, ACPI_TYPE_ANY,
128 ACPI_IMODE_LOAD_PASS1, flags, walk_state,
129 &(node));
130 if (ACPI_FAILURE(status)) {
131 ACPI_REPORT_NSERROR(arg->common.value.string, status);
132 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 }
134 }
135
Robert Moore44f6c012005-04-18 22:49:35 -0400136 /* We could put the returned object (Node) on the object stack for later,
137 * but for now, we will put it in the "op" object that the parser uses,
138 * so we can get it again at the end of this scope
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 */
140 op->common.node = node;
141
142 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400143 * If there is no object attached to the node, this node was just created
144 * and we need to create the field object. Otherwise, this was a lookup
145 * of an existing node and we don't want to create the field object again.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 */
Len Brown4be44fc2005-08-05 00:44:28 -0400147 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 if (obj_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400149 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 }
151
152 /*
153 * The Field definition is not fully parsed at this time.
154 * (We must save the address of the AML for the buffer and index operands)
155 */
156
157 /* Create the buffer field object */
158
Len Brown4be44fc2005-08-05 00:44:28 -0400159 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER_FIELD);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 if (!obj_desc) {
161 status = AE_NO_MEMORY;
162 goto cleanup;
163 }
164
165 /*
166 * Remember location in AML stream of the field unit
167 * opcode and operands -- since the buffer and index
168 * operands must be evaluated.
169 */
Len Brown4be44fc2005-08-05 00:44:28 -0400170 second_desc = obj_desc->common.next_object;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 second_desc->extra.aml_start = op->named.data;
172 second_desc->extra.aml_length = op->named.length;
173 obj_desc->buffer_field.node = node;
174
175 /* Attach constructed field descriptors to parent node */
176
Len Brown4be44fc2005-08-05 00:44:28 -0400177 status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
178 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 goto cleanup;
180 }
181
Len Brown4be44fc2005-08-05 00:44:28 -0400182 cleanup:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184 /* Remove local reference to the object */
185
Len Brown4be44fc2005-08-05 00:44:28 -0400186 acpi_ut_remove_reference(obj_desc);
187 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188}
189
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190/*******************************************************************************
191 *
192 * FUNCTION: acpi_ds_get_field_names
193 *
194 * PARAMETERS: Info - create_field info structure
195 * ` walk_state - Current method state
196 * Arg - First parser arg for the field name list
197 *
198 * RETURN: Status
199 *
200 * DESCRIPTION: Process all named fields in a field declaration. Names are
201 * entered into the namespace.
202 *
203 ******************************************************************************/
204
Robert Moore44f6c012005-04-18 22:49:35 -0400205static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400206acpi_ds_get_field_names(struct acpi_create_field_info *info,
207 struct acpi_walk_state *walk_state,
208 union acpi_parse_object *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209{
Len Brown4be44fc2005-08-05 00:44:28 -0400210 acpi_status status;
211 acpi_integer position;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Len Brown4be44fc2005-08-05 00:44:28 -0400213 ACPI_FUNCTION_TRACE_PTR("ds_get_field_names", info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 /* First field starts at bit zero */
216
217 info->field_bit_position = 0;
218
219 /* Process all elements in the field list (of parse nodes) */
220
221 while (arg) {
222 /*
223 * Three types of field elements are handled:
224 * 1) Offset - specifies a bit offset
225 * 2) access_as - changes the access mode
226 * 3) Name - Enters a new named field into the namespace
227 */
228 switch (arg->common.aml_opcode) {
229 case AML_INT_RESERVEDFIELD_OP:
230
231 position = (acpi_integer) info->field_bit_position
Len Brown4be44fc2005-08-05 00:44:28 -0400232 + (acpi_integer) arg->common.value.size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 if (position > ACPI_UINT32_MAX) {
Len Brown4be44fc2005-08-05 00:44:28 -0400235 ACPI_REPORT_ERROR(("Bit offset within field too large (> 0xFFFFFFFF)\n"));
236 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
238
239 info->field_bit_position = (u32) position;
240 break;
241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 case AML_INT_ACCESSFIELD_OP:
243
244 /*
245 * Get a new access_type and access_attribute -- to be used for all
Robert Moore44f6c012005-04-18 22:49:35 -0400246 * field units that follow, until field end or another access_as
247 * keyword.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 *
Robert Moore44f6c012005-04-18 22:49:35 -0400249 * In field_flags, preserve the flag bits other than the
250 * ACCESS_TYPE bits
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 */
Robert Moore44f6c012005-04-18 22:49:35 -0400252 info->field_flags = (u8)
Len Brown4be44fc2005-08-05 00:44:28 -0400253 ((info->
254 field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
255 ((u8) ((u32) arg->common.value.integer >> 8)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257 info->attribute = (u8) (arg->common.value.integer);
258 break;
259
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 case AML_INT_NAMEDFIELD_OP:
261
262 /* Lookup the name */
263
Len Brown4be44fc2005-08-05 00:44:28 -0400264 status = acpi_ns_lookup(walk_state->scope_info,
265 (char *)&arg->named.name,
266 info->field_type,
267 ACPI_IMODE_EXECUTE,
268 ACPI_NS_DONT_OPEN_SCOPE,
269 walk_state, &info->field_node);
270 if (ACPI_FAILURE(status)) {
271 ACPI_REPORT_NSERROR((char *)&arg->named.name,
272 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 if (status != AE_ALREADY_EXISTS) {
Len Brown4be44fc2005-08-05 00:44:28 -0400274 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 }
276
277 /* Already exists, ignore error */
Len Brown4be44fc2005-08-05 00:44:28 -0400278 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 arg->common.node = info->field_node;
280 info->field_bit_length = arg->common.value.size;
281
282 /* Create and initialize an object for the new Field Node */
283
Len Brown4be44fc2005-08-05 00:44:28 -0400284 status = acpi_ex_prep_field_value(info);
285 if (ACPI_FAILURE(status)) {
286 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 }
288 }
289
290 /* Keep track of bit position for the next field */
291
292 position = (acpi_integer) info->field_bit_position
Len Brown4be44fc2005-08-05 00:44:28 -0400293 + (acpi_integer) arg->common.value.size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
295 if (position > ACPI_UINT32_MAX) {
Bob Moore4a90c7e2006-01-13 16:22:00 -0500296 ACPI_REPORT_ERROR(("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", ACPI_CAST_PTR(char, &info->field_node->name)));
Len Brown4be44fc2005-08-05 00:44:28 -0400297 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 }
299
300 info->field_bit_position += info->field_bit_length;
301 break;
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 default:
304
Bob Moore4a90c7e2006-01-13 16:22:00 -0500305 ACPI_REPORT_ERROR(("Invalid opcode in field list: %X\n",
306 arg->common.aml_opcode));
Len Brown4be44fc2005-08-05 00:44:28 -0400307 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 }
309
310 arg = arg->common.next;
311 }
312
Len Brown4be44fc2005-08-05 00:44:28 -0400313 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314}
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316/*******************************************************************************
317 *
318 * FUNCTION: acpi_ds_create_field
319 *
320 * PARAMETERS: Op - Op containing the Field definition and args
321 * region_node - Object for the containing Operation Region
322 * ` walk_state - Current method state
323 *
324 * RETURN: Status
325 *
326 * DESCRIPTION: Create a new field in the specified operation region
327 *
328 ******************************************************************************/
329
330acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400331acpi_ds_create_field(union acpi_parse_object *op,
332 struct acpi_namespace_node *region_node,
333 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
Len Brown4be44fc2005-08-05 00:44:28 -0400335 acpi_status status;
336 union acpi_parse_object *arg;
337 struct acpi_create_field_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
Len Brown4be44fc2005-08-05 00:44:28 -0400339 ACPI_FUNCTION_TRACE_PTR("ds_create_field", op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341 /* First arg is the name of the parent op_region (must already exist) */
342
343 arg = op->common.value.arg;
344 if (!region_node) {
Len Brown4be44fc2005-08-05 00:44:28 -0400345 status =
346 acpi_ns_lookup(walk_state->scope_info,
347 arg->common.value.name, ACPI_TYPE_REGION,
348 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
349 walk_state, &region_node);
350 if (ACPI_FAILURE(status)) {
351 ACPI_REPORT_NSERROR(arg->common.value.name, status);
352 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 }
354 }
355
356 /* Second arg is the field flags */
357
358 arg = arg->common.next;
359 info.field_flags = (u8) arg->common.value.integer;
360 info.attribute = 0;
361
362 /* Each remaining arg is a Named Field */
363
364 info.field_type = ACPI_TYPE_LOCAL_REGION_FIELD;
365 info.region_node = region_node;
366
Len Brown4be44fc2005-08-05 00:44:28 -0400367 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368
Len Brown4be44fc2005-08-05 00:44:28 -0400369 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370}
371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372/*******************************************************************************
373 *
374 * FUNCTION: acpi_ds_init_field_objects
375 *
376 * PARAMETERS: Op - Op containing the Field definition and args
377 * ` walk_state - Current method state
378 *
379 * RETURN: Status
380 *
381 * DESCRIPTION: For each "Field Unit" name in the argument list that is
382 * part of the field declaration, enter the name into the
383 * namespace.
384 *
385 ******************************************************************************/
386
387acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400388acpi_ds_init_field_objects(union acpi_parse_object *op,
389 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
Len Brown4be44fc2005-08-05 00:44:28 -0400391 acpi_status status;
392 union acpi_parse_object *arg = NULL;
393 struct acpi_namespace_node *node;
394 u8 type = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Len Brown4be44fc2005-08-05 00:44:28 -0400396 ACPI_FUNCTION_TRACE_PTR("ds_init_field_objects", op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398 switch (walk_state->opcode) {
399 case AML_FIELD_OP:
Len Brown4be44fc2005-08-05 00:44:28 -0400400 arg = acpi_ps_get_arg(op, 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 type = ACPI_TYPE_LOCAL_REGION_FIELD;
402 break;
403
404 case AML_BANK_FIELD_OP:
Len Brown4be44fc2005-08-05 00:44:28 -0400405 arg = acpi_ps_get_arg(op, 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 type = ACPI_TYPE_LOCAL_BANK_FIELD;
407 break;
408
409 case AML_INDEX_FIELD_OP:
Len Brown4be44fc2005-08-05 00:44:28 -0400410 arg = acpi_ps_get_arg(op, 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 type = ACPI_TYPE_LOCAL_INDEX_FIELD;
412 break;
413
414 default:
Len Brown4be44fc2005-08-05 00:44:28 -0400415 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 }
417
418 /*
419 * Walk the list of entries in the field_list
420 */
421 while (arg) {
422 /* Ignore OFFSET and ACCESSAS terms here */
423
424 if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
Len Brown4be44fc2005-08-05 00:44:28 -0400425 status = acpi_ns_lookup(walk_state->scope_info,
426 (char *)&arg->named.name,
427 type, ACPI_IMODE_LOAD_PASS1,
428 ACPI_NS_NO_UPSEARCH |
429 ACPI_NS_DONT_OPEN_SCOPE |
430 ACPI_NS_ERROR_IF_FOUND,
431 walk_state, &node);
432 if (ACPI_FAILURE(status)) {
433 ACPI_REPORT_NSERROR((char *)&arg->named.name,
434 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 if (status != AE_ALREADY_EXISTS) {
Len Brown4be44fc2005-08-05 00:44:28 -0400436 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
438
439 /* Name already exists, just ignore this error */
440
441 status = AE_OK;
442 }
443
444 arg->common.node = node;
445 }
446
447 /* Move to next field in the list */
448
449 arg = arg->common.next;
450 }
451
Len Brown4be44fc2005-08-05 00:44:28 -0400452 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*******************************************************************************
456 *
457 * FUNCTION: acpi_ds_create_bank_field
458 *
459 * PARAMETERS: Op - Op containing the Field definition and args
460 * region_node - Object for the containing Operation Region
461 * ` walk_state - Current method state
462 *
463 * RETURN: Status
464 *
465 * DESCRIPTION: Create a new bank field in the specified operation region
466 *
467 ******************************************************************************/
468
469acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400470acpi_ds_create_bank_field(union acpi_parse_object *op,
471 struct acpi_namespace_node *region_node,
472 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473{
Len Brown4be44fc2005-08-05 00:44:28 -0400474 acpi_status status;
475 union acpi_parse_object *arg;
476 struct acpi_create_field_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Len Brown4be44fc2005-08-05 00:44:28 -0400478 ACPI_FUNCTION_TRACE_PTR("ds_create_bank_field", op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480 /* First arg is the name of the parent op_region (must already exist) */
481
482 arg = op->common.value.arg;
483 if (!region_node) {
Len Brown4be44fc2005-08-05 00:44:28 -0400484 status =
485 acpi_ns_lookup(walk_state->scope_info,
486 arg->common.value.name, ACPI_TYPE_REGION,
487 ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
488 walk_state, &region_node);
489 if (ACPI_FAILURE(status)) {
490 ACPI_REPORT_NSERROR(arg->common.value.name, status);
491 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 }
493 }
494
495 /* Second arg is the Bank Register (Field) (must already exist) */
496
497 arg = arg->common.next;
Len Brown4be44fc2005-08-05 00:44:28 -0400498 status =
499 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
500 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
501 ACPI_NS_SEARCH_PARENT, walk_state,
502 &info.register_node);
503 if (ACPI_FAILURE(status)) {
504 ACPI_REPORT_NSERROR(arg->common.value.string, status);
505 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 }
507
508 /* Third arg is the bank_value */
509
510 arg = arg->common.next;
511 info.bank_value = (u32) arg->common.value.integer;
512
513 /* Fourth arg is the field flags */
514
515 arg = arg->common.next;
516 info.field_flags = (u8) arg->common.value.integer;
517
518 /* Each remaining arg is a Named Field */
519
520 info.field_type = ACPI_TYPE_LOCAL_BANK_FIELD;
521 info.region_node = region_node;
522
Len Brown4be44fc2005-08-05 00:44:28 -0400523 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524
Len Brown4be44fc2005-08-05 00:44:28 -0400525 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526}
527
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528/*******************************************************************************
529 *
530 * FUNCTION: acpi_ds_create_index_field
531 *
532 * PARAMETERS: Op - Op containing the Field definition and args
533 * region_node - Object for the containing Operation Region
534 * ` walk_state - Current method state
535 *
536 * RETURN: Status
537 *
538 * DESCRIPTION: Create a new index field in the specified operation region
539 *
540 ******************************************************************************/
541
542acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400543acpi_ds_create_index_field(union acpi_parse_object *op,
544 struct acpi_namespace_node *region_node,
545 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546{
Len Brown4be44fc2005-08-05 00:44:28 -0400547 acpi_status status;
548 union acpi_parse_object *arg;
549 struct acpi_create_field_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
Len Brown4be44fc2005-08-05 00:44:28 -0400551 ACPI_FUNCTION_TRACE_PTR("ds_create_index_field", op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552
553 /* First arg is the name of the Index register (must already exist) */
554
555 arg = op->common.value.arg;
Len Brown4be44fc2005-08-05 00:44:28 -0400556 status =
557 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
558 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
559 ACPI_NS_SEARCH_PARENT, walk_state,
560 &info.register_node);
561 if (ACPI_FAILURE(status)) {
562 ACPI_REPORT_NSERROR(arg->common.value.string, status);
563 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 }
565
566 /* Second arg is the data register (must already exist) */
567
568 arg = arg->common.next;
Len Brown4be44fc2005-08-05 00:44:28 -0400569 status =
570 acpi_ns_lookup(walk_state->scope_info, arg->common.value.string,
571 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
572 ACPI_NS_SEARCH_PARENT, walk_state,
573 &info.data_register_node);
574 if (ACPI_FAILURE(status)) {
575 ACPI_REPORT_NSERROR(arg->common.value.string, status);
576 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 }
578
579 /* Next arg is the field flags */
580
581 arg = arg->common.next;
582 info.field_flags = (u8) arg->common.value.integer;
583
584 /* Each remaining arg is a Named Field */
585
586 info.field_type = ACPI_TYPE_LOCAL_INDEX_FIELD;
587 info.region_node = region_node;
588
Len Brown4be44fc2005-08-05 00:44:28 -0400589 status = acpi_ds_get_field_names(&info, walk_state, arg->common.next);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
Len Brown4be44fc2005-08-05 00:44:28 -0400591 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592}