File: /usr/src/linux/drivers/acpi/include/amlcode.h

1     /******************************************************************************
2      *
3      * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
4      *                   Declarations and definitions contained herein are derived
5      *                   directly from the ACPI specification.
6      *       $Revision: 53 $
7      *
8      *****************************************************************************/
9     
10     /*
11      *  Copyright (C) 2000, 2001 R. Byron Moore
12      *
13      *  This program is free software; you can redistribute it and/or modify
14      *  it under the terms of the GNU General Public License as published by
15      *  the Free Software Foundation; either version 2 of the License, or
16      *  (at your option) any later version.
17      *
18      *  This program is distributed in the hope that it will be useful,
19      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21      *  GNU General Public License for more details.
22      *
23      *  You should have received a copy of the GNU General Public License
24      *  along with this program; if not, write to the Free Software
25      *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26      */
27     
28     #ifndef __AMLCODE_H__
29     #define __AMLCODE_H__
30     
31     
32     /* primary opcodes */
33     
34     #define AML_NULL_CHAR               (u16) 0x00
35     
36     #define AML_ZERO_OP                 (u16) 0x00
37     #define AML_ONE_OP                  (u16) 0x01
38     #define AML_UNASSIGNED              (u16) 0x02
39     #define AML_ALIAS_OP                (u16) 0x06
40     #define AML_NAME_OP                 (u16) 0x08
41     #define AML_BYTE_OP                 (u16) 0x0a
42     #define AML_WORD_OP                 (u16) 0x0b
43     #define AML_DWORD_OP                (u16) 0x0c
44     #define AML_STRING_OP               (u16) 0x0d
45     #define AML_QWORD_OP                (u16) 0x0e     /* ACPI 2.0 */
46     #define AML_SCOPE_OP                (u16) 0x10
47     #define AML_BUFFER_OP               (u16) 0x11
48     #define AML_PACKAGE_OP              (u16) 0x12
49     #define AML_VAR_PACKAGE_OP          (u16) 0x13     /* ACPI 2.0 */
50     #define AML_METHOD_OP               (u16) 0x14
51     #define AML_DUAL_NAME_PREFIX        (u16) 0x2e
52     #define AML_MULTI_NAME_PREFIX_OP    (u16) 0x2f
53     #define AML_NAME_CHAR_SUBSEQ        (u16) 0x30
54     #define AML_NAME_CHAR_FIRST         (u16) 0x41
55     #define AML_OP_PREFIX               (u16) 0x5b
56     #define AML_ROOT_PREFIX             (u16) 0x5c
57     #define AML_PARENT_PREFIX           (u16) 0x5e
58     #define AML_LOCAL_OP                (u16) 0x60
59     #define AML_LOCAL0                  (u16) 0x60
60     #define AML_LOCAL1                  (u16) 0x61
61     #define AML_LOCAL2                  (u16) 0x62
62     #define AML_LOCAL3                  (u16) 0x63
63     #define AML_LOCAL4                  (u16) 0x64
64     #define AML_LOCAL5                  (u16) 0x65
65     #define AML_LOCAL6                  (u16) 0x66
66     #define AML_LOCAL7                  (u16) 0x67
67     #define AML_ARG_OP                  (u16) 0x68
68     #define AML_ARG0                    (u16) 0x68
69     #define AML_ARG1                    (u16) 0x69
70     #define AML_ARG2                    (u16) 0x6a
71     #define AML_ARG3                    (u16) 0x6b
72     #define AML_ARG4                    (u16) 0x6c
73     #define AML_ARG5                    (u16) 0x6d
74     #define AML_ARG6                    (u16) 0x6e
75     #define AML_STORE_OP                (u16) 0x70
76     #define AML_REF_OF_OP               (u16) 0x71
77     #define AML_ADD_OP                  (u16) 0x72
78     #define AML_CONCAT_OP               (u16) 0x73
79     #define AML_SUBTRACT_OP             (u16) 0x74
80     #define AML_INCREMENT_OP            (u16) 0x75
81     #define AML_DECREMENT_OP            (u16) 0x76
82     #define AML_MULTIPLY_OP             (u16) 0x77
83     #define AML_DIVIDE_OP               (u16) 0x78
84     #define AML_SHIFT_LEFT_OP           (u16) 0x79
85     #define AML_SHIFT_RIGHT_OP          (u16) 0x7a
86     #define AML_BIT_AND_OP              (u16) 0x7b
87     #define AML_BIT_NAND_OP             (u16) 0x7c
88     #define AML_BIT_OR_OP               (u16) 0x7d
89     #define AML_BIT_NOR_OP              (u16) 0x7e
90     #define AML_BIT_XOR_OP              (u16) 0x7f
91     #define AML_BIT_NOT_OP              (u16) 0x80
92     #define AML_FIND_SET_LEFT_BIT_OP    (u16) 0x81
93     #define AML_FIND_SET_RIGHT_BIT_OP   (u16) 0x82
94     #define AML_DEREF_OF_OP             (u16) 0x83
95     #define AML_CONCAT_RES_OP           (u16) 0x84     /* ACPI 2.0 */
96     #define AML_MOD_OP                  (u16) 0x85     /* ACPI 2.0 */
97     #define AML_NOTIFY_OP               (u16) 0x86
98     #define AML_SIZE_OF_OP              (u16) 0x87
99     #define AML_INDEX_OP                (u16) 0x88
100     #define AML_MATCH_OP                (u16) 0x89
101     #define AML_CREATE_DWORD_FIELD_OP   (u16) 0x8a
102     #define AML_CREATE_WORD_FIELD_OP    (u16) 0x8b
103     #define AML_CREATE_BYTE_FIELD_OP    (u16) 0x8c
104     #define AML_CREATE_BIT_FIELD_OP     (u16) 0x8d
105     #define AML_TYPE_OP                 (u16) 0x8e
106     #define AML_CREATE_QWORD_FIELD_OP   (u16) 0x8f     /* ACPI 2.0 */
107     #define AML_LAND_OP                 (u16) 0x90
108     #define AML_LOR_OP                  (u16) 0x91
109     #define AML_LNOT_OP                 (u16) 0x92
110     #define AML_LEQUAL_OP               (u16) 0x93
111     #define AML_LGREATER_OP             (u16) 0x94
112     #define AML_LLESS_OP                (u16) 0x95
113     #define AML_TO_BUFFER_OP            (u16) 0x96     /* ACPI 2.0 */
114     #define AML_TO_DECSTRING_OP         (u16) 0x97     /* ACPI 2.0 */
115     #define AML_TO_HEXSTRING_OP         (u16) 0x98     /* ACPI 2.0 */
116     #define AML_TO_INTEGER_OP           (u16) 0x99     /* ACPI 2.0 */
117     #define AML_TO_STRING_OP            (u16) 0x9c     /* ACPI 2.0 */
118     #define AML_COPY_OP                 (u16) 0x9d     /* ACPI 2.0 */
119     #define AML_MID_OP                  (u16) 0x9e     /* ACPI 2.0 */
120     #define AML_CONTINUE_OP             (u16) 0x9f     /* ACPI 2.0 */
121     #define AML_IF_OP                   (u16) 0xa0
122     #define AML_ELSE_OP                 (u16) 0xa1
123     #define AML_WHILE_OP                (u16) 0xa2
124     #define AML_NOOP_OP                 (u16) 0xa3
125     #define AML_RETURN_OP               (u16) 0xa4
126     #define AML_BREAK_OP                (u16) 0xa5
127     #define AML_BREAK_POINT_OP          (u16) 0xcc
128     #define AML_ONES_OP                 (u16) 0xff
129     
130     /* prefixed opcodes */
131     
132     #define AML_EXTOP                   (u16) 0x005b
133     
134     
135     #define AML_MUTEX_OP                (u16) 0x5b01
136     #define AML_EVENT_OP                (u16) 0x5b02
137     #define AML_SHIFT_RIGHT_BIT_OP      (u16) 0x5b10
138     #define AML_SHIFT_LEFT_BIT_OP       (u16) 0x5b11
139     #define AML_COND_REF_OF_OP          (u16) 0x5b12
140     #define AML_CREATE_FIELD_OP         (u16) 0x5b13
141     #define AML_LOAD_TABLE_OP           (u16) 0x5b1f     /* ACPI 2.0 */
142     #define AML_LOAD_OP                 (u16) 0x5b20
143     #define AML_STALL_OP                (u16) 0x5b21
144     #define AML_SLEEP_OP                (u16) 0x5b22
145     #define AML_ACQUIRE_OP              (u16) 0x5b23
146     #define AML_SIGNAL_OP               (u16) 0x5b24
147     #define AML_WAIT_OP                 (u16) 0x5b25
148     #define AML_RESET_OP                (u16) 0x5b26
149     #define AML_RELEASE_OP              (u16) 0x5b27
150     #define AML_FROM_BCD_OP             (u16) 0x5b28
151     #define AML_TO_BCD_OP               (u16) 0x5b29
152     #define AML_UNLOAD_OP               (u16) 0x5b2a
153     #define AML_REVISION_OP             (u16) 0x5b30
154     #define AML_DEBUG_OP                (u16) 0x5b31
155     #define AML_FATAL_OP                (u16) 0x5b32
156     #define AML_REGION_OP               (u16) 0x5b80
157     #define AML_FIELD_OP                (u16) 0x5b81
158     #define AML_DEVICE_OP               (u16) 0x5b82
159     #define AML_PROCESSOR_OP            (u16) 0x5b83
160     #define AML_POWER_RES_OP            (u16) 0x5b84
161     #define AML_THERMAL_ZONE_OP         (u16) 0x5b85
162     #define AML_INDEX_FIELD_OP          (u16) 0x5b86
163     #define AML_BANK_FIELD_OP           (u16) 0x5b87
164     #define AML_DATA_REGION_OP          (u16) 0x5b88     /* ACPI 2.0 */
165     
166     
167     /* Bogus opcodes (they are actually two separate opcodes) */
168     
169     #define AML_LGREATEREQUAL_OP        (u16) 0x9295
170     #define AML_LLESSEQUAL_OP           (u16) 0x9294
171     #define AML_LNOTEQUAL_OP            (u16) 0x9293
172     
173     
174     /*
175      * Internal opcodes
176      * Use only "Unknown" AML opcodes, don't attempt to use
177      * any valid ACPI ASCII values (A-Z, 0-9, '-')
178      */
179     
180     #define AML_INT_NAMEPATH_OP         (u16) 0x002d
181     #define AML_INT_NAMEDFIELD_OP       (u16) 0x0030
182     #define AML_INT_RESERVEDFIELD_OP    (u16) 0x0031
183     #define AML_INT_ACCESSFIELD_OP      (u16) 0x0032
184     #define AML_INT_BYTELIST_OP         (u16) 0x0033
185     #define AML_INT_STATICSTRING_OP     (u16) 0x0034
186     #define AML_INT_METHODCALL_OP       (u16) 0x0035
187     #define AML_INT_RETURN_VALUE_OP     (u16) 0x0036
188     
189     
190     #define ARG_NONE                    0x0
191     
192     /*
193      * Argument types for the AML Parser
194      * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
195      * There can be up to 31 unique argument types
196      */
197     
198     #define ARGP_BYTEDATA               0x01
199     #define ARGP_BYTELIST               0x02
200     #define ARGP_CHARLIST               0x03
201     #define ARGP_DATAOBJ                0x04
202     #define ARGP_DATAOBJLIST            0x05
203     #define ARGP_DWORDDATA              0x06
204     #define ARGP_FIELDLIST              0x07
205     #define ARGP_NAME                   0x08
206     #define ARGP_NAMESTRING             0x09
207     #define ARGP_OBJLIST                0x0A
208     #define ARGP_PKGLENGTH              0x0B
209     #define ARGP_SUPERNAME              0x0C
210     #define ARGP_TARGET                 0x0D
211     #define ARGP_TERMARG                0x0E
212     #define ARGP_TERMLIST               0x0F
213     #define ARGP_WORDDATA               0x10
214     #define ARGP_QWORDDATA              0x11
215     #define ARGP_SIMPLENAME             0x12
216     
217     /*
218      * Resolved argument types for the AML Interpreter
219      * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
220      * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
221      */
222     
223     /* "Standard" ACPI types are 1-15 (0x0F) */
224     
225     #define ARGI_INTEGER                ACPI_TYPE_INTEGER       /* 1 */
226     #define ARGI_STRING                 ACPI_TYPE_STRING        /* 2 */
227     #define ARGI_BUFFER                 ACPI_TYPE_BUFFER        /* 3 */
228     #define ARGI_PACKAGE                ACPI_TYPE_PACKAGE       /* 4 */
229     #define ARGI_EVENT                  ACPI_TYPE_EVENT
230     #define ARGI_MUTEX                  ACPI_TYPE_MUTEX
231     #define ARGI_REGION                 ACPI_TYPE_REGION
232     #define ARGI_DDBHANDLE              ACPI_TYPE_DDB_HANDLE
233     
234     /* Custom types are 0x10 through 0x1F */
235     
236     #define ARGI_IF                     0x10
237     #define ARGI_ANYOBJECT              0x11
238     #define ARGI_ANYTYPE                0x12
239     #define ARGI_COMPUTEDATA            0x13     /* Buffer, String, or Integer */
240     #define ARGI_DATAOBJECT             0x14     /* Buffer, String, package or reference to a Node - Used only by Size_of operator*/
241     #define ARGI_COMPLEXOBJ             0x15     /* Buffer, String, or package (Used by INDEX op only) */
242     #define ARGI_INTEGER_REF            0x16
243     #define ARGI_OBJECT_REF             0x17
244     #define ARGI_DEVICE_REF             0x18
245     #define ARGI_REFERENCE              0x19
246     #define ARGI_TARGETREF              0x1A     /* Target, subject to implicit conversion */
247     #define ARGI_FIXED_TARGET           0x1B     /* Target, no implicit conversion */
248     #define ARGI_SIMPLE_TARGET          0x1C     /* Name, Local, Arg -- no implicit conversion */
249     #define ARGI_BUFFERSTRING           0x1D
250     
251     #define ARGI_INVALID_OPCODE         0xFFFFFFFF
252     
253     
254     /*
255      * hash offsets
256      */
257     #define AML_EXTOP_HASH_OFFSET       22
258     #define AML_LNOT_HASH_OFFSET        19
259     
260     
261     /*
262      * opcode groups and types
263      */
264     
265     #define OPGRP_NAMED                 0x01
266     #define OPGRP_FIELD                 0x02
267     #define OPGRP_BYTELIST              0x04
268     
269     #define OPTYPE_UNDEFINED            0
270     
271     
272     #define OPTYPE_LITERAL              1
273     #define OPTYPE_CONSTANT             2
274     #define OPTYPE_METHOD_ARGUMENT      3
275     #define OPTYPE_LOCAL_VARIABLE       4
276     #define OPTYPE_DATA_TERM            5
277     
278     /* Type 1 opcodes */
279     
280     #define OPTYPE_MONADIC1             6
281     #define OPTYPE_DYADIC1              7
282     
283     /* Type 2 opcodes */
284     
285     #define OPTYPE_MONADIC2             8
286     #define OPTYPE_MONADIC2_r            9
287     #define OPTYPE_DYADIC2              10
288     #define OPTYPE_DYADIC2_r             11
289     #define OPTYPE_DYADIC2_s             12
290     
291     /* Multi-operand (>=3) opcodes */
292     
293     #define OPTYPE_TRIADIC              13
294     #define OPTYPE_QUADRADIC            14
295     #define OPTYPE_HEXADIC              15
296     
297     /* Generic for an op that returns a value */
298     
299     #define OPTYPE_METHOD_CALL          16
300     
301     /* Misc */
302     
303     #define OPTYPE_CREATE_FIELD         17
304     #define OPTYPE_CONTROL              18
305     #define OPTYPE_RECONFIGURATION      19
306     #define OPTYPE_NAMED_OBJECT         20
307     #define OPTYPE_RETURN               21
308     
309     #define OPTYPE_BOGUS                22
310     
311     
312     /* Predefined Operation Region Space_iDs */
313     
314     typedef enum
315     {
316     	REGION_MEMORY                   = 0,
317     	REGION_IO,
318     	REGION_PCI_CONFIG,
319     	REGION_EC,
320     	REGION_SMBUS,
321     	REGION_CMOS,
322     	REGION_PCI_BAR,
323     	REGION_FIXED_HW                 = 0x7F,
324     
325     } AML_REGION_TYPES;
326     
327     
328     /* Comparison operation codes for Match_op operator */
329     
330     typedef enum
331     {
332     	MATCH_MTR                       = 0,
333     	MATCH_MEQ                       = 1,
334     	MATCH_MLE                       = 2,
335     	MATCH_MLT                       = 3,
336     	MATCH_MGE                       = 4,
337     	MATCH_MGT                       = 5
338     
339     } AML_MATCH_OPERATOR;
340     
341     #define MAX_MATCH_OPERATOR          5
342     
343     
344     /* Field Access Types */
345     
346     #define ACCESS_TYPE_MASK            0x0f
347     #define ACCESS_TYPE_SHIFT           0
348     
349     typedef enum
350     {
351     	ACCESS_ANY_ACC                  = 0,
352     	ACCESS_BYTE_ACC                 = 1,
353     	ACCESS_WORD_ACC                 = 2,
354     	ACCESS_DWORD_ACC                = 3,
355     	ACCESS_QWORD_ACC                = 4,    /* ACPI 2.0 */
356     	ACCESS_BLOCK_ACC                = 4,
357     	ACCESS_SMBSEND_RECV_ACC         = 5,
358     	ACCESS_SMBQUICK_ACC             = 6
359     
360     } AML_ACCESS_TYPE;
361     
362     
363     /* Field Lock Rules */
364     
365     #define LOCK_RULE_MASK              0x10
366     #define LOCK_RULE_SHIFT             4
367     
368     typedef enum
369     {
370     	GLOCK_NEVER_LOCK                = 0,
371     	GLOCK_ALWAYS_LOCK               = 1
372     
373     } AML_LOCK_RULE;
374     
375     
376     /* Field Update Rules */
377     
378     #define UPDATE_RULE_MASK            0x060
379     #define UPDATE_RULE_SHIFT           5
380     
381     typedef enum
382     {
383     	UPDATE_PRESERVE                 = 0,
384     	UPDATE_WRITE_AS_ONES            = 1,
385     	UPDATE_WRITE_AS_ZEROS           = 2
386     
387     } AML_UPDATE_RULE;
388     
389     
390     /* bit fields in Method_flags byte */
391     
392     #define METHOD_FLAGS_ARG_COUNT      0x07
393     #define METHOD_FLAGS_SERIALIZED     0x08
394     #define METHOD_FLAGS_SYNCH_LEVEL    0xF0
395     
396     
397     /* Array sizes.  Used for range checking also */
398     
399     #define NUM_REGION_TYPES            7
400     #define NUM_ACCESS_TYPES            7
401     #define NUM_UPDATE_RULES            3
402     #define NUM_MATCH_OPS               7
403     #define NUM_OPCODES                 256
404     #define NUM_FIELD_NAMES             2
405     
406     
407     #define USER_REGION_BEGIN           0x80
408     
409     /*
410      * AML tables
411      */
412     
413     #ifdef DEFINE_AML_GLOBALS
414     
415     /* External declarations for the AML tables */
416     
417     extern u8                       acpi_gbl_aml            [NUM_OPCODES];
418     extern u16                      acpi_gbl_pfx            [NUM_OPCODES];
419     
420     
421     #endif /* DEFINE_AML_GLOBALS */
422     
423     #endif /* __AMLCODE_H__ */
424