1 /******************************************************************************
   2  *
   3  * Module Name: aslrestype2w - Large Word address resource descriptors
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2013, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.
  29  *
  30  * NO WARRANTY
  31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41  * POSSIBILITY OF SUCH DAMAGES.
  42  */
  43 
  44 
  45 #include "aslcompiler.h"
  46 #include "aslcompiler.y.h"
  47 
  48 #define _COMPONENT          ACPI_COMPILER
  49         ACPI_MODULE_NAME    ("aslrestype2w")
  50 
  51 /*
  52  * This module contains the Word (16-bit) address space descriptors:
  53  *
  54  * WordIO
  55  * WordMemory
  56  * WordSpace
  57  */
  58 
  59 /*******************************************************************************
  60  *
  61  * FUNCTION:    RsDoWordIoDescriptor
  62  *
  63  * PARAMETERS:  Op                  - Parent resource descriptor parse node
  64  *              CurrentByteOffset   - Offset into the resource template AML
  65  *                                    buffer (to track references to the desc)
  66  *
  67  * RETURN:      Completed resource node
  68  *
  69  * DESCRIPTION: Construct a long "WordIO" descriptor
  70  *
  71  ******************************************************************************/
  72 
  73 ASL_RESOURCE_NODE *
  74 RsDoWordIoDescriptor (
  75     ACPI_PARSE_OBJECT       *Op,
  76     UINT32                  CurrentByteOffset)
  77 {
  78     AML_RESOURCE            *Descriptor;
  79     ACPI_PARSE_OBJECT       *InitializerOp;
  80     ACPI_PARSE_OBJECT       *MinOp = NULL;
  81     ACPI_PARSE_OBJECT       *MaxOp = NULL;
  82     ACPI_PARSE_OBJECT       *LengthOp = NULL;
  83     ACPI_PARSE_OBJECT       *GranOp = NULL;
  84     ASL_RESOURCE_NODE       *Rnode;
  85     UINT8                   *OptionalFields;
  86     UINT16                  StringLength = 0;
  87     UINT32                  OptionIndex = 0;
  88     UINT32                  i;
  89     BOOLEAN                 ResSourceIndex = FALSE;
  90 
  91 
  92     InitializerOp = Op->Asl.Child;
  93     StringLength = RsGetStringDataLength (InitializerOp);
  94 
  95     Rnode = RsAllocateResourceNode (
  96                 sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
  97 
  98     Descriptor = Rnode->Buffer;
  99     Descriptor->Address16.DescriptorType  = ACPI_RESOURCE_NAME_ADDRESS16;
 100     Descriptor->Address16.ResourceType    = ACPI_ADDRESS_TYPE_IO_RANGE;
 101 
 102     /*
 103      * Initial descriptor length -- may be enlarged if there are
 104      * optional fields present
 105      */
 106     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
 107     Descriptor->Address16.ResourceLength = (UINT16)
 108         (sizeof (AML_RESOURCE_ADDRESS16) -
 109          sizeof (AML_RESOURCE_LARGE_HEADER));
 110 
 111     /* Process all child initialization nodes */
 112 
 113     for (i = 0; InitializerOp; i++)
 114     {
 115         switch (i)
 116         {
 117         case 0: /* Resource Usage */
 118 
 119             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
 120             break;
 121 
 122         case 1: /* MinType */
 123 
 124             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
 125             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
 126                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
 127             break;
 128 
 129         case 2: /* MaxType */
 130 
 131             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
 132             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
 133                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
 134             break;
 135 
 136         case 3: /* DecodeType */
 137 
 138             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
 139             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
 140                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
 141             break;
 142 
 143         case 4: /* Range Type */
 144 
 145             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3);
 146             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
 147                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0, 2);
 148             break;
 149 
 150         case 5: /* Address Granularity */
 151 
 152             Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
 153             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
 154                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
 155             GranOp = InitializerOp;
 156             break;
 157 
 158         case 6: /* Address Min */
 159 
 160             Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
 161             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
 162                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
 163             MinOp = InitializerOp;
 164             break;
 165 
 166         case 7: /* Address Max */
 167 
 168             Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
 169             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
 170                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
 171             MaxOp = InitializerOp;
 172             break;
 173 
 174         case 8: /* Translation Offset */
 175 
 176             Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
 177             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
 178                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
 179             break;
 180 
 181         case 9: /* Address Length */
 182 
 183             Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
 184             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
 185                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
 186             LengthOp = InitializerOp;
 187             break;
 188 
 189         case 10: /* ResSourceIndex [Optional Field - BYTE] */
 190 
 191             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
 192             {
 193                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
 194                 OptionIndex++;
 195                 Descriptor->Address16.ResourceLength++;
 196                 ResSourceIndex = TRUE;
 197             }
 198             break;
 199 
 200         case 11: /* ResSource [Optional Field - STRING] */
 201 
 202             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
 203                 (InitializerOp->Asl.Value.String))
 204             {
 205                 if (StringLength)
 206                 {
 207                     Descriptor->Address16.ResourceLength = (UINT16)
 208                         (Descriptor->Address16.ResourceLength + StringLength);
 209 
 210                     strcpy ((char *)
 211                         &OptionalFields[OptionIndex],
 212                         InitializerOp->Asl.Value.String);
 213 
 214                     /* ResourceSourceIndex must also be valid */
 215 
 216                     if (!ResSourceIndex)
 217                     {
 218                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
 219                             InitializerOp, NULL);
 220                     }
 221                 }
 222             }
 223 
 224 #if 0
 225             /*
 226              * Not a valid ResourceSource, ResourceSourceIndex must also
 227              * be invalid
 228              */
 229             else if (ResSourceIndex)
 230             {
 231                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
 232                     InitializerOp, NULL);
 233             }
 234 #endif
 235             break;
 236 
 237         case 12: /* ResourceTag */
 238 
 239             UtAttachNamepathToOwner (Op, InitializerOp);
 240             break;
 241 
 242         case 13: /* Type */
 243 
 244             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0);
 245             RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
 246                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4);
 247             break;
 248 
 249         case 14: /* Translation Type */
 250 
 251             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0);
 252             RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
 253                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5);
 254             break;
 255 
 256         default:
 257 
 258             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
 259             break;
 260         }
 261 
 262         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
 263     }
 264 
 265     /* Validate the Min/Max/Len/Gran values */
 266 
 267     RsLargeAddressCheck (
 268         (UINT64) Descriptor->Address16.Minimum,
 269         (UINT64) Descriptor->Address16.Maximum,
 270         (UINT64) Descriptor->Address16.AddressLength,
 271         (UINT64) Descriptor->Address16.Granularity,
 272         Descriptor->Address16.Flags,
 273         MinOp, MaxOp, LengthOp, GranOp, Op);
 274 
 275     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
 276                             OptionIndex + StringLength;
 277     return (Rnode);
 278 }
 279 
 280 
 281 /*******************************************************************************
 282  *
 283  * FUNCTION:    RsDoWordBusNumberDescriptor
 284  *
 285  * PARAMETERS:  Op                  - Parent resource descriptor parse node
 286  *              CurrentByteOffset   - Offset into the resource template AML
 287  *                                    buffer (to track references to the desc)
 288  *
 289  * RETURN:      Completed resource node
 290  *
 291  * DESCRIPTION: Construct a long "WordBusNumber" descriptor
 292  *
 293  ******************************************************************************/
 294 
 295 ASL_RESOURCE_NODE *
 296 RsDoWordBusNumberDescriptor (
 297     ACPI_PARSE_OBJECT       *Op,
 298     UINT32                  CurrentByteOffset)
 299 {
 300     AML_RESOURCE            *Descriptor;
 301     ACPI_PARSE_OBJECT       *InitializerOp;
 302     ACPI_PARSE_OBJECT       *MinOp = NULL;
 303     ACPI_PARSE_OBJECT       *MaxOp = NULL;
 304     ACPI_PARSE_OBJECT       *LengthOp = NULL;
 305     ACPI_PARSE_OBJECT       *GranOp = NULL;
 306     ASL_RESOURCE_NODE       *Rnode;
 307     UINT8                   *OptionalFields;
 308     UINT16                  StringLength = 0;
 309     UINT32                  OptionIndex = 0;
 310     UINT32                  i;
 311     BOOLEAN                 ResSourceIndex = FALSE;
 312 
 313 
 314     InitializerOp = Op->Asl.Child;
 315     StringLength = RsGetStringDataLength (InitializerOp);
 316 
 317     Rnode = RsAllocateResourceNode (
 318                 sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
 319 
 320     Descriptor = Rnode->Buffer;
 321     Descriptor->Address16.DescriptorType  = ACPI_RESOURCE_NAME_ADDRESS16;
 322     Descriptor->Address16.ResourceType    = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE;
 323 
 324     /*
 325      * Initial descriptor length -- may be enlarged if there are
 326      * optional fields present
 327      */
 328     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
 329     Descriptor->Address16.ResourceLength = (UINT16)
 330         (sizeof (AML_RESOURCE_ADDRESS16) -
 331          sizeof (AML_RESOURCE_LARGE_HEADER));
 332 
 333     /* Process all child initialization nodes */
 334 
 335     for (i = 0; InitializerOp; i++)
 336     {
 337         switch (i)
 338         {
 339         case 0: /* Resource Usage */
 340 
 341             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
 342             break;
 343 
 344         case 1: /* MinType */
 345 
 346             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
 347             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
 348                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
 349             break;
 350 
 351         case 2: /* MaxType */
 352 
 353             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
 354             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
 355                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
 356             break;
 357 
 358         case 3: /* DecodeType */
 359 
 360             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
 361             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
 362                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
 363             break;
 364 
 365         case 4: /* Address Granularity */
 366 
 367             Descriptor->Address16.Granularity =
 368                 (UINT16) InitializerOp->Asl.Value.Integer;
 369             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
 370                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
 371             GranOp = InitializerOp;
 372             break;
 373 
 374         case 5: /* Min Address */
 375 
 376             Descriptor->Address16.Minimum =
 377                 (UINT16) InitializerOp->Asl.Value.Integer;
 378             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
 379                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
 380             MinOp = InitializerOp;
 381             break;
 382 
 383         case 6: /* Max Address */
 384 
 385             Descriptor->Address16.Maximum =
 386                 (UINT16) InitializerOp->Asl.Value.Integer;
 387             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
 388                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
 389             MaxOp = InitializerOp;
 390             break;
 391 
 392         case 7: /* Translation Offset */
 393 
 394             Descriptor->Address16.TranslationOffset =
 395                 (UINT16) InitializerOp->Asl.Value.Integer;
 396             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
 397                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
 398             break;
 399 
 400         case 8: /* Address Length */
 401 
 402             Descriptor->Address16.AddressLength =
 403                 (UINT16) InitializerOp->Asl.Value.Integer;
 404             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
 405                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
 406             LengthOp = InitializerOp;
 407             break;
 408 
 409         case 9: /* ResSourceIndex [Optional Field - BYTE] */
 410 
 411             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
 412             {
 413                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
 414                 OptionIndex++;
 415                 Descriptor->Address16.ResourceLength++;
 416                 ResSourceIndex = TRUE;
 417             }
 418             break;
 419 
 420         case 10: /* ResSource [Optional Field - STRING] */
 421 
 422             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
 423                 (InitializerOp->Asl.Value.String))
 424             {
 425                 if (StringLength)
 426                 {
 427                     Descriptor->Address16.ResourceLength = (UINT16)
 428                         (Descriptor->Address16.ResourceLength + StringLength);
 429 
 430                     strcpy ((char *)
 431                         &OptionalFields[OptionIndex],
 432                         InitializerOp->Asl.Value.String);
 433 
 434                     /* ResourceSourceIndex must also be valid */
 435 
 436                     if (!ResSourceIndex)
 437                     {
 438                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
 439                             InitializerOp, NULL);
 440                     }
 441                 }
 442             }
 443 
 444 #if 0
 445             /*
 446              * Not a valid ResourceSource, ResourceSourceIndex must also
 447              * be invalid
 448              */
 449             else if (ResSourceIndex)
 450             {
 451                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
 452                     InitializerOp, NULL);
 453             }
 454 #endif
 455             break;
 456 
 457         case 11: /* ResourceTag */
 458 
 459             UtAttachNamepathToOwner (Op, InitializerOp);
 460             break;
 461 
 462         default:
 463 
 464             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
 465             break;
 466         }
 467 
 468         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
 469     }
 470 
 471     /* Validate the Min/Max/Len/Gran values */
 472 
 473     RsLargeAddressCheck (
 474         (UINT64) Descriptor->Address16.Minimum,
 475         (UINT64) Descriptor->Address16.Maximum,
 476         (UINT64) Descriptor->Address16.AddressLength,
 477         (UINT64) Descriptor->Address16.Granularity,
 478         Descriptor->Address16.Flags,
 479         MinOp, MaxOp, LengthOp, GranOp, Op);
 480 
 481     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
 482                             OptionIndex + StringLength;
 483     return (Rnode);
 484 }
 485 
 486 
 487 /*******************************************************************************
 488  *
 489  * FUNCTION:    RsDoWordSpaceDescriptor
 490  *
 491  * PARAMETERS:  Op                  - Parent resource descriptor parse node
 492  *              CurrentByteOffset   - Offset into the resource template AML
 493  *                                    buffer (to track references to the desc)
 494  *
 495  * RETURN:      Completed resource node
 496  *
 497  * DESCRIPTION: Construct a long "WordSpace" descriptor
 498  *
 499  ******************************************************************************/
 500 
 501 ASL_RESOURCE_NODE *
 502 RsDoWordSpaceDescriptor (
 503     ACPI_PARSE_OBJECT       *Op,
 504     UINT32                  CurrentByteOffset)
 505 {
 506     AML_RESOURCE            *Descriptor;
 507     ACPI_PARSE_OBJECT       *InitializerOp;
 508     ACPI_PARSE_OBJECT       *MinOp = NULL;
 509     ACPI_PARSE_OBJECT       *MaxOp = NULL;
 510     ACPI_PARSE_OBJECT       *LengthOp = NULL;
 511     ACPI_PARSE_OBJECT       *GranOp = NULL;
 512     ASL_RESOURCE_NODE       *Rnode;
 513     UINT8                   *OptionalFields;
 514     UINT16                  StringLength = 0;
 515     UINT32                  OptionIndex = 0;
 516     UINT32                  i;
 517     BOOLEAN                 ResSourceIndex = FALSE;
 518 
 519 
 520     InitializerOp = Op->Asl.Child;
 521     StringLength = RsGetStringDataLength (InitializerOp);
 522 
 523     Rnode = RsAllocateResourceNode (
 524                 sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
 525 
 526     Descriptor = Rnode->Buffer;
 527     Descriptor->Address16.DescriptorType  = ACPI_RESOURCE_NAME_ADDRESS16;
 528 
 529     /*
 530      * Initial descriptor length -- may be enlarged if there are
 531      * optional fields present
 532      */
 533     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
 534     Descriptor->Address16.ResourceLength = (UINT16)
 535         (sizeof (AML_RESOURCE_ADDRESS16) -
 536          sizeof (AML_RESOURCE_LARGE_HEADER));
 537 
 538     /* Process all child initialization nodes */
 539 
 540     for (i = 0; InitializerOp; i++)
 541     {
 542         switch (i)
 543         {
 544         case 0: /* Resource Type */
 545 
 546             Descriptor->Address16.ResourceType =
 547                 (UINT8) InitializerOp->Asl.Value.Integer;
 548             break;
 549 
 550         case 1: /* Resource Usage */
 551 
 552             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
 553             break;
 554 
 555         case 2: /* DecodeType */
 556 
 557             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
 558             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
 559                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
 560             break;
 561 
 562         case 3: /* MinType */
 563 
 564             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
 565             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
 566                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
 567             break;
 568 
 569         case 4: /* MaxType */
 570 
 571             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
 572             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
 573                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
 574             break;
 575 
 576         case 5: /* Type-Specific flags */
 577 
 578             Descriptor->Address16.SpecificFlags =
 579                 (UINT8) InitializerOp->Asl.Value.Integer;
 580             break;
 581 
 582         case 6: /* Address Granularity */
 583 
 584             Descriptor->Address16.Granularity =
 585                 (UINT16) InitializerOp->Asl.Value.Integer;
 586             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
 587                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
 588             GranOp = InitializerOp;
 589             break;
 590 
 591         case 7: /* Min Address */
 592 
 593             Descriptor->Address16.Minimum =
 594                 (UINT16) InitializerOp->Asl.Value.Integer;
 595             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
 596                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
 597             MinOp = InitializerOp;
 598             break;
 599 
 600         case 8: /* Max Address */
 601 
 602             Descriptor->Address16.Maximum =
 603                 (UINT16) InitializerOp->Asl.Value.Integer;
 604             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
 605                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
 606             MaxOp = InitializerOp;
 607             break;
 608 
 609         case 9: /* Translation Offset */
 610 
 611             Descriptor->Address16.TranslationOffset =
 612                 (UINT16) InitializerOp->Asl.Value.Integer;
 613             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
 614                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
 615             break;
 616 
 617         case 10: /* Address Length */
 618 
 619             Descriptor->Address16.AddressLength =
 620                 (UINT16) InitializerOp->Asl.Value.Integer;
 621             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
 622                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
 623             LengthOp = InitializerOp;
 624             break;
 625 
 626         case 11: /* ResSourceIndex [Optional Field - BYTE] */
 627 
 628             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
 629             {
 630                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
 631                 OptionIndex++;
 632                 Descriptor->Address16.ResourceLength++;
 633                 ResSourceIndex = TRUE;
 634             }
 635             break;
 636 
 637         case 12: /* ResSource [Optional Field - STRING] */
 638 
 639             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
 640                 (InitializerOp->Asl.Value.String))
 641             {
 642                 if (StringLength)
 643                 {
 644                     Descriptor->Address16.ResourceLength = (UINT16)
 645                         (Descriptor->Address16.ResourceLength + StringLength);
 646 
 647                     strcpy ((char *)
 648                         &OptionalFields[OptionIndex],
 649                         InitializerOp->Asl.Value.String);
 650 
 651                     /* ResourceSourceIndex must also be valid */
 652 
 653                     if (!ResSourceIndex)
 654                     {
 655                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
 656                             InitializerOp, NULL);
 657                     }
 658                 }
 659             }
 660 
 661 #if 0
 662             /*
 663              * Not a valid ResourceSource, ResourceSourceIndex must also
 664              * be invalid
 665              */
 666             else if (ResSourceIndex)
 667             {
 668                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
 669                     InitializerOp, NULL);
 670             }
 671 #endif
 672             break;
 673 
 674         case 13: /* ResourceTag */
 675 
 676             UtAttachNamepathToOwner (Op, InitializerOp);
 677             break;
 678 
 679         default:
 680 
 681             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
 682             break;
 683         }
 684 
 685         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
 686     }
 687 
 688     /* Validate the Min/Max/Len/Gran values */
 689 
 690     RsLargeAddressCheck (
 691         (UINT64) Descriptor->Address16.Minimum,
 692         (UINT64) Descriptor->Address16.Maximum,
 693         (UINT64) Descriptor->Address16.AddressLength,
 694         (UINT64) Descriptor->Address16.Granularity,
 695         Descriptor->Address16.Flags,
 696         MinOp, MaxOp, LengthOp, GranOp, Op);
 697 
 698     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
 699                             OptionIndex + StringLength;
 700     return (Rnode);
 701 }