1 /*******************************************************************************
   2  *
   3  * Module Name: rsinfo - Dispatch and Info tables
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.
  29  *
  30  * NO WARRANTY
  31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41  * POSSIBILITY OF SUCH DAMAGES.
  42  */
  43 
  44 #define __RSINFO_C__
  45 
  46 #include "acpi.h"
  47 #include "accommon.h"
  48 #include "acresrc.h"
  49 
  50 #define _COMPONENT          ACPI_RESOURCES
  51         ACPI_MODULE_NAME    ("rsinfo")
  52 
  53 /*
  54  * Resource dispatch and information tables. Any new resource types (either
  55  * Large or Small) must be reflected in each of these tables, so they are here
  56  * in one place.
  57  *
  58  * The tables for Large descriptors are indexed by bits 6:0 of the AML
  59  * descriptor type byte. The tables for Small descriptors are indexed by
  60  * bits 6:3 of the descriptor byte. The tables for internal resource
  61  * descriptors are indexed by the ACPI_RESOURCE_TYPE field.
  62  */
  63 
  64 
  65 /* Dispatch table for resource-to-AML (Set Resource) conversion functions */
  66 
  67 ACPI_RSCONVERT_INFO         *AcpiGbl_SetResourceDispatch[] =
  68 {
  69     AcpiRsSetIrq,                   /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
  70     AcpiRsConvertDma,               /* 0x01, ACPI_RESOURCE_TYPE_DMA */
  71     AcpiRsSetStartDpf,              /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
  72     AcpiRsConvertEndDpf,            /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
  73     AcpiRsConvertIo,                /* 0x04, ACPI_RESOURCE_TYPE_IO */
  74     AcpiRsConvertFixedIo,           /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
  75     AcpiRsSetVendor,                /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
  76     AcpiRsConvertEndTag,            /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
  77     AcpiRsConvertMemory24,          /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
  78     AcpiRsConvertMemory32,          /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
  79     AcpiRsConvertFixedMemory32,     /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
  80     AcpiRsConvertAddress16,         /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
  81     AcpiRsConvertAddress32,         /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
  82     AcpiRsConvertAddress64,         /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
  83     AcpiRsConvertExtAddress64,      /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
  84     AcpiRsConvertExtIrq,            /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
  85     AcpiRsConvertGenericReg,        /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
  86     AcpiRsConvertGpio,              /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
  87     AcpiRsConvertFixedDma,          /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
  88     NULL,                           /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
  89 };
  90 
  91 /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
  92 
  93 ACPI_RSCONVERT_INFO         *AcpiGbl_GetResourceDispatch[] =
  94 {
  95     /* Small descriptors */
  96 
  97     NULL,                           /* 0x00, Reserved */
  98     NULL,                           /* 0x01, Reserved */
  99     NULL,                           /* 0x02, Reserved */
 100     NULL,                           /* 0x03, Reserved */
 101     AcpiRsGetIrq,                   /* 0x04, ACPI_RESOURCE_NAME_IRQ */
 102     AcpiRsConvertDma,               /* 0x05, ACPI_RESOURCE_NAME_DMA */
 103     AcpiRsGetStartDpf,              /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
 104     AcpiRsConvertEndDpf,            /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
 105     AcpiRsConvertIo,                /* 0x08, ACPI_RESOURCE_NAME_IO */
 106     AcpiRsConvertFixedIo,           /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
 107     AcpiRsConvertFixedDma,          /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
 108     NULL,                           /* 0x0B, Reserved */
 109     NULL,                           /* 0x0C, Reserved */
 110     NULL,                           /* 0x0D, Reserved */
 111     AcpiRsGetVendorSmall,           /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
 112     AcpiRsConvertEndTag,            /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
 113 
 114     /* Large descriptors */
 115 
 116     NULL,                           /* 0x00, Reserved */
 117     AcpiRsConvertMemory24,          /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
 118     AcpiRsConvertGenericReg,        /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
 119     NULL,                           /* 0x03, Reserved */
 120     AcpiRsGetVendorLarge,           /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
 121     AcpiRsConvertMemory32,          /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
 122     AcpiRsConvertFixedMemory32,     /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
 123     AcpiRsConvertAddress32,         /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
 124     AcpiRsConvertAddress16,         /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
 125     AcpiRsConvertExtIrq,            /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
 126     AcpiRsConvertAddress64,         /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
 127     AcpiRsConvertExtAddress64,      /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
 128     AcpiRsConvertGpio,              /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
 129     NULL,                           /* 0x0D, Reserved */
 130     NULL,                           /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
 131 };
 132 
 133 /* Subtype table for SerialBus -- I2C, SPI, and UART */
 134 
 135 ACPI_RSCONVERT_INFO         *AcpiGbl_ConvertResourceSerialBusDispatch[] =
 136 {
 137     NULL,
 138     AcpiRsConvertI2cSerialBus,
 139     AcpiRsConvertSpiSerialBus,
 140     AcpiRsConvertUartSerialBus,
 141 };
 142 
 143 
 144 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
 145 
 146 /* Dispatch table for resource dump functions */
 147 
 148 ACPI_RSDUMP_INFO            *AcpiGbl_DumpResourceDispatch[] =
 149 {
 150     AcpiRsDumpIrq,                  /* ACPI_RESOURCE_TYPE_IRQ */
 151     AcpiRsDumpDma,                  /* ACPI_RESOURCE_TYPE_DMA */
 152     AcpiRsDumpStartDpf,             /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
 153     AcpiRsDumpEndDpf,               /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
 154     AcpiRsDumpIo,                   /* ACPI_RESOURCE_TYPE_IO */
 155     AcpiRsDumpFixedIo,              /* ACPI_RESOURCE_TYPE_FIXED_IO */
 156     AcpiRsDumpVendor,               /* ACPI_RESOURCE_TYPE_VENDOR */
 157     AcpiRsDumpEndTag,               /* ACPI_RESOURCE_TYPE_END_TAG */
 158     AcpiRsDumpMemory24,             /* ACPI_RESOURCE_TYPE_MEMORY24 */
 159     AcpiRsDumpMemory32,             /* ACPI_RESOURCE_TYPE_MEMORY32 */
 160     AcpiRsDumpFixedMemory32,        /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
 161     AcpiRsDumpAddress16,            /* ACPI_RESOURCE_TYPE_ADDRESS16 */
 162     AcpiRsDumpAddress32,            /* ACPI_RESOURCE_TYPE_ADDRESS32 */
 163     AcpiRsDumpAddress64,            /* ACPI_RESOURCE_TYPE_ADDRESS64 */
 164     AcpiRsDumpExtAddress64,         /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
 165     AcpiRsDumpExtIrq,               /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
 166     AcpiRsDumpGenericReg,           /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
 167     AcpiRsDumpGpio,                 /* ACPI_RESOURCE_TYPE_GPIO */
 168     AcpiRsDumpFixedDma,             /* ACPI_RESOURCE_TYPE_FIXED_DMA */
 169     NULL,                           /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
 170 };
 171 
 172 ACPI_RSDUMP_INFO            *AcpiGbl_DumpSerialBusDispatch[] =
 173 {
 174     NULL,
 175     AcpiRsDumpI2cSerialBus,         /* AML_RESOURCE_I2C_BUS_TYPE */
 176     AcpiRsDumpSpiSerialBus,         /* AML_RESOURCE_SPI_BUS_TYPE */
 177     AcpiRsDumpUartSerialBus,        /* AML_RESOURCE_UART_BUS_TYPE */
 178 };
 179 #endif
 180 
 181 
 182 /*
 183  * Base sizes for external AML resource descriptors, indexed by internal type.
 184  * Includes size of the descriptor header (1 byte for small descriptors,
 185  * 3 bytes for large descriptors)
 186  */
 187 const UINT8                 AcpiGbl_AmlResourceSizes[] =
 188 {
 189     sizeof (AML_RESOURCE_IRQ),              /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
 190     sizeof (AML_RESOURCE_DMA),              /* ACPI_RESOURCE_TYPE_DMA */
 191     sizeof (AML_RESOURCE_START_DEPENDENT),  /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
 192     sizeof (AML_RESOURCE_END_DEPENDENT),    /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
 193     sizeof (AML_RESOURCE_IO),               /* ACPI_RESOURCE_TYPE_IO */
 194     sizeof (AML_RESOURCE_FIXED_IO),         /* ACPI_RESOURCE_TYPE_FIXED_IO */
 195     sizeof (AML_RESOURCE_VENDOR_SMALL),     /* ACPI_RESOURCE_TYPE_VENDOR */
 196     sizeof (AML_RESOURCE_END_TAG),          /* ACPI_RESOURCE_TYPE_END_TAG */
 197     sizeof (AML_RESOURCE_MEMORY24),         /* ACPI_RESOURCE_TYPE_MEMORY24 */
 198     sizeof (AML_RESOURCE_MEMORY32),         /* ACPI_RESOURCE_TYPE_MEMORY32 */
 199     sizeof (AML_RESOURCE_FIXED_MEMORY32),   /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
 200     sizeof (AML_RESOURCE_ADDRESS16),        /* ACPI_RESOURCE_TYPE_ADDRESS16 */
 201     sizeof (AML_RESOURCE_ADDRESS32),        /* ACPI_RESOURCE_TYPE_ADDRESS32 */
 202     sizeof (AML_RESOURCE_ADDRESS64),        /* ACPI_RESOURCE_TYPE_ADDRESS64 */
 203     sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
 204     sizeof (AML_RESOURCE_EXTENDED_IRQ),     /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
 205     sizeof (AML_RESOURCE_GENERIC_REGISTER), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
 206     sizeof (AML_RESOURCE_GPIO),             /* ACPI_RESOURCE_TYPE_GPIO */
 207     sizeof (AML_RESOURCE_FIXED_DMA),        /* ACPI_RESOURCE_TYPE_FIXED_DMA */
 208     sizeof (AML_RESOURCE_COMMON_SERIALBUS), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
 209 };
 210 
 211 
 212 const UINT8                 AcpiGbl_ResourceStructSizes[] =
 213 {
 214     /* Small descriptors */
 215 
 216     0,
 217     0,
 218     0,
 219     0,
 220     ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
 221     ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
 222     ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
 223     ACPI_RS_SIZE_MIN,
 224     ACPI_RS_SIZE (ACPI_RESOURCE_IO),
 225     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
 226     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
 227     0,
 228     0,
 229     0,
 230     ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
 231     ACPI_RS_SIZE_MIN,
 232 
 233     /* Large descriptors */
 234 
 235     0,
 236     ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
 237     ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
 238     0,
 239     ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
 240     ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
 241     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
 242     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
 243     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
 244     ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
 245     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
 246     ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
 247     ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
 248     ACPI_RS_SIZE (ACPI_RESOURCE_COMMON_SERIALBUS)
 249 };
 250 
 251 const UINT8                 AcpiGbl_AmlResourceSerialBusSizes[] =
 252 {
 253     0,
 254     sizeof (AML_RESOURCE_I2C_SERIALBUS),
 255     sizeof (AML_RESOURCE_SPI_SERIALBUS),
 256     sizeof (AML_RESOURCE_UART_SERIALBUS),
 257 };
 258 
 259 const UINT8                 AcpiGbl_ResourceStructSerialBusSizes[] =
 260 {
 261     0,
 262     ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
 263     ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
 264     ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
 265 };