Home | History | Annotate | Line # | Download | only in compiler
      1 /******************************************************************************
      2  *
      3  * Module Name: aslrestype2w - Large Word address resource descriptors
      4  *
      5  *****************************************************************************/
      6 
      7 /******************************************************************************
      8  *
      9  * 1. Copyright Notice
     10  *
     11  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12  * All rights reserved.
     13  *
     14  * 2. License
     15  *
     16  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  * rights. You may have additional license terms from the party that provided
     18  * you this software, covering your right to use that party's intellectual
     19  * property rights.
     20  *
     21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  * copy of the source code appearing in this file ("Covered Code") an
     23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  * make derivatives, distribute, use and display any portion of the Covered
     26  * Code in any form, with the right to sublicense such rights; and
     27  *
     28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  * license (with the right to sublicense), under only those claims of Intel
     30  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  * offer to sell, and import the Covered Code and derivative works thereof
     32  * solely to the minimum extent necessary to exercise the above copyright
     33  * license, and in no event shall the patent license extend to any additions
     34  * to or modifications of the Original Intel Code. No other license or right
     35  * is granted directly or by implication, estoppel or otherwise;
     36  *
     37  * The above copyright and patent license is granted only if the following
     38  * conditions are met:
     39  *
     40  * 3. Conditions
     41  *
     42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  * Redistribution of source code of any substantial portion of the Covered
     44  * Code or modification with rights to further distribute source must include
     45  * the above Copyright Notice, the above License, this list of Conditions,
     46  * and the following Disclaimer and Export Compliance provision. In addition,
     47  * Licensee must cause all Covered Code to which Licensee contributes to
     48  * contain a file documenting the changes Licensee made to create that Covered
     49  * Code and the date of any change. Licensee must include in that file the
     50  * documentation of any changes made by any predecessor Licensee. Licensee
     51  * must include a prominent statement that the modification is derived,
     52  * directly or indirectly, from Original Intel Code.
     53  *
     54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  * Redistribution of source code of any substantial portion of the Covered
     56  * Code or modification without rights to further distribute source must
     57  * include the following Disclaimer and Export Compliance provision in the
     58  * documentation and/or other materials provided with distribution. In
     59  * addition, Licensee may not authorize further sublicense of source of any
     60  * portion of the Covered Code, and must include terms to the effect that the
     61  * license from Licensee to its licensee is limited to the intellectual
     62  * property embodied in the software Licensee provides to its licensee, and
     63  * not to intellectual property embodied in modifications its licensee may
     64  * make.
     65  *
     66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  * substantial portion of the Covered Code or modification must reproduce the
     68  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  * provision in the documentation and/or other materials provided with the
     70  * distribution.
     71  *
     72  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  * Intel Code.
     74  *
     75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  * other dealings in products derived from or relating to the Covered Code
     78  * without prior written authorization from Intel.
     79  *
     80  * 4. Disclaimer and Export Compliance
     81  *
     82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  * PARTICULAR PURPOSE.
     89  *
     90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  * LIMITED REMEDY.
     98  *
     99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  * software or system incorporating such software without first obtaining any
    101  * required license or other approval from the U. S. Department of Commerce or
    102  * any other agency or department of the United States Government. In the
    103  * event Licensee exports any such software from the United States or
    104  * re-exports any such software from a foreign destination, Licensee shall
    105  * ensure that the distribution and export/re-export of the software is in
    106  * compliance with all laws, regulations, orders, or other restrictions of the
    107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  * any of its subsidiaries will export/re-export any technical data, process,
    109  * software, or service, directly or indirectly, to any country for which the
    110  * United States government or any agency thereof requires an export license,
    111  * other governmental approval, or letter of assurance, without first obtaining
    112  * such license, approval or letter.
    113  *
    114  *****************************************************************************
    115  *
    116  * Alternatively, you may choose to be licensed under the terms of the
    117  * following license:
    118  *
    119  * Redistribution and use in source and binary forms, with or without
    120  * modification, are permitted provided that the following conditions
    121  * are met:
    122  * 1. Redistributions of source code must retain the above copyright
    123  *    notice, this list of conditions, and the following disclaimer,
    124  *    without modification.
    125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126  *    substantially similar to the "NO WARRANTY" disclaimer below
    127  *    ("Disclaimer") and any redistribution must be conditioned upon
    128  *    including a substantially similar Disclaimer requirement for further
    129  *    binary redistribution.
    130  * 3. Neither the names of the above-listed copyright holders nor the names
    131  *    of any contributors may be used to endorse or promote products derived
    132  *    from this software without specific prior written permission.
    133  *
    134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  *
    146  * Alternatively, you may choose to be licensed under the terms of the
    147  * GNU General Public License ("GPL") version 2 as published by the Free
    148  * Software Foundation.
    149  *
    150  *****************************************************************************/
    151 
    152 #include "aslcompiler.h"
    153 #include "aslcompiler.y.h"
    154 
    155 #define _COMPONENT          ACPI_COMPILER
    156         ACPI_MODULE_NAME    ("aslrestype2w")
    157 
    158 /*
    159  * This module contains the Word (16-bit) address space descriptors:
    160  *
    161  * WordIO
    162  * WordMemory
    163  * WordPcc
    164  * WordSpace
    165  */
    166 
    167 /*******************************************************************************
    168  *
    169  * FUNCTION:    RsDoWordIoDescriptor
    170  *
    171  * PARAMETERS:  Info                - Parse Op and resource template offset
    172  *
    173  * RETURN:      Completed resource node
    174  *
    175  * DESCRIPTION: Construct a long "WordIO" descriptor
    176  *
    177  ******************************************************************************/
    178 
    179 ASL_RESOURCE_NODE *
    180 RsDoWordIoDescriptor (
    181     ASL_RESOURCE_INFO       *Info)
    182 {
    183     AML_RESOURCE            *Descriptor;
    184     ACPI_PARSE_OBJECT       *InitializerOp;
    185     ACPI_PARSE_OBJECT       *MinOp = NULL;
    186     ACPI_PARSE_OBJECT       *MaxOp = NULL;
    187     ACPI_PARSE_OBJECT       *LengthOp = NULL;
    188     ACPI_PARSE_OBJECT       *GranOp = NULL;
    189     ASL_RESOURCE_NODE       *Rnode;
    190     UINT8                   *OptionalFields;
    191     UINT16                  StringLength = 0;
    192     UINT32                  OptionIndex = 0;
    193     UINT32                  CurrentByteOffset;
    194     UINT32                  i;
    195     BOOLEAN                 ResSourceIndex = FALSE;
    196 
    197 
    198     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
    199     StringLength = RsGetStringDataLength (InitializerOp);
    200     CurrentByteOffset = Info->CurrentByteOffset;
    201 
    202     Rnode = RsAllocateResourceNode (
    203         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
    204 
    205     Descriptor = Rnode->Buffer;
    206     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
    207     Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
    208 
    209     /*
    210      * Initial descriptor length -- may be enlarged if there are
    211      * optional fields present
    212      */
    213     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
    214     Descriptor->Address16.ResourceLength = (UINT16)
    215         (sizeof (AML_RESOURCE_ADDRESS16) -
    216          sizeof (AML_RESOURCE_LARGE_HEADER));
    217 
    218     /* Process all child initialization nodes */
    219 
    220     for (i = 0; InitializerOp; i++)
    221     {
    222         switch (i)
    223         {
    224         case 0: /* Resource Usage */
    225 
    226             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
    227             break;
    228 
    229         case 1: /* MinType */
    230 
    231             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
    232             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
    233                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
    234             break;
    235 
    236         case 2: /* MaxType */
    237 
    238             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
    239             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
    240                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
    241             break;
    242 
    243         case 3: /* DecodeType */
    244 
    245             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
    246             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
    247                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
    248             break;
    249 
    250         case 4: /* Range Type */
    251 
    252             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3);
    253             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
    254                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0, 2);
    255             break;
    256 
    257         case 5: /* Address Granularity */
    258 
    259             Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
    260             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
    261                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
    262             GranOp = InitializerOp;
    263             break;
    264 
    265         case 6: /* Address Min */
    266 
    267             Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
    268             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
    269                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
    270             MinOp = InitializerOp;
    271             break;
    272 
    273         case 7: /* Address Max */
    274 
    275             Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
    276             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
    277                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
    278             MaxOp = InitializerOp;
    279             break;
    280 
    281         case 8: /* Translation Offset */
    282 
    283             Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
    284             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
    285                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
    286             break;
    287 
    288         case 9: /* Address Length */
    289 
    290             Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
    291             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
    292                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
    293             LengthOp = InitializerOp;
    294             break;
    295 
    296         case 10: /* ResSourceIndex [Optional Field - BYTE] */
    297 
    298             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
    299             {
    300                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
    301                 OptionIndex++;
    302                 Descriptor->Address16.ResourceLength++;
    303                 ResSourceIndex = TRUE;
    304             }
    305             break;
    306 
    307         case 11: /* ResSource [Optional Field - STRING] */
    308 
    309             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
    310                 (InitializerOp->Asl.Value.String))
    311             {
    312                 if (StringLength)
    313                 {
    314                     Descriptor->Address16.ResourceLength = (UINT16)
    315                         (Descriptor->Address16.ResourceLength + StringLength);
    316 
    317                     strcpy ((char *)
    318                         &OptionalFields[OptionIndex],
    319                         InitializerOp->Asl.Value.String);
    320 
    321                     /* ResourceSourceIndex must also be valid */
    322 
    323                     if (!ResSourceIndex)
    324                     {
    325                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
    326                             InitializerOp, NULL);
    327                     }
    328                 }
    329             }
    330 
    331 #if 0
    332             /*
    333              * Not a valid ResourceSource, ResourceSourceIndex must also
    334              * be invalid
    335              */
    336             else if (ResSourceIndex)
    337             {
    338                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
    339                     InitializerOp, NULL);
    340             }
    341 #endif
    342             break;
    343 
    344         case 12: /* ResourceTag */
    345 
    346             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
    347             break;
    348 
    349         case 13: /* Type */
    350 
    351             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0);
    352             RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
    353                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4);
    354             break;
    355 
    356         case 14: /* Translation Type */
    357 
    358             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0);
    359             RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
    360                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5);
    361             break;
    362 
    363         default:
    364 
    365             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
    366             break;
    367         }
    368 
    369         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    370     }
    371 
    372     /* Validate the Min/Max/Len/Gran values */
    373 
    374     RsLargeAddressCheck (
    375         (UINT64) Descriptor->Address16.Minimum,
    376         (UINT64) Descriptor->Address16.Maximum,
    377         (UINT64) Descriptor->Address16.AddressLength,
    378         (UINT64) Descriptor->Address16.Granularity,
    379         Descriptor->Address16.Flags,
    380         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
    381 
    382     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
    383         OptionIndex + StringLength;
    384     return (Rnode);
    385 }
    386 
    387 
    388 /*******************************************************************************
    389  *
    390  * FUNCTION:    RsDoWordBusNumberDescriptor
    391  *
    392  * PARAMETERS:  Info                - Parse Op and resource template offset
    393  *
    394  * RETURN:      Completed resource node
    395  *
    396  * DESCRIPTION: Construct a long "WordBusNumber" descriptor
    397  *
    398  ******************************************************************************/
    399 
    400 ASL_RESOURCE_NODE *
    401 RsDoWordBusNumberDescriptor (
    402     ASL_RESOURCE_INFO       *Info)
    403 {
    404     AML_RESOURCE            *Descriptor;
    405     ACPI_PARSE_OBJECT       *InitializerOp;
    406     ACPI_PARSE_OBJECT       *MinOp = NULL;
    407     ACPI_PARSE_OBJECT       *MaxOp = NULL;
    408     ACPI_PARSE_OBJECT       *LengthOp = NULL;
    409     ACPI_PARSE_OBJECT       *GranOp = NULL;
    410     ASL_RESOURCE_NODE       *Rnode;
    411     UINT8                   *OptionalFields;
    412     UINT16                  StringLength = 0;
    413     UINT32                  OptionIndex = 0;
    414     UINT32                  CurrentByteOffset;
    415     UINT32                  i;
    416     BOOLEAN                 ResSourceIndex = FALSE;
    417 
    418 
    419     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
    420     StringLength = RsGetStringDataLength (InitializerOp);
    421     CurrentByteOffset = Info->CurrentByteOffset;
    422 
    423     Rnode = RsAllocateResourceNode (
    424         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
    425 
    426     Descriptor = Rnode->Buffer;
    427     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
    428     Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE;
    429 
    430     /*
    431      * Initial descriptor length -- may be enlarged if there are
    432      * optional fields present
    433      */
    434     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
    435     Descriptor->Address16.ResourceLength = (UINT16)
    436         (sizeof (AML_RESOURCE_ADDRESS16) -
    437          sizeof (AML_RESOURCE_LARGE_HEADER));
    438 
    439     /* Process all child initialization nodes */
    440 
    441     for (i = 0; InitializerOp; i++)
    442     {
    443         switch (i)
    444         {
    445         case 0: /* Resource Usage */
    446 
    447             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
    448             break;
    449 
    450         case 1: /* MinType */
    451 
    452             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
    453             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
    454                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
    455             break;
    456 
    457         case 2: /* MaxType */
    458 
    459             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
    460             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
    461                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
    462             break;
    463 
    464         case 3: /* DecodeType */
    465 
    466             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
    467             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
    468                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
    469             break;
    470 
    471         case 4: /* Address Granularity */
    472 
    473             Descriptor->Address16.Granularity =
    474                 (UINT16) InitializerOp->Asl.Value.Integer;
    475             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
    476                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
    477             GranOp = InitializerOp;
    478             break;
    479 
    480         case 5: /* Min Address */
    481 
    482             Descriptor->Address16.Minimum =
    483                 (UINT16) InitializerOp->Asl.Value.Integer;
    484             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
    485                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
    486             MinOp = InitializerOp;
    487             break;
    488 
    489         case 6: /* Max Address */
    490 
    491             Descriptor->Address16.Maximum =
    492                 (UINT16) InitializerOp->Asl.Value.Integer;
    493             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
    494                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
    495             MaxOp = InitializerOp;
    496             break;
    497 
    498         case 7: /* Translation Offset */
    499 
    500             Descriptor->Address16.TranslationOffset =
    501                 (UINT16) InitializerOp->Asl.Value.Integer;
    502             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
    503                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
    504             break;
    505 
    506         case 8: /* Address Length */
    507 
    508             Descriptor->Address16.AddressLength =
    509                 (UINT16) InitializerOp->Asl.Value.Integer;
    510             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
    511                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
    512             LengthOp = InitializerOp;
    513             break;
    514 
    515         case 9: /* ResSourceIndex [Optional Field - BYTE] */
    516 
    517             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
    518             {
    519                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
    520                 OptionIndex++;
    521                 Descriptor->Address16.ResourceLength++;
    522                 ResSourceIndex = TRUE;
    523             }
    524             break;
    525 
    526         case 10: /* ResSource [Optional Field - STRING] */
    527 
    528             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
    529                 (InitializerOp->Asl.Value.String))
    530             {
    531                 if (StringLength)
    532                 {
    533                     Descriptor->Address16.ResourceLength = (UINT16)
    534                         (Descriptor->Address16.ResourceLength + StringLength);
    535 
    536                     strcpy ((char *)
    537                         &OptionalFields[OptionIndex],
    538                         InitializerOp->Asl.Value.String);
    539 
    540                     /* ResourceSourceIndex must also be valid */
    541 
    542                     if (!ResSourceIndex)
    543                     {
    544                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
    545                             InitializerOp, NULL);
    546                     }
    547                 }
    548             }
    549 
    550 #if 0
    551             /*
    552              * Not a valid ResourceSource, ResourceSourceIndex must also
    553              * be invalid
    554              */
    555             else if (ResSourceIndex)
    556             {
    557                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
    558                     InitializerOp, NULL);
    559             }
    560 #endif
    561             break;
    562 
    563         case 11: /* ResourceTag */
    564 
    565             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
    566             break;
    567 
    568         default:
    569 
    570             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
    571             break;
    572         }
    573 
    574         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    575     }
    576 
    577     /* Validate the Min/Max/Len/Gran values */
    578 
    579     RsLargeAddressCheck (
    580         (UINT64) Descriptor->Address16.Minimum,
    581         (UINT64) Descriptor->Address16.Maximum,
    582         (UINT64) Descriptor->Address16.AddressLength,
    583         (UINT64) Descriptor->Address16.Granularity,
    584         Descriptor->Address16.Flags,
    585         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
    586 
    587     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
    588         OptionIndex + StringLength;
    589     return (Rnode);
    590 }
    591 
    592 
    593 /*******************************************************************************
    594  *
    595  * FUNCTION:    RsDoWordPccDescriptor
    596  *
    597  * PARAMETERS:  Info                - Parse Op and resource template offset
    598  *
    599  * RETURN:      Completed resource node
    600  *
    601  * DESCRIPTION: Construct a long "WordPcc" descriptor
    602  *
    603  ******************************************************************************/
    604 
    605 ASL_RESOURCE_NODE *
    606 RsDoWordPccDescriptor (
    607     ASL_RESOURCE_INFO       *Info)
    608 {
    609     AML_RESOURCE            *Descriptor;
    610     ACPI_PARSE_OBJECT       *InitializerOp;
    611     ACPI_PARSE_OBJECT       *MinOp = NULL;
    612     ACPI_PARSE_OBJECT       *MaxOp = NULL;
    613     ACPI_PARSE_OBJECT       *LengthOp = NULL;
    614     ACPI_PARSE_OBJECT       *GranOp = NULL;
    615     ASL_RESOURCE_NODE       *Rnode;
    616     UINT16                  StringLength = 0;
    617     UINT32                  OptionIndex = 0;
    618     UINT8                   *OptionalFields;
    619     UINT32                  i;
    620     BOOLEAN                 ResSourceIndex = FALSE;
    621 
    622 
    623     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
    624     StringLength = RsGetStringDataLength (InitializerOp);
    625 
    626     Rnode = RsAllocateResourceNode (
    627         sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
    628 
    629     Descriptor = Rnode->Buffer;
    630     Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
    631     Descriptor->Address32.ResourceType  = ACPI_ADDRESS_TYPE_PCC_NUMBER;
    632 
    633     /*
    634      * Initial descriptor length -- may be enlarged if there are
    635      * optional fields present
    636      */
    637     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
    638     Descriptor->Address32.ResourceLength = (UINT16)
    639         (sizeof (AML_RESOURCE_ADDRESS32) -
    640          sizeof (AML_RESOURCE_LARGE_HEADER));
    641 
    642 
    643     /*
    644     * Bit [3] Max Address Fixed, _MAF: 1 (max address is fixed)
    645     * Bit [2] Min Address Fixed,_MIF: 1 (min address is fixed)
    646     * Bit [1] Decode Type, _DEC: 0 (do not care)
    647     * BIT [0] Ignored (must be zero)
    648     */
    649     Descriptor->Address32.Flags = 0b1100;
    650 
    651     // No type specific flags. Set to 0.
    652     Descriptor->Address32.SpecificFlags = 0;
    653 
    654     // must be set to zero if _MAX == _MIN.
    655     Descriptor->Address32.Granularity = 0x0;
    656     /* Process all child initialization nodes */
    657 
    658     // No translation offset.
    659     Descriptor->Address32.TranslationOffset = 0;
    660 
    661     // Pcc is unique address.
    662     Descriptor->Address32.AddressLength = 1;
    663 
    664     for (i = 0; InitializerOp; i++)
    665     {
    666         switch (i)
    667         {
    668 
    669         case 0: /* Address Min = Max */
    670 
    671             Descriptor->Address32.Minimum =
    672                 (UINT32) InitializerOp->Asl.Value.Integer;
    673             Descriptor->Address32.Maximum =
    674                 (UINT32) InitializerOp->Asl.Value.Integer;
    675 
    676             break;
    677 
    678         case 1: /* ResSourceIndex [Optional Field - BYTE] */
    679 
    680             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
    681             {
    682                 /* Found a valid ResourceSourceIndex */
    683 
    684                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
    685                 OptionIndex++;
    686                 Descriptor->Address32.ResourceLength++;
    687                 ResSourceIndex = TRUE;
    688             }
    689             break;
    690 
    691         case 2: /* ResSource [Optional Field - STRING] */
    692 
    693             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
    694                 (InitializerOp->Asl.Value.String))
    695             {
    696                 if (StringLength)
    697                 {
    698                     /* Found a valid ResourceSource */
    699 
    700                     Descriptor->Address32.ResourceLength = (UINT16)
    701                         (Descriptor->Address32.ResourceLength + StringLength);
    702 
    703                     strcpy ((char *)
    704                         &OptionalFields[OptionIndex],
    705                         InitializerOp->Asl.Value.String);
    706 
    707                     /* ResourceSourceIndex must also be valid */
    708 
    709                     if (!ResSourceIndex)
    710                     {
    711                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
    712                             InitializerOp, NULL);
    713                     }
    714                 }
    715             }
    716 
    717             break;
    718 
    719         case 3: // DescriptorName
    720             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
    721             break;
    722 
    723         default:
    724 
    725             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
    726             break;
    727         }
    728 
    729         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    730     }
    731 
    732     /* Validate the Min/Max/Len/Gran values */
    733 
    734     RsLargeAddressCheck (
    735         (UINT64) Descriptor->Address32.Minimum,
    736         (UINT64) Descriptor->Address32.Maximum,
    737         (UINT64) Descriptor->Address32.AddressLength,
    738         (UINT64) Descriptor->Address32.Granularity,
    739         Descriptor->Address32.Flags,
    740         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
    741 
    742     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
    743         OptionIndex + StringLength;
    744     return (Rnode);
    745 }
    746 
    747 
    748 /*******************************************************************************
    749  *
    750  * FUNCTION:    RsDoWordSpaceDescriptor
    751  *
    752  * PARAMETERS:  Info                - Parse Op and resource template offset
    753  *
    754  * RETURN:      Completed resource node
    755  *
    756  * DESCRIPTION: Construct a long "WordSpace" descriptor
    757  *
    758  ******************************************************************************/
    759 
    760 ASL_RESOURCE_NODE *
    761 RsDoWordSpaceDescriptor (
    762     ASL_RESOURCE_INFO       *Info)
    763 {
    764     AML_RESOURCE            *Descriptor;
    765     ACPI_PARSE_OBJECT       *InitializerOp;
    766     ACPI_PARSE_OBJECT       *MinOp = NULL;
    767     ACPI_PARSE_OBJECT       *MaxOp = NULL;
    768     ACPI_PARSE_OBJECT       *LengthOp = NULL;
    769     ACPI_PARSE_OBJECT       *GranOp = NULL;
    770     ASL_RESOURCE_NODE       *Rnode;
    771     UINT8                   *OptionalFields;
    772     UINT16                  StringLength = 0;
    773     UINT32                  OptionIndex = 0;
    774     UINT32                  CurrentByteOffset;
    775     UINT32                  i;
    776     BOOLEAN                 ResSourceIndex = FALSE;
    777 
    778 
    779     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
    780     StringLength = RsGetStringDataLength (InitializerOp);
    781     CurrentByteOffset = Info->CurrentByteOffset;
    782 
    783     Rnode = RsAllocateResourceNode (
    784         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
    785 
    786     Descriptor = Rnode->Buffer;
    787     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
    788 
    789     /*
    790      * Initial descriptor length -- may be enlarged if there are
    791      * optional fields present
    792      */
    793     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
    794     Descriptor->Address16.ResourceLength = (UINT16)
    795         (sizeof (AML_RESOURCE_ADDRESS16) -
    796          sizeof (AML_RESOURCE_LARGE_HEADER));
    797 
    798     /* Process all child initialization nodes */
    799 
    800     for (i = 0; InitializerOp; i++)
    801     {
    802         switch (i)
    803         {
    804         case 0: /* Resource Type */
    805 
    806             Descriptor->Address16.ResourceType =
    807                 (UINT8) InitializerOp->Asl.Value.Integer;
    808             break;
    809 
    810         case 1: /* Resource Usage */
    811 
    812             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
    813             break;
    814 
    815         case 2: /* DecodeType */
    816 
    817             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
    818             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
    819                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
    820             break;
    821 
    822         case 3: /* MinType */
    823 
    824             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
    825             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
    826                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
    827             break;
    828 
    829         case 4: /* MaxType */
    830 
    831             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
    832             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
    833                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
    834             break;
    835 
    836         case 5: /* Type-Specific flags */
    837 
    838             Descriptor->Address16.SpecificFlags =
    839                 (UINT8) InitializerOp->Asl.Value.Integer;
    840             break;
    841 
    842         case 6: /* Address Granularity */
    843 
    844             Descriptor->Address16.Granularity =
    845                 (UINT16) InitializerOp->Asl.Value.Integer;
    846             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
    847                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
    848             GranOp = InitializerOp;
    849             break;
    850 
    851         case 7: /* Min Address */
    852 
    853             Descriptor->Address16.Minimum =
    854                 (UINT16) InitializerOp->Asl.Value.Integer;
    855             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
    856                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
    857             MinOp = InitializerOp;
    858             break;
    859 
    860         case 8: /* Max Address */
    861 
    862             Descriptor->Address16.Maximum =
    863                 (UINT16) InitializerOp->Asl.Value.Integer;
    864             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
    865                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
    866             MaxOp = InitializerOp;
    867             break;
    868 
    869         case 9: /* Translation Offset */
    870 
    871             Descriptor->Address16.TranslationOffset =
    872                 (UINT16) InitializerOp->Asl.Value.Integer;
    873             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
    874                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
    875             break;
    876 
    877         case 10: /* Address Length */
    878 
    879             Descriptor->Address16.AddressLength =
    880                 (UINT16) InitializerOp->Asl.Value.Integer;
    881             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
    882                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
    883             LengthOp = InitializerOp;
    884             break;
    885 
    886         case 11: /* ResSourceIndex [Optional Field - BYTE] */
    887 
    888             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
    889             {
    890                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
    891                 OptionIndex++;
    892                 Descriptor->Address16.ResourceLength++;
    893                 ResSourceIndex = TRUE;
    894             }
    895             break;
    896 
    897         case 12: /* ResSource [Optional Field - STRING] */
    898 
    899             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
    900                 (InitializerOp->Asl.Value.String))
    901             {
    902                 if (StringLength)
    903                 {
    904                     Descriptor->Address16.ResourceLength = (UINT16)
    905                         (Descriptor->Address16.ResourceLength + StringLength);
    906 
    907                     strcpy ((char *)
    908                         &OptionalFields[OptionIndex],
    909                         InitializerOp->Asl.Value.String);
    910 
    911                     /* ResourceSourceIndex must also be valid */
    912 
    913                     if (!ResSourceIndex)
    914                     {
    915                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
    916                             InitializerOp, NULL);
    917                     }
    918                 }
    919             }
    920 
    921 #if 0
    922             /*
    923              * Not a valid ResourceSource, ResourceSourceIndex must also
    924              * be invalid
    925              */
    926             else if (ResSourceIndex)
    927             {
    928                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
    929                     InitializerOp, NULL);
    930             }
    931 #endif
    932             break;
    933 
    934         case 13: /* ResourceTag */
    935 
    936             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
    937             break;
    938 
    939         default:
    940 
    941             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
    942             break;
    943         }
    944 
    945         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
    946     }
    947 
    948     /* Validate the Min/Max/Len/Gran values */
    949 
    950     RsLargeAddressCheck (
    951         (UINT64) Descriptor->Address16.Minimum,
    952         (UINT64) Descriptor->Address16.Maximum,
    953         (UINT64) Descriptor->Address16.AddressLength,
    954         (UINT64) Descriptor->Address16.Granularity,
    955         Descriptor->Address16.Flags,
    956         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
    957 
    958     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
    959         OptionIndex + StringLength;
    960     return (Rnode);
    961 }
    962