File: /usr/src/linux/drivers/acpi/include/acparser.h
1 /******************************************************************************
2 *
3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4 * $Revision: 51 $
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 *
66 * Parser interfaces
67 *
68 *****************************************************************************/
69
70
71 /* psargs - Parse AML opcode arguments */
72
73 u8 *
74 acpi_ps_get_next_package_end (
75 acpi_parse_state *parser_state);
76
77 u32
78 acpi_ps_get_next_package_length (
79 acpi_parse_state *parser_state);
80
81 NATIVE_CHAR *
82 acpi_ps_get_next_namestring (
83 acpi_parse_state *parser_state);
84
85 void
86 acpi_ps_get_next_simple_arg (
87 acpi_parse_state *parser_state,
88 u32 arg_type, /* type of argument */
89 acpi_parse_object *arg); /* (OUT) argument data */
90
91 void
92 acpi_ps_get_next_namepath (
93 acpi_parse_state *parser_state,
94 acpi_parse_object *arg,
95 u32 *arg_count,
96 u8 method_call);
97
98 acpi_parse_object *
99 acpi_ps_get_next_field (
100 acpi_parse_state *parser_state);
101
102 acpi_parse_object *
103 acpi_ps_get_next_arg (
104 acpi_parse_state *parser_state,
105 u32 arg_type,
106 u32 *arg_count);
107
108
109 /* psopcode - AML Opcode information */
110
111 const acpi_opcode_info *
112 acpi_ps_get_opcode_info (
113 u16 opcode);
114
115 NATIVE_CHAR *
116 acpi_ps_get_opcode_name (
117 u16 opcode);
118
119
120 /* psparse - top level parsing routines */
121
122 acpi_status
123 acpi_ps_find_object (
124 u16 opcode,
125 acpi_parse_object *op,
126 acpi_walk_state *walk_state,
127 acpi_parse_object **out_op);
128
129 void
130 acpi_ps_delete_parse_tree (
131 acpi_parse_object *root);
132
133 acpi_status
134 acpi_ps_parse_loop (
135 acpi_walk_state *walk_state);
136
137 acpi_status
138 acpi_ps_parse_aml (
139 acpi_parse_object *start_scope,
140 u8 *aml,
141 u32 aml_size,
142 u32 parse_flags,
143 acpi_namespace_node *method_node,
144 acpi_operand_object **params,
145 acpi_operand_object **caller_return_desc,
146 acpi_parse_downwards descending_callback,
147 acpi_parse_upwards ascending_callback);
148
149 acpi_status
150 acpi_ps_parse_table (
151 u8 *aml,
152 u32 aml_size,
153 acpi_parse_downwards descending_callback,
154 acpi_parse_upwards ascending_callback,
155 acpi_parse_object **root_object);
156
157 u16
158 acpi_ps_peek_opcode (
159 acpi_parse_state *state);
160
161
162 /* psscope - Scope stack management routines */
163
164
165 acpi_status
166 acpi_ps_init_scope (
167 acpi_parse_state *parser_state,
168 acpi_parse_object *root);
169
170 acpi_parse_object *
171 acpi_ps_get_parent_scope (
172 acpi_parse_state *state);
173
174 u8
175 acpi_ps_has_completed_scope (
176 acpi_parse_state *parser_state);
177
178 void
179 acpi_ps_pop_scope (
180 acpi_parse_state *parser_state,
181 acpi_parse_object **op,
182 u32 *arg_list,
183 u32 *arg_count);
184
185 acpi_status
186 acpi_ps_push_scope (
187 acpi_parse_state *parser_state,
188 acpi_parse_object *op,
189 u32 remaining_args,
190 u32 arg_count);
191
192 void
193 acpi_ps_cleanup_scope (
194 acpi_parse_state *state);
195
196
197 /* pstree - parse tree manipulation routines */
198
199 void
200 acpi_ps_append_arg(
201 acpi_parse_object *op,
202 acpi_parse_object *arg);
203
204 acpi_parse_object*
205 acpi_ps_find (
206 acpi_parse_object *scope,
207 NATIVE_CHAR *path,
208 u16 opcode,
209 u32 create);
210
211 acpi_parse_object *
212 acpi_ps_get_arg(
213 acpi_parse_object *op,
214 u32 argn);
215
216 acpi_parse_object *
217 acpi_ps_get_child (
218 acpi_parse_object *op);
219
220 acpi_parse_object *
221 acpi_ps_get_depth_next (
222 acpi_parse_object *origin,
223 acpi_parse_object *op);
224
225
226 /* pswalk - parse tree walk routines */
227
228 acpi_status
229 acpi_ps_walk_parsed_aml (
230 acpi_parse_object *start_op,
231 acpi_parse_object *end_op,
232 acpi_operand_object *mth_desc,
233 acpi_namespace_node *start_node,
234 acpi_operand_object **params,
235 acpi_operand_object **caller_return_desc,
236 acpi_owner_id owner_id,
237 acpi_parse_downwards descending_callback,
238 acpi_parse_upwards ascending_callback);
239
240 acpi_status
241 acpi_ps_get_next_walk_op (
242 acpi_walk_state *walk_state,
243 acpi_parse_object *op,
244 acpi_parse_upwards ascending_callback);
245
246
247 /* psutils - parser utilities */
248
249
250 acpi_parse_state *
251 acpi_ps_create_state (
252 u8 *aml,
253 u32 aml_size);
254
255 void
256 acpi_ps_init_op (
257 acpi_parse_object *op,
258 u16 opcode);
259
260 acpi_parse_object *
261 acpi_ps_alloc_op (
262 u16 opcode);
263
264 void
265 acpi_ps_free_op (
266 acpi_parse_object *op);
267
268 void
269 acpi_ps_delete_parse_cache (
270 void);
271
272 u8
273 acpi_ps_is_leading_char (
274 u32 c);
275
276 u8
277 acpi_ps_is_prefix_char (
278 u32 c);
279
280 u32
281 acpi_ps_get_name(
282 acpi_parse_object *op);
283
284 void
285 acpi_ps_set_name(
286 acpi_parse_object *op,
287 u32 name);
288
289
290 /* psdump - display parser tree */
291
292 u32
293 acpi_ps_sprint_path (
294 NATIVE_CHAR *buffer_start,
295 u32 buffer_size,
296 acpi_parse_object *op);
297
298 u32
299 acpi_ps_sprint_op (
300 NATIVE_CHAR *buffer_start,
301 u32 buffer_size,
302 acpi_parse_object *op);
303
304 void
305 acpi_ps_show (
306 acpi_parse_object *op);
307
308
309 #endif /* __ACPARSER_H__ */
310