1/******************************************************************************
2 *
3 * Name: acinterp.h - Interpreter subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2007, 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#ifndef __ACINTERP_H__
45#define __ACINTERP_H__
46
47#define ACPI_WALK_OPERANDS          (&(walk_state->operands [walk_state->num_operands -1]))
48
49/* Macros for tables used for debug output */
50
51#define ACPI_EXD_OFFSET(f)          (u8) ACPI_OFFSET (union acpi_operand_object,f)
52#define ACPI_EXD_NSOFFSET(f)        (u8) ACPI_OFFSET (struct acpi_namespace_node,f)
53#define ACPI_EXD_TABLE_SIZE(name)   (sizeof(name) / sizeof (struct acpi_exdump_info))
54
55/*
56 * If possible, pack the following structures to byte alignment, since we
57 * don't care about performance for debug output. Two cases where we cannot
58 * pack the structures:
59 *
60 * 1) Hardware does not support misaligned memory transfers
61 * 2) Compiler does not support pointers within packed structures
62 */
63#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && \
64	!defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
65#pragma pack(1)
66#endif
67
68typedef const struct acpi_exdump_info {
69	u8 opcode;
70	u8 offset;
71	char *name;
72
73} acpi_exdump_info;
74
75/* Values for the Opcode field above */
76
77#define ACPI_EXD_INIT                   0
78#define ACPI_EXD_TYPE                   1
79#define ACPI_EXD_UINT8                  2
80#define ACPI_EXD_UINT16                 3
81#define ACPI_EXD_UINT32                 4
82#define ACPI_EXD_UINT64                 5
83#define ACPI_EXD_LITERAL                6
84#define ACPI_EXD_POINTER                7
85#define ACPI_EXD_ADDRESS                8
86#define ACPI_EXD_STRING                 9
87#define ACPI_EXD_BUFFER                 10
88#define ACPI_EXD_PACKAGE                11
89#define ACPI_EXD_FIELD                  12
90#define ACPI_EXD_REFERENCE              13
91
92/* restore default alignment */
93
94#pragma pack()
95
96/*
97 * exconvrt - object conversion
98 */
99acpi_status
100acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
101			   union acpi_operand_object **result_desc, u32 flags);
102
103acpi_status
104acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
105			  union acpi_operand_object **result_desc);
106
107acpi_status
108acpi_ex_convert_to_string(union acpi_operand_object *obj_desc,
109			  union acpi_operand_object **result_desc, u32 type);
110
111/* Types for ->String conversion */
112
113#define ACPI_EXPLICIT_BYTE_COPY         0x00000000
114#define ACPI_EXPLICIT_CONVERT_HEX       0x00000001
115#define ACPI_IMPLICIT_CONVERT_HEX       0x00000002
116#define ACPI_EXPLICIT_CONVERT_DECIMAL   0x00000003
117
118acpi_status
119acpi_ex_convert_to_target_type(acpi_object_type destination_type,
120			       union acpi_operand_object *source_desc,
121			       union acpi_operand_object **result_desc,
122			       struct acpi_walk_state *walk_state);
123
124/*
125 * exfield - ACPI AML (p-code) execution - field manipulation
126 */
127acpi_status
128acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
129			    u32 buffer_length, u32 * datum_count);
130
131acpi_status
132acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
133			       acpi_integer mask,
134			       acpi_integer field_value,
135			       u32 field_datum_byte_offset);
136
137void
138acpi_ex_get_buffer_datum(acpi_integer * datum,
139			 void *buffer,
140			 u32 buffer_length,
141			 u32 byte_granularity, u32 buffer_offset);
142
143void
144acpi_ex_set_buffer_datum(acpi_integer merged_datum,
145			 void *buffer,
146			 u32 buffer_length,
147			 u32 byte_granularity, u32 buffer_offset);
148
149acpi_status
150acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
151			     union acpi_operand_object *obj_desc,
152			     union acpi_operand_object **ret_buffer_desc);
153
154acpi_status
155acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
156			    union acpi_operand_object *obj_desc,
157			    union acpi_operand_object **result_desc);
158
159/*
160 * exfldio - low level field I/O
161 */
162acpi_status
163acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
164			   void *buffer, u32 buffer_length);
165
166acpi_status
167acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
168			  void *buffer, u32 buffer_length);
169
170acpi_status
171acpi_ex_access_region(union acpi_operand_object *obj_desc,
172		      u32 field_datum_byte_offset,
173		      acpi_integer * value, u32 read_write);
174
175/*
176 * exmisc - misc support routines
177 */
178acpi_status
179acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
180			     union acpi_operand_object **return_desc,
181			     struct acpi_walk_state *walk_state);
182
183acpi_status
184acpi_ex_concat_template(union acpi_operand_object *obj_desc,
185			union acpi_operand_object *obj_desc2,
186			union acpi_operand_object **actual_return_desc,
187			struct acpi_walk_state *walk_state);
188
189acpi_status
190acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
191		       union acpi_operand_object *obj_desc2,
192		       union acpi_operand_object **actual_return_desc,
193		       struct acpi_walk_state *walk_state);
194
195acpi_status
196acpi_ex_do_logical_numeric_op(u16 opcode,
197			      acpi_integer integer0,
198			      acpi_integer integer1, u8 * logical_result);
199
200acpi_status
201acpi_ex_do_logical_op(u16 opcode,
202		      union acpi_operand_object *operand0,
203		      union acpi_operand_object *operand1, u8 * logical_result);
204
205acpi_integer
206acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
207
208acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
209
210acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state);
211
212acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state);
213
214acpi_status
215acpi_ex_create_region(u8 * aml_start,
216		      u32 aml_length,
217		      u8 region_space, struct acpi_walk_state *walk_state);
218
219acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state);
220
221acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
222
223acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
224
225acpi_status
226acpi_ex_create_method(u8 * aml_start,
227		      u32 aml_length, struct acpi_walk_state *walk_state);
228
229/*
230 * exconfig - dynamic table load/unload
231 */
232acpi_status
233acpi_ex_load_op(union acpi_operand_object *obj_desc,
234		union acpi_operand_object *target,
235		struct acpi_walk_state *walk_state);
236
237acpi_status
238acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
239		      union acpi_operand_object **return_desc);
240
241acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle);
242
243/*
244 * exmutex - mutex support
245 */
246acpi_status
247acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
248		      union acpi_operand_object *obj_desc,
249		      struct acpi_walk_state *walk_state);
250
251acpi_status
252acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
253		      struct acpi_walk_state *walk_state);
254
255void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
256
257void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
258
259/*
260 * exprep - ACPI AML execution - prep utilities
261 */
262acpi_status
263acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
264				 u8 field_flags,
265				 u8 field_attribute,
266				 u32 field_bit_position, u32 field_bit_length);
267
268acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info);
269
270/*
271 * exsystem - Interface to OS services
272 */
273acpi_status
274acpi_ex_system_do_notify_op(union acpi_operand_object *value,
275			    union acpi_operand_object *obj_desc);
276
277acpi_status acpi_ex_system_do_suspend(acpi_integer time);
278
279acpi_status acpi_ex_system_do_stall(u32 time);
280
281acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc);
282
283acpi_status
284acpi_ex_system_wait_event(union acpi_operand_object *time,
285			  union acpi_operand_object *obj_desc);
286
287acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
288
289acpi_status
290acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
291
292acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
293
294/*
295 * exoparg1 - ACPI AML execution, 1 operand
296 */
297acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state);
298
299acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state);
300
301acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state);
302
303acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state);
304
305acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state);
306
307/*
308 * exoparg2 - ACPI AML execution, 2 operands
309 */
310acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state);
311
312acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state);
313
314acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state);
315
316acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state);
317
318/*
319 * exoparg3 - ACPI AML execution, 3 operands
320 */
321acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state);
322
323acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state);
324
325/*
326 * exoparg6 - ACPI AML execution, 6 operands
327 */
328acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state);
329
330/*
331 * exresolv - Object resolution and get value functions
332 */
333acpi_status
334acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
335			 struct acpi_walk_state *walk_state);
336
337acpi_status
338acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
339			 union acpi_operand_object *operand,
340			 acpi_object_type * return_type,
341			 union acpi_operand_object **return_desc);
342
343/*
344 * exresnte - resolve namespace node
345 */
346acpi_status
347acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr,
348			      struct acpi_walk_state *walk_state);
349
350/*
351 * exresop - resolve operand to value
352 */
353acpi_status
354acpi_ex_resolve_operands(u16 opcode,
355			 union acpi_operand_object **stack_ptr,
356			 struct acpi_walk_state *walk_state);
357
358/*
359 * exdump - Interpreter debug output routines
360 */
361void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth);
362
363void
364acpi_ex_dump_operands(union acpi_operand_object **operands,
365		      acpi_interpreter_mode interpreter_mode,
366		      char *ident,
367		      u32 num_levels,
368		      char *note, char *module_name, u32 line_number);
369
370#ifdef	ACPI_FUTURE_USAGE
371void
372acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
373
374void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
375#endif				/* ACPI_FUTURE_USAGE */
376
377/*
378 * exnames - AML namestring support
379 */
380acpi_status
381acpi_ex_get_name_string(acpi_object_type data_type,
382			u8 * in_aml_address,
383			char **out_name_string, u32 * out_name_length);
384
385/*
386 * exstore - Object store support
387 */
388acpi_status
389acpi_ex_store(union acpi_operand_object *val_desc,
390	      union acpi_operand_object *dest_desc,
391	      struct acpi_walk_state *walk_state);
392
393acpi_status
394acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
395			     struct acpi_namespace_node *node,
396			     struct acpi_walk_state *walk_state,
397			     u8 implicit_conversion);
398
399#define ACPI_IMPLICIT_CONVERSION        TRUE
400#define ACPI_NO_IMPLICIT_CONVERSION     FALSE
401
402/*
403 * exstoren - resolve/store object
404 */
405acpi_status
406acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
407		       acpi_object_type target_type,
408		       struct acpi_walk_state *walk_state);
409
410acpi_status
411acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
412			       union acpi_operand_object *dest_desc,
413			       union acpi_operand_object **new_desc,
414			       struct acpi_walk_state *walk_state);
415
416/*
417 * exstorob - store object - buffer/string
418 */
419acpi_status
420acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
421			       union acpi_operand_object *target_desc);
422
423acpi_status
424acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
425			       union acpi_operand_object *target_desc);
426
427/*
428 * excopy - object copy
429 */
430acpi_status
431acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc,
432				    union acpi_operand_object *target_desc);
433
434acpi_status
435acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc,
436				   union acpi_operand_object *target_desc);
437
438acpi_status
439acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc,
440				 struct acpi_namespace_node *node);
441
442acpi_status
443acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc,
444				     union acpi_operand_object *target_desc);
445
446/*
447 * exutils - interpreter/scanner utilities
448 */
449void acpi_ex_enter_interpreter(void);
450
451void acpi_ex_exit_interpreter(void);
452
453void acpi_ex_reacquire_interpreter(void);
454
455void acpi_ex_relinquish_interpreter(void);
456
457void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
458
459u8 acpi_ex_acquire_global_lock(u32 rule);
460
461void acpi_ex_release_global_lock(u8 locked);
462
463void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string);
464
465void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string);
466
467/*
468 * exregion - default op_region handlers
469 */
470acpi_status
471acpi_ex_system_memory_space_handler(u32 function,
472				    acpi_physical_address address,
473				    u32 bit_width,
474				    acpi_integer * value,
475				    void *handler_context,
476				    void *region_context);
477
478acpi_status
479acpi_ex_system_io_space_handler(u32 function,
480				acpi_physical_address address,
481				u32 bit_width,
482				acpi_integer * value,
483				void *handler_context, void *region_context);
484
485acpi_status
486acpi_ex_pci_config_space_handler(u32 function,
487				 acpi_physical_address address,
488				 u32 bit_width,
489				 acpi_integer * value,
490				 void *handler_context, void *region_context);
491
492acpi_status
493acpi_ex_cmos_space_handler(u32 function,
494			   acpi_physical_address address,
495			   u32 bit_width,
496			   acpi_integer * value,
497			   void *handler_context, void *region_context);
498
499acpi_status
500acpi_ex_pci_bar_space_handler(u32 function,
501			      acpi_physical_address address,
502			      u32 bit_width,
503			      acpi_integer * value,
504			      void *handler_context, void *region_context);
505
506acpi_status
507acpi_ex_embedded_controller_space_handler(u32 function,
508					  acpi_physical_address address,
509					  u32 bit_width,
510					  acpi_integer * value,
511					  void *handler_context,
512					  void *region_context);
513
514acpi_status
515acpi_ex_sm_bus_space_handler(u32 function,
516			     acpi_physical_address address,
517			     u32 bit_width,
518			     acpi_integer * value,
519			     void *handler_context, void *region_context);
520
521acpi_status
522acpi_ex_data_table_space_handler(u32 function,
523				 acpi_physical_address address,
524				 u32 bit_width,
525				 acpi_integer * value,
526				 void *handler_context, void *region_context);
527
528#endif				/* __INTERP_H__ */
529