summaryrefslogtreecommitdiffstats
path: root/include/acpi/acparser.h
blob: c0395ef2b0d0602be9907e21fc04fb120398905f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/******************************************************************************
 *
 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
 *
 *****************************************************************************/

/*
 * Copyright (C) 2000 - 2005, R. Byron Moore
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    substantially similar to the "NO WARRANTY" disclaimer below
 *    ("Disclaimer") and any redistribution must be conditioned upon
 *    including a substantially similar Disclaimer requirement for further
 *    binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 */


#ifndef __ACPARSER_H__
#define __ACPARSER_H__


#define OP_HAS_RETURN_VALUE             1

/* variable # arguments */

#define ACPI_VAR_ARGS                   ACPI_UINT32_MAX


#define ACPI_PARSE_DELETE_TREE          0x0001
#define ACPI_PARSE_NO_TREE_DELETE       0x0000
#define ACPI_PARSE_TREE_MASK            0x0001

#define ACPI_PARSE_LOAD_PASS1           0x0010
#define ACPI_PARSE_LOAD_PASS2           0x0020
#define ACPI_PARSE_EXECUTE              0x0030
#define ACPI_PARSE_MODE_MASK            0x0030

#define ACPI_PARSE_DEFERRED_OP          0x0100

/* Parser external interfaces */

acpi_status
acpi_psx_load_table (
	u8                              *pcode_addr,
	u32                             pcode_length);

acpi_status
acpi_psx_execute (
	struct acpi_parameter_info      *info);


/******************************************************************************
 *
 * Parser interfaces
 *
 *****************************************************************************/


/* psargs - Parse AML opcode arguments */

u8 *
acpi_ps_get_next_package_end (
	struct acpi_parse_state         *parser_state);

u32
acpi_ps_get_next_package_length (
	struct acpi_parse_state         *parser_state);

char *
acpi_ps_get_next_namestring (
	struct acpi_parse_state         *parser_state);

void
acpi_ps_get_next_simple_arg (
	struct acpi_parse_state         *parser_state,
	u32                             arg_type,
	union acpi_parse_object         *arg);

acpi_status
acpi_ps_get_next_namepath (
	struct acpi_walk_state          *walk_state,
	struct acpi_parse_state         *parser_state,
	union acpi_parse_object         *arg,
	u8                              method_call);

union acpi_parse_object *
acpi_ps_get_next_field (
	struct acpi_parse_state         *parser_state);

acpi_status
acpi_ps_get_next_arg (
	struct acpi_walk_state          *walk_state,
	struct acpi_parse_state         *parser_state,
	u32                             arg_type,
	union acpi_parse_object         **return_arg);


/* psfind */

union acpi_parse_object *
acpi_ps_find_name (
	union acpi_parse_object         *scope,
	u32                             name,
	u32                             opcode);

union acpi_parse_object*
acpi_ps_get_parent (
	union acpi_parse_object         *op);


/* psopcode - AML Opcode information */

const struct acpi_opcode_info *
acpi_ps_get_opcode_info (
	u16                             opcode);

char *
acpi_ps_get_opcode_name (
	u16                             opcode);


/* psparse - top level parsing routines */

u32
acpi_ps_get_opcode_size (
	u32                             opcode);

void
acpi_ps_complete_this_op (
	struct acpi_walk_state          *walk_state,
	union acpi_parse_object         *op);

acpi_status
acpi_ps_next_parse_state (
	struct acpi_walk_state          *walk_state,
	union acpi_parse_object         *op,
	acpi_status                     callback_status);

acpi_status
acpi_ps_find_object (
	struct acpi_walk_state          *walk_state,
	union acpi_parse_object         **out_op);

void
acpi_ps_delete_parse_tree (
	union acpi_parse_object         *root);

acpi_status
acpi_ps_parse_loop (
	struct acpi_walk_state          *walk_state);

acpi_status
acpi_ps_parse_aml (
	struct acpi_walk_state          *walk_state);

acpi_status
acpi_ps_parse_table (
	u8                              *aml,
	u32                             aml_size,
	acpi_parse_downwards            descending_callback,
	acpi_parse_upwards              ascending_callback,
	union acpi_parse_object         **root_object);

u16
acpi_ps_peek_opcode (
	struct acpi_parse_state         *state);


/* psscope - Scope stack management routines */


acpi_status
acpi_ps_init_scope (
	struct acpi_parse_state         *parser_state,
	union acpi_parse_object         *root);

union acpi_parse_object *
acpi_ps_get_parent_scope (
	struct acpi_parse_state         *state);

u8
acpi_ps_has_completed_scope (
	struct acpi_parse_state         *parser_state);

void
acpi_ps_pop_scope (
	struct acpi_parse_state         *parser_state,
	union acpi_parse_object         **op,
	u32                             *arg_list,
	u32                             *arg_count);

acpi_status
acpi_ps_push_scope (
	struct acpi_parse_state         *parser_state,
	union acpi_parse_object         *op,
	u32                             remaining_args,
	u32                             arg_count);

void
acpi_ps_cleanup_scope (
	struct acpi_parse_state         *state);


/* pstree - parse tree manipulation routines */

void
acpi_ps_append_arg(
	union acpi_parse_object         *op,
	union acpi_parse_object         *arg);

union acpi_parse_object*
acpi_ps_find (
	union acpi_parse_object         *scope,
	char                            *path,
	u16                             opcode,
	u32                             create);

union acpi_parse_object *
acpi_ps_get_arg(
	union acpi_parse_object         *op,
	u32                              argn);

#ifdef ACPI_FUTURE_USAGE
union acpi_parse_object *
acpi_ps_get_child (
	union acpi_parse_object         *op);

union acpi_parse_object *
acpi_ps_get_depth_next (
	union acpi_parse_object         *origin,
	union acpi_parse_object         *op);
#endif  /*  ACPI_FUTURE_USAGE  */


/* pswalk - parse tree walk routines */

acpi_status
acpi_ps_walk_parsed_aml (
	union acpi_parse_object         *start_op,
	union acpi_parse_object         *end_op,
	union acpi_operand_object       *mth_desc,
	struct acpi_namespace_node      *start_node,
	union acpi_operand_object       **params,
	union acpi_operand_object       **caller_return_desc,
	acpi_owner_id                   owner_id,
	acpi_parse_downwards            descending_callback,
	acpi_parse_upwards              ascending_callback);

acpi_status
acpi_ps_get_next_walk_op (
	struct acpi_walk_state          *walk_state,
	union acpi_parse_object         *op,
	acpi_parse_upwards              ascending_callback);

acpi_status
acpi_ps_delete_completed_op (
	struct acpi_walk_state          *walk_state);


/* psutils - parser utilities */

union acpi_parse_object *
acpi_ps_create_scope_op (
	void);

void
acpi_ps_init_op (
	union acpi_parse_object         *op,
	u16                             opcode);

union acpi_parse_object *
acpi_ps_alloc_op (
	u16                             opcode);

void
acpi_ps_free_op (
	union acpi_parse_object         *op);

#ifdef ACPI_ENABLE_OBJECT_CACHE
void
acpi_ps_delete_parse_cache (
	void);
#endif

u8
acpi_ps_is_leading_char (
	u32                             c);

u8
acpi_ps_is_prefix_char (
	u32                             c);

#ifdef ACPI_FUTURE_USAGE
u32
acpi_ps_get_name(
	union acpi_parse_object         *op);
#endif

void
acpi_ps_set_name(
	union acpi_parse_object         *op,
	u32                             name);


/* psdump - display parser tree */

u32
acpi_ps_sprint_path (
	char                            *buffer_start,
	u32                             buffer_size,
	union acpi_parse_object         *op);

u32
acpi_ps_sprint_op (
	char                            *buffer_start,
	u32                             buffer_size,
	union acpi_parse_object         *op);

void
acpi_ps_show (
	union acpi_parse_object         *op);


#endif /* __ACPARSER_H__ */
OpenPOWER on IntegriCloud