Bring in acpica 20110211, still not ok anyway
[dragonfly.git] / sys / contrib / dev / acpica-unix / include / acresrc.h
1 /******************************************************************************
2  *
3  * Name: acresrc.h - Resource Manager function prototypes
4  *
5  *****************************************************************************/
6
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights.  You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116
117 #ifndef __ACRESRC_H__
118 #define __ACRESRC_H__
119
120 /* Need the AML resource descriptor structs */
121
122 #include "amlresrc.h"
123
124
125 /*
126  * If possible, pack the following structures to byte alignment, since we
127  * don't care about performance for debug output. Two cases where we cannot
128  * pack the structures:
129  *
130  * 1) Hardware does not support misaligned memory transfers
131  * 2) Compiler does not support pointers within packed structures
132  */
133 #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
134 #pragma pack(1)
135 #endif
136
137 /*
138  * Individual entry for the resource conversion tables
139  */
140 typedef const struct acpi_rsconvert_info
141 {
142     UINT8                   Opcode;
143     UINT8                   ResourceOffset;
144     UINT8                   AmlOffset;
145     UINT8                   Value;
146
147 } ACPI_RSCONVERT_INFO;
148
149 /* Resource conversion opcodes */
150
151 #define ACPI_RSC_INITGET                0
152 #define ACPI_RSC_INITSET                1
153 #define ACPI_RSC_FLAGINIT               2
154 #define ACPI_RSC_1BITFLAG               3
155 #define ACPI_RSC_2BITFLAG               4
156 #define ACPI_RSC_COUNT                  5
157 #define ACPI_RSC_COUNT16                6
158 #define ACPI_RSC_LENGTH                 7
159 #define ACPI_RSC_MOVE8                  8
160 #define ACPI_RSC_MOVE16                 9
161 #define ACPI_RSC_MOVE32                 10
162 #define ACPI_RSC_MOVE64                 11
163 #define ACPI_RSC_SET8                   12
164 #define ACPI_RSC_DATA8                  13
165 #define ACPI_RSC_ADDRESS                14
166 #define ACPI_RSC_SOURCE                 15
167 #define ACPI_RSC_SOURCEX                16
168 #define ACPI_RSC_BITMASK                17
169 #define ACPI_RSC_BITMASK16              18
170 #define ACPI_RSC_EXIT_NE                19
171 #define ACPI_RSC_EXIT_LE                20
172 #define ACPI_RSC_EXIT_EQ                21
173
174 /* Resource Conversion sub-opcodes */
175
176 #define ACPI_RSC_COMPARE_AML_LENGTH     0
177 #define ACPI_RSC_COMPARE_VALUE          1
178
179 #define ACPI_RSC_TABLE_SIZE(d)          (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO))
180
181 #define ACPI_RS_OFFSET(f)               (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f)
182 #define AML_OFFSET(f)                   (UINT8) ACPI_OFFSET (AML_RESOURCE,f)
183
184
185 typedef const struct acpi_rsdump_info
186 {
187     UINT8                   Opcode;
188     UINT8                   Offset;
189     char                    *Name;
190     const char              **Pointer;
191
192 } ACPI_RSDUMP_INFO;
193
194 /* Values for the Opcode field above */
195
196 #define ACPI_RSD_TITLE                  0
197 #define ACPI_RSD_LITERAL                1
198 #define ACPI_RSD_STRING                 2
199 #define ACPI_RSD_UINT8                  3
200 #define ACPI_RSD_UINT16                 4
201 #define ACPI_RSD_UINT32                 5
202 #define ACPI_RSD_UINT64                 6
203 #define ACPI_RSD_1BITFLAG               7
204 #define ACPI_RSD_2BITFLAG               8
205 #define ACPI_RSD_SHORTLIST              9
206 #define ACPI_RSD_LONGLIST               10
207 #define ACPI_RSD_DWORDLIST              11
208 #define ACPI_RSD_ADDRESS                12
209 #define ACPI_RSD_SOURCE                 13
210
211 /* restore default alignment */
212
213 #pragma pack()
214
215
216 /* Resource tables indexed by internal resource type */
217
218 extern const UINT8              AcpiGbl_AmlResourceSizes[];
219 extern ACPI_RSCONVERT_INFO      *AcpiGbl_SetResourceDispatch[];
220
221 /* Resource tables indexed by raw AML resource descriptor type */
222
223 extern const UINT8              AcpiGbl_ResourceStructSizes[];
224 extern ACPI_RSCONVERT_INFO      *AcpiGbl_GetResourceDispatch[];
225
226
227 typedef struct acpi_vendor_walk_info
228 {
229     ACPI_VENDOR_UUID        *Uuid;
230     ACPI_BUFFER             *Buffer;
231     ACPI_STATUS             Status;
232
233 } ACPI_VENDOR_WALK_INFO;
234
235
236 /*
237  * rscreate
238  */
239 ACPI_STATUS
240 AcpiRsCreateResourceList (
241     ACPI_OPERAND_OBJECT     *AmlBuffer,
242     ACPI_BUFFER             *OutputBuffer);
243
244 ACPI_STATUS
245 AcpiRsCreateAmlResources (
246     ACPI_RESOURCE           *LinkedListBuffer,
247     ACPI_BUFFER             *OutputBuffer);
248
249 ACPI_STATUS
250 AcpiRsCreatePciRoutingTable (
251     ACPI_OPERAND_OBJECT     *PackageObject,
252     ACPI_BUFFER             *OutputBuffer);
253
254
255 /*
256  * rsutils
257  */
258 ACPI_STATUS
259 AcpiRsGetPrtMethodData (
260     ACPI_NAMESPACE_NODE     *Node,
261     ACPI_BUFFER             *RetBuffer);
262
263 ACPI_STATUS
264 AcpiRsGetCrsMethodData (
265     ACPI_NAMESPACE_NODE     *Node,
266     ACPI_BUFFER             *RetBuffer);
267
268 ACPI_STATUS
269 AcpiRsGetPrsMethodData (
270     ACPI_NAMESPACE_NODE     *Node,
271     ACPI_BUFFER             *RetBuffer);
272
273 ACPI_STATUS
274 AcpiRsGetMethodData (
275     ACPI_HANDLE             Handle,
276     char                    *Path,
277     ACPI_BUFFER             *RetBuffer);
278
279 ACPI_STATUS
280 AcpiRsSetSrsMethodData (
281     ACPI_NAMESPACE_NODE     *Node,
282     ACPI_BUFFER             *RetBuffer);
283
284
285 /*
286  * rscalc
287  */
288 ACPI_STATUS
289 AcpiRsGetListLength (
290     UINT8                   *AmlBuffer,
291     UINT32                  AmlBufferLength,
292     ACPI_SIZE               *SizeNeeded);
293
294 ACPI_STATUS
295 AcpiRsGetAmlLength (
296     ACPI_RESOURCE           *LinkedListBuffer,
297     ACPI_SIZE               *SizeNeeded);
298
299 ACPI_STATUS
300 AcpiRsGetPciRoutingTableLength (
301     ACPI_OPERAND_OBJECT     *PackageObject,
302     ACPI_SIZE               *BufferSizeNeeded);
303
304 ACPI_STATUS
305 AcpiRsConvertAmlToResources (
306     UINT8                   *Aml,
307     UINT32                  Length,
308     UINT32                  Offset,
309     UINT8                   ResourceIndex,
310     void                    *Context);
311
312 ACPI_STATUS
313 AcpiRsConvertResourcesToAml (
314     ACPI_RESOURCE           *Resource,
315     ACPI_SIZE               AmlSizeNeeded,
316     UINT8                   *OutputBuffer);
317
318
319 /*
320  * rsaddr
321  */
322 void
323 AcpiRsSetAddressCommon (
324     AML_RESOURCE            *Aml,
325     ACPI_RESOURCE           *Resource);
326
327 BOOLEAN
328 AcpiRsGetAddressCommon (
329     ACPI_RESOURCE           *Resource,
330     AML_RESOURCE            *Aml);
331
332
333 /*
334  * rsmisc
335  */
336 ACPI_STATUS
337 AcpiRsConvertAmlToResource (
338     ACPI_RESOURCE           *Resource,
339     AML_RESOURCE            *Aml,
340     ACPI_RSCONVERT_INFO     *Info);
341
342 ACPI_STATUS
343 AcpiRsConvertResourceToAml (
344     ACPI_RESOURCE           *Resource,
345     AML_RESOURCE            *Aml,
346     ACPI_RSCONVERT_INFO     *Info);
347
348
349 /*
350  * rsutils
351  */
352 void
353 AcpiRsMoveData (
354     void                    *Destination,
355     void                    *Source,
356     UINT16                  ItemCount,
357     UINT8                   MoveType);
358
359 UINT8
360 AcpiRsDecodeBitmask (
361     UINT16                  Mask,
362     UINT8                   *List);
363
364 UINT16
365 AcpiRsEncodeBitmask (
366     UINT8                   *List,
367     UINT8                   Count);
368
369 ACPI_RS_LENGTH
370 AcpiRsGetResourceSource (
371     ACPI_RS_LENGTH          ResourceLength,
372     ACPI_RS_LENGTH          MinimumLength,
373     ACPI_RESOURCE_SOURCE    *ResourceSource,
374     AML_RESOURCE            *Aml,
375     char                    *StringPtr);
376
377 ACPI_RSDESC_SIZE
378 AcpiRsSetResourceSource (
379     AML_RESOURCE            *Aml,
380     ACPI_RS_LENGTH          MinimumLength,
381     ACPI_RESOURCE_SOURCE    *ResourceSource);
382
383 void
384 AcpiRsSetResourceHeader (
385     UINT8                   DescriptorType,
386     ACPI_RSDESC_SIZE        TotalLength,
387     AML_RESOURCE            *Aml);
388
389 void
390 AcpiRsSetResourceLength (
391     ACPI_RSDESC_SIZE        TotalLength,
392     AML_RESOURCE            *Aml);
393
394
395 /*
396  * rsdump
397  */
398 void
399 AcpiRsDumpResourceList (
400     ACPI_RESOURCE           *Resource);
401
402 void
403 AcpiRsDumpIrqList (
404     UINT8                   *RouteTable);
405
406
407 /*
408  * Resource conversion tables
409  */
410 extern ACPI_RSCONVERT_INFO      AcpiRsConvertDma[];
411 extern ACPI_RSCONVERT_INFO      AcpiRsConvertEndDpf[];
412 extern ACPI_RSCONVERT_INFO      AcpiRsConvertIo[];
413 extern ACPI_RSCONVERT_INFO      AcpiRsConvertFixedIo[];
414 extern ACPI_RSCONVERT_INFO      AcpiRsConvertEndTag[];
415 extern ACPI_RSCONVERT_INFO      AcpiRsConvertMemory24[];
416 extern ACPI_RSCONVERT_INFO      AcpiRsConvertGenericReg[];
417 extern ACPI_RSCONVERT_INFO      AcpiRsConvertMemory32[];
418 extern ACPI_RSCONVERT_INFO      AcpiRsConvertFixedMemory32[];
419 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress32[];
420 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress16[];
421 extern ACPI_RSCONVERT_INFO      AcpiRsConvertExtIrq[];
422 extern ACPI_RSCONVERT_INFO      AcpiRsConvertAddress64[];
423 extern ACPI_RSCONVERT_INFO      AcpiRsConvertExtAddress64[];
424
425 /* These resources require separate get/set tables */
426
427 extern ACPI_RSCONVERT_INFO      AcpiRsGetIrq[];
428 extern ACPI_RSCONVERT_INFO      AcpiRsGetStartDpf[];
429 extern ACPI_RSCONVERT_INFO      AcpiRsGetVendorSmall[];
430 extern ACPI_RSCONVERT_INFO      AcpiRsGetVendorLarge[];
431
432 extern ACPI_RSCONVERT_INFO      AcpiRsSetIrq[];
433 extern ACPI_RSCONVERT_INFO      AcpiRsSetStartDpf[];
434 extern ACPI_RSCONVERT_INFO      AcpiRsSetVendor[];
435
436
437 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
438 /*
439  * rsinfo
440  */
441 extern ACPI_RSDUMP_INFO         *AcpiGbl_DumpResourceDispatch[];
442
443 /*
444  * rsdump
445  */
446 extern ACPI_RSDUMP_INFO         AcpiRsDumpIrq[];
447 extern ACPI_RSDUMP_INFO         AcpiRsDumpDma[];
448 extern ACPI_RSDUMP_INFO         AcpiRsDumpStartDpf[];
449 extern ACPI_RSDUMP_INFO         AcpiRsDumpEndDpf[];
450 extern ACPI_RSDUMP_INFO         AcpiRsDumpIo[];
451 extern ACPI_RSDUMP_INFO         AcpiRsDumpFixedIo[];
452 extern ACPI_RSDUMP_INFO         AcpiRsDumpVendor[];
453 extern ACPI_RSDUMP_INFO         AcpiRsDumpEndTag[];
454 extern ACPI_RSDUMP_INFO         AcpiRsDumpMemory24[];
455 extern ACPI_RSDUMP_INFO         AcpiRsDumpMemory32[];
456 extern ACPI_RSDUMP_INFO         AcpiRsDumpFixedMemory32[];
457 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress16[];
458 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress32[];
459 extern ACPI_RSDUMP_INFO         AcpiRsDumpAddress64[];
460 extern ACPI_RSDUMP_INFO         AcpiRsDumpExtAddress64[];
461 extern ACPI_RSDUMP_INFO         AcpiRsDumpExtIrq[];
462 extern ACPI_RSDUMP_INFO         AcpiRsDumpGenericReg[];
463 #endif
464
465 #endif  /* __ACRESRC_H__ */