Home | History | Annotate | Line # | Download | only in compiler
aslpld.c revision 1.1.1.10
      1       1.1  christos /******************************************************************************
      2       1.1  christos  *
      3       1.1  christos  * Module Name: aslpld - Implementation of ASL ToPLD macro
      4       1.1  christos  *
      5       1.1  christos  *****************************************************************************/
      6       1.1  christos 
      7       1.1  christos /*
      8  1.1.1.10  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.8  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 "aslcompiler.h"
     45       1.1  christos #include "aslcompiler.y.h"
     46       1.1  christos #include "amlcode.h"
     47       1.1  christos 
     48       1.1  christos #define _COMPONENT          ACPI_COMPILER
     49       1.1  christos         ACPI_MODULE_NAME    ("aslpld")
     50       1.1  christos 
     51       1.1  christos 
     52       1.1  christos /* Local prototypes */
     53       1.1  christos 
     54       1.1  christos static UINT8 *
     55       1.1  christos OpcEncodePldBuffer (
     56       1.1  christos     ACPI_PLD_INFO           *PldInfo);
     57       1.1  christos 
     58       1.1  christos static BOOLEAN
     59       1.1  christos OpcFindName (
     60       1.1  christos     const char              **List,
     61       1.1  christos     char                    *Name,
     62       1.1  christos     UINT32                  *Index);
     63       1.1  christos 
     64       1.1  christos 
     65       1.1  christos /*******************************************************************************
     66       1.1  christos  *
     67       1.1  christos  * FUNCTION:    OpcDoPld
     68       1.1  christos  *
     69       1.1  christos  * PARAMETERS:  Op                  - Current parse node
     70       1.1  christos  *
     71       1.1  christos  * RETURN:      None
     72       1.1  christos  *
     73       1.1  christos  * DESCRIPTION: Convert ToPLD macro to 20-byte buffer
     74       1.1  christos  *
     75       1.1  christos  * The ToPLD parse tree looks like this:
     76       1.1  christos  *
     77       1.1  christos  *      TOPLD
     78       1.1  christos  *          PLD_REVISION
     79       1.1  christos  *              INTEGER
     80       1.1  christos  *          PLD_IGNORECOLOR
     81       1.1  christos  *              INTEGER
     82       1.1  christos  *          ...
     83       1.1  christos  *          etc.
     84       1.1  christos  *
     85       1.1  christos  ******************************************************************************/
     86       1.1  christos 
     87       1.1  christos void
     88       1.1  christos OpcDoPld (
     89       1.1  christos     ACPI_PARSE_OBJECT       *Op)
     90       1.1  christos {
     91       1.1  christos     ACPI_PLD_INFO           PldInfo;
     92       1.1  christos     UINT8                   *Buffer;
     93       1.1  christos     ACPI_PARSE_OBJECT       *ThisOp;
     94       1.1  christos     ACPI_PARSE_OBJECT       *NewOp;
     95       1.1  christos     UINT16                  ParseOpcode;
     96       1.1  christos     UINT32                  Value;
     97       1.1  christos 
     98       1.1  christos 
     99       1.1  christos     if (!Op)
    100       1.1  christos     {
    101       1.1  christos         AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL);
    102       1.1  christos         return;
    103       1.1  christos     }
    104       1.1  christos 
    105       1.1  christos     if (Op->Asl.ParseOpcode != PARSEOP_TOPLD)
    106       1.1  christos     {
    107       1.1  christos         AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL);
    108       1.1  christos         return;
    109       1.1  christos     }
    110       1.1  christos 
    111       1.1  christos     memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
    112       1.1  christos 
    113       1.1  christos     /* Traverse the list of PLD Ops (one per PLD field) */
    114       1.1  christos 
    115       1.1  christos     ThisOp = Op->Asl.Child;
    116       1.1  christos     while (ThisOp)
    117       1.1  christos     {
    118       1.1  christos         /* Get child values */
    119       1.1  christos 
    120       1.1  christos         ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode;
    121       1.1  christos         Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer;
    122       1.1  christos 
    123       1.1  christos         switch (ThisOp->Asl.ParseOpcode)
    124       1.1  christos         {
    125       1.1  christos         case PARSEOP_PLD_REVISION:
    126       1.1  christos 
    127       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    128       1.1  christos             {
    129       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    130       1.1  christos                 break;
    131       1.1  christos             }
    132       1.1  christos 
    133       1.1  christos             if (Value > 127)
    134       1.1  christos             {
    135       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    136       1.1  christos                 break;
    137       1.1  christos             }
    138       1.1  christos 
    139       1.1  christos             PldInfo.Revision = (UINT8) Value;
    140       1.1  christos             break;
    141       1.1  christos 
    142       1.1  christos         case PARSEOP_PLD_IGNORECOLOR:
    143       1.1  christos 
    144       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    145       1.1  christos             {
    146       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    147       1.1  christos                 break;
    148       1.1  christos             }
    149       1.1  christos 
    150       1.1  christos             if (Value > 1)
    151       1.1  christos             {
    152       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    153       1.1  christos                 break;
    154       1.1  christos             }
    155       1.1  christos 
    156       1.1  christos             PldInfo.IgnoreColor = (UINT8) Value;
    157       1.1  christos             break;
    158       1.1  christos 
    159       1.1  christos         case PARSEOP_PLD_RED:
    160       1.1  christos         case PARSEOP_PLD_GREEN:
    161       1.1  christos         case PARSEOP_PLD_BLUE:
    162       1.1  christos 
    163       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    164       1.1  christos             {
    165       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    166       1.1  christos                 break;
    167       1.1  christos             }
    168       1.1  christos 
    169       1.1  christos             if (Value > 255)
    170       1.1  christos             {
    171       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    172       1.1  christos                 break;
    173       1.1  christos             }
    174       1.1  christos 
    175       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED)
    176       1.1  christos             {
    177       1.1  christos                 PldInfo.Red = (UINT8) Value;
    178       1.1  christos             }
    179       1.1  christos             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN)
    180       1.1  christos             {
    181       1.1  christos                 PldInfo.Green = (UINT8) Value;
    182       1.1  christos             }
    183       1.1  christos             else /* PARSEOP_PLD_BLUE */
    184       1.1  christos             {
    185       1.1  christos                 PldInfo.Blue = (UINT8) Value;
    186       1.1  christos             }
    187       1.1  christos             break;
    188       1.1  christos 
    189       1.1  christos         case PARSEOP_PLD_WIDTH:
    190       1.1  christos         case PARSEOP_PLD_HEIGHT:
    191       1.1  christos 
    192       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    193       1.1  christos             {
    194       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    195       1.1  christos                 break;
    196       1.1  christos             }
    197       1.1  christos 
    198       1.1  christos             if (Value > 65535)
    199       1.1  christos             {
    200       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    201       1.1  christos                 break;
    202       1.1  christos             }
    203       1.1  christos 
    204       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH)
    205       1.1  christos             {
    206       1.1  christos                 PldInfo.Width = (UINT16) Value;
    207       1.1  christos             }
    208       1.1  christos             else /* PARSEOP_PLD_HEIGHT */
    209       1.1  christos             {
    210       1.1  christos                 PldInfo.Height = (UINT16) Value;
    211       1.1  christos             }
    212       1.1  christos 
    213       1.1  christos             break;
    214       1.1  christos 
    215       1.1  christos         case PARSEOP_PLD_USERVISIBLE:
    216       1.1  christos         case PARSEOP_PLD_DOCK:
    217       1.1  christos         case PARSEOP_PLD_LID:
    218       1.1  christos 
    219       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    220       1.1  christos             {
    221       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    222       1.1  christos                 break;
    223       1.1  christos             }
    224       1.1  christos 
    225       1.1  christos             if (Value > 1)
    226       1.1  christos             {
    227       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    228       1.1  christos                 break;
    229       1.1  christos             }
    230       1.1  christos 
    231       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE)
    232       1.1  christos             {
    233       1.1  christos                 PldInfo.UserVisible = (UINT8) Value;
    234       1.1  christos             }
    235       1.1  christos             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK)
    236       1.1  christos             {
    237       1.1  christos                 PldInfo.Dock = (UINT8) Value;
    238       1.1  christos             }
    239       1.1  christos             else
    240       1.1  christos             {
    241       1.1  christos                 PldInfo.Lid = (UINT8) Value;
    242       1.1  christos             }
    243       1.1  christos 
    244       1.1  christos             break;
    245       1.1  christos 
    246       1.1  christos         case PARSEOP_PLD_PANEL:
    247       1.1  christos 
    248       1.1  christos             if (ParseOpcode == PARSEOP_INTEGER)
    249       1.1  christos             {
    250       1.1  christos                 if (Value > 6)
    251       1.1  christos                 {
    252       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    253       1.1  christos                     break;
    254       1.1  christos                 }
    255       1.1  christos             }
    256       1.1  christos             else /* PARSEOP_STRING */
    257       1.1  christos             {
    258       1.1  christos                 if (!OpcFindName (AcpiGbl_PldPanelList,
    259       1.1  christos                     ThisOp->Asl.Child->Asl.Value.String,
    260       1.1  christos                     &Value))
    261       1.1  christos                 {
    262       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
    263       1.1  christos                     break;
    264       1.1  christos                 }
    265       1.1  christos             }
    266       1.1  christos 
    267       1.1  christos             PldInfo.Panel = (UINT8) Value;
    268       1.1  christos             break;
    269       1.1  christos 
    270       1.1  christos         case PARSEOP_PLD_VERTICALPOSITION:
    271       1.1  christos 
    272       1.1  christos             if (ParseOpcode == PARSEOP_INTEGER)
    273       1.1  christos             {
    274       1.1  christos                 if (Value > 2)
    275       1.1  christos                 {
    276       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    277       1.1  christos                     break;
    278       1.1  christos                 }
    279       1.1  christos             }
    280       1.1  christos             else /* PARSEOP_STRING */
    281       1.1  christos             {
    282       1.1  christos                 if (!OpcFindName (AcpiGbl_PldVerticalPositionList,
    283       1.1  christos                     ThisOp->Asl.Child->Asl.Value.String,
    284       1.1  christos                     &Value))
    285       1.1  christos                 {
    286       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
    287       1.1  christos                     break;
    288       1.1  christos                 }
    289       1.1  christos             }
    290       1.1  christos 
    291       1.1  christos             PldInfo.VerticalPosition = (UINT8) Value;
    292       1.1  christos             break;
    293       1.1  christos 
    294       1.1  christos         case PARSEOP_PLD_HORIZONTALPOSITION:
    295       1.1  christos 
    296       1.1  christos             if (ParseOpcode == PARSEOP_INTEGER)
    297       1.1  christos             {
    298       1.1  christos                 if (Value > 2)
    299       1.1  christos                 {
    300       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    301       1.1  christos                     break;
    302       1.1  christos                 }
    303       1.1  christos             }
    304       1.1  christos             else /* PARSEOP_STRING */
    305       1.1  christos             {
    306       1.1  christos                 if (!OpcFindName (AcpiGbl_PldHorizontalPositionList,
    307       1.1  christos                     ThisOp->Asl.Child->Asl.Value.String,
    308       1.1  christos                     &Value))
    309       1.1  christos                 {
    310       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
    311       1.1  christos                     break;
    312       1.1  christos                 }
    313       1.1  christos             }
    314       1.1  christos 
    315       1.1  christos             PldInfo.HorizontalPosition = (UINT8) Value;
    316       1.1  christos             break;
    317       1.1  christos 
    318       1.1  christos         case PARSEOP_PLD_SHAPE:
    319       1.1  christos 
    320       1.1  christos             if (ParseOpcode == PARSEOP_INTEGER)
    321       1.1  christos             {
    322       1.1  christos                 if (Value > 8)
    323       1.1  christos                 {
    324       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    325       1.1  christos                     break;
    326       1.1  christos                 }
    327       1.1  christos             }
    328       1.1  christos             else /* PARSEOP_STRING */
    329       1.1  christos             {
    330       1.1  christos                 if (!OpcFindName (AcpiGbl_PldShapeList,
    331       1.1  christos                     ThisOp->Asl.Child->Asl.Value.String,
    332       1.1  christos                     &Value))
    333       1.1  christos                 {
    334       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
    335       1.1  christos                     break;
    336       1.1  christos                 }
    337       1.1  christos             }
    338       1.1  christos 
    339       1.1  christos             PldInfo.Shape = (UINT8) Value;
    340       1.1  christos             break;
    341       1.1  christos 
    342       1.1  christos         case PARSEOP_PLD_GROUPORIENTATION:
    343       1.1  christos 
    344       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    345       1.1  christos             {
    346       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    347       1.1  christos                 break;
    348       1.1  christos             }
    349       1.1  christos 
    350       1.1  christos             if (Value > 1)
    351       1.1  christos             {
    352       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    353       1.1  christos                 break;
    354       1.1  christos             }
    355       1.1  christos 
    356       1.1  christos             PldInfo.GroupOrientation = (UINT8) Value;
    357       1.1  christos             break;
    358       1.1  christos 
    359       1.1  christos         case PARSEOP_PLD_GROUPTOKEN:
    360       1.1  christos         case PARSEOP_PLD_GROUPPOSITION:
    361       1.1  christos 
    362       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    363       1.1  christos             {
    364       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    365       1.1  christos                 break;
    366       1.1  christos             }
    367       1.1  christos 
    368       1.1  christos             if (Value > 255)
    369       1.1  christos             {
    370       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    371       1.1  christos                 break;
    372       1.1  christos             }
    373       1.1  christos 
    374       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN)
    375       1.1  christos             {
    376       1.1  christos                 PldInfo.GroupToken = (UINT8) Value;
    377       1.1  christos             }
    378       1.1  christos             else /* PARSEOP_PLD_GROUPPOSITION */
    379       1.1  christos             {
    380       1.1  christos                 PldInfo.GroupPosition = (UINT8) Value;
    381       1.1  christos             }
    382       1.1  christos 
    383       1.1  christos             break;
    384       1.1  christos 
    385       1.1  christos         case PARSEOP_PLD_BAY:
    386       1.1  christos         case PARSEOP_PLD_EJECTABLE:
    387       1.1  christos         case PARSEOP_PLD_EJECTREQUIRED:
    388       1.1  christos 
    389       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    390       1.1  christos             {
    391       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    392       1.1  christos                 break;
    393       1.1  christos             }
    394       1.1  christos 
    395       1.1  christos             if (Value > 1)
    396       1.1  christos             {
    397       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    398       1.1  christos                 break;
    399       1.1  christos             }
    400       1.1  christos 
    401       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY)
    402       1.1  christos             {
    403       1.1  christos                 PldInfo.Bay = (UINT8) Value;
    404       1.1  christos             }
    405       1.1  christos             else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE)
    406       1.1  christos             {
    407       1.1  christos                 PldInfo.Ejectable = (UINT8) Value;
    408       1.1  christos             }
    409       1.1  christos             else /* PARSEOP_PLD_EJECTREQUIRED */
    410       1.1  christos             {
    411       1.1  christos                 PldInfo.OspmEjectRequired = (UINT8) Value;
    412       1.1  christos             }
    413       1.1  christos 
    414       1.1  christos             break;
    415       1.1  christos 
    416       1.1  christos         case PARSEOP_PLD_CABINETNUMBER:
    417       1.1  christos         case PARSEOP_PLD_CARDCAGENUMBER:
    418       1.1  christos 
    419       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    420       1.1  christos             {
    421       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    422       1.1  christos                 break;
    423       1.1  christos             }
    424       1.1  christos 
    425       1.1  christos             if (Value > 255)
    426       1.1  christos             {
    427       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    428       1.1  christos                 break;
    429       1.1  christos             }
    430       1.1  christos 
    431       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER)
    432       1.1  christos             {
    433       1.1  christos                 PldInfo.CabinetNumber = (UINT8) Value;
    434       1.1  christos             }
    435       1.1  christos             else /* PARSEOP_PLD_CARDCAGENUMBER */
    436       1.1  christos             {
    437       1.1  christos                 PldInfo.CardCageNumber = (UINT8) Value;
    438       1.1  christos             }
    439       1.1  christos 
    440       1.1  christos             break;
    441       1.1  christos 
    442       1.1  christos         case PARSEOP_PLD_REFERENCE:
    443       1.1  christos 
    444       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    445       1.1  christos             {
    446       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    447       1.1  christos                 break;
    448       1.1  christos             }
    449       1.1  christos 
    450       1.1  christos             if (Value > 1)
    451       1.1  christos             {
    452       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    453       1.1  christos                 break;
    454       1.1  christos             }
    455       1.1  christos 
    456       1.1  christos             PldInfo.Reference = (UINT8) Value;
    457       1.1  christos             break;
    458       1.1  christos 
    459       1.1  christos         case PARSEOP_PLD_ROTATION:
    460       1.1  christos 
    461       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    462       1.1  christos             {
    463       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    464       1.1  christos                 break;
    465       1.1  christos             }
    466       1.1  christos 
    467       1.1  christos             if (Value > 7)
    468       1.1  christos             {
    469       1.1  christos                 switch (Value)
    470       1.1  christos                 {
    471       1.1  christos                 case 45:
    472       1.1  christos 
    473       1.1  christos                     Value = 1;
    474       1.1  christos                     break;
    475       1.1  christos 
    476       1.1  christos                 case 90:
    477       1.1  christos 
    478       1.1  christos                     Value = 2;
    479       1.1  christos                     break;
    480       1.1  christos 
    481       1.1  christos                 case 135:
    482       1.1  christos 
    483       1.1  christos                     Value = 3;
    484       1.1  christos                     break;
    485       1.1  christos 
    486       1.1  christos                 case 180:
    487       1.1  christos 
    488       1.1  christos                     Value = 4;
    489       1.1  christos                     break;
    490       1.1  christos 
    491       1.1  christos                 case 225:
    492       1.1  christos 
    493       1.1  christos                     Value = 5;
    494       1.1  christos                     break;
    495       1.1  christos 
    496       1.1  christos                 case 270:
    497       1.1  christos 
    498       1.1  christos                     Value = 6;
    499       1.1  christos                     break;
    500       1.1  christos 
    501       1.1  christos                 case 315:
    502       1.1  christos 
    503       1.1  christos                     Value = 7;
    504       1.1  christos                     break;
    505       1.1  christos 
    506       1.1  christos                 default:
    507       1.1  christos 
    508       1.1  christos                     AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    509       1.1  christos                     break;
    510       1.1  christos                 }
    511       1.1  christos             }
    512       1.1  christos 
    513       1.1  christos             PldInfo.Rotation = (UINT8) Value;
    514       1.1  christos             break;
    515       1.1  christos 
    516       1.1  christos         case PARSEOP_PLD_ORDER:
    517       1.1  christos 
    518       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    519       1.1  christos             {
    520       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    521       1.1  christos                 break;
    522       1.1  christos             }
    523       1.1  christos 
    524       1.1  christos             if (Value > 31)
    525       1.1  christos             {
    526       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    527       1.1  christos                 break;
    528       1.1  christos             }
    529       1.1  christos 
    530       1.1  christos             PldInfo.Order = (UINT8) Value;
    531       1.1  christos             break;
    532       1.1  christos 
    533       1.1  christos         case PARSEOP_PLD_VERTICALOFFSET:
    534       1.1  christos         case PARSEOP_PLD_HORIZONTALOFFSET:
    535       1.1  christos 
    536       1.1  christos             if (ParseOpcode != PARSEOP_INTEGER)
    537       1.1  christos             {
    538       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    539       1.1  christos                 break;
    540       1.1  christos             }
    541       1.1  christos 
    542       1.1  christos             if (Value > 65535)
    543       1.1  christos             {
    544       1.1  christos                 AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
    545       1.1  christos                 break;
    546       1.1  christos             }
    547       1.1  christos 
    548       1.1  christos             if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET)
    549       1.1  christos             {
    550       1.1  christos                 PldInfo.VerticalOffset = (UINT16) Value;
    551       1.1  christos             }
    552       1.1  christos             else /* PARSEOP_PLD_HORIZONTALOFFSET */
    553       1.1  christos             {
    554       1.1  christos                 PldInfo.HorizontalOffset = (UINT16) Value;
    555       1.1  christos             }
    556       1.1  christos 
    557       1.1  christos             break;
    558       1.1  christos 
    559       1.1  christos         default:
    560       1.1  christos 
    561       1.1  christos             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
    562       1.1  christos             break;
    563       1.1  christos         }
    564       1.1  christos 
    565       1.1  christos         ThisOp = ThisOp->Asl.Next;
    566       1.1  christos     }
    567       1.1  christos 
    568       1.1  christos     Buffer = OpcEncodePldBuffer (&PldInfo);
    569       1.1  christos 
    570       1.1  christos     /* Change Op to a Buffer */
    571       1.1  christos 
    572       1.1  christos     Op->Asl.ParseOpcode = PARSEOP_BUFFER;
    573       1.1  christos     Op->Common.AmlOpcode = AML_BUFFER_OP;
    574       1.1  christos 
    575       1.1  christos     /* Disable further optimization */
    576       1.1  christos 
    577   1.1.1.3  christos     Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
    578       1.1  christos     UtSetParseOpName (Op);
    579       1.1  christos 
    580       1.1  christos     /* Child node is the buffer length */
    581       1.1  christos 
    582   1.1.1.3  christos     NewOp = TrAllocateOp (PARSEOP_INTEGER);
    583       1.1  christos 
    584       1.1  christos     NewOp->Asl.AmlOpcode = AML_BYTE_OP;
    585       1.1  christos     NewOp->Asl.Value.Integer = 20;
    586       1.1  christos     NewOp->Asl.Parent = Op;
    587       1.1  christos 
    588       1.1  christos     Op->Asl.Child = NewOp;
    589       1.1  christos     Op = NewOp;
    590       1.1  christos 
    591       1.1  christos     /* Peer to the child is the raw buffer data */
    592       1.1  christos 
    593   1.1.1.3  christos     NewOp = TrAllocateOp (PARSEOP_RAW_DATA);
    594       1.1  christos     NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
    595       1.1  christos     NewOp->Asl.AmlLength = 20;
    596       1.1  christos     NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
    597       1.1  christos     NewOp->Asl.Parent = Op->Asl.Parent;
    598       1.1  christos 
    599       1.1  christos     Op->Asl.Next = NewOp;
    600       1.1  christos }
    601       1.1  christos 
    602       1.1  christos 
    603       1.1  christos /*******************************************************************************
    604       1.1  christos  *
    605       1.1  christos  * FUNCTION:    OpcEncodePldBuffer
    606       1.1  christos  *
    607       1.1  christos  * PARAMETERS:  PldInfo             - _PLD buffer struct (Using local struct)
    608       1.1  christos  *
    609       1.1  christos  * RETURN:      Encode _PLD buffer suitable for return value from _PLD
    610       1.1  christos  *
    611       1.1  christos  * DESCRIPTION: Bit-packs a _PLD buffer struct.
    612       1.1  christos  *
    613       1.1  christos  ******************************************************************************/
    614       1.1  christos 
    615       1.1  christos static UINT8 *
    616       1.1  christos OpcEncodePldBuffer (
    617       1.1  christos     ACPI_PLD_INFO           *PldInfo)
    618       1.1  christos {
    619       1.1  christos     UINT32                  *Buffer;
    620       1.1  christos     UINT32                  Dword;
    621       1.1  christos 
    622       1.1  christos 
    623   1.1.1.5  christos     Buffer = ACPI_CAST_PTR (UINT32, UtLocalCacheCalloc (ACPI_PLD_BUFFER_SIZE));
    624       1.1  christos 
    625       1.1  christos     /* First 32 bits */
    626       1.1  christos 
    627       1.1  christos     Dword = 0;
    628       1.1  christos     ACPI_PLD_SET_REVISION       (&Dword, PldInfo->Revision);
    629       1.1  christos     ACPI_PLD_SET_IGNORE_COLOR   (&Dword, PldInfo->IgnoreColor);
    630       1.1  christos     ACPI_PLD_SET_RED            (&Dword, PldInfo->Red);
    631       1.1  christos     ACPI_PLD_SET_GREEN          (&Dword, PldInfo->Green);
    632       1.1  christos     ACPI_PLD_SET_BLUE           (&Dword, PldInfo->Blue);
    633       1.1  christos     ACPI_MOVE_32_TO_32          (&Buffer[0], &Dword);
    634       1.1  christos 
    635       1.1  christos     /* Second 32 bits */
    636       1.1  christos 
    637       1.1  christos     Dword = 0;
    638       1.1  christos     ACPI_PLD_SET_WIDTH          (&Dword, PldInfo->Width);
    639       1.1  christos     ACPI_PLD_SET_HEIGHT         (&Dword, PldInfo->Height);
    640       1.1  christos     ACPI_MOVE_32_TO_32          (&Buffer[1], &Dword);
    641       1.1  christos 
    642       1.1  christos     /* Third 32 bits */
    643       1.1  christos 
    644       1.1  christos     Dword = 0;
    645       1.1  christos     ACPI_PLD_SET_USER_VISIBLE   (&Dword, PldInfo->UserVisible);
    646       1.1  christos     ACPI_PLD_SET_DOCK           (&Dword, PldInfo->Dock);
    647       1.1  christos     ACPI_PLD_SET_LID            (&Dword, PldInfo->Lid);
    648       1.1  christos     ACPI_PLD_SET_PANEL          (&Dword, PldInfo->Panel);
    649       1.1  christos     ACPI_PLD_SET_VERTICAL       (&Dword, PldInfo->VerticalPosition);
    650       1.1  christos     ACPI_PLD_SET_HORIZONTAL     (&Dword, PldInfo->HorizontalPosition);
    651       1.1  christos     ACPI_PLD_SET_SHAPE          (&Dword, PldInfo->Shape);
    652       1.1  christos     ACPI_PLD_SET_ORIENTATION    (&Dword, PldInfo->GroupOrientation);
    653       1.1  christos     ACPI_PLD_SET_TOKEN          (&Dword, PldInfo->GroupToken);
    654       1.1  christos     ACPI_PLD_SET_POSITION       (&Dword, PldInfo->GroupPosition);
    655       1.1  christos     ACPI_PLD_SET_BAY            (&Dword, PldInfo->Bay);
    656       1.1  christos     ACPI_MOVE_32_TO_32          (&Buffer[2], &Dword);
    657       1.1  christos 
    658       1.1  christos     /* Fourth 32 bits */
    659       1.1  christos 
    660       1.1  christos     Dword = 0;
    661       1.1  christos     ACPI_PLD_SET_EJECTABLE      (&Dword, PldInfo->Ejectable);
    662       1.1  christos     ACPI_PLD_SET_OSPM_EJECT     (&Dword, PldInfo->OspmEjectRequired);
    663       1.1  christos     ACPI_PLD_SET_CABINET        (&Dword, PldInfo->CabinetNumber);
    664       1.1  christos     ACPI_PLD_SET_CARD_CAGE      (&Dword, PldInfo->CardCageNumber);
    665       1.1  christos     ACPI_PLD_SET_REFERENCE      (&Dword, PldInfo->Reference);
    666       1.1  christos     ACPI_PLD_SET_ROTATION       (&Dword, PldInfo->Rotation);
    667       1.1  christos     ACPI_PLD_SET_ORDER          (&Dword, PldInfo->Order);
    668       1.1  christos     ACPI_MOVE_32_TO_32          (&Buffer[3], &Dword);
    669       1.1  christos 
    670       1.1  christos     /* Revision 2 adds an additional DWORD */
    671       1.1  christos 
    672       1.1  christos     if (PldInfo->Revision >= 2)
    673       1.1  christos     {
    674       1.1  christos         /* Fifth 32 bits */
    675       1.1  christos 
    676       1.1  christos         Dword = 0;
    677       1.1  christos         ACPI_PLD_SET_VERT_OFFSET    (&Dword, PldInfo->VerticalOffset);
    678       1.1  christos         ACPI_PLD_SET_HORIZ_OFFSET   (&Dword, PldInfo->HorizontalOffset);
    679       1.1  christos         ACPI_MOVE_32_TO_32          (&Buffer[4], &Dword);
    680       1.1  christos     }
    681       1.1  christos 
    682       1.1  christos     return (ACPI_CAST_PTR (UINT8, Buffer));
    683       1.1  christos }
    684       1.1  christos 
    685       1.1  christos 
    686       1.1  christos /*******************************************************************************
    687       1.1  christos  *
    688       1.1  christos  * FUNCTION:    OpcFindName
    689       1.1  christos  *
    690       1.1  christos  * PARAMETERS:  List                - Array of char strings to be searched
    691       1.1  christos  *              Name                - Char string to string for
    692       1.1  christos  *              Index               - Index value to set if found
    693       1.1  christos  *
    694       1.1  christos  * RETURN:      TRUE if any names matched, FALSE otherwise
    695       1.1  christos  *
    696       1.1  christos  * DESCRIPTION: Match PLD name to value in lookup table. Sets Value to
    697       1.1  christos  *              equivalent parameter value.
    698       1.1  christos  *
    699       1.1  christos  ******************************************************************************/
    700       1.1  christos 
    701       1.1  christos static BOOLEAN
    702       1.1  christos OpcFindName (
    703       1.1  christos     const char              **List,
    704       1.1  christos     char                    *Name,
    705       1.1  christos     UINT32                  *Index)
    706       1.1  christos {
    707       1.1  christos     const char              *NameString;
    708       1.1  christos     UINT32                  i;
    709       1.1  christos 
    710       1.1  christos 
    711       1.1  christos     AcpiUtStrupr (Name);
    712       1.1  christos 
    713       1.1  christos     for (i = 0, NameString = List[0];
    714       1.1  christos             NameString;
    715       1.1  christos             i++, NameString = List[i])
    716       1.1  christos     {
    717       1.1  christos         if (!(strncmp (NameString, Name, strlen (Name))))
    718       1.1  christos         {
    719       1.1  christos             *Index = i;
    720       1.1  christos             return (TRUE);
    721       1.1  christos         }
    722       1.1  christos     }
    723       1.1  christos 
    724       1.1  christos     return (FALSE);
    725       1.1  christos }
    726