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