dsfield.c revision 70243
1/****************************************************************************** 2 * 3 * Module Name: dsfield - Dispatcher field routines 4 * $Revision: 30 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __DSFIELD_C__ 118 119#include "acpi.h" 120#include "amlcode.h" 121#include "acdispat.h" 122#include "acinterp.h" 123#include "acnamesp.h" 124 125 126#define _COMPONENT DISPATCHER 127 MODULE_NAME ("dsfield") 128 129 130/* 131 * Field flags: Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) 132 * 04 : LockRule (1 == Lock) 133 * 05 - 06 : UpdateRule 134 */ 135 136#define FIELD_ACCESS_TYPE_MASK 0x0F 137#define FIELD_LOCK_RULE_MASK 0x10 138#define FIELD_UPDATE_RULE_MASK 0x60 139 140 141/******************************************************************************* 142 * 143 * FUNCTION: AcpiDsCreateField 144 * 145 * PARAMETERS: Op - Op containing the Field definition and args 146 * RegionNode - Object for the containing Operation Region 147 * 148 * RETURN: Status 149 * 150 * DESCRIPTION: Create a new field in the specified operation region 151 * 152 ******************************************************************************/ 153 154ACPI_STATUS 155AcpiDsCreateField ( 156 ACPI_PARSE_OBJECT *Op, 157 ACPI_NAMESPACE_NODE *RegionNode, 158 ACPI_WALK_STATE *WalkState) 159{ 160 ACPI_STATUS Status = AE_AML_ERROR; 161 ACPI_PARSE_OBJECT *Arg; 162 ACPI_NAMESPACE_NODE *Node; 163 UINT8 FieldFlags; 164 UINT8 AccessAttribute = 0; 165 UINT32 FieldBitPosition = 0; 166 167 168 FUNCTION_TRACE_PTR ("DsCreateField", Op); 169 170 171 /* First arg is the name of the parent OpRegion */ 172 173 Arg = Op->Value.Arg; 174 if (!RegionNode) 175 { 176 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, 177 ACPI_TYPE_REGION, IMODE_EXECUTE, 178 NS_SEARCH_PARENT, WalkState, 179 &RegionNode); 180 181 if (ACPI_FAILURE (Status)) 182 { 183 return_ACPI_STATUS (Status); 184 } 185 } 186 187 /* Second arg is the field flags */ 188 189 Arg = Arg->Next; 190 FieldFlags = (UINT8) Arg->Value.Integer; 191 192 /* Each remaining arg is a Named Field */ 193 194 Arg = Arg->Next; 195 while (Arg) 196 { 197 switch (Arg->Opcode) 198 { 199 case AML_RESERVEDFIELD_OP: 200 201 FieldBitPosition += Arg->Value.Size; 202 break; 203 204 205 case AML_ACCESSFIELD_OP: 206 207 /* 208 * Get a new AccessType and AccessAttribute for all 209 * entries (until end or another AccessAs keyword) 210 */ 211 212 AccessAttribute = (UINT8) Arg->Value.Integer; 213 FieldFlags = (UINT8) 214 ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || 215 ((UINT8) (Arg->Value.Integer >> 8))); 216 break; 217 218 219 case AML_NAMEDFIELD_OP: 220 221 Status = AcpiNsLookup (WalkState->ScopeInfo, 222 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, 223 INTERNAL_TYPE_DEF_FIELD, 224 IMODE_LOAD_PASS1, 225 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 226 NULL, &Node); 227 228 if (ACPI_FAILURE (Status)) 229 { 230 return_ACPI_STATUS (Status); 231 } 232 233 /* 234 * Initialize an object for the new Node that is on 235 * the object stack 236 */ 237 238 Status = AcpiAmlPrepDefFieldValue (Node, RegionNode, FieldFlags, 239 AccessAttribute, FieldBitPosition, Arg->Value.Size); 240 241 if (ACPI_FAILURE (Status)) 242 { 243 return_ACPI_STATUS (Status); 244 } 245 246 /* Keep track of bit position for *next* field */ 247 248 FieldBitPosition += Arg->Value.Size; 249 break; 250 } 251 252 Arg = Arg->Next; 253 } 254 255 return_ACPI_STATUS (Status); 256} 257 258 259/******************************************************************************* 260 * 261 * FUNCTION: AcpiDsCreateBankField 262 * 263 * PARAMETERS: Op - Op containing the Field definition and args 264 * RegionNode - Object for the containing Operation Region 265 * 266 * RETURN: Status 267 * 268 * DESCRIPTION: Create a new bank field in the specified operation region 269 * 270 ******************************************************************************/ 271 272ACPI_STATUS 273AcpiDsCreateBankField ( 274 ACPI_PARSE_OBJECT *Op, 275 ACPI_NAMESPACE_NODE *RegionNode, 276 ACPI_WALK_STATE *WalkState) 277{ 278 ACPI_STATUS Status = AE_AML_ERROR; 279 ACPI_PARSE_OBJECT *Arg; 280 ACPI_NAMESPACE_NODE *RegisterNode; 281 ACPI_NAMESPACE_NODE *Node; 282 UINT32 BankValue; 283 UINT8 FieldFlags; 284 UINT8 AccessAttribute = 0; 285 UINT32 FieldBitPosition = 0; 286 287 288 FUNCTION_TRACE_PTR ("DsCreateBankField", Op); 289 290 291 /* First arg is the name of the parent OpRegion */ 292 293 Arg = Op->Value.Arg; 294 if (!RegionNode) 295 { 296 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.Name, 297 ACPI_TYPE_REGION, IMODE_EXECUTE, 298 NS_SEARCH_PARENT, WalkState, 299 &RegionNode); 300 301 if (ACPI_FAILURE (Status)) 302 { 303 return_ACPI_STATUS (Status); 304 } 305 } 306 307 /* Second arg is the Bank Register */ 308 309 Arg = Arg->Next; 310 311 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, 312 INTERNAL_TYPE_BANK_FIELD_DEFN, 313 IMODE_LOAD_PASS1, 314 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 315 NULL, &RegisterNode); 316 317 if (ACPI_FAILURE (Status)) 318 { 319 return_ACPI_STATUS (Status); 320 } 321 322 /* Third arg is the BankValue */ 323 324 Arg = Arg->Next; 325 BankValue = Arg->Value.Integer; 326 327 328 /* Next arg is the field flags */ 329 330 Arg = Arg->Next; 331 FieldFlags = (UINT8) Arg->Value.Integer; 332 333 /* Each remaining arg is a Named Field */ 334 335 Arg = Arg->Next; 336 while (Arg) 337 { 338 switch (Arg->Opcode) 339 { 340 case AML_RESERVEDFIELD_OP: 341 342 FieldBitPosition += Arg->Value.Size; 343 break; 344 345 346 case AML_ACCESSFIELD_OP: 347 348 /* 349 * Get a new AccessType and AccessAttribute for 350 * all entries (until end or another AccessAs keyword) 351 */ 352 353 AccessAttribute = (UINT8) Arg->Value.Integer; 354 FieldFlags = (UINT8) 355 ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || 356 ((UINT8) (Arg->Value.Integer >> 8))); 357 break; 358 359 360 case AML_NAMEDFIELD_OP: 361 362 Status = AcpiNsLookup (WalkState->ScopeInfo, 363 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, 364 INTERNAL_TYPE_DEF_FIELD, 365 IMODE_LOAD_PASS1, 366 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 367 NULL, &Node); 368 369 if (ACPI_FAILURE (Status)) 370 { 371 return_ACPI_STATUS (Status); 372 } 373 374 /* 375 * Initialize an object for the new Node that is on 376 * the object stack 377 */ 378 379 Status = AcpiAmlPrepBankFieldValue (Node, RegionNode, RegisterNode, 380 BankValue, FieldFlags, AccessAttribute, 381 FieldBitPosition, Arg->Value.Size); 382 383 if (ACPI_FAILURE (Status)) 384 { 385 return_ACPI_STATUS (Status); 386 } 387 388 /* Keep track of bit position for the *next* field */ 389 390 FieldBitPosition += Arg->Value.Size; 391 break; 392 393 } 394 395 Arg = Arg->Next; 396 } 397 398 return_ACPI_STATUS (Status); 399} 400 401 402/******************************************************************************* 403 * 404 * FUNCTION: AcpiDsCreateIndexField 405 * 406 * PARAMETERS: Op - Op containing the Field definition and args 407 * RegionNode - Object for the containing Operation Region 408 * 409 * RETURN: Status 410 * 411 * DESCRIPTION: Create a new index field in the specified operation region 412 * 413 ******************************************************************************/ 414 415ACPI_STATUS 416AcpiDsCreateIndexField ( 417 ACPI_PARSE_OBJECT *Op, 418 ACPI_HANDLE RegionNode, 419 ACPI_WALK_STATE *WalkState) 420{ 421 ACPI_STATUS Status; 422 ACPI_PARSE_OBJECT *Arg; 423 ACPI_NAMESPACE_NODE *Node; 424 ACPI_NAMESPACE_NODE *IndexRegisterNode; 425 ACPI_NAMESPACE_NODE *DataRegisterNode; 426 UINT8 FieldFlags; 427 UINT8 AccessAttribute = 0; 428 UINT32 FieldBitPosition = 0; 429 430 431 FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); 432 433 434 Arg = Op->Value.Arg; 435 436 /* First arg is the name of the Index register */ 437 438 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, 439 ACPI_TYPE_ANY, IMODE_LOAD_PASS1, 440 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 441 NULL, &IndexRegisterNode); 442 443 if (ACPI_FAILURE (Status)) 444 { 445 return_ACPI_STATUS (Status); 446 } 447 448 /* Second arg is the data register */ 449 450 Arg = Arg->Next; 451 452 Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Value.String, 453 INTERNAL_TYPE_INDEX_FIELD_DEFN, 454 IMODE_LOAD_PASS1, 455 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 456 NULL, &DataRegisterNode); 457 458 if (ACPI_FAILURE (Status)) 459 { 460 return_ACPI_STATUS (Status); 461 } 462 463 464 /* Next arg is the field flags */ 465 466 Arg = Arg->Next; 467 FieldFlags = (UINT8) Arg->Value.Integer; 468 469 470 /* Each remaining arg is a Named Field */ 471 472 Arg = Arg->Next; 473 while (Arg) 474 { 475 switch (Arg->Opcode) 476 { 477 case AML_RESERVEDFIELD_OP: 478 479 FieldBitPosition += Arg->Value.Size; 480 break; 481 482 483 case AML_ACCESSFIELD_OP: 484 485 /* 486 * Get a new AccessType and AccessAttribute for all 487 * entries (until end or another AccessAs keyword) 488 */ 489 490 AccessAttribute = (UINT8) Arg->Value.Integer; 491 FieldFlags = (UINT8) 492 ((FieldFlags & FIELD_ACCESS_TYPE_MASK) || 493 ((UINT8) (Arg->Value.Integer >> 8))); 494 break; 495 496 497 case AML_NAMEDFIELD_OP: 498 499 Status = AcpiNsLookup (WalkState->ScopeInfo, 500 (NATIVE_CHAR *) &((ACPI_PARSE2_OBJECT *)Arg)->Name, 501 INTERNAL_TYPE_INDEX_FIELD, 502 IMODE_LOAD_PASS1, 503 NS_NO_UPSEARCH | NS_DONT_OPEN_SCOPE, 504 NULL, &Node); 505 506 if (ACPI_FAILURE (Status)) 507 { 508 return_ACPI_STATUS (Status); 509 } 510 511 /* 512 * Initialize an object for the new Node that is on 513 * the object stack 514 */ 515 516 Status = AcpiAmlPrepIndexFieldValue (Node, IndexRegisterNode, DataRegisterNode, 517 FieldFlags, AccessAttribute, 518 FieldBitPosition, Arg->Value.Size); 519 520 if (ACPI_FAILURE (Status)) 521 { 522 return_ACPI_STATUS (Status); 523 } 524 525 /* Keep track of bit position for the *next* field */ 526 527 FieldBitPosition += Arg->Value.Size; 528 break; 529 530 531 default: 532 533 DEBUG_PRINT (ACPI_ERROR, 534 ("DsEnterIndexField: Invalid opcode in field list: %X\n", 535 Arg->Opcode)); 536 Status = AE_AML_ERROR; 537 break; 538 } 539 540 Arg = Arg->Next; 541 } 542 543 return_ACPI_STATUS (Status); 544} 545 546 547