Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendsopcode.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: dsopcode - Dispatcher suport for regions and fields 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 __DSOPCODE_C__ 00117 00118 #include "acpi.h" 00119 #include "accommon.h" 00120 #include "acparser.h" 00121 #include "amlcode.h" 00122 #include "acdispat.h" 00123 #include "acinterp.h" 00124 #include "acnamesp.h" 00125 #include "acevents.h" 00126 #include "actables.h" 00127 00128 #define _COMPONENT ACPI_DISPATCHER 00129 ACPI_MODULE_NAME ("dsopcode") 00130 00131 /* Local prototypes */ 00132 00133 static ACPI_STATUS 00134 AcpiDsInitBufferField ( 00135 UINT16 AmlOpcode, 00136 ACPI_OPERAND_OBJECT *ObjDesc, 00137 ACPI_OPERAND_OBJECT *BufferDesc, 00138 ACPI_OPERAND_OBJECT *OffsetDesc, 00139 ACPI_OPERAND_OBJECT *LengthDesc, 00140 ACPI_OPERAND_OBJECT *ResultDesc); 00141 00142 00143 /******************************************************************************* 00144 * 00145 * FUNCTION: AcpiDsInitializeRegion 00146 * 00147 * PARAMETERS: ObjHandle - Region namespace node 00148 * 00149 * RETURN: Status 00150 * 00151 * DESCRIPTION: Front end to EvInitializeRegion 00152 * 00153 ******************************************************************************/ 00154 00155 ACPI_STATUS 00156 AcpiDsInitializeRegion ( 00157 ACPI_HANDLE ObjHandle) 00158 { 00159 ACPI_OPERAND_OBJECT *ObjDesc; 00160 ACPI_STATUS Status; 00161 00162 00163 ObjDesc = AcpiNsGetAttachedObject (ObjHandle); 00164 00165 /* Namespace is NOT locked */ 00166 00167 Status = AcpiEvInitializeRegion (ObjDesc, FALSE); 00168 return (Status); 00169 } 00170 00171 00172 /******************************************************************************* 00173 * 00174 * FUNCTION: AcpiDsInitBufferField 00175 * 00176 * PARAMETERS: AmlOpcode - CreateXxxField 00177 * ObjDesc - BufferField object 00178 * BufferDesc - Host Buffer 00179 * OffsetDesc - Offset into buffer 00180 * LengthDesc - Length of field (CREATE_FIELD_OP only) 00181 * ResultDesc - Where to store the result 00182 * 00183 * RETURN: Status 00184 * 00185 * DESCRIPTION: Perform actual initialization of a buffer field 00186 * 00187 ******************************************************************************/ 00188 00189 static ACPI_STATUS 00190 AcpiDsInitBufferField ( 00191 UINT16 AmlOpcode, 00192 ACPI_OPERAND_OBJECT *ObjDesc, 00193 ACPI_OPERAND_OBJECT *BufferDesc, 00194 ACPI_OPERAND_OBJECT *OffsetDesc, 00195 ACPI_OPERAND_OBJECT *LengthDesc, 00196 ACPI_OPERAND_OBJECT *ResultDesc) 00197 { 00198 UINT32 Offset; 00199 UINT32 BitOffset; 00200 UINT32 BitCount; 00201 UINT8 FieldFlags; 00202 ACPI_STATUS Status; 00203 00204 00205 ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); 00206 00207 00208 /* Host object must be a Buffer */ 00209 00210 if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) 00211 { 00212 ACPI_ERROR ((AE_INFO, 00213 "Target of Create Field is not a Buffer object - %s", 00214 AcpiUtGetObjectTypeName (BufferDesc))); 00215 00216 Status = AE_AML_OPERAND_TYPE; 00217 goto Cleanup; 00218 } 00219 00220 /* 00221 * The last parameter to all of these opcodes (ResultDesc) started 00222 * out as a NameString, and should therefore now be a NS node 00223 * after resolution in AcpiExResolveOperands(). 00224 */ 00225 if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) 00226 { 00227 ACPI_ERROR ((AE_INFO, 00228 "(%s) destination not a NS Node [%s]", 00229 AcpiPsGetOpcodeName (AmlOpcode), 00230 AcpiUtGetDescriptorName (ResultDesc))); 00231 00232 Status = AE_AML_OPERAND_TYPE; 00233 goto Cleanup; 00234 } 00235 00236 Offset = (UINT32) OffsetDesc->Integer.Value; 00237 00238 /* 00239 * Setup the Bit offsets and counts, according to the opcode 00240 */ 00241 switch (AmlOpcode) 00242 { 00243 case AML_CREATE_FIELD_OP: 00244 00245 /* Offset is in bits, count is in bits */ 00246 00247 FieldFlags = AML_FIELD_ACCESS_BYTE; 00248 BitOffset = Offset; 00249 BitCount = (UINT32) LengthDesc->Integer.Value; 00250 00251 /* Must have a valid (>0) bit count */ 00252 00253 if (BitCount == 0) 00254 { 00255 ACPI_ERROR ((AE_INFO, 00256 "Attempt to CreateField of length zero")); 00257 Status = AE_AML_OPERAND_VALUE; 00258 goto Cleanup; 00259 } 00260 break; 00261 00262 case AML_CREATE_BIT_FIELD_OP: 00263 00264 /* Offset is in bits, Field is one bit */ 00265 00266 BitOffset = Offset; 00267 BitCount = 1; 00268 FieldFlags = AML_FIELD_ACCESS_BYTE; 00269 break; 00270 00271 case AML_CREATE_BYTE_FIELD_OP: 00272 00273 /* Offset is in bytes, field is one byte */ 00274 00275 BitOffset = 8 * Offset; 00276 BitCount = 8; 00277 FieldFlags = AML_FIELD_ACCESS_BYTE; 00278 break; 00279 00280 case AML_CREATE_WORD_FIELD_OP: 00281 00282 /* Offset is in bytes, field is one word */ 00283 00284 BitOffset = 8 * Offset; 00285 BitCount = 16; 00286 FieldFlags = AML_FIELD_ACCESS_WORD; 00287 break; 00288 00289 case AML_CREATE_DWORD_FIELD_OP: 00290 00291 /* Offset is in bytes, field is one dword */ 00292 00293 BitOffset = 8 * Offset; 00294 BitCount = 32; 00295 FieldFlags = AML_FIELD_ACCESS_DWORD; 00296 break; 00297 00298 case AML_CREATE_QWORD_FIELD_OP: 00299 00300 /* Offset is in bytes, field is one qword */ 00301 00302 BitOffset = 8 * Offset; 00303 BitCount = 64; 00304 FieldFlags = AML_FIELD_ACCESS_QWORD; 00305 break; 00306 00307 default: 00308 00309 ACPI_ERROR ((AE_INFO, 00310 "Unknown field creation opcode 0x%02X", 00311 AmlOpcode)); 00312 Status = AE_AML_BAD_OPCODE; 00313 goto Cleanup; 00314 } 00315 00316 /* Entire field must fit within the current length of the buffer */ 00317 00318 if ((BitOffset + BitCount) > 00319 (8 * (UINT32) BufferDesc->Buffer.Length)) 00320 { 00321 ACPI_ERROR ((AE_INFO, 00322 "Field [%4.4s] at %u exceeds Buffer [%4.4s] size %u (bits)", 00323 AcpiUtGetNodeName (ResultDesc), 00324 BitOffset + BitCount, 00325 AcpiUtGetNodeName (BufferDesc->Buffer.Node), 00326 8 * (UINT32) BufferDesc->Buffer.Length)); 00327 Status = AE_AML_BUFFER_LIMIT; 00328 goto Cleanup; 00329 } 00330 00331 /* 00332 * Initialize areas of the field object that are common to all fields 00333 * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), 00334 * UPDATE_RULE = 0 (UPDATE_PRESERVE) 00335 */ 00336 Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, 00337 BitOffset, BitCount); 00338 if (ACPI_FAILURE (Status)) 00339 { 00340 goto Cleanup; 00341 } 00342 00343 ObjDesc->BufferField.BufferObj = BufferDesc; 00344 00345 /* Reference count for BufferDesc inherits ObjDesc count */ 00346 00347 BufferDesc->Common.ReferenceCount = (UINT16) 00348 (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); 00349 00350 00351 Cleanup: 00352 00353 /* Always delete the operands */ 00354 00355 AcpiUtRemoveReference (OffsetDesc); 00356 AcpiUtRemoveReference (BufferDesc); 00357 00358 if (AmlOpcode == AML_CREATE_FIELD_OP) 00359 { 00360 AcpiUtRemoveReference (LengthDesc); 00361 } 00362 00363 /* On failure, delete the result descriptor */ 00364 00365 if (ACPI_FAILURE (Status)) 00366 { 00367 AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ 00368 } 00369 else 00370 { 00371 /* Now the address and length are valid for this BufferField */ 00372 00373 ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; 00374 } 00375 00376 return_ACPI_STATUS (Status); 00377 } 00378 00379 00380 /******************************************************************************* 00381 * 00382 * FUNCTION: AcpiDsEvalBufferFieldOperands 00383 * 00384 * PARAMETERS: WalkState - Current walk 00385 * Op - A valid BufferField Op object 00386 * 00387 * RETURN: Status 00388 * 00389 * DESCRIPTION: Get BufferField Buffer and Index 00390 * Called from AcpiDsExecEndOp during BufferField parse tree walk 00391 * 00392 ******************************************************************************/ 00393 00394 ACPI_STATUS 00395 AcpiDsEvalBufferFieldOperands ( 00396 ACPI_WALK_STATE *WalkState, 00397 ACPI_PARSE_OBJECT *Op) 00398 { 00399 ACPI_STATUS Status; 00400 ACPI_OPERAND_OBJECT *ObjDesc; 00401 ACPI_NAMESPACE_NODE *Node; 00402 ACPI_PARSE_OBJECT *NextOp; 00403 00404 00405 ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); 00406 00407 00408 /* 00409 * This is where we evaluate the address and length fields of the 00410 * CreateXxxField declaration 00411 */ 00412 Node = Op->Common.Node; 00413 00414 /* NextOp points to the op that holds the Buffer */ 00415 00416 NextOp = Op->Common.Value.Arg; 00417 00418 /* Evaluate/create the address and length operands */ 00419 00420 Status = AcpiDsCreateOperands (WalkState, NextOp); 00421 if (ACPI_FAILURE (Status)) 00422 { 00423 return_ACPI_STATUS (Status); 00424 } 00425 00426 ObjDesc = AcpiNsGetAttachedObject (Node); 00427 if (!ObjDesc) 00428 { 00429 return_ACPI_STATUS (AE_NOT_EXIST); 00430 } 00431 00432 /* Resolve the operands */ 00433 00434 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 00435 ACPI_WALK_OPERANDS, WalkState); 00436 if (ACPI_FAILURE (Status)) 00437 { 00438 ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X", 00439 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); 00440 00441 return_ACPI_STATUS (Status); 00442 } 00443 00444 /* Initialize the Buffer Field */ 00445 00446 if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) 00447 { 00448 /* NOTE: Slightly different operands for this opcode */ 00449 00450 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 00451 WalkState->Operands[0], WalkState->Operands[1], 00452 WalkState->Operands[2], WalkState->Operands[3]); 00453 } 00454 else 00455 { 00456 /* All other, CreateXxxField opcodes */ 00457 00458 Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, 00459 WalkState->Operands[0], WalkState->Operands[1], 00460 NULL, WalkState->Operands[2]); 00461 } 00462 00463 return_ACPI_STATUS (Status); 00464 } 00465 00466 00467 /******************************************************************************* 00468 * 00469 * FUNCTION: AcpiDsEvalRegionOperands 00470 * 00471 * PARAMETERS: WalkState - Current walk 00472 * Op - A valid region Op object 00473 * 00474 * RETURN: Status 00475 * 00476 * DESCRIPTION: Get region address and length 00477 * Called from AcpiDsExecEndOp during OpRegion parse tree walk 00478 * 00479 ******************************************************************************/ 00480 00481 ACPI_STATUS 00482 AcpiDsEvalRegionOperands ( 00483 ACPI_WALK_STATE *WalkState, 00484 ACPI_PARSE_OBJECT *Op) 00485 { 00486 ACPI_STATUS Status; 00487 ACPI_OPERAND_OBJECT *ObjDesc; 00488 ACPI_OPERAND_OBJECT *OperandDesc; 00489 ACPI_NAMESPACE_NODE *Node; 00490 ACPI_PARSE_OBJECT *NextOp; 00491 00492 00493 ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); 00494 00495 00496 /* 00497 * This is where we evaluate the address and length fields of the 00498 * OpRegion declaration 00499 */ 00500 Node = Op->Common.Node; 00501 00502 /* NextOp points to the op that holds the SpaceID */ 00503 00504 NextOp = Op->Common.Value.Arg; 00505 00506 /* NextOp points to address op */ 00507 00508 NextOp = NextOp->Common.Next; 00509 00510 /* Evaluate/create the address and length operands */ 00511 00512 Status = AcpiDsCreateOperands (WalkState, NextOp); 00513 if (ACPI_FAILURE (Status)) 00514 { 00515 return_ACPI_STATUS (Status); 00516 } 00517 00518 /* Resolve the length and address operands to numbers */ 00519 00520 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 00521 ACPI_WALK_OPERANDS, WalkState); 00522 if (ACPI_FAILURE (Status)) 00523 { 00524 return_ACPI_STATUS (Status); 00525 } 00526 00527 ObjDesc = AcpiNsGetAttachedObject (Node); 00528 if (!ObjDesc) 00529 { 00530 return_ACPI_STATUS (AE_NOT_EXIST); 00531 } 00532 00533 /* 00534 * Get the length operand and save it 00535 * (at Top of stack) 00536 */ 00537 OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; 00538 00539 ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; 00540 AcpiUtRemoveReference (OperandDesc); 00541 00542 /* 00543 * Get the address and save it 00544 * (at top of stack - 1) 00545 */ 00546 OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 00547 00548 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) 00549 OperandDesc->Integer.Value; 00550 AcpiUtRemoveReference (OperandDesc); 00551 00552 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 00553 ObjDesc, 00554 ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), 00555 ObjDesc->Region.Length)); 00556 00557 /* Now the address and length are valid for this opregion */ 00558 00559 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 00560 00561 return_ACPI_STATUS (Status); 00562 } 00563 00564 00565 /******************************************************************************* 00566 * 00567 * FUNCTION: AcpiDsEvalTableRegionOperands 00568 * 00569 * PARAMETERS: WalkState - Current walk 00570 * Op - A valid region Op object 00571 * 00572 * RETURN: Status 00573 * 00574 * DESCRIPTION: Get region address and length. 00575 * Called from AcpiDsExecEndOp during DataTableRegion parse 00576 * tree walk. 00577 * 00578 ******************************************************************************/ 00579 00580 ACPI_STATUS 00581 AcpiDsEvalTableRegionOperands ( 00582 ACPI_WALK_STATE *WalkState, 00583 ACPI_PARSE_OBJECT *Op) 00584 { 00585 ACPI_STATUS Status; 00586 ACPI_OPERAND_OBJECT *ObjDesc; 00587 ACPI_OPERAND_OBJECT **Operand; 00588 ACPI_NAMESPACE_NODE *Node; 00589 ACPI_PARSE_OBJECT *NextOp; 00590 UINT32 TableIndex; 00591 ACPI_TABLE_HEADER *Table; 00592 00593 00594 ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); 00595 00596 00597 /* 00598 * This is where we evaluate the SignatureString and OemIDString 00599 * and OemTableIDString of the DataTableRegion declaration 00600 */ 00601 Node = Op->Common.Node; 00602 00603 /* NextOp points to SignatureString op */ 00604 00605 NextOp = Op->Common.Value.Arg; 00606 00607 /* 00608 * Evaluate/create the SignatureString and OemIDString 00609 * and OemTableIDString operands 00610 */ 00611 Status = AcpiDsCreateOperands (WalkState, NextOp); 00612 if (ACPI_FAILURE (Status)) 00613 { 00614 return_ACPI_STATUS (Status); 00615 } 00616 00617 /* 00618 * Resolve the SignatureString and OemIDString 00619 * and OemTableIDString operands 00620 */ 00621 Status = AcpiExResolveOperands (Op->Common.AmlOpcode, 00622 ACPI_WALK_OPERANDS, WalkState); 00623 if (ACPI_FAILURE (Status)) 00624 { 00625 return_ACPI_STATUS (Status); 00626 } 00627 00628 Operand = &WalkState->Operands[0]; 00629 00630 /* Find the ACPI table */ 00631 00632 Status = AcpiTbFindTable (Operand[0]->String.Pointer, 00633 Operand[1]->String.Pointer, Operand[2]->String.Pointer, 00634 &TableIndex); 00635 if (ACPI_FAILURE (Status)) 00636 { 00637 return_ACPI_STATUS (Status); 00638 } 00639 00640 AcpiUtRemoveReference (Operand[0]); 00641 AcpiUtRemoveReference (Operand[1]); 00642 AcpiUtRemoveReference (Operand[2]); 00643 00644 Status = AcpiGetTableByIndex (TableIndex, &Table); 00645 if (ACPI_FAILURE (Status)) 00646 { 00647 return_ACPI_STATUS (Status); 00648 } 00649 00650 ObjDesc = AcpiNsGetAttachedObject (Node); 00651 if (!ObjDesc) 00652 { 00653 return_ACPI_STATUS (AE_NOT_EXIST); 00654 } 00655 00656 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); 00657 ObjDesc->Region.Length = Table->Length; 00658 00659 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", 00660 ObjDesc, 00661 ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), 00662 ObjDesc->Region.Length)); 00663 00664 /* Now the address and length are valid for this opregion */ 00665 00666 ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; 00667 00668 return_ACPI_STATUS (Status); 00669 } 00670 00671 00672 /******************************************************************************* 00673 * 00674 * FUNCTION: AcpiDsEvalDataObjectOperands 00675 * 00676 * PARAMETERS: WalkState - Current walk 00677 * Op - A valid DataObject Op object 00678 * ObjDesc - DataObject 00679 * 00680 * RETURN: Status 00681 * 00682 * DESCRIPTION: Get the operands and complete the following data object types: 00683 * Buffer, Package. 00684 * 00685 ******************************************************************************/ 00686 00687 ACPI_STATUS 00688 AcpiDsEvalDataObjectOperands ( 00689 ACPI_WALK_STATE *WalkState, 00690 ACPI_PARSE_OBJECT *Op, 00691 ACPI_OPERAND_OBJECT *ObjDesc) 00692 { 00693 ACPI_STATUS Status; 00694 ACPI_OPERAND_OBJECT *ArgDesc; 00695 UINT32 Length; 00696 00697 00698 ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); 00699 00700 00701 /* The first operand (for all of these data objects) is the length */ 00702 00703 /* 00704 * Set proper index into operand stack for AcpiDsObjStackPush 00705 * invoked inside AcpiDsCreateOperand. 00706 */ 00707 WalkState->OperandIndex = WalkState->NumOperands; 00708 00709 Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); 00710 if (ACPI_FAILURE (Status)) 00711 { 00712 return_ACPI_STATUS (Status); 00713 } 00714 00715 Status = AcpiExResolveOperands (WalkState->Opcode, 00716 &(WalkState->Operands [WalkState->NumOperands -1]), 00717 WalkState); 00718 if (ACPI_FAILURE (Status)) 00719 { 00720 return_ACPI_STATUS (Status); 00721 } 00722 00723 /* Extract length operand */ 00724 00725 ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; 00726 Length = (UINT32) ArgDesc->Integer.Value; 00727 00728 /* Cleanup for length operand */ 00729 00730 Status = AcpiDsObjStackPop (1, WalkState); 00731 if (ACPI_FAILURE (Status)) 00732 { 00733 return_ACPI_STATUS (Status); 00734 } 00735 00736 AcpiUtRemoveReference (ArgDesc); 00737 00738 /* 00739 * Create the actual data object 00740 */ 00741 switch (Op->Common.AmlOpcode) 00742 { 00743 case AML_BUFFER_OP: 00744 00745 Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); 00746 break; 00747 00748 case AML_PACKAGE_OP: 00749 case AML_VAR_PACKAGE_OP: 00750 00751 Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); 00752 break; 00753 00754 default: 00755 return_ACPI_STATUS (AE_AML_BAD_OPCODE); 00756 } 00757 00758 if (ACPI_SUCCESS (Status)) 00759 { 00760 /* 00761 * Return the object in the WalkState, unless the parent is a package - 00762 * in this case, the return object will be stored in the parse tree 00763 * for the package. 00764 */ 00765 if ((!Op->Common.Parent) || 00766 ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && 00767 (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && 00768 (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) 00769 { 00770 WalkState->ResultObj = ObjDesc; 00771 } 00772 } 00773 00774 return_ACPI_STATUS (Status); 00775 } 00776 00777 00778 /******************************************************************************* 00779 * 00780 * FUNCTION: AcpiDsEvalBankFieldOperands 00781 * 00782 * PARAMETERS: WalkState - Current walk 00783 * Op - A valid BankField Op object 00784 * 00785 * RETURN: Status 00786 * 00787 * DESCRIPTION: Get BankField BankValue 00788 * Called from AcpiDsExecEndOp during BankField parse tree walk 00789 * 00790 ******************************************************************************/ 00791 00792 ACPI_STATUS 00793 AcpiDsEvalBankFieldOperands ( 00794 ACPI_WALK_STATE *WalkState, 00795 ACPI_PARSE_OBJECT *Op) 00796 { 00797 ACPI_STATUS Status; 00798 ACPI_OPERAND_OBJECT *ObjDesc; 00799 ACPI_OPERAND_OBJECT *OperandDesc; 00800 ACPI_NAMESPACE_NODE *Node; 00801 ACPI_PARSE_OBJECT *NextOp; 00802 ACPI_PARSE_OBJECT *Arg; 00803 00804 00805 ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op); 00806 00807 00808 /* 00809 * This is where we evaluate the BankValue field of the 00810 * BankField declaration 00811 */ 00812 00813 /* NextOp points to the op that holds the Region */ 00814 00815 NextOp = Op->Common.Value.Arg; 00816 00817 /* NextOp points to the op that holds the Bank Register */ 00818 00819 NextOp = NextOp->Common.Next; 00820 00821 /* NextOp points to the op that holds the Bank Value */ 00822 00823 NextOp = NextOp->Common.Next; 00824 00825 /* 00826 * Set proper index into operand stack for AcpiDsObjStackPush 00827 * invoked inside AcpiDsCreateOperand. 00828 * 00829 * We use WalkState->Operands[0] to store the evaluated BankValue 00830 */ 00831 WalkState->OperandIndex = 0; 00832 00833 Status = AcpiDsCreateOperand (WalkState, NextOp, 0); 00834 if (ACPI_FAILURE (Status)) 00835 { 00836 return_ACPI_STATUS (Status); 00837 } 00838 00839 Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState); 00840 if (ACPI_FAILURE (Status)) 00841 { 00842 return_ACPI_STATUS (Status); 00843 } 00844 00845 ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, 00846 AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1); 00847 /* 00848 * Get the BankValue operand and save it 00849 * (at Top of stack) 00850 */ 00851 OperandDesc = WalkState->Operands[0]; 00852 00853 /* Arg points to the start Bank Field */ 00854 00855 Arg = AcpiPsGetArg (Op, 4); 00856 while (Arg) 00857 { 00858 /* Ignore OFFSET and ACCESSAS terms here */ 00859 00860 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) 00861 { 00862 Node = Arg->Common.Node; 00863 00864 ObjDesc = AcpiNsGetAttachedObject (Node); 00865 if (!ObjDesc) 00866 { 00867 return_ACPI_STATUS (AE_NOT_EXIST); 00868 } 00869 00870 ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value; 00871 } 00872 00873 /* Move to next field in the list */ 00874 00875 Arg = Arg->Common.Next; 00876 } 00877 00878 AcpiUtRemoveReference (OperandDesc); 00879 return_ACPI_STATUS (Status); 00880 } 00881 Generated on Sun May 27 2012 04:27:15 for ReactOS by
1.7.6.1
|