ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dsmthdat.c
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Module Name: dsmthdat - control method arguments and local variables
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 __DSMTHDAT_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "acdispat.h"
00121 #include "acnamesp.h"
00122 #include "acinterp.h"
00123 
00124 
00125 #define _COMPONENT          ACPI_DISPATCHER
00126         ACPI_MODULE_NAME    ("dsmthdat")
00127 
00128 /* Local prototypes */
00129 
00130 static void
00131 AcpiDsMethodDataDeleteValue (
00132     UINT8                   Type,
00133     UINT32                  Index,
00134     ACPI_WALK_STATE         *WalkState);
00135 
00136 static ACPI_STATUS
00137 AcpiDsMethodDataSetValue (
00138     UINT8                   Type,
00139     UINT32                  Index,
00140     ACPI_OPERAND_OBJECT     *Object,
00141     ACPI_WALK_STATE         *WalkState);
00142 
00143 #ifdef ACPI_OBSOLETE_FUNCTIONS
00144 ACPI_OBJECT_TYPE
00145 AcpiDsMethodDataGetType (
00146     UINT16                  Opcode,
00147     UINT32                  Index,
00148     ACPI_WALK_STATE         *WalkState);
00149 #endif
00150 
00151 
00152 /*******************************************************************************
00153  *
00154  * FUNCTION:    AcpiDsMethodDataInit
00155  *
00156  * PARAMETERS:  WalkState           - Current walk state object
00157  *
00158  * RETURN:      Status
00159  *
00160  * DESCRIPTION: Initialize the data structures that hold the method's arguments
00161  *              and locals.  The data struct is an array of namespace nodes for
00162  *              each - this allows RefOf and DeRefOf to work properly for these
00163  *              special data types.
00164  *
00165  * NOTES:       WalkState fields are initialized to zero by the
00166  *              ACPI_ALLOCATE_ZEROED().
00167  *
00168  *              A pseudo-Namespace Node is assigned to each argument and local
00169  *              so that RefOf() can return a pointer to the Node.
00170  *
00171  ******************************************************************************/
00172 
00173 void
00174 AcpiDsMethodDataInit (
00175     ACPI_WALK_STATE         *WalkState)
00176 {
00177     UINT32                  i;
00178 
00179 
00180     ACPI_FUNCTION_TRACE (DsMethodDataInit);
00181 
00182 
00183     /* Init the method arguments */
00184 
00185     for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
00186     {
00187         ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
00188         WalkState->Arguments[i].Name.Integer |= (i << 24);
00189         WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
00190         WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
00191         WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
00192     }
00193 
00194     /* Init the method locals */
00195 
00196     for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
00197     {
00198         ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
00199 
00200         WalkState->LocalVariables[i].Name.Integer |= (i << 24);
00201         WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
00202         WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
00203         WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
00204     }
00205 
00206     return_VOID;
00207 }
00208 
00209 
00210 /*******************************************************************************
00211  *
00212  * FUNCTION:    AcpiDsMethodDataDeleteAll
00213  *
00214  * PARAMETERS:  WalkState           - Current walk state object
00215  *
00216  * RETURN:      None
00217  *
00218  * DESCRIPTION: Delete method locals and arguments.  Arguments are only
00219  *              deleted if this method was called from another method.
00220  *
00221  ******************************************************************************/
00222 
00223 void
00224 AcpiDsMethodDataDeleteAll (
00225     ACPI_WALK_STATE         *WalkState)
00226 {
00227     UINT32                  Index;
00228 
00229 
00230     ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
00231 
00232 
00233     /* Detach the locals */
00234 
00235     for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
00236     {
00237         if (WalkState->LocalVariables[Index].Object)
00238         {
00239             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
00240                     Index, WalkState->LocalVariables[Index].Object));
00241 
00242             /* Detach object (if present) and remove a reference */
00243 
00244             AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
00245         }
00246     }
00247 
00248     /* Detach the arguments */
00249 
00250     for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
00251     {
00252         if (WalkState->Arguments[Index].Object)
00253         {
00254             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
00255                     Index, WalkState->Arguments[Index].Object));
00256 
00257             /* Detach object (if present) and remove a reference */
00258 
00259             AcpiNsDetachObject (&WalkState->Arguments[Index]);
00260         }
00261     }
00262 
00263     return_VOID;
00264 }
00265 
00266 
00267 /*******************************************************************************
00268  *
00269  * FUNCTION:    AcpiDsMethodDataInitArgs
00270  *
00271  * PARAMETERS:  *Params         - Pointer to a parameter list for the method
00272  *              MaxParamCount   - The arg count for this method
00273  *              WalkState       - Current walk state object
00274  *
00275  * RETURN:      Status
00276  *
00277  * DESCRIPTION: Initialize arguments for a method.  The parameter list is a list
00278  *              of ACPI operand objects, either null terminated or whose length
00279  *              is defined by MaxParamCount.
00280  *
00281  ******************************************************************************/
00282 
00283 ACPI_STATUS
00284 AcpiDsMethodDataInitArgs (
00285     ACPI_OPERAND_OBJECT     **Params,
00286     UINT32                  MaxParamCount,
00287     ACPI_WALK_STATE         *WalkState)
00288 {
00289     ACPI_STATUS             Status;
00290     UINT32                  Index = 0;
00291 
00292 
00293     ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
00294 
00295 
00296     if (!Params)
00297     {
00298         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
00299         return_ACPI_STATUS (AE_OK);
00300     }
00301 
00302     /* Copy passed parameters into the new method stack frame */
00303 
00304     while ((Index < ACPI_METHOD_NUM_ARGS) &&
00305            (Index < MaxParamCount)        &&
00306             Params[Index])
00307     {
00308         /*
00309          * A valid parameter.
00310          * Store the argument in the method/walk descriptor.
00311          * Do not copy the arg in order to implement call by reference
00312          */
00313         Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
00314                     Params[Index], WalkState);
00315         if (ACPI_FAILURE (Status))
00316         {
00317             return_ACPI_STATUS (Status);
00318         }
00319 
00320         Index++;
00321     }
00322 
00323     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
00324     return_ACPI_STATUS (AE_OK);
00325 }
00326 
00327 
00328 /*******************************************************************************
00329  *
00330  * FUNCTION:    AcpiDsMethodDataGetNode
00331  *
00332  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
00333  *                                    ACPI_REFCLASS_ARG
00334  *              Index               - Which Local or Arg whose type to get
00335  *              WalkState           - Current walk state object
00336  *              Node                - Where the node is returned.
00337  *
00338  * RETURN:      Status and node
00339  *
00340  * DESCRIPTION: Get the Node associated with a local or arg.
00341  *
00342  ******************************************************************************/
00343 
00344 ACPI_STATUS
00345 AcpiDsMethodDataGetNode (
00346     UINT8                   Type,
00347     UINT32                  Index,
00348     ACPI_WALK_STATE         *WalkState,
00349     ACPI_NAMESPACE_NODE     **Node)
00350 {
00351     ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
00352 
00353 
00354     /*
00355      * Method Locals and Arguments are supported
00356      */
00357     switch (Type)
00358     {
00359     case ACPI_REFCLASS_LOCAL:
00360 
00361         if (Index > ACPI_METHOD_MAX_LOCAL)
00362         {
00363             ACPI_ERROR ((AE_INFO,
00364                 "Local index %u is invalid (max %u)",
00365                 Index, ACPI_METHOD_MAX_LOCAL));
00366             return_ACPI_STATUS (AE_AML_INVALID_INDEX);
00367         }
00368 
00369         /* Return a pointer to the pseudo-node */
00370 
00371         *Node = &WalkState->LocalVariables[Index];
00372         break;
00373 
00374     case ACPI_REFCLASS_ARG:
00375 
00376         if (Index > ACPI_METHOD_MAX_ARG)
00377         {
00378             ACPI_ERROR ((AE_INFO,
00379                 "Arg index %u is invalid (max %u)",
00380                 Index, ACPI_METHOD_MAX_ARG));
00381             return_ACPI_STATUS (AE_AML_INVALID_INDEX);
00382         }
00383 
00384         /* Return a pointer to the pseudo-node */
00385 
00386         *Node = &WalkState->Arguments[Index];
00387         break;
00388 
00389     default:
00390         ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
00391         return_ACPI_STATUS (AE_TYPE);
00392     }
00393 
00394     return_ACPI_STATUS (AE_OK);
00395 }
00396 
00397 
00398 /*******************************************************************************
00399  *
00400  * FUNCTION:    AcpiDsMethodDataSetValue
00401  *
00402  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
00403  *                                    ACPI_REFCLASS_ARG
00404  *              Index               - Which Local or Arg to get
00405  *              Object              - Object to be inserted into the stack entry
00406  *              WalkState           - Current walk state object
00407  *
00408  * RETURN:      Status
00409  *
00410  * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
00411  *              Note: There is no "implicit conversion" for locals.
00412  *
00413  ******************************************************************************/
00414 
00415 static ACPI_STATUS
00416 AcpiDsMethodDataSetValue (
00417     UINT8                   Type,
00418     UINT32                  Index,
00419     ACPI_OPERAND_OBJECT     *Object,
00420     ACPI_WALK_STATE         *WalkState)
00421 {
00422     ACPI_STATUS             Status;
00423     ACPI_NAMESPACE_NODE     *Node;
00424 
00425 
00426     ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
00427 
00428 
00429     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
00430         "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
00431         Type, Object->Common.ReferenceCount,
00432         AcpiUtGetTypeName (Object->Common.Type)));
00433 
00434     /* Get the namespace node for the arg/local */
00435 
00436     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
00437     if (ACPI_FAILURE (Status))
00438     {
00439         return_ACPI_STATUS (Status);
00440     }
00441 
00442     /*
00443      * Increment ref count so object can't be deleted while installed.
00444      * NOTE: We do not copy the object in order to preserve the call by
00445      * reference semantics of ACPI Control Method invocation.
00446      * (See ACPI Specification 2.0C)
00447      */
00448     AcpiUtAddReference (Object);
00449 
00450     /* Install the object */
00451 
00452     Node->Object = Object;
00453     return_ACPI_STATUS (Status);
00454 }
00455 
00456 
00457 /*******************************************************************************
00458  *
00459  * FUNCTION:    AcpiDsMethodDataGetValue
00460  *
00461  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
00462  *                                    ACPI_REFCLASS_ARG
00463  *              Index               - Which localVar or argument to get
00464  *              WalkState           - Current walk state object
00465  *              DestDesc            - Where Arg or Local value is returned
00466  *
00467  * RETURN:      Status
00468  *
00469  * DESCRIPTION: Retrieve value of selected Arg or Local for this method
00470  *              Used only in AcpiExResolveToValue().
00471  *
00472  ******************************************************************************/
00473 
00474 ACPI_STATUS
00475 AcpiDsMethodDataGetValue (
00476     UINT8                   Type,
00477     UINT32                  Index,
00478     ACPI_WALK_STATE         *WalkState,
00479     ACPI_OPERAND_OBJECT     **DestDesc)
00480 {
00481     ACPI_STATUS             Status;
00482     ACPI_NAMESPACE_NODE     *Node;
00483     ACPI_OPERAND_OBJECT     *Object;
00484 
00485 
00486     ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
00487 
00488 
00489     /* Validate the object descriptor */
00490 
00491     if (!DestDesc)
00492     {
00493         ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
00494         return_ACPI_STATUS (AE_BAD_PARAMETER);
00495     }
00496 
00497     /* Get the namespace node for the arg/local */
00498 
00499     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
00500     if (ACPI_FAILURE (Status))
00501     {
00502         return_ACPI_STATUS (Status);
00503     }
00504 
00505     /* Get the object from the node */
00506 
00507     Object = Node->Object;
00508 
00509     /* Examine the returned object, it must be valid. */
00510 
00511     if (!Object)
00512     {
00513         /*
00514          * Index points to uninitialized object.
00515          * This means that either 1) The expected argument was
00516          * not passed to the method, or 2) A local variable
00517          * was referenced by the method (via the ASL)
00518          * before it was initialized.  Either case is an error.
00519          */
00520 
00521         /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
00522 
00523         if (AcpiGbl_EnableInterpreterSlack)
00524         {
00525             Object = AcpiUtCreateIntegerObject ((UINT64) 0);
00526             if (!Object)
00527             {
00528                 return_ACPI_STATUS (AE_NO_MEMORY);
00529             }
00530 
00531             Node->Object = Object;
00532         }
00533 
00534         /* Otherwise, return the error */
00535 
00536         else switch (Type)
00537         {
00538         case ACPI_REFCLASS_ARG:
00539 
00540             ACPI_ERROR ((AE_INFO,
00541                 "Uninitialized Arg[%u] at node %p",
00542                 Index, Node));
00543 
00544             return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
00545 
00546         case ACPI_REFCLASS_LOCAL:
00547 
00548             /*
00549              * No error message for this case, will be trapped again later to
00550              * detect and ignore cases of Store(LocalX,LocalX)
00551              */
00552             return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
00553 
00554         default:
00555 
00556             ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
00557             return_ACPI_STATUS (AE_AML_INTERNAL);
00558         }
00559     }
00560 
00561     /*
00562      * The Index points to an initialized and valid object.
00563      * Return an additional reference to the object
00564      */
00565     *DestDesc = Object;
00566     AcpiUtAddReference (Object);
00567 
00568     return_ACPI_STATUS (AE_OK);
00569 }
00570 
00571 
00572 /*******************************************************************************
00573  *
00574  * FUNCTION:    AcpiDsMethodDataDeleteValue
00575  *
00576  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
00577  *                                    ACPI_REFCLASS_ARG
00578  *              Index               - Which localVar or argument to delete
00579  *              WalkState           - Current walk state object
00580  *
00581  * RETURN:      None
00582  *
00583  * DESCRIPTION: Delete the entry at Opcode:Index.  Inserts
00584  *              a null into the stack slot after the object is deleted.
00585  *
00586  ******************************************************************************/
00587 
00588 static void
00589 AcpiDsMethodDataDeleteValue (
00590     UINT8                   Type,
00591     UINT32                  Index,
00592     ACPI_WALK_STATE         *WalkState)
00593 {
00594     ACPI_STATUS             Status;
00595     ACPI_NAMESPACE_NODE     *Node;
00596     ACPI_OPERAND_OBJECT     *Object;
00597 
00598 
00599     ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
00600 
00601 
00602     /* Get the namespace node for the arg/local */
00603 
00604     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
00605     if (ACPI_FAILURE (Status))
00606     {
00607         return_VOID;
00608     }
00609 
00610     /* Get the associated object */
00611 
00612     Object = AcpiNsGetAttachedObject (Node);
00613 
00614     /*
00615      * Undefine the Arg or Local by setting its descriptor
00616      * pointer to NULL. Locals/Args can contain both
00617      * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
00618      */
00619     Node->Object = NULL;
00620 
00621     if ((Object) &&
00622         (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
00623     {
00624         /*
00625          * There is a valid object.
00626          * Decrement the reference count by one to balance the
00627          * increment when the object was stored.
00628          */
00629         AcpiUtRemoveReference (Object);
00630     }
00631 
00632     return_VOID;
00633 }
00634 
00635 
00636 /*******************************************************************************
00637  *
00638  * FUNCTION:    AcpiDsStoreObjectToLocal
00639  *
00640  * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
00641  *                                    ACPI_REFCLASS_ARG
00642  *              Index               - Which Local or Arg to set
00643  *              ObjDesc             - Value to be stored
00644  *              WalkState           - Current walk state
00645  *
00646  * RETURN:      Status
00647  *
00648  * DESCRIPTION: Store a value in an Arg or Local.  The ObjDesc is installed
00649  *              as the new value for the Arg or Local and the reference count
00650  *              for ObjDesc is incremented.
00651  *
00652  ******************************************************************************/
00653 
00654 ACPI_STATUS
00655 AcpiDsStoreObjectToLocal (
00656     UINT8                   Type,
00657     UINT32                  Index,
00658     ACPI_OPERAND_OBJECT     *ObjDesc,
00659     ACPI_WALK_STATE         *WalkState)
00660 {
00661     ACPI_STATUS             Status;
00662     ACPI_NAMESPACE_NODE     *Node;
00663     ACPI_OPERAND_OBJECT     *CurrentObjDesc;
00664     ACPI_OPERAND_OBJECT     *NewObjDesc;
00665 
00666 
00667     ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
00668     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
00669         Type, Index, ObjDesc));
00670 
00671     /* Parameter validation */
00672 
00673     if (!ObjDesc)
00674     {
00675         return_ACPI_STATUS (AE_BAD_PARAMETER);
00676     }
00677 
00678     /* Get the namespace node for the arg/local */
00679 
00680     Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
00681     if (ACPI_FAILURE (Status))
00682     {
00683         return_ACPI_STATUS (Status);
00684     }
00685 
00686     CurrentObjDesc = AcpiNsGetAttachedObject (Node);
00687     if (CurrentObjDesc == ObjDesc)
00688     {
00689         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
00690             ObjDesc));
00691         return_ACPI_STATUS (Status);
00692     }
00693 
00694     /*
00695      * If the reference count on the object is more than one, we must
00696      * take a copy of the object before we store.  A reference count
00697      * of exactly 1 means that the object was just created during the
00698      * evaluation of an expression, and we can safely use it since it
00699      * is not used anywhere else.
00700      */
00701     NewObjDesc = ObjDesc;
00702     if (ObjDesc->Common.ReferenceCount > 1)
00703     {
00704         Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
00705         if (ACPI_FAILURE (Status))
00706         {
00707             return_ACPI_STATUS (Status);
00708         }
00709     }
00710 
00711     /*
00712      * If there is an object already in this slot, we either
00713      * have to delete it, or if this is an argument and there
00714      * is an object reference stored there, we have to do
00715      * an indirect store!
00716      */
00717     if (CurrentObjDesc)
00718     {
00719         /*
00720          * Check for an indirect store if an argument
00721          * contains an object reference (stored as an Node).
00722          * We don't allow this automatic dereferencing for
00723          * locals, since a store to a local should overwrite
00724          * anything there, including an object reference.
00725          *
00726          * If both Arg0 and Local0 contain RefOf (Local4):
00727          *
00728          * Store (1, Arg0)             - Causes indirect store to local4
00729          * Store (1, Local0)           - Stores 1 in local0, overwriting
00730          *                                  the reference to local4
00731          * Store (1, DeRefof (Local0)) - Causes indirect store to local4
00732          *
00733          * Weird, but true.
00734          */
00735         if (Type == ACPI_REFCLASS_ARG)
00736         {
00737             /*
00738              * If we have a valid reference object that came from RefOf(),
00739              * do the indirect store
00740              */
00741             if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
00742                 (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
00743                 (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
00744             {
00745                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
00746                         "Arg (%p) is an ObjRef(Node), storing in node %p\n",
00747                         NewObjDesc, CurrentObjDesc));
00748 
00749                 /*
00750                  * Store this object to the Node (perform the indirect store)
00751                  * NOTE: No implicit conversion is performed, as per the ACPI
00752                  * specification rules on storing to Locals/Args.
00753                  */
00754                 Status = AcpiExStoreObjectToNode (NewObjDesc,
00755                             CurrentObjDesc->Reference.Object, WalkState,
00756                             ACPI_NO_IMPLICIT_CONVERSION);
00757 
00758                 /* Remove local reference if we copied the object above */
00759 
00760                 if (NewObjDesc != ObjDesc)
00761                 {
00762                     AcpiUtRemoveReference (NewObjDesc);
00763                 }
00764                 return_ACPI_STATUS (Status);
00765             }
00766         }
00767 
00768         /* Delete the existing object before storing the new one */
00769 
00770         AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
00771     }
00772 
00773     /*
00774      * Install the Obj descriptor (*NewObjDesc) into
00775      * the descriptor for the Arg or Local.
00776      * (increments the object reference count by one)
00777      */
00778     Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
00779 
00780     /* Remove local reference if we copied the object above */
00781 
00782     if (NewObjDesc != ObjDesc)
00783     {
00784         AcpiUtRemoveReference (NewObjDesc);
00785     }
00786 
00787     return_ACPI_STATUS (Status);
00788 }
00789 
00790 
00791 #ifdef ACPI_OBSOLETE_FUNCTIONS
00792 /*******************************************************************************
00793  *
00794  * FUNCTION:    AcpiDsMethodDataGetType
00795  *
00796  * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
00797  *              Index               - Which Local or Arg whose type to get
00798  *              WalkState           - Current walk state object
00799  *
00800  * RETURN:      Data type of current value of the selected Arg or Local
00801  *
00802  * DESCRIPTION: Get the type of the object stored in the Local or Arg
00803  *
00804  ******************************************************************************/
00805 
00806 ACPI_OBJECT_TYPE
00807 AcpiDsMethodDataGetType (
00808     UINT16                  Opcode,
00809     UINT32                  Index,
00810     ACPI_WALK_STATE         *WalkState)
00811 {
00812     ACPI_STATUS             Status;
00813     ACPI_NAMESPACE_NODE     *Node;
00814     ACPI_OPERAND_OBJECT     *Object;
00815 
00816 
00817     ACPI_FUNCTION_TRACE (DsMethodDataGetType);
00818 
00819 
00820     /* Get the namespace node for the arg/local */
00821 
00822     Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
00823     if (ACPI_FAILURE (Status))
00824     {
00825         return_VALUE ((ACPI_TYPE_NOT_FOUND));
00826     }
00827 
00828     /* Get the object */
00829 
00830     Object = AcpiNsGetAttachedObject (Node);
00831     if (!Object)
00832     {
00833         /* Uninitialized local/arg, return TYPE_ANY */
00834 
00835         return_VALUE (ACPI_TYPE_ANY);
00836     }
00837 
00838     /* Get the object type */
00839 
00840     return_VALUE (Object->Type);
00841 }
00842 #endif
00843 
00844 

Generated on Sat May 26 2012 04:25:45 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.