Subversion Repositories Kolibri OS

Rev

Rev 1498 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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