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

utobject.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: utobject - ACPI object create/delete/size/cache routines
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 __UTOBJECT_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "acnamesp.h"
00121 
00122 
00123 #define _COMPONENT          ACPI_UTILITIES
00124         ACPI_MODULE_NAME    ("utobject")
00125 
00126 /* Local prototypes */
00127 
00128 static ACPI_STATUS
00129 AcpiUtGetSimpleObjectSize (
00130     ACPI_OPERAND_OBJECT     *Obj,
00131     ACPI_SIZE               *ObjLength);
00132 
00133 static ACPI_STATUS
00134 AcpiUtGetPackageObjectSize (
00135     ACPI_OPERAND_OBJECT     *Obj,
00136     ACPI_SIZE               *ObjLength);
00137 
00138 static ACPI_STATUS
00139 AcpiUtGetElementLength (
00140     UINT8                   ObjectType,
00141     ACPI_OPERAND_OBJECT     *SourceObject,
00142     ACPI_GENERIC_STATE      *State,
00143     void                    *Context);
00144 
00145 
00146 /*******************************************************************************
00147  *
00148  * FUNCTION:    AcpiUtCreateInternalObjectDbg
00149  *
00150  * PARAMETERS:  ModuleName          - Source file name of caller
00151  *              LineNumber          - Line number of caller
00152  *              ComponentId         - Component type of caller
00153  *              Type                - ACPI Type of the new object
00154  *
00155  * RETURN:      A new internal object, null on failure
00156  *
00157  * DESCRIPTION: Create and initialize a new internal object.
00158  *
00159  * NOTE:        We always allocate the worst-case object descriptor because
00160  *              these objects are cached, and we want them to be
00161  *              one-size-satisifies-any-request.  This in itself may not be
00162  *              the most memory efficient, but the efficiency of the object
00163  *              cache should more than make up for this!
00164  *
00165  ******************************************************************************/
00166 
00167 ACPI_OPERAND_OBJECT  *
00168 AcpiUtCreateInternalObjectDbg (
00169     const char              *ModuleName,
00170     UINT32                  LineNumber,
00171     UINT32                  ComponentId,
00172     ACPI_OBJECT_TYPE        Type)
00173 {
00174     ACPI_OPERAND_OBJECT     *Object;
00175     ACPI_OPERAND_OBJECT     *SecondObject;
00176 
00177 
00178     ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,
00179         AcpiUtGetTypeName (Type));
00180 
00181 
00182     /* Allocate the raw object descriptor */
00183 
00184     Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId);
00185     if (!Object)
00186     {
00187         return_PTR (NULL);
00188     }
00189 
00190     switch (Type)
00191     {
00192     case ACPI_TYPE_REGION:
00193     case ACPI_TYPE_BUFFER_FIELD:
00194     case ACPI_TYPE_LOCAL_BANK_FIELD:
00195 
00196         /* These types require a secondary object */
00197 
00198         SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
00199                             LineNumber, ComponentId);
00200         if (!SecondObject)
00201         {
00202             AcpiUtDeleteObjectDesc (Object);
00203             return_PTR (NULL);
00204         }
00205 
00206         SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
00207         SecondObject->Common.ReferenceCount = 1;
00208 
00209         /* Link the second object to the first */
00210 
00211         Object->Common.NextObject = SecondObject;
00212         break;
00213 
00214     default:
00215         /* All others have no secondary object */
00216         break;
00217     }
00218 
00219     /* Save the object type in the object descriptor */
00220 
00221     Object->Common.Type = (UINT8) Type;
00222 
00223     /* Init the reference count */
00224 
00225     Object->Common.ReferenceCount = 1;
00226 
00227     /* Any per-type initialization should go here */
00228 
00229     return_PTR (Object);
00230 }
00231 
00232 
00233 /*******************************************************************************
00234  *
00235  * FUNCTION:    AcpiUtCreatePackageObject
00236  *
00237  * PARAMETERS:  Count               - Number of package elements
00238  *
00239  * RETURN:      Pointer to a new Package object, null on failure
00240  *
00241  * DESCRIPTION: Create a fully initialized package object
00242  *
00243  ******************************************************************************/
00244 
00245 ACPI_OPERAND_OBJECT *
00246 AcpiUtCreatePackageObject (
00247     UINT32                  Count)
00248 {
00249     ACPI_OPERAND_OBJECT     *PackageDesc;
00250     ACPI_OPERAND_OBJECT     **PackageElements;
00251 
00252 
00253     ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);
00254 
00255 
00256     /* Create a new Package object */
00257 
00258     PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
00259     if (!PackageDesc)
00260     {
00261         return_PTR (NULL);
00262     }
00263 
00264     /*
00265      * Create the element array. Count+1 allows the array to be null
00266      * terminated.
00267      */
00268     PackageElements = ACPI_ALLOCATE_ZEROED (
00269                         ((ACPI_SIZE) Count + 1) * sizeof (void *));
00270     if (!PackageElements)
00271     {
00272         ACPI_FREE (PackageDesc);
00273         return_PTR (NULL);
00274     }
00275 
00276     PackageDesc->Package.Count = Count;
00277     PackageDesc->Package.Elements = PackageElements;
00278     return_PTR (PackageDesc);
00279 }
00280 
00281 
00282 /*******************************************************************************
00283  *
00284  * FUNCTION:    AcpiUtCreateIntegerObject
00285  *
00286  * PARAMETERS:  InitialValue        - Initial value for the integer
00287  *
00288  * RETURN:      Pointer to a new Integer object, null on failure
00289  *
00290  * DESCRIPTION: Create an initialized integer object
00291  *
00292  ******************************************************************************/
00293 
00294 ACPI_OPERAND_OBJECT *
00295 AcpiUtCreateIntegerObject (
00296     UINT64                  InitialValue)
00297 {
00298     ACPI_OPERAND_OBJECT     *IntegerDesc;
00299 
00300 
00301     ACPI_FUNCTION_TRACE (UtCreateIntegerObject);
00302 
00303 
00304     /* Create and initialize a new integer object */
00305 
00306     IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
00307     if (!IntegerDesc)
00308     {
00309         return_PTR (NULL);
00310     }
00311 
00312     IntegerDesc->Integer.Value = InitialValue;
00313     return_PTR (IntegerDesc);
00314 }
00315 
00316 
00317 /*******************************************************************************
00318  *
00319  * FUNCTION:    AcpiUtCreateBufferObject
00320  *
00321  * PARAMETERS:  BufferSize             - Size of buffer to be created
00322  *
00323  * RETURN:      Pointer to a new Buffer object, null on failure
00324  *
00325  * DESCRIPTION: Create a fully initialized buffer object
00326  *
00327  ******************************************************************************/
00328 
00329 ACPI_OPERAND_OBJECT *
00330 AcpiUtCreateBufferObject (
00331     ACPI_SIZE               BufferSize)
00332 {
00333     ACPI_OPERAND_OBJECT     *BufferDesc;
00334     UINT8                   *Buffer = NULL;
00335 
00336 
00337     ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);
00338 
00339 
00340     /* Create a new Buffer object */
00341 
00342     BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
00343     if (!BufferDesc)
00344     {
00345         return_PTR (NULL);
00346     }
00347 
00348     /* Create an actual buffer only if size > 0 */
00349 
00350     if (BufferSize > 0)
00351     {
00352         /* Allocate the actual buffer */
00353 
00354         Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);
00355         if (!Buffer)
00356         {
00357             ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
00358                 (UINT32) BufferSize));
00359             AcpiUtRemoveReference (BufferDesc);
00360             return_PTR (NULL);
00361         }
00362     }
00363 
00364     /* Complete buffer object initialization */
00365 
00366     BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
00367     BufferDesc->Buffer.Pointer = Buffer;
00368     BufferDesc->Buffer.Length = (UINT32) BufferSize;
00369 
00370     /* Return the new buffer descriptor */
00371 
00372     return_PTR (BufferDesc);
00373 }
00374 
00375 
00376 /*******************************************************************************
00377  *
00378  * FUNCTION:    AcpiUtCreateStringObject
00379  *
00380  * PARAMETERS:  StringSize          - Size of string to be created. Does not
00381  *                                    include NULL terminator, this is added
00382  *                                    automatically.
00383  *
00384  * RETURN:      Pointer to a new String object
00385  *
00386  * DESCRIPTION: Create a fully initialized string object
00387  *
00388  ******************************************************************************/
00389 
00390 ACPI_OPERAND_OBJECT *
00391 AcpiUtCreateStringObject (
00392     ACPI_SIZE               StringSize)
00393 {
00394     ACPI_OPERAND_OBJECT     *StringDesc;
00395     char                    *String;
00396 
00397 
00398     ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);
00399 
00400 
00401     /* Create a new String object */
00402 
00403     StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
00404     if (!StringDesc)
00405     {
00406         return_PTR (NULL);
00407     }
00408 
00409     /*
00410      * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
00411      * NOTE: Zero-length strings are NULL terminated
00412      */
00413     String = ACPI_ALLOCATE_ZEROED (StringSize + 1);
00414     if (!String)
00415     {
00416         ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
00417             (UINT32) StringSize));
00418         AcpiUtRemoveReference (StringDesc);
00419         return_PTR (NULL);
00420     }
00421 
00422     /* Complete string object initialization */
00423 
00424     StringDesc->String.Pointer = String;
00425     StringDesc->String.Length = (UINT32) StringSize;
00426 
00427     /* Return the new string descriptor */
00428 
00429     return_PTR (StringDesc);
00430 }
00431 
00432 
00433 /*******************************************************************************
00434  *
00435  * FUNCTION:    AcpiUtValidInternalObject
00436  *
00437  * PARAMETERS:  Object              - Object to be validated
00438  *
00439  * RETURN:      TRUE if object is valid, FALSE otherwise
00440  *
00441  * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
00442  *
00443  ******************************************************************************/
00444 
00445 BOOLEAN
00446 AcpiUtValidInternalObject (
00447     void                    *Object)
00448 {
00449 
00450     ACPI_FUNCTION_NAME (UtValidInternalObject);
00451 
00452 
00453     /* Check for a null pointer */
00454 
00455     if (!Object)
00456     {
00457         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
00458         return (FALSE);
00459     }
00460 
00461     /* Check the descriptor type field */
00462 
00463     switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
00464     {
00465     case ACPI_DESC_TYPE_OPERAND:
00466 
00467         /* The object appears to be a valid ACPI_OPERAND_OBJECT  */
00468 
00469         return (TRUE);
00470 
00471     default:
00472         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
00473                 "%p is not not an ACPI operand obj [%s]\n",
00474                 Object, AcpiUtGetDescriptorName (Object)));
00475         break;
00476     }
00477 
00478     return (FALSE);
00479 }
00480 
00481 
00482 /*******************************************************************************
00483  *
00484  * FUNCTION:    AcpiUtAllocateObjectDescDbg
00485  *
00486  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
00487  *              LineNumber          - Caller's line number (for error output)
00488  *              ComponentId         - Caller's component ID (for error output)
00489  *
00490  * RETURN:      Pointer to newly allocated object descriptor.  Null on error
00491  *
00492  * DESCRIPTION: Allocate a new object descriptor.  Gracefully handle
00493  *              error conditions.
00494  *
00495  ******************************************************************************/
00496 
00497 void *
00498 AcpiUtAllocateObjectDescDbg (
00499     const char              *ModuleName,
00500     UINT32                  LineNumber,
00501     UINT32                  ComponentId)
00502 {
00503     ACPI_OPERAND_OBJECT     *Object;
00504 
00505 
00506     ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);
00507 
00508 
00509     Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);
00510     if (!Object)
00511     {
00512         ACPI_ERROR ((ModuleName, LineNumber,
00513             "Could not allocate an object descriptor"));
00514 
00515         return_PTR (NULL);
00516     }
00517 
00518     /* Mark the descriptor type */
00519 
00520     ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);
00521 
00522     ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
00523             Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));
00524 
00525     return_PTR (Object);
00526 }
00527 
00528 
00529 /*******************************************************************************
00530  *
00531  * FUNCTION:    AcpiUtDeleteObjectDesc
00532  *
00533  * PARAMETERS:  Object          - An Acpi internal object to be deleted
00534  *
00535  * RETURN:      None.
00536  *
00537  * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
00538  *
00539  ******************************************************************************/
00540 
00541 void
00542 AcpiUtDeleteObjectDesc (
00543     ACPI_OPERAND_OBJECT     *Object)
00544 {
00545     ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
00546 
00547 
00548     /* Object must be an ACPI_OPERAND_OBJECT  */
00549 
00550     if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
00551     {
00552         ACPI_ERROR ((AE_INFO,
00553             "%p is not an ACPI Operand object [%s]", Object,
00554             AcpiUtGetDescriptorName (Object)));
00555         return_VOID;
00556     }
00557 
00558     (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
00559     return_VOID;
00560 }
00561 
00562 
00563 /*******************************************************************************
00564  *
00565  * FUNCTION:    AcpiUtGetSimpleObjectSize
00566  *
00567  * PARAMETERS:  InternalObject     - An ACPI operand object
00568  *              ObjLength          - Where the length is returned
00569  *
00570  * RETURN:      Status
00571  *
00572  * DESCRIPTION: This function is called to determine the space required to
00573  *              contain a simple object for return to an external user.
00574  *
00575  *              The length includes the object structure plus any additional
00576  *              needed space.
00577  *
00578  ******************************************************************************/
00579 
00580 static ACPI_STATUS
00581 AcpiUtGetSimpleObjectSize (
00582     ACPI_OPERAND_OBJECT     *InternalObject,
00583     ACPI_SIZE               *ObjLength)
00584 {
00585     ACPI_SIZE               Length;
00586     ACPI_SIZE               Size;
00587     ACPI_STATUS             Status = AE_OK;
00588 
00589 
00590     ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);
00591 
00592 
00593     /* Start with the length of the (external) Acpi object */
00594 
00595     Length = sizeof (ACPI_OBJECT);
00596 
00597     /* A NULL object is allowed, can be a legal uninitialized package element */
00598 
00599     if (!InternalObject)
00600     {
00601         /*
00602          * Object is NULL, just return the length of ACPI_OBJECT
00603          * (A NULL ACPI_OBJECT is an object of all zeroes.)
00604          */
00605         *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
00606         return_ACPI_STATUS (AE_OK);
00607     }
00608 
00609     /* A Namespace Node should never appear here */
00610 
00611     if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
00612     {
00613         /* A namespace node should never get here */
00614 
00615         return_ACPI_STATUS (AE_AML_INTERNAL);
00616     }
00617 
00618     /*
00619      * The final length depends on the object type
00620      * Strings and Buffers are packed right up against the parent object and
00621      * must be accessed bytewise or there may be alignment problems on
00622      * certain processors
00623      */
00624     switch (InternalObject->Common.Type)
00625     {
00626     case ACPI_TYPE_STRING:
00627 
00628         Length += (ACPI_SIZE) InternalObject->String.Length + 1;
00629         break;
00630 
00631 
00632     case ACPI_TYPE_BUFFER:
00633 
00634         Length += (ACPI_SIZE) InternalObject->Buffer.Length;
00635         break;
00636 
00637 
00638     case ACPI_TYPE_INTEGER:
00639     case ACPI_TYPE_PROCESSOR:
00640     case ACPI_TYPE_POWER:
00641 
00642         /* No extra data for these types */
00643 
00644         break;
00645 
00646 
00647     case ACPI_TYPE_LOCAL_REFERENCE:
00648 
00649         switch (InternalObject->Reference.Class)
00650         {
00651         case ACPI_REFCLASS_NAME:
00652 
00653             /*
00654              * Get the actual length of the full pathname to this object.
00655              * The reference will be converted to the pathname to the object
00656              */
00657             Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
00658             if (!Size)
00659             {
00660                 return_ACPI_STATUS (AE_BAD_PARAMETER);
00661             }
00662 
00663             Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
00664             break;
00665 
00666         default:
00667 
00668             /*
00669              * No other reference opcodes are supported.
00670              * Notably, Locals and Args are not supported, but this may be
00671              * required eventually.
00672              */
00673             ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
00674                 "unsupported Reference Class [%s] 0x%X in object %p",
00675                 AcpiUtGetReferenceName (InternalObject),
00676                 InternalObject->Reference.Class, InternalObject));
00677             Status = AE_TYPE;
00678             break;
00679         }
00680         break;
00681 
00682 
00683     default:
00684 
00685         ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
00686             "unsupported type [%s] 0x%X in object %p",
00687             AcpiUtGetObjectTypeName (InternalObject),
00688             InternalObject->Common.Type, InternalObject));
00689         Status = AE_TYPE;
00690         break;
00691     }
00692 
00693     /*
00694      * Account for the space required by the object rounded up to the next
00695      * multiple of the machine word size.  This keeps each object aligned
00696      * on a machine word boundary. (preventing alignment faults on some
00697      * machines.)
00698      */
00699     *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
00700     return_ACPI_STATUS (Status);
00701 }
00702 
00703 
00704 /*******************************************************************************
00705  *
00706  * FUNCTION:    AcpiUtGetElementLength
00707  *
00708  * PARAMETERS:  ACPI_PKG_CALLBACK
00709  *
00710  * RETURN:      Status
00711  *
00712  * DESCRIPTION: Get the length of one package element.
00713  *
00714  ******************************************************************************/
00715 
00716 static ACPI_STATUS
00717 AcpiUtGetElementLength (
00718     UINT8                   ObjectType,
00719     ACPI_OPERAND_OBJECT     *SourceObject,
00720     ACPI_GENERIC_STATE      *State,
00721     void                    *Context)
00722 {
00723     ACPI_STATUS             Status = AE_OK;
00724     ACPI_PKG_INFO           *Info = (ACPI_PKG_INFO *) Context;
00725     ACPI_SIZE               ObjectSpace;
00726 
00727 
00728     switch (ObjectType)
00729     {
00730     case ACPI_COPY_TYPE_SIMPLE:
00731 
00732         /*
00733          * Simple object - just get the size (Null object/entry is handled
00734          * here also) and sum it into the running package length
00735          */
00736         Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
00737         if (ACPI_FAILURE (Status))
00738         {
00739             return (Status);
00740         }
00741 
00742         Info->Length += ObjectSpace;
00743         break;
00744 
00745 
00746     case ACPI_COPY_TYPE_PACKAGE:
00747 
00748         /* Package object - nothing much to do here, let the walk handle it */
00749 
00750         Info->NumPackages++;
00751         State->Pkg.ThisTargetObj = NULL;
00752         break;
00753 
00754 
00755     default:
00756 
00757         /* No other types allowed */
00758 
00759         return (AE_BAD_PARAMETER);
00760     }
00761 
00762     return (Status);
00763 }
00764 
00765 
00766 /*******************************************************************************
00767  *
00768  * FUNCTION:    AcpiUtGetPackageObjectSize
00769  *
00770  * PARAMETERS:  InternalObject      - An ACPI internal object
00771  *              ObjLength           - Where the length is returned
00772  *
00773  * RETURN:      Status
00774  *
00775  * DESCRIPTION: This function is called to determine the space required to
00776  *              contain a package object for return to an external user.
00777  *
00778  *              This is moderately complex since a package contains other
00779  *              objects including packages.
00780  *
00781  ******************************************************************************/
00782 
00783 static ACPI_STATUS
00784 AcpiUtGetPackageObjectSize (
00785     ACPI_OPERAND_OBJECT     *InternalObject,
00786     ACPI_SIZE               *ObjLength)
00787 {
00788     ACPI_STATUS             Status;
00789     ACPI_PKG_INFO           Info;
00790 
00791 
00792     ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);
00793 
00794 
00795     Info.Length      = 0;
00796     Info.ObjectSpace = 0;
00797     Info.NumPackages = 1;
00798 
00799     Status = AcpiUtWalkPackageTree (InternalObject, NULL,
00800                             AcpiUtGetElementLength, &Info);
00801     if (ACPI_FAILURE (Status))
00802     {
00803         return_ACPI_STATUS (Status);
00804     }
00805 
00806     /*
00807      * We have handled all of the objects in all levels of the package.
00808      * just add the length of the package objects themselves.
00809      * Round up to the next machine word.
00810      */
00811     Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
00812                     (ACPI_SIZE) Info.NumPackages;
00813 
00814     /* Return the total package length */
00815 
00816     *ObjLength = Info.Length;
00817     return_ACPI_STATUS (Status);
00818 }
00819 
00820 
00821 /*******************************************************************************
00822  *
00823  * FUNCTION:    AcpiUtGetObjectSize
00824  *
00825  * PARAMETERS:  InternalObject      - An ACPI internal object
00826  *              ObjLength           - Where the length will be returned
00827  *
00828  * RETURN:      Status
00829  *
00830  * DESCRIPTION: This function is called to determine the space required to
00831  *              contain an object for return to an API user.
00832  *
00833  ******************************************************************************/
00834 
00835 ACPI_STATUS
00836 AcpiUtGetObjectSize (
00837     ACPI_OPERAND_OBJECT     *InternalObject,
00838     ACPI_SIZE               *ObjLength)
00839 {
00840     ACPI_STATUS             Status;
00841 
00842 
00843     ACPI_FUNCTION_ENTRY ();
00844 
00845 
00846     if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
00847         (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
00848     {
00849         Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
00850     }
00851     else
00852     {
00853         Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
00854     }
00855 
00856     return (Status);
00857 }
00858 
00859 

Generated on Sun May 27 2012 04:27:24 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.