Home | History | Annotate | Line # | Download | only in utilities
utresrc.c revision 1.1.1.2.10.1
      1           1.1  jruoho /*******************************************************************************
      2           1.1  jruoho  *
      3  1.1.1.2.10.1    yamt  * Module Name: utresrc - Resource management utilities
      4           1.1  jruoho  *
      5           1.1  jruoho  ******************************************************************************/
      6           1.1  jruoho 
      7       1.1.1.2  jruoho /*
      8  1.1.1.2.10.1    yamt  * Copyright (C) 2000 - 2013, Intel Corp.
      9           1.1  jruoho  * All rights reserved.
     10           1.1  jruoho  *
     11       1.1.1.2  jruoho  * Redistribution and use in source and binary forms, with or without
     12       1.1.1.2  jruoho  * modification, are permitted provided that the following conditions
     13       1.1.1.2  jruoho  * are met:
     14       1.1.1.2  jruoho  * 1. Redistributions of source code must retain the above copyright
     15       1.1.1.2  jruoho  *    notice, this list of conditions, and the following disclaimer,
     16       1.1.1.2  jruoho  *    without modification.
     17       1.1.1.2  jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18       1.1.1.2  jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19       1.1.1.2  jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20       1.1.1.2  jruoho  *    including a substantially similar Disclaimer requirement for further
     21       1.1.1.2  jruoho  *    binary redistribution.
     22       1.1.1.2  jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23       1.1.1.2  jruoho  *    of any contributors may be used to endorse or promote products derived
     24       1.1.1.2  jruoho  *    from this software without specific prior written permission.
     25       1.1.1.2  jruoho  *
     26       1.1.1.2  jruoho  * Alternatively, this software may be distributed under the terms of the
     27       1.1.1.2  jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28       1.1.1.2  jruoho  * Software Foundation.
     29       1.1.1.2  jruoho  *
     30       1.1.1.2  jruoho  * NO WARRANTY
     31       1.1.1.2  jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32       1.1.1.2  jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33       1.1.1.2  jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34       1.1.1.2  jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35       1.1.1.2  jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36       1.1.1.2  jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37       1.1.1.2  jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38       1.1.1.2  jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39       1.1.1.2  jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40       1.1.1.2  jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41       1.1.1.2  jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42       1.1.1.2  jruoho  */
     43           1.1  jruoho 
     44           1.1  jruoho 
     45           1.1  jruoho #define __UTRESRC_C__
     46           1.1  jruoho 
     47           1.1  jruoho #include "acpi.h"
     48           1.1  jruoho #include "accommon.h"
     49  1.1.1.2.10.1    yamt #include "acresrc.h"
     50           1.1  jruoho 
     51           1.1  jruoho 
     52           1.1  jruoho #define _COMPONENT          ACPI_UTILITIES
     53           1.1  jruoho         ACPI_MODULE_NAME    ("utresrc")
     54           1.1  jruoho 
     55           1.1  jruoho 
     56           1.1  jruoho #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
     57           1.1  jruoho 
     58           1.1  jruoho /*
     59           1.1  jruoho  * Strings used to decode resource descriptors.
     60  1.1.1.2.10.1    yamt  * Used by both the disassembler and the debugger resource dump routines
     61           1.1  jruoho  */
     62           1.1  jruoho const char                      *AcpiGbl_BmDecode[] =
     63           1.1  jruoho {
     64           1.1  jruoho     "NotBusMaster",
     65           1.1  jruoho     "BusMaster"
     66           1.1  jruoho };
     67           1.1  jruoho 
     68           1.1  jruoho const char                      *AcpiGbl_ConfigDecode[] =
     69           1.1  jruoho {
     70           1.1  jruoho     "0 - Good Configuration",
     71           1.1  jruoho     "1 - Acceptable Configuration",
     72           1.1  jruoho     "2 - Suboptimal Configuration",
     73           1.1  jruoho     "3 - ***Invalid Configuration***",
     74           1.1  jruoho };
     75           1.1  jruoho 
     76           1.1  jruoho const char                      *AcpiGbl_ConsumeDecode[] =
     77           1.1  jruoho {
     78           1.1  jruoho     "ResourceProducer",
     79           1.1  jruoho     "ResourceConsumer"
     80           1.1  jruoho };
     81           1.1  jruoho 
     82           1.1  jruoho const char                      *AcpiGbl_DecDecode[] =
     83           1.1  jruoho {
     84           1.1  jruoho     "PosDecode",
     85           1.1  jruoho     "SubDecode"
     86           1.1  jruoho };
     87           1.1  jruoho 
     88           1.1  jruoho const char                      *AcpiGbl_HeDecode[] =
     89           1.1  jruoho {
     90           1.1  jruoho     "Level",
     91           1.1  jruoho     "Edge"
     92           1.1  jruoho };
     93           1.1  jruoho 
     94           1.1  jruoho const char                      *AcpiGbl_IoDecode[] =
     95           1.1  jruoho {
     96           1.1  jruoho     "Decode10",
     97           1.1  jruoho     "Decode16"
     98           1.1  jruoho };
     99           1.1  jruoho 
    100           1.1  jruoho const char                      *AcpiGbl_LlDecode[] =
    101           1.1  jruoho {
    102           1.1  jruoho     "ActiveHigh",
    103           1.1  jruoho     "ActiveLow"
    104           1.1  jruoho };
    105           1.1  jruoho 
    106           1.1  jruoho const char                      *AcpiGbl_MaxDecode[] =
    107           1.1  jruoho {
    108           1.1  jruoho     "MaxNotFixed",
    109           1.1  jruoho     "MaxFixed"
    110           1.1  jruoho };
    111           1.1  jruoho 
    112           1.1  jruoho const char                      *AcpiGbl_MemDecode[] =
    113           1.1  jruoho {
    114           1.1  jruoho     "NonCacheable",
    115           1.1  jruoho     "Cacheable",
    116           1.1  jruoho     "WriteCombining",
    117           1.1  jruoho     "Prefetchable"
    118           1.1  jruoho };
    119           1.1  jruoho 
    120           1.1  jruoho const char                      *AcpiGbl_MinDecode[] =
    121           1.1  jruoho {
    122           1.1  jruoho     "MinNotFixed",
    123           1.1  jruoho     "MinFixed"
    124           1.1  jruoho };
    125           1.1  jruoho 
    126           1.1  jruoho const char                      *AcpiGbl_MtpDecode[] =
    127           1.1  jruoho {
    128           1.1  jruoho     "AddressRangeMemory",
    129           1.1  jruoho     "AddressRangeReserved",
    130           1.1  jruoho     "AddressRangeACPI",
    131           1.1  jruoho     "AddressRangeNVS"
    132           1.1  jruoho };
    133           1.1  jruoho 
    134           1.1  jruoho const char                      *AcpiGbl_RngDecode[] =
    135           1.1  jruoho {
    136           1.1  jruoho     "InvalidRanges",
    137           1.1  jruoho     "NonISAOnlyRanges",
    138           1.1  jruoho     "ISAOnlyRanges",
    139           1.1  jruoho     "EntireRange"
    140           1.1  jruoho };
    141           1.1  jruoho 
    142           1.1  jruoho const char                      *AcpiGbl_RwDecode[] =
    143           1.1  jruoho {
    144           1.1  jruoho     "ReadOnly",
    145           1.1  jruoho     "ReadWrite"
    146           1.1  jruoho };
    147           1.1  jruoho 
    148           1.1  jruoho const char                      *AcpiGbl_ShrDecode[] =
    149           1.1  jruoho {
    150           1.1  jruoho     "Exclusive",
    151  1.1.1.2.10.1    yamt     "Shared",
    152  1.1.1.2.10.1    yamt     "ExclusiveAndWake",         /* ACPI 5.0 */
    153  1.1.1.2.10.1    yamt     "SharedAndWake"             /* ACPI 5.0 */
    154           1.1  jruoho };
    155           1.1  jruoho 
    156           1.1  jruoho const char                      *AcpiGbl_SizDecode[] =
    157           1.1  jruoho {
    158           1.1  jruoho     "Transfer8",
    159           1.1  jruoho     "Transfer8_16",
    160           1.1  jruoho     "Transfer16",
    161           1.1  jruoho     "InvalidSize"
    162           1.1  jruoho };
    163           1.1  jruoho 
    164           1.1  jruoho const char                      *AcpiGbl_TrsDecode[] =
    165           1.1  jruoho {
    166           1.1  jruoho     "DenseTranslation",
    167           1.1  jruoho     "SparseTranslation"
    168           1.1  jruoho };
    169           1.1  jruoho 
    170           1.1  jruoho const char                      *AcpiGbl_TtpDecode[] =
    171           1.1  jruoho {
    172           1.1  jruoho     "TypeStatic",
    173           1.1  jruoho     "TypeTranslation"
    174           1.1  jruoho };
    175           1.1  jruoho 
    176           1.1  jruoho const char                      *AcpiGbl_TypDecode[] =
    177           1.1  jruoho {
    178           1.1  jruoho     "Compatibility",
    179           1.1  jruoho     "TypeA",
    180           1.1  jruoho     "TypeB",
    181           1.1  jruoho     "TypeF"
    182           1.1  jruoho };
    183           1.1  jruoho 
    184  1.1.1.2.10.1    yamt const char                      *AcpiGbl_PpcDecode[] =
    185  1.1.1.2.10.1    yamt {
    186  1.1.1.2.10.1    yamt     "PullDefault",
    187  1.1.1.2.10.1    yamt     "PullUp",
    188  1.1.1.2.10.1    yamt     "PullDown",
    189  1.1.1.2.10.1    yamt     "PullNone"
    190  1.1.1.2.10.1    yamt };
    191  1.1.1.2.10.1    yamt 
    192  1.1.1.2.10.1    yamt const char                      *AcpiGbl_IorDecode[] =
    193  1.1.1.2.10.1    yamt {
    194  1.1.1.2.10.1    yamt     "IoRestrictionNone",
    195  1.1.1.2.10.1    yamt     "IoRestrictionInputOnly",
    196  1.1.1.2.10.1    yamt     "IoRestrictionOutputOnly",
    197  1.1.1.2.10.1    yamt     "IoRestrictionNoneAndPreserve"
    198  1.1.1.2.10.1    yamt };
    199  1.1.1.2.10.1    yamt 
    200  1.1.1.2.10.1    yamt const char                      *AcpiGbl_DtsDecode[] =
    201  1.1.1.2.10.1    yamt {
    202  1.1.1.2.10.1    yamt     "Width8bit",
    203  1.1.1.2.10.1    yamt     "Width16bit",
    204  1.1.1.2.10.1    yamt     "Width32bit",
    205  1.1.1.2.10.1    yamt     "Width64bit",
    206  1.1.1.2.10.1    yamt     "Width128bit",
    207  1.1.1.2.10.1    yamt     "Width256bit",
    208  1.1.1.2.10.1    yamt };
    209  1.1.1.2.10.1    yamt 
    210  1.1.1.2.10.1    yamt /* GPIO connection type */
    211  1.1.1.2.10.1    yamt 
    212  1.1.1.2.10.1    yamt const char                      *AcpiGbl_CtDecode[] =
    213  1.1.1.2.10.1    yamt {
    214  1.1.1.2.10.1    yamt     "Interrupt",
    215  1.1.1.2.10.1    yamt     "I/O"
    216  1.1.1.2.10.1    yamt };
    217  1.1.1.2.10.1    yamt 
    218  1.1.1.2.10.1    yamt /* Serial bus type */
    219  1.1.1.2.10.1    yamt 
    220  1.1.1.2.10.1    yamt const char                      *AcpiGbl_SbtDecode[] =
    221  1.1.1.2.10.1    yamt {
    222  1.1.1.2.10.1    yamt     "/* UNKNOWN serial bus type */",
    223  1.1.1.2.10.1    yamt     "I2C",
    224  1.1.1.2.10.1    yamt     "SPI",
    225  1.1.1.2.10.1    yamt     "UART"
    226  1.1.1.2.10.1    yamt };
    227  1.1.1.2.10.1    yamt 
    228  1.1.1.2.10.1    yamt /* I2C serial bus access mode */
    229  1.1.1.2.10.1    yamt 
    230  1.1.1.2.10.1    yamt const char                      *AcpiGbl_AmDecode[] =
    231  1.1.1.2.10.1    yamt {
    232  1.1.1.2.10.1    yamt     "AddressingMode7Bit",
    233  1.1.1.2.10.1    yamt     "AddressingMode10Bit"
    234  1.1.1.2.10.1    yamt };
    235  1.1.1.2.10.1    yamt 
    236  1.1.1.2.10.1    yamt /* I2C serial bus slave mode */
    237  1.1.1.2.10.1    yamt 
    238  1.1.1.2.10.1    yamt const char                      *AcpiGbl_SmDecode[] =
    239  1.1.1.2.10.1    yamt {
    240  1.1.1.2.10.1    yamt     "ControllerInitiated",
    241  1.1.1.2.10.1    yamt     "DeviceInitiated"
    242  1.1.1.2.10.1    yamt };
    243  1.1.1.2.10.1    yamt 
    244  1.1.1.2.10.1    yamt /* SPI serial bus wire mode */
    245  1.1.1.2.10.1    yamt 
    246  1.1.1.2.10.1    yamt const char                      *AcpiGbl_WmDecode[] =
    247  1.1.1.2.10.1    yamt {
    248  1.1.1.2.10.1    yamt     "FourWireMode",
    249  1.1.1.2.10.1    yamt     "ThreeWireMode"
    250  1.1.1.2.10.1    yamt };
    251  1.1.1.2.10.1    yamt 
    252  1.1.1.2.10.1    yamt /* SPI serial clock phase */
    253  1.1.1.2.10.1    yamt 
    254  1.1.1.2.10.1    yamt const char                      *AcpiGbl_CphDecode[] =
    255  1.1.1.2.10.1    yamt {
    256  1.1.1.2.10.1    yamt     "ClockPhaseFirst",
    257  1.1.1.2.10.1    yamt     "ClockPhaseSecond"
    258  1.1.1.2.10.1    yamt };
    259  1.1.1.2.10.1    yamt 
    260  1.1.1.2.10.1    yamt /* SPI serial bus clock polarity */
    261  1.1.1.2.10.1    yamt 
    262  1.1.1.2.10.1    yamt const char                      *AcpiGbl_CpoDecode[] =
    263  1.1.1.2.10.1    yamt {
    264  1.1.1.2.10.1    yamt     "ClockPolarityLow",
    265  1.1.1.2.10.1    yamt     "ClockPolarityHigh"
    266  1.1.1.2.10.1    yamt };
    267  1.1.1.2.10.1    yamt 
    268  1.1.1.2.10.1    yamt /* SPI serial bus device polarity */
    269  1.1.1.2.10.1    yamt 
    270  1.1.1.2.10.1    yamt const char                      *AcpiGbl_DpDecode[] =
    271  1.1.1.2.10.1    yamt {
    272  1.1.1.2.10.1    yamt     "PolarityLow",
    273  1.1.1.2.10.1    yamt     "PolarityHigh"
    274  1.1.1.2.10.1    yamt };
    275  1.1.1.2.10.1    yamt 
    276  1.1.1.2.10.1    yamt /* UART serial bus endian */
    277  1.1.1.2.10.1    yamt 
    278  1.1.1.2.10.1    yamt const char                      *AcpiGbl_EdDecode[] =
    279  1.1.1.2.10.1    yamt {
    280  1.1.1.2.10.1    yamt     "LittleEndian",
    281  1.1.1.2.10.1    yamt     "BigEndian"
    282  1.1.1.2.10.1    yamt };
    283  1.1.1.2.10.1    yamt 
    284  1.1.1.2.10.1    yamt /* UART serial bus bits per byte */
    285  1.1.1.2.10.1    yamt 
    286  1.1.1.2.10.1    yamt const char                      *AcpiGbl_BpbDecode[] =
    287  1.1.1.2.10.1    yamt {
    288  1.1.1.2.10.1    yamt     "DataBitsFive",
    289  1.1.1.2.10.1    yamt     "DataBitsSix",
    290  1.1.1.2.10.1    yamt     "DataBitsSeven",
    291  1.1.1.2.10.1    yamt     "DataBitsEight",
    292  1.1.1.2.10.1    yamt     "DataBitsNine",
    293  1.1.1.2.10.1    yamt     "/* UNKNOWN Bits per byte */",
    294  1.1.1.2.10.1    yamt     "/* UNKNOWN Bits per byte */",
    295  1.1.1.2.10.1    yamt     "/* UNKNOWN Bits per byte */"
    296  1.1.1.2.10.1    yamt };
    297  1.1.1.2.10.1    yamt 
    298  1.1.1.2.10.1    yamt /* UART serial bus stop bits */
    299  1.1.1.2.10.1    yamt 
    300  1.1.1.2.10.1    yamt const char                      *AcpiGbl_SbDecode[] =
    301  1.1.1.2.10.1    yamt {
    302  1.1.1.2.10.1    yamt     "StopBitsNone",
    303  1.1.1.2.10.1    yamt     "StopBitsOne",
    304  1.1.1.2.10.1    yamt     "StopBitsOnePlusHalf",
    305  1.1.1.2.10.1    yamt     "StopBitsTwo"
    306  1.1.1.2.10.1    yamt };
    307  1.1.1.2.10.1    yamt 
    308  1.1.1.2.10.1    yamt /* UART serial bus flow control */
    309  1.1.1.2.10.1    yamt 
    310  1.1.1.2.10.1    yamt const char                      *AcpiGbl_FcDecode[] =
    311  1.1.1.2.10.1    yamt {
    312  1.1.1.2.10.1    yamt     "FlowControlNone",
    313  1.1.1.2.10.1    yamt     "FlowControlHardware",
    314  1.1.1.2.10.1    yamt     "FlowControlXON",
    315  1.1.1.2.10.1    yamt     "/* UNKNOWN flow control keyword */"
    316  1.1.1.2.10.1    yamt };
    317  1.1.1.2.10.1    yamt 
    318  1.1.1.2.10.1    yamt /* UART serial bus parity type */
    319  1.1.1.2.10.1    yamt 
    320  1.1.1.2.10.1    yamt const char                      *AcpiGbl_PtDecode[] =
    321  1.1.1.2.10.1    yamt {
    322  1.1.1.2.10.1    yamt     "ParityTypeNone",
    323  1.1.1.2.10.1    yamt     "ParityTypeEven",
    324  1.1.1.2.10.1    yamt     "ParityTypeOdd",
    325  1.1.1.2.10.1    yamt     "ParityTypeMark",
    326  1.1.1.2.10.1    yamt     "ParityTypeSpace",
    327  1.1.1.2.10.1    yamt     "/* UNKNOWN parity keyword */",
    328  1.1.1.2.10.1    yamt     "/* UNKNOWN parity keyword */",
    329  1.1.1.2.10.1    yamt     "/* UNKNOWN parity keyword */"
    330  1.1.1.2.10.1    yamt };
    331  1.1.1.2.10.1    yamt 
    332           1.1  jruoho #endif
    333           1.1  jruoho 
    334           1.1  jruoho 
    335           1.1  jruoho /*
    336           1.1  jruoho  * Base sizes of the raw AML resource descriptors, indexed by resource type.
    337           1.1  jruoho  * Zero indicates a reserved (and therefore invalid) resource type.
    338           1.1  jruoho  */
    339           1.1  jruoho const UINT8                 AcpiGbl_ResourceAmlSizes[] =
    340           1.1  jruoho {
    341           1.1  jruoho     /* Small descriptors */
    342           1.1  jruoho 
    343           1.1  jruoho     0,
    344           1.1  jruoho     0,
    345           1.1  jruoho     0,
    346           1.1  jruoho     0,
    347           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ),
    348           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA),
    349           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT),
    350           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT),
    351           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO),
    352           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO),
    353  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_DMA),
    354           1.1  jruoho     0,
    355           1.1  jruoho     0,
    356           1.1  jruoho     0,
    357           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL),
    358           1.1  jruoho     ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG),
    359           1.1  jruoho 
    360           1.1  jruoho     /* Large descriptors */
    361           1.1  jruoho 
    362           1.1  jruoho     0,
    363           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24),
    364           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER),
    365           1.1  jruoho     0,
    366           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE),
    367           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32),
    368           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32),
    369           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32),
    370           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16),
    371           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ),
    372           1.1  jruoho     ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64),
    373  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64),
    374  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO),
    375  1.1.1.2.10.1    yamt     0,
    376  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_COMMON_SERIALBUS),
    377  1.1.1.2.10.1    yamt };
    378  1.1.1.2.10.1    yamt 
    379  1.1.1.2.10.1    yamt const UINT8                 AcpiGbl_ResourceAmlSerialBusSizes[] =
    380  1.1.1.2.10.1    yamt {
    381  1.1.1.2.10.1    yamt     0,
    382  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS),
    383  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS),
    384  1.1.1.2.10.1    yamt     ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS),
    385           1.1  jruoho };
    386           1.1  jruoho 
    387           1.1  jruoho 
    388           1.1  jruoho /*
    389           1.1  jruoho  * Resource types, used to validate the resource length field.
    390           1.1  jruoho  * The length of fixed-length types must match exactly, variable
    391           1.1  jruoho  * lengths must meet the minimum required length, etc.
    392           1.1  jruoho  * Zero indicates a reserved (and therefore invalid) resource type.
    393           1.1  jruoho  */
    394           1.1  jruoho static const UINT8          AcpiGbl_ResourceTypes[] =
    395           1.1  jruoho {
    396           1.1  jruoho     /* Small descriptors */
    397           1.1  jruoho 
    398           1.1  jruoho     0,
    399           1.1  jruoho     0,
    400           1.1  jruoho     0,
    401           1.1  jruoho     0,
    402  1.1.1.2.10.1    yamt     ACPI_SMALL_VARIABLE_LENGTH,     /* 04 IRQ */
    403  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 05 DMA */
    404  1.1.1.2.10.1    yamt     ACPI_SMALL_VARIABLE_LENGTH,     /* 06 StartDependentFunctions */
    405  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 07 EndDependentFunctions */
    406  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 08 IO */
    407  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 09 FixedIO */
    408  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 0A FixedDMA */
    409           1.1  jruoho     0,
    410           1.1  jruoho     0,
    411           1.1  jruoho     0,
    412  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 0E VendorShort */
    413  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 0F EndTag */
    414           1.1  jruoho 
    415           1.1  jruoho     /* Large descriptors */
    416           1.1  jruoho 
    417           1.1  jruoho     0,
    418  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 01 Memory24 */
    419  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 02 GenericRegister */
    420           1.1  jruoho     0,
    421  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 04 VendorLong */
    422  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 05 Memory32 */
    423  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 06 Memory32Fixed */
    424  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 07 Dword* address */
    425  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 08 Word* address */
    426  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 09 ExtendedIRQ */
    427  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 0A Qword* address */
    428  1.1.1.2.10.1    yamt     ACPI_FIXED_LENGTH,              /* 0B Extended* address */
    429  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH,           /* 0C Gpio* */
    430  1.1.1.2.10.1    yamt     0,
    431  1.1.1.2.10.1    yamt     ACPI_VARIABLE_LENGTH            /* 0E *SerialBus */
    432           1.1  jruoho };
    433           1.1  jruoho 
    434           1.1  jruoho 
    435           1.1  jruoho /*******************************************************************************
    436           1.1  jruoho  *
    437           1.1  jruoho  * FUNCTION:    AcpiUtWalkAmlResources
    438           1.1  jruoho  *
    439  1.1.1.2.10.1    yamt  * PARAMETERS:  WalkState           - Current walk info
    440  1.1.1.2.10.1    yamt  * PARAMETERS:  Aml                 - Pointer to the raw AML resource template
    441  1.1.1.2.10.1    yamt  *              AmlLength           - Length of the entire template
    442  1.1.1.2.10.1    yamt  *              UserFunction        - Called once for each descriptor found. If
    443  1.1.1.2.10.1    yamt  *                                    NULL, a pointer to the EndTag is returned
    444  1.1.1.2.10.1    yamt  *              Context             - Passed to UserFunction
    445           1.1  jruoho  *
    446           1.1  jruoho  * RETURN:      Status
    447           1.1  jruoho  *
    448           1.1  jruoho  * DESCRIPTION: Walk a raw AML resource list(buffer). User function called
    449           1.1  jruoho  *              once for each resource found.
    450           1.1  jruoho  *
    451           1.1  jruoho  ******************************************************************************/
    452           1.1  jruoho 
    453           1.1  jruoho ACPI_STATUS
    454           1.1  jruoho AcpiUtWalkAmlResources (
    455  1.1.1.2.10.1    yamt     ACPI_WALK_STATE         *WalkState,
    456           1.1  jruoho     UINT8                   *Aml,
    457           1.1  jruoho     ACPI_SIZE               AmlLength,
    458           1.1  jruoho     ACPI_WALK_AML_CALLBACK  UserFunction,
    459  1.1.1.2.10.1    yamt     void                    **Context)
    460           1.1  jruoho {
    461           1.1  jruoho     ACPI_STATUS             Status;
    462           1.1  jruoho     UINT8                   *EndAml;
    463           1.1  jruoho     UINT8                   ResourceIndex;
    464           1.1  jruoho     UINT32                  Length;
    465           1.1  jruoho     UINT32                  Offset = 0;
    466  1.1.1.2.10.1    yamt     UINT8                   EndTag[2] = {0x79, 0x00};
    467           1.1  jruoho 
    468           1.1  jruoho 
    469           1.1  jruoho     ACPI_FUNCTION_TRACE (UtWalkAmlResources);
    470           1.1  jruoho 
    471           1.1  jruoho 
    472           1.1  jruoho     /* The absolute minimum resource template is one EndTag descriptor */
    473           1.1  jruoho 
    474           1.1  jruoho     if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
    475           1.1  jruoho     {
    476           1.1  jruoho         return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
    477           1.1  jruoho     }
    478           1.1  jruoho 
    479           1.1  jruoho     /* Point to the end of the resource template buffer */
    480           1.1  jruoho 
    481           1.1  jruoho     EndAml = Aml + AmlLength;
    482           1.1  jruoho 
    483           1.1  jruoho     /* Walk the byte list, abort on any invalid descriptor type or length */
    484           1.1  jruoho 
    485           1.1  jruoho     while (Aml < EndAml)
    486           1.1  jruoho     {
    487           1.1  jruoho         /* Validate the Resource Type and Resource Length */
    488           1.1  jruoho 
    489  1.1.1.2.10.1    yamt         Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex);
    490           1.1  jruoho         if (ACPI_FAILURE (Status))
    491           1.1  jruoho         {
    492  1.1.1.2.10.1    yamt             /*
    493  1.1.1.2.10.1    yamt              * Exit on failure. Cannot continue because the descriptor length
    494  1.1.1.2.10.1    yamt              * may be bogus also.
    495  1.1.1.2.10.1    yamt              */
    496           1.1  jruoho             return_ACPI_STATUS (Status);
    497           1.1  jruoho         }
    498           1.1  jruoho 
    499           1.1  jruoho         /* Get the length of this descriptor */
    500           1.1  jruoho 
    501           1.1  jruoho         Length = AcpiUtGetDescriptorLength (Aml);
    502           1.1  jruoho 
    503           1.1  jruoho         /* Invoke the user function */
    504           1.1  jruoho 
    505           1.1  jruoho         if (UserFunction)
    506           1.1  jruoho         {
    507           1.1  jruoho             Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context);
    508           1.1  jruoho             if (ACPI_FAILURE (Status))
    509           1.1  jruoho             {
    510  1.1.1.2.10.1    yamt                 return_ACPI_STATUS (Status);
    511           1.1  jruoho             }
    512           1.1  jruoho         }
    513           1.1  jruoho 
    514           1.1  jruoho         /* An EndTag descriptor terminates this resource template */
    515           1.1  jruoho 
    516           1.1  jruoho         if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG)
    517           1.1  jruoho         {
    518           1.1  jruoho             /*
    519           1.1  jruoho              * There must be at least one more byte in the buffer for
    520           1.1  jruoho              * the 2nd byte of the EndTag
    521           1.1  jruoho              */
    522           1.1  jruoho             if ((Aml + 1) >= EndAml)
    523           1.1  jruoho             {
    524           1.1  jruoho                 return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
    525           1.1  jruoho             }
    526           1.1  jruoho 
    527           1.1  jruoho             /* Return the pointer to the EndTag if requested */
    528           1.1  jruoho 
    529           1.1  jruoho             if (!UserFunction)
    530           1.1  jruoho             {
    531  1.1.1.2.10.1    yamt                 *Context = Aml;
    532           1.1  jruoho             }
    533           1.1  jruoho 
    534           1.1  jruoho             /* Normal exit */
    535           1.1  jruoho 
    536           1.1  jruoho             return_ACPI_STATUS (AE_OK);
    537           1.1  jruoho         }
    538           1.1  jruoho 
    539           1.1  jruoho         Aml += Length;
    540           1.1  jruoho         Offset += Length;
    541           1.1  jruoho     }
    542           1.1  jruoho 
    543           1.1  jruoho     /* Did not find an EndTag descriptor */
    544           1.1  jruoho 
    545  1.1.1.2.10.1    yamt     if (UserFunction)
    546  1.1.1.2.10.1    yamt     {
    547  1.1.1.2.10.1    yamt         /* Insert an EndTag anyway. AcpiRsGetListLength always leaves room */
    548  1.1.1.2.10.1    yamt 
    549  1.1.1.2.10.1    yamt         (void) AcpiUtValidateResource (WalkState, EndTag, &ResourceIndex);
    550  1.1.1.2.10.1    yamt         Status = UserFunction (EndTag, 2, Offset, ResourceIndex, Context);
    551  1.1.1.2.10.1    yamt         if (ACPI_FAILURE (Status))
    552  1.1.1.2.10.1    yamt         {
    553  1.1.1.2.10.1    yamt             return_ACPI_STATUS (Status);
    554  1.1.1.2.10.1    yamt         }
    555  1.1.1.2.10.1    yamt     }
    556  1.1.1.2.10.1    yamt 
    557  1.1.1.2.10.1    yamt     return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
    558           1.1  jruoho }
    559           1.1  jruoho 
    560           1.1  jruoho 
    561           1.1  jruoho /*******************************************************************************
    562           1.1  jruoho  *
    563           1.1  jruoho  * FUNCTION:    AcpiUtValidateResource
    564           1.1  jruoho  *
    565  1.1.1.2.10.1    yamt  * PARAMETERS:  WalkState           - Current walk info
    566  1.1.1.2.10.1    yamt  *              Aml                 - Pointer to the raw AML resource descriptor
    567  1.1.1.2.10.1    yamt  *              ReturnIndex         - Where the resource index is returned. NULL
    568  1.1.1.2.10.1    yamt  *                                    if the index is not required.
    569           1.1  jruoho  *
    570           1.1  jruoho  * RETURN:      Status, and optionally the Index into the global resource tables
    571           1.1  jruoho  *
    572           1.1  jruoho  * DESCRIPTION: Validate an AML resource descriptor by checking the Resource
    573           1.1  jruoho  *              Type and Resource Length. Returns an index into the global
    574           1.1  jruoho  *              resource information/dispatch tables for later use.
    575           1.1  jruoho  *
    576           1.1  jruoho  ******************************************************************************/
    577           1.1  jruoho 
    578           1.1  jruoho ACPI_STATUS
    579           1.1  jruoho AcpiUtValidateResource (
    580  1.1.1.2.10.1    yamt     ACPI_WALK_STATE         *WalkState,
    581           1.1  jruoho     void                    *Aml,
    582           1.1  jruoho     UINT8                   *ReturnIndex)
    583           1.1  jruoho {
    584  1.1.1.2.10.1    yamt     AML_RESOURCE            *AmlResource;
    585           1.1  jruoho     UINT8                   ResourceType;
    586           1.1  jruoho     UINT8                   ResourceIndex;
    587           1.1  jruoho     ACPI_RS_LENGTH          ResourceLength;
    588           1.1  jruoho     ACPI_RS_LENGTH          MinimumResourceLength;
    589           1.1  jruoho 
    590           1.1  jruoho 
    591           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    592           1.1  jruoho 
    593           1.1  jruoho 
    594           1.1  jruoho     /*
    595           1.1  jruoho      * 1) Validate the ResourceType field (Byte 0)
    596           1.1  jruoho      */
    597           1.1  jruoho     ResourceType = ACPI_GET8 (Aml);
    598           1.1  jruoho 
    599           1.1  jruoho     /*
    600           1.1  jruoho      * Byte 0 contains the descriptor name (Resource Type)
    601           1.1  jruoho      * Examine the large/small bit in the resource header
    602           1.1  jruoho      */
    603           1.1  jruoho     if (ResourceType & ACPI_RESOURCE_NAME_LARGE)
    604           1.1  jruoho     {
    605           1.1  jruoho         /* Verify the large resource type (name) against the max */
    606           1.1  jruoho 
    607           1.1  jruoho         if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX)
    608           1.1  jruoho         {
    609  1.1.1.2.10.1    yamt             goto InvalidResource;
    610           1.1  jruoho         }
    611           1.1  jruoho 
    612           1.1  jruoho         /*
    613           1.1  jruoho          * Large Resource Type -- bits 6:0 contain the name
    614           1.1  jruoho          * Translate range 0x80-0x8B to index range 0x10-0x1B
    615           1.1  jruoho          */
    616           1.1  jruoho         ResourceIndex = (UINT8) (ResourceType - 0x70);
    617           1.1  jruoho     }
    618           1.1  jruoho     else
    619           1.1  jruoho     {
    620           1.1  jruoho         /*
    621           1.1  jruoho          * Small Resource Type -- bits 6:3 contain the name
    622           1.1  jruoho          * Shift range to index range 0x00-0x0F
    623           1.1  jruoho          */
    624           1.1  jruoho         ResourceIndex = (UINT8)
    625           1.1  jruoho             ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
    626           1.1  jruoho     }
    627           1.1  jruoho 
    628  1.1.1.2.10.1    yamt     /*
    629  1.1.1.2.10.1    yamt      * Check validity of the resource type, via AcpiGbl_ResourceTypes. Zero
    630  1.1.1.2.10.1    yamt      * indicates an invalid resource.
    631  1.1.1.2.10.1    yamt      */
    632           1.1  jruoho     if (!AcpiGbl_ResourceTypes[ResourceIndex])
    633           1.1  jruoho     {
    634  1.1.1.2.10.1    yamt         goto InvalidResource;
    635           1.1  jruoho     }
    636           1.1  jruoho 
    637           1.1  jruoho     /*
    638  1.1.1.2.10.1    yamt      * Validate the ResourceLength field. This ensures that the length
    639  1.1.1.2.10.1    yamt      * is at least reasonable, and guarantees that it is non-zero.
    640           1.1  jruoho      */
    641           1.1  jruoho     ResourceLength = AcpiUtGetResourceLength (Aml);
    642           1.1  jruoho     MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex];
    643           1.1  jruoho 
    644           1.1  jruoho     /* Validate based upon the type of resource - fixed length or variable */
    645           1.1  jruoho 
    646           1.1  jruoho     switch (AcpiGbl_ResourceTypes[ResourceIndex])
    647           1.1  jruoho     {
    648           1.1  jruoho     case ACPI_FIXED_LENGTH:
    649           1.1  jruoho 
    650           1.1  jruoho         /* Fixed length resource, length must match exactly */
    651           1.1  jruoho 
    652           1.1  jruoho         if (ResourceLength != MinimumResourceLength)
    653           1.1  jruoho         {
    654  1.1.1.2.10.1    yamt             goto BadResourceLength;
    655           1.1  jruoho         }
    656           1.1  jruoho         break;
    657           1.1  jruoho 
    658           1.1  jruoho     case ACPI_VARIABLE_LENGTH:
    659           1.1  jruoho 
    660           1.1  jruoho         /* Variable length resource, length must be at least the minimum */
    661           1.1  jruoho 
    662           1.1  jruoho         if (ResourceLength < MinimumResourceLength)
    663           1.1  jruoho         {
    664  1.1.1.2.10.1    yamt             goto BadResourceLength;
    665           1.1  jruoho         }
    666           1.1  jruoho         break;
    667           1.1  jruoho 
    668           1.1  jruoho     case ACPI_SMALL_VARIABLE_LENGTH:
    669           1.1  jruoho 
    670           1.1  jruoho         /* Small variable length resource, length can be (Min) or (Min-1) */
    671           1.1  jruoho 
    672           1.1  jruoho         if ((ResourceLength > MinimumResourceLength) ||
    673           1.1  jruoho             (ResourceLength < (MinimumResourceLength - 1)))
    674           1.1  jruoho         {
    675  1.1.1.2.10.1    yamt             goto BadResourceLength;
    676           1.1  jruoho         }
    677           1.1  jruoho         break;
    678           1.1  jruoho 
    679           1.1  jruoho     default:
    680           1.1  jruoho 
    681           1.1  jruoho         /* Shouldn't happen (because of validation earlier), but be sure */
    682           1.1  jruoho 
    683  1.1.1.2.10.1    yamt         goto InvalidResource;
    684  1.1.1.2.10.1    yamt     }
    685  1.1.1.2.10.1    yamt 
    686  1.1.1.2.10.1    yamt     AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
    687  1.1.1.2.10.1    yamt     if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
    688  1.1.1.2.10.1    yamt     {
    689  1.1.1.2.10.1    yamt         /* Validate the BusType field */
    690  1.1.1.2.10.1    yamt 
    691  1.1.1.2.10.1    yamt         if ((AmlResource->CommonSerialBus.Type == 0) ||
    692  1.1.1.2.10.1    yamt             (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
    693  1.1.1.2.10.1    yamt         {
    694  1.1.1.2.10.1    yamt             if (WalkState)
    695  1.1.1.2.10.1    yamt             {
    696  1.1.1.2.10.1    yamt                 ACPI_ERROR ((AE_INFO,
    697  1.1.1.2.10.1    yamt                     "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
    698  1.1.1.2.10.1    yamt                     AmlResource->CommonSerialBus.Type));
    699  1.1.1.2.10.1    yamt             }
    700  1.1.1.2.10.1    yamt             return (AE_AML_INVALID_RESOURCE_TYPE);
    701  1.1.1.2.10.1    yamt         }
    702           1.1  jruoho     }
    703           1.1  jruoho 
    704           1.1  jruoho     /* Optionally return the resource table index */
    705           1.1  jruoho 
    706           1.1  jruoho     if (ReturnIndex)
    707           1.1  jruoho     {
    708           1.1  jruoho         *ReturnIndex = ResourceIndex;
    709           1.1  jruoho     }
    710           1.1  jruoho 
    711           1.1  jruoho     return (AE_OK);
    712  1.1.1.2.10.1    yamt 
    713  1.1.1.2.10.1    yamt 
    714  1.1.1.2.10.1    yamt InvalidResource:
    715  1.1.1.2.10.1    yamt 
    716  1.1.1.2.10.1    yamt     if (WalkState)
    717  1.1.1.2.10.1    yamt     {
    718  1.1.1.2.10.1    yamt         ACPI_ERROR ((AE_INFO,
    719  1.1.1.2.10.1    yamt             "Invalid/unsupported resource descriptor: Type 0x%2.2X",
    720  1.1.1.2.10.1    yamt             ResourceType));
    721  1.1.1.2.10.1    yamt     }
    722  1.1.1.2.10.1    yamt     return (AE_AML_INVALID_RESOURCE_TYPE);
    723  1.1.1.2.10.1    yamt 
    724  1.1.1.2.10.1    yamt BadResourceLength:
    725  1.1.1.2.10.1    yamt 
    726  1.1.1.2.10.1    yamt     if (WalkState)
    727  1.1.1.2.10.1    yamt     {
    728  1.1.1.2.10.1    yamt         ACPI_ERROR ((AE_INFO,
    729  1.1.1.2.10.1    yamt             "Invalid resource descriptor length: Type "
    730  1.1.1.2.10.1    yamt             "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
    731  1.1.1.2.10.1    yamt             ResourceType, ResourceLength, MinimumResourceLength));
    732  1.1.1.2.10.1    yamt     }
    733  1.1.1.2.10.1    yamt     return (AE_AML_BAD_RESOURCE_LENGTH);
    734           1.1  jruoho }
    735           1.1  jruoho 
    736           1.1  jruoho 
    737           1.1  jruoho /*******************************************************************************
    738           1.1  jruoho  *
    739           1.1  jruoho  * FUNCTION:    AcpiUtGetResourceType
    740           1.1  jruoho  *
    741           1.1  jruoho  * PARAMETERS:  Aml             - Pointer to the raw AML resource descriptor
    742           1.1  jruoho  *
    743           1.1  jruoho  * RETURN:      The Resource Type with no extraneous bits (except the
    744           1.1  jruoho  *              Large/Small descriptor bit -- this is left alone)
    745           1.1  jruoho  *
    746           1.1  jruoho  * DESCRIPTION: Extract the Resource Type/Name from the first byte of
    747           1.1  jruoho  *              a resource descriptor.
    748           1.1  jruoho  *
    749           1.1  jruoho  ******************************************************************************/
    750           1.1  jruoho 
    751           1.1  jruoho UINT8
    752           1.1  jruoho AcpiUtGetResourceType (
    753           1.1  jruoho     void                    *Aml)
    754           1.1  jruoho {
    755           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    756           1.1  jruoho 
    757           1.1  jruoho 
    758           1.1  jruoho     /*
    759           1.1  jruoho      * Byte 0 contains the descriptor name (Resource Type)
    760           1.1  jruoho      * Examine the large/small bit in the resource header
    761           1.1  jruoho      */
    762           1.1  jruoho     if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
    763           1.1  jruoho     {
    764           1.1  jruoho         /* Large Resource Type -- bits 6:0 contain the name */
    765           1.1  jruoho 
    766           1.1  jruoho         return (ACPI_GET8 (Aml));
    767           1.1  jruoho     }
    768           1.1  jruoho     else
    769           1.1  jruoho     {
    770           1.1  jruoho         /* Small Resource Type -- bits 6:3 contain the name */
    771           1.1  jruoho 
    772           1.1  jruoho         return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
    773           1.1  jruoho     }
    774           1.1  jruoho }
    775           1.1  jruoho 
    776           1.1  jruoho 
    777           1.1  jruoho /*******************************************************************************
    778           1.1  jruoho  *
    779           1.1  jruoho  * FUNCTION:    AcpiUtGetResourceLength
    780           1.1  jruoho  *
    781           1.1  jruoho  * PARAMETERS:  Aml             - Pointer to the raw AML resource descriptor
    782           1.1  jruoho  *
    783           1.1  jruoho  * RETURN:      Byte Length
    784           1.1  jruoho  *
    785           1.1  jruoho  * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By
    786           1.1  jruoho  *              definition, this does not include the size of the descriptor
    787           1.1  jruoho  *              header or the length field itself.
    788           1.1  jruoho  *
    789           1.1  jruoho  ******************************************************************************/
    790           1.1  jruoho 
    791           1.1  jruoho UINT16
    792           1.1  jruoho AcpiUtGetResourceLength (
    793           1.1  jruoho     void                    *Aml)
    794           1.1  jruoho {
    795           1.1  jruoho     ACPI_RS_LENGTH          ResourceLength;
    796           1.1  jruoho 
    797           1.1  jruoho 
    798           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    799           1.1  jruoho 
    800           1.1  jruoho 
    801           1.1  jruoho     /*
    802           1.1  jruoho      * Byte 0 contains the descriptor name (Resource Type)
    803           1.1  jruoho      * Examine the large/small bit in the resource header
    804           1.1  jruoho      */
    805           1.1  jruoho     if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
    806           1.1  jruoho     {
    807           1.1  jruoho         /* Large Resource type -- bytes 1-2 contain the 16-bit length */
    808           1.1  jruoho 
    809           1.1  jruoho         ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1));
    810           1.1  jruoho 
    811           1.1  jruoho     }
    812           1.1  jruoho     else
    813           1.1  jruoho     {
    814           1.1  jruoho         /* Small Resource type -- bits 2:0 of byte 0 contain the length */
    815           1.1  jruoho 
    816           1.1  jruoho         ResourceLength = (UINT16) (ACPI_GET8 (Aml) &
    817           1.1  jruoho                                     ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
    818           1.1  jruoho     }
    819           1.1  jruoho 
    820           1.1  jruoho     return (ResourceLength);
    821           1.1  jruoho }
    822           1.1  jruoho 
    823           1.1  jruoho 
    824           1.1  jruoho /*******************************************************************************
    825           1.1  jruoho  *
    826           1.1  jruoho  * FUNCTION:    AcpiUtGetResourceHeaderLength
    827           1.1  jruoho  *
    828           1.1  jruoho  * PARAMETERS:  Aml             - Pointer to the raw AML resource descriptor
    829           1.1  jruoho  *
    830           1.1  jruoho  * RETURN:      Length of the AML header (depends on large/small descriptor)
    831           1.1  jruoho  *
    832           1.1  jruoho  * DESCRIPTION: Get the length of the header for this resource.
    833           1.1  jruoho  *
    834           1.1  jruoho  ******************************************************************************/
    835           1.1  jruoho 
    836           1.1  jruoho UINT8
    837           1.1  jruoho AcpiUtGetResourceHeaderLength (
    838           1.1  jruoho     void                    *Aml)
    839           1.1  jruoho {
    840           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    841           1.1  jruoho 
    842           1.1  jruoho 
    843           1.1  jruoho     /* Examine the large/small bit in the resource header */
    844           1.1  jruoho 
    845           1.1  jruoho     if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE)
    846           1.1  jruoho     {
    847           1.1  jruoho         return (sizeof (AML_RESOURCE_LARGE_HEADER));
    848           1.1  jruoho     }
    849           1.1  jruoho     else
    850           1.1  jruoho     {
    851           1.1  jruoho         return (sizeof (AML_RESOURCE_SMALL_HEADER));
    852           1.1  jruoho     }
    853           1.1  jruoho }
    854           1.1  jruoho 
    855           1.1  jruoho 
    856           1.1  jruoho /*******************************************************************************
    857           1.1  jruoho  *
    858           1.1  jruoho  * FUNCTION:    AcpiUtGetDescriptorLength
    859           1.1  jruoho  *
    860           1.1  jruoho  * PARAMETERS:  Aml             - Pointer to the raw AML resource descriptor
    861           1.1  jruoho  *
    862           1.1  jruoho  * RETURN:      Byte length
    863           1.1  jruoho  *
    864           1.1  jruoho  * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the
    865           1.1  jruoho  *              length of the descriptor header and the length field itself.
    866           1.1  jruoho  *              Used to walk descriptor lists.
    867           1.1  jruoho  *
    868           1.1  jruoho  ******************************************************************************/
    869           1.1  jruoho 
    870           1.1  jruoho UINT32
    871           1.1  jruoho AcpiUtGetDescriptorLength (
    872           1.1  jruoho     void                    *Aml)
    873           1.1  jruoho {
    874           1.1  jruoho     ACPI_FUNCTION_ENTRY ();
    875           1.1  jruoho 
    876           1.1  jruoho 
    877           1.1  jruoho     /*
    878           1.1  jruoho      * Get the Resource Length (does not include header length) and add
    879           1.1  jruoho      * the header length (depends on if this is a small or large resource)
    880           1.1  jruoho      */
    881           1.1  jruoho     return (AcpiUtGetResourceLength (Aml) +
    882           1.1  jruoho             AcpiUtGetResourceHeaderLength (Aml));
    883           1.1  jruoho }
    884           1.1  jruoho 
    885           1.1  jruoho 
    886           1.1  jruoho /*******************************************************************************
    887           1.1  jruoho  *
    888           1.1  jruoho  * FUNCTION:    AcpiUtGetResourceEndTag
    889           1.1  jruoho  *
    890           1.1  jruoho  * PARAMETERS:  ObjDesc         - The resource template buffer object
    891           1.1  jruoho  *              EndTag          - Where the pointer to the EndTag is returned
    892           1.1  jruoho  *
    893           1.1  jruoho  * RETURN:      Status, pointer to the end tag
    894           1.1  jruoho  *
    895           1.1  jruoho  * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template
    896           1.1  jruoho  *              Note: allows a buffer length of zero.
    897           1.1  jruoho  *
    898           1.1  jruoho  ******************************************************************************/
    899           1.1  jruoho 
    900           1.1  jruoho ACPI_STATUS
    901           1.1  jruoho AcpiUtGetResourceEndTag (
    902           1.1  jruoho     ACPI_OPERAND_OBJECT     *ObjDesc,
    903           1.1  jruoho     UINT8                   **EndTag)
    904           1.1  jruoho {
    905           1.1  jruoho     ACPI_STATUS             Status;
    906           1.1  jruoho 
    907           1.1  jruoho 
    908           1.1  jruoho     ACPI_FUNCTION_TRACE (UtGetResourceEndTag);
    909           1.1  jruoho 
    910           1.1  jruoho 
    911           1.1  jruoho     /* Allow a buffer length of zero */
    912           1.1  jruoho 
    913           1.1  jruoho     if (!ObjDesc->Buffer.Length)
    914           1.1  jruoho     {
    915           1.1  jruoho         *EndTag = ObjDesc->Buffer.Pointer;
    916           1.1  jruoho         return_ACPI_STATUS (AE_OK);
    917           1.1  jruoho     }
    918           1.1  jruoho 
    919           1.1  jruoho     /* Validate the template and get a pointer to the EndTag */
    920           1.1  jruoho 
    921  1.1.1.2.10.1    yamt     Status = AcpiUtWalkAmlResources (NULL, ObjDesc->Buffer.Pointer,
    922  1.1.1.2.10.1    yamt                 ObjDesc->Buffer.Length, NULL, (void **) EndTag);
    923           1.1  jruoho 
    924           1.1  jruoho     return_ACPI_STATUS (Status);
    925           1.1  jruoho }
    926