Home | History | Annotate | Line # | Download | only in debugger
dbconvert.c revision 1.1
      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  christos  * Copyright (C) 2000 - 2013, 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 
     45  1.1  christos #include "acpi.h"
     46  1.1  christos #include "accommon.h"
     47  1.1  christos #include "acdebug.h"
     48  1.1  christos 
     49  1.1  christos #ifdef ACPI_DEBUGGER
     50  1.1  christos 
     51  1.1  christos #define _COMPONENT          ACPI_CA_DEBUGGER
     52  1.1  christos         ACPI_MODULE_NAME    ("dbconvert")
     53  1.1  christos 
     54  1.1  christos 
     55  1.1  christos #define DB_DEFAULT_PKG_ELEMENTS     33
     56  1.1  christos 
     57  1.1  christos 
     58  1.1  christos /*******************************************************************************
     59  1.1  christos  *
     60  1.1  christos  * FUNCTION:    AcpiDbHexCharToValue
     61  1.1  christos  *
     62  1.1  christos  * PARAMETERS:  HexChar             - Ascii Hex digit, 0-9|a-f|A-F
     63  1.1  christos  *              ReturnValue         - Where the converted value is returned
     64  1.1  christos  *
     65  1.1  christos  * RETURN:      Status
     66  1.1  christos  *
     67  1.1  christos  * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16).
     68  1.1  christos  *
     69  1.1  christos  ******************************************************************************/
     70  1.1  christos 
     71  1.1  christos ACPI_STATUS
     72  1.1  christos AcpiDbHexCharToValue (
     73  1.1  christos     int                     HexChar,
     74  1.1  christos     UINT8                   *ReturnValue)
     75  1.1  christos {
     76  1.1  christos     UINT8                   Value;
     77  1.1  christos 
     78  1.1  christos 
     79  1.1  christos     /* Digit must be ascii [0-9a-fA-F] */
     80  1.1  christos 
     81  1.1  christos     if (!ACPI_IS_XDIGIT (HexChar))
     82  1.1  christos     {
     83  1.1  christos         return (AE_BAD_HEX_CONSTANT);
     84  1.1  christos     }
     85  1.1  christos 
     86  1.1  christos     if (HexChar <= 0x39)
     87  1.1  christos     {
     88  1.1  christos         Value = (UINT8) (HexChar - 0x30);
     89  1.1  christos     }
     90  1.1  christos     else
     91  1.1  christos     {
     92  1.1  christos         Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37);
     93  1.1  christos     }
     94  1.1  christos 
     95  1.1  christos     *ReturnValue = Value;
     96  1.1  christos     return (AE_OK);
     97  1.1  christos }
     98  1.1  christos 
     99  1.1  christos 
    100  1.1  christos /*******************************************************************************
    101  1.1  christos  *
    102  1.1  christos  * FUNCTION:    AcpiDbHexByteToBinary
    103  1.1  christos  *
    104  1.1  christos  * PARAMETERS:  HexByte             - Double hex digit (0x00 - 0xFF) in format:
    105  1.1  christos  *                                    HiByte then LoByte.
    106  1.1  christos  *              ReturnValue         - Where the converted value is returned
    107  1.1  christos  *
    108  1.1  christos  * RETURN:      Status
    109  1.1  christos  *
    110  1.1  christos  * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255).
    111  1.1  christos  *
    112  1.1  christos  ******************************************************************************/
    113  1.1  christos 
    114  1.1  christos static ACPI_STATUS
    115  1.1  christos AcpiDbHexByteToBinary (
    116  1.1  christos     char                    *HexByte,
    117  1.1  christos     UINT8                   *ReturnValue)
    118  1.1  christos {
    119  1.1  christos     UINT8                   Local0;
    120  1.1  christos     UINT8                   Local1;
    121  1.1  christos     ACPI_STATUS             Status;
    122  1.1  christos 
    123  1.1  christos 
    124  1.1  christos     /* High byte */
    125  1.1  christos 
    126  1.1  christos     Status = AcpiDbHexCharToValue (HexByte[0], &Local0);
    127  1.1  christos     if (ACPI_FAILURE (Status))
    128  1.1  christos     {
    129  1.1  christos         return (Status);
    130  1.1  christos     }
    131  1.1  christos 
    132  1.1  christos     /* Low byte */
    133  1.1  christos 
    134  1.1  christos     Status = AcpiDbHexCharToValue (HexByte[1], &Local1);
    135  1.1  christos     if (ACPI_FAILURE (Status))
    136  1.1  christos     {
    137  1.1  christos         return (Status);
    138  1.1  christos     }
    139  1.1  christos 
    140  1.1  christos     *ReturnValue = (UINT8) ((Local0 << 4) | Local1);
    141  1.1  christos     return (AE_OK);
    142  1.1  christos }
    143  1.1  christos 
    144  1.1  christos 
    145  1.1  christos /*******************************************************************************
    146  1.1  christos  *
    147  1.1  christos  * FUNCTION:    AcpiDbConvertToBuffer
    148  1.1  christos  *
    149  1.1  christos  * PARAMETERS:  String              - Input string to be converted
    150  1.1  christos  *              Object              - Where the buffer object is returned
    151  1.1  christos  *
    152  1.1  christos  * RETURN:      Status
    153  1.1  christos  *
    154  1.1  christos  * DESCRIPTION: Convert a string to a buffer object. String is treated a list
    155  1.1  christos  *              of buffer elements, each separated by a space or comma.
    156  1.1  christos  *
    157  1.1  christos  ******************************************************************************/
    158  1.1  christos 
    159  1.1  christos static ACPI_STATUS
    160  1.1  christos AcpiDbConvertToBuffer (
    161  1.1  christos     char                    *String,
    162  1.1  christos     ACPI_OBJECT             *Object)
    163  1.1  christos {
    164  1.1  christos     UINT32                  i;
    165  1.1  christos     UINT32                  j;
    166  1.1  christos     UINT32                  Length;
    167  1.1  christos     UINT8                   *Buffer;
    168  1.1  christos     ACPI_STATUS             Status;
    169  1.1  christos 
    170  1.1  christos 
    171  1.1  christos     /* Generate the final buffer length */
    172  1.1  christos 
    173  1.1  christos     for (i = 0, Length = 0; String[i];)
    174  1.1  christos     {
    175  1.1  christos         i+=2;
    176  1.1  christos         Length++;
    177  1.1  christos 
    178  1.1  christos         while (String[i] &&
    179  1.1  christos               ((String[i] == ',') || (String[i] == ' ')))
    180  1.1  christos         {
    181  1.1  christos             i++;
    182  1.1  christos         }
    183  1.1  christos     }
    184  1.1  christos 
    185  1.1  christos     Buffer = ACPI_ALLOCATE (Length);
    186  1.1  christos     if (!Buffer)
    187  1.1  christos     {
    188  1.1  christos         return (AE_NO_MEMORY);
    189  1.1  christos     }
    190  1.1  christos 
    191  1.1  christos     /* Convert the command line bytes to the buffer */
    192  1.1  christos 
    193  1.1  christos     for (i = 0, j = 0; String[i];)
    194  1.1  christos     {
    195  1.1  christos         Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]);
    196  1.1  christos         if (ACPI_FAILURE (Status))
    197  1.1  christos         {
    198  1.1  christos             ACPI_FREE (Buffer);
    199  1.1  christos             return (Status);
    200  1.1  christos         }
    201  1.1  christos 
    202  1.1  christos         j++;
    203  1.1  christos         i+=2;
    204  1.1  christos         while (String[i] &&
    205  1.1  christos               ((String[i] == ',') || (String[i] == ' ')))
    206  1.1  christos         {
    207  1.1  christos             i++;
    208  1.1  christos         }
    209  1.1  christos     }
    210  1.1  christos 
    211  1.1  christos     Object->Type = ACPI_TYPE_BUFFER;
    212  1.1  christos     Object->Buffer.Pointer = Buffer;
    213  1.1  christos     Object->Buffer.Length = Length;
    214  1.1  christos     return (AE_OK);
    215  1.1  christos }
    216  1.1  christos 
    217  1.1  christos 
    218  1.1  christos /*******************************************************************************
    219  1.1  christos  *
    220  1.1  christos  * FUNCTION:    AcpiDbConvertToPackage
    221  1.1  christos  *
    222  1.1  christos  * PARAMETERS:  String              - Input string to be converted
    223  1.1  christos  *              Object              - Where the package object is returned
    224  1.1  christos  *
    225  1.1  christos  * RETURN:      Status
    226  1.1  christos  *
    227  1.1  christos  * DESCRIPTION: Convert a string to a package object. Handles nested packages
    228  1.1  christos  *              via recursion with AcpiDbConvertToObject.
    229  1.1  christos  *
    230  1.1  christos  ******************************************************************************/
    231  1.1  christos 
    232  1.1  christos ACPI_STATUS
    233  1.1  christos AcpiDbConvertToPackage (
    234  1.1  christos     char                    *String,
    235  1.1  christos     ACPI_OBJECT             *Object)
    236  1.1  christos {
    237  1.1  christos     char                    *This;
    238  1.1  christos     char                    *Next;
    239  1.1  christos     UINT32                  i;
    240  1.1  christos     ACPI_OBJECT_TYPE        Type;
    241  1.1  christos     ACPI_OBJECT             *Elements;
    242  1.1  christos     ACPI_STATUS             Status;
    243  1.1  christos 
    244  1.1  christos 
    245  1.1  christos     Elements = ACPI_ALLOCATE_ZEROED (
    246  1.1  christos         DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT));
    247  1.1  christos 
    248  1.1  christos     This = String;
    249  1.1  christos     for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++)
    250  1.1  christos     {
    251  1.1  christos         This = AcpiDbGetNextToken (This, &Next, &Type);
    252  1.1  christos         if (!This)
    253  1.1  christos         {
    254  1.1  christos             break;
    255  1.1  christos         }
    256  1.1  christos 
    257  1.1  christos         /* Recursive call to convert each package element */
    258  1.1  christos 
    259  1.1  christos         Status = AcpiDbConvertToObject (Type, This, &Elements[i]);
    260  1.1  christos         if (ACPI_FAILURE (Status))
    261  1.1  christos         {
    262  1.1  christos             AcpiDbDeleteObjects (i + 1, Elements);
    263  1.1  christos             ACPI_FREE (Elements);
    264  1.1  christos             return (Status);
    265  1.1  christos         }
    266  1.1  christos 
    267  1.1  christos         This = Next;
    268  1.1  christos     }
    269  1.1  christos 
    270  1.1  christos     Object->Type = ACPI_TYPE_PACKAGE;
    271  1.1  christos     Object->Package.Count = i;
    272  1.1  christos     Object->Package.Elements = Elements;
    273  1.1  christos     return (AE_OK);
    274  1.1  christos }
    275  1.1  christos 
    276  1.1  christos 
    277  1.1  christos /*******************************************************************************
    278  1.1  christos  *
    279  1.1  christos  * FUNCTION:    AcpiDbConvertToObject
    280  1.1  christos  *
    281  1.1  christos  * PARAMETERS:  Type                - Object type as determined by parser
    282  1.1  christos  *              String              - Input string to be converted
    283  1.1  christos  *              Object              - Where the new object is returned
    284  1.1  christos  *
    285  1.1  christos  * RETURN:      Status
    286  1.1  christos  *
    287  1.1  christos  * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing:
    288  1.1  christos  *              1) String objects were surrounded by quotes.
    289  1.1  christos  *              2) Buffer objects were surrounded by parentheses.
    290  1.1  christos  *              3) Package objects were surrounded by brackets "[]".
    291  1.1  christos  *              4) All standalone tokens are treated as integers.
    292  1.1  christos  *
    293  1.1  christos  ******************************************************************************/
    294  1.1  christos 
    295  1.1  christos ACPI_STATUS
    296  1.1  christos AcpiDbConvertToObject (
    297  1.1  christos     ACPI_OBJECT_TYPE        Type,
    298  1.1  christos     char                    *String,
    299  1.1  christos     ACPI_OBJECT             *Object)
    300  1.1  christos {
    301  1.1  christos     ACPI_STATUS             Status = AE_OK;
    302  1.1  christos 
    303  1.1  christos 
    304  1.1  christos     switch (Type)
    305  1.1  christos     {
    306  1.1  christos     case ACPI_TYPE_STRING:
    307  1.1  christos 
    308  1.1  christos         Object->Type = ACPI_TYPE_STRING;
    309  1.1  christos         Object->String.Pointer = String;
    310  1.1  christos         Object->String.Length = (UINT32) ACPI_STRLEN (String);
    311  1.1  christos         break;
    312  1.1  christos 
    313  1.1  christos     case ACPI_TYPE_BUFFER:
    314  1.1  christos 
    315  1.1  christos         Status = AcpiDbConvertToBuffer (String, Object);
    316  1.1  christos         break;
    317  1.1  christos 
    318  1.1  christos     case ACPI_TYPE_PACKAGE:
    319  1.1  christos 
    320  1.1  christos         Status = AcpiDbConvertToPackage (String, Object);
    321  1.1  christos         break;
    322  1.1  christos 
    323  1.1  christos     default:
    324  1.1  christos 
    325  1.1  christos         Object->Type = ACPI_TYPE_INTEGER;
    326  1.1  christos         Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value);
    327  1.1  christos         break;
    328  1.1  christos     }
    329  1.1  christos 
    330  1.1  christos     return (Status);
    331  1.1  christos }
    332  1.1  christos 
    333  1.1  christos 
    334  1.1  christos /*******************************************************************************
    335  1.1  christos  *
    336  1.1  christos  * FUNCTION:    AcpiDbEncodePldBuffer
    337  1.1  christos  *
    338  1.1  christos  * PARAMETERS:  PldInfo             - _PLD buffer struct (Using local struct)
    339  1.1  christos  *
    340  1.1  christos  * RETURN:      Encode _PLD buffer suitable for return value from _PLD
    341  1.1  christos  *
    342  1.1  christos  * DESCRIPTION: Bit-packs a _PLD buffer struct. Used to test the _PLD macros
    343  1.1  christos  *
    344  1.1  christos  ******************************************************************************/
    345  1.1  christos 
    346  1.1  christos UINT8 *
    347  1.1  christos AcpiDbEncodePldBuffer (
    348  1.1  christos     ACPI_PLD_INFO           *PldInfo)
    349  1.1  christos {
    350  1.1  christos     UINT32                  *Buffer;
    351  1.1  christos     UINT32                  Dword;
    352  1.1  christos 
    353  1.1  christos 
    354  1.1  christos     Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE);
    355  1.1  christos     if (!Buffer)
    356  1.1  christos     {
    357  1.1  christos         return (NULL);
    358  1.1  christos     }
    359  1.1  christos 
    360  1.1  christos     /* First 32 bits */
    361  1.1  christos 
    362  1.1  christos     Dword = 0;
    363  1.1  christos     ACPI_PLD_SET_REVISION       (&Dword, PldInfo->Revision);
    364  1.1  christos     ACPI_PLD_SET_IGNORE_COLOR   (&Dword, PldInfo->IgnoreColor);
    365  1.1  christos     ACPI_PLD_SET_COLOR          (&Dword, PldInfo->Color);
    366  1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword);
    367  1.1  christos 
    368  1.1  christos     /* Second 32 bits */
    369  1.1  christos 
    370  1.1  christos     Dword = 0;
    371  1.1  christos     ACPI_PLD_SET_WIDTH          (&Dword, PldInfo->Width);
    372  1.1  christos     ACPI_PLD_SET_HEIGHT         (&Dword, PldInfo->Height);
    373  1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword);
    374  1.1  christos 
    375  1.1  christos     /* Third 32 bits */
    376  1.1  christos 
    377  1.1  christos     Dword = 0;
    378  1.1  christos     ACPI_PLD_SET_USER_VISIBLE   (&Dword, PldInfo->UserVisible);
    379  1.1  christos     ACPI_PLD_SET_DOCK           (&Dword, PldInfo->Dock);
    380  1.1  christos     ACPI_PLD_SET_LID            (&Dword, PldInfo->Lid);
    381  1.1  christos     ACPI_PLD_SET_PANEL          (&Dword, PldInfo->Panel);
    382  1.1  christos     ACPI_PLD_SET_VERTICAL       (&Dword, PldInfo->VerticalPosition);
    383  1.1  christos     ACPI_PLD_SET_HORIZONTAL     (&Dword, PldInfo->HorizontalPosition);
    384  1.1  christos     ACPI_PLD_SET_SHAPE          (&Dword, PldInfo->Shape);
    385  1.1  christos     ACPI_PLD_SET_ORIENTATION    (&Dword, PldInfo->GroupOrientation);
    386  1.1  christos     ACPI_PLD_SET_TOKEN          (&Dword, PldInfo->GroupToken);
    387  1.1  christos     ACPI_PLD_SET_POSITION       (&Dword, PldInfo->GroupPosition);
    388  1.1  christos     ACPI_PLD_SET_BAY            (&Dword, PldInfo->Bay);
    389  1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword);
    390  1.1  christos 
    391  1.1  christos     /* Fourth 32 bits */
    392  1.1  christos 
    393  1.1  christos     Dword = 0;
    394  1.1  christos     ACPI_PLD_SET_EJECTABLE      (&Dword, PldInfo->Ejectable);
    395  1.1  christos     ACPI_PLD_SET_OSPM_EJECT     (&Dword, PldInfo->OspmEjectRequired);
    396  1.1  christos     ACPI_PLD_SET_CABINET        (&Dword, PldInfo->CabinetNumber);
    397  1.1  christos     ACPI_PLD_SET_CARD_CAGE      (&Dword, PldInfo->CardCageNumber);
    398  1.1  christos     ACPI_PLD_SET_REFERENCE      (&Dword, PldInfo->Reference);
    399  1.1  christos     ACPI_PLD_SET_ROTATION       (&Dword, PldInfo->Rotation);
    400  1.1  christos     ACPI_PLD_SET_ORDER          (&Dword, PldInfo->Order);
    401  1.1  christos     ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword);
    402  1.1  christos 
    403  1.1  christos     if (PldInfo->Revision >= 2)
    404  1.1  christos     {
    405  1.1  christos         /* Fifth 32 bits */
    406  1.1  christos 
    407  1.1  christos         Dword = 0;
    408  1.1  christos         ACPI_PLD_SET_VERT_OFFSET    (&Dword, PldInfo->VerticalOffset);
    409  1.1  christos         ACPI_PLD_SET_HORIZ_OFFSET   (&Dword, PldInfo->HorizontalOffset);
    410  1.1  christos         ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword);
    411  1.1  christos     }
    412  1.1  christos 
    413  1.1  christos     return (ACPI_CAST_PTR (UINT8, Buffer));
    414  1.1  christos }
    415  1.1  christos 
    416  1.1  christos 
    417  1.1  christos /*******************************************************************************
    418  1.1  christos  *
    419  1.1  christos  * FUNCTION:    AcpiDbDumpPldBuffer
    420  1.1  christos  *
    421  1.1  christos  * PARAMETERS:  ObjDesc             - Object returned from _PLD method
    422  1.1  christos  *
    423  1.1  christos  * RETURN:      None.
    424  1.1  christos  *
    425  1.1  christos  * DESCRIPTION: Dumps formatted contents of a _PLD return buffer.
    426  1.1  christos  *
    427  1.1  christos  ******************************************************************************/
    428  1.1  christos 
    429  1.1  christos #define ACPI_PLD_OUTPUT     "%20s : %-6X\n"
    430  1.1  christos 
    431  1.1  christos void
    432  1.1  christos AcpiDbDumpPldBuffer (
    433  1.1  christos     ACPI_OBJECT             *ObjDesc)
    434  1.1  christos {
    435  1.1  christos     ACPI_OBJECT             *BufferDesc;
    436  1.1  christos     ACPI_PLD_INFO           *PldInfo;
    437  1.1  christos     UINT8                   *NewBuffer;
    438  1.1  christos     ACPI_STATUS             Status;
    439  1.1  christos 
    440  1.1  christos 
    441  1.1  christos     /* Object must be of type Package with at least one Buffer element */
    442  1.1  christos 
    443  1.1  christos     if (ObjDesc->Type != ACPI_TYPE_PACKAGE)
    444  1.1  christos     {
    445  1.1  christos         return;
    446  1.1  christos     }
    447  1.1  christos 
    448  1.1  christos     BufferDesc = &ObjDesc->Package.Elements[0];
    449  1.1  christos     if (BufferDesc->Type != ACPI_TYPE_BUFFER)
    450  1.1  christos     {
    451  1.1  christos         return;
    452  1.1  christos     }
    453  1.1  christos 
    454  1.1  christos     /* Convert _PLD buffer to local _PLD struct */
    455  1.1  christos 
    456  1.1  christos     Status = AcpiDecodePldBuffer (BufferDesc->Buffer.Pointer,
    457  1.1  christos         BufferDesc->Buffer.Length, &PldInfo);
    458  1.1  christos     if (ACPI_FAILURE (Status))
    459  1.1  christos     {
    460  1.1  christos         return;
    461  1.1  christos     }
    462  1.1  christos 
    463  1.1  christos     /* Encode local _PLD struct back to a _PLD buffer */
    464  1.1  christos 
    465  1.1  christos     NewBuffer = AcpiDbEncodePldBuffer (PldInfo);
    466  1.1  christos     if (!NewBuffer)
    467  1.1  christos     {
    468  1.1  christos         return;
    469  1.1  christos     }
    470  1.1  christos 
    471  1.1  christos     /* The two bit-packed buffers should match */
    472  1.1  christos 
    473  1.1  christos     if (ACPI_MEMCMP (NewBuffer, BufferDesc->Buffer.Pointer,
    474  1.1  christos         BufferDesc->Buffer.Length))
    475  1.1  christos     {
    476  1.1  christos         AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n");
    477  1.1  christos 
    478  1.1  christos         AcpiUtDumpBuffer (NewBuffer,
    479  1.1  christos             BufferDesc->Buffer.Length, DB_BYTE_DISPLAY, 0);
    480  1.1  christos     }
    481  1.1  christos 
    482  1.1  christos     /* First 32-bit dword */
    483  1.1  christos 
    484  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Revision", PldInfo->Revision);
    485  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "IgnoreColor", PldInfo->IgnoreColor);
    486  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Color", PldInfo->Color);
    487  1.1  christos 
    488  1.1  christos     /* Second 32-bit dword */
    489  1.1  christos 
    490  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Width", PldInfo->Width);
    491  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Height", PldInfo->Height);
    492  1.1  christos 
    493  1.1  christos     /* Third 32-bit dword */
    494  1.1  christos 
    495  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "UserVisible", PldInfo->UserVisible);
    496  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Dock", PldInfo->Dock);
    497  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Lid", PldInfo->Lid);
    498  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Panel", PldInfo->Panel);
    499  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "VerticalPosition", PldInfo->VerticalPosition);
    500  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "HorizontalPosition", PldInfo->HorizontalPosition);
    501  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Shape", PldInfo->Shape);
    502  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "GroupOrientation", PldInfo->GroupOrientation);
    503  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "GroupToken", PldInfo->GroupToken);
    504  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "GroupPosition", PldInfo->GroupPosition);
    505  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Bay", PldInfo->Bay);
    506  1.1  christos 
    507  1.1  christos     /* Fourth 32-bit dword */
    508  1.1  christos 
    509  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Ejectable", PldInfo->Ejectable);
    510  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "OspmEjectRequired", PldInfo->OspmEjectRequired);
    511  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "CabinetNumber", PldInfo->CabinetNumber);
    512  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "CardCageNumber", PldInfo->CardCageNumber);
    513  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Reference", PldInfo->Reference);
    514  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Rotation", PldInfo->Rotation);
    515  1.1  christos     AcpiOsPrintf (ACPI_PLD_OUTPUT, "Order", PldInfo->Order);
    516  1.1  christos 
    517  1.1  christos     /* Fifth 32-bit dword */
    518  1.1  christos 
    519  1.1  christos     if (BufferDesc->Buffer.Length > 16)
    520  1.1  christos     {
    521  1.1  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT, "VerticalOffset", PldInfo->VerticalOffset);
    522  1.1  christos         AcpiOsPrintf (ACPI_PLD_OUTPUT, "HorizontalOffset", PldInfo->HorizontalOffset);
    523  1.1  christos     }
    524  1.1  christos 
    525  1.1  christos     ACPI_FREE (PldInfo);
    526  1.1  christos     ACPI_FREE (NewBuffer);
    527  1.1  christos }
    528  1.1  christos 
    529  1.1  christos #endif /* ACPI_DEBUGGER */
    530