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

rsutils.c
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Module Name: rsutils - Utilities for the resource manager
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 
00117 #define __RSUTILS_C__
00118 
00119 #include "acpi.h"
00120 #include "accommon.h"
00121 #include "acnamesp.h"
00122 #include "acresrc.h"
00123 
00124 
00125 #define _COMPONENT          ACPI_RESOURCES
00126         ACPI_MODULE_NAME    ("rsutils")
00127 
00128 
00129 /*******************************************************************************
00130  *
00131  * FUNCTION:    AcpiRsDecodeBitmask
00132  *
00133  * PARAMETERS:  Mask            - Bitmask to decode
00134  *              List            - Where the converted list is returned
00135  *
00136  * RETURN:      Count of bits set (length of list)
00137  *
00138  * DESCRIPTION: Convert a bit mask into a list of values
00139  *
00140  ******************************************************************************/
00141 
00142 UINT8
00143 AcpiRsDecodeBitmask (
00144     UINT16                  Mask,
00145     UINT8                   *List)
00146 {
00147     UINT8                   i;
00148     UINT8                   BitCount;
00149 
00150 
00151     ACPI_FUNCTION_ENTRY ();
00152 
00153 
00154     /* Decode the mask bits */
00155 
00156     for (i = 0, BitCount = 0; Mask; i++)
00157     {
00158         if (Mask & 0x0001)
00159         {
00160             List[BitCount] = i;
00161             BitCount++;
00162         }
00163 
00164         Mask >>= 1;
00165     }
00166 
00167     return (BitCount);
00168 }
00169 
00170 
00171 /*******************************************************************************
00172  *
00173  * FUNCTION:    AcpiRsEncodeBitmask
00174  *
00175  * PARAMETERS:  List            - List of values to encode
00176  *              Count           - Length of list
00177  *
00178  * RETURN:      Encoded bitmask
00179  *
00180  * DESCRIPTION: Convert a list of values to an encoded bitmask
00181  *
00182  ******************************************************************************/
00183 
00184 UINT16
00185 AcpiRsEncodeBitmask (
00186     UINT8                   *List,
00187     UINT8                   Count)
00188 {
00189     UINT32                  i;
00190     UINT16                  Mask;
00191 
00192 
00193     ACPI_FUNCTION_ENTRY ();
00194 
00195 
00196     /* Encode the list into a single bitmask */
00197 
00198     for (i = 0, Mask = 0; i < Count; i++)
00199     {
00200         Mask |= (0x1 << List[i]);
00201     }
00202 
00203     return (Mask);
00204 }
00205 
00206 
00207 /*******************************************************************************
00208  *
00209  * FUNCTION:    AcpiRsMoveData
00210  *
00211  * PARAMETERS:  Destination         - Pointer to the destination descriptor
00212  *              Source              - Pointer to the source descriptor
00213  *              ItemCount           - How many items to move
00214  *              MoveType            - Byte width
00215  *
00216  * RETURN:      None
00217  *
00218  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
00219  *              alignment issues and endian issues if necessary, as configured
00220  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
00221  *
00222  ******************************************************************************/
00223 
00224 void
00225 AcpiRsMoveData (
00226     void                    *Destination,
00227     void                    *Source,
00228     UINT16                  ItemCount,
00229     UINT8                   MoveType)
00230 {
00231     UINT32                  i;
00232 
00233 
00234     ACPI_FUNCTION_ENTRY ();
00235 
00236 
00237     /* One move per item */
00238 
00239     for (i = 0; i < ItemCount; i++)
00240     {
00241         switch (MoveType)
00242         {
00243         /*
00244          * For the 8-bit case, we can perform the move all at once
00245          * since there are no alignment or endian issues
00246          */
00247         case ACPI_RSC_MOVE8:
00248             ACPI_MEMCPY (Destination, Source, ItemCount);
00249             return;
00250 
00251         /*
00252          * 16-, 32-, and 64-bit cases must use the move macros that perform
00253          * endian conversion and/or accomodate hardware that cannot perform
00254          * misaligned memory transfers
00255          */
00256         case ACPI_RSC_MOVE16:
00257             ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
00258                                 &ACPI_CAST_PTR (UINT16, Source)[i]);
00259             break;
00260 
00261         case ACPI_RSC_MOVE32:
00262             ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
00263                                 &ACPI_CAST_PTR (UINT32, Source)[i]);
00264             break;
00265 
00266         case ACPI_RSC_MOVE64:
00267             ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
00268                                 &ACPI_CAST_PTR (UINT64, Source)[i]);
00269             break;
00270 
00271         default:
00272             return;
00273         }
00274     }
00275 }
00276 
00277 
00278 /*******************************************************************************
00279  *
00280  * FUNCTION:    AcpiRsSetResourceLength
00281  *
00282  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
00283  *                                    the header and length fields.
00284  *              Aml                 - Pointer to the raw AML descriptor
00285  *
00286  * RETURN:      None
00287  *
00288  * DESCRIPTION: Set the ResourceLength field of an AML
00289  *              resource descriptor, both Large and Small descriptors are
00290  *              supported automatically. Note: Descriptor Type field must
00291  *              be valid.
00292  *
00293  ******************************************************************************/
00294 
00295 void
00296 AcpiRsSetResourceLength (
00297     ACPI_RSDESC_SIZE        TotalLength,
00298     AML_RESOURCE            *Aml)
00299 {
00300     ACPI_RS_LENGTH          ResourceLength;
00301 
00302 
00303     ACPI_FUNCTION_ENTRY ();
00304 
00305 
00306     /* Length is the total descriptor length minus the header length */
00307 
00308     ResourceLength = (ACPI_RS_LENGTH)
00309         (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
00310 
00311     /* Length is stored differently for large and small descriptors */
00312 
00313     if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
00314     {
00315         /* Large descriptor -- bytes 1-2 contain the 16-bit length */
00316 
00317         ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
00318     }
00319     else
00320     {
00321         /* Small descriptor -- bits 2:0 of byte 0 contain the length */
00322 
00323         Aml->SmallHeader.DescriptorType = (UINT8)
00324 
00325             /* Clear any existing length, preserving descriptor type bits */
00326 
00327             ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
00328 
00329             | ResourceLength);
00330     }
00331 }
00332 
00333 
00334 /*******************************************************************************
00335  *
00336  * FUNCTION:    AcpiRsSetResourceHeader
00337  *
00338  * PARAMETERS:  DescriptorType      - Byte to be inserted as the type
00339  *              TotalLength         - Length of the AML descriptor, including
00340  *                                    the header and length fields.
00341  *              Aml                 - Pointer to the raw AML descriptor
00342  *
00343  * RETURN:      None
00344  *
00345  * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
00346  *              resource descriptor, both Large and Small descriptors are
00347  *              supported automatically
00348  *
00349  ******************************************************************************/
00350 
00351 void
00352 AcpiRsSetResourceHeader (
00353     UINT8                   DescriptorType,
00354     ACPI_RSDESC_SIZE        TotalLength,
00355     AML_RESOURCE            *Aml)
00356 {
00357     ACPI_FUNCTION_ENTRY ();
00358 
00359 
00360     /* Set the Resource Type */
00361 
00362     Aml->SmallHeader.DescriptorType = DescriptorType;
00363 
00364     /* Set the Resource Length */
00365 
00366     AcpiRsSetResourceLength (TotalLength, Aml);
00367 }
00368 
00369 
00370 /*******************************************************************************
00371  *
00372  * FUNCTION:    AcpiRsStrcpy
00373  *
00374  * PARAMETERS:  Destination         - Pointer to the destination string
00375  *              Source              - Pointer to the source string
00376  *
00377  * RETURN:      String length, including NULL terminator
00378  *
00379  * DESCRIPTION: Local string copy that returns the string length, saving a
00380  *              strcpy followed by a strlen.
00381  *
00382  ******************************************************************************/
00383 
00384 static UINT16
00385 AcpiRsStrcpy (
00386     char                    *Destination,
00387     char                    *Source)
00388 {
00389     UINT16                  i;
00390 
00391 
00392     ACPI_FUNCTION_ENTRY ();
00393 
00394 
00395     for (i = 0; Source[i]; i++)
00396     {
00397         Destination[i] = Source[i];
00398     }
00399 
00400     Destination[i] = 0;
00401 
00402     /* Return string length including the NULL terminator */
00403 
00404     return ((UINT16) (i + 1));
00405 }
00406 
00407 
00408 /*******************************************************************************
00409  *
00410  * FUNCTION:    AcpiRsGetResourceSource
00411  *
00412  * PARAMETERS:  ResourceLength      - Length field of the descriptor
00413  *              MinimumLength       - Minimum length of the descriptor (minus
00414  *                                    any optional fields)
00415  *              ResourceSource      - Where the ResourceSource is returned
00416  *              Aml                 - Pointer to the raw AML descriptor
00417  *              StringPtr           - (optional) where to store the actual
00418  *                                    ResourceSource string
00419  *
00420  * RETURN:      Length of the string plus NULL terminator, rounded up to native
00421  *              word boundary
00422  *
00423  * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
00424  *              to an internal resource descriptor
00425  *
00426  ******************************************************************************/
00427 
00428 ACPI_RS_LENGTH
00429 AcpiRsGetResourceSource (
00430     ACPI_RS_LENGTH          ResourceLength,
00431     ACPI_RS_LENGTH          MinimumLength,
00432     ACPI_RESOURCE_SOURCE    *ResourceSource,
00433     AML_RESOURCE            *Aml,
00434     char                    *StringPtr)
00435 {
00436     ACPI_RSDESC_SIZE        TotalLength;
00437     UINT8                   *AmlResourceSource;
00438 
00439 
00440     ACPI_FUNCTION_ENTRY ();
00441 
00442 
00443     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
00444     AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
00445 
00446     /*
00447      * ResourceSource is present if the length of the descriptor is longer than
00448      * the minimum length.
00449      *
00450      * Note: Some resource descriptors will have an additional null, so
00451      * we add 1 to the minimum length.
00452      */
00453     if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
00454     {
00455         /* Get the ResourceSourceIndex */
00456 
00457         ResourceSource->Index = AmlResourceSource[0];
00458 
00459         ResourceSource->StringPtr = StringPtr;
00460         if (!StringPtr)
00461         {
00462             /*
00463              * String destination pointer is not specified; Set the String
00464              * pointer to the end of the current ResourceSource structure.
00465              */
00466             ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
00467                 sizeof (ACPI_RESOURCE_SOURCE));
00468         }
00469 
00470         /*
00471          * In order for the Resource length to be a multiple of the native
00472          * word, calculate the length of the string (+1 for NULL terminator)
00473          * and expand to the next word multiple.
00474          *
00475          * Zero the entire area of the buffer.
00476          */
00477         TotalLength = (UINT32) ACPI_STRLEN (
00478             ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
00479         TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
00480 
00481         ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
00482 
00483         /* Copy the ResourceSource string to the destination */
00484 
00485         ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
00486             ACPI_CAST_PTR (char, &AmlResourceSource[1]));
00487 
00488         return ((ACPI_RS_LENGTH) TotalLength);
00489     }
00490 
00491     /* ResourceSource is not present */
00492 
00493     ResourceSource->Index = 0;
00494     ResourceSource->StringLength = 0;
00495     ResourceSource->StringPtr = NULL;
00496     return (0);
00497 }
00498 
00499 
00500 /*******************************************************************************
00501  *
00502  * FUNCTION:    AcpiRsSetResourceSource
00503  *
00504  * PARAMETERS:  Aml                 - Pointer to the raw AML descriptor
00505  *              MinimumLength       - Minimum length of the descriptor (minus
00506  *                                    any optional fields)
00507  *              ResourceSource      - Internal ResourceSource
00508 
00509  *
00510  * RETURN:      Total length of the AML descriptor
00511  *
00512  * DESCRIPTION: Convert an optional ResourceSource from internal format to a
00513  *              raw AML resource descriptor
00514  *
00515  ******************************************************************************/
00516 
00517 ACPI_RSDESC_SIZE
00518 AcpiRsSetResourceSource (
00519     AML_RESOURCE            *Aml,
00520     ACPI_RS_LENGTH          MinimumLength,
00521     ACPI_RESOURCE_SOURCE    *ResourceSource)
00522 {
00523     UINT8                   *AmlResourceSource;
00524     ACPI_RSDESC_SIZE        DescriptorLength;
00525 
00526 
00527     ACPI_FUNCTION_ENTRY ();
00528 
00529 
00530     DescriptorLength = MinimumLength;
00531 
00532     /* Non-zero string length indicates presence of a ResourceSource */
00533 
00534     if (ResourceSource->StringLength)
00535     {
00536         /* Point to the end of the AML descriptor */
00537 
00538         AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
00539 
00540         /* Copy the ResourceSourceIndex */
00541 
00542         AmlResourceSource[0] = (UINT8) ResourceSource->Index;
00543 
00544         /* Copy the ResourceSource string */
00545 
00546         ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
00547             ResourceSource->StringPtr);
00548 
00549         /*
00550          * Add the length of the string (+ 1 for null terminator) to the
00551          * final descriptor length
00552          */
00553         DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
00554     }
00555 
00556     /* Return the new total length of the AML descriptor */
00557 
00558     return (DescriptorLength);
00559 }
00560 
00561 
00562 /*******************************************************************************
00563  *
00564  * FUNCTION:    AcpiRsGetPrtMethodData
00565  *
00566  * PARAMETERS:  Node            - Device node
00567  *              RetBuffer       - Pointer to a buffer structure for the
00568  *                                results
00569  *
00570  * RETURN:      Status
00571  *
00572  * DESCRIPTION: This function is called to get the _PRT value of an object
00573  *              contained in an object specified by the handle passed in
00574  *
00575  *              If the function fails an appropriate status will be returned
00576  *              and the contents of the callers buffer is undefined.
00577  *
00578  ******************************************************************************/
00579 
00580 ACPI_STATUS
00581 AcpiRsGetPrtMethodData (
00582     ACPI_NAMESPACE_NODE     *Node,
00583     ACPI_BUFFER             *RetBuffer)
00584 {
00585     ACPI_OPERAND_OBJECT     *ObjDesc;
00586     ACPI_STATUS             Status;
00587 
00588 
00589     ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
00590 
00591 
00592     /* Parameters guaranteed valid by caller */
00593 
00594     /* Execute the method, no parameters */
00595 
00596     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
00597                 ACPI_BTYPE_PACKAGE, &ObjDesc);
00598     if (ACPI_FAILURE (Status))
00599     {
00600         return_ACPI_STATUS (Status);
00601     }
00602 
00603     /*
00604      * Create a resource linked list from the byte stream buffer that comes
00605      * back from the _CRS method execution.
00606      */
00607     Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
00608 
00609     /* On exit, we must delete the object returned by EvaluateObject */
00610 
00611     AcpiUtRemoveReference (ObjDesc);
00612     return_ACPI_STATUS (Status);
00613 }
00614 
00615 
00616 /*******************************************************************************
00617  *
00618  * FUNCTION:    AcpiRsGetCrsMethodData
00619  *
00620  * PARAMETERS:  Node            - Device node
00621  *              RetBuffer       - Pointer to a buffer structure for the
00622  *                                results
00623  *
00624  * RETURN:      Status
00625  *
00626  * DESCRIPTION: This function is called to get the _CRS value of an object
00627  *              contained in an object specified by the handle passed in
00628  *
00629  *              If the function fails an appropriate status will be returned
00630  *              and the contents of the callers buffer is undefined.
00631  *
00632  ******************************************************************************/
00633 
00634 ACPI_STATUS
00635 AcpiRsGetCrsMethodData (
00636     ACPI_NAMESPACE_NODE     *Node,
00637     ACPI_BUFFER             *RetBuffer)
00638 {
00639     ACPI_OPERAND_OBJECT     *ObjDesc;
00640     ACPI_STATUS             Status;
00641 
00642 
00643     ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
00644 
00645 
00646     /* Parameters guaranteed valid by caller */
00647 
00648     /* Execute the method, no parameters */
00649 
00650     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
00651                 ACPI_BTYPE_BUFFER, &ObjDesc);
00652     if (ACPI_FAILURE (Status))
00653     {
00654         return_ACPI_STATUS (Status);
00655     }
00656 
00657     /*
00658      * Make the call to create a resource linked list from the
00659      * byte stream buffer that comes back from the _CRS method
00660      * execution.
00661      */
00662     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
00663 
00664     /* On exit, we must delete the object returned by evaluateObject */
00665 
00666     AcpiUtRemoveReference (ObjDesc);
00667     return_ACPI_STATUS (Status);
00668 }
00669 
00670 
00671 /*******************************************************************************
00672  *
00673  * FUNCTION:    AcpiRsGetPrsMethodData
00674  *
00675  * PARAMETERS:  Node            - Device node
00676  *              RetBuffer       - Pointer to a buffer structure for the
00677  *                                results
00678  *
00679  * RETURN:      Status
00680  *
00681  * DESCRIPTION: This function is called to get the _PRS value of an object
00682  *              contained in an object specified by the handle passed in
00683  *
00684  *              If the function fails an appropriate status will be returned
00685  *              and the contents of the callers buffer is undefined.
00686  *
00687  ******************************************************************************/
00688 
00689 ACPI_STATUS
00690 AcpiRsGetPrsMethodData (
00691     ACPI_NAMESPACE_NODE     *Node,
00692     ACPI_BUFFER             *RetBuffer)
00693 {
00694     ACPI_OPERAND_OBJECT     *ObjDesc;
00695     ACPI_STATUS             Status;
00696 
00697 
00698     ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
00699 
00700 
00701     /* Parameters guaranteed valid by caller */
00702 
00703     /* Execute the method, no parameters */
00704 
00705     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
00706                 ACPI_BTYPE_BUFFER, &ObjDesc);
00707     if (ACPI_FAILURE (Status))
00708     {
00709         return_ACPI_STATUS (Status);
00710     }
00711 
00712     /*
00713      * Make the call to create a resource linked list from the
00714      * byte stream buffer that comes back from the _CRS method
00715      * execution.
00716      */
00717     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
00718 
00719     /* On exit, we must delete the object returned by evaluateObject */
00720 
00721     AcpiUtRemoveReference (ObjDesc);
00722     return_ACPI_STATUS (Status);
00723 }
00724 
00725 
00726 /*******************************************************************************
00727  *
00728  * FUNCTION:    AcpiRsGetMethodData
00729  *
00730  * PARAMETERS:  Handle          - Handle to the containing object
00731  *              Path            - Path to method, relative to Handle
00732  *              RetBuffer       - Pointer to a buffer structure for the
00733  *                                results
00734  *
00735  * RETURN:      Status
00736  *
00737  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
00738  *              object contained in an object specified by the handle passed in
00739  *
00740  *              If the function fails an appropriate status will be returned
00741  *              and the contents of the callers buffer is undefined.
00742  *
00743  ******************************************************************************/
00744 
00745 ACPI_STATUS
00746 AcpiRsGetMethodData (
00747     ACPI_HANDLE             Handle,
00748     char                    *Path,
00749     ACPI_BUFFER             *RetBuffer)
00750 {
00751     ACPI_OPERAND_OBJECT     *ObjDesc;
00752     ACPI_STATUS             Status;
00753 
00754 
00755     ACPI_FUNCTION_TRACE (RsGetMethodData);
00756 
00757 
00758     /* Parameters guaranteed valid by caller */
00759 
00760     /* Execute the method, no parameters */
00761 
00762     Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
00763     if (ACPI_FAILURE (Status))
00764     {
00765         return_ACPI_STATUS (Status);
00766     }
00767 
00768     /*
00769      * Make the call to create a resource linked list from the
00770      * byte stream buffer that comes back from the method
00771      * execution.
00772      */
00773     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
00774 
00775     /* On exit, we must delete the object returned by EvaluateObject */
00776 
00777     AcpiUtRemoveReference (ObjDesc);
00778     return_ACPI_STATUS (Status);
00779 }
00780 
00781 
00782 /*******************************************************************************
00783  *
00784  * FUNCTION:    AcpiRsSetSrsMethodData
00785  *
00786  * PARAMETERS:  Node            - Device node
00787  *              InBuffer        - Pointer to a buffer structure of the
00788  *                                parameter
00789  *
00790  * RETURN:      Status
00791  *
00792  * DESCRIPTION: This function is called to set the _SRS of an object contained
00793  *              in an object specified by the handle passed in
00794  *
00795  *              If the function fails an appropriate status will be returned
00796  *              and the contents of the callers buffer is undefined.
00797  *
00798  * Note: Parameters guaranteed valid by caller
00799  *
00800  ******************************************************************************/
00801 
00802 ACPI_STATUS
00803 AcpiRsSetSrsMethodData (
00804     ACPI_NAMESPACE_NODE     *Node,
00805     ACPI_BUFFER             *InBuffer)
00806 {
00807     ACPI_EVALUATE_INFO      *Info;
00808     ACPI_OPERAND_OBJECT     *Args[2];
00809     ACPI_STATUS             Status;
00810     ACPI_BUFFER             Buffer;
00811 
00812 
00813     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
00814 
00815 
00816     /* Allocate and initialize the evaluation information block */
00817 
00818     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
00819     if (!Info)
00820     {
00821         return_ACPI_STATUS (AE_NO_MEMORY);
00822     }
00823 
00824     Info->PrefixNode = Node;
00825     Info->Pathname = METHOD_NAME__SRS;
00826     Info->Parameters = Args;
00827     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
00828 
00829     /*
00830      * The InBuffer parameter will point to a linked list of
00831      * resource parameters. It needs to be formatted into a
00832      * byte stream to be sent in as an input parameter to _SRS
00833      *
00834      * Convert the linked list into a byte stream
00835      */
00836     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
00837     Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
00838     if (ACPI_FAILURE (Status))
00839     {
00840         goto Cleanup;
00841     }
00842 
00843     /* Create and initialize the method parameter object */
00844 
00845     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
00846     if (!Args[0])
00847     {
00848         /*
00849          * Must free the buffer allocated above (otherwise it is freed
00850          * later)
00851          */
00852         ACPI_FREE (Buffer.Pointer);
00853         Status = AE_NO_MEMORY;
00854         goto Cleanup;
00855     }
00856 
00857     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
00858     Args[0]->Buffer.Pointer = Buffer.Pointer;
00859     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
00860     Args[1] = NULL;
00861 
00862     /* Execute the method, no return value is expected */
00863 
00864     Status = AcpiNsEvaluate (Info);
00865 
00866     /* Clean up and return the status from AcpiNsEvaluate */
00867 
00868     AcpiUtRemoveReference (Args[0]);
00869 
00870 Cleanup:
00871     ACPI_FREE (Info);
00872     return_ACPI_STATUS (Status);
00873 }
00874 

Generated on Fri May 25 2012 04:25:39 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.