1 /******************************************************************************
3 * Module Name: dsfield - Dispatcher field routines
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define _COMPONENT ACPI_DISPATCHER
35 MODULE_NAME ("dsfield")
39 * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.)
40 * 04 : Lock_rule (1 == Lock)
41 * 05 - 06 : Update_rule
44 #define FIELD_ACCESS_TYPE_MASK 0x0F
45 #define FIELD_LOCK_RULE_MASK 0x10
46 #define FIELD_UPDATE_RULE_MASK 0x60
49 /*******************************************************************************
51 * FUNCTION: Acpi_ds_create_field
53 * PARAMETERS: Op - Op containing the Field definition and args
54 * Region_node - Object for the containing Operation Region
58 * DESCRIPTION: Create a new field in the specified operation region
60 ******************************************************************************/
63 acpi_ds_create_field (
64 ACPI_PARSE_OBJECT *op,
65 ACPI_NAMESPACE_NODE *region_node,
66 ACPI_WALK_STATE *walk_state)
68 ACPI_STATUS status = AE_AML_ERROR;
69 ACPI_PARSE_OBJECT *arg;
70 ACPI_NAMESPACE_NODE *node;
72 u8 access_attribute = 0;
73 u32 field_bit_position = 0;
76 /* First arg is the name of the parent Op_region */
80 status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
81 ACPI_TYPE_REGION, IMODE_EXECUTE,
82 NS_SEARCH_PARENT, walk_state,
85 if (ACPI_FAILURE (status)) {
90 /* Second arg is the field flags */
93 field_flags = (u8) arg->value.integer;
95 /* Each remaining arg is a Named Field */
99 switch (arg->opcode) {
100 case AML_RESERVEDFIELD_OP:
102 field_bit_position += arg->value.size;
106 case AML_ACCESSFIELD_OP:
109 * Get a new Access_type and Access_attribute for all
110 * entries (until end or another Access_as keyword)
113 access_attribute = (u8) arg->value.integer;
115 ((field_flags & FIELD_ACCESS_TYPE_MASK) ||
116 ((u8) (arg->value.integer >> 8)));
120 case AML_NAMEDFIELD_OP:
122 status = acpi_ns_lookup (walk_state->scope_info,
123 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name,
124 INTERNAL_TYPE_DEF_FIELD,
126 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
129 if (ACPI_FAILURE (status)) {
134 * Initialize an object for the new Node that is on
138 status = acpi_aml_prep_def_field_value (node, region_node, field_flags,
139 access_attribute, field_bit_position, arg->value.size);
141 if (ACPI_FAILURE (status)) {
145 /* Keep track of bit position for *next* field */
147 field_bit_position += arg->value.size;
158 /*******************************************************************************
160 * FUNCTION: Acpi_ds_create_bank_field
162 * PARAMETERS: Op - Op containing the Field definition and args
163 * Region_node - Object for the containing Operation Region
167 * DESCRIPTION: Create a new bank field in the specified operation region
169 ******************************************************************************/
172 acpi_ds_create_bank_field (
173 ACPI_PARSE_OBJECT *op,
174 ACPI_NAMESPACE_NODE *region_node,
175 ACPI_WALK_STATE *walk_state)
177 ACPI_STATUS status = AE_AML_ERROR;
178 ACPI_PARSE_OBJECT *arg;
179 ACPI_NAMESPACE_NODE *register_node;
180 ACPI_NAMESPACE_NODE *node;
183 u8 access_attribute = 0;
184 u32 field_bit_position = 0;
187 /* First arg is the name of the parent Op_region */
191 status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
192 ACPI_TYPE_REGION, IMODE_EXECUTE,
193 NS_SEARCH_PARENT, walk_state,
196 if (ACPI_FAILURE (status)) {
201 /* Second arg is the Bank Register */
205 status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
206 INTERNAL_TYPE_BANK_FIELD_DEFN,
208 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
209 NULL, ®ister_node);
211 if (ACPI_FAILURE (status)) {
215 /* Third arg is the Bank_value */
218 bank_value = arg->value.integer;
221 /* Next arg is the field flags */
224 field_flags = (u8) arg->value.integer;
226 /* Each remaining arg is a Named Field */
230 switch (arg->opcode) {
231 case AML_RESERVEDFIELD_OP:
233 field_bit_position += arg->value.size;
237 case AML_ACCESSFIELD_OP:
240 * Get a new Access_type and Access_attribute for
241 * all entries (until end or another Access_as keyword)
244 access_attribute = (u8) arg->value.integer;
246 ((field_flags & FIELD_ACCESS_TYPE_MASK) ||
247 ((u8) (arg->value.integer >> 8)));
251 case AML_NAMEDFIELD_OP:
253 status = acpi_ns_lookup (walk_state->scope_info,
254 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name,
255 INTERNAL_TYPE_DEF_FIELD,
257 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
260 if (ACPI_FAILURE (status)) {
265 * Initialize an object for the new Node that is on
269 status = acpi_aml_prep_bank_field_value (node, region_node, register_node,
270 bank_value, field_flags, access_attribute,
271 field_bit_position, arg->value.size);
273 if (ACPI_FAILURE (status)) {
277 /* Keep track of bit position for the *next* field */
279 field_bit_position += arg->value.size;
291 /*******************************************************************************
293 * FUNCTION: Acpi_ds_create_index_field
295 * PARAMETERS: Op - Op containing the Field definition and args
296 * Region_node - Object for the containing Operation Region
300 * DESCRIPTION: Create a new index field in the specified operation region
302 ******************************************************************************/
305 acpi_ds_create_index_field (
306 ACPI_PARSE_OBJECT *op,
307 ACPI_HANDLE region_node,
308 ACPI_WALK_STATE *walk_state)
311 ACPI_PARSE_OBJECT *arg;
312 ACPI_NAMESPACE_NODE *node;
313 ACPI_NAMESPACE_NODE *index_register_node;
314 ACPI_NAMESPACE_NODE *data_register_node;
316 u8 access_attribute = 0;
317 u32 field_bit_position = 0;
322 /* First arg is the name of the Index register */
324 status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
325 ACPI_TYPE_ANY, IMODE_LOAD_PASS1,
326 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
327 NULL, &index_register_node);
329 if (ACPI_FAILURE (status)) {
333 /* Second arg is the data register */
337 status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
338 INTERNAL_TYPE_INDEX_FIELD_DEFN,
340 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
341 NULL, &data_register_node);
343 if (ACPI_FAILURE (status)) {
348 /* Next arg is the field flags */
351 field_flags = (u8) arg->value.integer;
354 /* Each remaining arg is a Named Field */
358 switch (arg->opcode) {
359 case AML_RESERVEDFIELD_OP:
361 field_bit_position += arg->value.size;
365 case AML_ACCESSFIELD_OP:
368 * Get a new Access_type and Access_attribute for all
369 * entries (until end or another Access_as keyword)
372 access_attribute = (u8) arg->value.integer;
374 ((field_flags & FIELD_ACCESS_TYPE_MASK) ||
375 ((u8) (arg->value.integer >> 8)));
379 case AML_NAMEDFIELD_OP:
381 status = acpi_ns_lookup (walk_state->scope_info,
382 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)arg)->name,
383 INTERNAL_TYPE_INDEX_FIELD,
385 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
388 if (ACPI_FAILURE (status)) {
393 * Initialize an object for the new Node that is on
397 status = acpi_aml_prep_index_field_value (node, index_register_node, data_register_node,
398 field_flags, access_attribute,
399 field_bit_position, arg->value.size);
401 if (ACPI_FAILURE (status)) {
405 /* Keep track of bit position for the *next* field */
407 field_bit_position += arg->value.size;
413 status = AE_AML_ERROR;