xref: /illumos-gate/usr/src/uts/intel/sys/acpi/acresrc.h (revision e8d80663e4f91871f843bb8ad9108dc0b76dfcf3)
1 /******************************************************************************
2  *
3  * Name: acresrc.h - Resource Manager function prototypes
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, 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 #ifndef __ACRESRC_H__
45 #define __ACRESRC_H__
46 
47 /* Need the AML resource descriptor structs */
48 
49 #include "amlresrc.h"
50 
51 
52 /*
53  * If possible, pack the following structures to byte alignment, since we
54  * don't care about performance for debug output. Two cases where we cannot
55  * pack the structures:
56  *
57  * 1) Hardware does not support misaligned memory transfers
58  * 2) Compiler does not support pointers within packed structures
59  */
60 #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
61 #pragma pack(1)
62 #endif
63 
64 /*
65  * Individual entry for the resource conversion tables
66  */
67 typedef const struct acpi_rsconvert_info
68 {
69     UINT8                   Opcode;
70     UINT8                   ResourceOffset;
71     UINT8                   AmlOffset;
72     UINT8                   Value;
73 
74 } ACPI_RSCONVERT_INFO;
75 
76 /* Resource conversion opcodes */
77 
78 #define ACPI_RSC_INITGET                0
79 #define ACPI_RSC_INITSET                1
80 #define ACPI_RSC_FLAGINIT               2
81 #define ACPI_RSC_1BITFLAG               3
82 #define ACPI_RSC_2BITFLAG               4
83 #define ACPI_RSC_COUNT                  5
84 #define ACPI_RSC_COUNT16                6
85 #define ACPI_RSC_LENGTH                 7
86 #define ACPI_RSC_MOVE8                  8
87 #define ACPI_RSC_MOVE16                 9
88 #define ACPI_RSC_MOVE32                 10
89 #define ACPI_RSC_MOVE64                 11
90 #define ACPI_RSC_SET8                   12
91 #define ACPI_RSC_DATA8                  13
92 #define ACPI_RSC_ADDRESS                14
93 #define ACPI_RSC_SOURCE                 15
94 #define ACPI_RSC_SOURCEX                16
95 #define ACPI_RSC_BITMASK                17
96 #define ACPI_RSC_BITMASK16              18
97 #define ACPI_RSC_EXIT_NE                19
98 #define ACPI_RSC_EXIT_LE                20
99 #define ACPI_RSC_EXIT_EQ                21
100 
101 /* Resource Conversion sub-opcodes */
102 
103 #define ACPI_RSC_COMPARE_AML_LENGTH     0
104 #define ACPI_RSC_COMPARE_VALUE          1
105 
106 #define ACPI_RSC_TABLE_SIZE(d)          (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO))
107 
108 #define ACPI_RS_OFFSET(f)               (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f)
109 #define AML_OFFSET(f)                   (UINT8) ACPI_OFFSET (AML_RESOURCE,f)
110 
111 
112 typedef const struct acpi_rsdump_info
113 {
114     UINT8                   Opcode;
115     UINT8                   Offset;
116     char                    *Name;
117     const char              **Pointer;
118 
119 } ACPI_RSDUMP_INFO;
120 
121 /* Values for the Opcode field above */
122 
123 #define ACPI_RSD_TITLE                  0
124 #define ACPI_RSD_LITERAL                1
125 #define ACPI_RSD_STRING                 2
126 #define ACPI_RSD_UINT8                  3
127 #define ACPI_RSD_UINT16                 4
128 #define ACPI_RSD_UINT32                 5
129 #define ACPI_RSD_UINT64                 6
130 #define ACPI_RSD_1BITFLAG               7
131 #define ACPI_RSD_2BITFLAG               8
132 #define ACPI_RSD_SHORTLIST              9
133 #define ACPI_RSD_LONGLIST               10
134 #define ACPI_RSD_DWORDLIST              11
135 #define ACPI_RSD_ADDRESS                12
136 #define ACPI_RSD_SOURCE                 13
137 
138 /* restore default alignment */
139 
140 #pragma pack()
141 
142 
143 /* Resource tables indexed by internal resource type */
144 
145 extern const UINT8              AcpiGbl_AmlResourceSizes[];
146 extern ACPI_RSCONVERT_INFO      *AcpiGbl_SetResourceDispatch[];
147 
148 /* Resource tables indexed by raw AML resource descriptor type */
149 
150 extern const UINT8              AcpiGbl_ResourceStructSizes[];
151 extern ACPI_RSCONVERT_INFO      *AcpiGbl_GetResourceDispatch[];
152 
153 
154 typedef struct acpi_vendor_walk_info
155 {
156     ACPI_VENDOR_UUID        *Uuid;
157     ACPI_BUFFER             *Buffer;
158     ACPI_STATUS             Status;
159 
160 } ACPI_VENDOR_WALK_INFO;
161 
162 
163 /*
164  * rscreate
165  */
166 ACPI_STATUS
167 AcpiRsCreateResourceList (
168     ACPI_OPERAND_OBJECT     *AmlBuffer,
169     ACPI_BUFFER             *OutputBuffer);
170 
171 ACPI_STATUS
172 AcpiRsCreateAmlResources (
173     ACPI_RESOURCE           *LinkedListBuffer,
174     ACPI_BUFFER             *OutputBuffer);
175 
176 ACPI_STATUS
177 AcpiRsCreatePciRoutingTable (
178     ACPI_OPERAND_OBJECT     *PackageObject,
179     ACPI_BUFFER             *OutputBuffer);
180 
181 
182 /*
183  * rsutils
184  */
185 ACPI_STATUS
186 AcpiRsGetPrtMethodData (
187     ACPI_NAMESPACE_NODE     *Node,
188     ACPI_BUFFER             *RetBuffer);
189 
190 ACPI_STATUS
191 AcpiRsGetCrsMethodData (
192     ACPI_NAMESPACE_NODE     *Node,
193     ACPI_BUFFER             *RetBuffer);
194 
195 ACPI_STATUS
196 AcpiRsGetPrsMethodData (
197     ACPI_NAMESPACE_NODE     *Node,
198     ACPI_BUFFER             *RetBuffer);
199 
200 ACPI_STATUS
201 AcpiRsGetMethodData (
202     ACPI_HANDLE             Handle,
203     char                    *Path,
204     ACPI_BUFFER             *RetBuffer);
205 
206 ACPI_STATUS
207 AcpiRsSetSrsMethodData (
208     ACPI_NAMESPACE_NODE     *Node,
209     ACPI_BUFFER             *RetBuffer);
210 
211 
212 /*
213  * rscalc
214  */
215 ACPI_STATUS
216 AcpiRsGetListLength (
217     UINT8                   *AmlBuffer,
218     UINT32                  AmlBufferLength,
219     ACPI_SIZE               *SizeNeeded);
220 
221 ACPI_STATUS
222 AcpiRsGetAmlLength (
223     ACPI_RESOURCE           *LinkedListBuffer,
224     ACPI_SIZE               *SizeNeeded);
225 
226 ACPI_STATUS
227 AcpiRsGetPciRoutingTableLength (
228     ACPI_OPERAND_OBJECT     *PackageObject,
229     ACPI_SIZE               *BufferSizeNeeded);
230 
231 ACPI_STATUS
232 AcpiRsConvertAmlToResources (
233     UINT8                   *Aml,
234     UINT32                  Length,
235     UINT32                  Offset,
236     UINT8                   ResourceIndex,
237     void                    *Context);
238 
239 ACPI_STATUS
240 AcpiRsConvertResourcesToAml (
241     ACPI_RESOURCE           *Resource,
242     ACPI_SIZE               AmlSizeNeeded,
243     UINT8                   *OutputBuffer);
244 
245 
246 /*
247  * rsaddr
248  */
249 void
250 AcpiRsSetAddressCommon (
251     AML_RESOURCE            *Aml,
252     ACPI_RESOURCE           *Resource);
253 
254 BOOLEAN
255 AcpiRsGetAddressCommon (
256     ACPI_RESOURCE           *Resource,
257     AML_RESOURCE            *Aml);
258 
259 
260 /*
261  * rsmisc
262  */
263 ACPI_STATUS
264 AcpiRsConvertAmlToResource (
265     ACPI_RESOURCE           *Resource,
266     AML_RESOURCE            *Aml,
267     ACPI_RSCONVERT_INFO     *Info);
268 
269 ACPI_STATUS
270 AcpiRsConvertResourceToAml (
271     ACPI_RESOURCE           *Resource,
272     AML_RESOURCE            *Aml,
273     ACPI_RSCONVERT_INFO     *Info);
274 
275 
276 /*
277  * rsutils
278  */
279 void
280 AcpiRsMoveData (
281     void                    *Destination,
282     void                    *Source,
283     UINT16                  ItemCount,
284     UINT8                   MoveType);
285 
286 UINT8
287 AcpiRsDecodeBitmask (
288     UINT16                  Mask,
289     UINT8                   *List);
290 
291 UINT16
292 AcpiRsEncodeBitmask (
293     UINT8                   *List,
294     UINT8                   Count);
295 
296 ACPI_RS_LENGTH
297 AcpiRsGetResourceSource (
298     ACPI_RS_LENGTH          ResourceLength,
299     ACPI_RS_LENGTH          MinimumLength,
300     ACPI_RESOURCE_SOURCE    *ResourceSource,
301     AML_RESOURCE            *Aml,
302     char                    *StringPtr);
303 
304 ACPI_RSDESC_SIZE
305 AcpiRsSetResourceSource (
306     AML_RESOURCE            *Aml,
307     ACPI_RS_LENGTH          MinimumLength,
308     ACPI_RESOURCE_SOURCE    *ResourceSource);
309 
310 void
311 AcpiRsSetResourceHeader (
312     UINT8                   DescriptorType,
313     ACPI_RSDESC_SIZE        TotalLength,
314     AML_RESOURCE            *Aml);
315 
316 void
317 AcpiRsSetResourceLength (
318     ACPI_RSDESC_SIZE        TotalLength,
319     AML_RESOURCE            *Aml);
320 
321 
322 /*
323  * rsdump
324  */
325 void
326 AcpiRsDumpResourceList (
327     ACPI_RESOURCE           *Resource);
328 
329 void
330 AcpiRsDumpIrqList (
331     UINT8                   *RouteTable);
332 
333 
334 /*
335  * Resource conversion tables
336  */
337 extern ACPI_RSCONVERT_INFO      AcpiRsConvertDma[];
338 extern ACPI_RSCONVERT_INFO      AcpiRsConvertEndDpf[];
339 extern ACPI_RSCONVERT_INFO      AcpiRsConvertIo[];
340 extern ACPI_RSCONVERT_INFO      AcpiRsConvertFixedIo[];
341 extern ACPI_RSCONVERT_INFO      AcpiRsConvertEndTag[];
342 extern ACPI_RSCONVERT_INFO      AcpiRsConvertMemory24[];
343 extern ACPI_RSCONVERT_INFO      AcpiRsConvertGenericReg[];
344 extern ACPI_RSCONVERT_INFO      AcpiRsConvertMemory32[];
345 extern ACPI_RSCONVERT_INFO      AcpiRsConvertFixedMemory32[];
346 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress32[];
347 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress16[];
348 extern ACPI_RSCONVERT_INFO      AcpiRsConvertExtIrq[];
349 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress64[];
350 extern ACPI_RSCONVERT_INFO      AcpiRsConvertExtAddress64[];
351 
352 /* These resources require separate get/set tables */
353 
354 extern ACPI_RSCONVERT_INFO      AcpiRsGetIrq[];
355 extern ACPI_RSCONVERT_INFO      AcpiRsGetStartDpf[];
356 extern ACPI_RSCONVERT_INFO      AcpiRsGetVendorSmall[];
357 extern ACPI_RSCONVERT_INFO      AcpiRsGetVendorLarge[];
358 
359 extern ACPI_RSCONVERT_INFO      AcpiRsSetIrq[];
360 extern ACPI_RSCONVERT_INFO      AcpiRsSetStartDpf[];
361 extern ACPI_RSCONVERT_INFO      AcpiRsSetVendor[];
362 
363 
364 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
365 /*
366  * rsinfo
367  */
368 extern ACPI_RSDUMP_INFO         *AcpiGbl_DumpResourceDispatch[];
369 
370 /*
371  * rsdump
372  */
373 extern ACPI_RSDUMP_INFO         AcpiRsDumpIrq[];
374 extern ACPI_RSDUMP_INFO         AcpiRsDumpDma[];
375 extern ACPI_RSDUMP_INFO         AcpiRsDumpStartDpf[];
376 extern ACPI_RSDUMP_INFO         AcpiRsDumpEndDpf[];
377 extern ACPI_RSDUMP_INFO         AcpiRsDumpIo[];
378 extern ACPI_RSDUMP_INFO         AcpiRsDumpFixedIo[];
379 extern ACPI_RSDUMP_INFO         AcpiRsDumpVendor[];
380 extern ACPI_RSDUMP_INFO         AcpiRsDumpEndTag[];
381 extern ACPI_RSDUMP_INFO         AcpiRsDumpMemory24[];
382 extern ACPI_RSDUMP_INFO         AcpiRsDumpMemory32[];
383 extern ACPI_RSDUMP_INFO         AcpiRsDumpFixedMemory32[];
384 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress16[];
385 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress32[];
386 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress64[];
387 extern ACPI_RSDUMP_INFO         AcpiRsDumpExtAddress64[];
388 extern ACPI_RSDUMP_INFO         AcpiRsDumpExtIrq[];
389 extern ACPI_RSDUMP_INFO         AcpiRsDumpGenericReg[];
390 #endif
391 
392 #endif  /* __ACRESRC_H__ */
393