psargs.c revision 114237
1/****************************************************************************** 2 * 3 * Module Name: psargs - Parse AML opcode arguments 4 * $Revision: 69 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __PSARGS_C__ 118 119#include "acpi.h" 120#include "acparser.h" 121#include "amlcode.h" 122#include "acnamesp.h" 123 124#define _COMPONENT ACPI_PARSER 125 ACPI_MODULE_NAME ("psargs") 126 127 128/******************************************************************************* 129 * 130 * FUNCTION: AcpiPsGetNextPackageLength 131 * 132 * PARAMETERS: ParserState - Current parser state object 133 * 134 * RETURN: Decoded package length. On completion, the AML pointer points 135 * past the length byte or bytes. 136 * 137 * DESCRIPTION: Decode and return a package length field 138 * 139 ******************************************************************************/ 140 141UINT32 142AcpiPsGetNextPackageLength ( 143 ACPI_PARSE_STATE *ParserState) 144{ 145 UINT32 EncodedLength; 146 UINT32 Length = 0; 147 148 149 ACPI_FUNCTION_TRACE ("PsGetNextPackageLength"); 150 151 152 EncodedLength = (UINT32) ACPI_GET8 (ParserState->Aml); 153 ParserState->Aml++; 154 155 156 switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ 157 { 158 case 0: /* 1-byte encoding (bits 0-5) */ 159 160 Length = (EncodedLength & 0x3F); 161 break; 162 163 164 case 1: /* 2-byte encoding (next byte + bits 0-3) */ 165 166 Length = ((ACPI_GET8 (ParserState->Aml) << 04) | 167 (EncodedLength & 0x0F)); 168 ParserState->Aml++; 169 break; 170 171 172 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ 173 174 Length = ((ACPI_GET8 (ParserState->Aml + 1) << 12) | 175 (ACPI_GET8 (ParserState->Aml) << 04) | 176 (EncodedLength & 0x0F)); 177 ParserState->Aml += 2; 178 break; 179 180 181 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ 182 183 Length = ((ACPI_GET8 (ParserState->Aml + 2) << 20) | 184 (ACPI_GET8 (ParserState->Aml + 1) << 12) | 185 (ACPI_GET8 (ParserState->Aml) << 04) | 186 (EncodedLength & 0x0F)); 187 ParserState->Aml += 3; 188 break; 189 190 default: 191 192 /* Can't get here, only 2 bits / 4 cases */ 193 break; 194 } 195 196 return_VALUE (Length); 197} 198 199 200/******************************************************************************* 201 * 202 * FUNCTION: AcpiPsGetNextPackageEnd 203 * 204 * PARAMETERS: ParserState - Current parser state object 205 * 206 * RETURN: Pointer to end-of-package +1 207 * 208 * DESCRIPTION: Get next package length and return a pointer past the end of 209 * the package. Consumes the package length field 210 * 211 ******************************************************************************/ 212 213UINT8 * 214AcpiPsGetNextPackageEnd ( 215 ACPI_PARSE_STATE *ParserState) 216{ 217 UINT8 *Start = ParserState->Aml; 218 ACPI_NATIVE_UINT Length; 219 220 221 ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd"); 222 223 224 /* Function below changes ParserState->Aml */ 225 226 Length = (ACPI_NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState); 227 228 return_PTR (Start + Length); /* end of package */ 229} 230 231 232/******************************************************************************* 233 * 234 * FUNCTION: AcpiPsGetNextNamestring 235 * 236 * PARAMETERS: ParserState - Current parser state object 237 * 238 * RETURN: Pointer to the start of the name string (pointer points into 239 * the AML. 240 * 241 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name 242 * prefix characters. Set parser state to point past the string. 243 * (Name is consumed from the AML.) 244 * 245 ******************************************************************************/ 246 247char * 248AcpiPsGetNextNamestring ( 249 ACPI_PARSE_STATE *ParserState) 250{ 251 UINT8 *Start = ParserState->Aml; 252 UINT8 *End = ParserState->Aml; 253 254 255 ACPI_FUNCTION_TRACE ("PsGetNextNamestring"); 256 257 258 /* Handle multiple prefix characters */ 259 260 while (AcpiPsIsPrefixChar (ACPI_GET8 (End))) 261 { 262 /* Include prefix '\\' or '^' */ 263 264 End++; 265 } 266 267 /* Decode the path */ 268 269 switch (ACPI_GET8 (End)) 270 { 271 case 0: 272 273 /* NullName */ 274 275 if (End == Start) 276 { 277 Start = NULL; 278 } 279 End++; 280 break; 281 282 case AML_DUAL_NAME_PREFIX: 283 284 /* Two name segments */ 285 286 End += 1 + (2 * ACPI_NAME_SIZE); 287 break; 288 289 case AML_MULTI_NAME_PREFIX_OP: 290 291 /* Multiple name segments, 4 chars each */ 292 293 End += 2 + ((ACPI_SIZE) ACPI_GET8 (End + 1) * ACPI_NAME_SIZE); 294 break; 295 296 default: 297 298 /* Single name segment */ 299 300 End += ACPI_NAME_SIZE; 301 break; 302 } 303 304 ParserState->Aml = (UINT8*) End; 305 return_PTR ((char *) Start); 306} 307 308 309/******************************************************************************* 310 * 311 * FUNCTION: AcpiPsGetNextNamepath 312 * 313 * PARAMETERS: ParserState - Current parser state object 314 * Arg - Where the namepath will be stored 315 * ArgCount - If the namepath points to a control method 316 * the method's argument is returned here. 317 * MethodCall - Whether the namepath can possibly be the 318 * start of a method call 319 * 320 * RETURN: Status 321 * 322 * DESCRIPTION: Get next name (if method call, return # of required args). 323 * Names are looked up in the internal namespace to determine 324 * if the name represents a control method. If a method 325 * is found, the number of arguments to the method is returned. 326 * This information is critical for parsing to continue correctly. 327 * 328 ******************************************************************************/ 329 330ACPI_STATUS 331AcpiPsGetNextNamepath ( 332 ACPI_WALK_STATE *WalkState, 333 ACPI_PARSE_STATE *ParserState, 334 ACPI_PARSE_OBJECT *Arg, 335 BOOLEAN MethodCall) 336{ 337 char *Path; 338 ACPI_PARSE_OBJECT *NameOp; 339 ACPI_STATUS Status = AE_OK; 340 ACPI_OPERAND_OBJECT *MethodDesc; 341 ACPI_NAMESPACE_NODE *Node; 342 ACPI_GENERIC_STATE ScopeInfo; 343 344 345 ACPI_FUNCTION_TRACE ("PsGetNextNamepath"); 346 347 348 Path = AcpiPsGetNextNamestring (ParserState); 349 350 /* Null path case is allowed */ 351 352 if (Path) 353 { 354 /* 355 * Lookup the name in the internal namespace 356 */ 357 ScopeInfo.Scope.Node = NULL; 358 Node = ParserState->StartNode; 359 if (Node) 360 { 361 ScopeInfo.Scope.Node = Node; 362 } 363 364 /* 365 * Lookup object. We don't want to add anything new to the namespace 366 * here, however. So we use MODE_EXECUTE. Allow searching of the 367 * parent tree, but don't open a new scope -- we just want to lookup the 368 * object (MUST BE mode EXECUTE to perform upsearch) 369 */ 370 Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 371 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); 372 if (ACPI_SUCCESS (Status) && MethodCall) 373 { 374 if (Node->Type == ACPI_TYPE_METHOD) 375 { 376 /* 377 * This name is actually a control method invocation 378 */ 379 MethodDesc = AcpiNsGetAttachedObject (Node); 380 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 381 "Control Method - %p Desc %p Path=%p\n", 382 Node, MethodDesc, Path)); 383 384 NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); 385 if (!NameOp) 386 { 387 return_ACPI_STATUS (AE_NO_MEMORY); 388 } 389 390 /* Change arg into a METHOD CALL and attach name to it */ 391 392 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); 393 NameOp->Common.Value.Name = Path; 394 395 /* Point METHODCALL/NAME to the METHOD Node */ 396 397 NameOp->Common.Node = Node; 398 AcpiPsAppendArg (Arg, NameOp); 399 400 if (!MethodDesc) 401 { 402 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 403 "Control Method - %p has no attached object\n", 404 Node)); 405 return_ACPI_STATUS (AE_AML_INTERNAL); 406 } 407 408 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 409 "Control Method - %p Args %X\n", 410 Node, MethodDesc->Method.ParamCount)); 411 412 /* Get the number of arguments to expect */ 413 414 WalkState->ArgCount = MethodDesc->Method.ParamCount; 415 return_ACPI_STATUS (AE_OK); 416 } 417 418 /* 419 * Else this is normal named object reference. 420 * Just init the NAMEPATH object with the pathname. 421 * (See code below) 422 */ 423 } 424 425 if (ACPI_FAILURE (Status)) 426 { 427 /* 428 * 1) Any error other than NOT_FOUND is always severe 429 * 2) NOT_FOUND is only important if we are executing a method. 430 * 3) If executing a CondRefOf opcode, NOT_FOUND is ok. 431 */ 432 if ((((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) && 433 (Status == AE_NOT_FOUND) && 434 (WalkState->Op->Common.AmlOpcode != AML_COND_REF_OF_OP)) || 435 436 (Status != AE_NOT_FOUND)) 437 { 438 ACPI_REPORT_NSERROR (Path, Status); 439 } 440 else 441 { 442 /* 443 * We got a NOT_FOUND during table load or we encountered 444 * a CondRefOf(x) where the target does not exist. 445 * -- either case is ok 446 */ 447 Status = AE_OK; 448 } 449 } 450 } 451 452 /* 453 * Regardless of success/failure above, 454 * Just initialize the Op with the pathname. 455 */ 456 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 457 Arg->Common.Value.Name = Path; 458 459 return_ACPI_STATUS (Status); 460} 461 462 463/******************************************************************************* 464 * 465 * FUNCTION: AcpiPsGetNextSimpleArg 466 * 467 * PARAMETERS: ParserState - Current parser state object 468 * ArgType - The argument type (AML_*_ARG) 469 * Arg - Where the argument is returned 470 * 471 * RETURN: None 472 * 473 * DESCRIPTION: Get the next simple argument (constant, string, or namestring) 474 * 475 ******************************************************************************/ 476 477void 478AcpiPsGetNextSimpleArg ( 479 ACPI_PARSE_STATE *ParserState, 480 UINT32 ArgType, 481 ACPI_PARSE_OBJECT *Arg) 482{ 483 484 ACPI_FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); 485 486 487 switch (ArgType) 488 { 489 case ARGP_BYTEDATA: 490 491 AcpiPsInitOp (Arg, AML_BYTE_OP); 492 Arg->Common.Value.Integer = (UINT32) ACPI_GET8 (ParserState->Aml); 493 ParserState->Aml++; 494 break; 495 496 497 case ARGP_WORDDATA: 498 499 AcpiPsInitOp (Arg, AML_WORD_OP); 500 501 /* Get 2 bytes from the AML stream */ 502 503 ACPI_MOVE_UNALIGNED16_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); 504 ParserState->Aml += 2; 505 break; 506 507 508 case ARGP_DWORDDATA: 509 510 AcpiPsInitOp (Arg, AML_DWORD_OP); 511 512 /* Get 4 bytes from the AML stream */ 513 514 ACPI_MOVE_UNALIGNED32_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); 515 ParserState->Aml += 4; 516 break; 517 518 519 case ARGP_QWORDDATA: 520 521 AcpiPsInitOp (Arg, AML_QWORD_OP); 522 523 /* Get 8 bytes from the AML stream */ 524 525 ACPI_MOVE_UNALIGNED64_TO_64 (&Arg->Common.Value.Integer, ParserState->Aml); 526 ParserState->Aml += 8; 527 break; 528 529 530 case ARGP_CHARLIST: 531 532 AcpiPsInitOp (Arg, AML_STRING_OP); 533 Arg->Common.Value.String = (char *) ParserState->Aml; 534 535 while (ACPI_GET8 (ParserState->Aml) != '\0') 536 { 537 ParserState->Aml++; 538 } 539 ParserState->Aml++; 540 break; 541 542 543 case ARGP_NAME: 544 case ARGP_NAMESTRING: 545 546 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 547 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); 548 break; 549 550 551 default: 552 553 ACPI_REPORT_ERROR (("Invalid ArgType %X\n", ArgType)); 554 break; 555 } 556 557 return_VOID; 558} 559 560 561/******************************************************************************* 562 * 563 * FUNCTION: AcpiPsGetNextField 564 * 565 * PARAMETERS: ParserState - Current parser state object 566 * 567 * RETURN: A newly allocated FIELD op 568 * 569 * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) 570 * 571 ******************************************************************************/ 572 573ACPI_PARSE_OBJECT * 574AcpiPsGetNextField ( 575 ACPI_PARSE_STATE *ParserState) 576{ 577 UINT32 AmlOffset = ACPI_PTR_DIFF (ParserState->Aml, 578 ParserState->AmlStart); 579 ACPI_PARSE_OBJECT *Field; 580 UINT16 Opcode; 581 UINT32 Name; 582 583 584 ACPI_FUNCTION_TRACE ("PsGetNextField"); 585 586 587 /* determine field type */ 588 589 switch (ACPI_GET8 (ParserState->Aml)) 590 { 591 default: 592 593 Opcode = AML_INT_NAMEDFIELD_OP; 594 break; 595 596 case 0x00: 597 598 Opcode = AML_INT_RESERVEDFIELD_OP; 599 ParserState->Aml++; 600 break; 601 602 case 0x01: 603 604 Opcode = AML_INT_ACCESSFIELD_OP; 605 ParserState->Aml++; 606 break; 607 } 608 609 610 /* Allocate a new field op */ 611 612 Field = AcpiPsAllocOp (Opcode); 613 if (!Field) 614 { 615 return_PTR (NULL); 616 } 617 618 Field->Common.AmlOffset = AmlOffset; 619 620 /* Decode the field type */ 621 622 switch (Opcode) 623 { 624 case AML_INT_NAMEDFIELD_OP: 625 626 /* Get the 4-character name */ 627 628 ACPI_MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml); 629 AcpiPsSetName (Field, Name); 630 ParserState->Aml += ACPI_NAME_SIZE; 631 632 /* Get the length which is encoded as a package length */ 633 634 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 635 break; 636 637 638 case AML_INT_RESERVEDFIELD_OP: 639 640 /* Get the length which is encoded as a package length */ 641 642 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 643 break; 644 645 646 case AML_INT_ACCESSFIELD_OP: 647 648 /* 649 * Get AccessType and AccessAttrib and merge into the field Op 650 * AccessType is first operand, AccessAttribute is second 651 */ 652 Field->Common.Value.Integer32 = (ACPI_GET8 (ParserState->Aml) << 8); 653 ParserState->Aml++; 654 Field->Common.Value.Integer32 |= ACPI_GET8 (ParserState->Aml); 655 ParserState->Aml++; 656 break; 657 658 default: 659 660 /* Opcode was set in previous switch */ 661 break; 662 } 663 664 return_PTR (Field); 665} 666 667 668/******************************************************************************* 669 * 670 * FUNCTION: AcpiPsGetNextArg 671 * 672 * PARAMETERS: ParserState - Current parser state object 673 * ArgType - The argument type (AML_*_ARG) 674 * ArgCount - If the argument points to a control method 675 * the method's argument is returned here. 676 * 677 * RETURN: Status, and an op object containing the next argument. 678 * 679 * DESCRIPTION: Get next argument (including complex list arguments that require 680 * pushing the parser stack) 681 * 682 ******************************************************************************/ 683 684ACPI_STATUS 685AcpiPsGetNextArg ( 686 ACPI_WALK_STATE *WalkState, 687 ACPI_PARSE_STATE *ParserState, 688 UINT32 ArgType, 689 ACPI_PARSE_OBJECT **ReturnArg) 690{ 691 ACPI_PARSE_OBJECT *Arg = NULL; 692 ACPI_PARSE_OBJECT *Prev = NULL; 693 ACPI_PARSE_OBJECT *Field; 694 UINT32 Subop; 695 ACPI_STATUS Status = AE_OK; 696 697 698 ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); 699 700 701 switch (ArgType) 702 { 703 case ARGP_BYTEDATA: 704 case ARGP_WORDDATA: 705 case ARGP_DWORDDATA: 706 case ARGP_CHARLIST: 707 case ARGP_NAME: 708 case ARGP_NAMESTRING: 709 710 /* constants, strings, and namestrings are all the same size */ 711 712 Arg = AcpiPsAllocOp (AML_BYTE_OP); 713 if (!Arg) 714 { 715 return_ACPI_STATUS (AE_NO_MEMORY); 716 } 717 AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); 718 break; 719 720 721 case ARGP_PKGLENGTH: 722 723 /* Package length, nothing returned */ 724 725 ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); 726 break; 727 728 729 case ARGP_FIELDLIST: 730 731 if (ParserState->Aml < ParserState->PkgEnd) 732 { 733 /* Non-empty list */ 734 735 while (ParserState->Aml < ParserState->PkgEnd) 736 { 737 Field = AcpiPsGetNextField (ParserState); 738 if (!Field) 739 { 740 return_ACPI_STATUS (AE_NO_MEMORY); 741 } 742 743 if (Prev) 744 { 745 Prev->Common.Next = Field; 746 } 747 else 748 { 749 Arg = Field; 750 } 751 752 Prev = Field; 753 } 754 755 /* Skip to End of byte data */ 756 757 ParserState->Aml = ParserState->PkgEnd; 758 } 759 break; 760 761 762 case ARGP_BYTELIST: 763 764 if (ParserState->Aml < ParserState->PkgEnd) 765 { 766 /* Non-empty list */ 767 768 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); 769 if (!Arg) 770 { 771 return_ACPI_STATUS (AE_NO_MEMORY); 772 } 773 774 /* Fill in bytelist data */ 775 776 Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd, 777 ParserState->Aml); 778 Arg->Named.Data = ParserState->Aml; 779 780 /* Skip to End of byte data */ 781 782 ParserState->Aml = ParserState->PkgEnd; 783 } 784 break; 785 786 787 case ARGP_TARGET: 788 case ARGP_SUPERNAME: 789 case ARGP_SIMPLENAME: 790 791 Subop = AcpiPsPeekOpcode (ParserState); 792 if (Subop == 0 || 793 AcpiPsIsLeadingChar (Subop) || 794 AcpiPsIsPrefixChar (Subop)) 795 { 796 /* NullName or NameString */ 797 798 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); 799 if (!Arg) 800 { 801 return_ACPI_STATUS (AE_NO_MEMORY); 802 } 803 804 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); 805 } 806 else 807 { 808 /* single complex argument, nothing returned */ 809 810 WalkState->ArgCount = 1; 811 } 812 break; 813 814 815 case ARGP_DATAOBJ: 816 case ARGP_TERMARG: 817 818 /* single complex argument, nothing returned */ 819 820 WalkState->ArgCount = 1; 821 break; 822 823 824 case ARGP_DATAOBJLIST: 825 case ARGP_TERMLIST: 826 case ARGP_OBJLIST: 827 828 if (ParserState->Aml < ParserState->PkgEnd) 829 { 830 /* non-empty list of variable arguments, nothing returned */ 831 832 WalkState->ArgCount = ACPI_VAR_ARGS; 833 } 834 break; 835 836 837 default: 838 839 ACPI_REPORT_ERROR (("Invalid ArgType: %X\n", ArgType)); 840 Status = AE_AML_OPERAND_TYPE; 841 break; 842 } 843 844 *ReturnArg = Arg; 845 return_ACPI_STATUS (Status); 846} 847