minor corrections by M.Taguchi
[reactos.git] / reactos / drivers / bus / acpi / include / acparser.h
1 /******************************************************************************
2 *
3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4 * $Revision: 1.1 $
5 *
6 *****************************************************************************/
7
8 /*
9 * Copyright (C) 2000, 2001 R. Byron Moore
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26
27 #ifndef __ACPARSER_H__
28 #define __ACPARSER_H__
29
30
31 #define OP_HAS_RETURN_VALUE 1
32
33 /* variable # arguments */
34
35 #define ACPI_VAR_ARGS ACPI_UINT32_MAX
36
37 /* maximum virtual address */
38
39 #define ACPI_MAX_AML ((u8 *)(~0UL))
40
41
42 #define ACPI_PARSE_DELETE_TREE 0x0001
43 #define ACPI_PARSE_NO_TREE_DELETE 0x0000
44 #define ACPI_PARSE_TREE_MASK 0x0001
45
46 #define ACPI_PARSE_LOAD_PASS1 0x0010
47 #define ACPI_PARSE_LOAD_PASS2 0x0020
48 #define ACPI_PARSE_EXECUTE 0x0030
49 #define ACPI_PARSE_MODE_MASK 0x0030
50
51 /* psapi - Parser external interfaces */
52
53 ACPI_STATUS
54 acpi_psx_load_table (
55 u8 *pcode_addr,
56 u32 pcode_length);
57
58 ACPI_STATUS
59 acpi_psx_execute (
60 ACPI_NAMESPACE_NODE *method_node,
61 ACPI_OPERAND_OBJECT **params,
62 ACPI_OPERAND_OBJECT **return_obj_desc);
63
64
65 u8
66 acpi_ps_is_namespace_object_op (
67 u16 opcode);
68 u8
69 acpi_ps_is_namespace_op (
70 u16 opcode);
71
72
73 /******************************************************************************
74 *
75 * Parser interfaces
76 *
77 *****************************************************************************/
78
79
80 /* psargs - Parse AML opcode arguments */
81
82 u8 *
83 acpi_ps_get_next_package_end (
84 ACPI_PARSE_STATE *parser_state);
85
86 u32
87 acpi_ps_get_next_package_length (
88 ACPI_PARSE_STATE *parser_state);
89
90 NATIVE_CHAR *
91 acpi_ps_get_next_namestring (
92 ACPI_PARSE_STATE *parser_state);
93
94 void
95 acpi_ps_get_next_simple_arg (
96 ACPI_PARSE_STATE *parser_state,
97 u32 arg_type, /* type of argument */
98 ACPI_PARSE_OBJECT *arg); /* (OUT) argument data */
99
100 void
101 acpi_ps_get_next_namepath (
102 ACPI_PARSE_STATE *parser_state,
103 ACPI_PARSE_OBJECT *arg,
104 u32 *arg_count,
105 u8 method_call);
106
107 ACPI_PARSE_OBJECT *
108 acpi_ps_get_next_field (
109 ACPI_PARSE_STATE *parser_state);
110
111 ACPI_PARSE_OBJECT *
112 acpi_ps_get_next_arg (
113 ACPI_PARSE_STATE *parser_state,
114 u32 arg_type,
115 u32 *arg_count);
116
117
118 /* psopcode - AML Opcode information */
119
120 ACPI_OPCODE_INFO *
121 acpi_ps_get_opcode_info (
122 u16 opcode);
123
124 NATIVE_CHAR *
125 acpi_ps_get_opcode_name (
126 u16 opcode);
127
128
129 /* psparse - top level parsing routines */
130
131 ACPI_STATUS
132 acpi_ps_find_object (
133 u16 opcode,
134 ACPI_PARSE_OBJECT *op,
135 ACPI_WALK_STATE *walk_state,
136 ACPI_PARSE_OBJECT **out_op);
137
138 void
139 acpi_ps_delete_parse_tree (
140 ACPI_PARSE_OBJECT *root);
141
142 ACPI_STATUS
143 acpi_ps_parse_loop (
144 ACPI_WALK_STATE *walk_state);
145
146 ACPI_STATUS
147 acpi_ps_parse_aml (
148 ACPI_PARSE_OBJECT *start_scope,
149 u8 *aml,
150 u32 aml_size,
151 u32 parse_flags,
152 ACPI_NAMESPACE_NODE *method_node,
153 ACPI_OPERAND_OBJECT **params,
154 ACPI_OPERAND_OBJECT **caller_return_desc,
155 ACPI_PARSE_DOWNWARDS descending_callback,
156 ACPI_PARSE_UPWARDS ascending_callback);
157
158 ACPI_STATUS
159 acpi_ps_parse_table (
160 u8 *aml,
161 u32 aml_size,
162 ACPI_PARSE_DOWNWARDS descending_callback,
163 ACPI_PARSE_UPWARDS ascending_callback,
164 ACPI_PARSE_OBJECT **root_object);
165
166 u16
167 acpi_ps_peek_opcode (
168 ACPI_PARSE_STATE *state);
169
170
171 /* psscope - Scope stack management routines */
172
173
174 ACPI_STATUS
175 acpi_ps_init_scope (
176 ACPI_PARSE_STATE *parser_state,
177 ACPI_PARSE_OBJECT *root);
178
179 ACPI_PARSE_OBJECT *
180 acpi_ps_get_parent_scope (
181 ACPI_PARSE_STATE *state);
182
183 u8
184 acpi_ps_has_completed_scope (
185 ACPI_PARSE_STATE *parser_state);
186
187 void
188 acpi_ps_pop_scope (
189 ACPI_PARSE_STATE *parser_state,
190 ACPI_PARSE_OBJECT **op,
191 u32 *arg_list,
192 u32 *arg_count);
193
194 ACPI_STATUS
195 acpi_ps_push_scope (
196 ACPI_PARSE_STATE *parser_state,
197 ACPI_PARSE_OBJECT *op,
198 u32 remaining_args,
199 u32 arg_count);
200
201 void
202 acpi_ps_cleanup_scope (
203 ACPI_PARSE_STATE *state);
204
205
206 /* pstree - parse tree manipulation routines */
207
208 void
209 acpi_ps_append_arg(
210 ACPI_PARSE_OBJECT *op,
211 ACPI_PARSE_OBJECT *arg);
212
213 ACPI_PARSE_OBJECT*
214 acpi_ps_find (
215 ACPI_PARSE_OBJECT *scope,
216 NATIVE_CHAR *path,
217 u16 opcode,
218 u32 create);
219
220 ACPI_PARSE_OBJECT *
221 acpi_ps_get_arg(
222 ACPI_PARSE_OBJECT *op,
223 u32 argn);
224
225 ACPI_PARSE_OBJECT *
226 acpi_ps_get_child (
227 ACPI_PARSE_OBJECT *op);
228
229 ACPI_PARSE_OBJECT *
230 acpi_ps_get_depth_next (
231 ACPI_PARSE_OBJECT *origin,
232 ACPI_PARSE_OBJECT *op);
233
234
235 /* pswalk - parse tree walk routines */
236
237 ACPI_STATUS
238 acpi_ps_walk_parsed_aml (
239 ACPI_PARSE_OBJECT *start_op,
240 ACPI_PARSE_OBJECT *end_op,
241 ACPI_OPERAND_OBJECT *mth_desc,
242 ACPI_NAMESPACE_NODE *start_node,
243 ACPI_OPERAND_OBJECT **params,
244 ACPI_OPERAND_OBJECT **caller_return_desc,
245 ACPI_OWNER_ID owner_id,
246 ACPI_PARSE_DOWNWARDS descending_callback,
247 ACPI_PARSE_UPWARDS ascending_callback);
248
249 ACPI_STATUS
250 acpi_ps_get_next_walk_op (
251 ACPI_WALK_STATE *walk_state,
252 ACPI_PARSE_OBJECT *op,
253 ACPI_PARSE_UPWARDS ascending_callback);
254
255
256 /* psutils - parser utilities */
257
258
259 ACPI_PARSE_STATE *
260 acpi_ps_create_state (
261 u8 *aml,
262 u32 aml_size);
263
264 void
265 acpi_ps_init_op (
266 ACPI_PARSE_OBJECT *op,
267 u16 opcode);
268
269 ACPI_PARSE_OBJECT *
270 acpi_ps_alloc_op (
271 u16 opcode);
272
273 void
274 acpi_ps_free_op (
275 ACPI_PARSE_OBJECT *op);
276
277 void
278 acpi_ps_delete_parse_cache (
279 void);
280
281 u8
282 acpi_ps_is_leading_char (
283 u32 c);
284
285 u8
286 acpi_ps_is_prefix_char (
287 u32 c);
288
289 u8
290 acpi_ps_is_named_op (
291 u16 opcode);
292
293 u8
294 acpi_ps_is_node_op (
295 u16 opcode);
296
297 u8
298 acpi_ps_is_deferred_op (
299 u16 opcode);
300
301 u8
302 acpi_ps_is_bytelist_op(
303 u16 opcode);
304
305 u8
306 acpi_ps_is_field_op(
307 u16 opcode);
308
309 u8
310 acpi_ps_is_create_field_op (
311 u16 opcode);
312
313 ACPI_PARSE2_OBJECT*
314 acpi_ps_to_extended_op(
315 ACPI_PARSE_OBJECT *op);
316
317 u32
318 acpi_ps_get_name(
319 ACPI_PARSE_OBJECT *op);
320
321 void
322 acpi_ps_set_name(
323 ACPI_PARSE_OBJECT *op,
324 u32 name);
325
326
327 /* psdump - display parser tree */
328
329 u32
330 acpi_ps_sprint_path (
331 NATIVE_CHAR *buffer_start,
332 u32 buffer_size,
333 ACPI_PARSE_OBJECT *op);
334
335 u32
336 acpi_ps_sprint_op (
337 NATIVE_CHAR *buffer_start,
338 u32 buffer_size,
339 ACPI_PARSE_OBJECT *op);
340
341 void
342 acpi_ps_show (
343 ACPI_PARSE_OBJECT *op);
344
345
346 #endif /* __ACPARSER_H__ */