import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / acpi / include / aclocal.h
1 /******************************************************************************
2  *
3  * Name: aclocal.h - Internal data types used across the ACPI subsystem
4  *       $Revision: 1.1.1.1 $
5  *
6  *****************************************************************************/
7
8 /*
9  *  Copyright (C) 2000, 2001 R. Byron Moore
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef __ACLOCAL_H__
27 #define __ACLOCAL_H__
28
29
30 #define WAIT_FOREVER                    ((u32) -1)
31
32 typedef void*                           acpi_mutex;
33 typedef u32                             ACPI_MUTEX_HANDLE;
34
35
36 #define ACPI_MEMORY_MODE                0x01
37 #define ACPI_LOGICAL_ADDRESSING         0x00
38 #define ACPI_PHYSICAL_ADDRESSING        0x01
39
40 /* Object descriptor types */
41
42 #define ACPI_CACHED_OBJECT              0x11    /* ORed in when object is cached */
43 #define ACPI_DESC_TYPE_STATE            0x20
44 #define ACPI_DESC_TYPE_STATE_UPDATE     0x21
45 #define ACPI_DESC_TYPE_STATE_PACKAGE    0x22
46 #define ACPI_DESC_TYPE_STATE_CONTROL    0x23
47 #define ACPI_DESC_TYPE_STATE_RPSCOPE    0x24
48 #define ACPI_DESC_TYPE_STATE_PSCOPE     0x25
49 #define ACPI_DESC_TYPE_STATE_WSCOPE     0x26
50 #define ACPI_DESC_TYPE_STATE_RESULT     0x27
51 #define ACPI_DESC_TYPE_STATE_NOTIFY     0x28
52 #define ACPI_DESC_TYPE_WALK             0x44
53 #define ACPI_DESC_TYPE_PARSER           0x66
54 #define ACPI_DESC_TYPE_INTERNAL         0x88
55 #define ACPI_DESC_TYPE_NAMED            0xAA
56
57
58 /*****************************************************************************
59  *
60  * Mutex typedefs and structs
61  *
62  ****************************************************************************/
63
64
65 /*
66  * Predefined handles for the mutex objects used within the subsystem
67  * All mutex objects are automatically created by Acpi_ut_mutex_initialize.
68  *
69  * The acquire/release ordering protocol is implied via this list.  Mutexes
70  * with a lower value must be acquired before mutexes with a higher value.
71  *
72  * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also!
73  */
74
75 #define ACPI_MTX_EXECUTE                0
76 #define ACPI_MTX_INTERPRETER            1
77 #define ACPI_MTX_PARSER                 2
78 #define ACPI_MTX_DISPATCHER             3
79 #define ACPI_MTX_TABLES                 4
80 #define ACPI_MTX_OP_REGIONS             5
81 #define ACPI_MTX_NAMESPACE              6
82 #define ACPI_MTX_EVENTS                 7
83 #define ACPI_MTX_HARDWARE               8
84 #define ACPI_MTX_CACHES                 9
85 #define ACPI_MTX_MEMORY                 10
86 #define ACPI_MTX_DEBUG_CMD_COMPLETE     11
87 #define ACPI_MTX_DEBUG_CMD_READY        12
88
89 #define MAX_MTX                         12
90 #define NUM_MTX                         MAX_MTX+1
91
92
93 #if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
94 #ifdef DEFINE_ACPI_GLOBALS
95
96 /* Names for the mutexes used in the subsystem */
97
98 static NATIVE_CHAR          *acpi_gbl_mutex_names[] =
99 {
100         "ACPI_MTX_Execute",
101         "ACPI_MTX_Interpreter",
102         "ACPI_MTX_Parser",
103         "ACPI_MTX_Dispatcher",
104         "ACPI_MTX_Tables",
105         "ACPI_MTX_Op_regions",
106         "ACPI_MTX_Namespace",
107         "ACPI_MTX_Events",
108         "ACPI_MTX_Hardware",
109         "ACPI_MTX_Caches",
110         "ACPI_MTX_Memory",
111         "ACPI_MTX_Debug_cmd_complete",
112         "ACPI_MTX_Debug_cmd_ready",
113 };
114
115 #endif
116 #endif
117
118
119 /* Table for the global mutexes */
120
121 typedef struct acpi_mutex_info
122 {
123         acpi_mutex                  mutex;
124         u32                         use_count;
125         u32                         owner_id;
126
127 } acpi_mutex_info;
128
129 /* This owner ID means that the mutex is not in use (unlocked) */
130
131 #define ACPI_MUTEX_NOT_ACQUIRED         (u32) (-1)
132
133
134 /* Lock flag parameter for various interfaces */
135
136 #define ACPI_MTX_DO_NOT_LOCK            0
137 #define ACPI_MTX_LOCK                   1
138
139
140 typedef u16                             acpi_owner_id;
141 #define OWNER_TYPE_TABLE                0x0
142 #define OWNER_TYPE_METHOD               0x1
143 #define FIRST_METHOD_ID                 0x0000
144 #define FIRST_TABLE_ID                  0x8000
145
146 /* TBD: [Restructure] get rid of the need for this! */
147
148 #define TABLE_ID_DSDT                   (acpi_owner_id) 0x8000
149
150
151 /* Field access granularities */
152
153 #define ACPI_FIELD_BYTE_GRANULARITY     1
154 #define ACPI_FIELD_WORD_GRANULARITY     2
155 #define ACPI_FIELD_DWORD_GRANULARITY    4
156 #define ACPI_FIELD_QWORD_GRANULARITY    8
157
158 /*****************************************************************************
159  *
160  * Namespace typedefs and structs
161  *
162  ****************************************************************************/
163
164
165 /* Operational modes of the AML interpreter/scanner */
166
167 typedef enum
168 {
169         IMODE_LOAD_PASS1                = 0x01,
170         IMODE_LOAD_PASS2                = 0x02,
171         IMODE_EXECUTE                   = 0x0E
172
173 } operating_mode;
174
175
176 /*
177  * The Node describes a named object that appears in the AML
178  * An Acpi_node is used to store Nodes.
179  *
180  * Data_type is used to differentiate between internal descriptors, and MUST
181  * be the first byte in this structure.
182  */
183
184 typedef struct acpi_node
185 {
186         u8                      data_type;
187         u8                      type;           /* Type associated with this name */
188         u16                     owner_id;
189         u32                     name;           /* ACPI Name, always 4 chars per ACPI spec */
190
191
192         union acpi_operand_obj  *object;        /* Pointer to attached ACPI object (optional) */
193         struct acpi_node        *child;         /* first child */
194         struct acpi_node        *peer;          /* Next peer*/
195         u16                     reference_count; /* Current count of references and children */
196         u8                      flags;
197
198 } acpi_namespace_node;
199
200
201 #define ENTRY_NOT_FOUND             NULL
202
203
204 /* Node flags */
205
206 #define ANOBJ_AML_ATTACHMENT            0x01
207 #define ANOBJ_END_OF_PEER_LIST          0x02
208 #define ANOBJ_DATA_WIDTH_32             0x04     /* Parent table is 64-bits */
209 #define ANOBJ_METHOD_ARG                0x08
210 #define ANOBJ_METHOD_LOCAL              0x10
211 #define ANOBJ_METHOD_NO_RETVAL          0x20
212 #define ANOBJ_METHOD_SOME_NO_RETVAL     0x40
213
214 #define ANOBJ_IS_BIT_OFFSET             0x80
215
216
217 /*
218  * ACPI Table Descriptor.  One per ACPI table
219  */
220 typedef struct acpi_table_desc
221 {
222         struct acpi_table_desc  *prev;
223         struct acpi_table_desc  *next;
224         struct acpi_table_desc  *installed_desc;
225         acpi_table_header       *pointer;
226         void                    *base_pointer;
227         u8                      *aml_start;
228         u64                     physical_address;
229         u32                     aml_length;
230         u32                     length;
231         u32                     count;
232         acpi_owner_id           table_id;
233         u8                      type;
234         u8                      allocation;
235         u8                      loaded_into_namespace;
236
237 } acpi_table_desc;
238
239
240 typedef struct
241 {
242         NATIVE_CHAR             *search_for;
243         acpi_handle             *list;
244         u32                     *count;
245
246 } find_context;
247
248
249 typedef struct
250 {
251         acpi_namespace_node     *node;
252 } ns_search_data;
253
254
255 /*
256  * Predefined Namespace items
257  */
258 typedef struct
259 {
260         NATIVE_CHAR             *name;
261         acpi_object_type8       type;
262         NATIVE_CHAR             *val;
263
264 } predefined_names;
265
266
267 /* Object types used during package copies */
268
269
270 #define ACPI_COPY_TYPE_SIMPLE           0
271 #define ACPI_COPY_TYPE_PACKAGE          1
272
273 /* Info structure used to convert external<->internal namestrings */
274
275 typedef struct acpi_namestring_info
276 {
277         NATIVE_CHAR             *external_name;
278         NATIVE_CHAR             *next_external_char;
279         NATIVE_CHAR             *internal_name;
280         u32                     length;
281         u32                     num_segments;
282         u32                     num_carats;
283         u8                      fully_qualified;
284
285 } acpi_namestring_info;
286
287
288 /* Field creation info */
289
290 typedef struct
291 {
292         acpi_namespace_node     *region_node;
293         acpi_namespace_node     *field_node;
294         acpi_namespace_node     *register_node;
295         acpi_namespace_node     *data_register_node;
296         u32                     bank_value;
297         u32                     field_bit_position;
298         u32                     field_bit_length;
299         u8                      field_flags;
300         u8                      field_type;
301
302 } ACPI_CREATE_FIELD_INFO;
303
304 /*
305  * Field flags: Bits 00 - 03 : Access_type (Any_acc, Byte_acc, etc.)
306  *                   04      : Lock_rule (1 == Lock)
307  *                   05 - 06 : Update_rule
308  */
309
310 #define FIELD_ACCESS_TYPE_MASK      0x0F
311 #define FIELD_LOCK_RULE_MASK        0x10
312 #define FIELD_UPDATE_RULE_MASK      0x60
313
314
315 /*****************************************************************************
316  *
317  * Event typedefs and structs
318  *
319  ****************************************************************************/
320
321
322 /* Status bits. */
323
324 #define ACPI_STATUS_PMTIMER             0x0001
325 #define ACPI_STATUS_BUSMASTER           0x0010
326 #define ACPI_STATUS_GLOBAL              0x0020
327 #define ACPI_STATUS_POWER_BUTTON        0x0100
328 #define ACPI_STATUS_SLEEP_BUTTON        0x0200
329 #define ACPI_STATUS_RTC_ALARM           0x0400
330
331 /* Enable bits. */
332
333 #define ACPI_ENABLE_PMTIMER             0x0001
334 #define ACPI_ENABLE_GLOBAL              0x0020
335 #define ACPI_ENABLE_POWER_BUTTON        0x0100
336 #define ACPI_ENABLE_SLEEP_BUTTON        0x0200
337 #define ACPI_ENABLE_RTC_ALARM           0x0400
338
339
340 /*
341  * Entry in the Address_space (AKA Operation Region) table
342  */
343
344 typedef struct
345 {
346         acpi_adr_space_handler  handler;
347         void                    *context;
348
349 } acpi_adr_space_info;
350
351
352 /* Values and addresses of the GPE registers (both banks) */
353
354 typedef struct
355 {
356         u16                     status_addr;    /* Address of status reg */
357         u16                     enable_addr;    /* Address of enable reg */
358         u8                      status;         /* Current value of status reg */
359         u8                      enable;         /* Current value of enable reg */
360         u8                      wake_enable;    /* Mask of bits to keep enabled when sleeping */
361         u8                      gpe_base;       /* Base GPE number */
362
363 } acpi_gpe_registers;
364
365
366 #define ACPI_GPE_LEVEL_TRIGGERED        1
367 #define ACPI_GPE_EDGE_TRIGGERED         2
368
369
370 /* Information about each particular GPE level */
371
372 typedef struct
373 {
374         u8                      type;           /* Level or Edge */
375
376         acpi_handle             method_handle;  /* Method handle for direct (fast) execution */
377         acpi_gpe_handler        handler;        /* Address of handler, if any */
378         void                    *context;       /* Context to be passed to handler */
379
380 } acpi_gpe_level_info;
381
382
383 /* Information about each particular fixed event */
384
385 typedef struct
386 {
387         acpi_event_handler      handler;        /* Address of handler. */
388         void                    *context;       /* Context to be passed to handler */
389
390 } acpi_fixed_event_info;
391
392
393 /* Information used during field processing */
394
395 typedef struct
396 {
397         u8                      skip_field;
398         u8                      field_flag;
399         u32                     pkg_length;
400
401 } acpi_field_info;
402
403
404 /*****************************************************************************
405  *
406  * Generic "state" object for stacks
407  *
408  ****************************************************************************/
409
410
411 #define CONTROL_NORMAL                  0xC0
412 #define CONTROL_CONDITIONAL_EXECUTING   0xC1
413 #define CONTROL_PREDICATE_EXECUTING     0xC2
414 #define CONTROL_PREDICATE_FALSE         0xC3
415 #define CONTROL_PREDICATE_TRUE          0xC4
416
417
418 /* Forward declarations */
419 struct acpi_walk_state;
420 struct acpi_walk_list;
421 struct acpi_parse_obj;
422 struct acpi_obj_mutex;
423
424
425 #define ACPI_STATE_COMMON                  /* Two 32-bit fields and a pointer */\
426         u8                      data_type;          /* To differentiate various internal objs */\
427         u8                      flags; \
428         u16                     value; \
429         u16                     state; \
430         u16                     acpi_eval; \
431         void                    *next; \
432
433 typedef struct acpi_common_state
434 {
435         ACPI_STATE_COMMON
436 } acpi_common_state;
437
438
439 /*
440  * Update state - used to traverse complex objects such as packages
441  */
442 typedef struct acpi_update_state
443 {
444         ACPI_STATE_COMMON
445         union acpi_operand_obj  *object;
446
447 } acpi_update_state;
448
449
450 /*
451  * Pkg state - used to traverse nested package structures
452  */
453 typedef struct acpi_pkg_state
454 {
455         ACPI_STATE_COMMON
456         union acpi_operand_obj  *source_object;
457         union acpi_operand_obj  *dest_object;
458         struct acpi_walk_state  *walk_state;
459         void                    *this_target_obj;
460         u32                     num_packages;
461         u16                     index;
462
463 } acpi_pkg_state;
464
465
466 /*
467  * Control state - one per if/else and while constructs.
468  * Allows nesting of these constructs
469  */
470 typedef struct acpi_control_state
471 {
472         ACPI_STATE_COMMON
473         struct acpi_parse_obj   *predicate_op;
474         u8                      *aml_predicate_start; /* Start of if/while predicate */
475
476 } acpi_control_state;
477
478
479 /*
480  * Scope state - current scope during namespace lookups
481  */
482 typedef struct acpi_scope_state
483 {
484         ACPI_STATE_COMMON
485         acpi_namespace_node     *node;
486
487 } acpi_scope_state;
488
489
490 typedef struct acpi_pscope_state
491 {
492         ACPI_STATE_COMMON
493         struct acpi_parse_obj   *op;            /* current op being parsed */
494         u8                      *arg_end;       /* current argument end */
495         u8                      *pkg_end;       /* current package end */
496         u32                     arg_list;       /* next argument to parse */
497         u32                     arg_count;      /* Number of fixed arguments */
498
499 } acpi_pscope_state;
500
501
502 /*
503  * Result values - used to accumulate the results of nested
504  * AML arguments
505  */
506 typedef struct acpi_result_values
507 {
508         ACPI_STATE_COMMON
509         union acpi_operand_obj  *obj_desc [OBJ_NUM_OPERANDS];
510         u8                      num_results;
511         u8                      last_insert;
512
513 } acpi_result_values;
514
515
516 typedef
517 acpi_status (*acpi_parse_downwards) (
518         struct acpi_walk_state  *walk_state,
519         struct acpi_parse_obj   **out_op);
520
521 typedef
522 acpi_status (*acpi_parse_upwards) (
523         struct acpi_walk_state  *walk_state);
524
525
526 /*
527  * Notify info - used to pass info to the deferred notify
528  * handler/dispatcher.
529  */
530 typedef struct acpi_notify_info
531 {
532         ACPI_STATE_COMMON
533         acpi_namespace_node     *node;
534         union acpi_operand_obj  *handler_obj;
535
536 } acpi_notify_info;
537
538
539 /* Generic state is union of structs above */
540
541 typedef union acpi_gen_state
542 {
543         acpi_common_state       common;
544         acpi_control_state      control;
545         acpi_update_state       update;
546         acpi_scope_state        scope;
547         acpi_pscope_state       parse_scope;
548         acpi_pkg_state          pkg;
549         acpi_result_values      results;
550         acpi_notify_info        notify;
551
552 } acpi_generic_state;
553
554
555 /*****************************************************************************
556  *
557  * Interpreter typedefs and structs
558  *
559  ****************************************************************************/
560
561 typedef
562 acpi_status (*ACPI_EXECUTE_OP) (
563         struct acpi_walk_state  *walk_state);
564
565
566 /*****************************************************************************
567  *
568  * Parser typedefs and structs
569  *
570  ****************************************************************************/
571
572 /*
573  * AML opcode, name, and argument layout
574  */
575 typedef struct acpi_opcode_info
576 {
577         u32                     parse_args;     /* Grammar/Parse time arguments */
578         u32                     runtime_args;   /* Interpret time arguments */
579         u16                     flags;          /* Misc flags */
580         u8                      class;          /* Opcode class */
581         u8                      type;           /* Opcode type */
582
583 #ifdef _OPCODE_NAMES
584         NATIVE_CHAR             *name;          /* op name (debug only) */
585 #endif
586
587 } acpi_opcode_info;
588
589
590 typedef union acpi_parse_val
591 {
592         acpi_integer            integer;        /* integer constant (Up to 64 bits) */
593         uint64_struct           integer64;      /* Structure overlay for 2 32-bit Dwords */
594         u32                     integer32;      /* integer constant, 32 bits only */
595         u16                     integer16;      /* integer constant, 16 bits only */
596         u8                      integer8;       /* integer constant, 8 bits only */
597         u32                     size;           /* bytelist or field size */
598         NATIVE_CHAR             *string;        /* NULL terminated string */
599         u8                      *buffer;        /* buffer or string */
600         NATIVE_CHAR             *name;          /* NULL terminated string */
601         struct acpi_parse_obj   *arg;           /* arguments and contained ops */
602
603 } acpi_parse_value;
604
605
606 #define ACPI_PARSE_COMMON \
607         u8                      data_type;      /* To differentiate various internal objs */\
608         u8                      flags;          /* Type of Op */\
609         u16                     opcode;         /* AML opcode */\
610         u32                     aml_offset;     /* offset of declaration in AML */\
611         struct acpi_parse_obj   *parent;        /* parent op */\
612         struct acpi_parse_obj   *next;          /* next op */\
613         DEBUG_ONLY_MEMBERS (\
614         NATIVE_CHAR             op_name[16])    /* op name (debug only) */\
615                           /* NON-DEBUG members below: */\
616         acpi_namespace_node     *node;          /* for use by interpreter */\
617         acpi_parse_value        value;          /* Value or args associated with the opcode */\
618
619
620 /*
621  * generic operation (eg. If, While, Store)
622  */
623 typedef struct acpi_parse_obj
624 {
625         ACPI_PARSE_COMMON
626 } acpi_parse_object;
627
628
629 /*
630  * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and Op_regions),
631  * and bytelists.
632  */
633 typedef struct acpi_parse2_obj
634 {
635         ACPI_PARSE_COMMON
636         u8                      *data;          /* AML body or bytelist data */
637         u32                     length;         /* AML length */
638         u32                     name;           /* 4-byte name or zero if no name */
639
640 } acpi_parse2_object;
641
642
643 /*
644  * Parse state - one state per parser invocation and each control
645  * method.
646  */
647 typedef struct acpi_parse_state
648 {
649         u32                     aml_size;
650         u8                      *aml_start;     /* first AML byte */
651         u8                      *aml;           /* next AML byte */
652         u8                      *aml_end;       /* (last + 1) AML byte */
653         u8                      *pkg_start;     /* current package begin */
654         u8                      *pkg_end;       /* current package end */
655
656         struct acpi_parse_obj   *start_op;      /* root of parse tree */
657         struct acpi_node        *start_node;
658         union acpi_gen_state    *scope;         /* current scope */
659
660
661         struct acpi_parse_obj   *start_scope;
662
663
664 } acpi_parse_state;
665
666
667 /*****************************************************************************
668  *
669  * Hardware and PNP
670  *
671  ****************************************************************************/
672
673
674 /* PCI */
675 #define PCI_ROOT_HID_STRING             "PNP0A03"
676
677 /*
678  * The #define's and enum below establish an abstract way of identifying what
679  * register block and register is to be accessed.  Do not change any of the
680  * values as they are used in switch statements and offset calculations.
681  */
682
683 #define REGISTER_BLOCK_MASK             0xFF00  /* Register Block Id    */
684 #define BIT_IN_REGISTER_MASK            0x00FF  /* Bit Id in the Register Block Id    */
685 #define BYTE_IN_REGISTER_MASK           0x00FF  /* Register Offset in the Register Block    */
686
687 #define REGISTER_BLOCK_ID(reg_id)       (reg_id & REGISTER_BLOCK_MASK)
688 #define REGISTER_BIT_ID(reg_id)         (reg_id & BIT_IN_REGISTER_MASK)
689 #define REGISTER_OFFSET(reg_id)         (reg_id & BYTE_IN_REGISTER_MASK)
690
691 /*
692  * Access Rule
693  *  To access a Register Bit:
694  *  -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum.
695  *
696  *  To access a Register:
697  *  -> Use Register Id (= Register Block Id | Register Offset)
698  */
699
700
701 /*
702  * Register Block Id
703  */
704 #define PM1_STS                         0x0100
705 #define PM1_EN                          0x0200
706 #define PM1_CONTROL                     0x0300
707 #define PM1A_CONTROL                    0x0400
708 #define PM1B_CONTROL                    0x0500
709 #define PM2_CONTROL                     0x0600
710 #define PM_TIMER                        0x0700
711 #define PROCESSOR_BLOCK                 0x0800
712 #define GPE0_STS_BLOCK                  0x0900
713 #define GPE0_EN_BLOCK                   0x0A00
714 #define GPE1_STS_BLOCK                  0x0B00
715 #define GPE1_EN_BLOCK                   0x0C00
716 #define SMI_CMD_BLOCK                   0x0D00
717
718 /*
719  * Address space bitmasks for mmio or io spaces
720  */
721
722 #define SMI_CMD_ADDRESS_SPACE           0x01
723 #define PM1_BLK_ADDRESS_SPACE           0x02
724 #define PM2_CNT_BLK_ADDRESS_SPACE       0x04
725 #define PM_TMR_BLK_ADDRESS_SPACE        0x08
726 #define GPE0_BLK_ADDRESS_SPACE          0x10
727 #define GPE1_BLK_ADDRESS_SPACE          0x20
728
729 /*
730  * Control bit definitions
731  */
732 #define TMR_STS                         (PM1_STS | 0x01)
733 #define BM_STS                          (PM1_STS | 0x02)
734 #define GBL_STS                         (PM1_STS | 0x03)
735 #define PWRBTN_STS                      (PM1_STS | 0x04)
736 #define SLPBTN_STS                      (PM1_STS | 0x05)
737 #define RTC_STS                         (PM1_STS | 0x06)
738 #define WAK_STS                         (PM1_STS | 0x07)
739
740 #define TMR_EN                          (PM1_EN | 0x01)
741                          /* no BM_EN */
742 #define GBL_EN                          (PM1_EN | 0x03)
743 #define PWRBTN_EN                       (PM1_EN | 0x04)
744 #define SLPBTN_EN                       (PM1_EN | 0x05)
745 #define RTC_EN                          (PM1_EN | 0x06)
746 #define WAK_EN                          (PM1_EN | 0x07)
747
748 #define SCI_EN                          (PM1_CONTROL | 0x01)
749 #define BM_RLD                          (PM1_CONTROL | 0x02)
750 #define GBL_RLS                         (PM1_CONTROL | 0x03)
751 #define SLP_TYPE_A                      (PM1_CONTROL | 0x04)
752 #define SLP_TYPE_B                      (PM1_CONTROL | 0x05)
753 #define SLP_EN                          (PM1_CONTROL | 0x06)
754
755 #define ARB_DIS                         (PM2_CONTROL | 0x01)
756
757 #define TMR_VAL                         (PM_TIMER | 0x01)
758
759 #define GPE0_STS                        (GPE0_STS_BLOCK | 0x01)
760 #define GPE0_EN                         (GPE0_EN_BLOCK  | 0x01)
761
762 #define GPE1_STS                        (GPE1_STS_BLOCK | 0x01)
763 #define GPE1_EN                         (GPE1_EN_BLOCK  | 0x01)
764
765
766 #define TMR_STS_MASK                    0x0001
767 #define BM_STS_MASK                     0x0010
768 #define GBL_STS_MASK                    0x0020
769 #define PWRBTN_STS_MASK                 0x0100
770 #define SLPBTN_STS_MASK                 0x0200
771 #define RTC_STS_MASK                    0x0400
772 #define WAK_STS_MASK                    0x8000
773
774 #define ALL_FIXED_STS_BITS              (TMR_STS_MASK   | BM_STS_MASK  | GBL_STS_MASK \
775                                           | PWRBTN_STS_MASK | SLPBTN_STS_MASK \
776                                           | RTC_STS_MASK | WAK_STS_MASK)
777
778 #define TMR_EN_MASK                     0x0001
779 #define GBL_EN_MASK                     0x0020
780 #define PWRBTN_EN_MASK                  0x0100
781 #define SLPBTN_EN_MASK                  0x0200
782 #define RTC_EN_MASK                     0x0400
783
784 #define SCI_EN_MASK                     0x0001
785 #define BM_RLD_MASK                     0x0002
786 #define GBL_RLS_MASK                    0x0004
787 #define SLP_TYPE_X_MASK                 0x1C00
788 #define SLP_EN_MASK                     0x2000
789
790 #define ARB_DIS_MASK                    0x0001
791 #define TMR_VAL_MASK                    0xFFFFFFFF
792
793 #define GPE0_STS_MASK
794 #define GPE0_EN_MASK
795
796 #define GPE1_STS_MASK
797 #define GPE1_EN_MASK
798
799
800 #define ACPI_READ                       1
801 #define ACPI_WRITE                      2
802
803
804 /*****************************************************************************
805  *
806  * Resource descriptors
807  *
808  ****************************************************************************/
809
810
811 /* Resource_type values */
812
813 #define RESOURCE_TYPE_MEMORY_RANGE              0
814 #define RESOURCE_TYPE_IO_RANGE                  1
815 #define RESOURCE_TYPE_BUS_NUMBER_RANGE          2
816
817 /* Resource descriptor types and masks */
818
819 #define RESOURCE_DESC_TYPE_LARGE                0x80
820 #define RESOURCE_DESC_TYPE_SMALL                0x00
821
822 #define RESOURCE_DESC_TYPE_MASK                 0x80
823 #define RESOURCE_DESC_SMALL_MASK                0x78        /* Only bits 6:3 contain the type */
824
825
826 /*
827  * Small resource descriptor types
828  * Note: The 3 length bits (2:0) must be zero
829  */
830 #define RESOURCE_DESC_IRQ_FORMAT                0x20
831 #define RESOURCE_DESC_DMA_FORMAT                0x28
832 #define RESOURCE_DESC_START_DEPENDENT           0x30
833 #define RESOURCE_DESC_END_DEPENDENT             0x38
834 #define RESOURCE_DESC_IO_PORT                   0x40
835 #define RESOURCE_DESC_FIXED_IO_PORT             0x48
836 #define RESOURCE_DESC_SMALL_VENDOR              0x70
837 #define RESOURCE_DESC_END_TAG                   0x78
838
839 /*
840  * Large resource descriptor types
841  */
842
843 #define RESOURCE_DESC_MEMORY_24                 0x81
844 #define RESOURCE_DESC_GENERAL_REGISTER          0x82
845 #define RESOURCE_DESC_LARGE_VENDOR              0x84
846 #define RESOURCE_DESC_MEMORY_32                 0x85
847 #define RESOURCE_DESC_FIXED_MEMORY_32           0x86
848 #define RESOURCE_DESC_DWORD_ADDRESS_SPACE       0x87
849 #define RESOURCE_DESC_WORD_ADDRESS_SPACE        0x88
850 #define RESOURCE_DESC_EXTENDED_XRUPT            0x89
851 #define RESOURCE_DESC_QWORD_ADDRESS_SPACE       0x8A
852
853
854 /* String version of device HIDs and UIDs */
855
856 #define ACPI_DEVICE_ID_LENGTH                   0x09
857
858 typedef struct
859 {
860         char            buffer[ACPI_DEVICE_ID_LENGTH];
861
862 } acpi_device_id;
863
864
865 /*****************************************************************************
866  *
867  * Miscellaneous
868  *
869  ****************************************************************************/
870
871 #define ASCII_ZERO                      0x30
872
873 /*****************************************************************************
874  *
875  * Debugger
876  *
877  ****************************************************************************/
878
879 typedef struct dbmethodinfo
880 {
881         acpi_handle             thread_gate;
882         NATIVE_CHAR             *name;
883         NATIVE_CHAR             **args;
884         u32                     flags;
885         u32                     num_loops;
886         NATIVE_CHAR             pathname[128];
887
888 } db_method_info;
889
890
891 /*****************************************************************************
892  *
893  * Debug
894  *
895  ****************************************************************************/
896
897 typedef struct
898 {
899         u32                     component_id;
900         NATIVE_CHAR             *proc_name;
901         NATIVE_CHAR             *module_name;
902
903 } acpi_debug_print_info;
904
905
906 /* Entry for a memory allocation (debug only) */
907
908
909 #define MEM_MALLOC                      0
910 #define MEM_CALLOC                      1
911 #define MAX_MODULE_NAME                 16
912
913 #define ACPI_COMMON_DEBUG_MEM_HEADER \
914         struct acpi_debug_mem_block *previous; \
915         struct acpi_debug_mem_block *next; \
916         u32                         size; \
917         u32                         component; \
918         u32                         line; \
919         NATIVE_CHAR                 module[MAX_MODULE_NAME]; \
920         u8                          alloc_type;
921
922
923 typedef struct
924 {
925         ACPI_COMMON_DEBUG_MEM_HEADER
926
927 } acpi_debug_mem_header;
928
929 typedef struct acpi_debug_mem_block
930 {
931         ACPI_COMMON_DEBUG_MEM_HEADER
932         u64                         user_space;
933
934 } acpi_debug_mem_block;
935
936
937 #define ACPI_MEM_LIST_GLOBAL            0
938 #define ACPI_MEM_LIST_NSNODE            1
939
940 #define ACPI_MEM_LIST_FIRST_CACHE_LIST  2
941 #define ACPI_MEM_LIST_STATE             2
942 #define ACPI_MEM_LIST_PSNODE            3
943 #define ACPI_MEM_LIST_PSNODE_EXT        4
944 #define ACPI_MEM_LIST_OPERAND           5
945 #define ACPI_MEM_LIST_WALK              6
946 #define ACPI_MEM_LIST_MAX               6
947 #define ACPI_NUM_MEM_LISTS              7
948
949
950 typedef struct
951 {
952         void                        *list_head;
953         u16                         link_offset;
954         u16                         max_cache_depth;
955         u16                         cache_depth;
956         u16                         object_size;
957
958 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
959
960         /* Statistics for debug memory tracking only */
961
962         u32                         total_allocated;
963         u32                         total_freed;
964         u32                         current_total_size;
965         u32                         cache_requests;
966         u32                         cache_hits;
967         char                        *list_name;
968 #endif
969
970 } ACPI_MEMORY_LIST;
971
972
973 #endif /* __ACLOCAL_H__ */