Merge to-linus-stable into to-akpm
[pandora-kernel.git] / include / acpi / acparser.h
1 /******************************************************************************
2  *
3  * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
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
45 #ifndef __ACPARSER_H__
46 #define __ACPARSER_H__
47
48
49 #define OP_HAS_RETURN_VALUE             1
50
51 /* variable # arguments */
52
53 #define ACPI_VAR_ARGS                   ACPI_UINT32_MAX
54
55
56 #define ACPI_PARSE_DELETE_TREE          0x0001
57 #define ACPI_PARSE_NO_TREE_DELETE       0x0000
58 #define ACPI_PARSE_TREE_MASK            0x0001
59
60 #define ACPI_PARSE_LOAD_PASS1           0x0010
61 #define ACPI_PARSE_LOAD_PASS2           0x0020
62 #define ACPI_PARSE_EXECUTE              0x0030
63 #define ACPI_PARSE_MODE_MASK            0x0030
64
65 #define ACPI_PARSE_DEFERRED_OP          0x0100
66 #define ACPI_PARSE_DISASSEMBLE          0x0200
67
68
69 /******************************************************************************
70  *
71  * Parser interfaces
72  *
73  *****************************************************************************/
74
75
76 /*
77  * psxface - Parser external interfaces
78  */
79 acpi_status
80 acpi_ps_execute_method (
81         struct acpi_parameter_info      *info);
82
83
84 /*
85  * psargs - Parse AML opcode arguments
86  */
87 u8 *
88 acpi_ps_get_next_package_end (
89         struct acpi_parse_state         *parser_state);
90
91 char *
92 acpi_ps_get_next_namestring (
93         struct acpi_parse_state         *parser_state);
94
95 void
96 acpi_ps_get_next_simple_arg (
97         struct acpi_parse_state         *parser_state,
98         u32                             arg_type,
99         union acpi_parse_object         *arg);
100
101 acpi_status
102 acpi_ps_get_next_namepath (
103         struct acpi_walk_state          *walk_state,
104         struct acpi_parse_state         *parser_state,
105         union acpi_parse_object         *arg,
106         u8                              method_call);
107
108 acpi_status
109 acpi_ps_get_next_arg (
110         struct acpi_walk_state          *walk_state,
111         struct acpi_parse_state         *parser_state,
112         u32                             arg_type,
113         union acpi_parse_object         **return_arg);
114
115
116 /*
117  * psfind
118  */
119 union acpi_parse_object *
120 acpi_ps_find_name (
121         union acpi_parse_object         *scope,
122         u32                             name,
123         u32                             opcode);
124
125 union acpi_parse_object*
126 acpi_ps_get_parent (
127         union acpi_parse_object         *op);
128
129
130 /*
131  * psopcode - AML Opcode information
132  */
133 const struct acpi_opcode_info *
134 acpi_ps_get_opcode_info (
135         u16                             opcode);
136
137 char *
138 acpi_ps_get_opcode_name (
139         u16                             opcode);
140
141
142 /*
143  * psparse - top level parsing routines
144  */
145 acpi_status
146 acpi_ps_parse_aml (
147         struct acpi_walk_state          *walk_state);
148
149 u32
150 acpi_ps_get_opcode_size (
151         u32                             opcode);
152
153 u16
154 acpi_ps_peek_opcode (
155         struct acpi_parse_state         *state);
156
157 acpi_status
158 acpi_ps_complete_this_op (
159         struct acpi_walk_state          *walk_state,
160         union acpi_parse_object         *op);
161
162 acpi_status
163 acpi_ps_next_parse_state (
164         struct acpi_walk_state          *walk_state,
165         union acpi_parse_object         *op,
166         acpi_status                     callback_status);
167
168
169 /*
170  * psloop - main parse loop
171  */
172 acpi_status
173 acpi_ps_parse_loop (
174         struct acpi_walk_state          *walk_state);
175
176
177 /*
178  * psscope - Scope stack management routines
179  */
180 acpi_status
181 acpi_ps_init_scope (
182         struct acpi_parse_state         *parser_state,
183         union acpi_parse_object         *root);
184
185 union acpi_parse_object *
186 acpi_ps_get_parent_scope (
187         struct acpi_parse_state         *state);
188
189 u8
190 acpi_ps_has_completed_scope (
191         struct acpi_parse_state         *parser_state);
192
193 void
194 acpi_ps_pop_scope (
195         struct acpi_parse_state         *parser_state,
196         union acpi_parse_object         **op,
197         u32                             *arg_list,
198         u32                             *arg_count);
199
200 acpi_status
201 acpi_ps_push_scope (
202         struct acpi_parse_state         *parser_state,
203         union acpi_parse_object         *op,
204         u32                             remaining_args,
205         u32                             arg_count);
206
207 void
208 acpi_ps_cleanup_scope (
209         struct acpi_parse_state         *state);
210
211
212 /*
213  * pstree - parse tree manipulation routines
214  */
215 void
216 acpi_ps_append_arg(
217         union acpi_parse_object         *op,
218         union acpi_parse_object         *arg);
219
220 union acpi_parse_object*
221 acpi_ps_find (
222         union acpi_parse_object         *scope,
223         char                            *path,
224         u16                             opcode,
225         u32                             create);
226
227 union acpi_parse_object *
228 acpi_ps_get_arg(
229         union acpi_parse_object         *op,
230         u32                              argn);
231
232 #ifdef  ACPI_FUTURE_USAGE
233 union acpi_parse_object *
234 acpi_ps_get_depth_next (
235         union acpi_parse_object         *origin,
236         union acpi_parse_object         *op);
237 #endif  /* ACPI_FUTURE_USAGE */
238
239
240 /*
241  * pswalk - parse tree walk routines
242  */
243 acpi_status
244 acpi_ps_walk_parsed_aml (
245         union acpi_parse_object         *start_op,
246         union acpi_parse_object         *end_op,
247         union acpi_operand_object       *mth_desc,
248         struct acpi_namespace_node      *start_node,
249         union acpi_operand_object       **params,
250         union acpi_operand_object       **caller_return_desc,
251         acpi_owner_id                   owner_id,
252         acpi_parse_downwards            descending_callback,
253         acpi_parse_upwards              ascending_callback);
254
255 acpi_status
256 acpi_ps_get_next_walk_op (
257         struct acpi_walk_state          *walk_state,
258         union acpi_parse_object         *op,
259         acpi_parse_upwards              ascending_callback);
260
261 acpi_status
262 acpi_ps_delete_completed_op (
263         struct acpi_walk_state          *walk_state);
264
265 void
266 acpi_ps_delete_parse_tree (
267         union acpi_parse_object         *root);
268
269
270 /*
271  * psutils - parser utilities
272  */
273 union acpi_parse_object *
274 acpi_ps_create_scope_op (
275         void);
276
277 void
278 acpi_ps_init_op (
279         union acpi_parse_object         *op,
280         u16                             opcode);
281
282 union acpi_parse_object *
283 acpi_ps_alloc_op (
284         u16                             opcode);
285
286 void
287 acpi_ps_free_op (
288         union acpi_parse_object         *op);
289
290 u8
291 acpi_ps_is_leading_char (
292         u32                             c);
293
294 u8
295 acpi_ps_is_prefix_char (
296         u32                             c);
297
298 #ifdef  ACPI_FUTURE_USAGE
299 u32
300 acpi_ps_get_name(
301         union acpi_parse_object         *op);
302 #endif  /* ACPI_FUTURE_USAGE */
303
304 void
305 acpi_ps_set_name(
306         union acpi_parse_object         *op,
307         u32                             name);
308
309
310 /*
311  * psdump - display parser tree
312  */
313 u32
314 acpi_ps_sprint_path (
315         char                            *buffer_start,
316         u32                             buffer_size,
317         union acpi_parse_object         *op);
318
319 u32
320 acpi_ps_sprint_op (
321         char                            *buffer_start,
322         u32                             buffer_size,
323         union acpi_parse_object         *op);
324
325 void
326 acpi_ps_show (
327         union acpi_parse_object         *op);
328
329
330 #endif /* __ACPARSER_H__ */