asloperands.c revision 193529
1118611Snjl 2118611Snjl/****************************************************************************** 3118611Snjl * 4118611Snjl * Module Name: asloperands - AML operand processing 5118611Snjl * 6118611Snjl *****************************************************************************/ 7118611Snjl 8118611Snjl/****************************************************************************** 9118611Snjl * 10118611Snjl * 1. Copyright Notice 11118611Snjl * 12193529Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 13118611Snjl * All rights reserved. 14118611Snjl * 15118611Snjl * 2. License 16118611Snjl * 17118611Snjl * 2.1. This is your license from Intel Corp. under its intellectual property 18118611Snjl * rights. You may have additional license terms from the party that provided 19118611Snjl * you this software, covering your right to use that party's intellectual 20118611Snjl * property rights. 21118611Snjl * 22118611Snjl * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23118611Snjl * copy of the source code appearing in this file ("Covered Code") an 24118611Snjl * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25118611Snjl * base code distributed originally by Intel ("Original Intel Code") to copy, 26118611Snjl * make derivatives, distribute, use and display any portion of the Covered 27118611Snjl * Code in any form, with the right to sublicense such rights; and 28118611Snjl * 29118611Snjl * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30118611Snjl * license (with the right to sublicense), under only those claims of Intel 31118611Snjl * patents that are infringed by the Original Intel Code, to make, use, sell, 32118611Snjl * offer to sell, and import the Covered Code and derivative works thereof 33118611Snjl * solely to the minimum extent necessary to exercise the above copyright 34118611Snjl * license, and in no event shall the patent license extend to any additions 35118611Snjl * to or modifications of the Original Intel Code. No other license or right 36118611Snjl * is granted directly or by implication, estoppel or otherwise; 37118611Snjl * 38118611Snjl * The above copyright and patent license is granted only if the following 39118611Snjl * conditions are met: 40118611Snjl * 41118611Snjl * 3. Conditions 42118611Snjl * 43118611Snjl * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44118611Snjl * Redistribution of source code of any substantial portion of the Covered 45118611Snjl * Code or modification with rights to further distribute source must include 46118611Snjl * the above Copyright Notice, the above License, this list of Conditions, 47118611Snjl * and the following Disclaimer and Export Compliance provision. In addition, 48118611Snjl * Licensee must cause all Covered Code to which Licensee contributes to 49118611Snjl * contain a file documenting the changes Licensee made to create that Covered 50118611Snjl * Code and the date of any change. Licensee must include in that file the 51118611Snjl * documentation of any changes made by any predecessor Licensee. Licensee 52118611Snjl * must include a prominent statement that the modification is derived, 53118611Snjl * directly or indirectly, from Original Intel Code. 54118611Snjl * 55118611Snjl * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56118611Snjl * Redistribution of source code of any substantial portion of the Covered 57118611Snjl * Code or modification without rights to further distribute source must 58118611Snjl * include the following Disclaimer and Export Compliance provision in the 59118611Snjl * documentation and/or other materials provided with distribution. In 60118611Snjl * addition, Licensee may not authorize further sublicense of source of any 61118611Snjl * portion of the Covered Code, and must include terms to the effect that the 62118611Snjl * license from Licensee to its licensee is limited to the intellectual 63118611Snjl * property embodied in the software Licensee provides to its licensee, and 64118611Snjl * not to intellectual property embodied in modifications its licensee may 65118611Snjl * make. 66118611Snjl * 67118611Snjl * 3.3. Redistribution of Executable. Redistribution in executable form of any 68118611Snjl * substantial portion of the Covered Code or modification must reproduce the 69118611Snjl * above Copyright Notice, and the following Disclaimer and Export Compliance 70118611Snjl * provision in the documentation and/or other materials provided with the 71118611Snjl * distribution. 72118611Snjl * 73118611Snjl * 3.4. Intel retains all right, title, and interest in and to the Original 74118611Snjl * Intel Code. 75118611Snjl * 76118611Snjl * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77118611Snjl * Intel shall be used in advertising or otherwise to promote the sale, use or 78118611Snjl * other dealings in products derived from or relating to the Covered Code 79118611Snjl * without prior written authorization from Intel. 80118611Snjl * 81118611Snjl * 4. Disclaimer and Export Compliance 82118611Snjl * 83118611Snjl * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84118611Snjl * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85118611Snjl * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86118611Snjl * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87118611Snjl * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88118611Snjl * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89118611Snjl * PARTICULAR PURPOSE. 90118611Snjl * 91118611Snjl * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92118611Snjl * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93118611Snjl * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94118611Snjl * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95118611Snjl * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96118611Snjl * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97118611Snjl * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98118611Snjl * LIMITED REMEDY. 99118611Snjl * 100118611Snjl * 4.3. Licensee shall not export, either directly or indirectly, any of this 101118611Snjl * software or system incorporating such software without first obtaining any 102118611Snjl * required license or other approval from the U. S. Department of Commerce or 103118611Snjl * any other agency or department of the United States Government. In the 104118611Snjl * event Licensee exports any such software from the United States or 105118611Snjl * re-exports any such software from a foreign destination, Licensee shall 106118611Snjl * ensure that the distribution and export/re-export of the software is in 107118611Snjl * compliance with all laws, regulations, orders, or other restrictions of the 108118611Snjl * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109118611Snjl * any of its subsidiaries will export/re-export any technical data, process, 110118611Snjl * software, or service, directly or indirectly, to any country for which the 111118611Snjl * United States government or any agency thereof requires an export license, 112118611Snjl * other governmental approval, or letter of assurance, without first obtaining 113118611Snjl * such license, approval or letter. 114118611Snjl * 115118611Snjl *****************************************************************************/ 116118611Snjl 117118611Snjl 118151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h> 119118611Snjl#include "aslcompiler.y.h" 120193529Sjkim#include <contrib/dev/acpica/include/amlcode.h> 121118611Snjl 122118611Snjl#define _COMPONENT ACPI_COMPILER 123118611Snjl ACPI_MODULE_NAME ("asloperands") 124118611Snjl 125151937Sjkim/* Local prototypes */ 126118611Snjl 127151937Sjkimstatic void 128151937SjkimOpnDoField ( 129151937Sjkim ACPI_PARSE_OBJECT *Op); 130151937Sjkim 131151937Sjkimstatic void 132151937SjkimOpnDoBankField ( 133151937Sjkim ACPI_PARSE_OBJECT *Op); 134151937Sjkim 135151937Sjkimstatic void 136151937SjkimOpnDoBuffer ( 137151937Sjkim ACPI_PARSE_OBJECT *Op); 138151937Sjkim 139151937Sjkimstatic void 140151937SjkimOpnDoDefinitionBlock ( 141151937Sjkim ACPI_PARSE_OBJECT *Op); 142151937Sjkim 143151937Sjkimstatic void 144151937SjkimOpnDoFieldCommon ( 145151937Sjkim ACPI_PARSE_OBJECT *FieldOp, 146151937Sjkim ACPI_PARSE_OBJECT *Op); 147151937Sjkim 148151937Sjkimstatic void 149151937SjkimOpnDoIndexField ( 150151937Sjkim ACPI_PARSE_OBJECT *Op); 151151937Sjkim 152151937Sjkimstatic void 153151937SjkimOpnDoLoadTable ( 154151937Sjkim ACPI_PARSE_OBJECT *Op); 155151937Sjkim 156151937Sjkimstatic void 157151937SjkimOpnDoMethod ( 158151937Sjkim ACPI_PARSE_OBJECT *Op); 159151937Sjkim 160151937Sjkimstatic void 161151937SjkimOpnDoMutex ( 162151937Sjkim ACPI_PARSE_OBJECT *Op); 163151937Sjkim 164151937Sjkimstatic void 165151937SjkimOpnDoRegion ( 166151937Sjkim ACPI_PARSE_OBJECT *Op); 167151937Sjkim 168151937Sjkimstatic void 169151937SjkimOpnAttachNameToNode ( 170151937Sjkim ACPI_PARSE_OBJECT *Op); 171151937Sjkim 172151937Sjkim 173118611Snjl/******************************************************************************* 174118611Snjl * 175151937Sjkim * FUNCTION: OpnDoMutex 176151937Sjkim * 177151937Sjkim * PARAMETERS: Op - The parent parse node 178151937Sjkim * 179151937Sjkim * RETURN: None 180151937Sjkim * 181151937Sjkim * DESCRIPTION: Construct the operands for the MUTEX ASL keyword. 182151937Sjkim * 183151937Sjkim ******************************************************************************/ 184151937Sjkim 185151937Sjkimstatic void 186151937SjkimOpnDoMutex ( 187151937Sjkim ACPI_PARSE_OBJECT *Op) 188151937Sjkim{ 189151937Sjkim ACPI_PARSE_OBJECT *Next; 190151937Sjkim 191151937Sjkim 192151937Sjkim Next = Op->Asl.Child; 193151937Sjkim Next = Next->Asl.Next; 194151937Sjkim 195151937Sjkim if (Next->Asl.Value.Integer > 15) 196151937Sjkim { 197151937Sjkim AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); 198151937Sjkim } 199151937Sjkim return; 200151937Sjkim} 201151937Sjkim 202151937Sjkim 203151937Sjkim/******************************************************************************* 204151937Sjkim * 205118611Snjl * FUNCTION: OpnDoMethod 206118611Snjl * 207118611Snjl * PARAMETERS: Op - The parent parse node 208118611Snjl * 209118611Snjl * RETURN: None 210118611Snjl * 211118611Snjl * DESCRIPTION: Construct the operands for the METHOD ASL keyword. 212118611Snjl * 213118611Snjl ******************************************************************************/ 214118611Snjl 215151937Sjkimstatic void 216118611SnjlOpnDoMethod ( 217118611Snjl ACPI_PARSE_OBJECT *Op) 218118611Snjl{ 219118611Snjl ACPI_PARSE_OBJECT *Next; 220118611Snjl 221118611Snjl /* Optional arguments for this opcode with defaults */ 222118611Snjl 223118611Snjl UINT8 NumArgs = 0; 224118611Snjl UINT8 Serialized = 0; 225118611Snjl UINT8 Concurrency = 0; 226118611Snjl UINT8 MethodFlags; 227118611Snjl 228118611Snjl 229118611Snjl /* Opcode and package length first */ 230118611Snjl /* Method name */ 231118611Snjl 232118611Snjl Next = Op->Asl.Child; 233118611Snjl 234118611Snjl /* Num args */ 235118611Snjl 236118611Snjl Next = Next->Asl.Next; 237118611Snjl if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 238118611Snjl { 239118611Snjl NumArgs = (UINT8) Next->Asl.Value.Integer; 240118611Snjl Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 241118611Snjl } 242118611Snjl 243118611Snjl /* Serialized Flag */ 244118611Snjl 245118611Snjl Next = Next->Asl.Next; 246118611Snjl if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 247118611Snjl { 248118611Snjl Serialized = (UINT8) Next->Asl.Value.Integer; 249118611Snjl Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 250118611Snjl } 251118611Snjl 252151937Sjkim /* Concurrency value (valid values are 0-15) */ 253118611Snjl 254118611Snjl Next = Next->Asl.Next; 255118611Snjl if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 256118611Snjl { 257151937Sjkim if (Next->Asl.Value.Integer > 15) 258151937Sjkim { 259151937Sjkim AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); 260151937Sjkim } 261118611Snjl Concurrency = (UINT8) Next->Asl.Value.Integer; 262118611Snjl } 263118611Snjl 264118611Snjl /* Put the bits in their proper places */ 265118611Snjl 266118611Snjl MethodFlags = (UINT8) ((NumArgs & 0x7) | 267118611Snjl ((Serialized & 0x1) << 3) | 268118611Snjl ((Concurrency & 0xF) << 4)); 269118611Snjl 270118611Snjl /* Use the last node for the combined flags byte */ 271118611Snjl 272118611Snjl Next->Asl.Value.Integer = MethodFlags; 273118611Snjl Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 274118611Snjl Next->Asl.AmlLength = 1; 275118611Snjl Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; 276118611Snjl 277118611Snjl /* Save the arg count in the first node */ 278118611Snjl 279118611Snjl Op->Asl.Extra = NumArgs; 280118611Snjl} 281118611Snjl 282118611Snjl 283118611Snjl/******************************************************************************* 284118611Snjl * 285118611Snjl * FUNCTION: OpnDoFieldCommon 286118611Snjl * 287118611Snjl * PARAMETERS: FieldOp - Node for an ASL field 288118611Snjl * Op - The parent parse node 289118611Snjl * 290118611Snjl * RETURN: None 291118611Snjl * 292118611Snjl * DESCRIPTION: Construct the AML operands for the various field keywords, 293118611Snjl * FIELD, BANKFIELD, INDEXFIELD 294118611Snjl * 295118611Snjl ******************************************************************************/ 296118611Snjl 297151937Sjkimstatic void 298118611SnjlOpnDoFieldCommon ( 299118611Snjl ACPI_PARSE_OBJECT *FieldOp, 300118611Snjl ACPI_PARSE_OBJECT *Op) 301118611Snjl{ 302118611Snjl ACPI_PARSE_OBJECT *Next; 303118611Snjl ACPI_PARSE_OBJECT *PkgLengthNode; 304118611Snjl UINT32 CurrentBitOffset; 305118611Snjl UINT32 NewBitOffset; 306118611Snjl UINT8 AccessType; 307118611Snjl UINT8 LockRule; 308118611Snjl UINT8 UpdateRule; 309118611Snjl UINT8 FieldFlags; 310118611Snjl UINT32 MinimumLength; 311118611Snjl 312118611Snjl 313118611Snjl /* AccessType -- not optional, so no need to check for DEFAULT_ARG */ 314118611Snjl 315118611Snjl AccessType = (UINT8) Op->Asl.Value.Integer; 316118611Snjl Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 317118611Snjl 318118611Snjl /* Set the access type in the parent (field) node for use later */ 319118611Snjl 320118611Snjl FieldOp->Asl.Value.Integer = AccessType; 321118611Snjl 322118611Snjl /* LockRule -- not optional, so no need to check for DEFAULT_ARG */ 323118611Snjl 324118611Snjl Next = Op->Asl.Next; 325118611Snjl LockRule = (UINT8) Next->Asl.Value.Integer; 326118611Snjl Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 327118611Snjl 328118611Snjl /* UpdateRule -- not optional, so no need to check for DEFAULT_ARG */ 329118611Snjl 330118611Snjl Next = Next->Asl.Next; 331118611Snjl UpdateRule = (UINT8) Next->Asl.Value.Integer; 332118611Snjl 333118611Snjl /* 334118611Snjl * Generate the flags byte. The various fields are already 335118611Snjl * in the right bit position via translation from the 336118611Snjl * keywords by the parser. 337118611Snjl */ 338118611Snjl FieldFlags = (UINT8) (AccessType | LockRule | UpdateRule); 339118611Snjl 340118611Snjl /* Use the previous node to be the FieldFlags node */ 341118611Snjl 342118611Snjl /* Set the node to RAW_DATA */ 343118611Snjl 344118611Snjl Next->Asl.Value.Integer = FieldFlags; 345118611Snjl Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 346118611Snjl Next->Asl.AmlLength = 1; 347118611Snjl Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; 348118611Snjl 349118611Snjl /* Process the FieldUnitList */ 350118611Snjl 351118611Snjl Next = Next->Asl.Next; 352118611Snjl CurrentBitOffset = 0; 353118611Snjl 354118611Snjl while (Next) 355118611Snjl { 356118611Snjl /* Save the offset of this field unit */ 357118611Snjl 358118611Snjl Next->Asl.ExtraValue = CurrentBitOffset; 359118611Snjl 360118611Snjl switch (Next->Asl.ParseOpcode) 361118611Snjl { 362118611Snjl case PARSEOP_ACCESSAS: 363118611Snjl 364118611Snjl PkgLengthNode = Next->Asl.Child; 365118611Snjl AccessType = (UINT8) PkgLengthNode->Asl.Value.Integer; 366118611Snjl 367118611Snjl /* Nothing additional to do */ 368118611Snjl break; 369118611Snjl 370118611Snjl 371118611Snjl case PARSEOP_OFFSET: 372118611Snjl 373118611Snjl /* New offset into the field */ 374118611Snjl 375118611Snjl PkgLengthNode = Next->Asl.Child; 376118611Snjl NewBitOffset = ((UINT32) PkgLengthNode->Asl.Value.Integer) * 8; 377118611Snjl 378118611Snjl /* 379118611Snjl * Examine the specified offset in relation to the 380118611Snjl * current offset counter. 381118611Snjl */ 382118611Snjl if (NewBitOffset < CurrentBitOffset) 383118611Snjl { 384118611Snjl /* 385118611Snjl * Not allowed to specify a backwards offset! 386118611Snjl * Issue error and ignore this node. 387118611Snjl */ 388151937Sjkim AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, 389151937Sjkim NULL); 390118611Snjl Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 391118611Snjl PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 392118611Snjl } 393118611Snjl else if (NewBitOffset == CurrentBitOffset) 394118611Snjl { 395118611Snjl /* 396118611Snjl * Offset is redundant; we don't need to output an 397118611Snjl * offset opcode. Just set these nodes to default 398118611Snjl */ 399118611Snjl Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 400118611Snjl PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 401118611Snjl } 402118611Snjl else 403118611Snjl { 404118611Snjl /* 405118611Snjl * Valid new offset - set the value to be inserted into the AML 406118611Snjl * and update the offset counter. 407118611Snjl */ 408151937Sjkim PkgLengthNode->Asl.Value.Integer = 409151937Sjkim NewBitOffset - CurrentBitOffset; 410118611Snjl CurrentBitOffset = NewBitOffset; 411118611Snjl } 412118611Snjl break; 413118611Snjl 414118611Snjl 415118611Snjl case PARSEOP_NAMESEG: 416118611Snjl case PARSEOP_RESERVED_BYTES: 417118611Snjl 418118611Snjl /* Named or reserved field entry */ 419118611Snjl 420118611Snjl PkgLengthNode = Next->Asl.Child; 421118611Snjl NewBitOffset = (UINT32) PkgLengthNode->Asl.Value.Integer; 422118611Snjl CurrentBitOffset += NewBitOffset; 423118611Snjl 424118611Snjl /* Save the current AccessAs value for error checking later */ 425118611Snjl 426118611Snjl switch (AccessType) 427118611Snjl { 428118611Snjl case AML_FIELD_ACCESS_ANY: 429118611Snjl case AML_FIELD_ACCESS_BYTE: 430118611Snjl case AML_FIELD_ACCESS_BUFFER: 431118611Snjl default: 432118611Snjl MinimumLength = 8; 433118611Snjl break; 434118611Snjl 435118611Snjl case AML_FIELD_ACCESS_WORD: 436118611Snjl MinimumLength = 16; 437118611Snjl break; 438118611Snjl 439118611Snjl case AML_FIELD_ACCESS_DWORD: 440118611Snjl MinimumLength = 32; 441118611Snjl break; 442118611Snjl 443118611Snjl case AML_FIELD_ACCESS_QWORD: 444118611Snjl MinimumLength = 64; 445118611Snjl break; 446118611Snjl } 447118611Snjl 448118611Snjl PkgLengthNode->Asl.ExtraValue = MinimumLength; 449118611Snjl break; 450118611Snjl 451118611Snjl default: 452118611Snjl /* All supported field opcodes must appear above */ 453118611Snjl break; 454118611Snjl } 455118611Snjl 456118611Snjl /* Move on to next entry in the field list */ 457118611Snjl 458118611Snjl Next = Next->Asl.Next; 459118611Snjl } 460118611Snjl} 461118611Snjl 462118611Snjl 463118611Snjl/******************************************************************************* 464118611Snjl * 465118611Snjl * FUNCTION: OpnDoField 466118611Snjl * 467118611Snjl * PARAMETERS: Op - The parent parse node 468118611Snjl * 469118611Snjl * RETURN: None 470118611Snjl * 471118611Snjl * DESCRIPTION: Construct the AML operands for the FIELD ASL keyword 472118611Snjl * 473118611Snjl ******************************************************************************/ 474118611Snjl 475151937Sjkimstatic void 476118611SnjlOpnDoField ( 477118611Snjl ACPI_PARSE_OBJECT *Op) 478118611Snjl{ 479118611Snjl ACPI_PARSE_OBJECT *Next; 480118611Snjl 481118611Snjl 482118611Snjl /* Opcode is parent node */ 483118611Snjl /* First child is field name */ 484118611Snjl 485118611Snjl Next = Op->Asl.Child; 486118611Snjl 487118611Snjl /* Second child is the AccessType */ 488118611Snjl 489118611Snjl OpnDoFieldCommon (Op, Next->Asl.Next); 490118611Snjl} 491118611Snjl 492118611Snjl 493118611Snjl/******************************************************************************* 494118611Snjl * 495118611Snjl * FUNCTION: OpnDoIndexField 496118611Snjl * 497118611Snjl * PARAMETERS: Op - The parent parse node 498118611Snjl * 499118611Snjl * RETURN: None 500118611Snjl * 501118611Snjl * DESCRIPTION: Construct the AML operands for the INDEXFIELD ASL keyword 502118611Snjl * 503118611Snjl ******************************************************************************/ 504118611Snjl 505151937Sjkimstatic void 506118611SnjlOpnDoIndexField ( 507118611Snjl ACPI_PARSE_OBJECT *Op) 508118611Snjl{ 509118611Snjl ACPI_PARSE_OBJECT *Next; 510118611Snjl 511118611Snjl 512118611Snjl /* Opcode is parent node */ 513118611Snjl /* First child is the index name */ 514118611Snjl 515118611Snjl Next = Op->Asl.Child; 516118611Snjl 517118611Snjl /* Second child is the data name */ 518118611Snjl 519118611Snjl Next = Next->Asl.Next; 520118611Snjl 521118611Snjl /* Third child is the AccessType */ 522118611Snjl 523118611Snjl OpnDoFieldCommon (Op, Next->Asl.Next); 524118611Snjl} 525118611Snjl 526118611Snjl 527118611Snjl/******************************************************************************* 528118611Snjl * 529118611Snjl * FUNCTION: OpnDoBankField 530118611Snjl * 531118611Snjl * PARAMETERS: Op - The parent parse node 532118611Snjl * 533118611Snjl * RETURN: None 534118611Snjl * 535118611Snjl * DESCRIPTION: Construct the AML operands for the BANKFIELD ASL keyword 536118611Snjl * 537118611Snjl ******************************************************************************/ 538118611Snjl 539151937Sjkimstatic void 540118611SnjlOpnDoBankField ( 541118611Snjl ACPI_PARSE_OBJECT *Op) 542118611Snjl{ 543118611Snjl ACPI_PARSE_OBJECT *Next; 544118611Snjl 545118611Snjl 546118611Snjl /* Opcode is parent node */ 547118611Snjl /* First child is the region name */ 548118611Snjl 549118611Snjl Next = Op->Asl.Child; 550118611Snjl 551118611Snjl /* Second child is the bank name */ 552118611Snjl 553118611Snjl Next = Next->Asl.Next; 554118611Snjl 555118611Snjl /* Third child is the bank value */ 556118611Snjl 557118611Snjl Next = Next->Asl.Next; 558118611Snjl 559118611Snjl /* Fourth child is the AccessType */ 560118611Snjl 561118611Snjl OpnDoFieldCommon (Op, Next->Asl.Next); 562118611Snjl} 563118611Snjl 564118611Snjl 565118611Snjl/******************************************************************************* 566118611Snjl * 567118611Snjl * FUNCTION: OpnDoRegion 568118611Snjl * 569118611Snjl * PARAMETERS: Op - The parent parse node 570118611Snjl * 571118611Snjl * RETURN: None 572118611Snjl * 573118611Snjl * DESCRIPTION: Tries to get the length of the region. Can only do this at 574118611Snjl * compile time if the length is a constant. 575118611Snjl * 576118611Snjl ******************************************************************************/ 577118611Snjl 578151937Sjkimstatic void 579118611SnjlOpnDoRegion ( 580118611Snjl ACPI_PARSE_OBJECT *Op) 581118611Snjl{ 582118611Snjl ACPI_PARSE_OBJECT *Next; 583118611Snjl 584118611Snjl 585118611Snjl /* Opcode is parent node */ 586118611Snjl /* First child is the region name */ 587118611Snjl 588118611Snjl Next = Op->Asl.Child; 589118611Snjl 590118611Snjl /* Second child is the space ID*/ 591118611Snjl 592118611Snjl Next = Next->Asl.Next; 593118611Snjl 594118611Snjl /* Third child is the region offset */ 595118611Snjl 596118611Snjl Next = Next->Asl.Next; 597118611Snjl 598118611Snjl /* Fourth child is the region length */ 599118611Snjl 600118611Snjl Next = Next->Asl.Next; 601118611Snjl if (Next->Asl.ParseOpcode == PARSEOP_INTEGER) 602118611Snjl { 603118611Snjl Op->Asl.Value.Integer = Next->Asl.Value.Integer; 604118611Snjl } 605118611Snjl else 606118611Snjl { 607118611Snjl Op->Asl.Value.Integer = ACPI_INTEGER_MAX; 608118611Snjl } 609118611Snjl} 610118611Snjl 611118611Snjl 612118611Snjl/******************************************************************************* 613118611Snjl * 614118611Snjl * FUNCTION: OpnDoBuffer 615118611Snjl * 616118611Snjl * PARAMETERS: Op - The parent parse node 617118611Snjl * 618118611Snjl * RETURN: None 619118611Snjl * 620118611Snjl * DESCRIPTION: Construct the AML operands for the BUFFER ASL keyword. We 621118611Snjl * build a single raw byte buffer from the initialization nodes, 622118611Snjl * each parse node contains a buffer byte. 623118611Snjl * 624118611Snjl ******************************************************************************/ 625118611Snjl 626151937Sjkimstatic void 627118611SnjlOpnDoBuffer ( 628118611Snjl ACPI_PARSE_OBJECT *Op) 629118611Snjl{ 630118611Snjl ACPI_PARSE_OBJECT *InitializerOp; 631118611Snjl ACPI_PARSE_OBJECT *BufferLengthOp; 632118611Snjl 633118611Snjl /* Optional arguments for this opcode with defaults */ 634118611Snjl 635118611Snjl UINT32 BufferLength = 0; 636118611Snjl 637118611Snjl 638118611Snjl /* Opcode and package length first */ 639118611Snjl /* Buffer Length is next, followed by the initializer list */ 640118611Snjl 641118611Snjl BufferLengthOp = Op->Asl.Child; 642118611Snjl InitializerOp = BufferLengthOp->Asl.Next; 643118611Snjl 644118611Snjl /* 645118611Snjl * If the BufferLength is not an INTEGER or was not specified in the ASL 646118611Snjl * (DEFAULT_ARG), it is a TermArg that is 647118611Snjl * evaluated at run-time, and we are therefore finished. 648118611Snjl */ 649118611Snjl if ((BufferLengthOp->Asl.ParseOpcode != PARSEOP_INTEGER) && 650118611Snjl (BufferLengthOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) 651118611Snjl { 652118611Snjl return; 653118611Snjl } 654118611Snjl 655118611Snjl /* 656118611Snjl * We want to count the number of items in the initializer list, because if 657118611Snjl * it is larger than the buffer length, we will define the buffer size 658118611Snjl * to be the size of the initializer list (as per the ACPI Specification) 659118611Snjl */ 660118611Snjl switch (InitializerOp->Asl.ParseOpcode) 661118611Snjl { 662118611Snjl case PARSEOP_INTEGER: 663118611Snjl case PARSEOP_BYTECONST: 664118611Snjl case PARSEOP_WORDCONST: 665118611Snjl case PARSEOP_DWORDCONST: 666118611Snjl 667118611Snjl /* The peer list contains the byte list (if any...) */ 668118611Snjl 669118611Snjl while (InitializerOp) 670118611Snjl { 671118611Snjl /* For buffers, this is a list of raw bytes */ 672118611Snjl 673118611Snjl InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 674118611Snjl InitializerOp->Asl.AmlLength = 1; 675118611Snjl InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; 676118611Snjl 677118611Snjl BufferLength++; 678118611Snjl InitializerOp = ASL_GET_PEER_NODE (InitializerOp); 679118611Snjl } 680118611Snjl break; 681118611Snjl 682118611Snjl 683118611Snjl case PARSEOP_STRING_LITERAL: 684118611Snjl 685118611Snjl /* 686118611Snjl * Only one initializer, the string. Buffer must be big enough to hold 687118611Snjl * the string plus the null termination byte 688118611Snjl */ 689118611Snjl BufferLength = strlen (InitializerOp->Asl.Value.String) + 1; 690118611Snjl 691118611Snjl InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; 692118611Snjl InitializerOp->Asl.AmlLength = BufferLength; 693118611Snjl InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; 694118611Snjl break; 695118611Snjl 696118611Snjl 697118611Snjl case PARSEOP_RAW_DATA: 698118611Snjl 699118611Snjl /* Buffer nodes are already initialized (e.g. Unicode operator) */ 700118611Snjl return; 701118611Snjl 702118611Snjl 703118611Snjl case PARSEOP_DEFAULT_ARG: 704118611Snjl break; 705118611Snjl 706118611Snjl 707118611Snjl default: 708118611Snjl AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, InitializerOp, 709118611Snjl "Unknown buffer initializer opcode"); 710118611Snjl printf ("Unknown buffer initializer opcode [%s]\n", 711118611Snjl UtGetOpName (InitializerOp->Asl.ParseOpcode)); 712118611Snjl return; 713118611Snjl } 714118611Snjl 715118611Snjl /* Check if initializer list is longer than the buffer length */ 716118611Snjl 717118611Snjl if (BufferLengthOp->Asl.Value.Integer > BufferLength) 718118611Snjl { 719118611Snjl BufferLength = (UINT32) BufferLengthOp->Asl.Value.Integer; 720118611Snjl } 721118611Snjl 722118611Snjl if (!BufferLength) 723118611Snjl { 724151937Sjkim /* No length AND no items -- issue notice */ 725118611Snjl 726151937Sjkim AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL); 727118611Snjl 728118611Snjl /* But go ahead and put the buffer length of zero into the AML */ 729118611Snjl } 730118611Snjl 731118611Snjl /* 732118611Snjl * Just set the buffer size node to be the buffer length, regardless 733118611Snjl * of whether it was previously an integer or a default_arg placeholder 734118611Snjl */ 735118611Snjl BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; 736118611Snjl BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; 737118611Snjl BufferLengthOp->Asl.Value.Integer = BufferLength; 738118611Snjl 739118611Snjl (void) OpcSetOptimalIntegerSize (BufferLengthOp); 740118611Snjl 741118611Snjl /* Remaining nodes are handled via the tree walk */ 742118611Snjl} 743118611Snjl 744118611Snjl 745118611Snjl/******************************************************************************* 746118611Snjl * 747118611Snjl * FUNCTION: OpnDoPackage 748118611Snjl * 749118611Snjl * PARAMETERS: Op - The parent parse node 750118611Snjl * 751118611Snjl * RETURN: None 752118611Snjl * 753151937Sjkim * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE: 754151937Sjkim * can only be called after constants have been folded, to ensure 755151937Sjkim * that the PackageLength operand has been fully reduced. 756118611Snjl * 757118611Snjl ******************************************************************************/ 758118611Snjl 759118611Snjlvoid 760118611SnjlOpnDoPackage ( 761118611Snjl ACPI_PARSE_OBJECT *Op) 762118611Snjl{ 763118611Snjl ACPI_PARSE_OBJECT *InitializerOp; 764118611Snjl ACPI_PARSE_OBJECT *PackageLengthOp; 765151937Sjkim UINT32 PackageLength = 0; 766118611Snjl 767118611Snjl 768151937Sjkim /* Opcode and package length first, followed by the initializer list */ 769118611Snjl 770118611Snjl PackageLengthOp = Op->Asl.Child; 771118611Snjl InitializerOp = PackageLengthOp->Asl.Next; 772118611Snjl 773151937Sjkim /* Count the number of items in the initializer list */ 774151937Sjkim 775118611Snjl if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 776118611Snjl { 777118611Snjl /* The peer list contains the byte list (if any...) */ 778118611Snjl 779118611Snjl while (InitializerOp) 780118611Snjl { 781118611Snjl PackageLength++; 782118611Snjl InitializerOp = InitializerOp->Asl.Next; 783118611Snjl } 784118611Snjl } 785118611Snjl 786151937Sjkim /* If package length is a constant, compare to the initializer list */ 787118611Snjl 788118611Snjl if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || 789151937Sjkim (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)) 790118611Snjl { 791151937Sjkim if (PackageLengthOp->Asl.Value.Integer >= PackageLength) 792118611Snjl { 793151937Sjkim /* Allow package to be longer than the initializer list */ 794151937Sjkim 795118611Snjl PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer; 796118611Snjl } 797151937Sjkim else 798151937Sjkim { 799151937Sjkim /* 800151937Sjkim * Initializer list is longer than the package length. This 801151937Sjkim * is an error as per the ACPI spec. 802151937Sjkim */ 803151937Sjkim AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH, 804151937Sjkim PackageLengthOp->Asl.Next, NULL); 805151937Sjkim } 806118611Snjl } 807118611Snjl 808151937Sjkim if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 809151937Sjkim { 810151937Sjkim /* 811151937Sjkim * This is the case if the PackageLength was left empty - Package() 812151937Sjkim * The package length becomes the length of the initializer list 813151937Sjkim */ 814151937Sjkim Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER; 815151937Sjkim Op->Asl.Child->Asl.Value.Integer = PackageLength; 816151937Sjkim 817151937Sjkim /* Set the AML opcode */ 818151937Sjkim 819151937Sjkim (void) OpcSetOptimalIntegerSize (Op->Asl.Child); 820151937Sjkim } 821151937Sjkim 822151937Sjkim /* If not a variable-length package, check for a zero package length */ 823151937Sjkim 824118611Snjl if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || 825151937Sjkim (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) || 826118611Snjl (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)) 827118611Snjl { 828118611Snjl if (!PackageLength) 829118611Snjl { 830151937Sjkim /* No length AND no initializer list -- issue a remark */ 831118611Snjl 832151937Sjkim AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH, 833151937Sjkim PackageLengthOp, NULL); 834118611Snjl 835118611Snjl /* But go ahead and put the buffer length of zero into the AML */ 836118611Snjl } 837118611Snjl } 838118611Snjl 839118611Snjl /* 840151937Sjkim * If the PackageLength is a constant <= 255, we can change the 841151937Sjkim * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode. 842118611Snjl */ 843151937Sjkim if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && 844151937Sjkim (Op->Asl.Child->Asl.Value.Integer <= 255)) 845151937Sjkim { 846151937Sjkim Op->Asl.AmlOpcode = AML_PACKAGE_OP; 847151937Sjkim Op->Asl.ParseOpcode = PARSEOP_PACKAGE; 848118611Snjl 849151937Sjkim /* 850151937Sjkim * Just set the package size node to be the package length, regardless 851151937Sjkim * of whether it was previously an integer or a default_arg placeholder 852151937Sjkim */ 853151937Sjkim PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 854151937Sjkim PackageLengthOp->Asl.AmlLength = 1; 855151937Sjkim PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; 856151937Sjkim PackageLengthOp->Asl.Value.Integer = PackageLength; 857151937Sjkim } 858151937Sjkim 859118611Snjl /* Remaining nodes are handled via the tree walk */ 860118611Snjl} 861118611Snjl 862118611Snjl 863118611Snjl/******************************************************************************* 864118611Snjl * 865118611Snjl * FUNCTION: OpnDoLoadTable 866118611Snjl * 867118611Snjl * PARAMETERS: Op - The parent parse node 868118611Snjl * 869118611Snjl * RETURN: None 870118611Snjl * 871118611Snjl * DESCRIPTION: Construct the AML operands for the LOADTABLE ASL keyword. 872118611Snjl * 873118611Snjl ******************************************************************************/ 874118611Snjl 875151937Sjkimstatic void 876118611SnjlOpnDoLoadTable ( 877118611Snjl ACPI_PARSE_OBJECT *Op) 878118611Snjl{ 879118611Snjl ACPI_PARSE_OBJECT *Next; 880118611Snjl 881118611Snjl 882118611Snjl /* Opcode is parent node */ 883118611Snjl /* First child is the table signature */ 884118611Snjl 885118611Snjl Next = Op->Asl.Child; 886118611Snjl 887118611Snjl /* Second child is the OEM ID*/ 888118611Snjl 889118611Snjl Next = Next->Asl.Next; 890118611Snjl 891118611Snjl /* Third child is the OEM table ID */ 892118611Snjl 893118611Snjl Next = Next->Asl.Next; 894118611Snjl 895118611Snjl /* Fourth child is the RootPath string */ 896118611Snjl 897118611Snjl Next = Next->Asl.Next; 898118611Snjl if (Next->Asl.ParseOpcode == PARSEOP_ZERO) 899118611Snjl { 900118611Snjl Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; 901118611Snjl Next->Asl.Value.String = "\\"; 902118611Snjl Next->Asl.AmlLength = 2; 903118611Snjl OpcGenerateAmlOpcode (Next); 904118611Snjl } 905118611Snjl 906151937Sjkim#ifdef ASL_FUTURE_IMPLEMENTATION 907151937Sjkim 908151937Sjkim /* TBD: NOT IMPLEMENTED */ 909118611Snjl /* Fifth child is the [optional] ParameterPathString */ 910118611Snjl /* Sixth child is the [optional] ParameterData */ 911118611Snjl 912118611Snjl Next = Next->Asl.Next; 913118611Snjl if (Next->Asl.ParseOpcode == DEFAULT_ARG) 914118611Snjl { 915118611Snjl Next->Asl.AmlLength = 1; 916118611Snjl Next->Asl.ParseOpcode = ZERO; 917118611Snjl OpcGenerateAmlOpcode (Next); 918118611Snjl } 919118611Snjl 920118611Snjl 921118611Snjl Next = Next->Asl.Next; 922118611Snjl if (Next->Asl.ParseOpcode == DEFAULT_ARG) 923118611Snjl { 924118611Snjl Next->Asl.AmlLength = 1; 925118611Snjl Next->Asl.ParseOpcode = ZERO; 926118611Snjl OpcGenerateAmlOpcode (Next); 927118611Snjl } 928151937Sjkim#endif 929118611Snjl} 930118611Snjl 931118611Snjl 932118611Snjl/******************************************************************************* 933118611Snjl * 934118611Snjl * FUNCTION: OpnDoDefinitionBlock 935118611Snjl * 936118611Snjl * PARAMETERS: Op - The parent parse node 937118611Snjl * 938118611Snjl * RETURN: None 939118611Snjl * 940118611Snjl * DESCRIPTION: Construct the AML operands for the DEFINITIONBLOCK ASL keyword 941118611Snjl * 942118611Snjl ******************************************************************************/ 943118611Snjl 944151937Sjkimstatic void 945118611SnjlOpnDoDefinitionBlock ( 946118611Snjl ACPI_PARSE_OBJECT *Op) 947118611Snjl{ 948118611Snjl ACPI_PARSE_OBJECT *Child; 949118611Snjl ACPI_SIZE Length; 950193529Sjkim UINT32 i; 951193529Sjkim char *Filename; 952118611Snjl 953118611Snjl 954118611Snjl /* 955118611Snjl * These nodes get stuffed into the table header. They are special 956118611Snjl * cased when the table is written to the output file. 957118611Snjl * 958118611Snjl * Mark all of these nodes as non-usable so they won't get output 959118611Snjl * as AML opcodes! 960118611Snjl */ 961118611Snjl 962167802Sjkim /* Get AML filename. Use it if non-null */ 963118611Snjl 964118611Snjl Child = Op->Asl.Child; 965167802Sjkim if (Child->Asl.Value.Buffer && 966167802Sjkim *Child->Asl.Value.Buffer && 967167802Sjkim (Gbl_UseDefaultAmlFilename)) 968118611Snjl { 969193529Sjkim /* 970193529Sjkim * We will use the AML filename that is embedded in the source file 971193529Sjkim * for the output filename. 972193529Sjkim */ 973193529Sjkim Filename = ACPI_ALLOCATE (strlen (Gbl_DirectoryPath) + 974193529Sjkim strlen ((char *) Child->Asl.Value.Buffer) + 1); 975193529Sjkim 976193529Sjkim /* Prepend the current directory path */ 977193529Sjkim 978193529Sjkim strcpy (Filename, Gbl_DirectoryPath); 979193529Sjkim strcat (Filename, (char *) Child->Asl.Value.Buffer); 980193529Sjkim 981193529Sjkim Gbl_OutputFilenamePrefix = Filename; 982118611Snjl } 983118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 984118611Snjl 985118611Snjl /* Signature */ 986118611Snjl 987118611Snjl Child = Child->Asl.Next; 988118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 989118611Snjl if (Child->Asl.Value.String) 990118611Snjl { 991118611Snjl Gbl_TableSignature = Child->Asl.Value.String; 992118611Snjl if (ACPI_STRLEN (Gbl_TableSignature) != 4) 993118611Snjl { 994151937Sjkim AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, 995151937Sjkim "Length not exactly 4"); 996118611Snjl } 997118611Snjl 998118611Snjl for (i = 0; i < 4; i++) 999118611Snjl { 1000118611Snjl if (!isalnum (Gbl_TableSignature[i])) 1001118611Snjl { 1002151937Sjkim AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, 1003151937Sjkim "Contains non-alphanumeric characters"); 1004118611Snjl } 1005118611Snjl } 1006118611Snjl } 1007118611Snjl 1008118611Snjl /* Revision */ 1009118611Snjl 1010118611Snjl Child = Child->Asl.Next; 1011118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 1012167802Sjkim /* 1013167802Sjkim * We used the revision to set the integer width earlier 1014167802Sjkim */ 1015118611Snjl 1016118611Snjl /* OEMID */ 1017118611Snjl 1018118611Snjl Child = Child->Asl.Next; 1019118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 1020118611Snjl 1021118611Snjl /* OEM TableID */ 1022118611Snjl 1023118611Snjl Child = Child->Asl.Next; 1024118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 1025118611Snjl if (Child->Asl.Value.String) 1026118611Snjl { 1027118611Snjl Length = ACPI_STRLEN (Child->Asl.Value.String); 1028118611Snjl Gbl_TableId = AcpiOsAllocate (Length + 1); 1029118611Snjl ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); 1030118611Snjl 1031118611Snjl for (i = 0; i < Length; i++) 1032118611Snjl { 1033118611Snjl if (Gbl_TableId[i] == ' ') 1034118611Snjl { 1035118611Snjl Gbl_TableId[i] = 0; 1036118611Snjl break; 1037118611Snjl } 1038118611Snjl } 1039118611Snjl } 1040118611Snjl 1041118611Snjl /* OEM Revision */ 1042118611Snjl 1043118611Snjl Child = Child->Asl.Next; 1044118611Snjl Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 1045118611Snjl} 1046118611Snjl 1047118611Snjl 1048118611Snjl/******************************************************************************* 1049118611Snjl * 1050118611Snjl * FUNCTION: UtGetArg 1051118611Snjl * 1052118611Snjl * PARAMETERS: Op - Get an argument for this op 1053118611Snjl * Argn - Nth argument to get 1054118611Snjl * 1055118611Snjl * RETURN: The argument (as an Op object). NULL if argument does not exist 1056118611Snjl * 1057118611Snjl * DESCRIPTION: Get the specified op's argument (peer) 1058118611Snjl * 1059118611Snjl ******************************************************************************/ 1060118611Snjl 1061118611SnjlACPI_PARSE_OBJECT * 1062118611SnjlUtGetArg ( 1063118611Snjl ACPI_PARSE_OBJECT *Op, 1064118611Snjl UINT32 Argn) 1065118611Snjl{ 1066118611Snjl ACPI_PARSE_OBJECT *Arg = NULL; 1067118611Snjl 1068118611Snjl 1069118611Snjl /* Get the requested argument object */ 1070118611Snjl 1071118611Snjl Arg = Op->Asl.Child; 1072118611Snjl while (Arg && Argn) 1073118611Snjl { 1074118611Snjl Argn--; 1075118611Snjl Arg = Arg->Asl.Next; 1076118611Snjl } 1077118611Snjl 1078118611Snjl return (Arg); 1079118611Snjl} 1080118611Snjl 1081118611Snjl 1082118611Snjl/******************************************************************************* 1083118611Snjl * 1084118611Snjl * FUNCTION: OpnAttachNameToNode 1085118611Snjl * 1086118611Snjl * PARAMETERS: Op - The parent parse node 1087118611Snjl * 1088118611Snjl * RETURN: None 1089118611Snjl * 1090118611Snjl * DESCRIPTION: For the named ASL/AML operators, get the actual name from the 1091118611Snjl * argument list and attach it to the parent node so that we 1092118611Snjl * can get to it quickly later. 1093118611Snjl * 1094118611Snjl ******************************************************************************/ 1095118611Snjl 1096151937Sjkimstatic void 1097118611SnjlOpnAttachNameToNode ( 1098118611Snjl ACPI_PARSE_OBJECT *Op) 1099118611Snjl{ 1100118611Snjl ACPI_PARSE_OBJECT *Child = NULL; 1101118611Snjl 1102118611Snjl 1103118611Snjl if (Op->Asl.ParseOpcode == PARSEOP_EXTERNAL) 1104118611Snjl { 1105118611Snjl Child = UtGetArg (Op, 0); 1106118611Snjl } 1107118611Snjl else switch (Op->Asl.AmlOpcode) 1108118611Snjl { 1109118611Snjl case AML_DATA_REGION_OP: 1110118611Snjl case AML_DEVICE_OP: 1111118611Snjl case AML_EVENT_OP: 1112118611Snjl case AML_METHOD_OP: 1113118611Snjl case AML_MUTEX_OP: 1114118611Snjl case AML_REGION_OP: 1115118611Snjl case AML_POWER_RES_OP: 1116118611Snjl case AML_PROCESSOR_OP: 1117118611Snjl case AML_THERMAL_ZONE_OP: 1118118611Snjl case AML_NAME_OP: 1119118611Snjl case AML_SCOPE_OP: 1120118611Snjl 1121118611Snjl Child = UtGetArg (Op, 0); 1122118611Snjl break; 1123118611Snjl 1124118611Snjl case AML_ALIAS_OP: 1125118611Snjl 1126118611Snjl Child = UtGetArg (Op, 1); 1127118611Snjl break; 1128118611Snjl 1129118611Snjl case AML_CREATE_BIT_FIELD_OP: 1130118611Snjl case AML_CREATE_BYTE_FIELD_OP: 1131118611Snjl case AML_CREATE_WORD_FIELD_OP: 1132118611Snjl case AML_CREATE_DWORD_FIELD_OP: 1133118611Snjl case AML_CREATE_QWORD_FIELD_OP: 1134118611Snjl 1135118611Snjl Child = UtGetArg (Op, 2); 1136118611Snjl break; 1137118611Snjl 1138118611Snjl case AML_CREATE_FIELD_OP: 1139118611Snjl 1140118611Snjl Child = UtGetArg (Op, 3); 1141118611Snjl break; 1142118611Snjl 1143118611Snjl case AML_BANK_FIELD_OP: 1144118611Snjl case AML_INDEX_FIELD_OP: 1145118611Snjl case AML_FIELD_OP: 1146118611Snjl 1147118611Snjl return; 1148118611Snjl 1149118611Snjl default: 1150118611Snjl return; 1151118611Snjl } 1152118611Snjl 1153118611Snjl if (Child) 1154118611Snjl { 1155118611Snjl UtAttachNamepathToOwner (Op, Child); 1156118611Snjl } 1157118611Snjl} 1158118611Snjl 1159118611Snjl 1160118611Snjl/******************************************************************************* 1161118611Snjl * 1162118611Snjl * FUNCTION: OpnGenerateAmlOperands 1163118611Snjl * 1164118611Snjl * PARAMETERS: Op - The parent parse node 1165118611Snjl * 1166118611Snjl * RETURN: None 1167118611Snjl * 1168118611Snjl * DESCRIPTION: Prepare nodes to be output as AML data and operands. The more 1169118611Snjl * complex AML opcodes require processing of the child nodes 1170118611Snjl * (arguments/operands). 1171118611Snjl * 1172118611Snjl ******************************************************************************/ 1173118611Snjl 1174118611Snjlvoid 1175118611SnjlOpnGenerateAmlOperands ( 1176118611Snjl ACPI_PARSE_OBJECT *Op) 1177118611Snjl{ 1178118611Snjl 1179118611Snjl 1180118611Snjl if (Op->Asl.AmlOpcode == AML_RAW_DATA_BYTE) 1181118611Snjl { 1182118611Snjl return; 1183118611Snjl } 1184118611Snjl 1185118611Snjl switch (Op->Asl.ParseOpcode) 1186118611Snjl { 1187118611Snjl case PARSEOP_DEFINITIONBLOCK: 1188118611Snjl OpnDoDefinitionBlock (Op); 1189118611Snjl break; 1190118611Snjl 1191118611Snjl case PARSEOP_METHOD: 1192118611Snjl OpnDoMethod (Op); 1193118611Snjl break; 1194118611Snjl 1195151937Sjkim case PARSEOP_MUTEX: 1196151937Sjkim OpnDoMutex (Op); 1197151937Sjkim break; 1198151937Sjkim 1199118611Snjl case PARSEOP_FIELD: 1200118611Snjl OpnDoField (Op); 1201118611Snjl break; 1202118611Snjl 1203118611Snjl case PARSEOP_INDEXFIELD: 1204118611Snjl OpnDoIndexField (Op); 1205118611Snjl break; 1206118611Snjl 1207118611Snjl case PARSEOP_BANKFIELD: 1208118611Snjl OpnDoBankField (Op); 1209118611Snjl break; 1210118611Snjl 1211118611Snjl case PARSEOP_BUFFER: 1212118611Snjl OpnDoBuffer (Op); 1213118611Snjl break; 1214118611Snjl 1215118611Snjl case PARSEOP_LOADTABLE: 1216118611Snjl OpnDoLoadTable (Op); 1217118611Snjl break; 1218118611Snjl 1219118611Snjl case PARSEOP_OPERATIONREGION: 1220118611Snjl OpnDoRegion (Op); 1221118611Snjl break; 1222118611Snjl 1223118611Snjl case PARSEOP_RESOURCETEMPLATE: 1224118611Snjl RsDoResourceTemplate (Op); 1225118611Snjl break; 1226118611Snjl 1227118611Snjl case PARSEOP_NAMESEG: 1228118611Snjl case PARSEOP_NAMESTRING: 1229118611Snjl case PARSEOP_METHODCALL: 1230118611Snjl case PARSEOP_STRING_LITERAL: 1231118611Snjl break; 1232118611Snjl 1233118611Snjl default: 1234118611Snjl break; 1235118611Snjl } 1236118611Snjl 1237118611Snjl /* TBD: move */ 1238118611Snjl 1239118611Snjl OpnAttachNameToNode (Op); 1240118611Snjl} 1241118611Snjl 1242118611Snjl 1243