Home | History | Annotate | Line # | Download | only in disassembler
dmbuffer.c revision 1.2
      1  1.1    jruoho /*******************************************************************************
      2  1.1    jruoho  *
      3  1.1    jruoho  * Module Name: dmbuffer - AML disassembler, buffer and string support
      4  1.1    jruoho  *
      5  1.1    jruoho  ******************************************************************************/
      6  1.1    jruoho 
      7  1.2  christos /*
      8  1.2  christos  * Copyright (C) 2000 - 2015, Intel Corp.
      9  1.1    jruoho  * All rights reserved.
     10  1.1    jruoho  *
     11  1.2  christos  * Redistribution and use in source and binary forms, with or without
     12  1.2  christos  * modification, are permitted provided that the following conditions
     13  1.2  christos  * are met:
     14  1.2  christos  * 1. Redistributions of source code must retain the above copyright
     15  1.2  christos  *    notice, this list of conditions, and the following disclaimer,
     16  1.2  christos  *    without modification.
     17  1.2  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.2  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.2  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.2  christos  *    including a substantially similar Disclaimer requirement for further
     21  1.2  christos  *    binary redistribution.
     22  1.2  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.2  christos  *    of any contributors may be used to endorse or promote products derived
     24  1.2  christos  *    from this software without specific prior written permission.
     25  1.2  christos  *
     26  1.2  christos  * Alternatively, this software may be distributed under the terms of the
     27  1.2  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.2  christos  * Software Foundation.
     29  1.2  christos  *
     30  1.2  christos  * NO WARRANTY
     31  1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.2  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.2  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.2  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.2  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.2  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.2  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.2  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.2  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.2  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.2  christos  * POSSIBILITY OF SUCH DAMAGES.
     42  1.2  christos  */
     43  1.1    jruoho 
     44  1.1    jruoho #include "acpi.h"
     45  1.1    jruoho #include "accommon.h"
     46  1.2  christos #include "acutils.h"
     47  1.1    jruoho #include "acdisasm.h"
     48  1.1    jruoho #include "acparser.h"
     49  1.1    jruoho #include "amlcode.h"
     50  1.2  christos #include "acinterp.h"
     51  1.1    jruoho 
     52  1.1    jruoho 
     53  1.1    jruoho #ifdef ACPI_DISASSEMBLER
     54  1.1    jruoho 
     55  1.1    jruoho #define _COMPONENT          ACPI_CA_DEBUGGER
     56  1.1    jruoho         ACPI_MODULE_NAME    ("dmbuffer")
     57  1.1    jruoho 
     58  1.1    jruoho /* Local prototypes */
     59  1.1    jruoho 
     60  1.1    jruoho static void
     61  1.2  christos AcpiDmUuid (
     62  1.2  christos     ACPI_PARSE_OBJECT       *Op);
     63  1.2  christos 
     64  1.2  christos static void
     65  1.1    jruoho AcpiDmUnicode (
     66  1.1    jruoho     ACPI_PARSE_OBJECT       *Op);
     67  1.1    jruoho 
     68  1.1    jruoho static void
     69  1.2  christos AcpiDmGetHardwareIdType (
     70  1.1    jruoho     ACPI_PARSE_OBJECT       *Op);
     71  1.1    jruoho 
     72  1.2  christos static void
     73  1.2  christos AcpiDmPldBuffer (
     74  1.2  christos     UINT32                  Level,
     75  1.2  christos     UINT8                   *ByteData,
     76  1.2  christos     UINT32                  ByteCount);
     77  1.2  christos 
     78  1.2  christos 
     79  1.2  christos #define ACPI_BUFFER_BYTES_PER_LINE      8
     80  1.2  christos 
     81  1.2  christos 
     82  1.2  christos /* Strings for ToPld */
     83  1.2  christos 
     84  1.2  christos static const char *DmPanelList[] =
     85  1.2  christos {
     86  1.2  christos     "TOP",
     87  1.2  christos     "BOTTOM",
     88  1.2  christos     "LEFT",
     89  1.2  christos     "RIGHT",
     90  1.2  christos     "FRONT",
     91  1.2  christos     "BACK",
     92  1.2  christos     "UNKNOWN",
     93  1.2  christos     NULL
     94  1.2  christos };
     95  1.2  christos 
     96  1.2  christos static const char *DmVerticalPositionList[] =
     97  1.2  christos {
     98  1.2  christos     "UPPER",
     99  1.2  christos     "CENTER",
    100  1.2  christos     "LOWER",
    101  1.2  christos     NULL
    102  1.2  christos };
    103  1.2  christos 
    104  1.2  christos static const char *DmHorizontalPositionList[] =
    105  1.2  christos {
    106  1.2  christos     "LEFT",
    107  1.2  christos     "CENTER",
    108  1.2  christos     "RIGHT",
    109  1.2  christos     NULL
    110  1.2  christos };
    111  1.2  christos 
    112  1.2  christos static const char *DmShapeList[] =
    113  1.2  christos {
    114  1.2  christos     "ROUND",
    115  1.2  christos     "OVAL",
    116  1.2  christos     "SQUARE",
    117  1.2  christos     "VERTICALRECTANGLE",
    118  1.2  christos     "HORIZONTALRECTANGLE",
    119  1.2  christos     "VERTICALTRAPEZOID",
    120  1.2  christos     "HORIZONTALTRAPEZOID",
    121  1.2  christos     "UNKNOWN",
    122  1.2  christos     "CHAMFERED",
    123  1.2  christos     NULL
    124  1.2  christos };
    125  1.2  christos 
    126  1.1    jruoho 
    127  1.1    jruoho /*******************************************************************************
    128  1.1    jruoho  *
    129  1.1    jruoho  * FUNCTION:    AcpiDmDisasmByteList
    130  1.1    jruoho  *
    131  1.1    jruoho  * PARAMETERS:  Level               - Current source code indentation level
    132  1.1    jruoho  *              ByteData            - Pointer to the byte list
    133  1.1    jruoho  *              ByteCount           - Length of the byte list
    134  1.1    jruoho  *
    135  1.1    jruoho  * RETURN:      None
    136  1.1    jruoho  *
    137  1.1    jruoho  * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
    138  1.1    jruoho  *              with the hex buffer offset.
    139  1.1    jruoho  *
    140  1.1    jruoho  ******************************************************************************/
    141  1.1    jruoho 
    142  1.1    jruoho void
    143  1.1    jruoho AcpiDmDisasmByteList (
    144  1.1    jruoho     UINT32                  Level,
    145  1.1    jruoho     UINT8                   *ByteData,
    146  1.1    jruoho     UINT32                  ByteCount)
    147  1.1    jruoho {
    148  1.1    jruoho     UINT32                  i;
    149  1.2  christos     UINT32                  j;
    150  1.2  christos     UINT32                  CurrentIndex;
    151  1.2  christos     UINT8                   BufChar;
    152  1.1    jruoho 
    153  1.1    jruoho 
    154  1.1    jruoho     if (!ByteCount)
    155  1.1    jruoho     {
    156  1.1    jruoho         return;
    157  1.1    jruoho     }
    158  1.1    jruoho 
    159  1.2  christos     for (i = 0; i < ByteCount; i += ACPI_BUFFER_BYTES_PER_LINE)
    160  1.2  christos     {
    161  1.2  christos         /* Line indent and offset prefix for each new line */
    162  1.2  christos 
    163  1.2  christos         AcpiDmIndent (Level);
    164  1.2  christos         if (ByteCount > ACPI_BUFFER_BYTES_PER_LINE)
    165  1.2  christos         {
    166  1.2  christos             AcpiOsPrintf ("/* %04X */ ", i);
    167  1.2  christos         }
    168  1.1    jruoho 
    169  1.2  christos         /* Dump the actual hex values */
    170  1.1    jruoho 
    171  1.2  christos         for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++)
    172  1.1    jruoho         {
    173  1.2  christos             CurrentIndex = i + j;
    174  1.2  christos             if (CurrentIndex >= ByteCount)
    175  1.1    jruoho             {
    176  1.2  christos                 /* Dump fill spaces */
    177  1.2  christos 
    178  1.2  christos                 AcpiOsPrintf ("      ");
    179  1.2  christos                 continue;
    180  1.1    jruoho             }
    181  1.1    jruoho 
    182  1.2  christos             AcpiOsPrintf (" 0x%2.2X", ByteData[CurrentIndex]);
    183  1.2  christos 
    184  1.2  christos             /* Add comma if there are more bytes to display */
    185  1.2  christos 
    186  1.2  christos             if (CurrentIndex < (ByteCount - 1))
    187  1.1    jruoho             {
    188  1.2  christos                 AcpiOsPrintf (",");
    189  1.2  christos             }
    190  1.2  christos             else
    191  1.2  christos             {
    192  1.2  christos                 AcpiOsPrintf (" ");
    193  1.1    jruoho             }
    194  1.1    jruoho         }
    195  1.1    jruoho 
    196  1.2  christos         /* Dump the ASCII equivalents within a comment */
    197  1.1    jruoho 
    198  1.2  christos         AcpiOsPrintf ("  /* ");
    199  1.2  christos         for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++)
    200  1.2  christos         {
    201  1.2  christos             CurrentIndex = i + j;
    202  1.2  christos             if (CurrentIndex >= ByteCount)
    203  1.2  christos             {
    204  1.2  christos                 break;
    205  1.2  christos             }
    206  1.1    jruoho 
    207  1.2  christos             BufChar = ByteData[CurrentIndex];
    208  1.2  christos             if (ACPI_IS_PRINT (BufChar))
    209  1.2  christos             {
    210  1.2  christos                 AcpiOsPrintf ("%c", BufChar);
    211  1.2  christos             }
    212  1.2  christos             else
    213  1.2  christos             {
    214  1.2  christos                 AcpiOsPrintf (".");
    215  1.2  christos             }
    216  1.1    jruoho         }
    217  1.1    jruoho 
    218  1.2  christos         /* Finished with this line */
    219  1.2  christos 
    220  1.2  christos         AcpiOsPrintf (" */\n");
    221  1.1    jruoho     }
    222  1.1    jruoho }
    223  1.1    jruoho 
    224  1.1    jruoho 
    225  1.1    jruoho /*******************************************************************************
    226  1.1    jruoho  *
    227  1.1    jruoho  * FUNCTION:    AcpiDmByteList
    228  1.1    jruoho  *
    229  1.1    jruoho  * PARAMETERS:  Info            - Parse tree walk info
    230  1.1    jruoho  *              Op              - Byte list op
    231  1.1    jruoho  *
    232  1.1    jruoho  * RETURN:      None
    233  1.1    jruoho  *
    234  1.1    jruoho  * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
    235  1.1    jruoho  *              Buffer type must be already set in the Op DisasmOpcode.
    236  1.1    jruoho  *
    237  1.1    jruoho  ******************************************************************************/
    238  1.1    jruoho 
    239  1.1    jruoho void
    240  1.1    jruoho AcpiDmByteList (
    241  1.1    jruoho     ACPI_OP_WALK_INFO       *Info,
    242  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    243  1.1    jruoho {
    244  1.1    jruoho     UINT8                   *ByteData;
    245  1.1    jruoho     UINT32                  ByteCount;
    246  1.1    jruoho 
    247  1.1    jruoho 
    248  1.1    jruoho     ByteData = Op->Named.Data;
    249  1.1    jruoho     ByteCount = (UINT32) Op->Common.Value.Integer;
    250  1.1    jruoho 
    251  1.1    jruoho     /*
    252  1.1    jruoho      * The byte list belongs to a buffer, and can be produced by either
    253  1.1    jruoho      * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
    254  1.1    jruoho      */
    255  1.1    jruoho     switch (Op->Common.Parent->Common.DisasmOpcode)
    256  1.1    jruoho     {
    257  1.1    jruoho     case ACPI_DASM_RESOURCE:
    258  1.1    jruoho 
    259  1.1    jruoho         AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount);
    260  1.1    jruoho         break;
    261  1.1    jruoho 
    262  1.1    jruoho     case ACPI_DASM_STRING:
    263  1.1    jruoho 
    264  1.1    jruoho         AcpiDmIndent (Info->Level);
    265  1.2  christos         AcpiUtPrintString ((char *) ByteData, ACPI_UINT16_MAX);
    266  1.1    jruoho         AcpiOsPrintf ("\n");
    267  1.1    jruoho         break;
    268  1.1    jruoho 
    269  1.2  christos     case ACPI_DASM_UUID:
    270  1.2  christos 
    271  1.2  christos         AcpiDmUuid (Op);
    272  1.2  christos         break;
    273  1.2  christos 
    274  1.1    jruoho     case ACPI_DASM_UNICODE:
    275  1.1    jruoho 
    276  1.1    jruoho         AcpiDmUnicode (Op);
    277  1.1    jruoho         break;
    278  1.1    jruoho 
    279  1.2  christos     case ACPI_DASM_PLD_METHOD:
    280  1.2  christos #if 0
    281  1.2  christos         AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
    282  1.2  christos #endif
    283  1.2  christos         AcpiDmPldBuffer (Info->Level, ByteData, ByteCount);
    284  1.2  christos         break;
    285  1.2  christos 
    286  1.1    jruoho     case ACPI_DASM_BUFFER:
    287  1.1    jruoho     default:
    288  1.1    jruoho         /*
    289  1.1    jruoho          * Not a resource, string, or unicode string.
    290  1.1    jruoho          * Just dump the buffer
    291  1.1    jruoho          */
    292  1.1    jruoho         AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
    293  1.1    jruoho         break;
    294  1.1    jruoho     }
    295  1.1    jruoho }
    296  1.1    jruoho 
    297  1.1    jruoho 
    298  1.1    jruoho /*******************************************************************************
    299  1.1    jruoho  *
    300  1.2  christos  * FUNCTION:    AcpiDmIsUuidBuffer
    301  1.2  christos  *
    302  1.2  christos  * PARAMETERS:  Op              - Buffer Object to be examined
    303  1.2  christos  *
    304  1.2  christos  * RETURN:      TRUE if buffer contains a UUID
    305  1.2  christos  *
    306  1.2  christos  * DESCRIPTION: Determine if a buffer Op contains a UUID
    307  1.2  christos  *
    308  1.2  christos  * To help determine whether the buffer is a UUID versus a raw data buffer,
    309  1.2  christos  * there a are a couple bytes we can look at:
    310  1.2  christos  *
    311  1.2  christos  *    xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
    312  1.2  christos  *
    313  1.2  christos  * The variant covered by the UUID specification is indicated by the two most
    314  1.2  christos  * significant bits of N being 1 0 (i.e., the hexadecimal N will always be
    315  1.2  christos  * 8, 9, A, or B).
    316  1.2  christos  *
    317  1.2  christos  * The variant covered by the UUID specification has five versions. For this
    318  1.2  christos  * variant, the four bits of M indicates the UUID version (i.e., the
    319  1.2  christos  * hexadecimal M will be either 1, 2, 3, 4, or 5).
    320  1.2  christos  *
    321  1.2  christos  ******************************************************************************/
    322  1.2  christos 
    323  1.2  christos BOOLEAN
    324  1.2  christos AcpiDmIsUuidBuffer (
    325  1.2  christos     ACPI_PARSE_OBJECT       *Op)
    326  1.2  christos {
    327  1.2  christos     UINT8                   *ByteData;
    328  1.2  christos     UINT32                  ByteCount;
    329  1.2  christos     ACPI_PARSE_OBJECT       *SizeOp;
    330  1.2  christos     ACPI_PARSE_OBJECT       *NextOp;
    331  1.2  christos 
    332  1.2  christos 
    333  1.2  christos     /* Buffer size is the buffer argument */
    334  1.2  christos 
    335  1.2  christos     SizeOp = Op->Common.Value.Arg;
    336  1.2  christos 
    337  1.2  christos     /* Next, the initializer byte list to examine */
    338  1.2  christos 
    339  1.2  christos     NextOp = SizeOp->Common.Next;
    340  1.2  christos     if (!NextOp)
    341  1.2  christos     {
    342  1.2  christos         return (FALSE);
    343  1.2  christos     }
    344  1.2  christos 
    345  1.2  christos     /* Extract the byte list info */
    346  1.2  christos 
    347  1.2  christos     ByteData = NextOp->Named.Data;
    348  1.2  christos     ByteCount = (UINT32) NextOp->Common.Value.Integer;
    349  1.2  christos 
    350  1.2  christos     /* Byte count must be exactly 16 */
    351  1.2  christos 
    352  1.2  christos     if (ByteCount != UUID_BUFFER_LENGTH)
    353  1.2  christos     {
    354  1.2  christos         return (FALSE);
    355  1.2  christos     }
    356  1.2  christos 
    357  1.2  christos     /* Check for valid "M" and "N" values (see function header above) */
    358  1.2  christos 
    359  1.2  christos     if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */
    360  1.2  christos         ((ByteData[7] & 0xF0) > 0x50)  ||
    361  1.2  christos         ((ByteData[8] & 0xF0) < 0x80)  || /* N={8,9,A,B} */
    362  1.2  christos         ((ByteData[8] & 0xF0) > 0xB0))
    363  1.2  christos     {
    364  1.2  christos         return (FALSE);
    365  1.2  christos     }
    366  1.2  christos 
    367  1.2  christos     /* Ignore the Size argument in the disassembly of this buffer op */
    368  1.2  christos 
    369  1.2  christos     SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
    370  1.2  christos     return (TRUE);
    371  1.2  christos }
    372  1.2  christos 
    373  1.2  christos 
    374  1.2  christos /*******************************************************************************
    375  1.2  christos  *
    376  1.2  christos  * FUNCTION:    AcpiDmUuid
    377  1.2  christos  *
    378  1.2  christos  * PARAMETERS:  Op              - Byte List op containing a UUID
    379  1.2  christos  *
    380  1.2  christos  * RETURN:      None
    381  1.2  christos  *
    382  1.2  christos  * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string.
    383  1.2  christos  *
    384  1.2  christos  * Output Format:
    385  1.2  christos  * In its canonical form, the UUID is represented by a string containing 32
    386  1.2  christos  * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens.
    387  1.2  christos  * The complete form is 8-4-4-4-12 for a total of 36 characters (32
    388  1.2  christos  * alphanumeric characters representing hex digits and 4 hyphens). In bytes,
    389  1.2  christos  * 4-2-2-2-6. Example:
    390  1.2  christos  *
    391  1.2  christos  *    ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644")
    392  1.2  christos  *
    393  1.2  christos  ******************************************************************************/
    394  1.2  christos 
    395  1.2  christos static void
    396  1.2  christos AcpiDmUuid (
    397  1.2  christos     ACPI_PARSE_OBJECT       *Op)
    398  1.2  christos {
    399  1.2  christos     UINT8                   *Data;
    400  1.2  christos     const char              *Description;
    401  1.2  christos 
    402  1.2  christos 
    403  1.2  christos     Data = ACPI_CAST_PTR (UINT8, Op->Named.Data);
    404  1.2  christos 
    405  1.2  christos     /* Emit the 36-byte UUID string in the proper format/order */
    406  1.2  christos 
    407  1.2  christos     AcpiOsPrintf (
    408  1.2  christos         "\"%2.2x%2.2x%2.2x%2.2x-"
    409  1.2  christos         "%2.2x%2.2x-"
    410  1.2  christos         "%2.2x%2.2x-"
    411  1.2  christos         "%2.2x%2.2x-"
    412  1.2  christos         "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")",
    413  1.2  christos         Data[3], Data[2], Data[1], Data[0],
    414  1.2  christos         Data[5], Data[4],
    415  1.2  christos         Data[7], Data[6],
    416  1.2  christos         Data[8], Data[9],
    417  1.2  christos         Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]);
    418  1.2  christos 
    419  1.2  christos     /* Dump the UUID description string if available */
    420  1.2  christos 
    421  1.2  christos     Description = AcpiAhMatchUuid (Data);
    422  1.2  christos     if (Description)
    423  1.2  christos     {
    424  1.2  christos         AcpiOsPrintf (" /* %s */", Description);
    425  1.2  christos     }
    426  1.2  christos }
    427  1.2  christos 
    428  1.2  christos 
    429  1.2  christos /*******************************************************************************
    430  1.2  christos  *
    431  1.1    jruoho  * FUNCTION:    AcpiDmIsUnicodeBuffer
    432  1.1    jruoho  *
    433  1.1    jruoho  * PARAMETERS:  Op              - Buffer Object to be examined
    434  1.1    jruoho  *
    435  1.1    jruoho  * RETURN:      TRUE if buffer contains a UNICODE string
    436  1.1    jruoho  *
    437  1.1    jruoho  * DESCRIPTION: Determine if a buffer Op contains a Unicode string
    438  1.1    jruoho  *
    439  1.1    jruoho  ******************************************************************************/
    440  1.1    jruoho 
    441  1.1    jruoho BOOLEAN
    442  1.1    jruoho AcpiDmIsUnicodeBuffer (
    443  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    444  1.1    jruoho {
    445  1.1    jruoho     UINT8                   *ByteData;
    446  1.1    jruoho     UINT32                  ByteCount;
    447  1.1    jruoho     UINT32                  WordCount;
    448  1.1    jruoho     ACPI_PARSE_OBJECT       *SizeOp;
    449  1.1    jruoho     ACPI_PARSE_OBJECT       *NextOp;
    450  1.1    jruoho     UINT32                  i;
    451  1.1    jruoho 
    452  1.1    jruoho 
    453  1.1    jruoho     /* Buffer size is the buffer argument */
    454  1.1    jruoho 
    455  1.1    jruoho     SizeOp = Op->Common.Value.Arg;
    456  1.1    jruoho 
    457  1.1    jruoho     /* Next, the initializer byte list to examine */
    458  1.1    jruoho 
    459  1.1    jruoho     NextOp = SizeOp->Common.Next;
    460  1.1    jruoho     if (!NextOp)
    461  1.1    jruoho     {
    462  1.1    jruoho         return (FALSE);
    463  1.1    jruoho     }
    464  1.1    jruoho 
    465  1.1    jruoho     /* Extract the byte list info */
    466  1.1    jruoho 
    467  1.1    jruoho     ByteData = NextOp->Named.Data;
    468  1.1    jruoho     ByteCount = (UINT32) NextOp->Common.Value.Integer;
    469  1.1    jruoho     WordCount = ACPI_DIV_2 (ByteCount);
    470  1.1    jruoho 
    471  1.1    jruoho     /*
    472  1.1    jruoho      * Unicode string must have an even number of bytes and last
    473  1.1    jruoho      * word must be zero
    474  1.1    jruoho      */
    475  1.1    jruoho     if ((!ByteCount)     ||
    476  1.1    jruoho          (ByteCount < 4) ||
    477  1.1    jruoho          (ByteCount & 1) ||
    478  1.1    jruoho         ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)
    479  1.1    jruoho     {
    480  1.1    jruoho         return (FALSE);
    481  1.1    jruoho     }
    482  1.1    jruoho 
    483  1.2  christos     /* For each word, 1st byte must be ascii (1-0x7F), 2nd byte must be zero */
    484  1.1    jruoho 
    485  1.1    jruoho     for (i = 0; i < (ByteCount - 2); i += 2)
    486  1.1    jruoho     {
    487  1.2  christos         if ((ByteData[i] == 0) ||
    488  1.2  christos             (ByteData[i] > 0x7F) ||
    489  1.1    jruoho             (ByteData[(ACPI_SIZE) i + 1] != 0))
    490  1.1    jruoho         {
    491  1.1    jruoho             return (FALSE);
    492  1.1    jruoho         }
    493  1.1    jruoho     }
    494  1.1    jruoho 
    495  1.1    jruoho     /* Ignore the Size argument in the disassembly of this buffer op */
    496  1.1    jruoho 
    497  1.1    jruoho     SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
    498  1.1    jruoho     return (TRUE);
    499  1.1    jruoho }
    500  1.1    jruoho 
    501  1.1    jruoho 
    502  1.1    jruoho /*******************************************************************************
    503  1.1    jruoho  *
    504  1.1    jruoho  * FUNCTION:    AcpiDmIsStringBuffer
    505  1.1    jruoho  *
    506  1.1    jruoho  * PARAMETERS:  Op              - Buffer Object to be examined
    507  1.1    jruoho  *
    508  1.1    jruoho  * RETURN:      TRUE if buffer contains a ASCII string, FALSE otherwise
    509  1.1    jruoho  *
    510  1.1    jruoho  * DESCRIPTION: Determine if a buffer Op contains a ASCII string
    511  1.1    jruoho  *
    512  1.1    jruoho  ******************************************************************************/
    513  1.1    jruoho 
    514  1.1    jruoho BOOLEAN
    515  1.1    jruoho AcpiDmIsStringBuffer (
    516  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    517  1.1    jruoho {
    518  1.1    jruoho     UINT8                   *ByteData;
    519  1.1    jruoho     UINT32                  ByteCount;
    520  1.1    jruoho     ACPI_PARSE_OBJECT       *SizeOp;
    521  1.1    jruoho     ACPI_PARSE_OBJECT       *NextOp;
    522  1.1    jruoho     UINT32                  i;
    523  1.1    jruoho 
    524  1.1    jruoho 
    525  1.1    jruoho     /* Buffer size is the buffer argument */
    526  1.1    jruoho 
    527  1.1    jruoho     SizeOp = Op->Common.Value.Arg;
    528  1.1    jruoho 
    529  1.1    jruoho     /* Next, the initializer byte list to examine */
    530  1.1    jruoho 
    531  1.1    jruoho     NextOp = SizeOp->Common.Next;
    532  1.1    jruoho     if (!NextOp)
    533  1.1    jruoho     {
    534  1.1    jruoho         return (FALSE);
    535  1.1    jruoho     }
    536  1.1    jruoho 
    537  1.1    jruoho     /* Extract the byte list info */
    538  1.1    jruoho 
    539  1.1    jruoho     ByteData = NextOp->Named.Data;
    540  1.1    jruoho     ByteCount = (UINT32) NextOp->Common.Value.Integer;
    541  1.1    jruoho 
    542  1.1    jruoho     /* Last byte must be the null terminator */
    543  1.1    jruoho 
    544  1.1    jruoho     if ((!ByteCount)     ||
    545  1.1    jruoho          (ByteCount < 2) ||
    546  1.1    jruoho          (ByteData[ByteCount-1] != 0))
    547  1.1    jruoho     {
    548  1.1    jruoho         return (FALSE);
    549  1.1    jruoho     }
    550  1.1    jruoho 
    551  1.1    jruoho     for (i = 0; i < (ByteCount - 1); i++)
    552  1.1    jruoho     {
    553  1.1    jruoho         /* TBD: allow some escapes (non-ascii chars).
    554  1.1    jruoho          * they will be handled in the string output routine
    555  1.1    jruoho          */
    556  1.1    jruoho 
    557  1.1    jruoho         if (!ACPI_IS_PRINT (ByteData[i]))
    558  1.1    jruoho         {
    559  1.1    jruoho             return (FALSE);
    560  1.1    jruoho         }
    561  1.1    jruoho     }
    562  1.1    jruoho 
    563  1.1    jruoho     return (TRUE);
    564  1.1    jruoho }
    565  1.1    jruoho 
    566  1.1    jruoho 
    567  1.1    jruoho /*******************************************************************************
    568  1.1    jruoho  *
    569  1.2  christos  * FUNCTION:    AcpiDmIsPldBuffer
    570  1.2  christos  *
    571  1.2  christos  * PARAMETERS:  Op                  - Buffer Object to be examined
    572  1.2  christos  *
    573  1.2  christos  * RETURN:      TRUE if buffer contains a ASCII string, FALSE otherwise
    574  1.2  christos  *
    575  1.2  christos  * DESCRIPTION: Determine if a buffer Op contains a _PLD structure
    576  1.2  christos  *
    577  1.2  christos  ******************************************************************************/
    578  1.2  christos 
    579  1.2  christos BOOLEAN
    580  1.2  christos AcpiDmIsPldBuffer (
    581  1.2  christos     ACPI_PARSE_OBJECT       *Op)
    582  1.2  christos {
    583  1.2  christos     ACPI_NAMESPACE_NODE     *Node;
    584  1.2  christos     ACPI_PARSE_OBJECT       *SizeOp;
    585  1.2  christos     ACPI_PARSE_OBJECT       *ParentOp;
    586  1.2  christos 
    587  1.2  christos 
    588  1.2  christos     /* Buffer size is the buffer argument */
    589  1.2  christos 
    590  1.2  christos     SizeOp = Op->Common.Value.Arg;
    591  1.2  christos 
    592  1.2  christos     ParentOp = Op->Common.Parent;
    593  1.2  christos     if (!ParentOp)
    594  1.2  christos     {
    595  1.2  christos         return (FALSE);
    596  1.2  christos     }
    597  1.2  christos 
    598  1.2  christos     /* Check for form: Name(_PLD, Buffer() {}). Not legal, however */
    599  1.2  christos 
    600  1.2  christos     if (ParentOp->Common.AmlOpcode == AML_NAME_OP)
    601  1.2  christos     {
    602  1.2  christos         Node = ParentOp->Common.Node;
    603  1.2  christos 
    604  1.2  christos         if (ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__PLD))
    605  1.2  christos         {
    606  1.2  christos             /* Ignore the Size argument in the disassembly of this buffer op */
    607  1.2  christos 
    608  1.2  christos             SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
    609  1.2  christos             return (TRUE);
    610  1.2  christos         }
    611  1.2  christos 
    612  1.2  christos         return (FALSE);
    613  1.2  christos     }
    614  1.2  christos 
    615  1.2  christos     /* Check for proper form: Name(_PLD, Package() {Buffer() {}}) */
    616  1.2  christos 
    617  1.2  christos     if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP)
    618  1.2  christos     {
    619  1.2  christos         ParentOp = ParentOp->Common.Parent;
    620  1.2  christos         if (!ParentOp)
    621  1.2  christos         {
    622  1.2  christos             return (FALSE);
    623  1.2  christos         }
    624  1.2  christos 
    625  1.2  christos         if (ParentOp->Common.AmlOpcode == AML_NAME_OP)
    626  1.2  christos         {
    627  1.2  christos             Node = ParentOp->Common.Node;
    628  1.2  christos 
    629  1.2  christos             if (ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__PLD))
    630  1.2  christos             {
    631  1.2  christos                 /* Ignore the Size argument in the disassembly of this buffer op */
    632  1.2  christos 
    633  1.2  christos                 SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
    634  1.2  christos                 return (TRUE);
    635  1.2  christos             }
    636  1.2  christos         }
    637  1.2  christos     }
    638  1.2  christos 
    639  1.2  christos     return (FALSE);
    640  1.2  christos }
    641  1.2  christos 
    642  1.2  christos 
    643  1.2  christos /*******************************************************************************
    644  1.2  christos  *
    645  1.2  christos  * FUNCTION:    AcpiDmFindNameByIndex
    646  1.2  christos  *
    647  1.2  christos  * PARAMETERS:  Index               - Index of array to check
    648  1.2  christos  *              List                - Array to reference
    649  1.2  christos  *
    650  1.2  christos  * RETURN:      String from List or empty string
    651  1.2  christos  *
    652  1.2  christos  * DESCRIPTION: Finds and returns the char string located at the given index
    653  1.2  christos  *              position in List.
    654  1.2  christos  *
    655  1.2  christos  ******************************************************************************/
    656  1.2  christos 
    657  1.2  christos static const char *
    658  1.2  christos AcpiDmFindNameByIndex (
    659  1.2  christos     UINT64                  Index,
    660  1.2  christos     const char            **List)
    661  1.2  christos {
    662  1.2  christos     const char              *Str;
    663  1.2  christos     UINT32                   i;
    664  1.2  christos 
    665  1.2  christos 
    666  1.2  christos     /* Bounds check */
    667  1.2  christos 
    668  1.2  christos     Str = List[0];
    669  1.2  christos     i = 0;
    670  1.2  christos 
    671  1.2  christos     while(Str)
    672  1.2  christos     {
    673  1.2  christos         i++;
    674  1.2  christos         Str = List[i];
    675  1.2  christos     }
    676  1.2  christos 
    677  1.2  christos     if (Index >= i)
    678  1.2  christos     {
    679  1.2  christos         /* TBD: Add error msg */
    680  1.2  christos 
    681  1.2  christos         return ("");
    682  1.2  christos     }
    683  1.2  christos 
    684  1.2  christos     return (List[Index]);
    685  1.2  christos }
    686  1.2  christos 
    687  1.2  christos 
    688  1.2  christos /*******************************************************************************
    689  1.2  christos  *
    690  1.2  christos  * FUNCTION:    AcpiDmPldBuffer
    691  1.2  christos  *
    692  1.2  christos  * PARAMETERS:  Level               - Current source code indentation level
    693  1.2  christos  *              ByteData            - Pointer to the byte list
    694  1.2  christos  *              ByteCount           - Length of the byte list
    695  1.2  christos  *
    696  1.2  christos  * RETURN:      None
    697  1.2  christos  *
    698  1.2  christos  * DESCRIPTION: Dump and format the contents of a _PLD buffer object
    699  1.2  christos  *
    700  1.2  christos  ******************************************************************************/
    701  1.2  christos 
    702  1.2  christos #define ACPI_PLD_OUTPUT08   "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " "
    703  1.2  christos #define ACPI_PLD_OUTPUT08P  "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " "
    704  1.2  christos #define ACPI_PLD_OUTPUT16   "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " "
    705  1.2  christos #define ACPI_PLD_OUTPUT16P  "%*.s%-18s = 0x%X)\n", ACPI_MUL_4 (Level), " "
    706  1.2  christos #define ACPI_PLD_OUTPUT24   "%*.s%-18s = 0x%X,\n", ACPI_MUL_4 (Level), " "
    707  1.2  christos #define ACPI_PLD_OUTPUTSTR  "%*.s%-18s = \"%s\",\n", ACPI_MUL_4 (Level), " "
    708  1.2  christos 
    709  1.2  christos static void
    710  1.2  christos AcpiDmPldBuffer (
    711  1.2  christos     UINT32                  Level,
    712  1.2  christos     UINT8                   *ByteData,
    713  1.2  christos     UINT32                  ByteCount)
    714  1.2  christos {
    715  1.2  christos     ACPI_PLD_INFO           *PldInfo;
    716  1.2  christos     ACPI_STATUS             Status;
    717  1.2  christos 
    718  1.2  christos 
    719  1.2  christos     /* Check for valid byte count */
    720  1.2  christos 
    721  1.2  christos     if (ByteCount < ACPI_PLD_REV1_BUFFER_SIZE)
    722  1.2  christos     {
    723  1.2  christos         return;
    724  1.2  christos     }
    725  1.2  christos 
    726  1.2  christos     /* Convert _PLD buffer to local _PLD struct */
    727  1.2  christos 
    728  1.2  christos     Status = AcpiDecodePldBuffer (ByteData, ByteCount, &PldInfo);
    729  1.2  christos     if (ACPI_FAILURE (Status))
    730  1.2  christos     {
    731  1.2  christos         return;
    732  1.2  christos     }
    733  1.2  christos 
    734  1.2  christos     AcpiOsPrintf ("\n");
    735  1.2  christos 
    736  1.2  christos     /* First 32-bit dword */
    737  1.2  christos 
    738  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Revision", PldInfo->Revision);
    739  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_IgnoreColor", PldInfo->IgnoreColor);
    740  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Red", PldInfo->Red);
    741  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Green", PldInfo->Green);
    742  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Blue", PldInfo->Blue);
    743  1.2  christos 
    744  1.2  christos     /* Second 32-bit dword */
    745  1.2  christos 
    746  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT16,  "PLD_Width", PldInfo->Width);
    747  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT16,  "PLD_Height", PldInfo->Height);
    748  1.2  christos 
    749  1.2  christos     /* Third 32-bit dword */
    750  1.2  christos 
    751  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_UserVisible", PldInfo->UserVisible);
    752  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Dock", PldInfo->Dock);
    753  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Lid", PldInfo->Lid);
    754  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel",
    755  1.2  christos         AcpiDmFindNameByIndex(PldInfo->Panel, DmPanelList));
    756  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition",
    757  1.2  christos         AcpiDmFindNameByIndex(PldInfo->VerticalPosition, DmVerticalPositionList));
    758  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition",
    759  1.2  christos         AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, DmHorizontalPositionList));
    760  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape",
    761  1.2  christos         AcpiDmFindNameByIndex(PldInfo->Shape, DmShapeList));
    762  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_GroupOrientation", PldInfo->GroupOrientation);
    763  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_GroupToken", PldInfo->GroupToken);
    764  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_GroupPosition", PldInfo->GroupPosition);
    765  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Bay", PldInfo->Bay);
    766  1.2  christos 
    767  1.2  christos     /* Fourth 32-bit dword */
    768  1.2  christos 
    769  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Ejectable", PldInfo->Ejectable);
    770  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_EjectRequired", PldInfo->OspmEjectRequired);
    771  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_CabinetNumber", PldInfo->CabinetNumber);
    772  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_CardCageNumber", PldInfo->CardCageNumber);
    773  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Reference", PldInfo->Reference);
    774  1.2  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT08,  "PLD_Rotation", PldInfo->Rotation);
    775  1.2  christos 
    776  1.2  christos     if (ByteCount < ACPI_PLD_REV1_BUFFER_SIZE)
    777  1.2  christos     {
    778  1.2  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT08P, "PLD_Order", PldInfo->Order);
    779  1.2  christos     }
    780  1.2  christos     else
    781  1.2  christos     {
    782  1.2  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Order", PldInfo->Order);
    783  1.2  christos     }
    784  1.2  christos 
    785  1.2  christos     /* Fifth 32-bit dword */
    786  1.2  christos 
    787  1.2  christos     if (ByteCount >= ACPI_PLD_REV1_BUFFER_SIZE)
    788  1.2  christos     {
    789  1.2  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_VerticalOffset", PldInfo->VerticalOffset);
    790  1.2  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT16P, "PLD_HorizontalOffset", PldInfo->HorizontalOffset);
    791  1.2  christos     }
    792  1.2  christos 
    793  1.2  christos     ACPI_FREE (PldInfo);
    794  1.2  christos }
    795  1.2  christos 
    796  1.2  christos 
    797  1.2  christos /*******************************************************************************
    798  1.2  christos  *
    799  1.1    jruoho  * FUNCTION:    AcpiDmUnicode
    800  1.1    jruoho  *
    801  1.1    jruoho  * PARAMETERS:  Op              - Byte List op containing Unicode string
    802  1.1    jruoho  *
    803  1.1    jruoho  * RETURN:      None
    804  1.1    jruoho  *
    805  1.2  christos  * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove
    806  1.1    jruoho  *              the extra zero bytes).
    807  1.1    jruoho  *
    808  1.1    jruoho  ******************************************************************************/
    809  1.1    jruoho 
    810  1.1    jruoho static void
    811  1.1    jruoho AcpiDmUnicode (
    812  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    813  1.1    jruoho {
    814  1.1    jruoho     UINT16                  *WordData;
    815  1.1    jruoho     UINT32                  WordCount;
    816  1.1    jruoho     UINT32                  i;
    817  1.2  christos     int                     OutputValue;
    818  1.1    jruoho 
    819  1.1    jruoho 
    820  1.1    jruoho     /* Extract the buffer info as a WORD buffer */
    821  1.1    jruoho 
    822  1.1    jruoho     WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
    823  1.1    jruoho     WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
    824  1.1    jruoho 
    825  1.2  christos     /* Write every other byte as an ASCII character */
    826  1.1    jruoho 
    827  1.1    jruoho     AcpiOsPrintf ("\"");
    828  1.2  christos     for (i = 0; i < (WordCount - 1); i++)
    829  1.2  christos     {
    830  1.2  christos         OutputValue = (int) WordData[i];
    831  1.1    jruoho 
    832  1.2  christos         /* Handle values that must be escaped */
    833  1.1    jruoho 
    834  1.2  christos         if ((OutputValue == '\"') ||
    835  1.2  christos             (OutputValue == '\\'))
    836  1.2  christos         {
    837  1.2  christos             AcpiOsPrintf ("\\%c", OutputValue);
    838  1.2  christos         }
    839  1.2  christos         else if (!ACPI_IS_PRINT (OutputValue))
    840  1.2  christos         {
    841  1.2  christos             AcpiOsPrintf ("\\x%2.2X", OutputValue);
    842  1.2  christos         }
    843  1.2  christos         else
    844  1.2  christos         {
    845  1.2  christos             AcpiOsPrintf ("%c", OutputValue);
    846  1.2  christos         }
    847  1.1    jruoho     }
    848  1.1    jruoho 
    849  1.1    jruoho     AcpiOsPrintf ("\")");
    850  1.1    jruoho }
    851  1.1    jruoho 
    852  1.1    jruoho 
    853  1.1    jruoho /*******************************************************************************
    854  1.1    jruoho  *
    855  1.2  christos  * FUNCTION:    AcpiDmGetHardwareIdType
    856  1.1    jruoho  *
    857  1.1    jruoho  * PARAMETERS:  Op              - Op to be examined
    858  1.1    jruoho  *
    859  1.1    jruoho  * RETURN:      None
    860  1.1    jruoho  *
    861  1.2  christos  * DESCRIPTION: Determine the type of the argument to a _HID or _CID
    862  1.2  christos  *              1) Strings are allowed
    863  1.2  christos  *              2) If Integer, determine if it is a valid EISAID
    864  1.1    jruoho  *
    865  1.1    jruoho  ******************************************************************************/
    866  1.1    jruoho 
    867  1.1    jruoho static void
    868  1.2  christos AcpiDmGetHardwareIdType (
    869  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    870  1.1    jruoho {
    871  1.1    jruoho     UINT32                  BigEndianId;
    872  1.1    jruoho     UINT32                  Prefix[3];
    873  1.1    jruoho     UINT32                  i;
    874  1.1    jruoho 
    875  1.1    jruoho 
    876  1.2  christos     switch (Op->Common.AmlOpcode)
    877  1.2  christos     {
    878  1.2  christos     case AML_STRING_OP:
    879  1.2  christos 
    880  1.2  christos         /* Mark this string as an _HID/_CID string */
    881  1.2  christos 
    882  1.2  christos         Op->Common.DisasmOpcode = ACPI_DASM_HID_STRING;
    883  1.2  christos         break;
    884  1.2  christos 
    885  1.2  christos     case AML_WORD_OP:
    886  1.2  christos     case AML_DWORD_OP:
    887  1.1    jruoho 
    888  1.2  christos         /* Determine if a Word/Dword is a valid encoded EISAID */
    889  1.1    jruoho 
    890  1.2  christos         /* Swap from little-endian to big-endian to simplify conversion */
    891  1.1    jruoho 
    892  1.2  christos         BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
    893  1.1    jruoho 
    894  1.2  christos         /* Create the 3 leading ASCII letters */
    895  1.1    jruoho 
    896  1.2  christos         Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;
    897  1.2  christos         Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;
    898  1.2  christos         Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;
    899  1.1    jruoho 
    900  1.2  christos         /* Verify that all 3 are ascii and alpha */
    901  1.1    jruoho 
    902  1.2  christos         for (i = 0; i < 3; i++)
    903  1.1    jruoho         {
    904  1.2  christos             if (!ACPI_IS_ASCII (Prefix[i]) ||
    905  1.2  christos                 !ACPI_IS_ALPHA (Prefix[i]))
    906  1.2  christos             {
    907  1.2  christos                 return;
    908  1.2  christos             }
    909  1.1    jruoho         }
    910  1.1    jruoho 
    911  1.2  christos         /* Mark this node as convertable to an EISA ID string */
    912  1.2  christos 
    913  1.2  christos         Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
    914  1.2  christos         break;
    915  1.1    jruoho 
    916  1.2  christos     default:
    917  1.2  christos         break;
    918  1.2  christos     }
    919  1.1    jruoho }
    920  1.1    jruoho 
    921  1.1    jruoho 
    922  1.1    jruoho /*******************************************************************************
    923  1.1    jruoho  *
    924  1.2  christos  * FUNCTION:    AcpiDmCheckForHardwareId
    925  1.1    jruoho  *
    926  1.1    jruoho  * PARAMETERS:  Op              - Op to be examined
    927  1.1    jruoho  *
    928  1.1    jruoho  * RETURN:      None
    929  1.1    jruoho  *
    930  1.2  christos  * DESCRIPTION: Determine if a Name() Op is a _HID/_CID.
    931  1.1    jruoho  *
    932  1.1    jruoho  ******************************************************************************/
    933  1.1    jruoho 
    934  1.1    jruoho void
    935  1.2  christos AcpiDmCheckForHardwareId (
    936  1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    937  1.1    jruoho {
    938  1.1    jruoho     UINT32                  Name;
    939  1.1    jruoho     ACPI_PARSE_OBJECT       *NextOp;
    940  1.1    jruoho 
    941  1.1    jruoho 
    942  1.1    jruoho     /* Get the NameSegment */
    943  1.1    jruoho 
    944  1.1    jruoho     Name = AcpiPsGetName (Op);
    945  1.1    jruoho     if (!Name)
    946  1.1    jruoho     {
    947  1.1    jruoho         return;
    948  1.1    jruoho     }
    949  1.1    jruoho 
    950  1.1    jruoho     NextOp = AcpiPsGetDepthNext (NULL, Op);
    951  1.1    jruoho     if (!NextOp)
    952  1.1    jruoho     {
    953  1.1    jruoho         return;
    954  1.1    jruoho     }
    955  1.1    jruoho 
    956  1.1    jruoho     /* Check for _HID - has one argument */
    957  1.1    jruoho 
    958  1.1    jruoho     if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))
    959  1.1    jruoho     {
    960  1.2  christos         AcpiDmGetHardwareIdType (NextOp);
    961  1.1    jruoho         return;
    962  1.1    jruoho     }
    963  1.1    jruoho 
    964  1.1    jruoho     /* Exit if not _CID */
    965  1.1    jruoho 
    966  1.1    jruoho     if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID))
    967  1.1    jruoho     {
    968  1.1    jruoho         return;
    969  1.1    jruoho     }
    970  1.1    jruoho 
    971  1.1    jruoho     /* _CID can contain a single argument or a package */
    972  1.1    jruoho 
    973  1.1    jruoho     if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
    974  1.1    jruoho     {
    975  1.2  christos         AcpiDmGetHardwareIdType (NextOp);
    976  1.1    jruoho         return;
    977  1.1    jruoho     }
    978  1.1    jruoho 
    979  1.2  christos     /* _CID with Package: get the package length, check all elements */
    980  1.1    jruoho 
    981  1.1    jruoho     NextOp = AcpiPsGetDepthNext (NULL, NextOp);
    982  1.2  christos     if (!NextOp)
    983  1.2  christos     {
    984  1.2  christos         return;
    985  1.2  christos     }
    986  1.1    jruoho 
    987  1.1    jruoho     /* Don't need to use the length, just walk the peer list */
    988  1.1    jruoho 
    989  1.1    jruoho     NextOp = NextOp->Common.Next;
    990  1.1    jruoho     while (NextOp)
    991  1.1    jruoho     {
    992  1.2  christos         AcpiDmGetHardwareIdType (NextOp);
    993  1.1    jruoho         NextOp = NextOp->Common.Next;
    994  1.1    jruoho     }
    995  1.1    jruoho }
    996  1.1    jruoho 
    997  1.1    jruoho 
    998  1.1    jruoho /*******************************************************************************
    999  1.1    jruoho  *
   1000  1.2  christos  * FUNCTION:    AcpiDmDecompressEisaId
   1001  1.1    jruoho  *
   1002  1.1    jruoho  * PARAMETERS:  EncodedId       - Raw encoded EISA ID.
   1003  1.1    jruoho  *
   1004  1.1    jruoho  * RETURN:      None
   1005  1.1    jruoho  *
   1006  1.2  christos  * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String
   1007  1.2  christos  *              and emit the correct ASL statement. If the ID is known, emit
   1008  1.2  christos  *              a description of the ID as a comment.
   1009  1.1    jruoho  *
   1010  1.1    jruoho  ******************************************************************************/
   1011  1.1    jruoho 
   1012  1.1    jruoho void
   1013  1.2  christos AcpiDmDecompressEisaId (
   1014  1.1    jruoho     UINT32                  EncodedId)
   1015  1.1    jruoho {
   1016  1.2  christos     char                    IdBuffer[ACPI_EISAID_STRING_SIZE];
   1017  1.2  christos     const AH_DEVICE_ID      *Info;
   1018  1.1    jruoho 
   1019  1.1    jruoho 
   1020  1.2  christos     /* Convert EISAID to a string an emit the statement */
   1021  1.1    jruoho 
   1022  1.2  christos     AcpiExEisaIdToString (IdBuffer, EncodedId);
   1023  1.2  christos     AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer);
   1024  1.1    jruoho 
   1025  1.2  christos     /* If we know about the ID, emit the description */
   1026  1.1    jruoho 
   1027  1.2  christos     Info = AcpiAhMatchHardwareId (IdBuffer);
   1028  1.2  christos     if (Info)
   1029  1.2  christos     {
   1030  1.2  christos         AcpiOsPrintf (" /* %s */", Info->Description);
   1031  1.2  christos     }
   1032  1.1    jruoho }
   1033  1.1    jruoho 
   1034  1.1    jruoho #endif
   1035