acinterp.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /******************************************************************************
  2. *
  3. * Name: acinterp.h - Interpreter subcomponent prototypes and defines
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #ifndef __ACINTERP_H__
  43. #define __ACINTERP_H__
  44. #define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
  45. /* Macros for tables used for debug output */
  46. #define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f)
  47. #define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f)
  48. #define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info))
  49. /*
  50. * If possible, pack the following structures to byte alignment, since we
  51. * don't care about performance for debug output. Two cases where we cannot
  52. * pack the structures:
  53. *
  54. * 1) Hardware does not support misaligned memory transfers
  55. * 2) Compiler does not support pointers within packed structures
  56. */
  57. #if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
  58. #pragma pack(1)
  59. #endif
  60. typedef const struct acpi_exdump_info {
  61. u8 opcode;
  62. u8 offset;
  63. char *name;
  64. } acpi_exdump_info;
  65. /* Values for the Opcode field above */
  66. #define ACPI_EXD_INIT 0
  67. #define ACPI_EXD_TYPE 1
  68. #define ACPI_EXD_UINT8 2
  69. #define ACPI_EXD_UINT16 3
  70. #define ACPI_EXD_UINT32 4
  71. #define ACPI_EXD_UINT64 5
  72. #define ACPI_EXD_LITERAL 6
  73. #define ACPI_EXD_POINTER 7
  74. #define ACPI_EXD_ADDRESS 8
  75. #define ACPI_EXD_STRING 9
  76. #define ACPI_EXD_BUFFER 10
  77. #define ACPI_EXD_PACKAGE 11
  78. #define ACPI_EXD_FIELD 12
  79. #define ACPI_EXD_REFERENCE 13
  80. #define ACPI_EXD_LIST 14 /* Operand object list */
  81. #define ACPI_EXD_HDLR_LIST 15 /* Address Handler list */
  82. #define ACPI_EXD_RGN_LIST 16 /* Region list */
  83. #define ACPI_EXD_NODE 17 /* Namespace Node */
  84. /* restore default alignment */
  85. #pragma pack()
  86. /*
  87. * exconvrt - object conversion
  88. */
  89. acpi_status
  90. acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
  91. union acpi_operand_object **result_desc, u32 flags);
  92. acpi_status
  93. acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
  94. union acpi_operand_object **result_desc);
  95. acpi_status
  96. acpi_ex_convert_to_string(union acpi_operand_object *obj_desc,
  97. union acpi_operand_object **result_desc, u32 type);
  98. /* Types for ->String conversion */
  99. #define ACPI_EXPLICIT_BYTE_COPY 0x00000000
  100. #define ACPI_EXPLICIT_CONVERT_HEX 0x00000001
  101. #define ACPI_IMPLICIT_CONVERT_HEX 0x00000002
  102. #define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003
  103. acpi_status
  104. acpi_ex_convert_to_target_type(acpi_object_type destination_type,
  105. union acpi_operand_object *source_desc,
  106. union acpi_operand_object **result_desc,
  107. struct acpi_walk_state *walk_state);
  108. /*
  109. * exdebug - AML debug object
  110. */
  111. void
  112. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  113. u32 level, u32 index);
  114. void
  115. acpi_ex_start_trace_method(struct acpi_namespace_node *method_node,
  116. union acpi_operand_object *obj_desc,
  117. struct acpi_walk_state *walk_state);
  118. void
  119. acpi_ex_stop_trace_method(struct acpi_namespace_node *method_node,
  120. union acpi_operand_object *obj_desc,
  121. struct acpi_walk_state *walk_state);
  122. void
  123. acpi_ex_start_trace_opcode(union acpi_parse_object *op,
  124. struct acpi_walk_state *walk_state);
  125. void
  126. acpi_ex_stop_trace_opcode(union acpi_parse_object *op,
  127. struct acpi_walk_state *walk_state);
  128. void
  129. acpi_ex_trace_point(acpi_trace_event_type type,
  130. u8 begin, u8 *aml, char *pathname);
  131. /*
  132. * exfield - ACPI AML (p-code) execution - field manipulation
  133. */
  134. acpi_status
  135. acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
  136. u32 buffer_length, u32 * datum_count);
  137. acpi_status
  138. acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
  139. u64 mask,
  140. u64 field_value, u32 field_datum_byte_offset);
  141. void
  142. acpi_ex_get_buffer_datum(u64 *datum,
  143. void *buffer,
  144. u32 buffer_length,
  145. u32 byte_granularity, u32 buffer_offset);
  146. void
  147. acpi_ex_set_buffer_datum(u64 merged_datum,
  148. void *buffer,
  149. u32 buffer_length,
  150. u32 byte_granularity, u32 buffer_offset);
  151. acpi_status
  152. acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
  153. union acpi_operand_object *obj_desc,
  154. union acpi_operand_object **ret_buffer_desc);
  155. acpi_status
  156. acpi_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);
  159. /*
  160. * exfldio - low level field I/O
  161. */
  162. acpi_status
  163. acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
  164. void *buffer, u32 buffer_length);
  165. acpi_status
  166. acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
  167. void *buffer, u32 buffer_length);
  168. acpi_status
  169. acpi_ex_access_region(union acpi_operand_object *obj_desc,
  170. u32 field_datum_byte_offset, u64 *value, u32 read_write);
  171. /*
  172. * exmisc - misc support routines
  173. */
  174. acpi_status
  175. acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
  176. union acpi_operand_object **return_desc,
  177. struct acpi_walk_state *walk_state);
  178. acpi_status
  179. acpi_ex_concat_template(union acpi_operand_object *obj_desc,
  180. union acpi_operand_object *obj_desc2,
  181. union acpi_operand_object **actual_return_desc,
  182. struct acpi_walk_state *walk_state);
  183. acpi_status
  184. acpi_ex_do_concatenate(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. acpi_status
  189. acpi_ex_do_logical_numeric_op(u16 opcode,
  190. u64 integer0, u64 integer1, u8 *logical_result);
  191. acpi_status
  192. acpi_ex_do_logical_op(u16 opcode,
  193. union acpi_operand_object *operand0,
  194. union acpi_operand_object *operand1, u8 *logical_result);
  195. u64 acpi_ex_do_math_op(u16 opcode, u64 operand0, u64 operand1);
  196. acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
  197. acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state);
  198. acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state);
  199. acpi_status
  200. acpi_ex_create_region(u8 * aml_start,
  201. u32 aml_length,
  202. u8 region_space, struct acpi_walk_state *walk_state);
  203. acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
  204. acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
  205. acpi_status
  206. acpi_ex_create_method(u8 * aml_start,
  207. u32 aml_length, struct acpi_walk_state *walk_state);
  208. /*
  209. * exconfig - dynamic table load/unload
  210. */
  211. acpi_status
  212. acpi_ex_load_op(union acpi_operand_object *obj_desc,
  213. union acpi_operand_object *target,
  214. struct acpi_walk_state *walk_state);
  215. acpi_status
  216. acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
  217. union acpi_operand_object **return_desc);
  218. acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle);
  219. /*
  220. * exmutex - mutex support
  221. */
  222. acpi_status
  223. acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
  224. union acpi_operand_object *obj_desc,
  225. struct acpi_walk_state *walk_state);
  226. acpi_status
  227. acpi_ex_acquire_mutex_object(u16 timeout,
  228. union acpi_operand_object *obj_desc,
  229. acpi_thread_id thread_id);
  230. acpi_status
  231. acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
  232. struct acpi_walk_state *walk_state);
  233. acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc);
  234. void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
  235. void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
  236. /*
  237. * exprep - ACPI AML execution - prep utilities
  238. */
  239. acpi_status
  240. acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
  241. u8 field_flags,
  242. u8 field_attribute,
  243. u32 field_bit_position, u32 field_bit_length);
  244. acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info);
  245. /*
  246. * exsystem - Interface to OS services
  247. */
  248. acpi_status
  249. acpi_ex_system_do_notify_op(union acpi_operand_object *value,
  250. union acpi_operand_object *obj_desc);
  251. acpi_status acpi_ex_system_do_sleep(u64 time);
  252. acpi_status acpi_ex_system_do_stall(u32 time);
  253. acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc);
  254. acpi_status
  255. acpi_ex_system_wait_event(union acpi_operand_object *time,
  256. union acpi_operand_object *obj_desc);
  257. acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
  258. acpi_status
  259. acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
  260. acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
  261. /*
  262. * exoparg1 - ACPI AML execution, 1 operand
  263. */
  264. acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state);
  265. acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state);
  266. acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state);
  267. acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state);
  268. acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state);
  269. /*
  270. * exoparg2 - ACPI AML execution, 2 operands
  271. */
  272. acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state);
  273. acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state);
  274. acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state);
  275. acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state);
  276. /*
  277. * exoparg3 - ACPI AML execution, 3 operands
  278. */
  279. acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state);
  280. acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state);
  281. /*
  282. * exoparg6 - ACPI AML execution, 6 operands
  283. */
  284. acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state);
  285. /*
  286. * exresolv - Object resolution and get value functions
  287. */
  288. acpi_status
  289. acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
  290. struct acpi_walk_state *walk_state);
  291. acpi_status
  292. acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
  293. union acpi_operand_object *operand,
  294. acpi_object_type * return_type,
  295. union acpi_operand_object **return_desc);
  296. /*
  297. * exresnte - resolve namespace node
  298. */
  299. acpi_status
  300. acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr,
  301. struct acpi_walk_state *walk_state);
  302. /*
  303. * exresop - resolve operand to value
  304. */
  305. acpi_status
  306. acpi_ex_resolve_operands(u16 opcode,
  307. union acpi_operand_object **stack_ptr,
  308. struct acpi_walk_state *walk_state);
  309. /*
  310. * exdump - Interpreter debug output routines
  311. */
  312. void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth);
  313. void
  314. acpi_ex_dump_operands(union acpi_operand_object **operands,
  315. const char *opcode_name, u32 num_opcodes);
  316. void
  317. acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
  318. void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
  319. /*
  320. * exnames - AML namestring support
  321. */
  322. acpi_status
  323. acpi_ex_get_name_string(acpi_object_type data_type,
  324. u8 * in_aml_address,
  325. char **out_name_string, u32 * out_name_length);
  326. /*
  327. * exstore - Object store support
  328. */
  329. acpi_status
  330. acpi_ex_store(union acpi_operand_object *val_desc,
  331. union acpi_operand_object *dest_desc,
  332. struct acpi_walk_state *walk_state);
  333. acpi_status
  334. acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
  335. struct acpi_namespace_node *node,
  336. struct acpi_walk_state *walk_state,
  337. u8 implicit_conversion);
  338. #define ACPI_IMPLICIT_CONVERSION TRUE
  339. #define ACPI_NO_IMPLICIT_CONVERSION FALSE
  340. /*
  341. * exstoren - resolve/store object
  342. */
  343. acpi_status
  344. acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
  345. acpi_object_type target_type,
  346. struct acpi_walk_state *walk_state);
  347. acpi_status
  348. acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
  349. union acpi_operand_object *dest_desc,
  350. union acpi_operand_object **new_desc,
  351. struct acpi_walk_state *walk_state);
  352. /*
  353. * exstorob - store object - buffer/string
  354. */
  355. acpi_status
  356. acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
  357. union acpi_operand_object *target_desc);
  358. acpi_status
  359. acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
  360. union acpi_operand_object *target_desc);
  361. /*
  362. * excopy - object copy
  363. */
  364. acpi_status
  365. acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc,
  366. union acpi_operand_object *target_desc);
  367. acpi_status
  368. acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc,
  369. union acpi_operand_object *target_desc);
  370. acpi_status
  371. acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc,
  372. struct acpi_namespace_node *node);
  373. acpi_status
  374. acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc,
  375. union acpi_operand_object *target_desc);
  376. /*
  377. * exutils - interpreter/scanner utilities
  378. */
  379. void acpi_ex_enter_interpreter(void);
  380. void acpi_ex_exit_interpreter(void);
  381. u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
  382. void acpi_ex_acquire_global_lock(u32 rule);
  383. void acpi_ex_release_global_lock(u32 rule);
  384. void acpi_ex_eisa_id_to_string(char *dest, u64 compressed_id);
  385. void acpi_ex_integer_to_string(char *dest, u64 value);
  386. void acpi_ex_pci_cls_to_string(char *dest, u8 class_code[3]);
  387. u8 acpi_is_valid_space_id(u8 space_id);
  388. /*
  389. * exregion - default op_region handlers
  390. */
  391. acpi_status
  392. acpi_ex_system_memory_space_handler(u32 function,
  393. acpi_physical_address address,
  394. u32 bit_width,
  395. u64 *value,
  396. void *handler_context,
  397. void *region_context);
  398. acpi_status
  399. acpi_ex_system_io_space_handler(u32 function,
  400. acpi_physical_address address,
  401. u32 bit_width,
  402. u64 *value,
  403. void *handler_context, void *region_context);
  404. acpi_status
  405. acpi_ex_pci_config_space_handler(u32 function,
  406. acpi_physical_address address,
  407. u32 bit_width,
  408. u64 *value,
  409. void *handler_context, void *region_context);
  410. acpi_status
  411. acpi_ex_cmos_space_handler(u32 function,
  412. acpi_physical_address address,
  413. u32 bit_width,
  414. u64 *value,
  415. void *handler_context, void *region_context);
  416. acpi_status
  417. acpi_ex_pci_bar_space_handler(u32 function,
  418. acpi_physical_address address,
  419. u32 bit_width,
  420. u64 *value,
  421. void *handler_context, void *region_context);
  422. acpi_status
  423. acpi_ex_embedded_controller_space_handler(u32 function,
  424. acpi_physical_address address,
  425. u32 bit_width,
  426. u64 *value,
  427. void *handler_context,
  428. void *region_context);
  429. acpi_status
  430. acpi_ex_sm_bus_space_handler(u32 function,
  431. acpi_physical_address address,
  432. u32 bit_width,
  433. u64 *value,
  434. void *handler_context, void *region_context);
  435. acpi_status
  436. acpi_ex_data_table_space_handler(u32 function,
  437. acpi_physical_address address,
  438. u32 bit_width,
  439. u64 *value,
  440. void *handler_context, void *region_context);
  441. #endif /* __INTERP_H__ */