Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: psargs - Parse AML opcode arguments
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 165  *
 166  * DESCRIPTION: Get next raw namestring within the AML stream.  Handles all name
 167  *              prefix characters.  Set parser state to point past the string.
 168  *              (Name is consumed from the AML.)
 169  *
 170  ******************************************************************************/
 171 
 172 char *
 173 AcpiPsGetNextNamestring (
 174     ACPI_PARSE_STATE        *ParserState)
 175 {
 176     UINT8                   *Start = ParserState->Aml;
 177     UINT8                   *End = ParserState->Aml;
 178 
 179 
 180     ACPI_FUNCTION_TRACE (PsGetNextNamestring);
 181 
 182 
 183     /* Point past any namestring prefix characters (backslash or carat) */
 184 
 185     while (AcpiPsIsPrefixChar (*End))

 186     {
 187         End++;
 188     }
 189 
 190     /* Decode the path prefix character */
 191 
 192     switch (*End)
 193     {
 194     case 0:
 195 
 196         /* NullName */
 197 
 198         if (End == Start)
 199         {
 200             Start = NULL;
 201         }
 202         End++;
 203         break;
 204 
 205     case AML_DUAL_NAME_PREFIX:


 429 {
 430     UINT32                  Length;
 431     UINT16                  Opcode;
 432     UINT8                   *Aml = ParserState->Aml;
 433 
 434 
 435     ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
 436 
 437 
 438     switch (ArgType)
 439     {
 440     case ARGP_BYTEDATA:
 441 
 442         /* Get 1 byte from the AML stream */
 443 
 444         Opcode = AML_BYTE_OP;
 445         Arg->Common.Value.Integer = (UINT64) *Aml;
 446         Length = 1;
 447         break;
 448 
 449 
 450     case ARGP_WORDDATA:
 451 
 452         /* Get 2 bytes from the AML stream */
 453 
 454         Opcode = AML_WORD_OP;
 455         ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
 456         Length = 2;
 457         break;
 458 
 459 
 460     case ARGP_DWORDDATA:
 461 
 462         /* Get 4 bytes from the AML stream */
 463 
 464         Opcode = AML_DWORD_OP;
 465         ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
 466         Length = 4;
 467         break;
 468 
 469 
 470     case ARGP_QWORDDATA:
 471 
 472         /* Get 8 bytes from the AML stream */
 473 
 474         Opcode = AML_QWORD_OP;
 475         ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
 476         Length = 8;
 477         break;
 478 
 479 
 480     case ARGP_CHARLIST:
 481 
 482         /* Get a pointer to the string, point past the string */
 483 
 484         Opcode = AML_STRING_OP;
 485         Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
 486 
 487         /* Find the null terminator */
 488 
 489         Length = 0;
 490         while (Aml[Length])
 491         {
 492             Length++;
 493         }
 494         Length++;
 495         break;
 496 
 497 
 498     case ARGP_NAME:
 499     case ARGP_NAMESTRING:
 500 
 501         AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
 502         Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
 503         return_VOID;
 504 
 505 
 506     default:
 507 
 508         ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
 509         return_VOID;
 510     }
 511 
 512     AcpiPsInitOp (Arg, Opcode);
 513     ParserState->Aml += Length;
 514     return_VOID;
 515 }
 516 
 517 
 518 /*******************************************************************************
 519  *
 520  * FUNCTION:    AcpiPsGetNextField
 521  *
 522  * PARAMETERS:  ParserState         - Current parser state object
 523  *
 524  * RETURN:      A newly allocated FIELD op
 525  *
 526  * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
 527  *
 528  ******************************************************************************/
 529 
 530 static ACPI_PARSE_OBJECT *
 531 AcpiPsGetNextField (
 532     ACPI_PARSE_STATE        *ParserState)
 533 {
 534     UINT32                  AmlOffset = (UINT32)
 535                                 ACPI_PTR_DIFF (ParserState->Aml,
 536                                                ParserState->AmlStart);
 537     ACPI_PARSE_OBJECT       *Field;

 538     UINT16                  Opcode;
 539     UINT32                  Name;






 540 
 541 
 542     ACPI_FUNCTION_TRACE (PsGetNextField);
 543 
 544 



 545     /* Determine field type */
 546 
 547     switch (ACPI_GET8 (ParserState->Aml))
 548     {
 549     default:
 550 
 551         Opcode = AML_INT_NAMEDFIELD_OP;

 552         break;
 553 
 554     case 0x00:
 555 
 556         Opcode = AML_INT_RESERVEDFIELD_OP;
 557         ParserState->Aml++;
 558         break;
 559 
 560     case 0x01:
 561 
 562         Opcode = AML_INT_ACCESSFIELD_OP;
 563         ParserState->Aml++;
 564         break;











 565     }
 566 
 567     /* Allocate a new field op */
 568 
 569     Field = AcpiPsAllocOp (Opcode);
 570     if (!Field)
 571     {
 572         return_PTR (NULL);
 573     }
 574 
 575     Field->Common.AmlOffset = AmlOffset;
 576 
 577     /* Decode the field type */
 578 
 579     switch (Opcode)
 580     {
 581     case AML_INT_NAMEDFIELD_OP:
 582 
 583         /* Get the 4-character name */
 584 
 585         ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
 586         AcpiPsSetName (Field, Name);
 587         ParserState->Aml += ACPI_NAME_SIZE;
 588 
 589         /* Get the length which is encoded as a package length */
 590 
 591         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
 592         break;
 593 
 594 
 595     case AML_INT_RESERVEDFIELD_OP:
 596 
 597         /* Get the length which is encoded as a package length */
 598 
 599         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
 600         break;
 601 
 602 
 603     case AML_INT_ACCESSFIELD_OP:

 604 
 605         /*
 606          * Get AccessType and AccessAttrib and merge into the field Op
 607          * AccessType is first operand, AccessAttribute is second

 608          */
 609         Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8));



 610         ParserState->Aml++;
 611         Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml);
 612         ParserState->Aml++;













 613         break;
 614 



















































 615     default:
 616 




































 617         /* Opcode was set in previous switch */
 618         break;
 619     }
 620 
 621     return_PTR (Field);
 622 }
 623 
 624 
 625 /*******************************************************************************
 626  *
 627  * FUNCTION:    AcpiPsGetNextArg
 628  *
 629  * PARAMETERS:  WalkState           - Current state
 630  *              ParserState         - Current parser state object
 631  *              ArgType             - The argument type (AML_*_ARG)
 632  *              ReturnArg           - Where the next arg is returned
 633  *
 634  * RETURN:      Status, and an op object containing the next argument.
 635  *
 636  * DESCRIPTION: Get next argument (including complex list arguments that require


 657 
 658     switch (ArgType)
 659     {
 660     case ARGP_BYTEDATA:
 661     case ARGP_WORDDATA:
 662     case ARGP_DWORDDATA:
 663     case ARGP_CHARLIST:
 664     case ARGP_NAME:
 665     case ARGP_NAMESTRING:
 666 
 667         /* Constants, strings, and namestrings are all the same size */
 668 
 669         Arg = AcpiPsAllocOp (AML_BYTE_OP);
 670         if (!Arg)
 671         {
 672             return_ACPI_STATUS (AE_NO_MEMORY);
 673         }
 674         AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
 675         break;
 676 
 677 
 678     case ARGP_PKGLENGTH:
 679 
 680         /* Package length, nothing returned */
 681 
 682         ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
 683         break;
 684 
 685 
 686     case ARGP_FIELDLIST:
 687 
 688         if (ParserState->Aml < ParserState->PkgEnd)
 689         {
 690             /* Non-empty list */
 691 
 692             while (ParserState->Aml < ParserState->PkgEnd)
 693             {
 694                 Field = AcpiPsGetNextField (ParserState);
 695                 if (!Field)
 696                 {
 697                     return_ACPI_STATUS (AE_NO_MEMORY);
 698                 }
 699 
 700                 if (Prev)
 701                 {
 702                     Prev->Common.Next = Field;
 703                 }
 704                 else
 705                 {
 706                     Arg = Field;
 707                 }
 708                 Prev = Field;
 709             }
 710 
 711             /* Skip to End of byte data */
 712 
 713             ParserState->Aml = ParserState->PkgEnd;
 714         }
 715         break;
 716 
 717 
 718     case ARGP_BYTELIST:
 719 
 720         if (ParserState->Aml < ParserState->PkgEnd)
 721         {
 722             /* Non-empty list */
 723 
 724             Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
 725             if (!Arg)
 726             {
 727                 return_ACPI_STATUS (AE_NO_MEMORY);
 728             }
 729 
 730             /* Fill in bytelist data */
 731 
 732             Arg->Common.Value.Size = (UINT32)
 733                 ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
 734             Arg->Named.Data = ParserState->Aml;
 735 
 736             /* Skip to End of byte data */
 737 
 738             ParserState->Aml = ParserState->PkgEnd;
 739         }
 740         break;
 741 
 742 
 743     case ARGP_TARGET:
 744     case ARGP_SUPERNAME:
 745     case ARGP_SIMPLENAME:
 746 
 747         Subop = AcpiPsPeekOpcode (ParserState);
 748         if (Subop == 0                  ||
 749             AcpiPsIsLeadingChar (Subop) ||
 750             AcpiPsIsPrefixChar (Subop))

 751         {
 752             /* NullName or NameString */
 753 
 754             Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
 755             if (!Arg)
 756             {
 757                 return_ACPI_STATUS (AE_NO_MEMORY);
 758             }
 759 
 760             /* To support SuperName arg of Unload */
 761 
 762             if (WalkState->Opcode == AML_UNLOAD_OP)
 763             {
 764                 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
 765 
 766                 /*
 767                  * If the SuperName arg of Unload is a method call,
 768                  * we have restored the AML pointer, just free this Arg
 769                  */
 770                 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
 771                 {
 772                     AcpiPsFreeOp (Arg);
 773                     Arg = NULL;
 774                 }
 775             }
 776             else
 777             {
 778                 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
 779             }
 780         }
 781         else
 782         {
 783             /* Single complex argument, nothing returned */
 784 
 785             WalkState->ArgCount = 1;
 786         }
 787         break;
 788 
 789 
 790     case ARGP_DATAOBJ:
 791     case ARGP_TERMARG:
 792 
 793         /* Single complex argument, nothing returned */
 794 
 795         WalkState->ArgCount = 1;
 796         break;
 797 
 798 
 799     case ARGP_DATAOBJLIST:
 800     case ARGP_TERMLIST:
 801     case ARGP_OBJLIST:
 802 
 803         if (ParserState->Aml < ParserState->PkgEnd)
 804         {
 805             /* Non-empty list of variable arguments, nothing returned */
 806 
 807             WalkState->ArgCount = ACPI_VAR_ARGS;
 808         }
 809         break;
 810 
 811 
 812     default:
 813 
 814         ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
 815         Status = AE_AML_OPERAND_TYPE;
 816         break;
 817     }
 818 
 819     *ReturnArg = Arg;
 820     return_ACPI_STATUS (Status);
 821 }
   1 /******************************************************************************
   2  *
   3  * Module Name: psargs - Parse AML opcode arguments
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


 165  *
 166  * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name
 167  *              prefix characters. Set parser state to point past the string.
 168  *              (Name is consumed from the AML.)
 169  *
 170  ******************************************************************************/
 171 
 172 char *
 173 AcpiPsGetNextNamestring (
 174     ACPI_PARSE_STATE        *ParserState)
 175 {
 176     UINT8                   *Start = ParserState->Aml;
 177     UINT8                   *End = ParserState->Aml;
 178 
 179 
 180     ACPI_FUNCTION_TRACE (PsGetNextNamestring);
 181 
 182 
 183     /* Point past any namestring prefix characters (backslash or carat) */
 184 
 185     while (ACPI_IS_ROOT_PREFIX (*End) ||
 186            ACPI_IS_PARENT_PREFIX (*End))
 187     {
 188         End++;
 189     }
 190 
 191     /* Decode the path prefix character */
 192 
 193     switch (*End)
 194     {
 195     case 0:
 196 
 197         /* NullName */
 198 
 199         if (End == Start)
 200         {
 201             Start = NULL;
 202         }
 203         End++;
 204         break;
 205 
 206     case AML_DUAL_NAME_PREFIX:


 430 {
 431     UINT32                  Length;
 432     UINT16                  Opcode;
 433     UINT8                   *Aml = ParserState->Aml;
 434 
 435 
 436     ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
 437 
 438 
 439     switch (ArgType)
 440     {
 441     case ARGP_BYTEDATA:
 442 
 443         /* Get 1 byte from the AML stream */
 444 
 445         Opcode = AML_BYTE_OP;
 446         Arg->Common.Value.Integer = (UINT64) *Aml;
 447         Length = 1;
 448         break;
 449 

 450     case ARGP_WORDDATA:
 451 
 452         /* Get 2 bytes from the AML stream */
 453 
 454         Opcode = AML_WORD_OP;
 455         ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
 456         Length = 2;
 457         break;
 458 

 459     case ARGP_DWORDDATA:
 460 
 461         /* Get 4 bytes from the AML stream */
 462 
 463         Opcode = AML_DWORD_OP;
 464         ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
 465         Length = 4;
 466         break;
 467 

 468     case ARGP_QWORDDATA:
 469 
 470         /* Get 8 bytes from the AML stream */
 471 
 472         Opcode = AML_QWORD_OP;
 473         ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
 474         Length = 8;
 475         break;
 476 

 477     case ARGP_CHARLIST:
 478 
 479         /* Get a pointer to the string, point past the string */
 480 
 481         Opcode = AML_STRING_OP;
 482         Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
 483 
 484         /* Find the null terminator */
 485 
 486         Length = 0;
 487         while (Aml[Length])
 488         {
 489             Length++;
 490         }
 491         Length++;
 492         break;
 493 

 494     case ARGP_NAME:
 495     case ARGP_NAMESTRING:
 496 
 497         AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
 498         Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
 499         return_VOID;
 500 

 501     default:
 502 
 503         ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
 504         return_VOID;
 505     }
 506 
 507     AcpiPsInitOp (Arg, Opcode);
 508     ParserState->Aml += Length;
 509     return_VOID;
 510 }
 511 
 512 
 513 /*******************************************************************************
 514  *
 515  * FUNCTION:    AcpiPsGetNextField
 516  *
 517  * PARAMETERS:  ParserState         - Current parser state object
 518  *
 519  * RETURN:      A newly allocated FIELD op
 520  *
 521  * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField)
 522  *
 523  ******************************************************************************/
 524 
 525 static ACPI_PARSE_OBJECT *
 526 AcpiPsGetNextField (
 527     ACPI_PARSE_STATE        *ParserState)
 528 {
 529     UINT32                  AmlOffset;


 530     ACPI_PARSE_OBJECT       *Field;
 531     ACPI_PARSE_OBJECT       *Arg = NULL;
 532     UINT16                  Opcode;
 533     UINT32                  Name;
 534     UINT8                   AccessType;
 535     UINT8                   AccessAttribute;
 536     UINT8                   AccessLength;
 537     UINT32                  PkgLength;
 538     UINT8                   *PkgEnd;
 539     UINT32                  BufferLength;
 540 
 541 
 542     ACPI_FUNCTION_TRACE (PsGetNextField);
 543 
 544 
 545     AmlOffset = (UINT32) ACPI_PTR_DIFF (
 546         ParserState->Aml, ParserState->AmlStart);
 547 
 548     /* Determine field type */
 549 
 550     switch (ACPI_GET8 (ParserState->Aml))
 551     {
 552     case AML_FIELD_OFFSET_OP:
 553 
 554         Opcode = AML_INT_RESERVEDFIELD_OP;
 555         ParserState->Aml++;
 556         break;
 557 
 558     case AML_FIELD_ACCESS_OP:
 559 
 560         Opcode = AML_INT_ACCESSFIELD_OP;
 561         ParserState->Aml++;
 562         break;
 563 
 564     case AML_FIELD_CONNECTION_OP:
 565 
 566         Opcode = AML_INT_CONNECTION_OP;
 567         ParserState->Aml++;
 568         break;
 569 
 570     case AML_FIELD_EXT_ACCESS_OP:
 571 
 572         Opcode = AML_INT_EXTACCESSFIELD_OP;
 573         ParserState->Aml++;
 574         break;
 575 
 576     default:
 577 
 578         Opcode = AML_INT_NAMEDFIELD_OP;
 579         break;
 580     }
 581 
 582     /* Allocate a new field op */
 583 
 584     Field = AcpiPsAllocOp (Opcode);
 585     if (!Field)
 586     {
 587         return_PTR (NULL);
 588     }
 589 
 590     Field->Common.AmlOffset = AmlOffset;
 591 
 592     /* Decode the field type */
 593 
 594     switch (Opcode)
 595     {
 596     case AML_INT_NAMEDFIELD_OP:
 597 
 598         /* Get the 4-character name */
 599 
 600         ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml);
 601         AcpiPsSetName (Field, Name);
 602         ParserState->Aml += ACPI_NAME_SIZE;
 603 
 604         /* Get the length which is encoded as a package length */
 605 
 606         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
 607         break;
 608 
 609 
 610     case AML_INT_RESERVEDFIELD_OP:
 611 
 612         /* Get the length which is encoded as a package length */
 613 
 614         Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState);
 615         break;
 616 
 617 
 618     case AML_INT_ACCESSFIELD_OP:
 619     case AML_INT_EXTACCESSFIELD_OP:
 620 
 621         /*
 622          * Get AccessType and AccessAttrib and merge into the field Op
 623          * AccessType is first operand, AccessAttribute is second. stuff
 624          * these bytes into the node integer value for convenience.
 625          */
 626 
 627         /* Get the two bytes (Type/Attribute) */
 628 
 629         AccessType = ACPI_GET8 (ParserState->Aml);
 630         ParserState->Aml++;
 631         AccessAttribute = ACPI_GET8 (ParserState->Aml);
 632         ParserState->Aml++;
 633 
 634         Field->Common.Value.Integer = (UINT8) AccessType;
 635         Field->Common.Value.Integer |= (UINT16) (AccessAttribute << 8);
 636 
 637         /* This opcode has a third byte, AccessLength */
 638 
 639         if (Opcode == AML_INT_EXTACCESSFIELD_OP)
 640         {
 641             AccessLength = ACPI_GET8 (ParserState->Aml);
 642             ParserState->Aml++;
 643 
 644             Field->Common.Value.Integer |= (UINT32) (AccessLength << 16);
 645         }
 646         break;
 647 
 648 
 649     case AML_INT_CONNECTION_OP:
 650 
 651         /*
 652          * Argument for Connection operator can be either a Buffer
 653          * (resource descriptor), or a NameString.
 654          */
 655         if (ACPI_GET8 (ParserState->Aml) == AML_BUFFER_OP)
 656         {
 657             ParserState->Aml++;
 658 
 659             PkgEnd = ParserState->Aml;
 660             PkgLength = AcpiPsGetNextPackageLength (ParserState);
 661             PkgEnd += PkgLength;
 662 
 663             if (ParserState->Aml < PkgEnd)
 664             {
 665                 /* Non-empty list */
 666 
 667                 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
 668                 if (!Arg)
 669                 {
 670                     AcpiPsFreeOp (Field);
 671                     return_PTR (NULL);
 672                 }
 673 
 674                 /* Get the actual buffer length argument */
 675 
 676                 Opcode = ACPI_GET8 (ParserState->Aml);
 677                 ParserState->Aml++;
 678 
 679                 switch (Opcode)
 680                 {
 681                 case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
 682 
 683                     BufferLength = ACPI_GET8 (ParserState->Aml);
 684                     ParserState->Aml += 1;
 685                     break;
 686 
 687                 case AML_WORD_OP:       /* AML_WORDDATA_ARG */
 688 
 689                     BufferLength = ACPI_GET16 (ParserState->Aml);
 690                     ParserState->Aml += 2;
 691                     break;
 692 
 693                 case AML_DWORD_OP:      /* AML_DWORDATA_ARG */
 694 
 695                     BufferLength = ACPI_GET32 (ParserState->Aml);
 696                     ParserState->Aml += 4;
 697                     break;
 698 
 699                 default:
 700 
 701                     BufferLength = 0;
 702                     break;
 703                 }
 704 
 705                 /* Fill in bytelist data */
 706 
 707                 Arg->Named.Value.Size = BufferLength;
 708                 Arg->Named.Data = ParserState->Aml;
 709             }
 710 
 711             /* Skip to End of byte data */
 712 
 713             ParserState->Aml = PkgEnd;
 714         }
 715         else
 716         {
 717             Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
 718             if (!Arg)
 719             {
 720                 AcpiPsFreeOp (Field);
 721                 return_PTR (NULL);
 722             }
 723 
 724             /* Get the Namestring argument */
 725 
 726             Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
 727         }
 728 
 729         /* Link the buffer/namestring to parent (CONNECTION_OP) */
 730 
 731         AcpiPsAppendArg (Field, Arg);
 732         break;
 733 
 734 
 735     default:
 736 
 737         /* Opcode was set in previous switch */
 738         break;
 739     }
 740 
 741     return_PTR (Field);
 742 }
 743 
 744 
 745 /*******************************************************************************
 746  *
 747  * FUNCTION:    AcpiPsGetNextArg
 748  *
 749  * PARAMETERS:  WalkState           - Current state
 750  *              ParserState         - Current parser state object
 751  *              ArgType             - The argument type (AML_*_ARG)
 752  *              ReturnArg           - Where the next arg is returned
 753  *
 754  * RETURN:      Status, and an op object containing the next argument.
 755  *
 756  * DESCRIPTION: Get next argument (including complex list arguments that require


 777 
 778     switch (ArgType)
 779     {
 780     case ARGP_BYTEDATA:
 781     case ARGP_WORDDATA:
 782     case ARGP_DWORDDATA:
 783     case ARGP_CHARLIST:
 784     case ARGP_NAME:
 785     case ARGP_NAMESTRING:
 786 
 787         /* Constants, strings, and namestrings are all the same size */
 788 
 789         Arg = AcpiPsAllocOp (AML_BYTE_OP);
 790         if (!Arg)
 791         {
 792             return_ACPI_STATUS (AE_NO_MEMORY);
 793         }
 794         AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
 795         break;
 796 

 797     case ARGP_PKGLENGTH:
 798 
 799         /* Package length, nothing returned */
 800 
 801         ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
 802         break;
 803 

 804     case ARGP_FIELDLIST:
 805 
 806         if (ParserState->Aml < ParserState->PkgEnd)
 807         {
 808             /* Non-empty list */
 809 
 810             while (ParserState->Aml < ParserState->PkgEnd)
 811             {
 812                 Field = AcpiPsGetNextField (ParserState);
 813                 if (!Field)
 814                 {
 815                     return_ACPI_STATUS (AE_NO_MEMORY);
 816                 }
 817 
 818                 if (Prev)
 819                 {
 820                     Prev->Common.Next = Field;
 821                 }
 822                 else
 823                 {
 824                     Arg = Field;
 825                 }
 826                 Prev = Field;
 827             }
 828 
 829             /* Skip to End of byte data */
 830 
 831             ParserState->Aml = ParserState->PkgEnd;
 832         }
 833         break;
 834 

 835     case ARGP_BYTELIST:
 836 
 837         if (ParserState->Aml < ParserState->PkgEnd)
 838         {
 839             /* Non-empty list */
 840 
 841             Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP);
 842             if (!Arg)
 843             {
 844                 return_ACPI_STATUS (AE_NO_MEMORY);
 845             }
 846 
 847             /* Fill in bytelist data */
 848 
 849             Arg->Common.Value.Size = (UINT32)
 850                 ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
 851             Arg->Named.Data = ParserState->Aml;
 852 
 853             /* Skip to End of byte data */
 854 
 855             ParserState->Aml = ParserState->PkgEnd;
 856         }
 857         break;
 858 

 859     case ARGP_TARGET:
 860     case ARGP_SUPERNAME:
 861     case ARGP_SIMPLENAME:
 862 
 863         Subop = AcpiPsPeekOpcode (ParserState);
 864         if (Subop == 0                  ||
 865             AcpiPsIsLeadingChar (Subop) ||
 866             ACPI_IS_ROOT_PREFIX (Subop) ||
 867             ACPI_IS_PARENT_PREFIX (Subop))
 868         {
 869             /* NullName or NameString */
 870 
 871             Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP);
 872             if (!Arg)
 873             {
 874                 return_ACPI_STATUS (AE_NO_MEMORY);
 875             }
 876 
 877             /* To support SuperName arg of Unload */
 878 
 879             if (WalkState->Opcode == AML_UNLOAD_OP)
 880             {
 881                 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
 882 
 883                 /*
 884                  * If the SuperName arg of Unload is a method call,
 885                  * we have restored the AML pointer, just free this Arg
 886                  */
 887                 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
 888                 {
 889                     AcpiPsFreeOp (Arg);
 890                     Arg = NULL;
 891                 }
 892             }
 893             else
 894             {
 895                 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
 896             }
 897         }
 898         else
 899         {
 900             /* Single complex argument, nothing returned */
 901 
 902             WalkState->ArgCount = 1;
 903         }
 904         break;
 905 

 906     case ARGP_DATAOBJ:
 907     case ARGP_TERMARG:
 908 
 909         /* Single complex argument, nothing returned */
 910 
 911         WalkState->ArgCount = 1;
 912         break;
 913 

 914     case ARGP_DATAOBJLIST:
 915     case ARGP_TERMLIST:
 916     case ARGP_OBJLIST:
 917 
 918         if (ParserState->Aml < ParserState->PkgEnd)
 919         {
 920             /* Non-empty list of variable arguments, nothing returned */
 921 
 922             WalkState->ArgCount = ACPI_VAR_ARGS;
 923         }
 924         break;
 925 

 926     default:
 927 
 928         ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
 929         Status = AE_AML_OPERAND_TYPE;
 930         break;
 931     }
 932 
 933     *ReturnArg = Arg;
 934     return_ACPI_STATUS (Status);
 935 }