acstruct.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /******************************************************************************
  3. *
  4. * Name: acstruct.h - Internal structs
  5. *
  6. * Copyright (C) 2000 - 2022, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #ifndef __ACSTRUCT_H__
  10. #define __ACSTRUCT_H__
  11. /* acpisrc:struct_defs -- for acpisrc conversion */
  12. /*****************************************************************************
  13. *
  14. * Tree walking typedefs and structs
  15. *
  16. ****************************************************************************/
  17. /*
  18. * Walk state - current state of a parse tree walk. Used for both a leisurely
  19. * stroll through the tree (for whatever reason), and for control method
  20. * execution.
  21. */
  22. #define ACPI_NEXT_OP_DOWNWARD 1
  23. #define ACPI_NEXT_OP_UPWARD 2
  24. /*
  25. * Groups of definitions for walk_type used for different implementations of
  26. * walkers (never simultaneously) - flags for interpreter:
  27. */
  28. #define ACPI_WALK_NON_METHOD 0
  29. #define ACPI_WALK_METHOD 0x01
  30. #define ACPI_WALK_METHOD_RESTART 0x02
  31. struct acpi_walk_state {
  32. struct acpi_walk_state *next; /* Next walk_state in list */
  33. u8 descriptor_type; /* To differentiate various internal objs */
  34. u8 walk_type;
  35. u16 opcode; /* Current AML opcode */
  36. u8 next_op_info; /* Info about next_op */
  37. u8 num_operands; /* Stack pointer for Operands[] array */
  38. u8 operand_index; /* Index into operand stack, to be used by acpi_ds_obj_stack_push */
  39. acpi_owner_id owner_id; /* Owner of objects created during the walk */
  40. u8 last_predicate; /* Result of last predicate */
  41. u8 current_result;
  42. u8 return_used;
  43. u8 scope_depth;
  44. u8 pass_number; /* Parse pass during table load */
  45. u8 namespace_override; /* Override existing objects */
  46. u8 result_size; /* Total elements for the result stack */
  47. u8 result_count; /* Current number of occupied elements of result stack */
  48. u8 *aml;
  49. u32 arg_types;
  50. u32 method_breakpoint; /* For single stepping */
  51. u32 user_breakpoint; /* User AML breakpoint */
  52. u32 parse_flags;
  53. struct acpi_parse_state parser_state; /* Current state of parser */
  54. u32 prev_arg_types;
  55. u32 arg_count; /* push for fixed or var args */
  56. u16 method_nesting_depth;
  57. u8 method_is_nested;
  58. struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
  59. struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
  60. union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
  61. union acpi_operand_object **params;
  62. u8 *aml_last_while;
  63. union acpi_operand_object **caller_return_desc;
  64. union acpi_generic_state *control_state; /* List of control states (nested IFs) */
  65. struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */
  66. union acpi_operand_object *implicit_return_obj;
  67. struct acpi_namespace_node *method_call_node; /* Called method Node */
  68. union acpi_parse_object *method_call_op; /* method_call Op if running a method */
  69. union acpi_operand_object *method_desc; /* Method descriptor if running a method */
  70. struct acpi_namespace_node *method_node; /* Method node if running a method */
  71. char *method_pathname; /* Full pathname of running method */
  72. union acpi_parse_object *op; /* Current parser op */
  73. const struct acpi_opcode_info *op_info; /* Info on current opcode */
  74. union acpi_parse_object *origin; /* Start of walk [Obsolete] */
  75. union acpi_operand_object *result_obj;
  76. union acpi_generic_state *results; /* Stack of accumulated results */
  77. union acpi_operand_object *return_desc; /* Return object, if any */
  78. union acpi_generic_state *scope_info; /* Stack of nested scopes */
  79. union acpi_parse_object *prev_op; /* Last op that was processed */
  80. union acpi_parse_object *next_op; /* next op to be processed */
  81. struct acpi_thread_state *thread;
  82. acpi_parse_downwards descending_callback;
  83. acpi_parse_upwards ascending_callback;
  84. };
  85. /* Info used by acpi_ns_initialize_objects and acpi_ds_initialize_objects */
  86. struct acpi_init_walk_info {
  87. u32 table_index;
  88. u32 object_count;
  89. u32 method_count;
  90. u32 serial_method_count;
  91. u32 non_serial_method_count;
  92. u32 serialized_method_count;
  93. u32 device_count;
  94. u32 op_region_count;
  95. u32 field_count;
  96. u32 buffer_count;
  97. u32 package_count;
  98. u32 op_region_init;
  99. u32 field_init;
  100. u32 buffer_init;
  101. u32 package_init;
  102. acpi_owner_id owner_id;
  103. };
  104. struct acpi_get_devices_info {
  105. acpi_walk_callback user_function;
  106. void *context;
  107. const char *hid;
  108. };
  109. union acpi_aml_operands {
  110. union acpi_operand_object *operands[7];
  111. struct {
  112. struct acpi_object_integer *type;
  113. struct acpi_object_integer *code;
  114. struct acpi_object_integer *argument;
  115. } fatal;
  116. struct {
  117. union acpi_operand_object *source;
  118. struct acpi_object_integer *index;
  119. union acpi_operand_object *target;
  120. } index;
  121. struct {
  122. union acpi_operand_object *source;
  123. struct acpi_object_integer *index;
  124. struct acpi_object_integer *length;
  125. union acpi_operand_object *target;
  126. } mid;
  127. };
  128. /*
  129. * Structure used to pass object evaluation information and parameters.
  130. * Purpose is to reduce CPU stack use.
  131. */
  132. struct acpi_evaluate_info {
  133. /* The first 3 elements are passed by the caller to acpi_ns_evaluate */
  134. struct acpi_namespace_node *prefix_node; /* Input: starting node */
  135. const char *relative_pathname; /* Input: path relative to prefix_node */
  136. union acpi_operand_object **parameters; /* Input: argument list */
  137. struct acpi_namespace_node *node; /* Resolved node (prefix_node:relative_pathname) */
  138. union acpi_operand_object *obj_desc; /* Object attached to the resolved node */
  139. char *full_pathname; /* Full pathname of the resolved node */
  140. const union acpi_predefined_info *predefined; /* Used if Node is a predefined name */
  141. union acpi_operand_object *return_object; /* Object returned from the evaluation */
  142. union acpi_operand_object *parent_package; /* Used if return object is a Package */
  143. u32 return_flags; /* Used for return value analysis */
  144. u32 return_btype; /* Bitmapped type of the returned object */
  145. u16 param_count; /* Count of the input argument list */
  146. u16 node_flags; /* Same as Node->Flags */
  147. u8 pass_number; /* Parser pass number */
  148. u8 return_object_type; /* Object type of the returned object */
  149. u8 flags; /* General flags */
  150. };
  151. /* Values for Flags above */
  152. #define ACPI_IGNORE_RETURN_VALUE 1
  153. /* Defines for return_flags field above */
  154. #define ACPI_OBJECT_REPAIRED 1
  155. #define ACPI_OBJECT_WRAPPED 2
  156. /* Info used by acpi_ns_initialize_devices */
  157. struct acpi_device_walk_info {
  158. struct acpi_table_desc *table_desc;
  159. struct acpi_evaluate_info *evaluate_info;
  160. u32 device_count;
  161. u32 num_STA;
  162. u32 num_INI;
  163. };
  164. /* Info used by Acpi acpi_db_display_fields */
  165. struct acpi_region_walk_info {
  166. u32 debug_level;
  167. u32 count;
  168. acpi_owner_id owner_id;
  169. u8 display_type;
  170. u32 address_space_id;
  171. };
  172. /* TBD: [Restructure] Merge with struct above */
  173. struct acpi_walk_info {
  174. u32 debug_level;
  175. u32 count;
  176. acpi_owner_id owner_id;
  177. u8 display_type;
  178. };
  179. /* Display Types */
  180. #define ACPI_DISPLAY_SUMMARY (u8) 0
  181. #define ACPI_DISPLAY_OBJECTS (u8) 1
  182. #define ACPI_DISPLAY_MASK (u8) 1
  183. #define ACPI_DISPLAY_SHORT (u8) 2
  184. #endif