25cff0d5ba58dde5612ef8521c8005ba65d52d6c
[sfrench/cifs-2.6.git] / include / acpi / acresrc.h
1 /******************************************************************************
2  *
3  * Name: acresrc.h - Resource Manager function prototypes
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2005, R. Byron Moore
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  * If possible, pack the following structures to byte alignment, since we
53  * don't care about performance for debug output
54  */
55 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
56 #pragma pack(1)
57 #endif
58
59 /*
60  * Individual entry for the resource conversion tables
61  */
62 typedef const struct acpi_rsconvert_info {
63         u8 opcode;
64         u8 resource_offset;
65         u8 aml_offset;
66         u8 value;
67
68 } acpi_rsconvert_info;
69
70 /* Resource conversion opcodes */
71
72 #define ACPI_RSC_INITGET                0
73 #define ACPI_RSC_INITSET                1
74 #define ACPI_RSC_FLAGINIT               2
75 #define ACPI_RSC_1BITFLAG               3
76 #define ACPI_RSC_2BITFLAG               4
77 #define ACPI_RSC_COUNT                  5
78 #define ACPI_RSC_COUNT16                6
79 #define ACPI_RSC_LENGTH                 7
80 #define ACPI_RSC_MOVE8                  8
81 #define ACPI_RSC_MOVE16                 9
82 #define ACPI_RSC_MOVE32                 10
83 #define ACPI_RSC_MOVE64                 11
84 #define ACPI_RSC_SET8                   12
85 #define ACPI_RSC_DATA8                  13
86 #define ACPI_RSC_ADDRESS                14
87 #define ACPI_RSC_SOURCE                 15
88 #define ACPI_RSC_SOURCEX                16
89 #define ACPI_RSC_BITMASK                17
90 #define ACPI_RSC_BITMASK16              18
91 #define ACPI_RSC_EXIT_NE                19
92 #define ACPI_RSC_EXIT_LE                20
93
94 /* Resource Conversion sub-opcodes */
95
96 #define ACPI_RSC_COMPARE_AML_LENGTH     0
97 #define ACPI_RSC_COMPARE_VALUE          1
98
99 #define ACPI_RSC_TABLE_SIZE(d)          (sizeof (d) / sizeof (struct acpi_rsconvert_info))
100
101 #define ACPI_RS_OFFSET(f)               (u8) ACPI_OFFSET (struct acpi_resource,f)
102 #define AML_OFFSET(f)                   (u8) ACPI_OFFSET (union aml_resource,f)
103
104 /*
105  * Resource dispatch and info tables
106  */
107 typedef const struct acpi_resource_info {
108         u8 length_type;
109         u8 minimum_aml_resource_length;
110         u8 minimum_internal_struct_length;
111
112 } acpi_resource_info;
113
114 /* Types for length_type above */
115
116 #define ACPI_FIXED_LENGTH               0
117 #define ACPI_VARIABLE_LENGTH            1
118 #define ACPI_SMALL_VARIABLE_LENGTH      2
119
120 typedef const struct acpi_rsdump_info {
121         u8 opcode;
122         u8 offset;
123         char *name;
124         const void *pointer;
125
126 } acpi_rsdump_info;
127
128 /* Values for the Opcode field above */
129
130 #define ACPI_RSD_TITLE                  0
131 #define ACPI_RSD_LITERAL                1
132 #define ACPI_RSD_STRING                 2
133 #define ACPI_RSD_UINT8                  3
134 #define ACPI_RSD_UINT16                 4
135 #define ACPI_RSD_UINT32                 5
136 #define ACPI_RSD_UINT64                 6
137 #define ACPI_RSD_1BITFLAG               7
138 #define ACPI_RSD_2BITFLAG               8
139 #define ACPI_RSD_SHORTLIST              9
140 #define ACPI_RSD_LONGLIST               10
141 #define ACPI_RSD_DWORDLIST              11
142 #define ACPI_RSD_ADDRESS                12
143 #define ACPI_RSD_SOURCE                 13
144
145 /* restore default alignment */
146
147 #pragma pack()
148
149 /* Resource tables indexed by internal resource type */
150
151 extern const u8 acpi_gbl_aml_resource_sizes[];
152 extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
153
154 /* Resource tables indexed by raw AML resource descriptor type */
155
156 extern struct acpi_resource_info acpi_gbl_sm_resource_info[];
157 extern struct acpi_resource_info acpi_gbl_lg_resource_info[];
158 extern struct acpi_rsconvert_info *acpi_gbl_sm_get_resource_dispatch[];
159 extern struct acpi_rsconvert_info *acpi_gbl_lg_get_resource_dispatch[];
160
161 /*
162  * rscreate
163  */
164 acpi_status
165 acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
166                              struct acpi_buffer *output_buffer);
167
168 acpi_status
169 acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
170                              struct acpi_buffer *output_buffer);
171
172 acpi_status
173 acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
174                                  struct acpi_buffer *output_buffer);
175
176 /*
177  * rsutils
178  */
179 acpi_status
180 acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
181
182 acpi_status
183 acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
184
185 #ifdef  ACPI_FUTURE_USAGE
186 acpi_status
187 acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
188 #endif                          /* ACPI_FUTURE_USAGE */
189
190 acpi_status
191 acpi_rs_get_method_data(acpi_handle handle,
192                         char *path, struct acpi_buffer *ret_buffer);
193
194 acpi_status
195 acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer);
196
197 /*
198  * rscalc
199  */
200 acpi_status
201 acpi_rs_get_list_length(u8 * aml_buffer,
202                         u32 aml_buffer_length, acpi_size * size_needed);
203
204 acpi_status
205 acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
206                        acpi_size * size_needed);
207
208 acpi_status
209 acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
210                                      acpi_size * buffer_size_needed);
211
212 acpi_status
213 acpi_rs_convert_aml_to_resources(u8 * aml_buffer,
214                                  u32 aml_buffer_length, u8 * output_buffer);
215
216 acpi_status
217 acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
218                                  acpi_size aml_size_needed, u8 * output_buffer);
219
220 /*
221  * rsaddr
222  */
223 void
224 acpi_rs_set_address_common(union aml_resource *aml,
225                            struct acpi_resource *resource);
226
227 u8
228 acpi_rs_get_address_common(struct acpi_resource *resource,
229                            union aml_resource *aml);
230
231 /*
232  * rsmisc
233  */
234 acpi_status
235 acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
236                                 union aml_resource *aml,
237                                 struct acpi_rsconvert_info *info);
238
239 acpi_status
240 acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
241                                 union aml_resource *aml,
242                                 struct acpi_rsconvert_info *info);
243
244 /*
245  * rsutils
246  */
247 void
248 acpi_rs_move_data(void *destination,
249                   void *source, u16 item_count, u8 move_type);
250
251 u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
252
253 u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
254
255 acpi_rs_length
256 acpi_rs_get_resource_source(acpi_rs_length resource_length,
257                             acpi_rs_length minimum_length,
258                             struct acpi_resource_source *resource_source,
259                             union aml_resource *aml, char *string_ptr);
260
261 acpi_rsdesc_size
262 acpi_rs_set_resource_source(union aml_resource *aml,
263                             acpi_rs_length minimum_length,
264                             struct acpi_resource_source *resource_source);
265
266 void
267 acpi_rs_set_resource_header(u8 descriptor_type,
268                             acpi_rsdesc_size total_length,
269                             union aml_resource *aml);
270
271 void
272 acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
273                             union aml_resource *aml);
274
275 struct acpi_resource_info *acpi_rs_get_resource_info(u8 resource_type);
276
277 /*
278  * rsdump
279  */
280 void acpi_rs_dump_resource_list(struct acpi_resource *resource);
281
282 void acpi_rs_dump_irq_list(u8 * route_table);
283
284 /*
285  * Resource conversion tables
286  */
287 extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
288 extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
289 extern struct acpi_rsconvert_info acpi_rs_convert_io[];
290 extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
291 extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
292 extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
293 extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
294 extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
295 extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
296 extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
297 extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
298 extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
299 extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
300 extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
301
302 /* These resources require separate get/set tables */
303
304 extern struct acpi_rsconvert_info acpi_rs_get_irq[];
305 extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
306 extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
307 extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
308
309 extern struct acpi_rsconvert_info acpi_rs_set_irq[];
310 extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
311 extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
312
313 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
314 /*
315  * rsinfo
316  */
317 extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
318
319 /*
320  * rsdump
321  */
322 extern struct acpi_rsdump_info acpi_rs_dump_irq[];
323 extern struct acpi_rsdump_info acpi_rs_dump_dma[];
324 extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
325 extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
326 extern struct acpi_rsdump_info acpi_rs_dump_io[];
327 extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
328 extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
329 extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
330 extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
331 extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
332 extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
333 extern struct acpi_rsdump_info acpi_rs_dump_address16[];
334 extern struct acpi_rsdump_info acpi_rs_dump_address32[];
335 extern struct acpi_rsdump_info acpi_rs_dump_address64[];
336 extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
337 extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
338 extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
339 #endif
340
341 #endif                          /* __ACRESRC_H__ */