Home | History | Annotate | Line # | Download | only in debugger
dbconvert.c revision 1.1.1.4
      1      1.1  christos /*******************************************************************************
      2      1.1  christos  *
      3      1.1  christos  * Module Name: dbconvert - debugger miscellaneous conversion routines
      4      1.1  christos  *
      5      1.1  christos  ******************************************************************************/
      6      1.1  christos 
      7      1.1  christos /*
      8  1.1.1.3  christos  * Copyright (C) 2000 - 2015, Intel Corp.
      9      1.1  christos  * All rights reserved.
     10      1.1  christos  *
     11      1.1  christos  * Redistribution and use in source and binary forms, with or without
     12      1.1  christos  * modification, are permitted provided that the following conditions
     13      1.1  christos  * are met:
     14      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     15      1.1  christos  *    notice, this list of conditions, and the following disclaimer,
     16      1.1  christos  *    without modification.
     17      1.1  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1  christos  *    including a substantially similar Disclaimer requirement for further
     21      1.1  christos  *    binary redistribution.
     22      1.1  christos  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1  christos  *    of any contributors may be used to endorse or promote products derived
     24      1.1  christos  *    from this software without specific prior written permission.
     25      1.1  christos  *
     26      1.1  christos  * Alternatively, this software may be distributed under the terms of the
     27      1.1  christos  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1  christos  * Software Foundation.
     29      1.1  christos  *
     30      1.1  christos  * NO WARRANTY
     31      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1  christos  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1  christos  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1  christos  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1  christos  */
     43      1.1  christos 
     44      1.1  christos #include "acpi.h"
     45      1.1  christos #include "accommon.h"
     46      1.1  christos #include "acdebug.h"
     47      1.1  christos 
     48      1.1  christos #ifdef ACPI_DEBUGGER
     49      1.1  christos 
     50      1.1  christos #define _COMPONENT          ACPI_CA_DEBUGGER
     51      1.1  christos         ACPI_MODULE_NAME    ("dbconvert")
     52      1.1  christos 
     53      1.1  christos 
     54      1.1  christos #define DB_DEFAULT_PKG_ELEMENTS     33
     55      1.1  christos 
     56      1.1  christos 
     57      1.1  christos /*******************************************************************************
     58      1.1  christos  *
     59      1.1  christos  * FUNCTION:    AcpiDbHexCharToValue
     60      1.1  christos  *
     61      1.1  christos  * PARAMETERS:  HexChar             - Ascii Hex digit, 0-9|a-f|A-F
     62      1.1  christos  *              ReturnValue         - Where the converted value is returned
     63      1.1  christos  *
     64      1.1  christos  * RETURN:      Status
     65      1.1  christos  *
     66      1.1  christos  * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16).
     67      1.1  christos  *
     68      1.1  christos  ******************************************************************************/
     69      1.1  christos 
     70      1.1  christos ACPI_STATUS
     71      1.1  christos AcpiDbHexCharToValue (
     72      1.1  christos     int                     HexChar,
     73      1.1  christos     UINT8                   *ReturnValue)
     74      1.1  christos {
     75      1.1  christos     UINT8                   Value;
     76      1.1  christos 
     77      1.1  christos 
     78      1.1  christos     /* Digit must be ascii [0-9a-fA-F] */
     79      1.1  christos 
     80  1.1.1.4  christos     if (!isxdigit (HexChar))
     81      1.1  christos     {
     82      1.1  christos         return (AE_BAD_HEX_CONSTANT);
     83      1.1  christos     }
     84      1.1  christos 
     85      1.1  christos     if (HexChar <= 0x39)
     86      1.1  christos     {
     87      1.1  christos         Value = (UINT8) (HexChar - 0x30);
     88      1.1  christos     }
     89      1.1  christos     else
     90      1.1  christos     {
     91  1.1.1.4  christos         Value = (UINT8) (toupper (HexChar) - 0x37);
     92      1.1  christos     }
     93      1.1  christos 
     94      1.1  christos     *ReturnValue = Value;
     95      1.1  christos     return (AE_OK);
     96      1.1  christos }
     97      1.1  christos 
     98      1.1  christos 
     99      1.1  christos /*******************************************************************************
    100      1.1  christos  *
    101      1.1  christos  * FUNCTION:    AcpiDbHexByteToBinary
    102      1.1  christos  *
    103      1.1  christos  * PARAMETERS:  HexByte             - Double hex digit (0x00 - 0xFF) in format:
    104      1.1  christos  *                                    HiByte then LoByte.
    105      1.1  christos  *              ReturnValue         - Where the converted value is returned
    106      1.1  christos  *
    107      1.1  christos  * RETURN:      Status
    108      1.1  christos  *
    109      1.1  christos  * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255).
    110      1.1  christos  *
    111      1.1  christos  ******************************************************************************/
    112      1.1  christos 
    113      1.1  christos static ACPI_STATUS
    114      1.1  christos AcpiDbHexByteToBinary (
    115      1.1  christos     char                    *HexByte,
    116      1.1  christos     UINT8                   *ReturnValue)
    117      1.1  christos {
    118      1.1  christos     UINT8                   Local0;
    119      1.1  christos     UINT8                   Local1;
    120      1.1  christos     ACPI_STATUS             Status;
    121      1.1  christos 
    122      1.1  christos 
    123      1.1  christos     /* High byte */
    124      1.1  christos 
    125      1.1  christos     Status = AcpiDbHexCharToValue (HexByte[0], &Local0);
    126      1.1  christos     if (ACPI_FAILURE (Status))
    127      1.1  christos     {
    128      1.1  christos         return (Status);
    129      1.1  christos     }
    130      1.1  christos 
    131      1.1  christos     /* Low byte */
    132      1.1  christos 
    133      1.1  christos     Status = AcpiDbHexCharToValue (HexByte[1], &Local1);
    134      1.1  christos     if (ACPI_FAILURE (Status))
    135      1.1  christos     {
    136      1.1  christos         return (Status);
    137      1.1  christos     }
    138      1.1  christos 
    139      1.1  christos     *ReturnValue = (UINT8) ((Local0 << 4) | Local1);
    140      1.1  christos     return (AE_OK);
    141      1.1  christos }
    142      1.1  christos 
    143      1.1  christos 
    144      1.1  christos /*******************************************************************************
    145      1.1  christos  *
    146      1.1  christos  * FUNCTION:    AcpiDbConvertToBuffer
    147      1.1  christos  *
    148      1.1  christos  * PARAMETERS:  String              - Input string to be converted
    149      1.1  christos  *              Object              - Where the buffer object is returned
    150      1.1  christos  *
    151      1.1  christos  * RETURN:      Status
    152      1.1  christos  *
    153      1.1  christos  * DESCRIPTION: Convert a string to a buffer object. String is treated a list
    154      1.1  christos  *              of buffer elements, each separated by a space or comma.
    155      1.1  christos  *
    156      1.1  christos  ******************************************************************************/
    157      1.1  christos 
    158      1.1  christos static ACPI_STATUS
    159      1.1  christos AcpiDbConvertToBuffer (
    160      1.1  christos     char                    *String,
    161      1.1  christos     ACPI_OBJECT             *Object)
    162      1.1  christos {
    163      1.1  christos     UINT32                  i;
    164      1.1  christos     UINT32                  j;
    165      1.1  christos     UINT32                  Length;
    166      1.1  christos     UINT8                   *Buffer;
    167      1.1  christos     ACPI_STATUS             Status;
    168      1.1  christos 
    169      1.1  christos 
    170      1.1  christos     /* Generate the final buffer length */
    171      1.1  christos 
    172      1.1  christos     for (i = 0, Length = 0; String[i];)
    173      1.1  christos     {
    174      1.1  christos         i+=2;
    175      1.1  christos         Length++;
    176      1.1  christos 
    177      1.1  christos         while (String[i] &&
    178      1.1  christos               ((String[i] == ',') || (String[i] == ' ')))
    179      1.1  christos         {
    180      1.1  christos             i++;
    181      1.1  christos         }
    182      1.1  christos     }
    183      1.1  christos 
    184      1.1  christos     Buffer = ACPI_ALLOCATE (Length);
    185      1.1  christos     if (!Buffer)
    186      1.1  christos     {
    187      1.1  christos         return (AE_NO_MEMORY);
    188      1.1  christos     }
    189      1.1  christos 
    190      1.1  christos     /* Convert the command line bytes to the buffer */
    191      1.1  christos 
    192      1.1  christos     for (i = 0, j = 0; String[i];)
    193      1.1  christos     {
    194      1.1  christos         Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]);
    195      1.1  christos         if (ACPI_FAILURE (Status))
    196      1.1  christos         {
    197      1.1  christos             ACPI_FREE (Buffer);
    198      1.1  christos             return (Status);
    199      1.1  christos         }
    200      1.1  christos 
    201      1.1  christos         j++;
    202      1.1  christos         i+=2;
    203      1.1  christos         while (String[i] &&
    204      1.1  christos               ((String[i] == ',') || (String[i] == ' ')))
    205      1.1  christos         {
    206      1.1  christos             i++;
    207      1.1  christos         }
    208      1.1  christos     }
    209      1.1  christos 
    210      1.1  christos     Object->Type = ACPI_TYPE_BUFFER;
    211      1.1  christos     Object->Buffer.Pointer = Buffer;
    212      1.1  christos     Object->Buffer.Length = Length;
    213      1.1  christos     return (AE_OK);
    214      1.1  christos }
    215      1.1  christos 
    216      1.1  christos 
    217      1.1  christos /*******************************************************************************
    218      1.1  christos  *
    219      1.1  christos  * FUNCTION:    AcpiDbConvertToPackage
    220      1.1  christos  *
    221      1.1  christos  * PARAMETERS:  String              - Input string to be converted
    222      1.1  christos  *              Object              - Where the package object is returned
    223      1.1  christos  *
    224      1.1  christos  * RETURN:      Status
    225      1.1  christos  *
    226      1.1  christos  * DESCRIPTION: Convert a string to a package object. Handles nested packages
    227      1.1  christos  *              via recursion with AcpiDbConvertToObject.
    228      1.1  christos  *
    229      1.1  christos  ******************************************************************************/
    230      1.1  christos 
    231      1.1  christos ACPI_STATUS
    232      1.1  christos AcpiDbConvertToPackage (
    233      1.1  christos     char                    *String,
    234      1.1  christos     ACPI_OBJECT             *Object)
    235      1.1  christos {
    236      1.1  christos     char                    *This;
    237      1.1  christos     char                    *Next;
    238      1.1  christos     UINT32                  i;
    239      1.1  christos     ACPI_OBJECT_TYPE        Type;
    240      1.1  christos     ACPI_OBJECT             *Elements;
    241      1.1  christos     ACPI_STATUS             Status;
    242      1.1  christos 
    243      1.1  christos 
    244      1.1  christos     Elements = ACPI_ALLOCATE_ZEROED (
    245      1.1  christos         DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT));
    246      1.1  christos 
    247      1.1  christos     This = String;
    248      1.1  christos     for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++)
    249      1.1  christos     {
    250      1.1  christos         This = AcpiDbGetNextToken (This, &Next, &Type);
    251      1.1  christos         if (!This)
    252      1.1  christos         {
    253      1.1  christos             break;
    254      1.1  christos         }
    255      1.1  christos 
    256      1.1  christos         /* Recursive call to convert each package element */
    257      1.1  christos 
    258      1.1  christos         Status = AcpiDbConvertToObject (Type, This, &Elements[i]);
    259      1.1  christos         if (ACPI_FAILURE (Status))
    260      1.1  christos         {
    261      1.1  christos             AcpiDbDeleteObjects (i + 1, Elements);
    262      1.1  christos             ACPI_FREE (Elements);
    263      1.1  christos             return (Status);
    264      1.1  christos         }
    265      1.1  christos 
    266      1.1  christos         This = Next;
    267      1.1  christos     }
    268      1.1  christos 
    269      1.1  christos     Object->Type = ACPI_TYPE_PACKAGE;
    270      1.1  christos     Object->Package.Count = i;
    271      1.1  christos     Object->Package.Elements = Elements;
    272      1.1  christos     return (AE_OK);
    273      1.1  christos }
    274      1.1  christos 
    275      1.1  christos 
    276      1.1  christos /*******************************************************************************
    277      1.1  christos  *
    278      1.1  christos  * FUNCTION:    AcpiDbConvertToObject
    279      1.1  christos  *
    280      1.1  christos  * PARAMETERS:  Type                - Object type as determined by parser
    281      1.1  christos  *              String              - Input string to be converted
    282      1.1  christos  *              Object              - Where the new object is returned
    283      1.1  christos  *
    284      1.1  christos  * RETURN:      Status
    285      1.1  christos  *
    286      1.1  christos  * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing:
    287      1.1  christos  *              1) String objects were surrounded by quotes.
    288      1.1  christos  *              2) Buffer objects were surrounded by parentheses.
    289      1.1  christos  *              3) Package objects were surrounded by brackets "[]".
    290      1.1  christos  *              4) All standalone tokens are treated as integers.
    291      1.1  christos  *
    292      1.1  christos  ******************************************************************************/
    293      1.1  christos 
    294      1.1  christos ACPI_STATUS
    295      1.1  christos AcpiDbConvertToObject (
    296      1.1  christos     ACPI_OBJECT_TYPE        Type,
    297      1.1  christos     char                    *String,
    298      1.1  christos     ACPI_OBJECT             *Object)
    299      1.1  christos {
    300      1.1  christos     ACPI_STATUS             Status = AE_OK;
    301      1.1  christos 
    302      1.1  christos 
    303      1.1  christos     switch (Type)
    304      1.1  christos     {
    305      1.1  christos     case ACPI_TYPE_STRING:
    306      1.1  christos 
    307      1.1  christos         Object->Type = ACPI_TYPE_STRING;
    308      1.1  christos         Object->String.Pointer = String;
    309  1.1.1.4  christos         Object->String.Length = (UINT32) strlen (String);
    310      1.1  christos         break;
    311      1.1  christos 
    312      1.1  christos     case ACPI_TYPE_BUFFER:
    313      1.1  christos 
    314      1.1  christos         Status = AcpiDbConvertToBuffer (String, Object);
    315      1.1  christos         break;
    316      1.1  christos 
    317      1.1  christos     case ACPI_TYPE_PACKAGE:
    318      1.1  christos 
    319      1.1  christos         Status = AcpiDbConvertToPackage (String, Object);
    320      1.1  christos         break;
    321      1.1  christos 
    322      1.1  christos     default:
    323      1.1  christos 
    324      1.1  christos         Object->Type = ACPI_TYPE_INTEGER;
    325      1.1  christos         Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value);
    326      1.1  christos         break;
    327      1.1  christos     }
    328      1.1  christos 
    329      1.1  christos     return (Status);
    330      1.1  christos }
    331      1.1  christos 
    332      1.1  christos 
    333      1.1  christos /*******************************************************************************
    334      1.1  christos  *
    335      1.1  christos  * FUNCTION:    AcpiDbEncodePldBuffer
    336      1.1  christos  *
    337      1.1  christos  * PARAMETERS:  PldInfo             - _PLD buffer struct (Using local struct)
    338      1.1  christos  *
    339      1.1  christos  * RETURN:      Encode _PLD buffer suitable for return value from _PLD
    340      1.1  christos  *
    341      1.1  christos  * DESCRIPTION: Bit-packs a _PLD buffer struct. Used to test the _PLD macros
    342      1.1  christos  *
    343      1.1  christos  ******************************************************************************/
    344      1.1  christos 
    345      1.1  christos UINT8 *
    346      1.1  christos AcpiDbEncodePldBuffer (
    347      1.1  christos     ACPI_PLD_INFO           *PldInfo)
    348      1.1  christos {
    349      1.1  christos     UINT32                  *Buffer;
    350      1.1  christos     UINT32                  Dword;
    351      1.1  christos 
    352      1.1  christos 
    353      1.1  christos     Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE);
    354      1.1  christos     if (!Buffer)
    355      1.1  christos     {
    356      1.1  christos         return (NULL);
    357      1.1  christos     }
    358      1.1  christos 
    359      1.1  christos     /* First 32 bits */
    360      1.1  christos 
    361      1.1  christos     Dword = 0;
    362      1.1  christos     ACPI_PLD_SET_REVISION       (&Dword, PldInfo->Revision);
    363      1.1  christos     ACPI_PLD_SET_IGNORE_COLOR   (&Dword, PldInfo->IgnoreColor);
    364  1.1.1.3  christos     ACPI_PLD_SET_RED            (&Dword, PldInfo->Red);
    365  1.1.1.3  christos     ACPI_PLD_SET_GREEN          (&Dword, PldInfo->Green);
    366  1.1.1.3  christos     ACPI_PLD_SET_BLUE           (&Dword, PldInfo->Blue);
    367      1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword);
    368      1.1  christos 
    369      1.1  christos     /* Second 32 bits */
    370      1.1  christos 
    371      1.1  christos     Dword = 0;
    372      1.1  christos     ACPI_PLD_SET_WIDTH          (&Dword, PldInfo->Width);
    373      1.1  christos     ACPI_PLD_SET_HEIGHT         (&Dword, PldInfo->Height);
    374      1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword);
    375      1.1  christos 
    376      1.1  christos     /* Third 32 bits */
    377      1.1  christos 
    378      1.1  christos     Dword = 0;
    379      1.1  christos     ACPI_PLD_SET_USER_VISIBLE   (&Dword, PldInfo->UserVisible);
    380      1.1  christos     ACPI_PLD_SET_DOCK           (&Dword, PldInfo->Dock);
    381      1.1  christos     ACPI_PLD_SET_LID            (&Dword, PldInfo->Lid);
    382      1.1  christos     ACPI_PLD_SET_PANEL          (&Dword, PldInfo->Panel);
    383      1.1  christos     ACPI_PLD_SET_VERTICAL       (&Dword, PldInfo->VerticalPosition);
    384      1.1  christos     ACPI_PLD_SET_HORIZONTAL     (&Dword, PldInfo->HorizontalPosition);
    385      1.1  christos     ACPI_PLD_SET_SHAPE          (&Dword, PldInfo->Shape);
    386      1.1  christos     ACPI_PLD_SET_ORIENTATION    (&Dword, PldInfo->GroupOrientation);
    387      1.1  christos     ACPI_PLD_SET_TOKEN          (&Dword, PldInfo->GroupToken);
    388      1.1  christos     ACPI_PLD_SET_POSITION       (&Dword, PldInfo->GroupPosition);
    389      1.1  christos     ACPI_PLD_SET_BAY            (&Dword, PldInfo->Bay);
    390      1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword);
    391      1.1  christos 
    392      1.1  christos     /* Fourth 32 bits */
    393      1.1  christos 
    394      1.1  christos     Dword = 0;
    395      1.1  christos     ACPI_PLD_SET_EJECTABLE      (&Dword, PldInfo->Ejectable);
    396      1.1  christos     ACPI_PLD_SET_OSPM_EJECT     (&Dword, PldInfo->OspmEjectRequired);
    397      1.1  christos     ACPI_PLD_SET_CABINET        (&Dword, PldInfo->CabinetNumber);
    398      1.1  christos     ACPI_PLD_SET_CARD_CAGE      (&Dword, PldInfo->CardCageNumber);
    399      1.1  christos     ACPI_PLD_SET_REFERENCE      (&Dword, PldInfo->Reference);
    400      1.1  christos     ACPI_PLD_SET_ROTATION       (&Dword, PldInfo->Rotation);
    401      1.1  christos     ACPI_PLD_SET_ORDER          (&Dword, PldInfo->Order);
    402      1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword);
    403      1.1  christos 
    404      1.1  christos     if (PldInfo->Revision >= 2)
    405      1.1  christos     {
    406      1.1  christos         /* Fifth 32 bits */
    407      1.1  christos 
    408      1.1  christos         Dword = 0;
    409      1.1  christos         ACPI_PLD_SET_VERT_OFFSET    (&Dword, PldInfo->VerticalOffset);
    410      1.1  christos         ACPI_PLD_SET_HORIZ_OFFSET   (&Dword, PldInfo->HorizontalOffset);
    411      1.1  christos         ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword);
    412      1.1  christos     }
    413      1.1  christos 
    414      1.1  christos     return (ACPI_CAST_PTR (UINT8, Buffer));
    415      1.1  christos }
    416      1.1  christos 
    417      1.1  christos 
    418      1.1  christos /*******************************************************************************
    419      1.1  christos  *
    420      1.1  christos  * FUNCTION:    AcpiDbDumpPldBuffer
    421      1.1  christos  *
    422      1.1  christos  * PARAMETERS:  ObjDesc             - Object returned from _PLD method
    423      1.1  christos  *
    424      1.1  christos  * RETURN:      None.
    425      1.1  christos  *
    426      1.1  christos  * DESCRIPTION: Dumps formatted contents of a _PLD return buffer.
    427      1.1  christos  *
    428      1.1  christos  ******************************************************************************/
    429      1.1  christos 
    430      1.1  christos #define ACPI_PLD_OUTPUT     "%20s : %-6X\n"
    431      1.1  christos 
    432      1.1  christos void
    433      1.1  christos AcpiDbDumpPldBuffer (
    434      1.1  christos     ACPI_OBJECT             *ObjDesc)
    435      1.1  christos {
    436      1.1  christos     ACPI_OBJECT             *BufferDesc;
    437      1.1  christos     ACPI_PLD_INFO           *PldInfo;
    438      1.1  christos     UINT8                   *NewBuffer;
    439      1.1  christos     ACPI_STATUS             Status;
    440      1.1  christos 
    441      1.1  christos 
    442      1.1  christos     /* Object must be of type Package with at least one Buffer element */
    443      1.1  christos 
    444      1.1  christos     if (ObjDesc->Type != ACPI_TYPE_PACKAGE)
    445      1.1  christos     {
    446      1.1  christos         return;
    447      1.1  christos     }
    448      1.1  christos 
    449      1.1  christos     BufferDesc = &ObjDesc->Package.Elements[0];
    450      1.1  christos     if (BufferDesc->Type != ACPI_TYPE_BUFFER)
    451      1.1  christos     {
    452      1.1  christos         return;
    453      1.1  christos     }
    454      1.1  christos 
    455      1.1  christos     /* Convert _PLD buffer to local _PLD struct */
    456      1.1  christos 
    457      1.1  christos     Status = AcpiDecodePldBuffer (BufferDesc->Buffer.Pointer,
    458      1.1  christos         BufferDesc->Buffer.Length, &PldInfo);
    459      1.1  christos     if (ACPI_FAILURE (Status))
    460      1.1  christos     {
    461      1.1  christos         return;
    462      1.1  christos     }
    463      1.1  christos 
    464      1.1  christos     /* Encode local _PLD struct back to a _PLD buffer */
    465      1.1  christos 
    466      1.1  christos     NewBuffer = AcpiDbEncodePldBuffer (PldInfo);
    467      1.1  christos     if (!NewBuffer)
    468      1.1  christos     {
    469      1.1  christos         return;
    470      1.1  christos     }
    471      1.1  christos 
    472      1.1  christos     /* The two bit-packed buffers should match */
    473      1.1  christos 
    474  1.1.1.4  christos     if (memcmp (NewBuffer, BufferDesc->Buffer.Pointer,
    475      1.1  christos         BufferDesc->Buffer.Length))
    476      1.1  christos     {
    477      1.1  christos         AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n");
    478      1.1  christos 
    479      1.1  christos         AcpiUtDumpBuffer (NewBuffer,
    480      1.1  christos             BufferDesc->Buffer.Length, DB_BYTE_DISPLAY, 0);
    481      1.1  christos     }
    482      1.1  christos 
    483      1.1  christos     /* First 32-bit dword */
    484      1.1  christos 
    485  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Revision", PldInfo->Revision);
    486  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_IgnoreColor", PldInfo->IgnoreColor);
    487  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Red", PldInfo->Red);
    488  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Green", PldInfo->Green);
    489  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Blue", PldInfo->Blue);
    490      1.1  christos 
    491      1.1  christos     /* Second 32-bit dword */
    492      1.1  christos 
    493  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Width", PldInfo->Width);
    494  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Height", PldInfo->Height);
    495      1.1  christos 
    496      1.1  christos     /* Third 32-bit dword */
    497      1.1  christos 
    498  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_UserVisible", PldInfo->UserVisible);
    499  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Dock", PldInfo->Dock);
    500  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Lid", PldInfo->Lid);
    501  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Panel", PldInfo->Panel);
    502  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_VerticalPosition", PldInfo->VerticalPosition);
    503  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalPosition", PldInfo->HorizontalPosition);
    504  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Shape", PldInfo->Shape);
    505  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupOrientation", PldInfo->GroupOrientation);
    506  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupToken", PldInfo->GroupToken);
    507  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupPosition", PldInfo->GroupPosition);
    508  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Bay", PldInfo->Bay);
    509      1.1  christos 
    510      1.1  christos     /* Fourth 32-bit dword */
    511      1.1  christos 
    512  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Ejectable", PldInfo->Ejectable);
    513  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_EjectRequired", PldInfo->OspmEjectRequired);
    514  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_CabinetNumber", PldInfo->CabinetNumber);
    515  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_CardCageNumber", PldInfo->CardCageNumber);
    516  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Reference", PldInfo->Reference);
    517  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Rotation", PldInfo->Rotation);
    518  1.1.1.3  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Order", PldInfo->Order);
    519      1.1  christos 
    520      1.1  christos     /* Fifth 32-bit dword */
    521      1.1  christos 
    522      1.1  christos     if (BufferDesc->Buffer.Length > 16)
    523      1.1  christos     {
    524  1.1.1.3  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_VerticalOffset", PldInfo->VerticalOffset);
    525  1.1.1.3  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalOffset", PldInfo->HorizontalOffset);
    526      1.1  christos     }
    527      1.1  christos 
    528      1.1  christos     ACPI_FREE (PldInfo);
    529      1.1  christos     ACPI_FREE (NewBuffer);
    530      1.1  christos }
    531      1.1  christos 
    532      1.1  christos #endif /* ACPI_DEBUGGER */
    533