Home | History | Annotate | Line # | Download | only in utilities
utids.c revision 1.1.1.2.24.1
      1           1.1  jruoho /******************************************************************************
      2           1.1  jruoho  *
      3           1.1  jruoho  * Module Name: utids - support for device IDs - HID, UID, CID
      4           1.1  jruoho  *
      5           1.1  jruoho  *****************************************************************************/
      6           1.1  jruoho 
      7       1.1.1.2  jruoho /*
      8  1.1.1.2.24.1   rmind  * Copyright (C) 2000 - 2013, Intel Corp.
      9           1.1  jruoho  * All rights reserved.
     10           1.1  jruoho  *
     11       1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     12       1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     13       1.1.1.2  jruoho  * are met:
     14       1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     15       1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     16       1.1.1.2  jruoho  *    without modification.
     17       1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     21       1.1.1.2  jruoho  *    binary redistribution.
     22       1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     24       1.1.1.2  jruoho  *    from this software without specific prior written permission.
     25       1.1.1.2  jruoho  *
     26       1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     27       1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1.1.2  jruoho  * Software Foundation.
     29       1.1.1.2  jruoho  *
     30       1.1.1.2  jruoho  * NO WARRANTY
     31       1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33       1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34       1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1.1.2  jruoho  */
     43           1.1  jruoho 
     44           1.1  jruoho #define __UTIDS_C__
     45           1.1  jruoho 
     46           1.1  jruoho #include "acpi.h"
     47           1.1  jruoho #include "accommon.h"
     48           1.1  jruoho #include "acinterp.h"
     49           1.1  jruoho 
     50           1.1  jruoho 
     51           1.1  jruoho #define _COMPONENT          ACPI_UTILITIES
     52           1.1  jruoho         ACPI_MODULE_NAME    ("utids")
     53           1.1  jruoho 
     54           1.1  jruoho 
     55           1.1  jruoho /*******************************************************************************
     56           1.1  jruoho  *
     57           1.1  jruoho  * FUNCTION:    AcpiUtExecute_HID
     58           1.1  jruoho  *
     59           1.1  jruoho  * PARAMETERS:  DeviceNode          - Node for the device
     60           1.1  jruoho  *              ReturnId            - Where the string HID is returned
     61           1.1  jruoho  *
     62           1.1  jruoho  * RETURN:      Status
     63           1.1  jruoho  *
     64           1.1  jruoho  * DESCRIPTION: Executes the _HID control method that returns the hardware
     65           1.1  jruoho  *              ID of the device. The HID is either an 32-bit encoded EISAID
     66           1.1  jruoho  *              Integer or a String. A string is always returned. An EISAID
     67           1.1  jruoho  *              is converted to a string.
     68           1.1  jruoho  *
     69           1.1  jruoho  *              NOTE: Internal function, no parameter validation
     70           1.1  jruoho  *
     71           1.1  jruoho  ******************************************************************************/
     72           1.1  jruoho 
     73           1.1  jruoho ACPI_STATUS
     74           1.1  jruoho AcpiUtExecute_HID (
     75           1.1  jruoho     ACPI_NAMESPACE_NODE     *DeviceNode,
     76  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      **ReturnId)
     77           1.1  jruoho {
     78           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
     79  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      *Hid;
     80           1.1  jruoho     UINT32                  Length;
     81           1.1  jruoho     ACPI_STATUS             Status;
     82           1.1  jruoho 
     83           1.1  jruoho 
     84           1.1  jruoho     ACPI_FUNCTION_TRACE (UtExecute_HID);
     85           1.1  jruoho 
     86           1.1  jruoho 
     87           1.1  jruoho     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
     88           1.1  jruoho                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
     89           1.1  jruoho     if (ACPI_FAILURE (Status))
     90           1.1  jruoho     {
     91           1.1  jruoho         return_ACPI_STATUS (Status);
     92           1.1  jruoho     }
     93           1.1  jruoho 
     94           1.1  jruoho     /* Get the size of the String to be returned, includes null terminator */
     95           1.1  jruoho 
     96           1.1  jruoho     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
     97           1.1  jruoho     {
     98           1.1  jruoho         Length = ACPI_EISAID_STRING_SIZE;
     99           1.1  jruoho     }
    100           1.1  jruoho     else
    101           1.1  jruoho     {
    102           1.1  jruoho         Length = ObjDesc->String.Length + 1;
    103           1.1  jruoho     }
    104           1.1  jruoho 
    105           1.1  jruoho     /* Allocate a buffer for the HID */
    106           1.1  jruoho 
    107  1.1.1.2.24.1   rmind     Hid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
    108           1.1  jruoho     if (!Hid)
    109           1.1  jruoho     {
    110           1.1  jruoho         Status = AE_NO_MEMORY;
    111           1.1  jruoho         goto Cleanup;
    112           1.1  jruoho     }
    113           1.1  jruoho 
    114  1.1.1.2.24.1   rmind     /* Area for the string starts after PNP_DEVICE_ID struct */
    115           1.1  jruoho 
    116  1.1.1.2.24.1   rmind     Hid->String = ACPI_ADD_PTR (char, Hid, sizeof (ACPI_PNP_DEVICE_ID));
    117           1.1  jruoho 
    118           1.1  jruoho     /* Convert EISAID to a string or simply copy existing string */
    119           1.1  jruoho 
    120           1.1  jruoho     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
    121           1.1  jruoho     {
    122           1.1  jruoho         AcpiExEisaIdToString (Hid->String, ObjDesc->Integer.Value);
    123           1.1  jruoho     }
    124           1.1  jruoho     else
    125           1.1  jruoho     {
    126       1.1.1.2  jruoho         ACPI_STRCPY (Hid->String, ObjDesc->String.Pointer);
    127           1.1  jruoho     }
    128           1.1  jruoho 
    129           1.1  jruoho     Hid->Length = Length;
    130           1.1  jruoho     *ReturnId = Hid;
    131           1.1  jruoho 
    132           1.1  jruoho 
    133           1.1  jruoho Cleanup:
    134           1.1  jruoho 
    135           1.1  jruoho     /* On exit, we must delete the return object */
    136           1.1  jruoho 
    137           1.1  jruoho     AcpiUtRemoveReference (ObjDesc);
    138           1.1  jruoho     return_ACPI_STATUS (Status);
    139           1.1  jruoho }
    140           1.1  jruoho 
    141           1.1  jruoho 
    142           1.1  jruoho /*******************************************************************************
    143           1.1  jruoho  *
    144  1.1.1.2.24.1   rmind  * FUNCTION:    AcpiUtExecute_SUB
    145  1.1.1.2.24.1   rmind  *
    146  1.1.1.2.24.1   rmind  * PARAMETERS:  DeviceNode          - Node for the device
    147  1.1.1.2.24.1   rmind  *              ReturnId            - Where the _SUB is returned
    148  1.1.1.2.24.1   rmind  *
    149  1.1.1.2.24.1   rmind  * RETURN:      Status
    150  1.1.1.2.24.1   rmind  *
    151  1.1.1.2.24.1   rmind  * DESCRIPTION: Executes the _SUB control method that returns the subsystem
    152  1.1.1.2.24.1   rmind  *              ID of the device. The _SUB value is always a string containing
    153  1.1.1.2.24.1   rmind  *              either a valid PNP or ACPI ID.
    154  1.1.1.2.24.1   rmind  *
    155  1.1.1.2.24.1   rmind  *              NOTE: Internal function, no parameter validation
    156  1.1.1.2.24.1   rmind  *
    157  1.1.1.2.24.1   rmind  ******************************************************************************/
    158  1.1.1.2.24.1   rmind 
    159  1.1.1.2.24.1   rmind ACPI_STATUS
    160  1.1.1.2.24.1   rmind AcpiUtExecute_SUB (
    161  1.1.1.2.24.1   rmind     ACPI_NAMESPACE_NODE     *DeviceNode,
    162  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      **ReturnId)
    163  1.1.1.2.24.1   rmind {
    164  1.1.1.2.24.1   rmind     ACPI_OPERAND_OBJECT     *ObjDesc;
    165  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      *Sub;
    166  1.1.1.2.24.1   rmind     UINT32                  Length;
    167  1.1.1.2.24.1   rmind     ACPI_STATUS             Status;
    168  1.1.1.2.24.1   rmind 
    169  1.1.1.2.24.1   rmind 
    170  1.1.1.2.24.1   rmind     ACPI_FUNCTION_TRACE (UtExecute_SUB);
    171  1.1.1.2.24.1   rmind 
    172  1.1.1.2.24.1   rmind 
    173  1.1.1.2.24.1   rmind     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__SUB,
    174  1.1.1.2.24.1   rmind                 ACPI_BTYPE_STRING, &ObjDesc);
    175  1.1.1.2.24.1   rmind     if (ACPI_FAILURE (Status))
    176  1.1.1.2.24.1   rmind     {
    177  1.1.1.2.24.1   rmind         return_ACPI_STATUS (Status);
    178  1.1.1.2.24.1   rmind     }
    179  1.1.1.2.24.1   rmind 
    180  1.1.1.2.24.1   rmind     /* Get the size of the String to be returned, includes null terminator */
    181  1.1.1.2.24.1   rmind 
    182  1.1.1.2.24.1   rmind     Length = ObjDesc->String.Length + 1;
    183  1.1.1.2.24.1   rmind 
    184  1.1.1.2.24.1   rmind     /* Allocate a buffer for the SUB */
    185  1.1.1.2.24.1   rmind 
    186  1.1.1.2.24.1   rmind     Sub = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
    187  1.1.1.2.24.1   rmind     if (!Sub)
    188  1.1.1.2.24.1   rmind     {
    189  1.1.1.2.24.1   rmind         Status = AE_NO_MEMORY;
    190  1.1.1.2.24.1   rmind         goto Cleanup;
    191  1.1.1.2.24.1   rmind     }
    192  1.1.1.2.24.1   rmind 
    193  1.1.1.2.24.1   rmind     /* Area for the string starts after PNP_DEVICE_ID struct */
    194  1.1.1.2.24.1   rmind 
    195  1.1.1.2.24.1   rmind     Sub->String = ACPI_ADD_PTR (char, Sub, sizeof (ACPI_PNP_DEVICE_ID));
    196  1.1.1.2.24.1   rmind 
    197  1.1.1.2.24.1   rmind     /* Simply copy existing string */
    198  1.1.1.2.24.1   rmind 
    199  1.1.1.2.24.1   rmind     ACPI_STRCPY (Sub->String, ObjDesc->String.Pointer);
    200  1.1.1.2.24.1   rmind     Sub->Length = Length;
    201  1.1.1.2.24.1   rmind     *ReturnId = Sub;
    202  1.1.1.2.24.1   rmind 
    203  1.1.1.2.24.1   rmind 
    204  1.1.1.2.24.1   rmind Cleanup:
    205  1.1.1.2.24.1   rmind 
    206  1.1.1.2.24.1   rmind     /* On exit, we must delete the return object */
    207  1.1.1.2.24.1   rmind 
    208  1.1.1.2.24.1   rmind     AcpiUtRemoveReference (ObjDesc);
    209  1.1.1.2.24.1   rmind     return_ACPI_STATUS (Status);
    210  1.1.1.2.24.1   rmind }
    211  1.1.1.2.24.1   rmind 
    212  1.1.1.2.24.1   rmind 
    213  1.1.1.2.24.1   rmind /*******************************************************************************
    214  1.1.1.2.24.1   rmind  *
    215           1.1  jruoho  * FUNCTION:    AcpiUtExecute_UID
    216           1.1  jruoho  *
    217           1.1  jruoho  * PARAMETERS:  DeviceNode          - Node for the device
    218           1.1  jruoho  *              ReturnId            - Where the string UID is returned
    219           1.1  jruoho  *
    220           1.1  jruoho  * RETURN:      Status
    221           1.1  jruoho  *
    222           1.1  jruoho  * DESCRIPTION: Executes the _UID control method that returns the unique
    223           1.1  jruoho  *              ID of the device. The UID is either a 64-bit Integer (NOT an
    224           1.1  jruoho  *              EISAID) or a string. Always returns a string. A 64-bit integer
    225           1.1  jruoho  *              is converted to a decimal string.
    226           1.1  jruoho  *
    227           1.1  jruoho  *              NOTE: Internal function, no parameter validation
    228           1.1  jruoho  *
    229           1.1  jruoho  ******************************************************************************/
    230           1.1  jruoho 
    231           1.1  jruoho ACPI_STATUS
    232           1.1  jruoho AcpiUtExecute_UID (
    233           1.1  jruoho     ACPI_NAMESPACE_NODE     *DeviceNode,
    234  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      **ReturnId)
    235           1.1  jruoho {
    236           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    237  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID      *Uid;
    238           1.1  jruoho     UINT32                  Length;
    239           1.1  jruoho     ACPI_STATUS             Status;
    240           1.1  jruoho 
    241           1.1  jruoho 
    242           1.1  jruoho     ACPI_FUNCTION_TRACE (UtExecute_UID);
    243           1.1  jruoho 
    244           1.1  jruoho 
    245           1.1  jruoho     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
    246           1.1  jruoho                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
    247           1.1  jruoho     if (ACPI_FAILURE (Status))
    248           1.1  jruoho     {
    249           1.1  jruoho         return_ACPI_STATUS (Status);
    250           1.1  jruoho     }
    251           1.1  jruoho 
    252           1.1  jruoho     /* Get the size of the String to be returned, includes null terminator */
    253           1.1  jruoho 
    254           1.1  jruoho     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
    255           1.1  jruoho     {
    256           1.1  jruoho         Length = ACPI_MAX64_DECIMAL_DIGITS + 1;
    257           1.1  jruoho     }
    258           1.1  jruoho     else
    259           1.1  jruoho     {
    260           1.1  jruoho         Length = ObjDesc->String.Length + 1;
    261           1.1  jruoho     }
    262           1.1  jruoho 
    263           1.1  jruoho     /* Allocate a buffer for the UID */
    264           1.1  jruoho 
    265  1.1.1.2.24.1   rmind     Uid = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PNP_DEVICE_ID) + (ACPI_SIZE) Length);
    266           1.1  jruoho     if (!Uid)
    267           1.1  jruoho     {
    268           1.1  jruoho         Status = AE_NO_MEMORY;
    269           1.1  jruoho         goto Cleanup;
    270           1.1  jruoho     }
    271           1.1  jruoho 
    272  1.1.1.2.24.1   rmind     /* Area for the string starts after PNP_DEVICE_ID struct */
    273           1.1  jruoho 
    274  1.1.1.2.24.1   rmind     Uid->String = ACPI_ADD_PTR (char, Uid, sizeof (ACPI_PNP_DEVICE_ID));
    275           1.1  jruoho 
    276           1.1  jruoho     /* Convert an Integer to string, or just copy an existing string */
    277           1.1  jruoho 
    278           1.1  jruoho     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
    279           1.1  jruoho     {
    280           1.1  jruoho         AcpiExIntegerToString (Uid->String, ObjDesc->Integer.Value);
    281           1.1  jruoho     }
    282           1.1  jruoho     else
    283           1.1  jruoho     {
    284       1.1.1.2  jruoho         ACPI_STRCPY (Uid->String, ObjDesc->String.Pointer);
    285           1.1  jruoho     }
    286           1.1  jruoho 
    287           1.1  jruoho     Uid->Length = Length;
    288           1.1  jruoho     *ReturnId = Uid;
    289           1.1  jruoho 
    290           1.1  jruoho 
    291           1.1  jruoho Cleanup:
    292           1.1  jruoho 
    293           1.1  jruoho     /* On exit, we must delete the return object */
    294           1.1  jruoho 
    295           1.1  jruoho     AcpiUtRemoveReference (ObjDesc);
    296           1.1  jruoho     return_ACPI_STATUS (Status);
    297           1.1  jruoho }
    298           1.1  jruoho 
    299           1.1  jruoho 
    300           1.1  jruoho /*******************************************************************************
    301           1.1  jruoho  *
    302           1.1  jruoho  * FUNCTION:    AcpiUtExecute_CID
    303           1.1  jruoho  *
    304           1.1  jruoho  * PARAMETERS:  DeviceNode          - Node for the device
    305           1.1  jruoho  *              ReturnCidList       - Where the CID list is returned
    306           1.1  jruoho  *
    307           1.1  jruoho  * RETURN:      Status, list of CID strings
    308           1.1  jruoho  *
    309           1.1  jruoho  * DESCRIPTION: Executes the _CID control method that returns one or more
    310           1.1  jruoho  *              compatible hardware IDs for the device.
    311           1.1  jruoho  *
    312           1.1  jruoho  *              NOTE: Internal function, no parameter validation
    313           1.1  jruoho  *
    314           1.1  jruoho  * A _CID method can return either a single compatible ID or a package of
    315           1.1  jruoho  * compatible IDs. Each compatible ID can be one of the following:
    316           1.1  jruoho  * 1) Integer (32 bit compressed EISA ID) or
    317           1.1  jruoho  * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
    318           1.1  jruoho  *
    319           1.1  jruoho  * The Integer CIDs are converted to string format by this function.
    320           1.1  jruoho  *
    321           1.1  jruoho  ******************************************************************************/
    322           1.1  jruoho 
    323           1.1  jruoho ACPI_STATUS
    324           1.1  jruoho AcpiUtExecute_CID (
    325           1.1  jruoho     ACPI_NAMESPACE_NODE     *DeviceNode,
    326  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID_LIST **ReturnCidList)
    327           1.1  jruoho {
    328           1.1  jruoho     ACPI_OPERAND_OBJECT     **CidObjects;
    329           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    330  1.1.1.2.24.1   rmind     ACPI_PNP_DEVICE_ID_LIST *CidList;
    331           1.1  jruoho     char                    *NextIdString;
    332           1.1  jruoho     UINT32                  StringAreaSize;
    333           1.1  jruoho     UINT32                  Length;
    334           1.1  jruoho     UINT32                  CidListSize;
    335           1.1  jruoho     ACPI_STATUS             Status;
    336           1.1  jruoho     UINT32                  Count;
    337           1.1  jruoho     UINT32                  i;
    338           1.1  jruoho 
    339           1.1  jruoho 
    340           1.1  jruoho     ACPI_FUNCTION_TRACE (UtExecute_CID);
    341           1.1  jruoho 
    342           1.1  jruoho 
    343           1.1  jruoho     /* Evaluate the _CID method for this device */
    344           1.1  jruoho 
    345           1.1  jruoho     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
    346           1.1  jruoho                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
    347           1.1  jruoho                 &ObjDesc);
    348           1.1  jruoho     if (ACPI_FAILURE (Status))
    349           1.1  jruoho     {
    350           1.1  jruoho         return_ACPI_STATUS (Status);
    351           1.1  jruoho     }
    352           1.1  jruoho 
    353           1.1  jruoho     /*
    354           1.1  jruoho      * Get the count and size of the returned _CIDs. _CID can return either
    355           1.1  jruoho      * a Package of Integers/Strings or a single Integer or String.
    356           1.1  jruoho      * Note: This section also validates that all CID elements are of the
    357           1.1  jruoho      * correct type (Integer or String).
    358           1.1  jruoho      */
    359           1.1  jruoho     if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
    360           1.1  jruoho     {
    361           1.1  jruoho         Count = ObjDesc->Package.Count;
    362           1.1  jruoho         CidObjects = ObjDesc->Package.Elements;
    363           1.1  jruoho     }
    364           1.1  jruoho     else /* Single Integer or String CID */
    365           1.1  jruoho     {
    366           1.1  jruoho         Count = 1;
    367           1.1  jruoho         CidObjects = &ObjDesc;
    368           1.1  jruoho     }
    369           1.1  jruoho 
    370           1.1  jruoho     StringAreaSize = 0;
    371           1.1  jruoho     for (i = 0; i < Count; i++)
    372           1.1  jruoho     {
    373           1.1  jruoho         /* String lengths include null terminator */
    374           1.1  jruoho 
    375           1.1  jruoho         switch (CidObjects[i]->Common.Type)
    376           1.1  jruoho         {
    377           1.1  jruoho         case ACPI_TYPE_INTEGER:
    378  1.1.1.2.24.1   rmind 
    379           1.1  jruoho             StringAreaSize += ACPI_EISAID_STRING_SIZE;
    380           1.1  jruoho             break;
    381           1.1  jruoho 
    382           1.1  jruoho         case ACPI_TYPE_STRING:
    383  1.1.1.2.24.1   rmind 
    384           1.1  jruoho             StringAreaSize += CidObjects[i]->String.Length + 1;
    385           1.1  jruoho             break;
    386           1.1  jruoho 
    387           1.1  jruoho         default:
    388  1.1.1.2.24.1   rmind 
    389           1.1  jruoho             Status = AE_TYPE;
    390           1.1  jruoho             goto Cleanup;
    391           1.1  jruoho         }
    392           1.1  jruoho     }
    393           1.1  jruoho 
    394           1.1  jruoho     /*
    395           1.1  jruoho      * Now that we know the length of the CIDs, allocate return buffer:
    396           1.1  jruoho      * 1) Size of the base structure +
    397  1.1.1.2.24.1   rmind      * 2) Size of the CID PNP_DEVICE_ID array +
    398           1.1  jruoho      * 3) Size of the actual CID strings
    399           1.1  jruoho      */
    400  1.1.1.2.24.1   rmind     CidListSize = sizeof (ACPI_PNP_DEVICE_ID_LIST) +
    401  1.1.1.2.24.1   rmind         ((Count - 1) * sizeof (ACPI_PNP_DEVICE_ID)) +
    402           1.1  jruoho         StringAreaSize;
    403           1.1  jruoho 
    404           1.1  jruoho     CidList = ACPI_ALLOCATE_ZEROED (CidListSize);
    405           1.1  jruoho     if (!CidList)
    406           1.1  jruoho     {
    407           1.1  jruoho         Status = AE_NO_MEMORY;
    408           1.1  jruoho         goto Cleanup;
    409           1.1  jruoho     }
    410           1.1  jruoho 
    411  1.1.1.2.24.1   rmind     /* Area for CID strings starts after the CID PNP_DEVICE_ID array */
    412           1.1  jruoho 
    413           1.1  jruoho     NextIdString = ACPI_CAST_PTR (char, CidList->Ids) +
    414  1.1.1.2.24.1   rmind         ((ACPI_SIZE) Count * sizeof (ACPI_PNP_DEVICE_ID));
    415           1.1  jruoho 
    416           1.1  jruoho     /* Copy/convert the CIDs to the return buffer */
    417           1.1  jruoho 
    418           1.1  jruoho     for (i = 0; i < Count; i++)
    419           1.1  jruoho     {
    420           1.1  jruoho         if (CidObjects[i]->Common.Type == ACPI_TYPE_INTEGER)
    421           1.1  jruoho         {
    422           1.1  jruoho             /* Convert the Integer (EISAID) CID to a string */
    423           1.1  jruoho 
    424           1.1  jruoho             AcpiExEisaIdToString (NextIdString, CidObjects[i]->Integer.Value);
    425           1.1  jruoho             Length = ACPI_EISAID_STRING_SIZE;
    426           1.1  jruoho         }
    427           1.1  jruoho         else /* ACPI_TYPE_STRING */
    428           1.1  jruoho         {
    429           1.1  jruoho             /* Copy the String CID from the returned object */
    430           1.1  jruoho 
    431       1.1.1.2  jruoho             ACPI_STRCPY (NextIdString, CidObjects[i]->String.Pointer);
    432           1.1  jruoho             Length = CidObjects[i]->String.Length + 1;
    433           1.1  jruoho         }
    434           1.1  jruoho 
    435           1.1  jruoho         CidList->Ids[i].String = NextIdString;
    436           1.1  jruoho         CidList->Ids[i].Length = Length;
    437           1.1  jruoho         NextIdString += Length;
    438           1.1  jruoho     }
    439           1.1  jruoho 
    440           1.1  jruoho     /* Finish the CID list */
    441           1.1  jruoho 
    442           1.1  jruoho     CidList->Count = Count;
    443           1.1  jruoho     CidList->ListSize = CidListSize;
    444           1.1  jruoho     *ReturnCidList = CidList;
    445           1.1  jruoho 
    446           1.1  jruoho 
    447           1.1  jruoho Cleanup:
    448           1.1  jruoho 
    449           1.1  jruoho     /* On exit, we must delete the _CID return object */
    450           1.1  jruoho 
    451           1.1  jruoho     AcpiUtRemoveReference (ObjDesc);
    452           1.1  jruoho     return_ACPI_STATUS (Status);
    453           1.1  jruoho }
    454