xref: /linux/drivers/acpi/acpica/aclocal.h (revision 044b72395194965069da098d729110446855bb4d)
1e2f7a777SLen Brown /******************************************************************************
2e2f7a777SLen Brown  *
3e2f7a777SLen Brown  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4e2f7a777SLen Brown  *
5e2f7a777SLen Brown  *****************************************************************************/
6e2f7a777SLen Brown 
7e2f7a777SLen Brown /*
87735ca0eSBob Moore  * Copyright (C) 2000 - 2017, Intel Corp.
9e2f7a777SLen Brown  * All rights reserved.
10e2f7a777SLen Brown  *
11e2f7a777SLen Brown  * Redistribution and use in source and binary forms, with or without
12e2f7a777SLen Brown  * modification, are permitted provided that the following conditions
13e2f7a777SLen Brown  * are met:
14e2f7a777SLen Brown  * 1. Redistributions of source code must retain the above copyright
15e2f7a777SLen Brown  *    notice, this list of conditions, and the following disclaimer,
16e2f7a777SLen Brown  *    without modification.
17e2f7a777SLen Brown  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18e2f7a777SLen Brown  *    substantially similar to the "NO WARRANTY" disclaimer below
19e2f7a777SLen Brown  *    ("Disclaimer") and any redistribution must be conditioned upon
20e2f7a777SLen Brown  *    including a substantially similar Disclaimer requirement for further
21e2f7a777SLen Brown  *    binary redistribution.
22e2f7a777SLen Brown  * 3. Neither the names of the above-listed copyright holders nor the names
23e2f7a777SLen Brown  *    of any contributors may be used to endorse or promote products derived
24e2f7a777SLen Brown  *    from this software without specific prior written permission.
25e2f7a777SLen Brown  *
26e2f7a777SLen Brown  * Alternatively, this software may be distributed under the terms of the
27e2f7a777SLen Brown  * GNU General Public License ("GPL") version 2 as published by the Free
28e2f7a777SLen Brown  * Software Foundation.
29e2f7a777SLen Brown  *
30e2f7a777SLen Brown  * NO WARRANTY
31e2f7a777SLen Brown  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32e2f7a777SLen Brown  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33e2f7a777SLen Brown  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34e2f7a777SLen Brown  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35e2f7a777SLen Brown  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36e2f7a777SLen Brown  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37e2f7a777SLen Brown  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38e2f7a777SLen Brown  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39e2f7a777SLen Brown  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40e2f7a777SLen Brown  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41e2f7a777SLen Brown  * POSSIBILITY OF SUCH DAMAGES.
42e2f7a777SLen Brown  */
43e2f7a777SLen Brown 
44e2f7a777SLen Brown #ifndef __ACLOCAL_H__
45e2f7a777SLen Brown #define __ACLOCAL_H__
46e2f7a777SLen Brown 
47e2f7a777SLen Brown /* acpisrc:struct_defs -- for acpisrc conversion */
48e2f7a777SLen Brown 
49e2f7a777SLen Brown #define ACPI_SERIALIZED                 0xFF
50e2f7a777SLen Brown 
51e2f7a777SLen Brown typedef u32 acpi_mutex_handle;
52e2f7a777SLen Brown #define ACPI_GLOBAL_LOCK                (acpi_semaphore) (-1)
53e2f7a777SLen Brown 
54e2f7a777SLen Brown /* Total number of aml opcodes defined */
55e2f7a777SLen Brown 
569cf7adecSBob Moore #define AML_NUM_OPCODES                 0x83
57e2f7a777SLen Brown 
58e2f7a777SLen Brown /* Forward declarations */
59e2f7a777SLen Brown 
60e2f7a777SLen Brown struct acpi_walk_state;
61e2f7a777SLen Brown struct acpi_obj_mutex;
62e2f7a777SLen Brown union acpi_parse_object;
63e2f7a777SLen Brown 
64e2f7a777SLen Brown /*****************************************************************************
65e2f7a777SLen Brown  *
66e2f7a777SLen Brown  * Mutex typedefs and structs
67e2f7a777SLen Brown  *
68e2f7a777SLen Brown  ****************************************************************************/
69e2f7a777SLen Brown 
70e2f7a777SLen Brown /*
71e2f7a777SLen Brown  * Predefined handles for the mutex objects used within the subsystem
72e2f7a777SLen Brown  * All mutex objects are automatically created by acpi_ut_mutex_initialize.
73e2f7a777SLen Brown  *
74e2f7a777SLen Brown  * The acquire/release ordering protocol is implied via this list. Mutexes
75e2f7a777SLen Brown  * with a lower value must be acquired before mutexes with a higher value.
76e2f7a777SLen Brown  *
77e2f7a777SLen Brown  * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names
78e2f7a777SLen Brown  * table below also!
79e2f7a777SLen Brown  */
80e2f7a777SLen Brown #define ACPI_MTX_INTERPRETER            0	/* AML Interpreter, main lock */
81e2f7a777SLen Brown #define ACPI_MTX_NAMESPACE              1	/* ACPI Namespace */
82e2f7a777SLen Brown #define ACPI_MTX_TABLES                 2	/* Data for ACPI tables */
83e2f7a777SLen Brown #define ACPI_MTX_EVENTS                 3	/* Data for ACPI events */
84e2f7a777SLen Brown #define ACPI_MTX_CACHES                 4	/* Internal caches, general purposes */
85e2f7a777SLen Brown #define ACPI_MTX_MEMORY                 5	/* Debug memory tracking lists */
86e2f7a777SLen Brown 
87cd64bbf8SBob Moore #define ACPI_MAX_MUTEX                  5
883008ea9bSwaddlesplash #define ACPI_NUM_MUTEX                  (ACPI_MAX_MUTEX+1)
89e2f7a777SLen Brown 
908a335a23SBob Moore /* Lock structure for reader/writer interfaces */
918a335a23SBob Moore 
928a335a23SBob Moore struct acpi_rw_lock {
938a335a23SBob Moore 	acpi_mutex writer_mutex;
948a335a23SBob Moore 	acpi_mutex reader_mutex;
958a335a23SBob Moore 	u32 num_readers;
968a335a23SBob Moore };
978a335a23SBob Moore 
98e2f7a777SLen Brown /*
99e2f7a777SLen Brown  * Predefined handles for spinlocks used within the subsystem.
100e2f7a777SLen Brown  * These spinlocks are created by acpi_ut_mutex_initialize
101e2f7a777SLen Brown  */
102e2f7a777SLen Brown #define ACPI_LOCK_GPES                  0
103e2f7a777SLen Brown #define ACPI_LOCK_HARDWARE              1
104e2f7a777SLen Brown 
105e2f7a777SLen Brown #define ACPI_MAX_LOCK                   1
1063008ea9bSwaddlesplash #define ACPI_NUM_LOCK                   (ACPI_MAX_LOCK+1)
107e2f7a777SLen Brown 
108e2f7a777SLen Brown /* This Thread ID means that the mutex is not in use (unlocked) */
109e2f7a777SLen Brown 
1103008ea9bSwaddlesplash #define ACPI_MUTEX_NOT_ACQUIRED         ((acpi_thread_id) 0)
111e2f7a777SLen Brown 
112f988f24eSLv Zheng /* This Thread ID means an invalid thread ID */
113f988f24eSLv Zheng 
114f988f24eSLv Zheng #ifdef ACPI_OS_INVALID_THREAD_ID
115f988f24eSLv Zheng #define ACPI_INVALID_THREAD_ID          ACPI_OS_INVALID_THREAD_ID
116f988f24eSLv Zheng #else
117f988f24eSLv Zheng #define ACPI_INVALID_THREAD_ID          ((acpi_thread_id) 0xFFFFFFFF)
118f988f24eSLv Zheng #endif
119f988f24eSLv Zheng 
120e2f7a777SLen Brown /* Table for the global mutexes */
121e2f7a777SLen Brown 
122e2f7a777SLen Brown struct acpi_mutex_info {
123e2f7a777SLen Brown 	acpi_mutex mutex;
124e2f7a777SLen Brown 	u32 use_count;
125e2f7a777SLen Brown 	acpi_thread_id thread_id;
126e2f7a777SLen Brown };
127e2f7a777SLen Brown 
128e2f7a777SLen Brown /* Lock flag parameter for various interfaces */
129e2f7a777SLen Brown 
130e2f7a777SLen Brown #define ACPI_MTX_DO_NOT_LOCK            0
131e2f7a777SLen Brown #define ACPI_MTX_LOCK                   1
132e2f7a777SLen Brown 
133e2f7a777SLen Brown /* Field access granularities */
134e2f7a777SLen Brown 
135e2f7a777SLen Brown #define ACPI_FIELD_BYTE_GRANULARITY     1
136e2f7a777SLen Brown #define ACPI_FIELD_WORD_GRANULARITY     2
137e2f7a777SLen Brown #define ACPI_FIELD_DWORD_GRANULARITY    4
138e2f7a777SLen Brown #define ACPI_FIELD_QWORD_GRANULARITY    8
139e2f7a777SLen Brown 
140e2f7a777SLen Brown #define ACPI_ENTRY_NOT_FOUND            NULL
141e2f7a777SLen Brown 
142e2f7a777SLen Brown /*****************************************************************************
143e2f7a777SLen Brown  *
144e2f7a777SLen Brown  * Namespace typedefs and structs
145e2f7a777SLen Brown  *
146e2f7a777SLen Brown  ****************************************************************************/
147e2f7a777SLen Brown 
148e2f7a777SLen Brown /* Operational modes of the AML interpreter/scanner */
149e2f7a777SLen Brown 
150e2f7a777SLen Brown typedef enum {
151e2f7a777SLen Brown 	ACPI_IMODE_LOAD_PASS1 = 0x01,
152e2f7a777SLen Brown 	ACPI_IMODE_LOAD_PASS2 = 0x02,
153e2f7a777SLen Brown 	ACPI_IMODE_EXECUTE = 0x03
154e2f7a777SLen Brown } acpi_interpreter_mode;
155e2f7a777SLen Brown 
156e2f7a777SLen Brown /*
157e2f7a777SLen Brown  * The Namespace Node describes a named object that appears in the AML.
158e2f7a777SLen Brown  * descriptor_type is used to differentiate between internal descriptors.
159e2f7a777SLen Brown  *
160e2f7a777SLen Brown  * The node is optimized for both 32-bit and 64-bit platforms:
161e2f7a777SLen Brown  * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
162e2f7a777SLen Brown  *
163e2f7a777SLen Brown  * Note: The descriptor_type and Type fields must appear in the identical
164e2f7a777SLen Brown  * position in both the struct acpi_namespace_node and union acpi_operand_object
165e2f7a777SLen Brown  * structures.
166e2f7a777SLen Brown  */
167e2f7a777SLen Brown struct acpi_namespace_node {
168e2f7a777SLen Brown 	union acpi_operand_object *object;	/* Interpreter object */
169e2f7a777SLen Brown 	u8 descriptor_type;	/* Differentiate object descriptor types */
170e2f7a777SLen Brown 	u8 type;		/* ACPI Type associated with this name */
171e2f7a777SLen Brown 	u8 flags;		/* Miscellaneous flags */
172e2f7a777SLen Brown 	acpi_owner_id owner_id;	/* Node creator */
173e2f7a777SLen Brown 	union acpi_name_union name;	/* ACPI Name, always 4 chars per ACPI spec */
174c45b5c09SAlexey Starikovskiy 	struct acpi_namespace_node *parent;	/* Parent node */
175e2f7a777SLen Brown 	struct acpi_namespace_node *child;	/* First child */
176c45b5c09SAlexey Starikovskiy 	struct acpi_namespace_node *peer;	/* First peer */
177e2f7a777SLen Brown 
178e2f7a777SLen Brown 	/*
179e2f7a777SLen Brown 	 * The following fields are used by the ASL compiler and disassembler only
180e2f7a777SLen Brown 	 */
181e2f7a777SLen Brown #ifdef ACPI_LARGE_NAMESPACE_NODE
182e2f7a777SLen Brown 	union acpi_parse_object *op;
18353d9edceSBob Moore 	void *method_locals;
18453d9edceSBob Moore 	void *method_args;
185e2f7a777SLen Brown 	u32 value;
186e2f7a777SLen Brown 	u32 length;
18753d9edceSBob Moore 	u8 arg_count;
18853d9edceSBob Moore 
189e2f7a777SLen Brown #endif
190e2f7a777SLen Brown };
191e2f7a777SLen Brown 
192e2f7a777SLen Brown /* Namespace Node flags */
193e2f7a777SLen Brown 
194c45b5c09SAlexey Starikovskiy #define ANOBJ_RESERVED                  0x01	/* Available for use */
195e2f7a777SLen Brown #define ANOBJ_TEMPORARY                 0x02	/* Node is create by a method and is temporary */
196e2f7a777SLen Brown #define ANOBJ_METHOD_ARG                0x04	/* Node is a method argument */
197e2f7a777SLen Brown #define ANOBJ_METHOD_LOCAL              0x08	/* Node is a method local */
198e2f7a777SLen Brown #define ANOBJ_SUBTREE_HAS_INI           0x10	/* Used to optimize device initialization */
199e2f7a777SLen Brown #define ANOBJ_EVALUATED                 0x20	/* Set on first evaluation of node */
200b2f7ddcfSLin Ming #define ANOBJ_ALLOCATED_BUFFER          0x40	/* Method AML buffer is dynamic (install_method) */
201e2f7a777SLen Brown 
20275c8044fSLv Zheng #define ANOBJ_IS_EXTERNAL               0x08	/* iASL only: This object created via External() */
20375c8044fSLv Zheng #define ANOBJ_METHOD_NO_RETVAL          0x10	/* iASL only: Method has no return value */
20475c8044fSLv Zheng #define ANOBJ_METHOD_SOME_NO_RETVAL     0x20	/* iASL only: Method has at least one return value */
20575c8044fSLv Zheng #define ANOBJ_IS_REFERENCED             0x80	/* iASL only: Object was referenced */
206e2f7a777SLen Brown 
207b9ee2043SBob Moore /* Internal ACPI table management - master table list */
208e2f7a777SLen Brown 
209b9ee2043SBob Moore struct acpi_table_list {
210b9ee2043SBob Moore 	struct acpi_table_desc *tables;	/* Table descriptor array */
211b9ee2043SBob Moore 	u32 current_table_count;	/* Tables currently in the array */
212b9ee2043SBob Moore 	u32 max_table_count;	/* Max tables array will hold */
213e2f7a777SLen Brown 	u8 flags;
214e2f7a777SLen Brown };
215e2f7a777SLen Brown 
216e2f7a777SLen Brown /* Flags for above */
217e2f7a777SLen Brown 
218e2f7a777SLen Brown #define ACPI_ROOT_ORIGIN_UNKNOWN        (0)	/* ~ORIGIN_ALLOCATED */
219e2f7a777SLen Brown #define ACPI_ROOT_ORIGIN_ALLOCATED      (1)
220e2f7a777SLen Brown #define ACPI_ROOT_ALLOW_RESIZE          (2)
221e2f7a777SLen Brown 
2222ba7379bSBob Moore /* List to manage incoming ACPI tables */
2232ba7379bSBob Moore 
2242ba7379bSBob Moore struct acpi_new_table_desc {
2252ba7379bSBob Moore 	struct acpi_table_header *table;
2262ba7379bSBob Moore 	struct acpi_new_table_desc *next;
2272ba7379bSBob Moore };
2282ba7379bSBob Moore 
2298ec3f459SLv Zheng /* Predefined table indexes */
230e2f7a777SLen Brown 
2318ec3f459SLv Zheng #define ACPI_INVALID_TABLE_INDEX        (0xFFFFFFFF)
232e2f7a777SLen Brown 
233e2f7a777SLen Brown struct acpi_find_context {
234e2f7a777SLen Brown 	char *search_for;
235e2f7a777SLen Brown 	acpi_handle *list;
236e2f7a777SLen Brown 	u32 *count;
237e2f7a777SLen Brown };
238e2f7a777SLen Brown 
239e2f7a777SLen Brown struct acpi_ns_search_data {
240e2f7a777SLen Brown 	struct acpi_namespace_node *node;
241e2f7a777SLen Brown };
242e2f7a777SLen Brown 
243e2f7a777SLen Brown /* Object types used during package copies */
244e2f7a777SLen Brown 
245e2f7a777SLen Brown #define ACPI_COPY_TYPE_SIMPLE           0
246e2f7a777SLen Brown #define ACPI_COPY_TYPE_PACKAGE          1
247e2f7a777SLen Brown 
248e2f7a777SLen Brown /* Info structure used to convert external<->internal namestrings */
249e2f7a777SLen Brown 
250e2f7a777SLen Brown struct acpi_namestring_info {
251e2f7a777SLen Brown 	const char *external_name;
252e2f7a777SLen Brown 	const char *next_external_char;
253e2f7a777SLen Brown 	char *internal_name;
254e2f7a777SLen Brown 	u32 length;
255e2f7a777SLen Brown 	u32 num_segments;
256e2f7a777SLen Brown 	u32 num_carats;
257e2f7a777SLen Brown 	u8 fully_qualified;
258e2f7a777SLen Brown };
259e2f7a777SLen Brown 
260e2f7a777SLen Brown /* Field creation info */
261e2f7a777SLen Brown 
262e2f7a777SLen Brown struct acpi_create_field_info {
263e2f7a777SLen Brown 	struct acpi_namespace_node *region_node;
264e2f7a777SLen Brown 	struct acpi_namespace_node *field_node;
265e2f7a777SLen Brown 	struct acpi_namespace_node *register_node;
266e2f7a777SLen Brown 	struct acpi_namespace_node *data_register_node;
2679ce81784SBob Moore 	struct acpi_namespace_node *connection_node;
2689ce81784SBob Moore 	u8 *resource_buffer;
269e2f7a777SLen Brown 	u32 bank_value;
270e2f7a777SLen Brown 	u32 field_bit_position;
271e2f7a777SLen Brown 	u32 field_bit_length;
2729ce81784SBob Moore 	u16 resource_length;
27375ec6e55SBob Moore 	u16 pin_number_index;
274e2f7a777SLen Brown 	u8 field_flags;
275e2f7a777SLen Brown 	u8 attribute;
276e2f7a777SLen Brown 	u8 field_type;
2779ce81784SBob Moore 	u8 access_length;
278e2f7a777SLen Brown };
279e2f7a777SLen Brown 
280e2f7a777SLen Brown typedef
281644ef74eSLv Zheng acpi_status (*acpi_internal_method) (struct acpi_walk_state * walk_state);
282e2f7a777SLen Brown 
283e2f7a777SLen Brown /*
284e2f7a777SLen Brown  * Bitmapped ACPI types. Used internally only
285e2f7a777SLen Brown  */
286e2f7a777SLen Brown #define ACPI_BTYPE_ANY                  0x00000000
287e2f7a777SLen Brown #define ACPI_BTYPE_INTEGER              0x00000001
288e2f7a777SLen Brown #define ACPI_BTYPE_STRING               0x00000002
289e2f7a777SLen Brown #define ACPI_BTYPE_BUFFER               0x00000004
290e2f7a777SLen Brown #define ACPI_BTYPE_PACKAGE              0x00000008
291e2f7a777SLen Brown #define ACPI_BTYPE_FIELD_UNIT           0x00000010
292e2f7a777SLen Brown #define ACPI_BTYPE_DEVICE               0x00000020
293e2f7a777SLen Brown #define ACPI_BTYPE_EVENT                0x00000040
294e2f7a777SLen Brown #define ACPI_BTYPE_METHOD               0x00000080
295e2f7a777SLen Brown #define ACPI_BTYPE_MUTEX                0x00000100
296e2f7a777SLen Brown #define ACPI_BTYPE_REGION               0x00000200
297e2f7a777SLen Brown #define ACPI_BTYPE_POWER                0x00000400
298e2f7a777SLen Brown #define ACPI_BTYPE_PROCESSOR            0x00000800
299e2f7a777SLen Brown #define ACPI_BTYPE_THERMAL              0x00001000
300e2f7a777SLen Brown #define ACPI_BTYPE_BUFFER_FIELD         0x00002000
301e2f7a777SLen Brown #define ACPI_BTYPE_DDB_HANDLE           0x00004000
302e2f7a777SLen Brown #define ACPI_BTYPE_DEBUG_OBJECT         0x00008000
303a5922a1fSBob Moore #define ACPI_BTYPE_REFERENCE_OBJECT     0x00010000	/* From Index(), ref_of(), etc (type6_opcodes) */
304e2f7a777SLen Brown #define ACPI_BTYPE_RESOURCE             0x00020000
305a5922a1fSBob Moore #define ACPI_BTYPE_NAMED_REFERENCE      0x00040000	/* Generic unresolved Name or Namepath */
306e2f7a777SLen Brown 
307e2f7a777SLen Brown #define ACPI_BTYPE_COMPUTE_DATA         (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
308e2f7a777SLen Brown 
309e2f7a777SLen Brown #define ACPI_BTYPE_DATA                 (ACPI_BTYPE_COMPUTE_DATA  | ACPI_BTYPE_PACKAGE)
310a5922a1fSBob Moore 
311a5922a1fSBob Moore 	/* Used by Copy, de_ref_of, Store, Printf, Fprintf */
312a5922a1fSBob Moore 
313a5922a1fSBob Moore #define ACPI_BTYPE_DATA_REFERENCE       (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE_OBJECT | ACPI_BTYPE_DDB_HANDLE)
314e2f7a777SLen Brown #define ACPI_BTYPE_DEVICE_OBJECTS       (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
315e2f7a777SLen Brown #define ACPI_BTYPE_OBJECTS_AND_REFS     0x0001FFFF	/* ARG or LOCAL */
316e2f7a777SLen Brown #define ACPI_BTYPE_ALL_OBJECTS          0x0000FFFF
317e2f7a777SLen Brown 
318c34c82bcSBob Moore #pragma pack(1)
319c34c82bcSBob Moore 
320e2f7a777SLen Brown /*
321e2f7a777SLen Brown  * Information structure for ACPI predefined names.
322e2f7a777SLen Brown  * Each entry in the table contains the following items:
323e2f7a777SLen Brown  *
324ba494beeSBob Moore  * name                 - The ACPI reserved name
325e2f7a777SLen Brown  * param_count          - Number of arguments to the method
326e2f7a777SLen Brown  * expected_return_btypes - Allowed type(s) for the return value
327e2f7a777SLen Brown  */
328e2f7a777SLen Brown struct acpi_name_info {
329e2f7a777SLen Brown 	char name[ACPI_NAME_SIZE];
330c34c82bcSBob Moore 	u16 argument_list;
331e2f7a777SLen Brown 	u8 expected_btypes;
332e2f7a777SLen Brown };
333e2f7a777SLen Brown 
334e2f7a777SLen Brown /*
335e2f7a777SLen Brown  * Secondary information structures for ACPI predefined objects that return
336e2f7a777SLen Brown  * package objects. This structure appears as the next entry in the table
337e2f7a777SLen Brown  * after the NAME_INFO structure above.
338e2f7a777SLen Brown  *
339e2f7a777SLen Brown  * The reason for this is to minimize the size of the predefined name table.
340e2f7a777SLen Brown  */
341e2f7a777SLen Brown 
342e2f7a777SLen Brown /*
343e2f7a777SLen Brown  * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
3447fce7a4bSBob Moore  * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT,
3457fce7a4bSBob Moore  * ACPI_PTYPE2_FIX_VAR
346e2f7a777SLen Brown  */
347e2f7a777SLen Brown struct acpi_package_info {
348e2f7a777SLen Brown 	u8 type;
349e2f7a777SLen Brown 	u8 object_type1;
350e2f7a777SLen Brown 	u8 count1;
351e2f7a777SLen Brown 	u8 object_type2;
352e2f7a777SLen Brown 	u8 count2;
353c34c82bcSBob Moore 	u16 reserved;
354e2f7a777SLen Brown };
355e2f7a777SLen Brown 
356e2f7a777SLen Brown /* Used for ACPI_PTYPE2_FIXED */
357e2f7a777SLen Brown 
358e2f7a777SLen Brown struct acpi_package_info2 {
359e2f7a777SLen Brown 	u8 type;
360e2f7a777SLen Brown 	u8 count;
361e2f7a777SLen Brown 	u8 object_type[4];
362c34c82bcSBob Moore 	u8 reserved;
363e2f7a777SLen Brown };
364e2f7a777SLen Brown 
365e2f7a777SLen Brown /* Used for ACPI_PTYPE1_OPTION */
366e2f7a777SLen Brown 
367e2f7a777SLen Brown struct acpi_package_info3 {
368e2f7a777SLen Brown 	u8 type;
369e2f7a777SLen Brown 	u8 count;
370e2f7a777SLen Brown 	u8 object_type[2];
371e2f7a777SLen Brown 	u8 tail_object_type;
372c34c82bcSBob Moore 	u16 reserved;
373e2f7a777SLen Brown };
374e2f7a777SLen Brown 
375e34a7813SBob Moore struct acpi_package_info4 {
376e34a7813SBob Moore 	u8 type;
377e34a7813SBob Moore 	u8 object_type1;
378e34a7813SBob Moore 	u8 count1;
379e34a7813SBob Moore 	u8 sub_object_types;
380e34a7813SBob Moore 	u8 pkg_count;
381e34a7813SBob Moore 	u16 reserved;
382e34a7813SBob Moore };
383e34a7813SBob Moore 
384e2f7a777SLen Brown union acpi_predefined_info {
385e2f7a777SLen Brown 	struct acpi_name_info info;
386e2f7a777SLen Brown 	struct acpi_package_info ret_info;
387e2f7a777SLen Brown 	struct acpi_package_info2 ret_info2;
388e2f7a777SLen Brown 	struct acpi_package_info3 ret_info3;
389e34a7813SBob Moore 	struct acpi_package_info4 ret_info4;
390e2f7a777SLen Brown };
391e2f7a777SLen Brown 
392c34c82bcSBob Moore /* Reset to default packing */
393c34c82bcSBob Moore 
394c34c82bcSBob Moore #pragma pack()
395c34c82bcSBob Moore 
396d5a36100SBob Moore /* Return object auto-repair info */
397d5a36100SBob Moore 
398f5c1e1c5SLv Zheng typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node *
399f5c1e1c5SLv Zheng 					      scope,
400f5c1e1c5SLv Zheng 					      union acpi_operand_object *
401f5c1e1c5SLv Zheng 					      original_object,
402f5c1e1c5SLv Zheng 					      union acpi_operand_object **
403f5c1e1c5SLv Zheng 					      converted_object);
404d5a36100SBob Moore 
405d5a36100SBob Moore struct acpi_simple_repair_info {
406d5a36100SBob Moore 	char name[ACPI_NAME_SIZE];
407d5a36100SBob Moore 	u32 unexpected_btypes;
408d5a36100SBob Moore 	u32 package_index;
409d5a36100SBob Moore 	acpi_object_converter object_converter;
410d5a36100SBob Moore };
411d5a36100SBob Moore 
412e2f7a777SLen Brown /*
413e2f7a777SLen Brown  * Bitmapped return value types
414e2f7a777SLen Brown  * Note: the actual data types must be contiguous, a loop in nspredef.c
415e2f7a777SLen Brown  * depends on this.
416e2f7a777SLen Brown  */
417e2f7a777SLen Brown #define ACPI_RTYPE_ANY                  0x00
418e2f7a777SLen Brown #define ACPI_RTYPE_NONE                 0x01
419e2f7a777SLen Brown #define ACPI_RTYPE_INTEGER              0x02
420e2f7a777SLen Brown #define ACPI_RTYPE_STRING               0x04
421e2f7a777SLen Brown #define ACPI_RTYPE_BUFFER               0x08
422e2f7a777SLen Brown #define ACPI_RTYPE_PACKAGE              0x10
423e2f7a777SLen Brown #define ACPI_RTYPE_REFERENCE            0x20
424e2f7a777SLen Brown #define ACPI_RTYPE_ALL                  0x3F
425e2f7a777SLen Brown 
426e2f7a777SLen Brown #define ACPI_NUM_RTYPES                 5	/* Number of actual object types */
427e2f7a777SLen Brown 
42825823e78SBob Moore /* Info for running the _REG methods */
42925823e78SBob Moore 
43025823e78SBob Moore struct acpi_reg_walk_info {
43125823e78SBob Moore 	acpi_adr_space_type space_id;
432d815346fSLv Zheng 	u32 function;
43325823e78SBob Moore 	u32 reg_run_count;
43425823e78SBob Moore };
43525823e78SBob Moore 
436e2f7a777SLen Brown /*****************************************************************************
437e2f7a777SLen Brown  *
438e2f7a777SLen Brown  * Event typedefs and structs
439e2f7a777SLen Brown  *
440e2f7a777SLen Brown  ****************************************************************************/
441e2f7a777SLen Brown 
442a2fd4b4bSLv Zheng /* Dispatch info for each host-installed SCI handler */
443a2fd4b4bSLv Zheng 
444a2fd4b4bSLv Zheng struct acpi_sci_handler_info {
445a2fd4b4bSLv Zheng 	struct acpi_sci_handler_info *next;
446a2fd4b4bSLv Zheng 	acpi_sci_handler address;	/* Address of handler */
447a2fd4b4bSLv Zheng 	void *context;		/* Context to be passed to handler */
448a2fd4b4bSLv Zheng };
449a2fd4b4bSLv Zheng 
450e2f7a777SLen Brown /* Dispatch info for each GPE -- either a method or handler, cannot be both */
451e2f7a777SLen Brown 
4528b6cd8adSLin Ming struct acpi_gpe_handler_info {
4538b6cd8adSLin Ming 	acpi_gpe_handler address;	/* Address of handler, if any */
454e2f7a777SLen Brown 	void *context;		/* Context to be passed to handler */
455e2f7a777SLen Brown 	struct acpi_namespace_node *method_node;	/* Method node for this GPE level (saved) */
4563a37898dSLin Ming 	u8 original_flags;	/* Original (pre-handler) GPE info */
4573a37898dSLin Ming 	u8 originally_enabled;	/* True if GPE was originally enabled */
458e2f7a777SLen Brown };
459e2f7a777SLen Brown 
4605816b343SBob Moore /* Notify info for implicit notify, multiple device objects */
4615816b343SBob Moore 
4625816b343SBob Moore struct acpi_gpe_notify_info {
4635816b343SBob Moore 	struct acpi_namespace_node *device_node;	/* Device to be notified */
4645816b343SBob Moore 	struct acpi_gpe_notify_info *next;
4655816b343SBob Moore };
4665816b343SBob Moore 
46775c8044fSLv Zheng /*
46875c8044fSLv Zheng  * GPE dispatch info. At any time, the GPE can have at most one type
46975c8044fSLv Zheng  * of dispatch - Method, Handler, or Implicit Notify.
47075c8044fSLv Zheng  */
471e2f7a777SLen Brown union acpi_gpe_dispatch_info {
472e2f7a777SLen Brown 	struct acpi_namespace_node *method_node;	/* Method node for this GPE level */
4738b6cd8adSLin Ming 	struct acpi_gpe_handler_info *handler;  /* Installed GPE handler */
4745816b343SBob Moore 	struct acpi_gpe_notify_info *notify_list;	/* List of _PRW devices for implicit notifies */
475e2f7a777SLen Brown };
476e2f7a777SLen Brown 
477e2f7a777SLen Brown /*
478e2f7a777SLen Brown  * Information about a GPE, one per each GPE in an array.
479e2f7a777SLen Brown  * NOTE: Important to keep this struct as small as possible.
480e2f7a777SLen Brown  */
481e2f7a777SLen Brown struct acpi_gpe_event_info {
4825816b343SBob Moore 	union acpi_gpe_dispatch_info dispatch;	/* Either Method, Handler, or notify_list */
483e2f7a777SLen Brown 	struct acpi_gpe_register_info *register_info;	/* Backpointer to register info */
484e2f7a777SLen Brown 	u8 flags;		/* Misc info about this GPE */
485e2f7a777SLen Brown 	u8 gpe_number;		/* This GPE */
4860f849d2cSLin Ming 	u8 runtime_count;	/* References to a run GPE */
4872af52c2bSLv Zheng 	u8 disable_for_dispatch;	/* Masked during dispatching */
488e2f7a777SLen Brown };
489e2f7a777SLen Brown 
490e2f7a777SLen Brown /* Information about a GPE register pair, one per each status/enable pair in an array */
491e2f7a777SLen Brown 
492e2f7a777SLen Brown struct acpi_gpe_register_info {
493e2f7a777SLen Brown 	struct acpi_generic_address status_address;	/* Address of status reg */
494e2f7a777SLen Brown 	struct acpi_generic_address enable_address;	/* Address of enable reg */
4957505da4cSBob Moore 	u16 base_gpe_number;	/* Base GPE number for this register */
496e2f7a777SLen Brown 	u8 enable_for_wake;	/* GPEs to keep enabled when sleeping */
497e2f7a777SLen Brown 	u8 enable_for_run;	/* GPEs to keep enabled when running */
4982af52c2bSLv Zheng 	u8 mask_for_run;	/* GPEs to keep masked when running */
499c50f13c6SRafael J. Wysocki 	u8 enable_mask;		/* Current mask of enabled GPEs */
500e2f7a777SLen Brown };
501e2f7a777SLen Brown 
502e2f7a777SLen Brown /*
503e2f7a777SLen Brown  * Information about a GPE register block, one per each installed block --
504e2f7a777SLen Brown  * GPE0, GPE1, and one per each installed GPE Block Device.
505e2f7a777SLen Brown  */
506e2f7a777SLen Brown struct acpi_gpe_block_info {
507e2f7a777SLen Brown 	struct acpi_namespace_node *node;
508e2f7a777SLen Brown 	struct acpi_gpe_block_info *previous;
509e2f7a777SLen Brown 	struct acpi_gpe_block_info *next;
510e2f7a777SLen Brown 	struct acpi_gpe_xrupt_info *xrupt_block;	/* Backpointer to interrupt block */
511e2f7a777SLen Brown 	struct acpi_gpe_register_info *register_info;	/* One per GPE register pair */
512e2f7a777SLen Brown 	struct acpi_gpe_event_info *event_info;	/* One for each GPE */
5137505da4cSBob Moore 	u64 address;		/* Base address of the block */
514e2f7a777SLen Brown 	u32 register_count;	/* Number of register pairs in block */
5150f849d2cSLin Ming 	u16 gpe_count;		/* Number of individual GPEs in block */
5167505da4cSBob Moore 	u16 block_base_number;	/* Base GPE number for this block */
5177505da4cSBob Moore 	u8 space_id;
5183a37898dSLin Ming 	u8 initialized;		/* TRUE if this block is initialized */
519e2f7a777SLen Brown };
520e2f7a777SLen Brown 
521e2f7a777SLen Brown /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
522e2f7a777SLen Brown 
523e2f7a777SLen Brown struct acpi_gpe_xrupt_info {
524e2f7a777SLen Brown 	struct acpi_gpe_xrupt_info *previous;
525e2f7a777SLen Brown 	struct acpi_gpe_xrupt_info *next;
526e2f7a777SLen Brown 	struct acpi_gpe_block_info *gpe_block_list_head;	/* List of GPE blocks for this xrupt */
527e2f7a777SLen Brown 	u32 interrupt_number;	/* System interrupt number */
528e2f7a777SLen Brown };
529e2f7a777SLen Brown 
530e2f7a777SLen Brown struct acpi_gpe_walk_info {
531e2f7a777SLen Brown 	struct acpi_namespace_node *gpe_device;
532e2f7a777SLen Brown 	struct acpi_gpe_block_info *gpe_block;
533186c307fSBob Moore 	u16 count;
534186c307fSBob Moore 	acpi_owner_id owner_id;
535186c307fSBob Moore 	u8 execute_by_owner_id;
536e2f7a777SLen Brown };
537e2f7a777SLen Brown 
538e2f7a777SLen Brown struct acpi_gpe_device_info {
539e2f7a777SLen Brown 	u32 index;
540e2f7a777SLen Brown 	u32 next_block_base_index;
541e2f7a777SLen Brown 	acpi_status status;
542e2f7a777SLen Brown 	struct acpi_namespace_node *gpe_device;
543e2f7a777SLen Brown };
544e2f7a777SLen Brown 
5451f86e8c1SLv Zheng typedef acpi_status (*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *
5461f86e8c1SLv Zheng 					  gpe_xrupt_info,
547f5c1e1c5SLv Zheng 					  struct acpi_gpe_block_info *
548f5c1e1c5SLv Zheng 					  gpe_block, void *context);
549e2f7a777SLen Brown 
550e2f7a777SLen Brown /* Information about each particular fixed event */
551e2f7a777SLen Brown 
552e2f7a777SLen Brown struct acpi_fixed_event_handler {
553e2f7a777SLen Brown 	acpi_event_handler handler;	/* Address of handler. */
554e2f7a777SLen Brown 	void *context;		/* Context to be passed to handler */
555e2f7a777SLen Brown };
556e2f7a777SLen Brown 
557e2f7a777SLen Brown struct acpi_fixed_event_info {
558e2f7a777SLen Brown 	u8 status_register_id;
559e2f7a777SLen Brown 	u8 enable_register_id;
560e2f7a777SLen Brown 	u16 status_bit_mask;
561e2f7a777SLen Brown 	u16 enable_bit_mask;
562e2f7a777SLen Brown };
563e2f7a777SLen Brown 
564e2f7a777SLen Brown /* Information used during field processing */
565e2f7a777SLen Brown 
566e2f7a777SLen Brown struct acpi_field_info {
567e2f7a777SLen Brown 	u8 skip_field;
568e2f7a777SLen Brown 	u8 field_flag;
569e2f7a777SLen Brown 	u32 pkg_length;
570e2f7a777SLen Brown };
571e2f7a777SLen Brown 
572e2f7a777SLen Brown /*****************************************************************************
573e2f7a777SLen Brown  *
574e2f7a777SLen Brown  * Generic "state" object for stacks
575e2f7a777SLen Brown  *
576e2f7a777SLen Brown  ****************************************************************************/
577e2f7a777SLen Brown 
578e2f7a777SLen Brown #define ACPI_CONTROL_NORMAL                  0xC0
579e2f7a777SLen Brown #define ACPI_CONTROL_CONDITIONAL_EXECUTING   0xC1
580e2f7a777SLen Brown #define ACPI_CONTROL_PREDICATE_EXECUTING     0xC2
581e2f7a777SLen Brown #define ACPI_CONTROL_PREDICATE_FALSE         0xC3
582e2f7a777SLen Brown #define ACPI_CONTROL_PREDICATE_TRUE          0xC4
583e2f7a777SLen Brown 
584e2f7a777SLen Brown #define ACPI_STATE_COMMON \
585e2f7a777SLen Brown 	void                            *next; \
586e2f7a777SLen Brown 	u8                              descriptor_type; /* To differentiate various internal objs */\
587e2f7a777SLen Brown 	u8                              flags; \
588e2f7a777SLen Brown 	u16                             value; \
589e2f7a777SLen Brown 	u16                             state;
590e2f7a777SLen Brown 
591e2f7a777SLen Brown 	/* There are 2 bytes available here until the next natural alignment boundary */
592e2f7a777SLen Brown 
593e2f7a777SLen Brown struct acpi_common_state {
594e2f7a777SLen Brown ACPI_STATE_COMMON};
595e2f7a777SLen Brown 
596e2f7a777SLen Brown /*
597e2f7a777SLen Brown  * Update state - used to traverse complex objects such as packages
598e2f7a777SLen Brown  */
599e2f7a777SLen Brown struct acpi_update_state {
600e2f7a777SLen Brown 	ACPI_STATE_COMMON union acpi_operand_object *object;
601e2f7a777SLen Brown };
602e2f7a777SLen Brown 
603e2f7a777SLen Brown /*
604e2f7a777SLen Brown  * Pkg state - used to traverse nested package structures
605e2f7a777SLen Brown  */
606e2f7a777SLen Brown struct acpi_pkg_state {
607e2f7a777SLen Brown 	ACPI_STATE_COMMON u16 index;
608e2f7a777SLen Brown 	union acpi_operand_object *source_object;
609e2f7a777SLen Brown 	union acpi_operand_object *dest_object;
610e2f7a777SLen Brown 	struct acpi_walk_state *walk_state;
611e2f7a777SLen Brown 	void *this_target_obj;
612e2f7a777SLen Brown 	u32 num_packages;
613e2f7a777SLen Brown };
614e2f7a777SLen Brown 
615e2f7a777SLen Brown /*
616e2f7a777SLen Brown  * Control state - one per if/else and while constructs.
617e2f7a777SLen Brown  * Allows nesting of these constructs
618e2f7a777SLen Brown  */
619e2f7a777SLen Brown struct acpi_control_state {
620e2f7a777SLen Brown 	ACPI_STATE_COMMON u16 opcode;
621e2f7a777SLen Brown 	union acpi_parse_object *predicate_op;
622e2f7a777SLen Brown 	u8 *aml_predicate_start;	/* Start of if/while predicate */
623e2f7a777SLen Brown 	u8 *package_end;	/* End of if/while block */
624e2f7a777SLen Brown 	u32 loop_count;		/* While() loop counter */
625e2f7a777SLen Brown };
626e2f7a777SLen Brown 
627e2f7a777SLen Brown /*
628e2f7a777SLen Brown  * Scope state - current scope during namespace lookups
629e2f7a777SLen Brown  */
630e2f7a777SLen Brown struct acpi_scope_state {
631e2f7a777SLen Brown 	ACPI_STATE_COMMON struct acpi_namespace_node *node;
632e2f7a777SLen Brown };
633e2f7a777SLen Brown 
634e2f7a777SLen Brown struct acpi_pscope_state {
635e2f7a777SLen Brown 	ACPI_STATE_COMMON u32 arg_count;	/* Number of fixed arguments */
636e2f7a777SLen Brown 	union acpi_parse_object *op;	/* Current op being parsed */
637e2f7a777SLen Brown 	u8 *arg_end;		/* Current argument end */
638e2f7a777SLen Brown 	u8 *pkg_end;		/* Current package end */
639e2f7a777SLen Brown 	u32 arg_list;		/* Next argument to parse */
640e2f7a777SLen Brown };
641e2f7a777SLen Brown 
642e2f7a777SLen Brown /*
643e2f7a777SLen Brown  * Thread state - one per thread across multiple walk states. Multiple walk
644e2f7a777SLen Brown  * states are created when there are nested control methods executing.
645e2f7a777SLen Brown  */
646e2f7a777SLen Brown struct acpi_thread_state {
647e2f7a777SLen Brown 	ACPI_STATE_COMMON u8 current_sync_level;	/* Mutex Sync (nested acquire) level */
648e2f7a777SLen Brown 	struct acpi_walk_state *walk_state_list;	/* Head of list of walk_states for this thread */
649e2f7a777SLen Brown 	union acpi_operand_object *acquired_mutex_list;	/* List of all currently acquired mutexes */
650e2f7a777SLen Brown 	acpi_thread_id thread_id;	/* Running thread ID */
651e2f7a777SLen Brown };
652e2f7a777SLen Brown 
653e2f7a777SLen Brown /*
654e2f7a777SLen Brown  * Result values - used to accumulate the results of nested
655e2f7a777SLen Brown  * AML arguments
656e2f7a777SLen Brown  */
657e2f7a777SLen Brown struct acpi_result_values {
658e2f7a777SLen Brown 	ACPI_STATE_COMMON
659e2f7a777SLen Brown 	    union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM];
660e2f7a777SLen Brown };
661e2f7a777SLen Brown 
662e2f7a777SLen Brown typedef
663e2f7a777SLen Brown acpi_status (*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
664e2f7a777SLen Brown 				     union acpi_parse_object ** out_op);
665e2f7a777SLen Brown 
666f5c1e1c5SLv Zheng typedef
667f5c1e1c5SLv Zheng acpi_status (*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
668e2f7a777SLen Brown 
66986ed4bc8SBob Moore /* Global handlers for AML Notifies */
67086ed4bc8SBob Moore 
67186ed4bc8SBob Moore struct acpi_global_notify_handler {
67286ed4bc8SBob Moore 	acpi_notify_handler handler;
67386ed4bc8SBob Moore 	void *context;
67486ed4bc8SBob Moore };
67586ed4bc8SBob Moore 
676e2f7a777SLen Brown /*
677e2f7a777SLen Brown  * Notify info - used to pass info to the deferred notify
678e2f7a777SLen Brown  * handler/dispatcher.
679e2f7a777SLen Brown  */
680e2f7a777SLen Brown struct acpi_notify_info {
68186ed4bc8SBob Moore 	ACPI_STATE_COMMON u8 handler_list_id;
68286ed4bc8SBob Moore 	struct acpi_namespace_node *node;
68386ed4bc8SBob Moore 	union acpi_operand_object *handler_list_head;
68486ed4bc8SBob Moore 	struct acpi_global_notify_handler *global;
685e2f7a777SLen Brown };
686e2f7a777SLen Brown 
687e2f7a777SLen Brown /* Generic state is union of structs above */
688e2f7a777SLen Brown 
689e2f7a777SLen Brown union acpi_generic_state {
690e2f7a777SLen Brown 	struct acpi_common_state common;
691e2f7a777SLen Brown 	struct acpi_control_state control;
692e2f7a777SLen Brown 	struct acpi_update_state update;
693e2f7a777SLen Brown 	struct acpi_scope_state scope;
694e2f7a777SLen Brown 	struct acpi_pscope_state parse_scope;
695e2f7a777SLen Brown 	struct acpi_pkg_state pkg;
696e2f7a777SLen Brown 	struct acpi_thread_state thread;
697e2f7a777SLen Brown 	struct acpi_result_values results;
698e2f7a777SLen Brown 	struct acpi_notify_info notify;
699e2f7a777SLen Brown };
700e2f7a777SLen Brown 
701e2f7a777SLen Brown /*****************************************************************************
702e2f7a777SLen Brown  *
703e2f7a777SLen Brown  * Interpreter typedefs and structs
704e2f7a777SLen Brown  *
705e2f7a777SLen Brown  ****************************************************************************/
706e2f7a777SLen Brown 
707f5c1e1c5SLv Zheng typedef
708f5c1e1c5SLv Zheng acpi_status (*acpi_execute_op) (struct acpi_walk_state * walk_state);
709e2f7a777SLen Brown 
710f654c0feSLin Ming /* Address Range info block */
711f654c0feSLin Ming 
712f654c0feSLin Ming struct acpi_address_range {
713f654c0feSLin Ming 	struct acpi_address_range *next;
714f654c0feSLin Ming 	struct acpi_namespace_node *region_node;
715f654c0feSLin Ming 	acpi_physical_address start_address;
716f654c0feSLin Ming 	acpi_physical_address end_address;
717f654c0feSLin Ming };
718f654c0feSLin Ming 
719e2f7a777SLen Brown /*****************************************************************************
720e2f7a777SLen Brown  *
721e2f7a777SLen Brown  * Parser typedefs and structs
722e2f7a777SLen Brown  *
723e2f7a777SLen Brown  ****************************************************************************/
724e2f7a777SLen Brown 
725e2f7a777SLen Brown /*
726e2f7a777SLen Brown  * AML opcode, name, and argument layout
727e2f7a777SLen Brown  */
728e2f7a777SLen Brown struct acpi_opcode_info {
729e2f7a777SLen Brown #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
730e2f7a777SLen Brown 	char *name;		/* Opcode name (disassembler/debug only) */
731e2f7a777SLen Brown #endif
732e2f7a777SLen Brown 	u32 parse_args;		/* Grammar/Parse time arguments */
733e2f7a777SLen Brown 	u32 runtime_args;	/* Interpret time arguments */
734e2f7a777SLen Brown 	u16 flags;		/* Misc flags */
735e2f7a777SLen Brown 	u8 object_type;		/* Corresponding internal object type */
736e2f7a777SLen Brown 	u8 class;		/* Opcode class */
737e2f7a777SLen Brown 	u8 type;		/* Opcode type */
738e2f7a777SLen Brown };
739e2f7a777SLen Brown 
74075c8044fSLv Zheng /* Value associated with the parse object */
7413e8214e5SLv Zheng 
742e2f7a777SLen Brown union acpi_parse_value {
7435df7e6cbSBob Moore 	u64 integer;		/* Integer constant (Up to 64 bits) */
744e2f7a777SLen Brown 	u32 size;		/* bytelist or field size */
745e2f7a777SLen Brown 	char *string;		/* NULL terminated string */
746e2f7a777SLen Brown 	u8 *buffer;		/* buffer or string */
747e2f7a777SLen Brown 	char *name;		/* NULL terminated string */
748e2f7a777SLen Brown 	union acpi_parse_object *arg;	/* arguments and contained ops */
749e2f7a777SLen Brown };
750e2f7a777SLen Brown 
751a616dc2fSLv Zheng #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
752e2f7a777SLen Brown #define ACPI_DISASM_ONLY_MEMBERS(a)     a;
753e2f7a777SLen Brown #else
754e2f7a777SLen Brown #define ACPI_DISASM_ONLY_MEMBERS(a)
755e2f7a777SLen Brown #endif
756e2f7a777SLen Brown 
7579cf7adecSBob Moore #if defined(ACPI_ASL_COMPILER)
7589cf7adecSBob Moore #define ACPI_CONVERTER_ONLY_MEMBERS(a)  a;
7599cf7adecSBob Moore #else
7609cf7adecSBob Moore #define ACPI_CONVERTER_ONLY_MEMBERS(a)
7619cf7adecSBob Moore #endif
7629cf7adecSBob Moore 
763e2f7a777SLen Brown #define ACPI_PARSE_COMMON \
764e2f7a777SLen Brown 	union acpi_parse_object         *parent;            /* Parent op */\
765e2f7a777SLen Brown 	u8                              descriptor_type;    /* To differentiate various internal objs */\
766e2f7a777SLen Brown 	u8                              flags;              /* Type of Op */\
767e2f7a777SLen Brown 	u16                             aml_opcode;         /* AML opcode */\
768950a429cSLv Zheng 	u8                              *aml;               /* Address of declaration in AML */\
769e2f7a777SLen Brown 	union acpi_parse_object         *next;              /* Next op */\
770e2f7a777SLen Brown 	struct acpi_namespace_node      *node;              /* For use by interpreter */\
771e2f7a777SLen Brown 	union acpi_parse_value          value;              /* Value or args associated with the opcode */\
772e2f7a777SLen Brown 	u8                              arg_list_length;    /* Number of elements in the arg list */\
773e2f7a777SLen Brown 	 ACPI_DISASM_ONLY_MEMBERS (\
774a335e955SBob Moore 	u16                             disasm_flags;       /* Used during AML disassembly */\
775e2f7a777SLen Brown 	u8                              disasm_opcode;      /* Subtype used for disassembly */\
7765f040fc7SBob Moore 	char                            *operator_symbol;   /* Used for C-style operator name strings */\
7779cf7adecSBob Moore 	char                            aml_op_name[16])    /* Op name (debug only) */\
7789cf7adecSBob Moore 	 ACPI_CONVERTER_ONLY_MEMBERS (\
7799cf7adecSBob Moore 	char                            *inline_comment;    /* Inline comment */\
7809cf7adecSBob Moore 	char                            *end_node_comment;  /* End of node comment */\
7819cf7adecSBob Moore 	char                            *name_comment;      /* Comment associated with the first parameter of the name node */\
7829cf7adecSBob Moore 	char                            *close_brace_comment; /* Comments that come after } on the same as } */\
7839cf7adecSBob Moore 	struct acpi_comment_node        *comment_list;      /* comments that appears before this node */\
7849cf7adecSBob Moore 	struct acpi_comment_node        *end_blk_comment;   /* comments that at the end of a block but before ) or } */\
7859cf7adecSBob Moore 	char                            *cv_filename;       /* Filename associated with this node. Used for ASL/ASL+ converter */\
7869cf7adecSBob Moore 	char                            *cv_parent_filename)	/* Parent filename associated with this node. Used for ASL/ASL+ converter */
7879cf7adecSBob Moore 
7889cf7adecSBob Moore /* categories of comments */
7899cf7adecSBob Moore 
7909cf7adecSBob Moore typedef enum {
7919cf7adecSBob Moore 	STANDARD_COMMENT = 1,
7929cf7adecSBob Moore 	INLINE_COMMENT,
7939cf7adecSBob Moore 	ENDNODE_COMMENT,
7949cf7adecSBob Moore 	OPENBRACE_COMMENT,
7959cf7adecSBob Moore 	CLOSE_BRACE_COMMENT,
7969cf7adecSBob Moore 	STD_DEFBLK_COMMENT,
7979cf7adecSBob Moore 	END_DEFBLK_COMMENT,
7989cf7adecSBob Moore 	FILENAME_COMMENT,
7999cf7adecSBob Moore 	PARENTFILENAME_COMMENT,
8009cf7adecSBob Moore 	ENDBLK_COMMENT,
8019cf7adecSBob Moore 	INCLUDE_COMMENT
8029cf7adecSBob Moore } asl_comment_types;
803e2f7a777SLen Brown 
804a654b8caSDavid E. Box /* Internal opcodes for disasm_opcode field above */
805be030a57SBob Moore 
806be030a57SBob Moore #define ACPI_DASM_BUFFER                0x00	/* Buffer is a simple data buffer */
807be030a57SBob Moore #define ACPI_DASM_RESOURCE              0x01	/* Buffer is a Resource Descriptor */
808be030a57SBob Moore #define ACPI_DASM_STRING                0x02	/* Buffer is a ASCII string */
809be030a57SBob Moore #define ACPI_DASM_UNICODE               0x03	/* Buffer is a Unicode string */
810be030a57SBob Moore #define ACPI_DASM_PLD_METHOD            0x04	/* Buffer is a _PLD method bit-packed buffer */
81190da690bSBob Moore #define ACPI_DASM_UUID                  0x05	/* Buffer is a UUID/GUID */
81290da690bSBob Moore #define ACPI_DASM_EISAID                0x06	/* Integer is an EISAID */
81390da690bSBob Moore #define ACPI_DASM_MATCHOP               0x07	/* Parent opcode is a Match() operator */
81490da690bSBob Moore #define ACPI_DASM_LNOT_PREFIX           0x08	/* Start of a Lnot_equal (etc.) pair of opcodes */
81590da690bSBob Moore #define ACPI_DASM_LNOT_SUFFIX           0x09	/* End  of a Lnot_equal (etc.) pair of opcodes */
81690da690bSBob Moore #define ACPI_DASM_HID_STRING            0x0A	/* String is a _HID or _CID */
817a654b8caSDavid E. Box #define ACPI_DASM_IGNORE_SINGLE         0x0B	/* Ignore the opcode but not it's children */
818bee900dbSDavid E. Box #define ACPI_DASM_SWITCH                0x0C	/* While is a Switch */
819bee900dbSDavid E. Box #define ACPI_DASM_SWITCH_PREDICATE      0x0D	/* Object is a predicate for a Switch or Case block */
820bee900dbSDavid E. Box #define ACPI_DASM_CASE                  0x0E	/* If/Else is a Case in a Switch/Case block */
821bee900dbSDavid E. Box #define ACPI_DASM_DEFAULT               0x0F	/* Else is a Default in a Switch/Case block */
822e2f7a777SLen Brown 
823e2f7a777SLen Brown /*
8249cf7adecSBob Moore  * List struct used in the -ca option
8259cf7adecSBob Moore  */
8269cf7adecSBob Moore struct acpi_comment_node {
8279cf7adecSBob Moore 	char *comment;
8289cf7adecSBob Moore 	struct acpi_comment_node *next;
8299cf7adecSBob Moore };
8309cf7adecSBob Moore 
8319cf7adecSBob Moore struct acpi_comment_addr_node {
8329cf7adecSBob Moore 	u8 *addr;
8339cf7adecSBob Moore 	struct acpi_comment_addr_node *next;
8349cf7adecSBob Moore };
8359cf7adecSBob Moore 
8369cf7adecSBob Moore /*
8379cf7adecSBob Moore  * File node - used for "Include" operator file stack and
8389cf7adecSBob Moore  * depdendency tree for the -ca option
8399cf7adecSBob Moore  */
8409cf7adecSBob Moore struct acpi_file_node {
8419cf7adecSBob Moore 	void *file;
8429cf7adecSBob Moore 	char *filename;
8439cf7adecSBob Moore 	char *file_start;	/* Points to AML and indicates when the AML for this particular file starts. */
8449cf7adecSBob Moore 	char *file_end;		/* Points to AML and indicates when the AML for this particular file ends. */
8459cf7adecSBob Moore 	struct acpi_file_node *next;
8469cf7adecSBob Moore 	struct acpi_file_node *parent;
8479cf7adecSBob Moore 	u8 include_written;
8489cf7adecSBob Moore 	struct acpi_comment_node *include_comment;
8499cf7adecSBob Moore };
8509cf7adecSBob Moore 
8519cf7adecSBob Moore /*
852e2f7a777SLen Brown  * Generic operation (for example:  If, While, Store)
853e2f7a777SLen Brown  */
854e2f7a777SLen Brown struct acpi_parse_obj_common {
855e2f7a777SLen Brown ACPI_PARSE_COMMON};
856e2f7a777SLen Brown 
857e2f7a777SLen Brown /*
858e2f7a777SLen Brown  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
859e2f7a777SLen Brown  * and bytelists.
860e2f7a777SLen Brown  */
861e2f7a777SLen Brown struct acpi_parse_obj_named {
86205c3507cSErik Schmauss 	ACPI_PARSE_COMMON char *path;
863e2f7a777SLen Brown 	u8 *data;		/* AML body or bytelist data */
864e2f7a777SLen Brown 	u32 length;		/* AML length */
865e2f7a777SLen Brown 	u32 name;		/* 4-byte name or zero if no name */
866e2f7a777SLen Brown };
867e2f7a777SLen Brown 
868ba494beeSBob Moore /* This version is used by the iASL compiler only */
869e2f7a777SLen Brown 
870e2f7a777SLen Brown #define ACPI_MAX_PARSEOP_NAME   20
871e2f7a777SLen Brown 
872e2f7a777SLen Brown struct acpi_parse_obj_asl {
873e2f7a777SLen Brown 	ACPI_PARSE_COMMON union acpi_parse_object *child;
874e2f7a777SLen Brown 	union acpi_parse_object *parent_method;
875e2f7a777SLen Brown 	char *filename;
8769cf7adecSBob Moore 	u8 file_changed;
8779cf7adecSBob Moore 	char *parent_filename;
878e2f7a777SLen Brown 	char *external_name;
879e2f7a777SLen Brown 	char *namepath;
880e2f7a777SLen Brown 	char name_seg[4];
881e2f7a777SLen Brown 	u32 extra_value;
882e2f7a777SLen Brown 	u32 column;
883e2f7a777SLen Brown 	u32 line_number;
884e2f7a777SLen Brown 	u32 logical_line_number;
885e2f7a777SLen Brown 	u32 logical_byte_offset;
886e2f7a777SLen Brown 	u32 end_line;
887e2f7a777SLen Brown 	u32 end_logical_line;
888e2f7a777SLen Brown 	u32 acpi_btype;
889e2f7a777SLen Brown 	u32 aml_length;
890e2f7a777SLen Brown 	u32 aml_subtree_length;
891e2f7a777SLen Brown 	u32 final_aml_length;
892e2f7a777SLen Brown 	u32 final_aml_offset;
893e2f7a777SLen Brown 	u32 compile_flags;
894e2f7a777SLen Brown 	u16 parse_opcode;
895e2f7a777SLen Brown 	u8 aml_opcode_length;
896e2f7a777SLen Brown 	u8 aml_pkg_len_bytes;
897e2f7a777SLen Brown 	u8 extra;
898e2f7a777SLen Brown 	char parse_op_name[ACPI_MAX_PARSEOP_NAME];
899e2f7a777SLen Brown };
900e2f7a777SLen Brown 
901e2f7a777SLen Brown union acpi_parse_object {
902e2f7a777SLen Brown 	struct acpi_parse_obj_common common;
903e2f7a777SLen Brown 	struct acpi_parse_obj_named named;
904e2f7a777SLen Brown 	struct acpi_parse_obj_asl asl;
905e2f7a777SLen Brown };
906e2f7a777SLen Brown 
9079cf7adecSBob Moore struct asl_comment_state {
9089cf7adecSBob Moore 	u8 comment_type;
9099cf7adecSBob Moore 	u32 spaces_before;
9109cf7adecSBob Moore 	union acpi_parse_object *latest_parse_node;
9119cf7adecSBob Moore 	union acpi_parse_object *parsing_paren_brace_node;
9129cf7adecSBob Moore 	u8 capture_comments;
9139cf7adecSBob Moore };
9149cf7adecSBob Moore 
915e2f7a777SLen Brown /*
916e2f7a777SLen Brown  * Parse state - one state per parser invocation and each control
917e2f7a777SLen Brown  * method.
918e2f7a777SLen Brown  */
919e2f7a777SLen Brown struct acpi_parse_state {
920e2f7a777SLen Brown 	u8 *aml_start;		/* First AML byte */
921e2f7a777SLen Brown 	u8 *aml;		/* Next AML byte */
922e2f7a777SLen Brown 	u8 *aml_end;		/* (last + 1) AML byte */
923e2f7a777SLen Brown 	u8 *pkg_start;		/* Current package begin */
924e2f7a777SLen Brown 	u8 *pkg_end;		/* Current package end */
925e2f7a777SLen Brown 	union acpi_parse_object *start_op;	/* Root of parse tree */
926e2f7a777SLen Brown 	struct acpi_namespace_node *start_node;
927e2f7a777SLen Brown 	union acpi_generic_state *scope;	/* Current scope */
928e2f7a777SLen Brown 	union acpi_parse_object *start_scope;
929e2f7a777SLen Brown 	u32 aml_size;
930e2f7a777SLen Brown };
931e2f7a777SLen Brown 
932e2f7a777SLen Brown /* Parse object flags */
933e2f7a777SLen Brown 
934e2f7a777SLen Brown #define ACPI_PARSEOP_GENERIC                0x01
9355391abfdSBob Moore #define ACPI_PARSEOP_NAMED_OBJECT           0x02
936e2f7a777SLen Brown #define ACPI_PARSEOP_DEFERRED               0x04
937e2f7a777SLen Brown #define ACPI_PARSEOP_BYTELIST               0x08
938e2f7a777SLen Brown #define ACPI_PARSEOP_IN_STACK               0x10
939e2f7a777SLen Brown #define ACPI_PARSEOP_TARGET                 0x20
940e2f7a777SLen Brown #define ACPI_PARSEOP_IN_CACHE               0x80
941e2f7a777SLen Brown 
942e2f7a777SLen Brown /* Parse object disasm_flags */
943e2f7a777SLen Brown 
944a335e955SBob Moore #define ACPI_PARSEOP_IGNORE                 0x0001
945a335e955SBob Moore #define ACPI_PARSEOP_PARAMETER_LIST         0x0002
946a335e955SBob Moore #define ACPI_PARSEOP_EMPTY_TERMLIST         0x0004
947a335e955SBob Moore #define ACPI_PARSEOP_PREDEFINED_CHECKED     0x0008
948a335e955SBob Moore #define ACPI_PARSEOP_CLOSING_PAREN          0x0010
949a335e955SBob Moore #define ACPI_PARSEOP_COMPOUND_ASSIGNMENT    0x0020
950a335e955SBob Moore #define ACPI_PARSEOP_ASSIGNMENT             0x0040
951a335e955SBob Moore #define ACPI_PARSEOP_ELSEIF                 0x0080
952a335e955SBob Moore #define ACPI_PARSEOP_LEGACY_ASL_ONLY        0x0100
953e2f7a777SLen Brown 
954e2f7a777SLen Brown /*****************************************************************************
955e2f7a777SLen Brown  *
956e2f7a777SLen Brown  * Hardware (ACPI registers) and PNP
957e2f7a777SLen Brown  *
958e2f7a777SLen Brown  ****************************************************************************/
959e2f7a777SLen Brown 
960e2f7a777SLen Brown struct acpi_bit_register_info {
961e2f7a777SLen Brown 	u8 parent_register;
962e2f7a777SLen Brown 	u8 bit_position;
963e2f7a777SLen Brown 	u16 access_bit_mask;
964e2f7a777SLen Brown };
965e2f7a777SLen Brown 
966e2f7a777SLen Brown /*
967e2f7a777SLen Brown  * Some ACPI registers have bits that must be ignored -- meaning that they
968e2f7a777SLen Brown  * must be preserved.
969e2f7a777SLen Brown  */
970e2f7a777SLen Brown #define ACPI_PM1_STATUS_PRESERVED_BITS          0x0800	/* Bit 11 */
97120869dcfSBob Moore 
972c3dd25f4SLin Ming /* Write-only bits must be zeroed by software */
973c3dd25f4SLin Ming 
974c3dd25f4SLin Ming #define ACPI_PM1_CONTROL_WRITEONLY_BITS         0x2004	/* Bits 13, 2 */
975c3dd25f4SLin Ming 
97620869dcfSBob Moore /* For control registers, both ignored and reserved bits must be preserved */
97720869dcfSBob Moore 
978975b3c47SLin Ming /*
979b1cd843bSBob Moore  * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the
980b1cd843bSBob Moore  * ACPI specification to be a "preserved" bit - "OSPM always preserves this
981b1cd843bSBob Moore  * bit position", section 4.7.3.2.1. However, on some machines the OS must
982b1cd843bSBob Moore  * write a one to this bit after resume for the machine to work properly.
983b1cd843bSBob Moore  * To enable this, we no longer attempt to preserve this bit. No machines
984b1cd843bSBob Moore  * are known to fail if the bit is not preserved. (May 2009)
985975b3c47SLin Ming  */
986b1cd843bSBob Moore #define ACPI_PM1_CONTROL_IGNORED_BITS           0x0200	/* Bit 9 */
98720869dcfSBob Moore #define ACPI_PM1_CONTROL_RESERVED_BITS          0xC1F8	/* Bits 14-15, 3-8 */
98820869dcfSBob Moore #define ACPI_PM1_CONTROL_PRESERVED_BITS \
98920869dcfSBob Moore 	       (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS)
99020869dcfSBob Moore 
99120869dcfSBob Moore #define ACPI_PM2_CONTROL_PRESERVED_BITS         0xFFFFFFFE	/* All except bit 0 */
992e2f7a777SLen Brown 
993e2f7a777SLen Brown /*
994e2f7a777SLen Brown  * Register IDs
995e2f7a777SLen Brown  * These are the full ACPI registers
996e2f7a777SLen Brown  */
997e2f7a777SLen Brown #define ACPI_REGISTER_PM1_STATUS                0x01
998e2f7a777SLen Brown #define ACPI_REGISTER_PM1_ENABLE                0x02
999e2f7a777SLen Brown #define ACPI_REGISTER_PM1_CONTROL               0x03
100032c9ef99SBob Moore #define ACPI_REGISTER_PM2_CONTROL               0x04
100132c9ef99SBob Moore #define ACPI_REGISTER_PM_TIMER                  0x05
100232c9ef99SBob Moore #define ACPI_REGISTER_PROCESSOR_BLOCK           0x06
100332c9ef99SBob Moore #define ACPI_REGISTER_SMI_COMMAND_BLOCK         0x07
1004e2f7a777SLen Brown 
1005e2f7a777SLen Brown /* Masks used to access the bit_registers */
1006e2f7a777SLen Brown 
1007e2f7a777SLen Brown #define ACPI_BITMASK_TIMER_STATUS               0x0001
1008e2f7a777SLen Brown #define ACPI_BITMASK_BUS_MASTER_STATUS          0x0010
1009e2f7a777SLen Brown #define ACPI_BITMASK_GLOBAL_LOCK_STATUS         0x0020
1010e2f7a777SLen Brown #define ACPI_BITMASK_POWER_BUTTON_STATUS        0x0100
1011e2f7a777SLen Brown #define ACPI_BITMASK_SLEEP_BUTTON_STATUS        0x0200
1012e2f7a777SLen Brown #define ACPI_BITMASK_RT_CLOCK_STATUS            0x0400
1013e2f7a777SLen Brown #define ACPI_BITMASK_PCIEXP_WAKE_STATUS         0x4000	/* ACPI 3.0 */
1014e2f7a777SLen Brown #define ACPI_BITMASK_WAKE_STATUS                0x8000
1015e2f7a777SLen Brown 
1016e2f7a777SLen Brown #define ACPI_BITMASK_ALL_FIXED_STATUS           (\
1017e2f7a777SLen Brown 	ACPI_BITMASK_TIMER_STATUS          | \
1018e2f7a777SLen Brown 	ACPI_BITMASK_BUS_MASTER_STATUS     | \
1019e2f7a777SLen Brown 	ACPI_BITMASK_GLOBAL_LOCK_STATUS    | \
1020e2f7a777SLen Brown 	ACPI_BITMASK_POWER_BUTTON_STATUS   | \
1021e2f7a777SLen Brown 	ACPI_BITMASK_SLEEP_BUTTON_STATUS   | \
1022e2f7a777SLen Brown 	ACPI_BITMASK_RT_CLOCK_STATUS       | \
102349b3c1e0SColin Ian King 	ACPI_BITMASK_PCIEXP_WAKE_STATUS    | \
1024e2f7a777SLen Brown 	ACPI_BITMASK_WAKE_STATUS)
1025e2f7a777SLen Brown 
1026e2f7a777SLen Brown #define ACPI_BITMASK_TIMER_ENABLE               0x0001
1027e2f7a777SLen Brown #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE         0x0020
1028e2f7a777SLen Brown #define ACPI_BITMASK_POWER_BUTTON_ENABLE        0x0100
1029e2f7a777SLen Brown #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE        0x0200
1030e2f7a777SLen Brown #define ACPI_BITMASK_RT_CLOCK_ENABLE            0x0400
1031e2f7a777SLen Brown #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE        0x4000	/* ACPI 3.0 */
1032e2f7a777SLen Brown 
1033e2f7a777SLen Brown #define ACPI_BITMASK_SCI_ENABLE                 0x0001
1034e2f7a777SLen Brown #define ACPI_BITMASK_BUS_MASTER_RLD             0x0002
1035e2f7a777SLen Brown #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE        0x0004
103682d79b86SBob Moore #define ACPI_BITMASK_SLEEP_TYPE                 0x1C00
1037e2f7a777SLen Brown #define ACPI_BITMASK_SLEEP_ENABLE               0x2000
1038e2f7a777SLen Brown 
1039e2f7a777SLen Brown #define ACPI_BITMASK_ARB_DISABLE                0x0001
1040e2f7a777SLen Brown 
1041e2f7a777SLen Brown /* Raw bit position of each bit_register */
1042e2f7a777SLen Brown 
1043e2f7a777SLen Brown #define ACPI_BITPOSITION_TIMER_STATUS           0x00
1044e2f7a777SLen Brown #define ACPI_BITPOSITION_BUS_MASTER_STATUS      0x04
1045e2f7a777SLen Brown #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS     0x05
1046e2f7a777SLen Brown #define ACPI_BITPOSITION_POWER_BUTTON_STATUS    0x08
1047e2f7a777SLen Brown #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS    0x09
1048e2f7a777SLen Brown #define ACPI_BITPOSITION_RT_CLOCK_STATUS        0x0A
1049e2f7a777SLen Brown #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS     0x0E	/* ACPI 3.0 */
1050e2f7a777SLen Brown #define ACPI_BITPOSITION_WAKE_STATUS            0x0F
1051e2f7a777SLen Brown 
1052e2f7a777SLen Brown #define ACPI_BITPOSITION_TIMER_ENABLE           0x00
1053e2f7a777SLen Brown #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE     0x05
1054e2f7a777SLen Brown #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE    0x08
1055e2f7a777SLen Brown #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE    0x09
1056e2f7a777SLen Brown #define ACPI_BITPOSITION_RT_CLOCK_ENABLE        0x0A
1057e2f7a777SLen Brown #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE    0x0E	/* ACPI 3.0 */
1058e2f7a777SLen Brown 
1059e2f7a777SLen Brown #define ACPI_BITPOSITION_SCI_ENABLE             0x00
1060e2f7a777SLen Brown #define ACPI_BITPOSITION_BUS_MASTER_RLD         0x01
1061e2f7a777SLen Brown #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE    0x02
106282d79b86SBob Moore #define ACPI_BITPOSITION_SLEEP_TYPE             0x0A
1063e2f7a777SLen Brown #define ACPI_BITPOSITION_SLEEP_ENABLE           0x0D
1064e2f7a777SLen Brown 
1065e2f7a777SLen Brown #define ACPI_BITPOSITION_ARB_DISABLE            0x00
1066e2f7a777SLen Brown 
10677f071903SBob Moore /* Structs and definitions for _OSI support and I/O port validation */
10687f071903SBob Moore 
10697f071903SBob Moore #define ACPI_ALWAYS_ILLEGAL             0x00
10707f071903SBob Moore 
10717f071903SBob Moore struct acpi_interface_info {
10727f071903SBob Moore 	char *name;
1073b0ed7a91SLin Ming 	struct acpi_interface_info *next;
1074b0ed7a91SLin Ming 	u8 flags;
10757f071903SBob Moore 	u8 value;
10767f071903SBob Moore };
10777f071903SBob Moore 
1078b0ed7a91SLin Ming #define ACPI_OSI_INVALID                0x01
1079b0ed7a91SLin Ming #define ACPI_OSI_DYNAMIC                0x02
10802cf9f5bcSLv Zheng #define ACPI_OSI_FEATURE                0x04
10812cf9f5bcSLv Zheng #define ACPI_OSI_DEFAULT_INVALID        0x08
10822cf9f5bcSLv Zheng #define ACPI_OSI_OPTIONAL_FEATURE       (ACPI_OSI_FEATURE | ACPI_OSI_DEFAULT_INVALID | ACPI_OSI_INVALID)
1083b0ed7a91SLin Ming 
10847f071903SBob Moore struct acpi_port_info {
10857f071903SBob Moore 	char *name;
10867f071903SBob Moore 	u16 start;
10877f071903SBob Moore 	u16 end;
10887f071903SBob Moore 	u8 osi_dependency;
10897f071903SBob Moore };
10907f071903SBob Moore 
1091e2f7a777SLen Brown /*****************************************************************************
1092e2f7a777SLen Brown  *
1093e2f7a777SLen Brown  * Resource descriptors
1094e2f7a777SLen Brown  *
1095e2f7a777SLen Brown  ****************************************************************************/
1096e2f7a777SLen Brown 
1097e2f7a777SLen Brown /* resource_type values */
1098e2f7a777SLen Brown 
1099e2f7a777SLen Brown #define ACPI_ADDRESS_TYPE_MEMORY_RANGE          0
1100e2f7a777SLen Brown #define ACPI_ADDRESS_TYPE_IO_RANGE              1
1101e2f7a777SLen Brown #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE      2
1102e2f7a777SLen Brown 
1103e2f7a777SLen Brown /* Resource descriptor types and masks */
1104e2f7a777SLen Brown 
1105e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_LARGE                0x80
1106e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_SMALL                0x00
1107e2f7a777SLen Brown 
1108e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_SMALL_MASK           0x78	/* Bits 6:3 contain the type */
1109e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK    0x07	/* Bits 2:0 contain the length */
1110e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_LARGE_MASK           0x7F	/* Bits 6:0 contain the type */
1111e2f7a777SLen Brown 
1112e2f7a777SLen Brown /*
1113e2f7a777SLen Brown  * Small resource descriptor "names" as defined by the ACPI specification.
1114e2f7a777SLen Brown  * Note: Bits 2:0 are used for the descriptor length
1115e2f7a777SLen Brown  */
1116e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_IRQ                  0x20
1117e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_DMA                  0x28
1118e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_START_DEPENDENT      0x30
1119e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_END_DEPENDENT        0x38
1120e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_IO                   0x40
1121e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_FIXED_IO             0x48
1122e0fe0a8dSLin Ming #define ACPI_RESOURCE_NAME_FIXED_DMA            0x50
1123e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_RESERVED_S2          0x58
1124e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_RESERVED_S3          0x60
1125e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_RESERVED_S4          0x68
1126e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_VENDOR_SMALL         0x70
1127e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_END_TAG              0x78
1128e2f7a777SLen Brown 
1129e2f7a777SLen Brown /*
1130e2f7a777SLen Brown  * Large resource descriptor "names" as defined by the ACPI specification.
1131e2f7a777SLen Brown  * Note: includes the Large Descriptor bit in bit[7]
1132e2f7a777SLen Brown  */
1133e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_MEMORY24             0x81
1134e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_GENERIC_REGISTER     0x82
1135e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_RESERVED_L1          0x83
1136e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_VENDOR_LARGE         0x84
1137e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_MEMORY32             0x85
1138e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_FIXED_MEMORY32       0x86
1139e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_ADDRESS32            0x87
1140e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_ADDRESS16            0x88
1141e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_EXTENDED_IRQ         0x89
1142e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_ADDRESS64            0x8A
1143e2f7a777SLen Brown #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64   0x8B
1144e0fe0a8dSLin Ming #define ACPI_RESOURCE_NAME_GPIO                 0x8C
11452b726930SMika Westerberg #define ACPI_RESOURCE_NAME_PIN_FUNCTION         0x8D
1146e0fe0a8dSLin Ming #define ACPI_RESOURCE_NAME_SERIAL_BUS           0x8E
114797028ce6SMika Westerberg #define ACPI_RESOURCE_NAME_PIN_CONFIG           0x8F
1148fdaa0980SMika Westerberg #define ACPI_RESOURCE_NAME_PIN_GROUP            0x90
1149f8a6c866SMika Westerberg #define ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION   0x91
1150*044b7239SMika Westerberg #define ACPI_RESOURCE_NAME_PIN_GROUP_CONFIG     0x92
1151*044b7239SMika Westerberg #define ACPI_RESOURCE_NAME_LARGE_MAX            0x92
1152e2f7a777SLen Brown 
1153e2f7a777SLen Brown /*****************************************************************************
1154e2f7a777SLen Brown  *
1155e2f7a777SLen Brown  * Miscellaneous
1156e2f7a777SLen Brown  *
1157e2f7a777SLen Brown  ****************************************************************************/
1158e2f7a777SLen Brown 
1159e2f7a777SLen Brown #define ACPI_ASCII_ZERO                 0x30
1160e2f7a777SLen Brown 
1161e2f7a777SLen Brown /*****************************************************************************
1162e2f7a777SLen Brown  *
116356324c10SLv Zheng  * Disassembler
116456324c10SLv Zheng  *
116556324c10SLv Zheng  ****************************************************************************/
116656324c10SLv Zheng 
116756324c10SLv Zheng struct acpi_external_list {
116856324c10SLv Zheng 	char *path;
116956324c10SLv Zheng 	char *internal_path;
117056324c10SLv Zheng 	struct acpi_external_list *next;
117156324c10SLv Zheng 	u32 value;
117256324c10SLv Zheng 	u16 length;
11735af2b635SBob Moore 	u16 flags;
117456324c10SLv Zheng 	u8 type;
117556324c10SLv Zheng };
117656324c10SLv Zheng 
117756324c10SLv Zheng /* Values for Flags field above */
117856324c10SLv Zheng 
11795af2b635SBob Moore #define ACPI_EXT_RESOLVED_REFERENCE         0x01	/* Object was resolved during cross ref */
11805af2b635SBob Moore #define ACPI_EXT_ORIGIN_FROM_FILE           0x02	/* External came from a file */
11815af2b635SBob Moore #define ACPI_EXT_INTERNAL_PATH_ALLOCATED    0x04	/* Deallocate internal path on completion */
11825af2b635SBob Moore #define ACPI_EXT_EXTERNAL_EMITTED           0x08	/* External() statement has been emitted */
11837447bc1eSBob Moore #define ACPI_EXT_ORIGIN_FROM_OPCODE         0x10	/* External came from a External() opcode */
118456324c10SLv Zheng 
118556324c10SLv Zheng struct acpi_external_file {
118656324c10SLv Zheng 	char *path;
118756324c10SLv Zheng 	struct acpi_external_file *next;
118856324c10SLv Zheng };
118956324c10SLv Zheng 
1190a86c856eSDavid E. Box struct acpi_parse_object_list {
1191a86c856eSDavid E. Box 	union acpi_parse_object *op;
1192a86c856eSDavid E. Box 	struct acpi_parse_object_list *next;
1193a86c856eSDavid E. Box };
1194a86c856eSDavid E. Box 
119556324c10SLv Zheng /*****************************************************************************
119656324c10SLv Zheng  *
1197e2f7a777SLen Brown  * Debugger
1198e2f7a777SLen Brown  *
1199e2f7a777SLen Brown  ****************************************************************************/
1200e2f7a777SLen Brown 
1201e2f7a777SLen Brown struct acpi_db_method_info {
1202be030a57SBob Moore 	acpi_handle method;
1203e2f7a777SLen Brown 	acpi_handle main_thread_gate;
1204e2f7a777SLen Brown 	acpi_handle thread_complete_gate;
1205f540fadfSLv Zheng 	acpi_handle info_gate;
120628eb3fcfSLin Ming 	acpi_thread_id *threads;
1207e2f7a777SLen Brown 	u32 num_threads;
1208e2f7a777SLen Brown 	u32 num_created;
1209e2f7a777SLen Brown 	u32 num_completed;
1210e2f7a777SLen Brown 
1211e2f7a777SLen Brown 	char *name;
1212e2f7a777SLen Brown 	u32 flags;
1213e2f7a777SLen Brown 	u32 num_loops;
121473424473SBob Moore 	char pathname[ACPI_DB_LINE_BUFFER_SIZE];
1215e2f7a777SLen Brown 	char **args;
1216f540fadfSLv Zheng 	acpi_object_type *types;
1217e2f7a777SLen Brown 
1218e2f7a777SLen Brown 	/*
1219e2f7a777SLen Brown 	 * Arguments to be passed to method for the command
1220e2f7a777SLen Brown 	 * Threads -
1221e2f7a777SLen Brown 	 *   the Number of threads, ID of current thread and
1222e2f7a777SLen Brown 	 *   Index of current thread inside all them created.
1223e2f7a777SLen Brown 	 */
1224e2f7a777SLen Brown 	char init_args;
122502ca26beSLv Zheng #ifdef ACPI_DEBUGGER
122602ca26beSLv Zheng 	acpi_object_type arg_types[4];
122702ca26beSLv Zheng #endif
1228e2f7a777SLen Brown 	char *arguments[4];
1229e2f7a777SLen Brown 	char num_threads_str[11];
1230e2f7a777SLen Brown 	char id_of_thread_str[11];
1231e2f7a777SLen Brown 	char index_of_thread_str[11];
1232e2f7a777SLen Brown };
1233e2f7a777SLen Brown 
1234e2f7a777SLen Brown struct acpi_integrity_info {
1235e2f7a777SLen Brown 	u32 nodes;
1236e2f7a777SLen Brown 	u32 objects;
1237e2f7a777SLen Brown };
1238e2f7a777SLen Brown 
12391b673f23STomasz Nowicki #define ACPI_DB_DISABLE_OUTPUT          0x00
1240e2f7a777SLen Brown #define ACPI_DB_REDIRECTABLE_OUTPUT     0x01
1241e2f7a777SLen Brown #define ACPI_DB_CONSOLE_OUTPUT          0x02
1242e2f7a777SLen Brown #define ACPI_DB_DUPLICATE_OUTPUT        0x03
1243e2f7a777SLen Brown 
1244e69ab9a9SBob Moore struct acpi_object_info {
1245e69ab9a9SBob Moore 	u32 types[ACPI_TOTAL_TYPES];
1246e69ab9a9SBob Moore };
1247e69ab9a9SBob Moore 
1248e2f7a777SLen Brown /*****************************************************************************
1249e2f7a777SLen Brown  *
1250e2f7a777SLen Brown  * Debug
1251e2f7a777SLen Brown  *
1252e2f7a777SLen Brown  ****************************************************************************/
1253e2f7a777SLen Brown 
1254e2f7a777SLen Brown /* Entry for a memory allocation (debug only) */
1255e2f7a777SLen Brown 
1256e2f7a777SLen Brown #define ACPI_MEM_MALLOC                 0
1257e2f7a777SLen Brown #define ACPI_MEM_CALLOC                 1
1258e2f7a777SLen Brown #define ACPI_MAX_MODULE_NAME            16
1259e2f7a777SLen Brown 
1260e2f7a777SLen Brown #define ACPI_COMMON_DEBUG_MEM_HEADER \
1261e2f7a777SLen Brown 	struct acpi_debug_mem_block     *previous; \
1262e2f7a777SLen Brown 	struct acpi_debug_mem_block     *next; \
1263e2f7a777SLen Brown 	u32                             size; \
1264e2f7a777SLen Brown 	u32                             component; \
1265e2f7a777SLen Brown 	u32                             line; \
1266e2f7a777SLen Brown 	char                            module[ACPI_MAX_MODULE_NAME]; \
1267e2f7a777SLen Brown 	u8                              alloc_type;
1268e2f7a777SLen Brown 
1269e2f7a777SLen Brown struct acpi_debug_mem_header {
1270e2f7a777SLen Brown ACPI_COMMON_DEBUG_MEM_HEADER};
1271e2f7a777SLen Brown 
1272e2f7a777SLen Brown struct acpi_debug_mem_block {
1273e2f7a777SLen Brown 	ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
1274e2f7a777SLen Brown };
1275e2f7a777SLen Brown 
1276e2f7a777SLen Brown #define ACPI_MEM_LIST_GLOBAL            0
1277e2f7a777SLen Brown #define ACPI_MEM_LIST_NSNODE            1
1278e2f7a777SLen Brown #define ACPI_MEM_LIST_MAX               1
1279e2f7a777SLen Brown #define ACPI_NUM_MEM_LISTS              2
1280e2f7a777SLen Brown 
128140cdb368SBob Moore /*****************************************************************************
128240cdb368SBob Moore  *
128340cdb368SBob Moore  * Info/help support
128440cdb368SBob Moore  *
128540cdb368SBob Moore  ****************************************************************************/
128640cdb368SBob Moore 
128740cdb368SBob Moore struct ah_predefined_name {
128840cdb368SBob Moore 	char *name;
128940cdb368SBob Moore 	char *description;
129040cdb368SBob Moore #ifndef ACPI_ASL_COMPILER
129140cdb368SBob Moore 	char *action;
129240cdb368SBob Moore #endif
129340cdb368SBob Moore };
129440cdb368SBob Moore 
1295b944b29cSBob Moore struct ah_device_id {
1296b944b29cSBob Moore 	char *name;
1297b944b29cSBob Moore 	char *description;
1298b944b29cSBob Moore };
1299b944b29cSBob Moore 
130073bbca04SBob Moore struct ah_uuid {
130173bbca04SBob Moore 	char *description;
130273bbca04SBob Moore 	char *string;
130373bbca04SBob Moore };
130473bbca04SBob Moore 
13050bb346ccSBob Moore struct ah_table {
13060bb346ccSBob Moore 	char *signature;
13070bb346ccSBob Moore 	char *description;
13080bb346ccSBob Moore };
13090bb346ccSBob Moore 
1310e2f7a777SLen Brown #endif				/* __ACLOCAL_H__ */
1311