psargs.c revision 126372
1/****************************************************************************** 2 * 3 * Module Name: psargs - Parse AML opcode arguments 4 * $Revision: 76 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2004, 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_REPORT_ERROR (( 403 "PsGetNextNamepath: 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 AcpiOsPrintf ("SearchNode %p StartNode %p ReturnNode %p\n", 441 ScopeInfo.Scope.Node, ParserState->StartNode, Node); 442 443 444 } 445 else 446 { 447 /* 448 * We got a NOT_FOUND during table load or we encountered 449 * a CondRefOf(x) where the target does not exist. 450 * -- either case is ok 451 */ 452 Status = AE_OK; 453 } 454 } 455 } 456 457 /* 458 * Regardless of success/failure above, 459 * Just initialize the Op with the pathname. 460 */ 461 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 462 Arg->Common.Value.Name = Path; 463 464 return_ACPI_STATUS (Status); 465} 466 467 468/******************************************************************************* 469 * 470 * FUNCTION: AcpiPsGetNextSimpleArg 471 * 472 * PARAMETERS: ParserState - Current parser state object 473 * ArgType - The argument type (AML_*_ARG) 474 * Arg - Where the argument is returned 475 * 476 * RETURN: None 477 * 478 * DESCRIPTION: Get the next simple argument (constant, string, or namestring) 479 * 480 ******************************************************************************/ 481 482void 483AcpiPsGetNextSimpleArg ( 484 ACPI_PARSE_STATE *ParserState, 485 UINT32 ArgType, 486 ACPI_PARSE_OBJECT *Arg) 487{ 488 489 ACPI_FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); 490 491 492 switch (ArgType) 493 { 494 case ARGP_BYTEDATA: 495 496 AcpiPsInitOp (Arg, AML_BYTE_OP); 497 Arg->Common.Value.Integer = (UINT32) ACPI_GET8 (ParserState->Aml); 498 ParserState->Aml++; 499 break; 500 501 502 case ARGP_WORDDATA: 503 504 AcpiPsInitOp (Arg, AML_WORD_OP); 505 506 /* Get 2 bytes from the AML stream */ 507 508 ACPI_MOVE_16_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); 509 ParserState->Aml += 2; 510 break; 511 512 513 case ARGP_DWORDDATA: 514 515 AcpiPsInitOp (Arg, AML_DWORD_OP); 516 517 /* Get 4 bytes from the AML stream */ 518 519 ACPI_MOVE_32_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); 520 ParserState->Aml += 4; 521 break; 522 523 524 case ARGP_QWORDDATA: 525 526 AcpiPsInitOp (Arg, AML_QWORD_OP); 527 528 /* Get 8 bytes from the AML stream */ 529 530 ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, ParserState->Aml); 531 ParserState->Aml += 8; 532 break; 533 534 535 case ARGP_CHARLIST: 536 537 AcpiPsInitOp (Arg, AML_STRING_OP); 538 Arg->Common.Value.String = (char *) ParserState->Aml; 539 540 while (ACPI_GET8 (ParserState->Aml) != '\0') 541 { 542 ParserState->Aml++; 543 } 544 ParserState->Aml++; 545 break; 546 547 548 case ARGP_NAME: 549 case ARGP_NAMESTRING: 550 551 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 552 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); 553 break; 554 555 556 default: 557 558 ACPI_REPORT_ERROR (("Invalid ArgType %X\n", ArgType)); 559 break; 560 } 561 562 return_VOID; 563} 564 565 566/******************************************************************************* 567 * 568 * FUNCTION: AcpiPsGetNextField 569 * 570 * PARAMETERS: ParserState - Current parser state object 571 * 572 * RETURN: A newly allocated FIELD op 573 * 574 * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) 575 * 576 ******************************************************************************/ 577 578ACPI_PARSE_OBJECT * 579AcpiPsGetNextField ( 580 ACPI_PARSE_STATE *ParserState) 581{ 582 UINT32 AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, 583 ParserState->AmlStart); 584 ACPI_PARSE_OBJECT *Field; 585 UINT16 Opcode; 586 UINT32 Name; 587 588 589 ACPI_FUNCTION_TRACE ("PsGetNextField"); 590 591 592 /* determine field type */ 593 594 switch (ACPI_GET8 (ParserState->Aml)) 595 { 596 default: 597 598 Opcode = AML_INT_NAMEDFIELD_OP; 599 break; 600 601 case 0x00: 602 603 Opcode = AML_INT_RESERVEDFIELD_OP; 604 ParserState->Aml++; 605 break; 606 607 case 0x01: 608 609 Opcode = AML_INT_ACCESSFIELD_OP; 610 ParserState->Aml++; 611 break; 612 } 613 614 615 /* Allocate a new field op */ 616 617 Field = AcpiPsAllocOp (Opcode); 618 if (!Field) 619 { 620 return_PTR (NULL); 621 } 622 623 Field->Common.AmlOffset = AmlOffset; 624 625 /* Decode the field type */ 626 627 switch (Opcode) 628 { 629 case AML_INT_NAMEDFIELD_OP: 630 631 /* Get the 4-character name */ 632 633 ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); 634 AcpiPsSetName (Field, Name); 635 ParserState->Aml += ACPI_NAME_SIZE; 636 637 /* Get the length which is encoded as a package length */ 638 639 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 640 break; 641 642 643 case AML_INT_RESERVEDFIELD_OP: 644 645 /* Get the length which is encoded as a package length */ 646 647 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 648 break; 649 650 651 case AML_INT_ACCESSFIELD_OP: 652 653 /* 654 * Get AccessType and AccessAttrib and merge into the field Op 655 * AccessType is first operand, AccessAttribute is second 656 */ 657 Field->Common.Value.Integer = (ACPI_GET8 (ParserState->Aml) << 8); 658 ParserState->Aml++; 659 Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); 660 ParserState->Aml++; 661 break; 662 663 default: 664 665 /* Opcode was set in previous switch */ 666 break; 667 } 668 669 return_PTR (Field); 670} 671 672 673/******************************************************************************* 674 * 675 * FUNCTION: AcpiPsGetNextArg 676 * 677 * PARAMETERS: ParserState - Current parser state object 678 * ArgType - The argument type (AML_*_ARG) 679 * ArgCount - If the argument points to a control method 680 * the method's argument is returned here. 681 * 682 * RETURN: Status, and an op object containing the next argument. 683 * 684 * DESCRIPTION: Get next argument (including complex list arguments that require 685 * pushing the parser stack) 686 * 687 ******************************************************************************/ 688 689ACPI_STATUS 690AcpiPsGetNextArg ( 691 ACPI_WALK_STATE *WalkState, 692 ACPI_PARSE_STATE *ParserState, 693 UINT32 ArgType, 694 ACPI_PARSE_OBJECT **ReturnArg) 695{ 696 ACPI_PARSE_OBJECT *Arg = NULL; 697 ACPI_PARSE_OBJECT *Prev = NULL; 698 ACPI_PARSE_OBJECT *Field; 699 UINT32 Subop; 700 ACPI_STATUS Status = AE_OK; 701 702 703 ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); 704 705 706 switch (ArgType) 707 { 708 case ARGP_BYTEDATA: 709 case ARGP_WORDDATA: 710 case ARGP_DWORDDATA: 711 case ARGP_CHARLIST: 712 case ARGP_NAME: 713 case ARGP_NAMESTRING: 714 715 /* constants, strings, and namestrings are all the same size */ 716 717 Arg = AcpiPsAllocOp (AML_BYTE_OP); 718 if (!Arg) 719 { 720 return_ACPI_STATUS (AE_NO_MEMORY); 721 } 722 AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); 723 break; 724 725 726 case ARGP_PKGLENGTH: 727 728 /* Package length, nothing returned */ 729 730 ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); 731 break; 732 733 734 case ARGP_FIELDLIST: 735 736 if (ParserState->Aml < ParserState->PkgEnd) 737 { 738 /* Non-empty list */ 739 740 while (ParserState->Aml < ParserState->PkgEnd) 741 { 742 Field = AcpiPsGetNextField (ParserState); 743 if (!Field) 744 { 745 return_ACPI_STATUS (AE_NO_MEMORY); 746 } 747 748 if (Prev) 749 { 750 Prev->Common.Next = Field; 751 } 752 else 753 { 754 Arg = Field; 755 } 756 757 Prev = Field; 758 } 759 760 /* Skip to End of byte data */ 761 762 ParserState->Aml = ParserState->PkgEnd; 763 } 764 break; 765 766 767 case ARGP_BYTELIST: 768 769 if (ParserState->Aml < ParserState->PkgEnd) 770 { 771 /* Non-empty list */ 772 773 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); 774 if (!Arg) 775 { 776 return_ACPI_STATUS (AE_NO_MEMORY); 777 } 778 779 /* Fill in bytelist data */ 780 781 Arg->Common.Value.Size = (UINT32) ACPI_PTR_DIFF (ParserState->PkgEnd, 782 ParserState->Aml); 783 Arg->Named.Data = ParserState->Aml; 784 785 /* Skip to End of byte data */ 786 787 ParserState->Aml = ParserState->PkgEnd; 788 } 789 break; 790 791 792 case ARGP_TARGET: 793 case ARGP_SUPERNAME: 794 case ARGP_SIMPLENAME: 795 796 Subop = AcpiPsPeekOpcode (ParserState); 797 if (Subop == 0 || 798 AcpiPsIsLeadingChar (Subop) || 799 AcpiPsIsPrefixChar (Subop)) 800 { 801 /* NullName or NameString */ 802 803 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); 804 if (!Arg) 805 { 806 return_ACPI_STATUS (AE_NO_MEMORY); 807 } 808 809 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); 810 } 811 else 812 { 813 /* single complex argument, nothing returned */ 814 815 WalkState->ArgCount = 1; 816 } 817 break; 818 819 820 case ARGP_DATAOBJ: 821 case ARGP_TERMARG: 822 823 /* single complex argument, nothing returned */ 824 825 WalkState->ArgCount = 1; 826 break; 827 828 829 case ARGP_DATAOBJLIST: 830 case ARGP_TERMLIST: 831 case ARGP_OBJLIST: 832 833 if (ParserState->Aml < ParserState->PkgEnd) 834 { 835 /* non-empty list of variable arguments, nothing returned */ 836 837 WalkState->ArgCount = ACPI_VAR_ARGS; 838 } 839 break; 840 841 842 default: 843 844 ACPI_REPORT_ERROR (("Invalid ArgType: %X\n", ArgType)); 845 Status = AE_AML_OPERAND_TYPE; 846 break; 847 } 848 849 *ReturnArg = Arg; 850 return_ACPI_STATUS (Status); 851} 852