Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpsargs.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: psargs - Parse AML opcode arguments 00004 * 00005 *****************************************************************************/ 00006 00007 /****************************************************************************** 00008 * 00009 * 1. Copyright Notice 00010 * 00011 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00012 * All rights reserved. 00013 * 00014 * 2. License 00015 * 00016 * 2.1. This is your license from Intel Corp. under its intellectual property 00017 * rights. You may have additional license terms from the party that provided 00018 * you this software, covering your right to use that party's intellectual 00019 * property rights. 00020 * 00021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00022 * copy of the source code appearing in this file ("Covered Code") an 00023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00024 * base code distributed originally by Intel ("Original Intel Code") to copy, 00025 * make derivatives, distribute, use and display any portion of the Covered 00026 * Code in any form, with the right to sublicense such rights; and 00027 * 00028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00029 * license (with the right to sublicense), under only those claims of Intel 00030 * patents that are infringed by the Original Intel Code, to make, use, sell, 00031 * offer to sell, and import the Covered Code and derivative works thereof 00032 * solely to the minimum extent necessary to exercise the above copyright 00033 * license, and in no event shall the patent license extend to any additions 00034 * to or modifications of the Original Intel Code. No other license or right 00035 * is granted directly or by implication, estoppel or otherwise; 00036 * 00037 * The above copyright and patent license is granted only if the following 00038 * conditions are met: 00039 * 00040 * 3. Conditions 00041 * 00042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00043 * Redistribution of source code of any substantial portion of the Covered 00044 * Code or modification with rights to further distribute source must include 00045 * the above Copyright Notice, the above License, this list of Conditions, 00046 * and the following Disclaimer and Export Compliance provision. In addition, 00047 * Licensee must cause all Covered Code to which Licensee contributes to 00048 * contain a file documenting the changes Licensee made to create that Covered 00049 * Code and the date of any change. Licensee must include in that file the 00050 * documentation of any changes made by any predecessor Licensee. Licensee 00051 * must include a prominent statement that the modification is derived, 00052 * directly or indirectly, from Original Intel Code. 00053 * 00054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00055 * Redistribution of source code of any substantial portion of the Covered 00056 * Code or modification without rights to further distribute source must 00057 * include the following Disclaimer and Export Compliance provision in the 00058 * documentation and/or other materials provided with distribution. In 00059 * addition, Licensee may not authorize further sublicense of source of any 00060 * portion of the Covered Code, and must include terms to the effect that the 00061 * license from Licensee to its licensee is limited to the intellectual 00062 * property embodied in the software Licensee provides to its licensee, and 00063 * not to intellectual property embodied in modifications its licensee may 00064 * make. 00065 * 00066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00067 * substantial portion of the Covered Code or modification must reproduce the 00068 * above Copyright Notice, and the following Disclaimer and Export Compliance 00069 * provision in the documentation and/or other materials provided with the 00070 * distribution. 00071 * 00072 * 3.4. Intel retains all right, title, and interest in and to the Original 00073 * Intel Code. 00074 * 00075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00076 * Intel shall be used in advertising or otherwise to promote the sale, use or 00077 * other dealings in products derived from or relating to the Covered Code 00078 * without prior written authorization from Intel. 00079 * 00080 * 4. Disclaimer and Export Compliance 00081 * 00082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00088 * PARTICULAR PURPOSE. 00089 * 00090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00097 * LIMITED REMEDY. 00098 * 00099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00100 * software or system incorporating such software without first obtaining any 00101 * required license or other approval from the U. S. Department of Commerce or 00102 * any other agency or department of the United States Government. In the 00103 * event Licensee exports any such software from the United States or 00104 * re-exports any such software from a foreign destination, Licensee shall 00105 * ensure that the distribution and export/re-export of the software is in 00106 * compliance with all laws, regulations, orders, or other restrictions of the 00107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00108 * any of its subsidiaries will export/re-export any technical data, process, 00109 * software, or service, directly or indirectly, to any country for which the 00110 * United States government or any agency thereof requires an export license, 00111 * other governmental approval, or letter of assurance, without first obtaining 00112 * such license, approval or letter. 00113 * 00114 *****************************************************************************/ 00115 00116 #define __PSARGS_C__ 00117 00118 #include "acpi.h" 00119 #include "accommon.h" 00120 #include "acparser.h" 00121 #include "amlcode.h" 00122 #include "acnamesp.h" 00123 #include "acdispat.h" 00124 00125 #define _COMPONENT ACPI_PARSER 00126 ACPI_MODULE_NAME ("psargs") 00127 00128 /* Local prototypes */ 00129 00130 static UINT32 00131 AcpiPsGetNextPackageLength ( 00132 ACPI_PARSE_STATE *ParserState); 00133 00134 static ACPI_PARSE_OBJECT * 00135 AcpiPsGetNextField ( 00136 ACPI_PARSE_STATE *ParserState); 00137 00138 00139 /******************************************************************************* 00140 * 00141 * FUNCTION: AcpiPsGetNextPackageLength 00142 * 00143 * PARAMETERS: ParserState - Current parser state object 00144 * 00145 * RETURN: Decoded package length. On completion, the AML pointer points 00146 * past the length byte or bytes. 00147 * 00148 * DESCRIPTION: Decode and return a package length field. 00149 * Note: Largest package length is 28 bits, from ACPI specification 00150 * 00151 ******************************************************************************/ 00152 00153 static UINT32 00154 AcpiPsGetNextPackageLength ( 00155 ACPI_PARSE_STATE *ParserState) 00156 { 00157 UINT8 *Aml = ParserState->Aml; 00158 UINT32 PackageLength = 0; 00159 UINT32 ByteCount; 00160 UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ 00161 00162 00163 ACPI_FUNCTION_TRACE (PsGetNextPackageLength); 00164 00165 00166 /* 00167 * Byte 0 bits [6:7] contain the number of additional bytes 00168 * used to encode the package length, either 0,1,2, or 3 00169 */ 00170 ByteCount = (Aml[0] >> 6); 00171 ParserState->Aml += ((ACPI_SIZE) ByteCount + 1); 00172 00173 /* Get bytes 3, 2, 1 as needed */ 00174 00175 while (ByteCount) 00176 { 00177 /* 00178 * Final bit positions for the package length bytes: 00179 * Byte3->[20:27] 00180 * Byte2->[12:19] 00181 * Byte1->[04:11] 00182 * Byte0->[00:03] 00183 */ 00184 PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4)); 00185 00186 ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */ 00187 ByteCount--; 00188 } 00189 00190 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ 00191 00192 PackageLength |= (Aml[0] & ByteZeroMask); 00193 return_UINT32 (PackageLength); 00194 } 00195 00196 00197 /******************************************************************************* 00198 * 00199 * FUNCTION: AcpiPsGetNextPackageEnd 00200 * 00201 * PARAMETERS: ParserState - Current parser state object 00202 * 00203 * RETURN: Pointer to end-of-package +1 00204 * 00205 * DESCRIPTION: Get next package length and return a pointer past the end of 00206 * the package. Consumes the package length field 00207 * 00208 ******************************************************************************/ 00209 00210 UINT8 * 00211 AcpiPsGetNextPackageEnd ( 00212 ACPI_PARSE_STATE *ParserState) 00213 { 00214 UINT8 *Start = ParserState->Aml; 00215 UINT32 PackageLength; 00216 00217 00218 ACPI_FUNCTION_TRACE (PsGetNextPackageEnd); 00219 00220 00221 /* Function below updates ParserState->Aml */ 00222 00223 PackageLength = AcpiPsGetNextPackageLength (ParserState); 00224 00225 return_PTR (Start + PackageLength); /* end of package */ 00226 } 00227 00228 00229 /******************************************************************************* 00230 * 00231 * FUNCTION: AcpiPsGetNextNamestring 00232 * 00233 * PARAMETERS: ParserState - Current parser state object 00234 * 00235 * RETURN: Pointer to the start of the name string (pointer points into 00236 * the AML. 00237 * 00238 * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name 00239 * prefix characters. Set parser state to point past the string. 00240 * (Name is consumed from the AML.) 00241 * 00242 ******************************************************************************/ 00243 00244 char * 00245 AcpiPsGetNextNamestring ( 00246 ACPI_PARSE_STATE *ParserState) 00247 { 00248 UINT8 *Start = ParserState->Aml; 00249 UINT8 *End = ParserState->Aml; 00250 00251 00252 ACPI_FUNCTION_TRACE (PsGetNextNamestring); 00253 00254 00255 /* Point past any namestring prefix characters (backslash or carat) */ 00256 00257 while (AcpiPsIsPrefixChar (*End)) 00258 { 00259 End++; 00260 } 00261 00262 /* Decode the path prefix character */ 00263 00264 switch (*End) 00265 { 00266 case 0: 00267 00268 /* NullName */ 00269 00270 if (End == Start) 00271 { 00272 Start = NULL; 00273 } 00274 End++; 00275 break; 00276 00277 case AML_DUAL_NAME_PREFIX: 00278 00279 /* Two name segments */ 00280 00281 End += 1 + (2 * ACPI_NAME_SIZE); 00282 break; 00283 00284 case AML_MULTI_NAME_PREFIX_OP: 00285 00286 /* Multiple name segments, 4 chars each, count in next byte */ 00287 00288 End += 2 + (*(End + 1) * ACPI_NAME_SIZE); 00289 break; 00290 00291 default: 00292 00293 /* Single name segment */ 00294 00295 End += ACPI_NAME_SIZE; 00296 break; 00297 } 00298 00299 ParserState->Aml = End; 00300 return_PTR ((char *) Start); 00301 } 00302 00303 00304 /******************************************************************************* 00305 * 00306 * FUNCTION: AcpiPsGetNextNamepath 00307 * 00308 * PARAMETERS: ParserState - Current parser state object 00309 * Arg - Where the namepath will be stored 00310 * ArgCount - If the namepath points to a control method 00311 * the method's argument is returned here. 00312 * PossibleMethodCall - Whether the namepath can possibly be the 00313 * start of a method call 00314 * 00315 * RETURN: Status 00316 * 00317 * DESCRIPTION: Get next name (if method call, return # of required args). 00318 * Names are looked up in the internal namespace to determine 00319 * if the name represents a control method. If a method 00320 * is found, the number of arguments to the method is returned. 00321 * This information is critical for parsing to continue correctly. 00322 * 00323 ******************************************************************************/ 00324 00325 ACPI_STATUS 00326 AcpiPsGetNextNamepath ( 00327 ACPI_WALK_STATE *WalkState, 00328 ACPI_PARSE_STATE *ParserState, 00329 ACPI_PARSE_OBJECT *Arg, 00330 BOOLEAN PossibleMethodCall) 00331 { 00332 ACPI_STATUS Status; 00333 char *Path; 00334 ACPI_PARSE_OBJECT *NameOp; 00335 ACPI_OPERAND_OBJECT *MethodDesc; 00336 ACPI_NAMESPACE_NODE *Node; 00337 UINT8 *Start = ParserState->Aml; 00338 00339 00340 ACPI_FUNCTION_TRACE (PsGetNextNamepath); 00341 00342 00343 Path = AcpiPsGetNextNamestring (ParserState); 00344 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 00345 00346 /* Null path case is allowed, just exit */ 00347 00348 if (!Path) 00349 { 00350 Arg->Common.Value.Name = Path; 00351 return_ACPI_STATUS (AE_OK); 00352 } 00353 00354 /* 00355 * Lookup the name in the internal namespace, starting with the current 00356 * scope. We don't want to add anything new to the namespace here, 00357 * however, so we use MODE_EXECUTE. 00358 * Allow searching of the parent tree, but don't open a new scope - 00359 * we just want to lookup the object (must be mode EXECUTE to perform 00360 * the upsearch) 00361 */ 00362 Status = AcpiNsLookup (WalkState->ScopeInfo, Path, 00363 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, 00364 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); 00365 00366 /* 00367 * If this name is a control method invocation, we must 00368 * setup the method call 00369 */ 00370 if (ACPI_SUCCESS (Status) && 00371 PossibleMethodCall && 00372 (Node->Type == ACPI_TYPE_METHOD)) 00373 { 00374 if (WalkState->Opcode == AML_UNLOAD_OP) 00375 { 00376 /* 00377 * AcpiPsGetNextNamestring has increased the AML pointer, 00378 * so we need to restore the saved AML pointer for method call. 00379 */ 00380 WalkState->ParserState.Aml = Start; 00381 WalkState->ArgCount = 1; 00382 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); 00383 return_ACPI_STATUS (AE_OK); 00384 } 00385 00386 /* This name is actually a control method invocation */ 00387 00388 MethodDesc = AcpiNsGetAttachedObject (Node); 00389 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 00390 "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); 00391 00392 NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); 00393 if (!NameOp) 00394 { 00395 return_ACPI_STATUS (AE_NO_MEMORY); 00396 } 00397 00398 /* Change Arg into a METHOD CALL and attach name to it */ 00399 00400 AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); 00401 NameOp->Common.Value.Name = Path; 00402 00403 /* Point METHODCALL/NAME to the METHOD Node */ 00404 00405 NameOp->Common.Node = Node; 00406 AcpiPsAppendArg (Arg, NameOp); 00407 00408 if (!MethodDesc) 00409 { 00410 ACPI_ERROR ((AE_INFO, 00411 "Control Method %p has no attached object", 00412 Node)); 00413 return_ACPI_STATUS (AE_AML_INTERNAL); 00414 } 00415 00416 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 00417 "Control Method - %p Args %X\n", 00418 Node, MethodDesc->Method.ParamCount)); 00419 00420 /* Get the number of arguments to expect */ 00421 00422 WalkState->ArgCount = MethodDesc->Method.ParamCount; 00423 return_ACPI_STATUS (AE_OK); 00424 } 00425 00426 /* 00427 * Special handling if the name was not found during the lookup - 00428 * some NotFound cases are allowed 00429 */ 00430 if (Status == AE_NOT_FOUND) 00431 { 00432 /* 1) NotFound is ok during load pass 1/2 (allow forward references) */ 00433 00434 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) != 00435 ACPI_PARSE_EXECUTE) 00436 { 00437 Status = AE_OK; 00438 } 00439 00440 /* 2) NotFound during a CondRefOf(x) is ok by definition */ 00441 00442 else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP) 00443 { 00444 Status = AE_OK; 00445 } 00446 00447 /* 00448 * 3) NotFound while building a Package is ok at this point, we 00449 * may flag as an error later if slack mode is not enabled. 00450 * (Some ASL code depends on allowing this behavior) 00451 */ 00452 else if ((Arg->Common.Parent) && 00453 ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || 00454 (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) 00455 { 00456 Status = AE_OK; 00457 } 00458 } 00459 00460 /* Final exception check (may have been changed from code above) */ 00461 00462 if (ACPI_FAILURE (Status)) 00463 { 00464 ACPI_ERROR_NAMESPACE (Path, Status); 00465 00466 if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == 00467 ACPI_PARSE_EXECUTE) 00468 { 00469 /* Report a control method execution error */ 00470 00471 Status = AcpiDsMethodError (Status, WalkState); 00472 } 00473 } 00474 00475 /* Save the namepath */ 00476 00477 Arg->Common.Value.Name = Path; 00478 return_ACPI_STATUS (Status); 00479 } 00480 00481 00482 /******************************************************************************* 00483 * 00484 * FUNCTION: AcpiPsGetNextSimpleArg 00485 * 00486 * PARAMETERS: ParserState - Current parser state object 00487 * ArgType - The argument type (AML_*_ARG) 00488 * Arg - Where the argument is returned 00489 * 00490 * RETURN: None 00491 * 00492 * DESCRIPTION: Get the next simple argument (constant, string, or namestring) 00493 * 00494 ******************************************************************************/ 00495 00496 void 00497 AcpiPsGetNextSimpleArg ( 00498 ACPI_PARSE_STATE *ParserState, 00499 UINT32 ArgType, 00500 ACPI_PARSE_OBJECT *Arg) 00501 { 00502 UINT32 Length; 00503 UINT16 Opcode; 00504 UINT8 *Aml = ParserState->Aml; 00505 00506 00507 ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); 00508 00509 00510 switch (ArgType) 00511 { 00512 case ARGP_BYTEDATA: 00513 00514 /* Get 1 byte from the AML stream */ 00515 00516 Opcode = AML_BYTE_OP; 00517 Arg->Common.Value.Integer = (UINT64) *Aml; 00518 Length = 1; 00519 break; 00520 00521 00522 case ARGP_WORDDATA: 00523 00524 /* Get 2 bytes from the AML stream */ 00525 00526 Opcode = AML_WORD_OP; 00527 ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); 00528 Length = 2; 00529 break; 00530 00531 00532 case ARGP_DWORDDATA: 00533 00534 /* Get 4 bytes from the AML stream */ 00535 00536 Opcode = AML_DWORD_OP; 00537 ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); 00538 Length = 4; 00539 break; 00540 00541 00542 case ARGP_QWORDDATA: 00543 00544 /* Get 8 bytes from the AML stream */ 00545 00546 Opcode = AML_QWORD_OP; 00547 ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); 00548 Length = 8; 00549 break; 00550 00551 00552 case ARGP_CHARLIST: 00553 00554 /* Get a pointer to the string, point past the string */ 00555 00556 Opcode = AML_STRING_OP; 00557 Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml); 00558 00559 /* Find the null terminator */ 00560 00561 Length = 0; 00562 while (Aml[Length]) 00563 { 00564 Length++; 00565 } 00566 Length++; 00567 break; 00568 00569 00570 case ARGP_NAME: 00571 case ARGP_NAMESTRING: 00572 00573 AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); 00574 Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); 00575 return_VOID; 00576 00577 00578 default: 00579 00580 ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType)); 00581 return_VOID; 00582 } 00583 00584 AcpiPsInitOp (Arg, Opcode); 00585 ParserState->Aml += Length; 00586 return_VOID; 00587 } 00588 00589 00590 /******************************************************************************* 00591 * 00592 * FUNCTION: AcpiPsGetNextField 00593 * 00594 * PARAMETERS: ParserState - Current parser state object 00595 * 00596 * RETURN: A newly allocated FIELD op 00597 * 00598 * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) 00599 * 00600 ******************************************************************************/ 00601 00602 static ACPI_PARSE_OBJECT * 00603 AcpiPsGetNextField ( 00604 ACPI_PARSE_STATE *ParserState) 00605 { 00606 UINT32 AmlOffset = (UINT32) 00607 ACPI_PTR_DIFF (ParserState->Aml, 00608 ParserState->AmlStart); 00609 ACPI_PARSE_OBJECT *Field; 00610 UINT16 Opcode; 00611 UINT32 Name; 00612 00613 00614 ACPI_FUNCTION_TRACE (PsGetNextField); 00615 00616 00617 /* Determine field type */ 00618 00619 switch (ACPI_GET8 (ParserState->Aml)) 00620 { 00621 default: 00622 00623 Opcode = AML_INT_NAMEDFIELD_OP; 00624 break; 00625 00626 case 0x00: 00627 00628 Opcode = AML_INT_RESERVEDFIELD_OP; 00629 ParserState->Aml++; 00630 break; 00631 00632 case 0x01: 00633 00634 Opcode = AML_INT_ACCESSFIELD_OP; 00635 ParserState->Aml++; 00636 break; 00637 } 00638 00639 /* Allocate a new field op */ 00640 00641 Field = AcpiPsAllocOp (Opcode); 00642 if (!Field) 00643 { 00644 return_PTR (NULL); 00645 } 00646 00647 Field->Common.AmlOffset = AmlOffset; 00648 00649 /* Decode the field type */ 00650 00651 switch (Opcode) 00652 { 00653 case AML_INT_NAMEDFIELD_OP: 00654 00655 /* Get the 4-character name */ 00656 00657 ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); 00658 AcpiPsSetName (Field, Name); 00659 ParserState->Aml += ACPI_NAME_SIZE; 00660 00661 /* Get the length which is encoded as a package length */ 00662 00663 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 00664 break; 00665 00666 00667 case AML_INT_RESERVEDFIELD_OP: 00668 00669 /* Get the length which is encoded as a package length */ 00670 00671 Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); 00672 break; 00673 00674 00675 case AML_INT_ACCESSFIELD_OP: 00676 00677 /* 00678 * Get AccessType and AccessAttrib and merge into the field Op 00679 * AccessType is first operand, AccessAttribute is second 00680 */ 00681 Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8)); 00682 ParserState->Aml++; 00683 Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); 00684 ParserState->Aml++; 00685 break; 00686 00687 default: 00688 00689 /* Opcode was set in previous switch */ 00690 break; 00691 } 00692 00693 return_PTR (Field); 00694 } 00695 00696 00697 /******************************************************************************* 00698 * 00699 * FUNCTION: AcpiPsGetNextArg 00700 * 00701 * PARAMETERS: WalkState - Current state 00702 * ParserState - Current parser state object 00703 * ArgType - The argument type (AML_*_ARG) 00704 * ReturnArg - Where the next arg is returned 00705 * 00706 * RETURN: Status, and an op object containing the next argument. 00707 * 00708 * DESCRIPTION: Get next argument (including complex list arguments that require 00709 * pushing the parser stack) 00710 * 00711 ******************************************************************************/ 00712 00713 ACPI_STATUS 00714 AcpiPsGetNextArg ( 00715 ACPI_WALK_STATE *WalkState, 00716 ACPI_PARSE_STATE *ParserState, 00717 UINT32 ArgType, 00718 ACPI_PARSE_OBJECT **ReturnArg) 00719 { 00720 ACPI_PARSE_OBJECT *Arg = NULL; 00721 ACPI_PARSE_OBJECT *Prev = NULL; 00722 ACPI_PARSE_OBJECT *Field; 00723 UINT32 Subop; 00724 ACPI_STATUS Status = AE_OK; 00725 00726 00727 ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); 00728 00729 00730 switch (ArgType) 00731 { 00732 case ARGP_BYTEDATA: 00733 case ARGP_WORDDATA: 00734 case ARGP_DWORDDATA: 00735 case ARGP_CHARLIST: 00736 case ARGP_NAME: 00737 case ARGP_NAMESTRING: 00738 00739 /* Constants, strings, and namestrings are all the same size */ 00740 00741 Arg = AcpiPsAllocOp (AML_BYTE_OP); 00742 if (!Arg) 00743 { 00744 return_ACPI_STATUS (AE_NO_MEMORY); 00745 } 00746 AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); 00747 break; 00748 00749 00750 case ARGP_PKGLENGTH: 00751 00752 /* Package length, nothing returned */ 00753 00754 ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); 00755 break; 00756 00757 00758 case ARGP_FIELDLIST: 00759 00760 if (ParserState->Aml < ParserState->PkgEnd) 00761 { 00762 /* Non-empty list */ 00763 00764 while (ParserState->Aml < ParserState->PkgEnd) 00765 { 00766 Field = AcpiPsGetNextField (ParserState); 00767 if (!Field) 00768 { 00769 return_ACPI_STATUS (AE_NO_MEMORY); 00770 } 00771 00772 if (Prev) 00773 { 00774 Prev->Common.Next = Field; 00775 } 00776 else 00777 { 00778 Arg = Field; 00779 } 00780 Prev = Field; 00781 } 00782 00783 /* Skip to End of byte data */ 00784 00785 ParserState->Aml = ParserState->PkgEnd; 00786 } 00787 break; 00788 00789 00790 case ARGP_BYTELIST: 00791 00792 if (ParserState->Aml < ParserState->PkgEnd) 00793 { 00794 /* Non-empty list */ 00795 00796 Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); 00797 if (!Arg) 00798 { 00799 return_ACPI_STATUS (AE_NO_MEMORY); 00800 } 00801 00802 /* Fill in bytelist data */ 00803 00804 Arg->Common.Value.Size = (UINT32) 00805 ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); 00806 Arg->Named.Data = ParserState->Aml; 00807 00808 /* Skip to End of byte data */ 00809 00810 ParserState->Aml = ParserState->PkgEnd; 00811 } 00812 break; 00813 00814 00815 case ARGP_TARGET: 00816 case ARGP_SUPERNAME: 00817 case ARGP_SIMPLENAME: 00818 00819 Subop = AcpiPsPeekOpcode (ParserState); 00820 if (Subop == 0 || 00821 AcpiPsIsLeadingChar (Subop) || 00822 AcpiPsIsPrefixChar (Subop)) 00823 { 00824 /* NullName or NameString */ 00825 00826 Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); 00827 if (!Arg) 00828 { 00829 return_ACPI_STATUS (AE_NO_MEMORY); 00830 } 00831 00832 /* To support SuperName arg of Unload */ 00833 00834 if (WalkState->Opcode == AML_UNLOAD_OP) 00835 { 00836 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); 00837 00838 /* 00839 * If the SuperName arg of Unload is a method call, 00840 * we have restored the AML pointer, just free this Arg 00841 */ 00842 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) 00843 { 00844 AcpiPsFreeOp (Arg); 00845 Arg = NULL; 00846 } 00847 } 00848 else 00849 { 00850 Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); 00851 } 00852 } 00853 else 00854 { 00855 /* Single complex argument, nothing returned */ 00856 00857 WalkState->ArgCount = 1; 00858 } 00859 break; 00860 00861 00862 case ARGP_DATAOBJ: 00863 case ARGP_TERMARG: 00864 00865 /* Single complex argument, nothing returned */ 00866 00867 WalkState->ArgCount = 1; 00868 break; 00869 00870 00871 case ARGP_DATAOBJLIST: 00872 case ARGP_TERMLIST: 00873 case ARGP_OBJLIST: 00874 00875 if (ParserState->Aml < ParserState->PkgEnd) 00876 { 00877 /* Non-empty list of variable arguments, nothing returned */ 00878 00879 WalkState->ArgCount = ACPI_VAR_ARGS; 00880 } 00881 break; 00882 00883 00884 default: 00885 00886 ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType)); 00887 Status = AE_AML_OPERAND_TYPE; 00888 break; 00889 } 00890 00891 *ReturnArg = Arg; 00892 return_ACPI_STATUS (Status); 00893 } Generated on Fri May 25 2012 04:25:38 for ReactOS by
1.7.6.1
|