xref: /openbmc/linux/drivers/acpi/acpica/acstruct.h (revision bc05aa6e)
1 /******************************************************************************
2  *
3  * Name: acstruct.h - Internal structs
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2018, 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 __ACSTRUCT_H__
45 #define __ACSTRUCT_H__
46 
47 /* acpisrc:struct_defs -- for acpisrc conversion */
48 
49 /*****************************************************************************
50  *
51  * Tree walking typedefs and structs
52  *
53  ****************************************************************************/
54 
55 /*
56  * Walk state - current state of a parse tree walk. Used for both a leisurely
57  * stroll through the tree (for whatever reason), and for control method
58  * execution.
59  */
60 #define ACPI_NEXT_OP_DOWNWARD       1
61 #define ACPI_NEXT_OP_UPWARD         2
62 
63 /*
64  * Groups of definitions for walk_type used for different implementations of
65  * walkers (never simultaneously) - flags for interpreter:
66  */
67 #define ACPI_WALK_NON_METHOD        0
68 #define ACPI_WALK_METHOD            0x01
69 #define ACPI_WALK_METHOD_RESTART    0x02
70 
71 struct acpi_walk_state {
72 	struct acpi_walk_state *next;	/* Next walk_state in list */
73 	u8 descriptor_type;	/* To differentiate various internal objs */
74 	u8 walk_type;
75 	u16 opcode;		/* Current AML opcode */
76 	u8 next_op_info;	/* Info about next_op */
77 	u8 num_operands;	/* Stack pointer for Operands[] array */
78 	u8 operand_index;	/* Index into operand stack, to be used by acpi_ds_obj_stack_push */
79 	acpi_owner_id owner_id;	/* Owner of objects created during the walk */
80 	u8 last_predicate;	/* Result of last predicate */
81 	u8 current_result;
82 	u8 return_used;
83 	u8 scope_depth;
84 	u8 pass_number;		/* Parse pass during table load */
85 	u8 namespace_override;	/* Override existing objects */
86 	u8 result_size;		/* Total elements for the result stack */
87 	u8 result_count;	/* Current number of occupied elements of result stack */
88 	u8 *aml;
89 	u32 arg_types;
90 	u32 method_breakpoint;	/* For single stepping */
91 	u32 user_breakpoint;	/* User AML breakpoint */
92 	u32 parse_flags;
93 
94 	struct acpi_parse_state parser_state;	/* Current state of parser */
95 	u32 prev_arg_types;
96 	u32 arg_count;		/* push for fixed or var args */
97 
98 	struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS];	/* Control method arguments */
99 	struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS];	/* Control method locals */
100 	union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1];	/* Operands passed to the interpreter (+1 for NULL terminator) */
101 	union acpi_operand_object **params;
102 
103 	u8 *aml_last_while;
104 	union acpi_operand_object **caller_return_desc;
105 	union acpi_generic_state *control_state;	/* List of control states (nested IFs) */
106 	struct acpi_namespace_node *deferred_node;	/* Used when executing deferred opcodes */
107 	union acpi_operand_object *implicit_return_obj;
108 	struct acpi_namespace_node *method_call_node;	/* Called method Node */
109 	union acpi_parse_object *method_call_op;	/* method_call Op if running a method */
110 	union acpi_operand_object *method_desc;	/* Method descriptor if running a method */
111 	struct acpi_namespace_node *method_node;	/* Method node if running a method. */
112 	union acpi_parse_object *op;	/* Current parser op */
113 	const struct acpi_opcode_info *op_info;	/* Info on current opcode */
114 	union acpi_parse_object *origin;	/* Start of walk [Obsolete] */
115 	union acpi_operand_object *result_obj;
116 	union acpi_generic_state *results;	/* Stack of accumulated results */
117 	union acpi_operand_object *return_desc;	/* Return object, if any */
118 	union acpi_generic_state *scope_info;	/* Stack of nested scopes */
119 	union acpi_parse_object *prev_op;	/* Last op that was processed */
120 	union acpi_parse_object *next_op;	/* next op to be processed */
121 	struct acpi_thread_state *thread;
122 	acpi_parse_downwards descending_callback;
123 	acpi_parse_upwards ascending_callback;
124 };
125 
126 /* Info used by acpi_ns_initialize_objects and acpi_ds_initialize_objects */
127 
128 struct acpi_init_walk_info {
129 	u32 table_index;
130 	u32 object_count;
131 	u32 method_count;
132 	u32 serial_method_count;
133 	u32 non_serial_method_count;
134 	u32 serialized_method_count;
135 	u32 device_count;
136 	u32 op_region_count;
137 	u32 field_count;
138 	u32 buffer_count;
139 	u32 package_count;
140 	u32 op_region_init;
141 	u32 field_init;
142 	u32 buffer_init;
143 	u32 package_init;
144 	acpi_owner_id owner_id;
145 };
146 
147 struct acpi_get_devices_info {
148 	acpi_walk_callback user_function;
149 	void *context;
150 	const char *hid;
151 };
152 
153 union acpi_aml_operands {
154 	union acpi_operand_object *operands[7];
155 
156 	struct {
157 		struct acpi_object_integer *type;
158 		struct acpi_object_integer *code;
159 		struct acpi_object_integer *argument;
160 
161 	} fatal;
162 
163 	struct {
164 		union acpi_operand_object *source;
165 		struct acpi_object_integer *index;
166 		union acpi_operand_object *target;
167 
168 	} index;
169 
170 	struct {
171 		union acpi_operand_object *source;
172 		struct acpi_object_integer *index;
173 		struct acpi_object_integer *length;
174 		union acpi_operand_object *target;
175 
176 	} mid;
177 };
178 
179 /*
180  * Structure used to pass object evaluation information and parameters.
181  * Purpose is to reduce CPU stack use.
182  */
183 struct acpi_evaluate_info {
184 	/* The first 3 elements are passed by the caller to acpi_ns_evaluate */
185 
186 	struct acpi_namespace_node *prefix_node;	/* Input: starting node */
187 	const char *relative_pathname;	/* Input: path relative to prefix_node */
188 	union acpi_operand_object **parameters;	/* Input: argument list */
189 
190 	struct acpi_namespace_node *node;	/* Resolved node (prefix_node:relative_pathname) */
191 	union acpi_operand_object *obj_desc;	/* Object attached to the resolved node */
192 	char *full_pathname;	/* Full pathname of the resolved node */
193 
194 	const union acpi_predefined_info *predefined;	/* Used if Node is a predefined name */
195 	union acpi_operand_object *return_object;	/* Object returned from the evaluation */
196 	union acpi_operand_object *parent_package;	/* Used if return object is a Package */
197 
198 	u32 return_flags;	/* Used for return value analysis */
199 	u32 return_btype;	/* Bitmapped type of the returned object */
200 	u16 param_count;	/* Count of the input argument list */
201 	u8 pass_number;		/* Parser pass number */
202 	u8 return_object_type;	/* Object type of the returned object */
203 	u8 node_flags;		/* Same as Node->Flags */
204 	u8 flags;		/* General flags */
205 };
206 
207 /* Values for Flags above */
208 
209 #define ACPI_IGNORE_RETURN_VALUE    1
210 
211 /* Defines for return_flags field above */
212 
213 #define ACPI_OBJECT_REPAIRED        1
214 #define ACPI_OBJECT_WRAPPED         2
215 
216 /* Info used by acpi_ns_initialize_devices */
217 
218 struct acpi_device_walk_info {
219 	struct acpi_table_desc *table_desc;
220 	struct acpi_evaluate_info *evaluate_info;
221 	u32 device_count;
222 	u32 num_STA;
223 	u32 num_INI;
224 };
225 
226 /* TBD: [Restructure] Merge with struct above */
227 
228 struct acpi_walk_info {
229 	u32 debug_level;
230 	u32 count;
231 	acpi_owner_id owner_id;
232 	u8 display_type;
233 };
234 
235 /* Display Types */
236 
237 #define ACPI_DISPLAY_SUMMARY        (u8) 0
238 #define ACPI_DISPLAY_OBJECTS        (u8) 1
239 #define ACPI_DISPLAY_MASK           (u8) 1
240 
241 #define ACPI_DISPLAY_SHORT          (u8) 2
242 
243 #endif
244