1 2 /****************************************************************************** 3 * 4 * Module Name: aslopcode - AML opcode generation 5 * 6 *****************************************************************************/ 7 8 /****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2009, 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 118 #include <contrib/dev/acpica/compiler/aslcompiler.h> 119 #include "aslcompiler.y.h" 120 #include <contrib/dev/acpica/include/amlcode.h> 121 122 #define _COMPONENT ACPI_COMPILER 123 ACPI_MODULE_NAME ("aslopcodes") 124 125 126 /* UUID support */ 127 128 static UINT8 OpcMapToUUID[16] = 129 { 130 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 131 }; 132 133 /* Local prototypes */ 134 135 static void 136 OpcDoAccessAs ( 137 ACPI_PARSE_OBJECT *Op); 138 139 static void 140 OpcDoUnicode ( 141 ACPI_PARSE_OBJECT *Op); 142 143 static void 144 OpcDoEisaId ( 145 ACPI_PARSE_OBJECT *Op); 146 147 static void 148 OpcDoUuId ( 149 ACPI_PARSE_OBJECT *Op); 150 151 152 /******************************************************************************* 153 * 154 * FUNCTION: OpcAmlOpcodeUpdateWalk 155 * 156 * PARAMETERS: ASL_WALK_CALLBACK 157 * 158 * RETURN: Status 159 * 160 * DESCRIPTION: Opcode update walk, ascending callback 161 * 162 ******************************************************************************/ 163 164 ACPI_STATUS 165 OpcAmlOpcodeUpdateWalk ( 166 ACPI_PARSE_OBJECT *Op, 167 UINT32 Level, 168 void *Context) 169 { 170 171 /* 172 * Handle the Package() case where the actual opcode cannot be determined 173 * until the PackageLength operand has been folded and minimized. 174 * (PackageOp versus VarPackageOp) 175 * 176 * This is (as of ACPI 3.0) the only case where the AML opcode can change 177 * based upon the value of a parameter. 178 * 179 * The parser always inserts a VarPackage opcode, which can possibly be 180 * optimized to a Package opcode. 181 */ 182 if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE) 183 { 184 OpnDoPackage (Op); 185 } 186 187 return (AE_OK); 188 } 189 190 191 /******************************************************************************* 192 * 193 * FUNCTION: OpcAmlOpcodeWalk 194 * 195 * PARAMETERS: ASL_WALK_CALLBACK 196 * 197 * RETURN: Status 198 * 199 * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML 200 * operands. 201 * 202 ******************************************************************************/ 203 204 ACPI_STATUS 205 OpcAmlOpcodeWalk ( 206 ACPI_PARSE_OBJECT *Op, 207 UINT32 Level, 208 void *Context) 209 { 210 211 TotalParseNodes++; 212 213 OpcGenerateAmlOpcode (Op); 214 OpnGenerateAmlOperands (Op); 215 return (AE_OK); 216 } 217 218 219 /******************************************************************************* 220 * 221 * FUNCTION: OpcGetIntegerWidth 222 * 223 * PARAMETERS: Op - DEFINITION BLOCK op 224 * 225 * RETURN: none 226 * 227 * DESCRIPTION: Extract integer width from the table revision 228 * 229 ******************************************************************************/ 230 231 void 232 OpcGetIntegerWidth ( 233 ACPI_PARSE_OBJECT *Op) 234 { 235 ACPI_PARSE_OBJECT *Child; 236 237 238 if (!Op) 239 { 240 return; 241 } 242 243 if (Gbl_RevisionOverride) 244 { 245 AcpiUtSetIntegerWidth (Gbl_RevisionOverride); 246 } 247 else 248 { 249 Child = Op->Asl.Child; 250 Child = Child->Asl.Next; 251 Child = Child->Asl.Next; 252 253 /* Use the revision to set the integer width */ 254 255 AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer); 256 } 257 } 258 259 260 /******************************************************************************* 261 * 262 * FUNCTION: OpcSetOptimalIntegerSize 263 * 264 * PARAMETERS: Op - A parse tree node 265 * 266 * RETURN: Integer width, in bytes. Also sets the node AML opcode to the 267 * optimal integer AML prefix opcode. 268 * 269 * DESCRIPTION: Determine the optimal AML encoding of an integer. All leading 270 * zeros can be truncated to squeeze the integer into the 271 * minimal number of AML bytes. 272 * 273 ******************************************************************************/ 274 275 UINT32 276 OpcSetOptimalIntegerSize ( 277 ACPI_PARSE_OBJECT *Op) 278 { 279 280 #if 0 281 /* 282 * TBD: - we don't want to optimize integers in the block header, but the 283 * code below does not work correctly. 284 */ 285 if (Op->Asl.Parent && 286 Op->Asl.Parent->Asl.Parent && 287 (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) 288 { 289 return 0; 290 } 291 #endif 292 293 /* 294 * Check for the special AML integers first - Zero, One, Ones. 295 * These are single-byte opcodes that are the smallest possible 296 * representation of an integer. 297 * 298 * This optimization is optional. 299 */ 300 if (Gbl_IntegerOptimizationFlag) 301 { 302 switch (Op->Asl.Value.Integer) 303 { 304 case 0: 305 306 Op->Asl.AmlOpcode = AML_ZERO_OP; 307 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, 308 Op, "Zero"); 309 return 1; 310 311 case 1: 312 313 Op->Asl.AmlOpcode = AML_ONE_OP; 314 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, 315 Op, "One"); 316 return 1; 317 318 case ACPI_UINT32_MAX: 319 320 /* Check for table integer width (32 or 64) */ 321 322 if (AcpiGbl_IntegerByteWidth == 4) 323 { 324 Op->Asl.AmlOpcode = AML_ONES_OP; 325 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, 326 Op, "Ones"); 327 return 1; 328 } 329 break; 330 331 case ACPI_INTEGER_MAX: 332 333 /* Check for table integer width (32 or 64) */ 334 335 if (AcpiGbl_IntegerByteWidth == 8) 336 { 337 Op->Asl.AmlOpcode = AML_ONES_OP; 338 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, 339 Op, "Ones"); 340 return 1; 341 } 342 break; 343 344 default: 345 break; 346 } 347 } 348 349 /* Find the best fit using the various AML integer prefixes */ 350 351 if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX) 352 { 353 Op->Asl.AmlOpcode = AML_BYTE_OP; 354 return 1; 355 } 356 if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX) 357 { 358 Op->Asl.AmlOpcode = AML_WORD_OP; 359 return 2; 360 } 361 if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX) 362 { 363 Op->Asl.AmlOpcode = AML_DWORD_OP; 364 return 4; 365 } 366 else 367 { 368 if (AcpiGbl_IntegerByteWidth == 4) 369 { 370 AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH, 371 Op, NULL); 372 373 if (!Gbl_IgnoreErrors) 374 { 375 /* Truncate the integer to 32-bit */ 376 Op->Asl.AmlOpcode = AML_DWORD_OP; 377 return 4; 378 } 379 } 380 381 Op->Asl.AmlOpcode = AML_QWORD_OP; 382 return 8; 383 } 384 } 385 386 387 /******************************************************************************* 388 * 389 * FUNCTION: OpcDoAccessAs 390 * 391 * PARAMETERS: Op - Parse node 392 * 393 * RETURN: None 394 * 395 * DESCRIPTION: Implement the ACCESS_AS ASL keyword. 396 * 397 ******************************************************************************/ 398 399 static void 400 OpcDoAccessAs ( 401 ACPI_PARSE_OBJECT *Op) 402 { 403 ACPI_PARSE_OBJECT *Next; 404 405 406 Op->Asl.AmlOpcodeLength = 1; 407 Next = Op->Asl.Child; 408 409 /* First child is the access type */ 410 411 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 412 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; 413 414 /* Second child is the optional access attribute */ 415 416 Next = Next->Asl.Next; 417 if (Next->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) 418 { 419 Next->Asl.Value.Integer = 0; 420 } 421 Next->Asl.AmlOpcode = AML_RAW_DATA_BYTE; 422 Next->Asl.ParseOpcode = PARSEOP_RAW_DATA; 423 } 424 425 426 /******************************************************************************* 427 * 428 * FUNCTION: OpcDoUnicode 429 * 430 * PARAMETERS: Op - Parse node 431 * 432 * RETURN: None 433 * 434 * DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string 435 * to a unicode buffer. There is no Unicode AML opcode. 436 * 437 * Note: The Unicode string is 16 bits per character, no leading signature, 438 * with a 16-bit terminating NULL. 439 * 440 ******************************************************************************/ 441 442 static void 443 OpcDoUnicode ( 444 ACPI_PARSE_OBJECT *Op) 445 { 446 ACPI_PARSE_OBJECT *InitializerOp; 447 UINT32 Length; 448 UINT32 Count; 449 UINT32 i; 450 UINT8 *AsciiString; 451 UINT16 *UnicodeString; 452 ACPI_PARSE_OBJECT *BufferLengthOp; 453 454 455 /* Change op into a buffer object */ 456 457 Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; 458 Op->Asl.ParseOpcode = PARSEOP_BUFFER; 459 UtSetParseOpName (Op); 460 461 /* Buffer Length is first, followed by the string */ 462 463 BufferLengthOp = Op->Asl.Child; 464 InitializerOp = BufferLengthOp->Asl.Next; 465 466 AsciiString = (UINT8 *) InitializerOp->Asl.Value.String; 467 468 /* Create a new buffer for the Unicode string */ 469 470 Count = strlen (InitializerOp->Asl.Value.String) + 1; 471 Length = Count * sizeof (UINT16); 472 UnicodeString = UtLocalCalloc (Length); 473 474 /* Convert to Unicode string (including null terminator) */ 475 476 for (i = 0; i < Count; i++) 477 { 478 UnicodeString[i] = (UINT16) AsciiString[i]; 479 } 480 481 /* 482 * Just set the buffer size node to be the buffer length, regardless 483 * of whether it was previously an integer or a default_arg placeholder 484 */ 485 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER; 486 BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP; 487 BufferLengthOp->Asl.Value.Integer = Length; 488 UtSetParseOpName (BufferLengthOp); 489 490 (void) OpcSetOptimalIntegerSize (BufferLengthOp); 491 492 /* The Unicode string is a raw data buffer */ 493 494 InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString; 495 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; 496 InitializerOp->Asl.AmlLength = Length; 497 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; 498 InitializerOp->Asl.Child = NULL; 499 UtSetParseOpName (InitializerOp); 500 } 501 502 503 /******************************************************************************* 504 * 505 * FUNCTION: OpcDoEisaId 506 * 507 * PARAMETERS: Op - Parse node 508 * 509 * RETURN: None 510 * 511 * DESCRIPTION: Convert a string EISA ID to numeric representation. See the 512 * Pnp BIOS Specification for details. Here is an excerpt: 513 * 514 * A seven character ASCII representation of the product 515 * identifier compressed into a 32-bit identifier. The seven 516 * character ID consists of a three character manufacturer code, 517 * a three character hexadecimal product identifier, and a one 518 * character hexadecimal revision number. The manufacturer code 519 * is a 3 uppercase character code that is compressed into 3 5-bit 520 * values as follows: 521 * 1) Find hex ASCII value for each letter 522 * 2) Subtract 40h from each ASCII value 523 * 3) Retain 5 least signficant bits for each letter by 524 * discarding upper 3 bits because they are always 0. 525 * 4) Compressed code = concatenate 0 and the 3 5-bit values 526 * 527 * The format of the compressed product identifier is as follows: 528 * Byte 0: Bit 7 - Reserved (0) 529 * Bits 6-2: - 1st character of compressed mfg code 530 * Bits 1-0 - Upper 2 bits of 2nd character of mfg code 531 * Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code 532 * Bits 4-0 - 3rd character of mfg code 533 * Byte 2: Bits 7-4 - 1st hex digit of product number 534 * Bits 3-0 - 2nd hex digit of product number 535 * Byte 3: Bits 7-4 - 3st hex digit of product number 536 * Bits 3-0 - Hex digit of the revision number 537 * 538 ******************************************************************************/ 539 540 static void 541 OpcDoEisaId ( 542 ACPI_PARSE_OBJECT *Op) 543 { 544 UINT32 EisaId = 0; 545 UINT32 BigEndianId; 546 char *InString; 547 ACPI_STATUS Status = AE_OK; 548 UINT32 i; 549 550 551 InString = (char *) Op->Asl.Value.String; 552 553 /* 554 * The EISAID string must be exactly 7 characters and of the form 555 * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001") 556 */ 557 if (ACPI_STRLEN (InString) != 7) 558 { 559 Status = AE_BAD_PARAMETER; 560 } 561 else 562 { 563 /* Check all 7 characters for correct format */ 564 565 for (i = 0; i < 7; i++) 566 { 567 /* First 3 characters must be uppercase letters */ 568 569 if (i < 3) 570 { 571 if (!isupper (InString[i])) 572 { 573 Status = AE_BAD_PARAMETER; 574 } 575 } 576 577 /* Last 4 characters must be hex digits */ 578 579 else if (!isxdigit (InString[i])) 580 { 581 Status = AE_BAD_PARAMETER; 582 } 583 } 584 } 585 586 if (ACPI_FAILURE (Status)) 587 { 588 AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String); 589 } 590 else 591 { 592 /* Create ID big-endian first (bits are contiguous) */ 593 594 BigEndianId = 595 (UINT32) (InString[0] - 0x40) << 26 | 596 (UINT32) (InString[1] - 0x40) << 21 | 597 (UINT32) (InString[2] - 0x40) << 16 | 598 599 (UtHexCharToValue (InString[3])) << 12 | 600 (UtHexCharToValue (InString[4])) << 8 | 601 (UtHexCharToValue (InString[5])) << 4 | 602 UtHexCharToValue (InString[6]); 603 604 /* Swap to little-endian to get final ID (see function header) */ 605 606 EisaId = AcpiUtDwordByteSwap (BigEndianId); 607 } 608 609 /* 610 * Morph the Op into an integer, regardless of whether there 611 * was an error in the EISAID string 612 */ 613 Op->Asl.Value.Integer = EisaId; 614 615 Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; 616 Op->Asl.ParseOpcode = PARSEOP_INTEGER; 617 (void) OpcSetOptimalIntegerSize (Op); 618 619 /* Op is now an integer */ 620 621 UtSetParseOpName (Op); 622 } 623 624 625 /******************************************************************************* 626 * 627 * FUNCTION: OpcDoUiId 628 * 629 * PARAMETERS: Op - Parse node 630 * 631 * RETURN: None 632 * 633 * DESCRIPTION: Convert UUID string to 16-byte buffer 634 * 635 ******************************************************************************/ 636 637 static void 638 OpcDoUuId ( 639 ACPI_PARSE_OBJECT *Op) 640 { 641 char *InString; 642 char *Buffer; 643 ACPI_STATUS Status = AE_OK; 644 UINT32 i; 645 ACPI_PARSE_OBJECT *NewOp; 646 647 648 InString = (char *) Op->Asl.Value.String; 649 650 if (ACPI_STRLEN (InString) != 36) 651 { 652 Status = AE_BAD_PARAMETER; 653 } 654 else 655 { 656 /* Check all 36 characters for correct format */ 657 658 for (i = 0; i < 36; i++) 659 { 660 if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) 661 { 662 if (InString[i] != '-') 663 { 664 Status = AE_BAD_PARAMETER; 665 } 666 } 667 else 668 { 669 if (!isxdigit (InString[i])) 670 { 671 Status = AE_BAD_PARAMETER; 672 } 673 } 674 } 675 } 676 677 Buffer = UtLocalCalloc (16); 678 679 if (ACPI_FAILURE (Status)) 680 { 681 AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String); 682 } 683 else for (i = 0; i < 16; i++) 684 { 685 Buffer[i] = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4); 686 Buffer[i] |= (char) UtHexCharToValue (InString[OpcMapToUUID[i] + 1]); 687 } 688 689 /* Change Op to a Buffer */ 690 691 Op->Asl.ParseOpcode = PARSEOP_BUFFER; 692 Op->Common.AmlOpcode = AML_BUFFER_OP; 693 694 /* Disable further optimization */ 695 696 Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; 697 UtSetParseOpName (Op); 698 699 /* Child node is the buffer length */ 700 701 NewOp = TrAllocateNode (PARSEOP_INTEGER); 702 703 NewOp->Asl.AmlOpcode = AML_BYTE_OP; 704 NewOp->Asl.Value.Integer = 16; 705 NewOp->Asl.Parent = Op; 706 707 Op->Asl.Child = NewOp; 708 Op = NewOp; 709 710 /* Peer to the child is the raw buffer data */ 711 712 NewOp = TrAllocateNode (PARSEOP_RAW_DATA); 713 NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; 714 NewOp->Asl.AmlLength = 16; 715 NewOp->Asl.Value.String = (char *) Buffer; 716 NewOp->Asl.Parent = Op->Asl.Parent; 717 718 Op->Asl.Next = NewOp; 719 } 720 721 722 /******************************************************************************* 723 * 724 * FUNCTION: OpcGenerateAmlOpcode 725 * 726 * PARAMETERS: Op - Parse node 727 * 728 * RETURN: None 729 * 730 * DESCRIPTION: Generate the AML opcode associated with the node and its 731 * parse (lex/flex) keyword opcode. Essentially implements 732 * a mapping between the parse opcodes and the actual AML opcodes. 733 * 734 ******************************************************************************/ 735 736 void 737 OpcGenerateAmlOpcode ( 738 ACPI_PARSE_OBJECT *Op) 739 { 740 741 UINT16 Index; 742 743 744 Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE); 745 746 Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode; 747 Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype; 748 Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags; 749 750 if (!Op->Asl.Value.Integer) 751 { 752 Op->Asl.Value.Integer = AslKeywordMapping[Index].Value; 753 } 754 755 /* Special handling for some opcodes */ 756 757 switch (Op->Asl.ParseOpcode) 758 { 759 case PARSEOP_INTEGER: 760 /* 761 * Set the opcode based on the size of the integer 762 */ 763 (void) OpcSetOptimalIntegerSize (Op); 764 break; 765 766 case PARSEOP_OFFSET: 767 768 Op->Asl.AmlOpcodeLength = 1; 769 break; 770 771 case PARSEOP_ACCESSAS: 772 773 OpcDoAccessAs (Op); 774 break; 775 776 case PARSEOP_EISAID: 777 778 OpcDoEisaId (Op); 779 break; 780 781 case PARSEOP_TOUUID: 782 783 OpcDoUuId (Op); 784 break; 785 786 case PARSEOP_UNICODE: 787 788 OpcDoUnicode (Op); 789 break; 790 791 case PARSEOP_INCLUDE: 792 793 Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 794 Gbl_HasIncludeFiles = TRUE; 795 break; 796 797 case PARSEOP_EXTERNAL: 798 799 Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 800 Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 801 break; 802 803 default: 804 /* Nothing to do for other opcodes */ 805 break; 806 } 807 808 return; 809 } 810 811 812