1683bf072a52e5653fee7ef5e2718e99371d6006
[dragonfly.git] / sys / contrib / dev / acpica / source / components / disassembler / dmresrcs.c
1 /*******************************************************************************
2  *
3  * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2015, 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 "acdisasm.h"
47
48
49 #ifdef ACPI_DISASSEMBLER
50
51 #define _COMPONENT          ACPI_CA_DEBUGGER
52         ACPI_MODULE_NAME    ("dbresrcs")
53
54
55 /*******************************************************************************
56  *
57  * FUNCTION:    AcpiDmIrqDescriptor
58  *
59  * PARAMETERS:  Info                - Extra resource info
60  *              Resource            - Pointer to the resource descriptor
61  *              Length              - Length of the descriptor in bytes
62  *              Level               - Current source code indentation level
63  *
64  * RETURN:      None
65  *
66  * DESCRIPTION: Decode a IRQ descriptor, either Irq() or IrqNoFlags()
67  *
68  ******************************************************************************/
69
70 void
71 AcpiDmIrqDescriptor (
72     ACPI_OP_WALK_INFO       *Info,
73     AML_RESOURCE            *Resource,
74     UINT32                  Length,
75     UINT32                  Level)
76 {
77
78     AcpiDmIndent (Level);
79     AcpiOsPrintf ("%s (",
80         AcpiGbl_IrqDecode [ACPI_GET_1BIT_FLAG (Length)]);
81
82     /* Decode flags byte if present */
83
84     if (Length & 1)
85     {
86         AcpiOsPrintf ("%s, %s, %s, ",
87             AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Irq.Flags)],
88             AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->Irq.Flags, 3)],
89             AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Irq.Flags, 4)]);
90     }
91
92     /* Insert a descriptor name */
93
94     AcpiDmDescriptorName ();
95     AcpiOsPrintf (")\n");
96
97     AcpiDmIndent (Level + 1);
98     AcpiDmBitList (Resource->Irq.IrqMask);
99 }
100
101
102 /*******************************************************************************
103  *
104  * FUNCTION:    AcpiDmDmaDescriptor
105  *
106  * PARAMETERS:  Info                - Extra resource info
107  *              Resource            - Pointer to the resource descriptor
108  *              Length              - Length of the descriptor in bytes
109  *              Level               - Current source code indentation level
110  *
111  * RETURN:      None
112  *
113  * DESCRIPTION: Decode a DMA descriptor
114  *
115  ******************************************************************************/
116
117 void
118 AcpiDmDmaDescriptor (
119     ACPI_OP_WALK_INFO       *Info,
120     AML_RESOURCE            *Resource,
121     UINT32                  Length,
122     UINT32                  Level)
123 {
124
125     AcpiDmIndent (Level);
126     AcpiOsPrintf ("DMA (%s, %s, %s, ",
127         AcpiGbl_TypDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Dma.Flags, 5)],
128         AcpiGbl_BmDecode  [ACPI_EXTRACT_1BIT_FLAG (Resource->Dma.Flags, 2)],
129         AcpiGbl_SizDecode [ACPI_GET_2BIT_FLAG (Resource->Dma.Flags)]);
130
131     /* Insert a descriptor name */
132
133     AcpiDmDescriptorName ();
134     AcpiOsPrintf (")\n");
135
136     AcpiDmIndent (Level + 1);
137     AcpiDmBitList (Resource->Dma.DmaChannelMask);
138 }
139
140
141 /*******************************************************************************
142  *
143  * FUNCTION:    AcpiDmFixedDmaDescriptor
144  *
145  * PARAMETERS:  Info                - Extra resource info
146  *              Resource            - Pointer to the resource descriptor
147  *              Length              - Length of the descriptor in bytes
148  *              Level               - Current source code indentation level
149  *
150  * RETURN:      None
151  *
152  * DESCRIPTION: Decode a FixedDMA descriptor
153  *
154  ******************************************************************************/
155
156 void
157 AcpiDmFixedDmaDescriptor (
158     ACPI_OP_WALK_INFO       *Info,
159     AML_RESOURCE            *Resource,
160     UINT32                  Length,
161     UINT32                  Level)
162 {
163
164     AcpiDmIndent (Level);
165     AcpiOsPrintf ("FixedDMA (0x%4.4X, 0x%4.4X, ",
166         Resource->FixedDma.RequestLines,
167         Resource->FixedDma.Channels);
168
169     if (Resource->FixedDma.Width <= 5)
170     {
171         AcpiOsPrintf ("%s, ",
172             AcpiGbl_DtsDecode [Resource->FixedDma.Width]);
173     }
174     else
175     {
176         AcpiOsPrintf ("%X /* INVALID DMA WIDTH */, ",
177             Resource->FixedDma.Width);
178     }
179
180     /* Insert a descriptor name */
181
182     AcpiDmDescriptorName ();
183     AcpiOsPrintf (")\n");
184 }
185
186
187 /*******************************************************************************
188  *
189  * FUNCTION:    AcpiDmIoDescriptor
190  *
191  * PARAMETERS:  Info                - Extra resource info
192  *              Resource            - Pointer to the resource descriptor
193  *              Length              - Length of the descriptor in bytes
194  *              Level               - Current source code indentation level
195  *
196  * RETURN:      None
197  *
198  * DESCRIPTION: Decode an IO descriptor
199  *
200  ******************************************************************************/
201
202 void
203 AcpiDmIoDescriptor (
204     ACPI_OP_WALK_INFO       *Info,
205     AML_RESOURCE            *Resource,
206     UINT32                  Length,
207     UINT32                  Level)
208 {
209
210     AcpiDmIndent (Level);
211     AcpiOsPrintf ("IO (%s,\n",
212         AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
213
214     AcpiDmIndent (Level + 1);
215     AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
216
217     AcpiDmIndent (Level + 1);
218     AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
219
220     AcpiDmIndent (Level + 1);
221     AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
222
223     AcpiDmIndent (Level + 1);
224     AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Length");
225
226     /* Insert a descriptor name */
227
228     AcpiDmIndent (Level + 1);
229     AcpiDmDescriptorName ();
230     AcpiOsPrintf (")\n");
231 }
232
233
234 /*******************************************************************************
235  *
236  * FUNCTION:    AcpiDmFixedIoDescriptor
237  *
238  * PARAMETERS:  Info                - Extra resource info
239  *              Resource            - Pointer to the resource descriptor
240  *              Length              - Length of the descriptor in bytes
241  *              Level               - Current source code indentation level
242  *
243  * RETURN:      None
244  *
245  * DESCRIPTION: Decode a Fixed IO descriptor
246  *
247  ******************************************************************************/
248
249 void
250 AcpiDmFixedIoDescriptor (
251     ACPI_OP_WALK_INFO       *Info,
252     AML_RESOURCE            *Resource,
253     UINT32                  Length,
254     UINT32                  Level)
255 {
256
257     AcpiDmIndent (Level);
258     AcpiOsPrintf ("FixedIO (\n");
259
260     AcpiDmIndent (Level + 1);
261     AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
262
263     AcpiDmIndent (Level + 1);
264     AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
265
266     /* Insert a descriptor name */
267
268     AcpiDmIndent (Level + 1);
269     AcpiDmDescriptorName ();
270     AcpiOsPrintf (")\n");
271 }
272
273
274 /*******************************************************************************
275  *
276  * FUNCTION:    AcpiDmStartDependentDescriptor
277  *
278  * PARAMETERS:  Info                - Extra resource info
279  *              Resource            - Pointer to the resource descriptor
280  *              Length              - Length of the descriptor in bytes
281  *              Level               - Current source code indentation level
282  *
283  * RETURN:      None
284  *
285  * DESCRIPTION: Decode a Start Dependendent functions descriptor
286  *
287  ******************************************************************************/
288
289 void
290 AcpiDmStartDependentDescriptor (
291     ACPI_OP_WALK_INFO       *Info,
292     AML_RESOURCE            *Resource,
293     UINT32                  Length,
294     UINT32                  Level)
295 {
296
297     AcpiDmIndent (Level);
298
299     if (Length & 1)
300     {
301         AcpiOsPrintf ("StartDependentFn (0x%2.2X, 0x%2.2X)\n",
302             (UINT32) ACPI_GET_2BIT_FLAG (Resource->StartDpf.Flags),
303             (UINT32) ACPI_EXTRACT_2BIT_FLAG (Resource->StartDpf.Flags, 2));
304     }
305     else
306     {
307         AcpiOsPrintf ("StartDependentFnNoPri ()\n");
308     }
309
310     AcpiDmIndent (Level);
311     AcpiOsPrintf ("{\n");
312 }
313
314
315 /*******************************************************************************
316  *
317  * FUNCTION:    AcpiDmEndDependentDescriptor
318  *
319  * PARAMETERS:  Info                - Extra resource info
320  *              Resource            - Pointer to the resource descriptor
321  *              Length              - Length of the descriptor in bytes
322  *              Level               - Current source code indentation level
323  *
324  * RETURN:      None
325  *
326  * DESCRIPTION: Decode an End Dependent functions descriptor
327  *
328  ******************************************************************************/
329
330 void
331 AcpiDmEndDependentDescriptor (
332     ACPI_OP_WALK_INFO       *Info,
333     AML_RESOURCE            *Resource,
334     UINT32                  Length,
335     UINT32                  Level)
336 {
337
338     AcpiDmIndent (Level);
339     AcpiOsPrintf ("}\n");
340     AcpiDmIndent (Level);
341     AcpiOsPrintf ("EndDependentFn ()\n");
342 }
343
344
345 /*******************************************************************************
346  *
347  * FUNCTION:    AcpiDmVendorSmallDescriptor
348  *
349  * PARAMETERS:  Info                - Extra resource info
350  *              Resource            - Pointer to the resource descriptor
351  *              Length              - Length of the descriptor in bytes
352  *              Level               - Current source code indentation level
353  *
354  * RETURN:      None
355  *
356  * DESCRIPTION: Decode a Vendor Small Descriptor
357  *
358  ******************************************************************************/
359
360 void
361 AcpiDmVendorSmallDescriptor (
362     ACPI_OP_WALK_INFO       *Info,
363     AML_RESOURCE            *Resource,
364     UINT32                  Length,
365     UINT32                  Level)
366 {
367
368     AcpiDmVendorCommon ("Short",
369         ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_SMALL_HEADER)),
370         Length, Level);
371 }
372
373 #endif