1 /******************************************************************************
2  *
3  * Name: acdispat.h - dispatcher (parser to interpreter interface)
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2004, 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 _ACDISPAT_H_
46 #define _ACDISPAT_H_
47 
48 
49 #define NAMEOF_LOCAL_NTE    "__L0"
50 #define NAMEOF_ARG_NTE      "__A0"
51 
52 
53 /* Common interfaces */
54 
55 acpi_status
56 acpi_ds_obj_stack_push (
57 	void                            *object,
58 	struct acpi_walk_state          *walk_state);
59 
60 acpi_status
61 acpi_ds_obj_stack_pop (
62 	u32                             pop_count,
63 	struct acpi_walk_state          *walk_state);
64 
65 void *
66 acpi_ds_obj_stack_get_value (
67 	u32                             index,
68 	struct acpi_walk_state          *walk_state);
69 
70 acpi_status
71 acpi_ds_obj_stack_pop_object (
72 	union acpi_operand_object       **object,
73 	struct acpi_walk_state          *walk_state);
74 
75 
76 /* dsopcode - support for late evaluation */
77 
78 acpi_status
79 acpi_ds_execute_arguments (
80 	struct acpi_namespace_node      *node,
81 	struct acpi_namespace_node      *scope_node,
82 	u32                             aml_length,
83 	u8                              *aml_start);
84 
85 acpi_status
86 acpi_ds_get_buffer_field_arguments (
87 	union acpi_operand_object       *obj_desc);
88 
89 acpi_status
90 acpi_ds_get_region_arguments (
91 	union acpi_operand_object       *rgn_desc);
92 
93 acpi_status
94 acpi_ds_get_buffer_arguments (
95 	union acpi_operand_object       *obj_desc);
96 
97 acpi_status
98 acpi_ds_get_package_arguments (
99 	union acpi_operand_object       *obj_desc);
100 
101 acpi_status
102 acpi_ds_init_buffer_field (
103 	u16                             aml_opcode,
104 	union acpi_operand_object       *obj_desc,
105 	union acpi_operand_object       *buffer_desc,
106 	union acpi_operand_object       *offset_desc,
107 	union acpi_operand_object       *length_desc,
108 	union acpi_operand_object       *result_desc);
109 
110 acpi_status
111 acpi_ds_eval_buffer_field_operands (
112 	struct acpi_walk_state          *walk_state,
113 	union acpi_parse_object         *op);
114 
115 acpi_status
116 acpi_ds_eval_region_operands (
117 	struct acpi_walk_state          *walk_state,
118 	union acpi_parse_object         *op);
119 
120 acpi_status
121 acpi_ds_eval_data_object_operands (
122 	struct acpi_walk_state          *walk_state,
123 	union acpi_parse_object         *op,
124 	union acpi_operand_object       *obj_desc);
125 
126 acpi_status
127 acpi_ds_initialize_region (
128 	acpi_handle                     obj_handle);
129 
130 
131 /* dsctrl - Parser/Interpreter interface, control stack routines */
132 
133 
134 acpi_status
135 acpi_ds_exec_begin_control_op (
136 	struct acpi_walk_state          *walk_state,
137 	union acpi_parse_object         *op);
138 
139 acpi_status
140 acpi_ds_exec_end_control_op (
141 	struct acpi_walk_state          *walk_state,
142 	union acpi_parse_object         *op);
143 
144 
145 /* dsexec - Parser/Interpreter interface, method execution callbacks */
146 
147 
148 acpi_status
149 acpi_ds_get_predicate_value (
150 	struct acpi_walk_state          *walk_state,
151 	union acpi_operand_object       *result_obj);
152 
153 acpi_status
154 acpi_ds_exec_begin_op (
155 	struct acpi_walk_state          *walk_state,
156 	union acpi_parse_object         **out_op);
157 
158 acpi_status
159 acpi_ds_exec_end_op (
160 	struct acpi_walk_state          *state);
161 
162 
163 /* dsfield - Parser/Interpreter interface for AML fields */
164 
165 acpi_status
166 acpi_ds_get_field_names (
167 	struct acpi_create_field_info   *info,
168 	struct acpi_walk_state          *walk_state,
169 	union acpi_parse_object         *arg);
170 
171 acpi_status
172 acpi_ds_create_field (
173 	union acpi_parse_object         *op,
174 	struct acpi_namespace_node      *region_node,
175 	struct acpi_walk_state          *walk_state);
176 
177 acpi_status
178 acpi_ds_create_bank_field (
179 	union acpi_parse_object         *op,
180 	struct acpi_namespace_node      *region_node,
181 	struct acpi_walk_state          *walk_state);
182 
183 acpi_status
184 acpi_ds_create_index_field (
185 	union acpi_parse_object         *op,
186 	struct acpi_namespace_node      *region_node,
187 	struct acpi_walk_state          *walk_state);
188 
189 acpi_status
190 acpi_ds_create_buffer_field (
191 	union acpi_parse_object         *op,
192 	struct acpi_walk_state          *walk_state);
193 
194 acpi_status
195 acpi_ds_init_field_objects (
196 	union acpi_parse_object         *op,
197 	struct acpi_walk_state          *walk_state);
198 
199 
200 /* dsload - Parser/Interpreter interface, namespace load callbacks */
201 
202 acpi_status
203 acpi_ds_load1_begin_op (
204 	struct acpi_walk_state          *walk_state,
205 	union acpi_parse_object         **out_op);
206 
207 acpi_status
208 acpi_ds_load1_end_op (
209 	struct acpi_walk_state          *walk_state);
210 
211 acpi_status
212 acpi_ds_load2_begin_op (
213 	struct acpi_walk_state          *walk_state,
214 	union acpi_parse_object         **out_op);
215 
216 acpi_status
217 acpi_ds_load2_end_op (
218 	struct acpi_walk_state          *walk_state);
219 
220 acpi_status
221 acpi_ds_init_callbacks (
222 	struct acpi_walk_state          *walk_state,
223 	u32                             pass_number);
224 
225 
226 /* dsmthdat - method data (locals/args) */
227 
228 
229 acpi_status
230 acpi_ds_store_object_to_local (
231 	u16                             opcode,
232 	u32                             index,
233 	union acpi_operand_object       *src_desc,
234 	struct acpi_walk_state          *walk_state);
235 
236 acpi_status
237 acpi_ds_method_data_get_entry (
238 	u16                             opcode,
239 	u32                             index,
240 	struct acpi_walk_state          *walk_state,
241 	union acpi_operand_object       ***node);
242 
243 void
244 acpi_ds_method_data_delete_all (
245 	struct acpi_walk_state          *walk_state);
246 
247 u8
248 acpi_ds_is_method_value (
249 	union acpi_operand_object       *obj_desc);
250 
251 acpi_object_type
252 acpi_ds_method_data_get_type (
253 	u16                             opcode,
254 	u32                             index,
255 	struct acpi_walk_state          *walk_state);
256 
257 acpi_status
258 acpi_ds_method_data_get_value (
259 	u16                             opcode,
260 	u32                             index,
261 	struct acpi_walk_state          *walk_state,
262 	union acpi_operand_object       **dest_desc);
263 
264 void
265 acpi_ds_method_data_delete_value (
266 	u16                             opcode,
267 	u32                             index,
268 	struct acpi_walk_state          *walk_state);
269 
270 acpi_status
271 acpi_ds_method_data_init_args (
272 	union acpi_operand_object       **params,
273 	u32                             max_param_count,
274 	struct acpi_walk_state          *walk_state);
275 
276 acpi_status
277 acpi_ds_method_data_get_node (
278 	u16                             opcode,
279 	u32                             index,
280 	struct acpi_walk_state          *walk_state,
281 	struct acpi_namespace_node      **node);
282 
283 void
284 acpi_ds_method_data_init (
285 	struct acpi_walk_state          *walk_state);
286 
287 acpi_status
288 acpi_ds_method_data_set_value (
289 	u16                             opcode,
290 	u32                             index,
291 	union acpi_operand_object       *object,
292 	struct acpi_walk_state          *walk_state);
293 
294 
295 /* dsmethod - Parser/Interpreter interface - control method parsing */
296 
297 acpi_status
298 acpi_ds_parse_method (
299 	acpi_handle                     obj_handle);
300 
301 acpi_status
302 acpi_ds_call_control_method (
303 	struct acpi_thread_state        *thread,
304 	struct acpi_walk_state          *walk_state,
305 	union acpi_parse_object         *op);
306 
307 acpi_status
308 acpi_ds_restart_control_method (
309 	struct acpi_walk_state          *walk_state,
310 	union acpi_operand_object       *return_desc);
311 
312 acpi_status
313 acpi_ds_terminate_control_method (
314 	struct acpi_walk_state          *walk_state);
315 
316 acpi_status
317 acpi_ds_begin_method_execution (
318 	struct acpi_namespace_node      *method_node,
319 	union acpi_operand_object       *obj_desc,
320 	struct acpi_namespace_node      *calling_method_node);
321 
322 
323 /* dsobj - Parser/Interpreter interface - object initialization and conversion */
324 
325 acpi_status
326 acpi_ds_init_one_object (
327 	acpi_handle                     obj_handle,
328 	u32                             level,
329 	void                            *context,
330 	void                            **return_value);
331 
332 acpi_status
333 acpi_ds_initialize_objects (
334 	struct acpi_table_desc          *table_desc,
335 	struct acpi_namespace_node      *start_node);
336 
337 acpi_status
338 acpi_ds_build_internal_buffer_obj (
339 	struct acpi_walk_state          *walk_state,
340 	union acpi_parse_object         *op,
341 	u32                             buffer_length,
342 	union acpi_operand_object       **obj_desc_ptr);
343 
344 acpi_status
345 acpi_ds_build_internal_package_obj (
346 	struct acpi_walk_state          *walk_state,
347 	union acpi_parse_object         *op,
348 	u32                             package_length,
349 	union acpi_operand_object       **obj_desc);
350 
351 acpi_status
352 acpi_ds_build_internal_object (
353 	struct acpi_walk_state          *walk_state,
354 	union acpi_parse_object         *op,
355 	union acpi_operand_object       **obj_desc_ptr);
356 
357 acpi_status
358 acpi_ds_init_object_from_op (
359 	struct acpi_walk_state          *walk_state,
360 	union acpi_parse_object         *op,
361 	u16                             opcode,
362 	union acpi_operand_object       **obj_desc);
363 
364 acpi_status
365 acpi_ds_create_node (
366 	struct acpi_walk_state          *walk_state,
367 	struct acpi_namespace_node      *node,
368 	union acpi_parse_object         *op);
369 
370 
371 /* dsutils - Parser/Interpreter interface utility routines */
372 
373 u8
374 acpi_ds_is_result_used (
375 	union acpi_parse_object         *op,
376 	struct acpi_walk_state          *walk_state);
377 
378 void
379 acpi_ds_delete_result_if_not_used (
380 	union acpi_parse_object         *op,
381 	union acpi_operand_object       *result_obj,
382 	struct acpi_walk_state          *walk_state);
383 
384 acpi_status
385 acpi_ds_create_operand (
386 	struct acpi_walk_state          *walk_state,
387 	union acpi_parse_object         *arg,
388 	u32                             args_remaining);
389 
390 acpi_status
391 acpi_ds_create_operands (
392 	struct acpi_walk_state          *walk_state,
393 	union acpi_parse_object         *first_arg);
394 
395 acpi_status
396 acpi_ds_resolve_operands (
397 	struct acpi_walk_state          *walk_state);
398 
399 void
400 acpi_ds_clear_operands (
401 	struct acpi_walk_state          *walk_state);
402 
403 
404 /*
405  * dswscope - Scope Stack manipulation
406  */
407 
408 acpi_status
409 acpi_ds_scope_stack_push (
410 	struct acpi_namespace_node      *node,
411 	acpi_object_type                type,
412 	struct acpi_walk_state          *walk_state);
413 
414 
415 acpi_status
416 acpi_ds_scope_stack_pop (
417 	struct acpi_walk_state          *walk_state);
418 
419 void
420 acpi_ds_scope_stack_clear (
421 	struct acpi_walk_state          *walk_state);
422 
423 
424 /* dswstate - parser WALK_STATE management routines */
425 
426 struct acpi_walk_state *
427 acpi_ds_create_walk_state (
428 	acpi_owner_id                   owner_id,
429 	union acpi_parse_object         *origin,
430 	union acpi_operand_object       *mth_desc,
431 	struct acpi_thread_state        *thread);
432 
433 acpi_status
434 acpi_ds_init_aml_walk (
435 	struct acpi_walk_state          *walk_state,
436 	union acpi_parse_object         *op,
437 	struct acpi_namespace_node      *method_node,
438 	u8                              *aml_start,
439 	u32                             aml_length,
440 	union acpi_operand_object       **params,
441 	union acpi_operand_object       **return_obj_desc,
442 	u32                             pass_number);
443 
444 acpi_status
445 acpi_ds_obj_stack_delete_all (
446 	struct acpi_walk_state          *walk_state);
447 
448 acpi_status
449 acpi_ds_obj_stack_pop_and_delete (
450 	u32                             pop_count,
451 	struct acpi_walk_state          *walk_state);
452 
453 void
454 acpi_ds_delete_walk_state (
455 	struct acpi_walk_state          *walk_state);
456 
457 struct acpi_walk_state *
458 acpi_ds_pop_walk_state (
459 	struct acpi_thread_state        *thread);
460 
461 void
462 acpi_ds_push_walk_state (
463 	struct acpi_walk_state          *walk_state,
464 	struct acpi_thread_state        *thread);
465 
466 acpi_status
467 acpi_ds_result_stack_pop (
468 	struct acpi_walk_state          *walk_state);
469 
470 acpi_status
471 acpi_ds_result_stack_push (
472 	struct acpi_walk_state          *walk_state);
473 
474 acpi_status
475 acpi_ds_result_stack_clear (
476 	struct acpi_walk_state          *walk_state);
477 
478 struct acpi_walk_state *
479 acpi_ds_get_current_walk_state (
480 	struct acpi_thread_state        *thread);
481 
482 void
483 acpi_ds_delete_walk_state_cache (
484 	void);
485 
486 acpi_status
487 acpi_ds_result_insert (
488 	void                            *object,
489 	u32                             index,
490 	struct acpi_walk_state          *walk_state);
491 
492 acpi_status
493 acpi_ds_result_remove (
494 	union acpi_operand_object       **object,
495 	u32                             index,
496 	struct acpi_walk_state          *walk_state);
497 
498 acpi_status
499 acpi_ds_result_pop (
500 	union acpi_operand_object       **object,
501 	struct acpi_walk_state          *walk_state);
502 
503 acpi_status
504 acpi_ds_result_push (
505 	union acpi_operand_object       *object,
506 	struct acpi_walk_state          *walk_state);
507 
508 acpi_status
509 acpi_ds_result_pop_from_bottom (
510 	union acpi_operand_object       **object,
511 	struct acpi_walk_state          *walk_state);
512 
513 #endif /* _ACDISPAT_H_ */
514