1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef __DEV_ACPI_AMLTYPES_H__
19 #define __DEV_ACPI_AMLTYPES_H__
20
21
22 #define AMLOP_ZERO 0x00
23 #define AMLOP_ONE 0x01
24 #define AMLOP_ALIAS 0x06
25 #define AMLOP_NAME 0x08
26 #define AMLOP_BYTEPREFIX 0x0A
27 #define AMLOP_WORDPREFIX 0x0B
28 #define AMLOP_DWORDPREFIX 0x0C
29 #define AMLOP_STRINGPREFIX 0x0D
30 #define AMLOP_QWORDPREFIX 0x0E
31 #define AMLOP_SCOPE 0x10
32 #define AMLOP_BUFFER 0x11
33 #define AMLOP_PACKAGE 0x12
34 #define AMLOP_VARPACKAGE 0x13
35 #define AMLOP_METHOD 0x14
36 #define AMLOP_DUALNAMEPREFIX 0x2E
37 #define AMLOP_MULTINAMEPREFIX 0x2F
38 #define AMLOP_EXTPREFIX 0x5B
39 #define AMLOP_MUTEX 0x5B01
40 #define AMLOP_EVENT 0x5B02
41 #define AMLOP_CONDREFOF 0x5B12
42 #define AMLOP_CREATEFIELD 0x5B13
43 #define AMLOP_LOADTABLE 0x5B1F
44 #define AMLOP_LOAD 0x5B20
45 #define AMLOP_STALL 0x5B21
46 #define AMLOP_SLEEP 0x5B22
47 #define AMLOP_ACQUIRE 0x5B23
48 #define AMLOP_SIGNAL 0x5B24
49 #define AMLOP_WAIT 0x5B25
50 #define AMLOP_RESET 0x5B26
51 #define AMLOP_RELEASE 0x5B27
52 #define AMLOP_FROMBCD 0x5B28
53 #define AMLOP_TOBCD 0x5B29
54 #define AMLOP_UNLOAD 0x5B2A
55 #define AMLOP_REVISION 0x5B30
56 #define AMLOP_DEBUG 0x5B31
57 #define AMLOP_FATAL 0x5B32
58 #define AMLOP_TIMER 0x5B33
59 #define AMLOP_OPREGION 0x5B80
60 #define AMLOP_FIELD 0x5B81
61 #define AMLOP_DEVICE 0x5B82
62 #define AMLOP_PROCESSOR 0x5B83
63 #define AMLOP_POWERRSRC 0x5B84
64 #define AMLOP_THERMALZONE 0x5B85
65 #define AMLOP_INDEXFIELD 0x5B86
66 #define AMLOP_BANKFIELD 0x5B87
67 #define AMLOP_DATAREGION 0x5B88
68 #define AMLOP_ROOTCHAR 0x5C
69 #define AMLOP_PARENTPREFIX 0x5E
70 #define AMLOP_NAMECHAR 0x5F
71 #define AMLOP_LOCAL0 0x60
72 #define AMLOP_LOCAL1 0x61
73 #define AMLOP_LOCAL2 0x62
74 #define AMLOP_LOCAL3 0x63
75 #define AMLOP_LOCAL4 0x64
76 #define AMLOP_LOCAL5 0x65
77 #define AMLOP_LOCAL6 0x66
78 #define AMLOP_LOCAL7 0x67
79 #define AMLOP_ARG0 0x68
80 #define AMLOP_ARG1 0x69
81 #define AMLOP_ARG2 0x6A
82 #define AMLOP_ARG3 0x6B
83 #define AMLOP_ARG4 0x6C
84 #define AMLOP_ARG5 0x6D
85 #define AMLOP_ARG6 0x6E
86 #define AMLOP_STORE 0x70
87 #define AMLOP_REFOF 0x71
88 #define AMLOP_ADD 0x72
89 #define AMLOP_CONCAT 0x73
90 #define AMLOP_SUBTRACT 0x74
91 #define AMLOP_INCREMENT 0x75
92 #define AMLOP_DECREMENT 0x76
93 #define AMLOP_MULTIPLY 0x77
94 #define AMLOP_DIVIDE 0x78
95 #define AMLOP_SHL 0x79
96 #define AMLOP_SHR 0x7A
97 #define AMLOP_AND 0x7B
98 #define AMLOP_NAND 0x7C
99 #define AMLOP_OR 0x7D
100 #define AMLOP_NOR 0x7E
101 #define AMLOP_XOR 0x7F
102 #define AMLOP_NOT 0x80
103 #define AMLOP_FINDSETLEFTBIT 0x81
104 #define AMLOP_FINDSETRIGHTBIT 0x82
105 #define AMLOP_DEREFOF 0x83
106 #define AMLOP_CONCATRES 0x84
107 #define AMLOP_MOD 0x85
108 #define AMLOP_NOTIFY 0x86
109 #define AMLOP_SIZEOF 0x87
110 #define AMLOP_INDEX 0x88
111 #define AMLOP_DEREFOF 0x83
112 #define AMLOP_MATCH 0x89
113 #define AMLOP_CREATEDWORDFIELD 0x8A
114 #define AMLOP_CREATEWORDFIELD 0x8B
115 #define AMLOP_CREATEBYTEFIELD 0x8C
116 #define AMLOP_CREATEBITFIELD 0x8D
117 #define AMLOP_OBJECTTYPE 0x8E
118 #define AMLOP_CREATEQWORDFIELD 0x8F
119 #define AMLOP_LAND 0x90
120 #define AMLOP_LOR 0x91
121 #define AMLOP_LNOT 0x92
122 #define AMLOP_LNOTEQUAL 0x9293
123 #define AMLOP_LLESSEQUAL 0x9294
124 #define AMLOP_LGREATEREQUAL 0x9295
125 #define AMLOP_LEQUAL 0x93
126 #define AMLOP_LGREATER 0x94
127 #define AMLOP_LLESS 0x95
128 #define AMLOP_TOBUFFER 0x96
129 #define AMLOP_TODECSTRING 0x97
130 #define AMLOP_TOHEXSTRING 0x98
131 #define AMLOP_TOINTEGER 0x99
132 #define AMLOP_TOSTRING 0x9C
133 #define AMLOP_COPYOBJECT 0x9D
134 #define AMLOP_MID 0x9E
135 #define AMLOP_CONTINUE 0x9F
136 #define AMLOP_IF 0xA0
137 #define AMLOP_ELSE 0xA1
138 #define AMLOP_WHILE 0xA2
139 #define AMLOP_NOP 0xA3
140 #define AMLOP_RETURN 0xA4
141 #define AMLOP_BREAK 0xA5
142 #define AMLOP_BREAKPOINT 0xCC
143 #define AMLOP_ONES 0xFF
144
145 #define AMLOP_FIELDUNIT 0xFE00
146 #define AML_ANYINT 0xFF00
147
148
149
150
151
152
153 #define AML_MATCH_TR 0
154 #define AML_MATCH_EQ 1
155 #define AML_MATCH_LE 2
156 #define AML_MATCH_LT 3
157 #define AML_MATCH_GE 4
158 #define AML_MATCH_GT 5
159
160 #define AML_STATIC 0x8000
161
162
163 enum aml_objecttype {
164 AML_OBJTYPE_UNINITIALIZED = 0,
165 AML_OBJTYPE_INTEGER,
166 AML_OBJTYPE_STRING,
167 AML_OBJTYPE_BUFFER,
168 AML_OBJTYPE_PACKAGE,
169 AML_OBJTYPE_FIELDUNIT,
170 AML_OBJTYPE_DEVICE,
171 AML_OBJTYPE_EVENT,
172 AML_OBJTYPE_METHOD,
173 AML_OBJTYPE_MUTEX,
174 AML_OBJTYPE_OPREGION,
175 AML_OBJTYPE_POWERRSRC,
176 AML_OBJTYPE_PROCESSOR,
177 AML_OBJTYPE_THERMZONE,
178 AML_OBJTYPE_BUFFERFIELD,
179 AML_OBJTYPE_DDBHANDLE,
180 AML_OBJTYPE_DEBUGOBJ,
181
182 AML_OBJTYPE_NAMEREF = 0x100,
183 AML_OBJTYPE_OBJREF,
184 AML_OBJTYPE_STATICINT=AML_OBJTYPE_INTEGER|AML_STATIC,
185 };
186
187
188 #define AML_ARG_INTEGER 'i'
189 #define AML_ARG_BYTE 'b'
190 #define AML_ARG_WORD 'w'
191 #define AML_ARG_DWORD 'd'
192 #define AML_ARG_QWORD 'q'
193 #define AML_ARG_IMPBYTE '!'
194 #define AML_ARG_OBJLEN 'p'
195 #define AML_ARG_STRING 'a'
196 #define AML_ARG_BYTELIST 'B'
197 #define AML_ARG_REVISION 'R'
198
199 #define AML_ARG_METHOD 'M'
200 #define AML_ARG_NAMESTRING 'N'
201 #define AML_ARG_NAMEREF 'n'
202 #define AML_ARG_FIELDLIST 'F'
203 #define AML_ARG_FLAG 'f'
204
205 #define AML_ARG_DATAOBJLIST 'O'
206 #define AML_ARG_DATAOBJ 'o'
207
208 #define AML_ARG_SIMPLENAME 's'
209 #define AML_ARG_SUPERNAME 'S'
210
211 #define AML_ARG_TERMOBJLIST 'T'
212 #define AML_ARG_TERMOBJ 't'
213
214 #define AML_METHOD_ARGCOUNT(v) (((v) >> 0) & 0x7)
215 #define AML_METHOD_SERIALIZED(v) (((v) >> 3) & 0x1)
216 #define AML_METHOD_SYNCLEVEL(v) (((v) >> 4) & 0xF)
217
218 #define AML_FIELD_ACCESSMASK 0x0F
219 #define AML_FIELD_SETATTR(f,t,a) (((f) & 0xF0) | ((t) & 0xF) | ((a)<<8))
220 #define AML_FIELD_ACCESS(v) (((v) >> 0) & 0xF)
221 # define AML_FIELD_ANYACC 0x0
222 # define AML_FIELD_BYTEACC 0x1
223 # define AML_FIELD_WORDACC 0x2
224 # define AML_FIELD_DWORDACC 0x3
225 # define AML_FIELD_QWORDACC 0x4
226 # define AML_FIELD_BUFFERACC 0x5
227 #define AML_FIELD_LOCK(v) (((v) >> 4) & 0x1)
228 # define AML_FIELD_LOCK_OFF 0x0
229 # define AML_FIELD_LOCK_ON 0x1
230 #define AML_FIELD_UPDATE(v) (((v) >> 5) & 0x3)
231 # define AML_FIELD_PRESERVE 0x0
232 # define AML_FIELD_WRITEASONES 0x1
233 # define AML_FIELD_WRITEASZEROES 0x2
234 #define AML_FIELD_ATTR(v) ((v) >> 8)
235 #define AML_FIELD_RESERVED 0x00
236
237 #define AML_FIELD_ATTR__ 0x01
238
239 struct aml_scope;
240 struct aml_node;
241
242
243 struct aml_value {
244 int type;
245 int length;
246 int refcnt;
247 int stack;
248 struct aml_node *node;
249 union {
250 int64_t vinteger;
251 char *vstring;
252 u_int8_t *vbuffer;
253 struct aml_value **vpackage;
254 struct {
255 u_int8_t iospace;
256 u_int64_t iobase;
257 u_int32_t iolen;
258 } vopregion;
259 struct {
260 int flags;
261 u_int8_t *start;
262 u_int8_t *end;
263 struct aml_value *(*fneval)(struct aml_scope *, struct aml_value *);
264 } vmethod;
265 struct {
266 u_int16_t type;
267 u_int16_t flags;
268 u_int32_t bitpos;
269 u_int32_t bitlen;
270 struct aml_value *ref1;
271 struct aml_value *ref2;
272 int ref3;
273 } vfield;
274 struct {
275 u_int8_t proc_id;
276 u_int32_t proc_addr;
277 u_int8_t proc_len;
278 } vprocessor;
279 struct {
280 int index;
281 struct aml_value *ref;
282 } vobjref;
283 struct {
284 u_int8_t pwr_level;
285 u_int16_t pwr_order;
286 } vpowerrsrc;
287 struct acpi_mutex *vmutex;
288 } _;
289 };
290
291 #define v_nameref _.vbuffer
292 #define v_objref _.vobjref
293 #define v_integer _.vinteger
294 #define v_string _.vstring
295 #define v_buffer _.vbuffer
296 #define v_package _.vpackage
297 #define v_field _.vfield
298 #define v_opregion _.vopregion
299 #define v_method _.vmethod
300 #define v_processor _.vprocessor
301 #define v_powerrsrc _.vpowerrsrc
302 #define v_mutex _.vmutex
303
304 #define xaml_intval(v) ((v)->v_integer)
305 #define aml_strlen(v) ((v)->length)
306 #define aml_strval(v) ((v)->v_string ? (v)->v_string : "bad string")
307 #define aml_buflen(v) ((v)->length)
308 #define aml_bufval(v) ((v)->v_buffer)
309 #define aml_pkglen(v) ((v)->length)
310 #define aml_pkgval(v,i) (&(v)->v_package[(i)])
311
312 struct aml_node {
313 struct aml_node *parent;
314 struct aml_node *child;
315 struct aml_node *sibling;
316
317 char name[5];
318 u_int16_t opcode;
319 u_int8_t *start;
320 u_int8_t *end;
321
322
323
324 struct aml_value *value;
325
326 int depth;
327 };
328
329 #define AML_FALSE (0)
330 #define AML_TRUE (1)
331
332 #define aml_bitmask(n) (1L << ((n) & 0x7))
333 #define aml_bitpos(n) ((n)&0x7)
334 #define aml_bytepos(n) ((n)>>3)
335 #define aml_bytelen(n) (((n)+7)>>3)
336 #define aml_bytealigned(x) !((x)&0x7)
337
338 #endif