xref: /titanic_50/usr/src/uts/intel/io/acpica/resources/rsinfo.c (revision 385cc6b4ad1792caef3f84eb61eed3f27085801f)
1 /*******************************************************************************
2  *
3  * Module Name: rsinfo - Dispatch and Info tables
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, 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 #include "acpi.h"
45 #include "accommon.h"
46 #include "acresrc.h"
47 
48 #define _COMPONENT          ACPI_RESOURCES
49         ACPI_MODULE_NAME    ("rsinfo")
50 
51 /*
52  * Resource dispatch and information tables. Any new resource types (either
53  * Large or Small) must be reflected in each of these tables, so they are here
54  * in one place.
55  *
56  * The tables for Large descriptors are indexed by bits 6:0 of the AML
57  * descriptor type byte. The tables for Small descriptors are indexed by
58  * bits 6:3 of the descriptor byte. The tables for internal resource
59  * descriptors are indexed by the ACPI_RESOURCE_TYPE field.
60  */
61 
62 
63 /* Dispatch table for resource-to-AML (Set Resource) conversion functions */
64 
65 ACPI_RSCONVERT_INFO         *AcpiGbl_SetResourceDispatch[] =
66 {
67     AcpiRsSetIrq,                   /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
68     AcpiRsConvertDma,               /* 0x01, ACPI_RESOURCE_TYPE_DMA */
69     AcpiRsSetStartDpf,              /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
70     AcpiRsConvertEndDpf,            /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
71     AcpiRsConvertIo,                /* 0x04, ACPI_RESOURCE_TYPE_IO */
72     AcpiRsConvertFixedIo,           /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
73     AcpiRsSetVendor,                /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
74     AcpiRsConvertEndTag,            /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
75     AcpiRsConvertMemory24,          /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
76     AcpiRsConvertMemory32,          /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
77     AcpiRsConvertFixedMemory32,     /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
78     AcpiRsConvertAddress16,         /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
79     AcpiRsConvertAddress32,         /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
80     AcpiRsConvertAddress64,         /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
81     AcpiRsConvertExtAddress64,      /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
82     AcpiRsConvertExtIrq,            /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
83     AcpiRsConvertGenericReg,        /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
84     AcpiRsConvertGpio,              /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
85     AcpiRsConvertFixedDma,          /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
86     NULL,                           /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
87 };
88 
89 /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
90 
91 ACPI_RSCONVERT_INFO         *AcpiGbl_GetResourceDispatch[] =
92 {
93     /* Small descriptors */
94 
95     NULL,                           /* 0x00, Reserved */
96     NULL,                           /* 0x01, Reserved */
97     NULL,                           /* 0x02, Reserved */
98     NULL,                           /* 0x03, Reserved */
99     AcpiRsGetIrq,                   /* 0x04, ACPI_RESOURCE_NAME_IRQ */
100     AcpiRsConvertDma,               /* 0x05, ACPI_RESOURCE_NAME_DMA */
101     AcpiRsGetStartDpf,              /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
102     AcpiRsConvertEndDpf,            /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
103     AcpiRsConvertIo,                /* 0x08, ACPI_RESOURCE_NAME_IO */
104     AcpiRsConvertFixedIo,           /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
105     AcpiRsConvertFixedDma,          /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
106     NULL,                           /* 0x0B, Reserved */
107     NULL,                           /* 0x0C, Reserved */
108     NULL,                           /* 0x0D, Reserved */
109     AcpiRsGetVendorSmall,           /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
110     AcpiRsConvertEndTag,            /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
111 
112     /* Large descriptors */
113 
114     NULL,                           /* 0x00, Reserved */
115     AcpiRsConvertMemory24,          /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
116     AcpiRsConvertGenericReg,        /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
117     NULL,                           /* 0x03, Reserved */
118     AcpiRsGetVendorLarge,           /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
119     AcpiRsConvertMemory32,          /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
120     AcpiRsConvertFixedMemory32,     /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
121     AcpiRsConvertAddress32,         /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
122     AcpiRsConvertAddress16,         /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
123     AcpiRsConvertExtIrq,            /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
124     AcpiRsConvertAddress64,         /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
125     AcpiRsConvertExtAddress64,      /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
126     AcpiRsConvertGpio,              /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
127     NULL,                           /* 0x0D, Reserved */
128     NULL,                           /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
129 };
130 
131 /* Subtype table for SerialBus -- I2C, SPI, and UART */
132 
133 ACPI_RSCONVERT_INFO         *AcpiGbl_ConvertResourceSerialBusDispatch[] =
134 {
135     NULL,
136     AcpiRsConvertI2cSerialBus,
137     AcpiRsConvertSpiSerialBus,
138     AcpiRsConvertUartSerialBus,
139 };
140 
141 
142 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
143 
144 /* Dispatch table for resource dump functions */
145 
146 ACPI_RSDUMP_INFO            *AcpiGbl_DumpResourceDispatch[] =
147 {
148     AcpiRsDumpIrq,                  /* ACPI_RESOURCE_TYPE_IRQ */
149     AcpiRsDumpDma,                  /* ACPI_RESOURCE_TYPE_DMA */
150     AcpiRsDumpStartDpf,             /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
151     AcpiRsDumpEndDpf,               /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
152     AcpiRsDumpIo,                   /* ACPI_RESOURCE_TYPE_IO */
153     AcpiRsDumpFixedIo,              /* ACPI_RESOURCE_TYPE_FIXED_IO */
154     AcpiRsDumpVendor,               /* ACPI_RESOURCE_TYPE_VENDOR */
155     AcpiRsDumpEndTag,               /* ACPI_RESOURCE_TYPE_END_TAG */
156     AcpiRsDumpMemory24,             /* ACPI_RESOURCE_TYPE_MEMORY24 */
157     AcpiRsDumpMemory32,             /* ACPI_RESOURCE_TYPE_MEMORY32 */
158     AcpiRsDumpFixedMemory32,        /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
159     AcpiRsDumpAddress16,            /* ACPI_RESOURCE_TYPE_ADDRESS16 */
160     AcpiRsDumpAddress32,            /* ACPI_RESOURCE_TYPE_ADDRESS32 */
161     AcpiRsDumpAddress64,            /* ACPI_RESOURCE_TYPE_ADDRESS64 */
162     AcpiRsDumpExtAddress64,         /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
163     AcpiRsDumpExtIrq,               /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
164     AcpiRsDumpGenericReg,           /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
165     AcpiRsDumpGpio,                 /* ACPI_RESOURCE_TYPE_GPIO */
166     AcpiRsDumpFixedDma,             /* ACPI_RESOURCE_TYPE_FIXED_DMA */
167     NULL,                           /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
168 };
169 
170 ACPI_RSDUMP_INFO            *AcpiGbl_DumpSerialBusDispatch[] =
171 {
172     NULL,
173     AcpiRsDumpI2cSerialBus,         /* AML_RESOURCE_I2C_BUS_TYPE */
174     AcpiRsDumpSpiSerialBus,         /* AML_RESOURCE_SPI_BUS_TYPE */
175     AcpiRsDumpUartSerialBus,        /* AML_RESOURCE_UART_BUS_TYPE */
176 };
177 #endif
178 
179 
180 /*
181  * Base sizes for external AML resource descriptors, indexed by internal type.
182  * Includes size of the descriptor header (1 byte for small descriptors,
183  * 3 bytes for large descriptors)
184  */
185 const UINT8                 AcpiGbl_AmlResourceSizes[] =
186 {
187     sizeof (AML_RESOURCE_IRQ),              /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
188     sizeof (AML_RESOURCE_DMA),              /* ACPI_RESOURCE_TYPE_DMA */
189     sizeof (AML_RESOURCE_START_DEPENDENT),  /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
190     sizeof (AML_RESOURCE_END_DEPENDENT),    /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
191     sizeof (AML_RESOURCE_IO),               /* ACPI_RESOURCE_TYPE_IO */
192     sizeof (AML_RESOURCE_FIXED_IO),         /* ACPI_RESOURCE_TYPE_FIXED_IO */
193     sizeof (AML_RESOURCE_VENDOR_SMALL),     /* ACPI_RESOURCE_TYPE_VENDOR */
194     sizeof (AML_RESOURCE_END_TAG),          /* ACPI_RESOURCE_TYPE_END_TAG */
195     sizeof (AML_RESOURCE_MEMORY24),         /* ACPI_RESOURCE_TYPE_MEMORY24 */
196     sizeof (AML_RESOURCE_MEMORY32),         /* ACPI_RESOURCE_TYPE_MEMORY32 */
197     sizeof (AML_RESOURCE_FIXED_MEMORY32),   /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
198     sizeof (AML_RESOURCE_ADDRESS16),        /* ACPI_RESOURCE_TYPE_ADDRESS16 */
199     sizeof (AML_RESOURCE_ADDRESS32),        /* ACPI_RESOURCE_TYPE_ADDRESS32 */
200     sizeof (AML_RESOURCE_ADDRESS64),        /* ACPI_RESOURCE_TYPE_ADDRESS64 */
201     sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
202     sizeof (AML_RESOURCE_EXTENDED_IRQ),     /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
203     sizeof (AML_RESOURCE_GENERIC_REGISTER), /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
204     sizeof (AML_RESOURCE_GPIO),             /* ACPI_RESOURCE_TYPE_GPIO */
205     sizeof (AML_RESOURCE_FIXED_DMA),        /* ACPI_RESOURCE_TYPE_FIXED_DMA */
206     sizeof (AML_RESOURCE_COMMON_SERIALBUS), /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
207 };
208 
209 
210 const UINT8                 AcpiGbl_ResourceStructSizes[] =
211 {
212     /* Small descriptors */
213 
214     0,
215     0,
216     0,
217     0,
218     ACPI_RS_SIZE (ACPI_RESOURCE_IRQ),
219     ACPI_RS_SIZE (ACPI_RESOURCE_DMA),
220     ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT),
221     ACPI_RS_SIZE_MIN,
222     ACPI_RS_SIZE (ACPI_RESOURCE_IO),
223     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO),
224     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_DMA),
225     0,
226     0,
227     0,
228     ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
229     ACPI_RS_SIZE_MIN,
230 
231     /* Large descriptors */
232 
233     0,
234     ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24),
235     ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER),
236     0,
237     ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR),
238     ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32),
239     ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32),
240     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32),
241     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16),
242     ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ),
243     ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64),
244     ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64),
245     ACPI_RS_SIZE (ACPI_RESOURCE_GPIO),
246     ACPI_RS_SIZE (ACPI_RESOURCE_COMMON_SERIALBUS)
247 };
248 
249 const UINT8                 AcpiGbl_AmlResourceSerialBusSizes[] =
250 {
251     0,
252     sizeof (AML_RESOURCE_I2C_SERIALBUS),
253     sizeof (AML_RESOURCE_SPI_SERIALBUS),
254     sizeof (AML_RESOURCE_UART_SERIALBUS),
255 };
256 
257 const UINT8                 AcpiGbl_ResourceStructSerialBusSizes[] =
258 {
259     0,
260     ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS),
261     ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS),
262     ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS),
263 };
264