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