1 /******************************************************************************
3 * Name: aclocal.h - Internal data types used across the ACPI subsystem
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
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.
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.
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
30 #define WAIT_FOREVER ((u32) -1)
32 typedef void* ACPI_MUTEX
;
33 typedef u32 ACPI_MUTEX_HANDLE
;
36 /* Object descriptor types */
38 #define ACPI_CACHED_OBJECT 0x11 /* ORed in when object is cached */
39 #define ACPI_DESC_TYPE_STATE 0x22
40 #define ACPI_DESC_TYPE_WALK 0x44
41 #define ACPI_DESC_TYPE_PARSER 0x66
42 #define ACPI_DESC_TYPE_INTERNAL 0x88
43 #define ACPI_DESC_TYPE_NAMED 0xAA
46 /*****************************************************************************
48 * Mutex typedefs and structs
50 ****************************************************************************/
54 * Predefined handles for the mutex objects used within the subsystem
55 * All mutex objects are automatically created by Acpi_cm_mutex_initialize.
57 * The acquire/release ordering protocol is implied via this list. Mutexes
58 * with a lower value must be acquired before mutexes with a higher value.
60 * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also!
63 #define ACPI_MTX_EXECUTE 0
64 #define ACPI_MTX_INTERPRETER 1
65 #define ACPI_MTX_PARSER 2
66 #define ACPI_MTX_DISPATCHER 3
67 #define ACPI_MTX_TABLES 4
68 #define ACPI_MTX_OP_REGIONS 5
69 #define ACPI_MTX_NAMESPACE 6
70 #define ACPI_MTX_EVENTS 7
71 #define ACPI_MTX_HARDWARE 8
72 #define ACPI_MTX_CACHES 9
73 #define ACPI_MTX_MEMORY 10
74 #define ACPI_MTX_DEBUG_CMD_COMPLETE 11
75 #define ACPI_MTX_DEBUG_CMD_READY 12
78 #define NUM_MTX MAX_MTX+1
81 #if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
82 #ifdef DEFINE_ACPI_GLOBALS
84 /* Names for the mutexes used in the subsystem */
86 static NATIVE_CHAR
*acpi_gbl_mutex_names
[] =
89 "ACPI_MTX_Interpreter",
91 "ACPI_MTX_Dispatcher",
93 "ACPI_MTX_Op_regions",
99 "ACPI_MTX_Debug_cmd_complete"
100 "ACPI_MTX_Debug_cmd_ready",
107 /* Table for the global mutexes */
109 typedef struct acpi_mutex_info
119 /* Lock flag parameter for various interfaces */
121 #define ACPI_MTX_DO_NOT_LOCK 0
122 #define ACPI_MTX_LOCK 1
125 typedef u16 ACPI_OWNER_ID
;
126 #define OWNER_TYPE_TABLE 0x0
127 #define OWNER_TYPE_METHOD 0x1
128 #define FIRST_METHOD_ID 0x0000
129 #define FIRST_TABLE_ID 0x8000
131 /* TBD: [Restructure] get rid of the need for this! */
133 #define TABLE_ID_DSDT (ACPI_OWNER_ID) 0x8000
136 /*****************************************************************************
138 * Namespace typedefs and structs
140 ****************************************************************************/
143 /* Operational modes of the AML interpreter/scanner */
147 IMODE_LOAD_PASS1
= 0x01,
148 IMODE_LOAD_PASS2
= 0x02,
155 * The Node describes a named object that appears in the AML
156 * An Acpi_node is used to store Nodes.
158 * Data_type is used to differentiate between internal descriptors, and MUST
159 * be the first byte in this structure.
162 typedef struct acpi_node
165 u8 type
; /* Type associated with this name */
167 u32 name
; /* ACPI Name, always 4 chars per ACPI spec */
170 void *object
; /* Pointer to attached ACPI object (optional) */
171 struct acpi_node
*child
; /* first child */
172 struct acpi_node
*peer
; /* Next peer*/
173 u16 reference_count
; /* Current count of references and children */
176 } ACPI_NAMESPACE_NODE
;
179 #define ENTRY_NOT_FOUND NULL
184 #define ANOBJ_AML_ATTACHMENT 0x01
185 #define ANOBJ_END_OF_PEER_LIST 0x02
186 #define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */
187 #define ANOBJ_METHOD_ARG 0x08
188 #define ANOBJ_METHOD_LOCAL 0x10
189 #define ANOBJ_METHOD_NO_RETVAL 0x20
190 #define ANOBJ_METHOD_SOME_NO_RETVAL 0x40
194 * ACPI Table Descriptor. One per ACPI table
196 typedef struct acpi_table_desc
198 struct acpi_table_desc
*prev
;
199 struct acpi_table_desc
*next
;
200 struct acpi_table_desc
*installed_desc
;
201 ACPI_TABLE_HEADER
*pointer
;
204 UINT64 physical_address
;
208 ACPI_OWNER_ID table_id
;
211 u8 loaded_into_namespace
;
218 NATIVE_CHAR
*search_for
;
227 ACPI_NAMESPACE_NODE
*node
;
232 * Predefined Namespace items
234 #define ACPI_MAX_ADDRESS_SPACE 255
235 #define ACPI_NUM_ADDRESS_SPACES 256
241 ACPI_OBJECT_TYPE type
;
247 /* Object types used during package copies */
250 #define ACPI_COPY_TYPE_SIMPLE 0
251 #define ACPI_COPY_TYPE_PACKAGE 1
254 /*****************************************************************************
256 * Event typedefs and structs
258 ****************************************************************************/
263 #define ACPI_STATUS_PMTIMER 0x0001
264 #define ACPI_STATUS_GLOBAL 0x0020
265 #define ACPI_STATUS_POWER_BUTTON 0x0100
266 #define ACPI_STATUS_SLEEP_BUTTON 0x0200
267 #define ACPI_STATUS_RTC_ALARM 0x0400
271 #define ACPI_ENABLE_PMTIMER 0x0001
272 #define ACPI_ENABLE_GLOBAL 0x0020
273 #define ACPI_ENABLE_POWER_BUTTON 0x0100
274 #define ACPI_ENABLE_SLEEP_BUTTON 0x0200
275 #define ACPI_ENABLE_RTC_ALARM 0x0400
279 * Entry in the Address_space (AKA Operation Region) table
284 ADDRESS_SPACE_HANDLER handler
;
287 } ACPI_ADDRESS_SPACE_INFO
;
290 /* Values and addresses of the GPE registers (both banks) */
294 u8 status
; /* Current value of status reg */
295 u8 enable
; /* Current value of enable reg */
296 u16 status_addr
; /* Address of status reg */
297 u16 enable_addr
; /* Address of enable reg */
298 u8 gpe_base
; /* Base GPE number */
300 } ACPI_GPE_REGISTERS
;
303 #define ACPI_GPE_LEVEL_TRIGGERED 1
304 #define ACPI_GPE_EDGE_TRIGGERED 2
307 /* Information about each particular GPE level */
311 u8 type
; /* Level or Edge */
313 ACPI_HANDLE method_handle
; /* Method handle for direct (fast) execution */
314 GPE_HANDLER handler
; /* Address of handler, if any */
315 void *context
; /* Context to be passed to handler */
317 } ACPI_GPE_LEVEL_INFO
;
320 /* Information about each particular fixed event */
324 FIXED_EVENT_HANDLER handler
; /* Address of handler. */
325 void *context
; /* Context to be passed to handler */
327 } ACPI_FIXED_EVENT_INFO
;
330 /* Information used during field processing */
341 /*****************************************************************************
343 * Generic "state" object for stacks
345 ****************************************************************************/
348 #define CONTROL_NORMAL 0xC0
349 #define CONTROL_CONDITIONAL_EXECUTING 0xC1
350 #define CONTROL_PREDICATE_EXECUTING 0xC2
351 #define CONTROL_PREDICATE_FALSE 0xC3
352 #define CONTROL_PREDICATE_TRUE 0xC4
355 /* Forward declarations */
356 struct acpi_walk_state
;
357 struct acpi_walk_list
;
358 struct acpi_parse_obj
;
359 struct acpi_obj_mutex
;
362 #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\
363 u8 data_type; /* To differentiate various internal objs */\
370 typedef struct acpi_common_state
377 * Update state - used to traverse complex objects such as packages
379 typedef struct acpi_update_state
382 union acpi_operand_obj
*object
;
388 * Pkg state - used to traverse nested package structures
390 typedef struct acpi_pkg_state
393 union acpi_operand_obj
*source_object
;
394 union acpi_operand_obj
*dest_object
;
395 struct acpi_walk_state
*walk_state
;
396 void *this_target_obj
;
404 * Control state - one per if/else and while constructs.
405 * Allows nesting of these constructs
407 typedef struct acpi_control_state
410 struct acpi_parse_obj
*predicate_op
;
411 u8
*aml_predicate_start
; /* Start of if/while predicate */
413 } ACPI_CONTROL_STATE
;
417 * Scope state - current scope during namespace lookups
420 typedef struct acpi_scope_state
423 ACPI_NAMESPACE_NODE
*node
;
428 typedef struct acpi_pscope_state
431 struct acpi_parse_obj
*op
; /* current op being parsed */
432 u8
*arg_end
; /* current argument end */
433 u8
*pkg_end
; /* current package end */
434 u32 arg_list
; /* next argument to parse */
435 u32 arg_count
; /* Number of fixed arguments */
441 * Result values - used to accumulate the results of nested
444 typedef struct acpi_result_values
447 union acpi_operand_obj
*obj_desc
[OBJ_NUM_OPERANDS
];
451 } ACPI_RESULT_VALUES
;
455 * Notify info - used to pass info to the deferred notify
456 * handler/dispatcher.
459 typedef struct acpi_notify_info
462 ACPI_NAMESPACE_NODE
*node
;
463 union acpi_operand_obj
*handler_obj
;
468 /* Generic state is union of structs above */
470 typedef union acpi_gen_state
472 ACPI_COMMON_STATE common
;
473 ACPI_CONTROL_STATE control
;
474 ACPI_UPDATE_STATE update
;
475 ACPI_SCOPE_STATE scope
;
476 ACPI_PSCOPE_STATE parse_scope
;
478 ACPI_RESULT_VALUES results
;
479 ACPI_NOTIFY_INFO notify
;
481 } ACPI_GENERIC_STATE
;
485 ACPI_STATUS (*ACPI_PARSE_DOWNWARDS
) (
487 struct acpi_parse_obj
*op
,
488 struct acpi_walk_state
*walk_state
,
489 struct acpi_parse_obj
**out_op
);
492 ACPI_STATUS (*ACPI_PARSE_UPWARDS
) (
493 struct acpi_walk_state
*walk_state
,
494 struct acpi_parse_obj
*op
);
497 /*****************************************************************************
499 * Parser typedefs and structs
501 ****************************************************************************/
504 #define ACPI_OP_CLASS_MASK 0x1F
505 #define ACPI_OP_ARGS_MASK 0x20
506 #define ACPI_OP_TYPE_MASK 0xC0
508 #define ACPI_OP_TYPE_OPCODE 0x00
509 #define ACPI_OP_TYPE_ASCII 0x40
510 #define ACPI_OP_TYPE_PREFIX 0x80
511 #define ACPI_OP_TYPE_UNKNOWN 0xC0
513 #define ACPI_GET_OP_CLASS(a) ((a)->flags & ACPI_OP_CLASS_MASK)
514 #define ACPI_GET_OP_ARGS(a) ((a)->flags & ACPI_OP_ARGS_MASK)
515 #define ACPI_GET_OP_TYPE(a) ((a)->flags & ACPI_OP_TYPE_MASK)
519 * AML opcode, name, and argument layout
521 typedef struct acpi_opcode_info
523 u8 flags
; /* Opcode type, Has_args flag */
524 u32 parse_args
; /* Grammar/Parse time arguments */
525 u32 runtime_args
; /* Interpret time arguments */
528 NATIVE_CHAR
*name
; /* op name (debug only) */
534 typedef union acpi_parse_val
536 u32 integer
; /* integer constant */
537 u32 size
; /* bytelist or field size */
538 NATIVE_CHAR
*string
; /* NULL terminated string */
539 u8
*buffer
; /* buffer or string */
540 NATIVE_CHAR
*name
; /* NULL terminated string */
541 struct acpi_parse_obj
*arg
; /* arguments and contained ops */
546 #define ACPI_PARSE_COMMON \
547 u8 data_type; /* To differentiate various internal objs */\
548 u8 flags; /* Type of Op */\
549 u16 opcode; /* AML opcode */\
550 u32 aml_offset; /* offset of declaration in AML */\
551 struct acpi_parse_obj *parent; /* parent op */\
552 struct acpi_parse_obj *next; /* next op */\
553 DEBUG_ONLY_MEMBERS (\
554 NATIVE_CHAR op_name[16]) /* op name (debug only) */\
555 /* NON-DEBUG members below: */\
556 ACPI_NAMESPACE_NODE *node; /* for use by interpreter */\
557 ACPI_PARSE_VALUE value; /* Value or args associated with the opcode */\
561 * generic operation (eg. If, While, Store)
563 typedef struct acpi_parse_obj
570 * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and Op_regions),
573 typedef struct acpi_parse2_obj
576 u8
*data
; /* AML body or bytelist data */
577 u32 length
; /* AML length */
578 u32 name
; /* 4-byte name or zero if no name */
580 } ACPI_PARSE2_OBJECT
;
584 * Parse state - one state per parser invocation and each control
588 typedef struct acpi_parse_state
590 u8
*aml_start
; /* first AML byte */
591 u8
*aml
; /* next AML byte */
592 u8
*aml_end
; /* (last + 1) AML byte */
593 u8
*pkg_start
; /* current package begin */
594 u8
*pkg_end
; /* current package end */
595 ACPI_PARSE_OBJECT
*start_op
; /* root of parse tree */
596 struct acpi_node
*start_node
;
597 ACPI_GENERIC_STATE
*scope
; /* current scope */
598 struct acpi_parse_state
*next
;
603 /*****************************************************************************
607 ****************************************************************************/
612 #define PCI_ROOT_HID_STRING "PNP0A03"
613 #define PCI_ROOT_HID_VALUE 0x030AD041 /* EISAID("PNP0A03") */
618 #define SLWA_DEBUG_LEVEL 4
624 #define MAX_CX_STATE_LATENCY 0xFFFFFFFF
625 #define MAX_CX_STATES 4
629 * The #define's and enum below establish an abstract way of identifying what
630 * register block and register is to be accessed. Do not change any of the
631 * values as they are used in switch statements and offset calculations.
634 #define REGISTER_BLOCK_MASK 0xFF00 /* Register Block Id */
635 #define BIT_IN_REGISTER_MASK 0x00FF /* Bit Id in the Register Block Id */
636 #define BYTE_IN_REGISTER_MASK 0x00FF /* Register Offset in the Register Block */
638 #define REGISTER_BLOCK_ID(reg_id) (reg_id & REGISTER_BLOCK_MASK)
639 #define REGISTER_BIT_ID(reg_id) (reg_id & BIT_IN_REGISTER_MASK)
640 #define REGISTER_OFFSET(reg_id) (reg_id & BYTE_IN_REGISTER_MASK)
644 * To access a Register Bit:
645 * -> Use Bit Name (= Register Block Id | Bit Id) defined in the enum.
647 * To access a Register:
648 * -> Use Register Id (= Register Block Id | Register Offset)
655 #define PM1_STS 0x0100
656 #define PM1_EN 0x0200
657 #define PM1_CONTROL 0x0300
658 #define PM1_a_CONTROL 0x0400
659 #define PM1_b_CONTROL 0x0500
660 #define PM2_CONTROL 0x0600
661 #define PM_TIMER 0x0700
662 #define PROCESSOR_BLOCK 0x0800
663 #define GPE0_STS_BLOCK 0x0900
664 #define GPE0_EN_BLOCK 0x0A00
665 #define GPE1_STS_BLOCK 0x0B00
666 #define GPE1_EN_BLOCK 0x0C00
667 #define SMI_CMD_BLOCK 0x0D00
670 * Address space bitmasks for mmio or io spaces
673 #define SMI_CMD_ADDRESS_SPACE 0x01
674 #define PM1_BLK_ADDRESS_SPACE 0x02
675 #define PM2_CNT_BLK_ADDRESS_SPACE 0x04
676 #define PM_TMR_BLK_ADDRESS_SPACE 0x08
677 #define GPE0_BLK_ADDRESS_SPACE 0x10
678 #define GPE1_BLK_ADDRESS_SPACE 0x20
681 * Control bit definitions
683 #define TMR_STS (PM1_STS | 0x01)
684 #define BM_STS (PM1_STS | 0x02)
685 #define GBL_STS (PM1_STS | 0x03)
686 #define PWRBTN_STS (PM1_STS | 0x04)
687 #define SLPBTN_STS (PM1_STS | 0x05)
688 #define RTC_STS (PM1_STS | 0x06)
689 #define WAK_STS (PM1_STS | 0x07)
691 #define TMR_EN (PM1_EN | 0x01)
693 #define GBL_EN (PM1_EN | 0x03)
694 #define PWRBTN_EN (PM1_EN | 0x04)
695 #define SLPBTN_EN (PM1_EN | 0x05)
696 #define RTC_EN (PM1_EN | 0x06)
697 #define WAK_EN (PM1_EN | 0x07)
699 #define SCI_EN (PM1_CONTROL | 0x01)
700 #define BM_RLD (PM1_CONTROL | 0x02)
701 #define GBL_RLS (PM1_CONTROL | 0x03)
702 #define SLP_TYPE_A (PM1_CONTROL | 0x04)
703 #define SLP_TYPE_B (PM1_CONTROL | 0x05)
704 #define SLP_EN (PM1_CONTROL | 0x06)
706 #define ARB_DIS (PM2_CONTROL | 0x01)
708 #define TMR_VAL (PM_TIMER | 0x01)
710 #define GPE0_STS (GPE0_STS_BLOCK | 0x01)
711 #define GPE0_EN (GPE0_EN_BLOCK | 0x01)
713 #define GPE1_STS (GPE1_STS_BLOCK | 0x01)
714 #define GPE1_EN (GPE1_EN_BLOCK | 0x01)
717 #define TMR_STS_MASK 0x0001
718 #define BM_STS_MASK 0x0010
719 #define GBL_STS_MASK 0x0020
720 #define PWRBTN_STS_MASK 0x0100
721 #define SLPBTN_STS_MASK 0x0200
722 #define RTC_STS_MASK 0x0400
723 #define WAK_STS_MASK 0x8000
725 #define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK \
726 | PWRBTN_STS_MASK | SLPBTN_STS_MASK \
727 | RTC_STS_MASK | WAK_STS_MASK)
729 #define TMR_EN_MASK 0x0001
730 #define GBL_EN_MASK 0x0020
731 #define PWRBTN_EN_MASK 0x0100
732 #define SLPBTN_EN_MASK 0x0200
733 #define RTC_EN_MASK 0x0400
735 #define SCI_EN_MASK 0x0001
736 #define BM_RLD_MASK 0x0002
737 #define GBL_RLS_MASK 0x0004
738 #define SLP_TYPE_X_MASK 0x1C00
739 #define SLP_EN_MASK 0x2000
741 #define ARB_DIS_MASK 0x0001
742 #define TMR_VAL_MASK 0xFFFFFFFF
744 #define GPE0_STS_MASK
747 #define GPE1_STS_MASK
757 /* Pnp and ACPI data */
759 #define VERSION_NO 0x01
760 #define LOGICAL_DEVICE_ID 0x02
761 #define COMPATIBLE_DEVICE_ID 0x03
762 #define IRQ_FORMAT 0x04
763 #define DMA_FORMAT 0x05
764 #define START_DEPENDENT_TAG 0x06
765 #define END_DEPENDENT_TAG 0x07
766 #define IO_PORT_DESCRIPTOR 0x08
767 #define FIXED_LOCATION_IO_DESCRIPTOR 0x09
768 #define RESERVED_TYPE0 0x0A
769 #define RESERVED_TYPE1 0x0B
770 #define RESERVED_TYPE2 0x0C
771 #define RESERVED_TYPE3 0x0D
772 #define SMALL_VENDOR_DEFINED 0x0E
775 /* Pnp and ACPI data */
777 #define MEMORY_RANGE_24 0x81
778 #define ISA_MEMORY_RANGE 0x81
779 #define LARGE_VENDOR_DEFINED 0x84
780 #define EISA_MEMORY_RANGE 0x85
781 #define MEMORY_RANGE_32 0x85
782 #define FIXED_EISA_MEMORY_RANGE 0x86
783 #define FIXED_MEMORY_RANGE_32 0x86
787 #define DWORD_ADDRESS_SPACE 0x87
788 #define WORD_ADDRESS_SPACE 0x88
789 #define EXTENDED_IRQ 0x89
793 #define DEVICE_ID_LENGTH 0x09
797 NATIVE_CHAR buffer
[DEVICE_ID_LENGTH
];
802 /*****************************************************************************
806 ****************************************************************************/
809 /* Entry for a memory allocation (debug only) */
815 #define MAX_MODULE_NAME 16
817 typedef struct allocation_info
819 struct allocation_info
*previous
;
820 struct allocation_info
*next
;
825 NATIVE_CHAR module
[MAX_MODULE_NAME
];
832 #endif /* __ACLOCAL_H__ */