1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
|
/******************************************************************************
*
* Module Name: dsfield - Dispatcher field routines
* $Revision: 46 $
*
*****************************************************************************/
/*
* Copyright (C) 2000, 2001 R. Byron Moore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "acpi.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acparser.h"
#define _COMPONENT ACPI_DISPATCHER
MODULE_NAME ("dsfield")
/*******************************************************************************
*
* FUNCTION: Acpi_ds_create_buffer_field
*
* PARAMETERS: Opcode - The opcode to be executed
* Operands - List of operands for the opcode
* Walk_state - Current state
*
* RETURN: Status
*
* DESCRIPTION: Execute the Create_field operators:
* Create_bit_field_op,
* Create_byte_field_op,
* Create_word_field_op,
* Create_dWord_field_op,
* Create_qWord_field_op,
* Create_field_op (all of which define fields in buffers)
*
******************************************************************************/
acpi_status
acpi_ds_create_buffer_field (
acpi_parse_object *op,
acpi_walk_state *walk_state)
{
acpi_parse_object *arg;
acpi_namespace_node *node;
acpi_status status;
acpi_operand_object *obj_desc;
FUNCTION_TRACE ("Ds_create_buffer_field");
/* Get the Name_string argument */
if (op->opcode == AML_CREATE_FIELD_OP) {
arg = acpi_ps_get_arg (op, 3);
}
else {
/* Create Bit/Byte/Word/Dword field */
arg = acpi_ps_get_arg (op, 2);
}
if (!arg) {
return_ACPI_STATUS (AE_AML_NO_OPERAND);
}
/*
* Enter the Name_string into the namespace
*/
status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
INTERNAL_TYPE_DEF_ANY, IMODE_LOAD_PASS1,
NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
walk_state, &(node));
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* We could put the returned object (Node) on the object stack for later, but
* for now, we will put it in the "op" object that the parser uses, so we
* can get it again at the end of this scope
*/
op->node = node;
/*
* If there is no object attached to the node, this node was just created and
* we need to create the field object. Otherwise, this was a lookup of an
* existing node and we don't want to create the field object again.
*/
if (node->object) {
return_ACPI_STATUS (AE_OK);
}
/*
* The Field definition is not fully parsed at this time.
* (We must save the address of the AML for the buffer and index operands)
*/
/* Create the buffer field object */
obj_desc = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER_FIELD);
if (!obj_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
/*
* Allocate a method object for this field unit
*/
obj_desc->buffer_field.extra = acpi_ut_create_internal_object (
INTERNAL_TYPE_EXTRA);
if (!obj_desc->buffer_field.extra) {
status = AE_NO_MEMORY;
goto cleanup;
}
/*
* Remember location in AML stream of the field unit
* opcode and operands -- since the buffer and index
* operands must be evaluated.
*/
obj_desc->buffer_field.extra->extra.aml_start = ((acpi_parse2_object *) op)->data;
obj_desc->buffer_field.extra->extra.aml_length = ((acpi_parse2_object *) op)->length;
obj_desc->buffer_field.node = node;
/* Attach constructed field descriptor to parent node */
status = acpi_ns_attach_object (node, obj_desc, ACPI_TYPE_BUFFER_FIELD);
cleanup:
/* Remove local reference to the object */
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: Acpi_ds_get_field_names
*
* PARAMETERS: Info - Create_field info structure
* ` Walk_state - Current method state
* Arg - First parser arg for the field name list
*
* RETURN: Status
*
* DESCRIPTION: Process all named fields in a field declaration. Names are
* entered into the namespace.
*
******************************************************************************/
acpi_status
acpi_ds_get_field_names (
ACPI_CREATE_FIELD_INFO *info,
acpi_walk_state *walk_state,
acpi_parse_object *arg)
{
acpi_status status;
FUNCTION_TRACE_U32 ("Ds_get_field_names", info);
/* First field starts at bit zero */
info->field_bit_position = 0;
/* Process all elements in the field list (of parse nodes) */
while (arg) {
/*
* Three types of field elements are handled:
* 1) Offset - specifies a bit offset
* 2) Access_as - changes the access mode
* 3) Name - Enters a new named field into the namespace
*/
switch (arg->opcode) {
case AML_INT_RESERVEDFIELD_OP:
info->field_bit_position += arg->value.size;
break;
case AML_INT_ACCESSFIELD_OP:
/*
* Get a new Access_type and Access_attribute for all
* entries (until end or another Access_as keyword)
*/
info->field_flags = (u8) ((info->field_flags & FIELD_ACCESS_TYPE_MASK) ||
((u8) (arg->value.integer >> 8)));
break;
case AML_INT_NAMEDFIELD_OP:
/* Enter a new field name into the namespace */
status = acpi_ns_lookup (walk_state->scope_info,
(NATIVE_CHAR *) &((acpi_parse2_object *)arg)->name,
info->field_type, IMODE_LOAD_PASS1,
NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE,
NULL, &info->field_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Create and initialize an object for the new Field Node */
info->field_bit_length = arg->value.size;
status = acpi_ex_prep_field_value (info);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Keep track of bit position for the next field */
info->field_bit_position += info->field_bit_length;
break;
default:
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",
arg->opcode));
return_ACPI_STATUS (AE_AML_ERROR);
break;
}
arg = arg->next;
}
return_ACPI_STATUS (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: Acpi_ds_create_field
*
* PARAMETERS: Op - Op containing the Field definition and args
* Region_node - Object for the containing Operation Region
* ` Walk_state - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new field in the specified operation region
*
******************************************************************************/
acpi_status
acpi_ds_create_field (
acpi_parse_object *op,
acpi_namespace_node *region_node,
acpi_walk_state *walk_state)
{
acpi_status status = AE_AML_ERROR;
acpi_parse_object *arg;
ACPI_CREATE_FIELD_INFO info;
FUNCTION_TRACE_PTR ("Ds_create_field", op);
/* First arg is the name of the parent Op_region (must already exist) */
arg = op->value.arg;
if (!region_node) {
status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
ACPI_TYPE_REGION, IMODE_EXECUTE,
NS_SEARCH_PARENT, walk_state, ®ion_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
}
/* Second arg is the field flags */
arg = arg->next;
info.field_flags = arg->value.integer8;
/* Each remaining arg is a Named Field */
info.field_type = INTERNAL_TYPE_REGION_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->next);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: Acpi_ds_create_bank_field
*
* PARAMETERS: Op - Op containing the Field definition and args
* Region_node - Object for the containing Operation Region
* ` Walk_state - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new bank field in the specified operation region
*
******************************************************************************/
acpi_status
acpi_ds_create_bank_field (
acpi_parse_object *op,
acpi_namespace_node *region_node,
acpi_walk_state *walk_state)
{
acpi_status status = AE_AML_ERROR;
acpi_parse_object *arg;
ACPI_CREATE_FIELD_INFO info;
FUNCTION_TRACE_PTR ("Ds_create_bank_field", op);
/* First arg is the name of the parent Op_region (must already exist) */
arg = op->value.arg;
if (!region_node) {
status = acpi_ns_lookup (walk_state->scope_info, arg->value.name,
ACPI_TYPE_REGION, IMODE_EXECUTE,
NS_SEARCH_PARENT, walk_state, ®ion_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
}
/* Second arg is the Bank Register (must already exist) */
arg = arg->next;
status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
INTERNAL_TYPE_BANK_FIELD_DEFN, IMODE_EXECUTE,
NS_SEARCH_PARENT, walk_state, &info.register_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Third arg is the Bank_value */
arg = arg->next;
info.bank_value = arg->value.integer32;
/* Fourth arg is the field flags */
arg = arg->next;
info.field_flags = arg->value.integer8;
/* Each remaining arg is a Named Field */
info.field_type = INTERNAL_TYPE_BANK_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->next);
return_ACPI_STATUS (status);
}
/*******************************************************************************
*
* FUNCTION: Acpi_ds_create_index_field
*
* PARAMETERS: Op - Op containing the Field definition and args
* Region_node - Object for the containing Operation Region
* ` Walk_state - Current method state
*
* RETURN: Status
*
* DESCRIPTION: Create a new index field in the specified operation region
*
******************************************************************************/
acpi_status
acpi_ds_create_index_field (
acpi_parse_object *op,
acpi_namespace_node *region_node,
acpi_walk_state *walk_state)
{
acpi_status status;
acpi_parse_object *arg;
ACPI_CREATE_FIELD_INFO info;
FUNCTION_TRACE_PTR ("Ds_create_index_field", op);
/* First arg is the name of the Index register (must already exist) */
arg = op->value.arg;
status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
ACPI_TYPE_ANY, IMODE_EXECUTE,
NS_SEARCH_PARENT, walk_state, &info.register_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Second arg is the data register (must already exist) */
arg = arg->next;
status = acpi_ns_lookup (walk_state->scope_info, arg->value.string,
INTERNAL_TYPE_INDEX_FIELD_DEFN, IMODE_EXECUTE,
NS_SEARCH_PARENT, walk_state, &info.data_register_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
/* Next arg is the field flags */
arg = arg->next;
info.field_flags = arg->value.integer8;
/* Each remaining arg is a Named Field */
info.field_type = INTERNAL_TYPE_INDEX_FIELD;
info.region_node = region_node;
status = acpi_ds_get_field_names (&info, walk_state, arg->next);
return_ACPI_STATUS (status);
}
|