The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/dev/acpica/compiler/aslrestype2w.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 - 2022, 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 <contrib/dev/acpica/compiler/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  * WordSpace
  164  */
  165 
  166 /*******************************************************************************
  167  *
  168  * FUNCTION:    RsDoWordIoDescriptor
  169  *
  170  * PARAMETERS:  Info                - Parse Op and resource template offset
  171  *
  172  * RETURN:      Completed resource node
  173  *
  174  * DESCRIPTION: Construct a long "WordIO" descriptor
  175  *
  176  ******************************************************************************/
  177 
  178 ASL_RESOURCE_NODE *
  179 RsDoWordIoDescriptor (
  180     ASL_RESOURCE_INFO       *Info)
  181 {
  182     AML_RESOURCE            *Descriptor;
  183     ACPI_PARSE_OBJECT       *InitializerOp;
  184     ACPI_PARSE_OBJECT       *MinOp = NULL;
  185     ACPI_PARSE_OBJECT       *MaxOp = NULL;
  186     ACPI_PARSE_OBJECT       *LengthOp = NULL;
  187     ACPI_PARSE_OBJECT       *GranOp = NULL;
  188     ASL_RESOURCE_NODE       *Rnode;
  189     UINT8                   *OptionalFields;
  190     UINT16                  StringLength = 0;
  191     UINT32                  OptionIndex = 0;
  192     UINT32                  CurrentByteOffset;
  193     UINT32                  i;
  194     BOOLEAN                 ResSourceIndex = FALSE;
  195 
  196 
  197     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
  198     StringLength = RsGetStringDataLength (InitializerOp);
  199     CurrentByteOffset = Info->CurrentByteOffset;
  200 
  201     Rnode = RsAllocateResourceNode (
  202         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
  203 
  204     Descriptor = Rnode->Buffer;
  205     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
  206     Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
  207 
  208     /*
  209      * Initial descriptor length -- may be enlarged if there are
  210      * optional fields present
  211      */
  212     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
  213     Descriptor->Address16.ResourceLength = (UINT16)
  214         (sizeof (AML_RESOURCE_ADDRESS16) -
  215          sizeof (AML_RESOURCE_LARGE_HEADER));
  216 
  217     /* Process all child initialization nodes */
  218 
  219     for (i = 0; InitializerOp; i++)
  220     {
  221         switch (i)
  222         {
  223         case 0: /* Resource Usage */
  224 
  225             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
  226             break;
  227 
  228         case 1: /* MinType */
  229 
  230             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
  231             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
  232                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
  233             break;
  234 
  235         case 2: /* MaxType */
  236 
  237             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
  238             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
  239                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
  240             break;
  241 
  242         case 3: /* DecodeType */
  243 
  244             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
  245             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
  246                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
  247             break;
  248 
  249         case 4: /* Range Type */
  250 
  251             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3);
  252             RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
  253                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0, 2);
  254             break;
  255 
  256         case 5: /* Address Granularity */
  257 
  258             Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
  259             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
  260                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
  261             GranOp = InitializerOp;
  262             break;
  263 
  264         case 6: /* Address Min */
  265 
  266             Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
  267             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
  268                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
  269             MinOp = InitializerOp;
  270             break;
  271 
  272         case 7: /* Address Max */
  273 
  274             Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
  275             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
  276                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
  277             MaxOp = InitializerOp;
  278             break;
  279 
  280         case 8: /* Translation Offset */
  281 
  282             Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
  283             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
  284                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
  285             break;
  286 
  287         case 9: /* Address Length */
  288 
  289             Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
  290             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
  291                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
  292             LengthOp = InitializerOp;
  293             break;
  294 
  295         case 10: /* ResSourceIndex [Optional Field - BYTE] */
  296 
  297             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
  298             {
  299                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
  300                 OptionIndex++;
  301                 Descriptor->Address16.ResourceLength++;
  302                 ResSourceIndex = TRUE;
  303             }
  304             break;
  305 
  306         case 11: /* ResSource [Optional Field - STRING] */
  307 
  308             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
  309                 (InitializerOp->Asl.Value.String))
  310             {
  311                 if (StringLength)
  312                 {
  313                     Descriptor->Address16.ResourceLength = (UINT16)
  314                         (Descriptor->Address16.ResourceLength + StringLength);
  315 
  316                     strcpy ((char *)
  317                         &OptionalFields[OptionIndex],
  318                         InitializerOp->Asl.Value.String);
  319 
  320                     /* ResourceSourceIndex must also be valid */
  321 
  322                     if (!ResSourceIndex)
  323                     {
  324                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
  325                             InitializerOp, NULL);
  326                     }
  327                 }
  328             }
  329 
  330 #if 0
  331             /*
  332              * Not a valid ResourceSource, ResourceSourceIndex must also
  333              * be invalid
  334              */
  335             else if (ResSourceIndex)
  336             {
  337                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
  338                     InitializerOp, NULL);
  339             }
  340 #endif
  341             break;
  342 
  343         case 12: /* ResourceTag */
  344 
  345             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
  346             break;
  347 
  348         case 13: /* Type */
  349 
  350             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0);
  351             RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
  352                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4);
  353             break;
  354 
  355         case 14: /* Translation Type */
  356 
  357             RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0);
  358             RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
  359                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5);
  360             break;
  361 
  362         default:
  363 
  364             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
  365             break;
  366         }
  367 
  368         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
  369     }
  370 
  371     /* Validate the Min/Max/Len/Gran values */
  372 
  373     RsLargeAddressCheck (
  374         (UINT64) Descriptor->Address16.Minimum,
  375         (UINT64) Descriptor->Address16.Maximum,
  376         (UINT64) Descriptor->Address16.AddressLength,
  377         (UINT64) Descriptor->Address16.Granularity,
  378         Descriptor->Address16.Flags,
  379         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
  380 
  381     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
  382         OptionIndex + StringLength;
  383     return (Rnode);
  384 }
  385 
  386 
  387 /*******************************************************************************
  388  *
  389  * FUNCTION:    RsDoWordBusNumberDescriptor
  390  *
  391  * PARAMETERS:  Info                - Parse Op and resource template offset
  392  *
  393  * RETURN:      Completed resource node
  394  *
  395  * DESCRIPTION: Construct a long "WordBusNumber" descriptor
  396  *
  397  ******************************************************************************/
  398 
  399 ASL_RESOURCE_NODE *
  400 RsDoWordBusNumberDescriptor (
  401     ASL_RESOURCE_INFO       *Info)
  402 {
  403     AML_RESOURCE            *Descriptor;
  404     ACPI_PARSE_OBJECT       *InitializerOp;
  405     ACPI_PARSE_OBJECT       *MinOp = NULL;
  406     ACPI_PARSE_OBJECT       *MaxOp = NULL;
  407     ACPI_PARSE_OBJECT       *LengthOp = NULL;
  408     ACPI_PARSE_OBJECT       *GranOp = NULL;
  409     ASL_RESOURCE_NODE       *Rnode;
  410     UINT8                   *OptionalFields;
  411     UINT16                  StringLength = 0;
  412     UINT32                  OptionIndex = 0;
  413     UINT32                  CurrentByteOffset;
  414     UINT32                  i;
  415     BOOLEAN                 ResSourceIndex = FALSE;
  416 
  417 
  418     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
  419     StringLength = RsGetStringDataLength (InitializerOp);
  420     CurrentByteOffset = Info->CurrentByteOffset;
  421 
  422     Rnode = RsAllocateResourceNode (
  423         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
  424 
  425     Descriptor = Rnode->Buffer;
  426     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
  427     Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE;
  428 
  429     /*
  430      * Initial descriptor length -- may be enlarged if there are
  431      * optional fields present
  432      */
  433     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
  434     Descriptor->Address16.ResourceLength = (UINT16)
  435         (sizeof (AML_RESOURCE_ADDRESS16) -
  436          sizeof (AML_RESOURCE_LARGE_HEADER));
  437 
  438     /* Process all child initialization nodes */
  439 
  440     for (i = 0; InitializerOp; i++)
  441     {
  442         switch (i)
  443         {
  444         case 0: /* Resource Usage */
  445 
  446             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
  447             break;
  448 
  449         case 1: /* MinType */
  450 
  451             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
  452             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
  453                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
  454             break;
  455 
  456         case 2: /* MaxType */
  457 
  458             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
  459             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
  460                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
  461             break;
  462 
  463         case 3: /* DecodeType */
  464 
  465             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
  466             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
  467                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
  468             break;
  469 
  470         case 4: /* Address Granularity */
  471 
  472             Descriptor->Address16.Granularity =
  473                 (UINT16) InitializerOp->Asl.Value.Integer;
  474             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
  475                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
  476             GranOp = InitializerOp;
  477             break;
  478 
  479         case 5: /* Min Address */
  480 
  481             Descriptor->Address16.Minimum =
  482                 (UINT16) InitializerOp->Asl.Value.Integer;
  483             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
  484                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
  485             MinOp = InitializerOp;
  486             break;
  487 
  488         case 6: /* Max Address */
  489 
  490             Descriptor->Address16.Maximum =
  491                 (UINT16) InitializerOp->Asl.Value.Integer;
  492             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
  493                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
  494             MaxOp = InitializerOp;
  495             break;
  496 
  497         case 7: /* Translation Offset */
  498 
  499             Descriptor->Address16.TranslationOffset =
  500                 (UINT16) InitializerOp->Asl.Value.Integer;
  501             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
  502                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
  503             break;
  504 
  505         case 8: /* Address Length */
  506 
  507             Descriptor->Address16.AddressLength =
  508                 (UINT16) InitializerOp->Asl.Value.Integer;
  509             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
  510                  CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
  511             LengthOp = InitializerOp;
  512             break;
  513 
  514         case 9: /* ResSourceIndex [Optional Field - BYTE] */
  515 
  516             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
  517             {
  518                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
  519                 OptionIndex++;
  520                 Descriptor->Address16.ResourceLength++;
  521                 ResSourceIndex = TRUE;
  522             }
  523             break;
  524 
  525         case 10: /* ResSource [Optional Field - STRING] */
  526 
  527             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
  528                 (InitializerOp->Asl.Value.String))
  529             {
  530                 if (StringLength)
  531                 {
  532                     Descriptor->Address16.ResourceLength = (UINT16)
  533                         (Descriptor->Address16.ResourceLength + StringLength);
  534 
  535                     strcpy ((char *)
  536                         &OptionalFields[OptionIndex],
  537                         InitializerOp->Asl.Value.String);
  538 
  539                     /* ResourceSourceIndex must also be valid */
  540 
  541                     if (!ResSourceIndex)
  542                     {
  543                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
  544                             InitializerOp, NULL);
  545                     }
  546                 }
  547             }
  548 
  549 #if 0
  550             /*
  551              * Not a valid ResourceSource, ResourceSourceIndex must also
  552              * be invalid
  553              */
  554             else if (ResSourceIndex)
  555             {
  556                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
  557                     InitializerOp, NULL);
  558             }
  559 #endif
  560             break;
  561 
  562         case 11: /* ResourceTag */
  563 
  564             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
  565             break;
  566 
  567         default:
  568 
  569             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
  570             break;
  571         }
  572 
  573         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
  574     }
  575 
  576     /* Validate the Min/Max/Len/Gran values */
  577 
  578     RsLargeAddressCheck (
  579         (UINT64) Descriptor->Address16.Minimum,
  580         (UINT64) Descriptor->Address16.Maximum,
  581         (UINT64) Descriptor->Address16.AddressLength,
  582         (UINT64) Descriptor->Address16.Granularity,
  583         Descriptor->Address16.Flags,
  584         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
  585 
  586     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
  587         OptionIndex + StringLength;
  588     return (Rnode);
  589 }
  590 
  591 
  592 /*******************************************************************************
  593  *
  594  * FUNCTION:    RsDoWordSpaceDescriptor
  595  *
  596  * PARAMETERS:  Info                - Parse Op and resource template offset
  597  *
  598  * RETURN:      Completed resource node
  599  *
  600  * DESCRIPTION: Construct a long "WordSpace" descriptor
  601  *
  602  ******************************************************************************/
  603 
  604 ASL_RESOURCE_NODE *
  605 RsDoWordSpaceDescriptor (
  606     ASL_RESOURCE_INFO       *Info)
  607 {
  608     AML_RESOURCE            *Descriptor;
  609     ACPI_PARSE_OBJECT       *InitializerOp;
  610     ACPI_PARSE_OBJECT       *MinOp = NULL;
  611     ACPI_PARSE_OBJECT       *MaxOp = NULL;
  612     ACPI_PARSE_OBJECT       *LengthOp = NULL;
  613     ACPI_PARSE_OBJECT       *GranOp = NULL;
  614     ASL_RESOURCE_NODE       *Rnode;
  615     UINT8                   *OptionalFields;
  616     UINT16                  StringLength = 0;
  617     UINT32                  OptionIndex = 0;
  618     UINT32                  CurrentByteOffset;
  619     UINT32                  i;
  620     BOOLEAN                 ResSourceIndex = FALSE;
  621 
  622 
  623     InitializerOp = Info->DescriptorTypeOp->Asl.Child;
  624     StringLength = RsGetStringDataLength (InitializerOp);
  625     CurrentByteOffset = Info->CurrentByteOffset;
  626 
  627     Rnode = RsAllocateResourceNode (
  628         sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
  629 
  630     Descriptor = Rnode->Buffer;
  631     Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
  632 
  633     /*
  634      * Initial descriptor length -- may be enlarged if there are
  635      * optional fields present
  636      */
  637     OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
  638     Descriptor->Address16.ResourceLength = (UINT16)
  639         (sizeof (AML_RESOURCE_ADDRESS16) -
  640          sizeof (AML_RESOURCE_LARGE_HEADER));
  641 
  642     /* Process all child initialization nodes */
  643 
  644     for (i = 0; InitializerOp; i++)
  645     {
  646         switch (i)
  647         {
  648         case 0: /* Resource Type */
  649 
  650             Descriptor->Address16.ResourceType =
  651                 (UINT8) InitializerOp->Asl.Value.Integer;
  652             break;
  653 
  654         case 1: /* Resource Usage */
  655 
  656             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
  657             break;
  658 
  659         case 2: /* DecodeType */
  660 
  661             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
  662             RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
  663                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
  664             break;
  665 
  666         case 3: /* MinType */
  667 
  668             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
  669             RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
  670                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
  671             break;
  672 
  673         case 4: /* MaxType */
  674 
  675             RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
  676             RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
  677                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
  678             break;
  679 
  680         case 5: /* Type-Specific flags */
  681 
  682             Descriptor->Address16.SpecificFlags =
  683                 (UINT8) InitializerOp->Asl.Value.Integer;
  684             break;
  685 
  686         case 6: /* Address Granularity */
  687 
  688             Descriptor->Address16.Granularity =
  689                 (UINT16) InitializerOp->Asl.Value.Integer;
  690             RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
  691                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
  692             GranOp = InitializerOp;
  693             break;
  694 
  695         case 7: /* Min Address */
  696 
  697             Descriptor->Address16.Minimum =
  698                 (UINT16) InitializerOp->Asl.Value.Integer;
  699             RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
  700                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
  701             MinOp = InitializerOp;
  702             break;
  703 
  704         case 8: /* Max Address */
  705 
  706             Descriptor->Address16.Maximum =
  707                 (UINT16) InitializerOp->Asl.Value.Integer;
  708             RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
  709                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
  710             MaxOp = InitializerOp;
  711             break;
  712 
  713         case 9: /* Translation Offset */
  714 
  715             Descriptor->Address16.TranslationOffset =
  716                 (UINT16) InitializerOp->Asl.Value.Integer;
  717             RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
  718                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
  719             break;
  720 
  721         case 10: /* Address Length */
  722 
  723             Descriptor->Address16.AddressLength =
  724                 (UINT16) InitializerOp->Asl.Value.Integer;
  725             RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
  726                 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
  727             LengthOp = InitializerOp;
  728             break;
  729 
  730         case 11: /* ResSourceIndex [Optional Field - BYTE] */
  731 
  732             if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
  733             {
  734                 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
  735                 OptionIndex++;
  736                 Descriptor->Address16.ResourceLength++;
  737                 ResSourceIndex = TRUE;
  738             }
  739             break;
  740 
  741         case 12: /* ResSource [Optional Field - STRING] */
  742 
  743             if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
  744                 (InitializerOp->Asl.Value.String))
  745             {
  746                 if (StringLength)
  747                 {
  748                     Descriptor->Address16.ResourceLength = (UINT16)
  749                         (Descriptor->Address16.ResourceLength + StringLength);
  750 
  751                     strcpy ((char *)
  752                         &OptionalFields[OptionIndex],
  753                         InitializerOp->Asl.Value.String);
  754 
  755                     /* ResourceSourceIndex must also be valid */
  756 
  757                     if (!ResSourceIndex)
  758                     {
  759                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
  760                             InitializerOp, NULL);
  761                     }
  762                 }
  763             }
  764 
  765 #if 0
  766             /*
  767              * Not a valid ResourceSource, ResourceSourceIndex must also
  768              * be invalid
  769              */
  770             else if (ResSourceIndex)
  771             {
  772                 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
  773                     InitializerOp, NULL);
  774             }
  775 #endif
  776             break;
  777 
  778         case 13: /* ResourceTag */
  779 
  780             UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
  781             break;
  782 
  783         default:
  784 
  785             AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
  786             break;
  787         }
  788 
  789         InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
  790     }
  791 
  792     /* Validate the Min/Max/Len/Gran values */
  793 
  794     RsLargeAddressCheck (
  795         (UINT64) Descriptor->Address16.Minimum,
  796         (UINT64) Descriptor->Address16.Maximum,
  797         (UINT64) Descriptor->Address16.AddressLength,
  798         (UINT64) Descriptor->Address16.Granularity,
  799         Descriptor->Address16.Flags,
  800         MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
  801 
  802     Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
  803         OptionIndex + StringLength;
  804     return (Rnode);
  805 }

Cache object: 208323dd68f9f16053fdfa568271978d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.