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