xref: /freebsd/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
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 <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/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 */, ", Resource->FixedDma.Width);
177     }
178 
179     /* Insert a descriptor name */
180 
181     AcpiDmDescriptorName ();
182     AcpiOsPrintf (")\n");
183 }
184 
185 
186 /*******************************************************************************
187  *
188  * FUNCTION:    AcpiDmIoDescriptor
189  *
190  * PARAMETERS:  Info                - Extra resource info
191  *              Resource            - Pointer to the resource descriptor
192  *              Length              - Length of the descriptor in bytes
193  *              Level               - Current source code indentation level
194  *
195  * RETURN:      None
196  *
197  * DESCRIPTION: Decode an IO descriptor
198  *
199  ******************************************************************************/
200 
201 void
202 AcpiDmIoDescriptor (
203     ACPI_OP_WALK_INFO       *Info,
204     AML_RESOURCE            *Resource,
205     UINT32                  Length,
206     UINT32                  Level)
207 {
208 
209     AcpiDmIndent (Level);
210     AcpiOsPrintf ("IO (%s,\n",
211         AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
212 
213     AcpiDmIndent (Level + 1);
214     AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
215 
216     AcpiDmIndent (Level + 1);
217     AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
218 
219     AcpiDmIndent (Level + 1);
220     AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
221 
222     AcpiDmIndent (Level + 1);
223     AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Length");
224 
225     /* Insert a descriptor name */
226 
227     AcpiDmIndent (Level + 1);
228     AcpiDmDescriptorName ();
229     AcpiOsPrintf (")\n");
230 }
231 
232 
233 /*******************************************************************************
234  *
235  * FUNCTION:    AcpiDmFixedIoDescriptor
236  *
237  * PARAMETERS:  Info                - Extra resource info
238  *              Resource            - Pointer to the resource descriptor
239  *              Length              - Length of the descriptor in bytes
240  *              Level               - Current source code indentation level
241  *
242  * RETURN:      None
243  *
244  * DESCRIPTION: Decode a Fixed IO descriptor
245  *
246  ******************************************************************************/
247 
248 void
249 AcpiDmFixedIoDescriptor (
250     ACPI_OP_WALK_INFO       *Info,
251     AML_RESOURCE            *Resource,
252     UINT32                  Length,
253     UINT32                  Level)
254 {
255 
256     AcpiDmIndent (Level);
257     AcpiOsPrintf ("FixedIO (\n");
258 
259     AcpiDmIndent (Level + 1);
260     AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
261 
262     AcpiDmIndent (Level + 1);
263     AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
264 
265     /* Insert a descriptor name */
266 
267     AcpiDmIndent (Level + 1);
268     AcpiDmDescriptorName ();
269     AcpiOsPrintf (")\n");
270 }
271 
272 
273 /*******************************************************************************
274  *
275  * FUNCTION:    AcpiDmStartDependentDescriptor
276  *
277  * PARAMETERS:  Info                - Extra resource info
278  *              Resource            - Pointer to the resource descriptor
279  *              Length              - Length of the descriptor in bytes
280  *              Level               - Current source code indentation level
281  *
282  * RETURN:      None
283  *
284  * DESCRIPTION: Decode a Start Dependendent functions descriptor
285  *
286  ******************************************************************************/
287 
288 void
289 AcpiDmStartDependentDescriptor (
290     ACPI_OP_WALK_INFO       *Info,
291     AML_RESOURCE            *Resource,
292     UINT32                  Length,
293     UINT32                  Level)
294 {
295 
296     AcpiDmIndent (Level);
297 
298     if (Length & 1)
299     {
300         AcpiOsPrintf ("StartDependentFn (0x%2.2X, 0x%2.2X)\n",
301             (UINT32) ACPI_GET_2BIT_FLAG (Resource->StartDpf.Flags),
302             (UINT32) ACPI_EXTRACT_2BIT_FLAG (Resource->StartDpf.Flags, 2));
303     }
304     else
305     {
306         AcpiOsPrintf ("StartDependentFnNoPri ()\n");
307     }
308 
309     AcpiDmIndent (Level);
310     AcpiOsPrintf ("{\n");
311 }
312 
313 
314 /*******************************************************************************
315  *
316  * FUNCTION:    AcpiDmEndDependentDescriptor
317  *
318  * PARAMETERS:  Info                - Extra resource info
319  *              Resource            - Pointer to the resource descriptor
320  *              Length              - Length of the descriptor in bytes
321  *              Level               - Current source code indentation level
322  *
323  * RETURN:      None
324  *
325  * DESCRIPTION: Decode an End Dependent functions descriptor
326  *
327  ******************************************************************************/
328 
329 void
330 AcpiDmEndDependentDescriptor (
331     ACPI_OP_WALK_INFO       *Info,
332     AML_RESOURCE            *Resource,
333     UINT32                  Length,
334     UINT32                  Level)
335 {
336 
337     AcpiDmIndent (Level);
338     AcpiOsPrintf ("}\n");
339     AcpiDmIndent (Level);
340     AcpiOsPrintf ("EndDependentFn ()\n");
341 }
342 
343 
344 /*******************************************************************************
345  *
346  * FUNCTION:    AcpiDmVendorSmallDescriptor
347  *
348  * PARAMETERS:  Info                - Extra resource info
349  *              Resource            - Pointer to the resource descriptor
350  *              Length              - Length of the descriptor in bytes
351  *              Level               - Current source code indentation level
352  *
353  * RETURN:      None
354  *
355  * DESCRIPTION: Decode a Vendor Small Descriptor
356  *
357  ******************************************************************************/
358 
359 void
360 AcpiDmVendorSmallDescriptor (
361     ACPI_OP_WALK_INFO       *Info,
362     AML_RESOURCE            *Resource,
363     UINT32                  Length,
364     UINT32                  Level)
365 {
366 
367     AcpiDmVendorCommon ("Short",
368         ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_SMALL_HEADER)),
369         Length, Level);
370 }
371 
372 #endif
373