ReactOS 0.4.15-dev-8119-g4fb2fdb
rsirq.c
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Module Name: rsirq - IRQ resource descriptors
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, 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 MERCHANTABILITY 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 ("rsirq")
50
51
52/*******************************************************************************
53 *
54 * AcpiRsGetIrq
55 *
56 ******************************************************************************/
57
59{
63
64 /* Get the IRQ mask (bytes 1:2) */
65
66 {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
67 AML_OFFSET (Irq.IrqMask),
68 ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
69
70 /* Set default flags (others are zero) */
71
72 {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering),
74 1},
75
76 /* Get the descriptor length (2 or 3 for IRQ descriptor) */
77
78 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength),
79 AML_OFFSET (Irq.DescriptorType),
80 0},
81
82 /* All done if no flag byte present in descriptor */
83
85
86 /* Get flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
87
88 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
89 AML_OFFSET (Irq.Flags),
90 0},
91
92 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
93 AML_OFFSET (Irq.Flags),
94 3},
95
96 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Shareable),
97 AML_OFFSET (Irq.Flags),
98 4},
99
100 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.WakeCapable),
101 AML_OFFSET (Irq.Flags),
102 5}
103};
104
105
106/*******************************************************************************
107 *
108 * AcpiRsSetIrq
109 *
110 ******************************************************************************/
111
113{
114 /* Start with a default descriptor of length 3 */
115
117 sizeof (AML_RESOURCE_IRQ),
119
120 /* Convert interrupt list to 16-bit IRQ bitmask */
121
122 {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]),
123 AML_OFFSET (Irq.IrqMask),
124 ACPI_RS_OFFSET (Data.Irq.InterruptCount)},
125
126 /* Set flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
127
128 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering),
129 AML_OFFSET (Irq.Flags),
130 0},
131
132 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity),
133 AML_OFFSET (Irq.Flags),
134 3},
135
136 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Shareable),
137 AML_OFFSET (Irq.Flags),
138 4},
139
140 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.WakeCapable),
141 AML_OFFSET (Irq.Flags),
142 5},
143
144 /*
145 * All done if the output descriptor length is required to be 3
146 * (i.e., optimization to 2 bytes cannot be attempted)
147 */
149 ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
150 3},
151
152 /* Set length to 2 bytes (no flags byte) */
153
155
156 /*
157 * All done if the output descriptor length is required to be 2.
158 *
159 * TBD: Perhaps we should check for error if input flags are not
160 * compatible with a 2-byte descriptor.
161 */
163 ACPI_RS_OFFSET(Data.Irq.DescriptorLength),
164 2},
165
166 /* Reset length to 3 bytes (descriptor with flags byte) */
167
168 {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)},
169
170 /*
171 * Check if the flags byte is necessary. Not needed if the flags are:
172 * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
173 */
175 ACPI_RS_OFFSET (Data.Irq.Triggering),
177
179 ACPI_RS_OFFSET (Data.Irq.Polarity),
181
183 ACPI_RS_OFFSET (Data.Irq.Shareable),
185
186 /* We can optimize to a 2-byte IrqNoFlags() descriptor */
187
189};
190
191
192/*******************************************************************************
193 *
194 * AcpiRsConvertExtIrq
195 *
196 ******************************************************************************/
197
199{
203
206 0},
207
208 /*
209 * Flags: Producer/Consumer[0], Triggering[1], Polarity[2],
210 * Sharing[3], Wake[4]
211 */
212 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer),
213 AML_OFFSET (ExtendedIrq.Flags),
214 0},
215
216 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering),
217 AML_OFFSET (ExtendedIrq.Flags),
218 1},
219
220 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity),
221 AML_OFFSET (ExtendedIrq.Flags),
222 2},
223
224 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Shareable),
225 AML_OFFSET (ExtendedIrq.Flags),
226 3},
227
228 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.WakeCapable),
229 AML_OFFSET (ExtendedIrq.Flags),
230 4},
231
232 /* IRQ Table length (Byte4) */
233
234 {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount),
235 AML_OFFSET (ExtendedIrq.InterruptCount),
236 sizeof (UINT32)},
237
238 /* Copy every IRQ in the table, each is 32 bits */
239
240 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
241 AML_OFFSET (ExtendedIrq.Interrupts[0]),
242 0},
243
244 /* Optional ResourceSource (Index and String) */
245
246 {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource),
247 ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]),
249};
250
251
252/*******************************************************************************
253 *
254 * AcpiRsConvertDma
255 *
256 ******************************************************************************/
257
259{
263
265 sizeof (AML_RESOURCE_DMA),
266 0},
267
268 /* Flags: transfer preference, bus mastering, channel speed */
269
270 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer),
271 AML_OFFSET (Dma.Flags),
272 0},
273
274 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster),
275 AML_OFFSET (Dma.Flags),
276 2},
277
279 AML_OFFSET (Dma.Flags),
280 5},
281
282 /* DMA channel mask bits */
283
284 {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]),
285 AML_OFFSET (Dma.DmaChannelMask),
286 ACPI_RS_OFFSET (Data.Dma.ChannelCount)}
287};
288
289
290/*******************************************************************************
291 *
292 * AcpiRsConvertFixedDma
293 *
294 ******************************************************************************/
295
297{
301
303 sizeof (AML_RESOURCE_FIXED_DMA),
304 0},
305
306 /*
307 * These fields are contiguous in both the source and destination:
308 * RequestLines
309 * Channels
310 */
311 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedDma.RequestLines),
312 AML_OFFSET (FixedDma.RequestLines),
313 2},
314
315 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedDma.Width),
316 AML_OFFSET (FixedDma.Width),
317 1},
318};
unsigned int UINT32
#define ACPI_RESOURCE_NAME_DMA
Definition: aclocal.h:1313
#define ACPI_RESOURCE_NAME_IRQ
Definition: aclocal.h:1312
#define ACPI_RESOURCE_NAME_EXTENDED_IRQ
Definition: aclocal.h:1337
#define ACPI_RESOURCE_NAME_FIXED_DMA
Definition: aclocal.h:1318
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_RSC_COMPARE_AML_LENGTH
Definition: acresrc.h:118
@ ACPI_RSC_INITSET
Definition: acresrc.h:81
@ ACPI_RSC_EXIT_NE
Definition: acresrc.h:100
@ ACPI_RSC_2BITFLAG
Definition: acresrc.h:84
@ ACPI_RSC_BITMASK16
Definition: acresrc.h:89
@ ACPI_RSC_LENGTH
Definition: acresrc.h:101
@ ACPI_RSC_MOVE8
Definition: acresrc.h:106
@ ACPI_RSC_SOURCEX
Definition: acresrc.h:112
@ ACPI_RSC_EXIT_EQ
Definition: acresrc.h:98
@ ACPI_RSC_COUNT
Definition: acresrc.h:90
@ ACPI_RSC_MOVE16
Definition: acresrc.h:107
@ ACPI_RSC_MOVE32
Definition: acresrc.h:108
@ ACPI_RSC_BITMASK
Definition: acresrc.h:88
@ ACPI_RSC_1BITFLAG
Definition: acresrc.h:83
@ ACPI_RSC_INITGET
Definition: acresrc.h:80
@ ACPI_RSC_SET8
Definition: acresrc.h:110
#define ACPI_RSC_TABLE_SIZE(d)
Definition: acresrc.h:121
#define ACPI_RS_OFFSET(f)
Definition: acresrc.h:123
#define ACPI_RSC_COMPARE_VALUE
Definition: acresrc.h:119
#define AML_OFFSET(f)
Definition: acresrc.h:124
#define ACPI_RESOURCE_TYPE_DMA
Definition: acrestyp.h:724
#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ
Definition: acrestyp.h:738
#define ACPI_ACTIVE_HIGH
Definition: acrestyp.h:98
#define ACPI_RESOURCE_TYPE_IRQ
Definition: acrestyp.h:723
#define ACPI_RESOURCE_TYPE_FIXED_DMA
Definition: acrestyp.h:741
#define ACPI_RS_SIZE(Type)
Definition: acrestyp.h:808
#define ACPI_EXCLUSIVE
Definition: acrestyp.h:104
#define ACPI_EDGE_SENSITIVE
Definition: acrestyp.h:94
struct aml_resource_extended_irq AML_RESOURCE_EXTENDED_IRQ
struct aml_resource_irq_noflags AML_RESOURCE_IRQ_NOFLAGS
struct aml_resource_dma AML_RESOURCE_DMA
struct aml_resource_fixed_dma AML_RESOURCE_FIXED_DMA
struct aml_resource_irq AML_RESOURCE_IRQ
ACPI_RSCONVERT_INFO AcpiRsGetIrq[9]
Definition: rsirq.c:58
ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[10]
Definition: rsirq.c:198
ACPI_RSCONVERT_INFO AcpiRsSetIrq[14]
Definition: rsirq.c:112
ACPI_RSCONVERT_INFO AcpiRsConvertDma[6]
Definition: rsirq.c:258
ACPI_RSCONVERT_INFO AcpiRsConvertFixedDma[4]
Definition: rsirq.c:296