diff options
Diffstat (limited to 'drivers/acpi/include')
26 files changed, 9033 insertions, 0 deletions
diff --git a/drivers/acpi/include/acenv.h b/drivers/acpi/include/acenv.h new file mode 100644 index 000000000..f2738537f --- /dev/null +++ b/drivers/acpi/include/acenv.h @@ -0,0 +1,302 @@ + +/****************************************************************************** + * + * Name: acenv.h - Generation environment specific items + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + + +/* + * Environment configuration. The purpose of this file is to interface to the + * local generation environment. + * + * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPI subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + * + * + * Functions and constants used from each header: + * + * string.h: memcpy + * memset + * strcat + * strcmp + * strcpy + * strlen + * strncmp + * strncat + * strncpy + * + * stdlib.h: strtoul + * + * stdarg.h: va_list + * va_arg + * va_start + * va_end + * + */ + + +/* + * Environment-specific configuration + */ + +#ifdef _LINUX + +#include <linux/config.h> +#include <linux/string.h> +#include <linux/kernel.h> +#include <linux/ctype.h> +#include <asm/system.h> + +/* Single threaded */ + +#define ACPI_APPLICATION + +/* Use native Linux string library */ + +#define ACPI_USE_SYSTEM_CLIBRARY + +/* Special functions */ + +#define strtoul simple_strtoul + +#else + +/* All other environments */ + +#define ACPI_USE_STANDARD_HEADERS + +#endif + + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +#ifdef ACPI_USE_SYSTEM_CLIBRARY +/* + * Use the standard C library headers. + * We want to keep these to a minimum. + * + */ + +#ifdef ACPI_USE_STANDARD_HEADERS +/* + * Use the standard headers from the standard locations + */ +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* + * We will be linking to the standard Clib functions + */ + +#define STRSTR(s1,s2) strstr((char *) (s1), (char *) (s2)) +#define STRUPR(s) strupr((char *) (s)) +#define STRLEN(s) strlen((char *) (s)) +#define STRCPY(d,s) strcpy((char *) (d), (char *) (s)) +#define STRNCPY(d,s,n) strncpy((char *) (d), (char *) (s), (n)) +#define STRNCMP(d,s,n) strncmp((char *) (d), (char *) (s), (n)) +#define STRCMP(d,s) strcmp((char *) (d), (char *) (s)) +#define STRCAT(d,s) strcat((char *) (d), (char *) (s)) +#define STRNCAT(d,s,n) strncat((char *) (d), (char *) (s), (n)) +#define STRTOUL(d,s,n) strtoul((char *) (d), (char **) (s), (n)) +#define MEMCPY(d,s,n) memcpy(d, s, (size_t) n) +#define MEMSET(d,s,n) memset(d, s, (size_t) n) +#define TOUPPER toupper +#define TOLOWER tolower + + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ +#else + +/* + * Use local definitions of C library macros and functions + * NOTE: The function implementations may not be as efficient + * as an inline or assembly code implementation provided by a + * native C library. + */ + +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* + * Storage alignment properties + */ + +#define _AUPBND (sizeof(int) - 1) +#define _ADNBND (sizeof(int) - 1) + +/* + * Variable argument list macro definitions + */ + +#define _bnd(X, bnd) (((sizeof(X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap) += ((_bnd(T, _AUPBND))) \ + - (_bnd(T, _ADNBND))))) +#define va_end(ap) (void)0 +#define va_start(ap, A) (void) ((ap) = (((char *)&(A)) \ + + (_bnd(A, _AUPBND)))) + +#endif /* va_arg */ + + +#define STRSTR(s1,s2) acpi_cm_strstr ((char *) (s1), (char *) (s2)) +#define STRUPR(s) acpi_cm_strupr ((char *) (s)) +#define STRLEN(s) acpi_cm_strlen ((char *) (s)) +#define STRCPY(d,s) acpi_cm_strcpy ((char *) (d), (char *) (s)) +#define STRNCPY(d,s,n) acpi_cm_strncpy ((char *) (d), (char *) (s), (n)) +#define STRNCMP(d,s,n) acpi_cm_strncmp ((char *) (d), (char *) (s), (n)) +#define STRCMP(d,s) acpi_cm_strcmp ((char *) (d), (char *) (s)) +#define STRCAT(d,s) acpi_cm_strcat ((char *) (d), (char *) (s)) +#define STRNCAT(d,s,n) acpi_cm_strncat ((char *) (d), (char *) (s), (n)) +#define STRTOUL(d,s,n) acpi_cm_strtoul ((char *) (d), (char **) (s), (n)) +#define MEMCPY(d,s,n) acpi_cm_memcpy ((void *) (d), (const void *) (s), (n)) +#define MEMSET(d,v,n) acpi_cm_memset ((void *) (d), (v), (n)) +#define TOUPPER acpi_cm_to_upper +#define TOLOWER acpi_cm_to_lower + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + + +/****************************************************************************** + * + * Assembly code macros + * + *****************************************************************************/ + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + + +#ifdef __GNUC__ + +#ifdef __ia64__ +#define _IA64 +#endif + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() __cli() +#define enable() __sti() +#define halt() __asm__ __volatile__ ("sti; hlt":::"memory") +#define wbinvd() + + +/*! [Begin] no source code translation + * + * A brief explanation as GNU inline assembly is a bit hairy + * %0 is the output parameter in EAX ("=a") + * %1 and %2 are the input parameters in ECX ("c") and an immediate value ("i") respectively + * All actual register references are preceded with "%%" as in "%%edx" + * Immediate values in the assembly are preceded by "$" as in "$0x1" + * The final asm parameter is the non-output registers altered by the operation + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) +/*! [End] no source code translation !*/ + +#endif /* __GNUC__ */ + + +#ifndef ACPI_ASM_MACROS + +/* Unrecognized compiler, use defaults */ + +#define ACPI_ASM_MACROS +#define causeinterrupt(level) +#define BREAKPOINT3 +#define disable() +#define enable() +#define halt() + +#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq) +#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq) + +#endif /* ACPI_ASM_MACROS */ + + +#ifdef ACPI_APPLICATION + +/* Don't want software interrupts within a ring3 application */ + +#undef causeinterrupt +#undef BREAKPOINT3 +#define causeinterrupt(level) +#define BREAKPOINT3 +#endif + + +#endif /* __ACENV_H__ */ diff --git a/drivers/acpi/include/acexcep.h b/drivers/acpi/include/acexcep.h new file mode 100644 index 000000000..4913ffd2c --- /dev/null +++ b/drivers/acpi/include/acexcep.h @@ -0,0 +1,162 @@ + +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + +#define AE_OK (ACPI_STATUS) 0x0000 +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) 0x0001 +#define AE_CTRL_PENDING (ACPI_STATUS) 0x0002 +#define AE_CTRL_TERMINATE (ACPI_STATUS) 0x0003 +#define AE_CTRL_TRUE (ACPI_STATUS) 0x0004 +#define AE_CTRL_FALSE (ACPI_STATUS) 0x0005 +#define AE_CTRL_DEPTH (ACPI_STATUS) 0x0006 +#define AE_CTRL_RESERVED (ACPI_STATUS) 0x0007 +#define AE_AML_ERROR (ACPI_STATUS) 0x0008 +#define AE_AML_PARSE (ACPI_STATUS) 0x0009 +#define AE_AML_BAD_OPCODE (ACPI_STATUS) 0x000A +#define AE_AML_NO_OPERAND (ACPI_STATUS) 0x000B +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) 0x000C +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) 0x000D +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) 0x000E +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) 0x000F +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) 0x0010 +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) 0x0011 +#define AE_AML_REGION_LIMIT (ACPI_STATUS) 0x0012 +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) 0x0013 +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) 0x0014 +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) 0x0015 +#define AE_AML_BAD_NAME (ACPI_STATUS) 0x0016 +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) 0x0017 +#define AE_AML_INTERNAL (ACPI_STATUS) 0x0018 +#define AE_AML_RESERVED (ACPI_STATUS) 0x0019 +#define AE_ERROR (ACPI_STATUS) 0x001A +#define AE_NO_ACPI_TABLES (ACPI_STATUS) 0x001B +#define AE_NO_NAMESPACE (ACPI_STATUS) 0x001C +#define AE_NO_MEMORY (ACPI_STATUS) 0x001D +#define AE_BAD_SIGNATURE (ACPI_STATUS) 0x001E +#define AE_BAD_HEADER (ACPI_STATUS) 0x001F +#define AE_BAD_CHECKSUM (ACPI_STATUS) 0x0020 +#define AE_BAD_PARAMETER (ACPI_STATUS) 0x0021 +#define AE_BAD_CHARACTER (ACPI_STATUS) 0x0022 +#define AE_BAD_PATHNAME (ACPI_STATUS) 0x0023 +#define AE_BAD_DATA (ACPI_STATUS) 0x0024 +#define AE_BAD_ADDRESS (ACPI_STATUS) 0x0025 +#define AE_NOT_FOUND (ACPI_STATUS) 0x0026 +#define AE_NOT_EXIST (ACPI_STATUS) 0x0027 +#define AE_EXIST (ACPI_STATUS) 0x0028 +#define AE_TYPE (ACPI_STATUS) 0x0029 +#define AE_NULL_OBJECT (ACPI_STATUS) 0x002A +#define AE_NULL_ENTRY (ACPI_STATUS) 0x002B +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) 0x002C +#define AE_STACK_OVERFLOW (ACPI_STATUS) 0x002D +#define AE_STACK_UNDERFLOW (ACPI_STATUS) 0x002E +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) 0x002F +#define AE_VERSION_MISMATCH (ACPI_STATUS) 0x0030 +#define AE_SUPPORT (ACPI_STATUS) 0x0031 +#define AE_SHARE (ACPI_STATUS) 0x0032 +#define AE_LIMIT (ACPI_STATUS) 0x0033 +#define AE_TIME (ACPI_STATUS) 0x0034 +#define AE_UNKNOWN_STATUS (ACPI_STATUS) 0x0035 +#define ACPI_MAX_STATUS (ACPI_STATUS) 0x0035 +#define ACPI_NUM_STATUS (ACPI_STATUS) 0x0036 + + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +static char *acpi_gbl_exception_names[] = +{ + "AE_OK", + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_RESERVED", + "AE_AML_ERROR", + "AE_AML_PARSE", + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", + "AE_AML_RESERVED", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_ADDRESS", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_EXIST", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_VERSION_MISMATCH", + "AE_SUPPORT", + "AE_SHARE", + "AE_LIMIT", + "AE_TIME", + "AE_UNKNOWN_STATUS" +}; + +#endif /* DEFINE_ACPI_GLOBALS */ + + +#endif /* __ACEXCEP_H__ */ diff --git a/drivers/acpi/include/acobject.h b/drivers/acpi/include/acobject.h new file mode 100644 index 000000000..449e23bb4 --- /dev/null +++ b/drivers/acpi/include/acobject.h @@ -0,0 +1,508 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OBJECT_INTERNAL (Internal object only) + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + +#include "actypes.h" +#include "macros.h" +#include "internal.h" + +/* + * The ACPI_OBJECT_INTERNAL is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow them to be cached and reused. + * + * All variants of the ACPI_OBJECT_INTERNAL are defined with the same + * sequence of field types, with fields that are not used in a particular + * variant being named "Reserved". This is not strictly necessary, but + * may in some circumstances simplify understanding if these structures + * need to be displayed in a debugger having limited (or no) support for + * union types. It also simplifies some debug code in Dump_table() which + * dumps multi-level values: fetching Buffer.Pointer suffices to pick up + * the value or next level for any of several types. + */ + +/****************************************************************************** + * + * Common Descriptors + * + *****************************************************************************/ + +/* + * Common area for all objects. + * + * Data_type is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + + +#define ACPI_OBJECT_COMMON_HEADER /* Two 32-bit fields */\ + u8 data_type; /* To differentiate various internal objs */\ + u8 type; /* ACPI_OBJECT_TYPE */\ + u8 size; /* Size of entire descriptor */\ + u8 flags;\ + u16 reference_count; /* For object deletion management */\ + u16 acpi_cm_fill2;\ + union acpi_obj_internal *next; \ + +/* Defines for flag byte above */ + +#define AO_STATIC_ALLOCATION 0x1 + + +/* + * Common bitfield for the field objects + */ +#define ACPI_COMMON_FIELD_INFO /* Three 32-bit values */\ + u32 offset; /* Byte offset within containing object */\ + u16 length; /* # of bits in buffer */ \ + u8 granularity;\ + u8 bit_offset; /* Bit offset within min read/write data unit */\ + u8 access; /* Access_type */\ + u8 lock_rule;\ + u8 update_rule;\ + u8 access_attribute; + + +/****************************************************************************** + * + * Individual Object Descriptors + * + *****************************************************************************/ + + +typedef struct /* COMMON */ +{ + ACPI_OBJECT_COMMON_HEADER + UCHAR first_non_common_byte; + +} ACPI_OBJECT_COMMON; + + +typedef struct /* NUMBER - has value */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 value; + u32 reserved2; + u32 reserved3; + u32 reserved4; + + void *reserved_p1; + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_NUMBER; + + +typedef struct /* STRING - has length and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 length; /* # of bytes in string, excluding trailing null */ + u32 reserved2; + u32 reserved3; + u32 reserved4; + + char *pointer; /* String value in AML stream or in allocated space */ + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_STRING; + + +typedef struct /* BUFFER - has length, sequence, and pointer */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 length; /* # of bytes in buffer */ + u32 sequence; /* Sequential count of buffers created */ + u32 reserved3; + u32 reserved4; + + u8 *pointer; /* points to the buffer in allocated space */ + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_BUFFER; + + +typedef struct /* PACKAGE - has count, elements, next element */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 count; /* # of elements in package */ + u32 reserved2; + u32 reserved3; + u32 reserved4; + + union acpi_obj_internal **elements; /* Array of pointers to Acpi_objects */ + union acpi_obj_internal **next_element; /* used only while initializing */ + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_PACKAGE; + + +typedef struct /* FIELD UNIT */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + u32 sequence; /* Container's sequence number */ + + union acpi_obj_internal *container; /* Containing object (Buffer) */ + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_FIELD_UNIT; + + +typedef struct /* DEVICE - has handle and notification handler/context */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 reserved1; + u32 reserved2; + u32 reserved3; + u32 reserved4; + + ACPI_HANDLE handle; + union acpi_obj_internal *sys_handler; /* Handler for system notifies */ + union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ + union acpi_obj_internal *addr_handler; /* Handler for Address space */ + void *reserved_p5; + +} ACPI_OBJECT_DEVICE; + + +typedef struct /* EVENT */ +{ + ACPI_OBJECT_COMMON_HEADER + + u16 lock_count; + u16 thread_id; + u16 signal_count; + u16 fill1; + u32 reserved3; + u32 reserved4; + + void *semaphore; + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_EVENT; + + +#define INFINITE_CONCURRENCY 0xFF + +typedef struct /* METHOD */ +{ + ACPI_OBJECT_COMMON_HEADER + + u8 method_flags; + u8 param_count; + u8 concurrency; + u8 fill1; + u32 pcode_length; + u32 table_length; + ACPI_OWNER_ID owning_id; + u16 reserved4; + + u8 *pcode; + u8 *acpi_table; + void *parser_op; + void *semaphore; + void *reserved_p5; + +} ACPI_OBJECT_METHOD; + + +typedef struct /* MUTEX */ +{ + ACPI_OBJECT_COMMON_HEADER + + u16 lock_count; + u16 thread_id; + u16 sync_level; + u16 fill1; + u32 reserved3; + u32 reserved4; + + void *semaphore; + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_MUTEX; + +/* Flags for Region */ + +#define INITIAL_REGION_FLAGS 0x0000 /* value set when the region is created */ +#define REGION_AGRUMENT_DATA_VALID 0x0001 /* Addr/Len are set */ +#define REGION_INITIALIZED 0x0002 /* region init handler has been called */ + /* this includes _REG method, if any */ + +typedef struct /* REGION */ +{ + ACPI_OBJECT_COMMON_HEADER + + u16 space_id; + u16 region_flags; /* bits defined above */ + u32 address; + u32 length; + u32 reserved4; /* Region Specific data (PCI _ADR) */ + + union acpi_obj_internal *method; /* Associated control method */ + union acpi_obj_internal *addr_handler; /* Handler for system notifies */ + union acpi_obj_internal *link; /* Link in list of regions */ + /* list is owned by Addr_handler */ + ACPI_NAMED_OBJECT *REGmethod; /* _REG method for this region (if any) */ + ACPI_NAMED_OBJECT *nte; /* containing object */ + +} ACPI_OBJECT_REGION; + + +typedef struct /* POWER RESOURCE - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 system_level; + u32 resource_order; + u32 reserved3; + u32 reserved4; + + ACPI_HANDLE handle; + union acpi_obj_internal *sys_handler; /* Handler for system notifies */ + union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct /* PROCESSOR - has Handle and notification handler/context*/ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 proc_id; + ACPI_IO_ADDRESS pblk_address; + u16 fill1; + u32 pblk_length; + u32 reserved4; + + ACPI_HANDLE handle; + union acpi_obj_internal *sys_handler; /* Handler for system notifies */ + union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ + union acpi_obj_internal *addr_handler; /* Handler for Address space */ + void *reserved_p5; + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct /* THERMAL ZONE - has Handle and Handler/Context */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 reserved1; + u32 reserved2; + u32 reserved3; + u32 reserved4; + + ACPI_HANDLE handle; + union acpi_obj_internal *sys_handler; /* Handler for system notifies */ + union acpi_obj_internal *drv_handler; /* Handler for driver notifies */ + union acpi_obj_internal *addr_handler; /* Handler for Address space */ + void *reserved_p5; + +} ACPI_OBJECT_THERMAL_ZONE; + + +/* + * Internal types + */ + +typedef struct /* FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + u32 reserved4; + + union acpi_obj_internal *container; /* Containing object */ + void *reserved_p2; + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_FIELD; + + +typedef struct /* BANK FIELD */ +{ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + u32 value; /* Value to store into Bank_select */ + + ACPI_HANDLE bank_select; /* Bank select register */ + union acpi_obj_internal *container; /* Containing object */ + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct /* INDEX FIELD */ +{ + /* + * No container pointer needed since the index and data register definitions + * will define how to access the respective registers + */ + ACPI_OBJECT_COMMON_HEADER + + ACPI_COMMON_FIELD_INFO + u32 value; /* Value to store into Index register */ + + ACPI_HANDLE index; /* Index register */ + ACPI_HANDLE data; /* Data register */ + void *reserved_p3; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_INDEX_FIELD; + + +typedef struct /* NOTIFY HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + u32 reserved1; + u32 reserved2; + u32 reserved3; + u32 reserved4; + + ACPI_NAMED_OBJECT *nte; /* Parent device */ + NOTIFY_HANDLER handler; + void *context; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +/* Flags for address handler */ + +#define ADDR_HANDLER_DEFAULT_INSTALLED 0x1 + +typedef struct /* ADDRESS HANDLER */ +{ + ACPI_OBJECT_COMMON_HEADER + + u16 space_id; + u16 hflags; + ADDRESS_SPACE_HANDLER handler; + + ACPI_NAMED_OBJECT *nte; /* Parent device */ + void *context; + ADDRESS_SPACE_SETUP setup; + union acpi_obj_internal *link; /* Link to next handler on device */ + union acpi_obj_internal *region_list; /* regions using this handler */ + +} ACPI_OBJECT_ADDR_HANDLER; + + +/* + * The Reference object type is used for these opcodes: + * Arg[0-6], Local[0-7], Index_op, Name_op, Zero_op, One_op, Ones_op, Debug_op + */ + +typedef struct /* Reference - Local object type */ +{ + ACPI_OBJECT_COMMON_HEADER + + u16 op_code; + u8 fill1; + u8 target_type; /* Used for Index_op */ + u32 offset; /* Used for Arg_op, Local_op, and Index_op */ + u32 reserved3; + u32 reserved4; + + void *object; /* Name_op=>HANDLE to obj, Index_op=>ACPI_OBJECT_INTERNAL */ + ACPI_NAMED_OBJECT *nte; + union acpi_obj_internal **where; + void *reserved_p4; + void *reserved_p5; + +} ACPI_OBJECT_REFERENCE; + + +/****************************************************************************** + * + * ACPI_OBJECT_INTERNAL Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_obj_internal +{ + ACPI_OBJECT_COMMON common; + ACPI_OBJECT_NUMBER number; + ACPI_OBJECT_STRING string; + ACPI_OBJECT_BUFFER buffer; + ACPI_OBJECT_PACKAGE package; + ACPI_OBJECT_FIELD_UNIT field_unit; + ACPI_OBJECT_DEVICE device; + ACPI_OBJECT_EVENT event; + ACPI_OBJECT_METHOD method; + ACPI_OBJECT_MUTEX mutex; + ACPI_OBJECT_REGION region; + ACPI_OBJECT_POWER_RESOURCE power_resource; + ACPI_OBJECT_PROCESSOR processor; + ACPI_OBJECT_THERMAL_ZONE thermal_zone; + ACPI_OBJECT_FIELD field; + ACPI_OBJECT_BANK_FIELD bank_field; + ACPI_OBJECT_INDEX_FIELD index_field; + ACPI_OBJECT_REFERENCE reference; + ACPI_OBJECT_NOTIFY_HANDLER notify_handler; + ACPI_OBJECT_ADDR_HANDLER addr_handler; + +} ACPI_OBJECT_INTERNAL; + +#endif /* _ACOBJECT_H */ diff --git a/drivers/acpi/include/acpi.h b/drivers/acpi/include/acpi.h new file mode 100644 index 000000000..5dc0a853a --- /dev/null +++ b/drivers/acpi/include/acpi.h @@ -0,0 +1,50 @@ + +/****************************************************************************** + * + * Name: acpi.h - Master include file, Publics and external data. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Common includes for all ACPI driver files + * We put them here because we don't want to duplicate them + * in the rest of the source code again and again. + */ +#include "config.h" /* Configuration constants */ +#include "acenv.h" /* Target environment specific items */ +#include "actypes.h" /* Fundamental data types */ +#include "acexcep.h" /* Local exception codes */ +#include "macros.h" /* C macros */ +#include "actables.h" /* Acpi table definitions */ +#include "internal.h" /* Internal data types */ +#include "output.h" /* Error output and Debug macros */ +#include "acpiosxf.h" /* Interfaces to the Acpi-to-OS layer*/ +#include "acpixf.h" /* Acpi core external interfaces */ +#include "acobject.h" /* Acpi internal object */ +#include "globals.h" /* All global variables */ +#include "hardware.h" /* Hardware defines and interfaces */ +#include "common.h" /* Common (global) interfaces */ + + +#endif /* __ACPI_H__ */ diff --git a/drivers/acpi/include/acpiosxf.h b/drivers/acpi/include/acpiosxf.h new file mode 100644 index 000000000..6f5c30c56 --- /dev/null +++ b/drivers/acpi/include/acpiosxf.h @@ -0,0 +1,296 @@ + +/****************************************************************************** + * + * Name: acpiosd.h - All interfaces to the OS-dependent layer. These + * interfaces must be implemented by the OS-dependent + * front-end to the ACPI subsystem. + * + *****************************************************************************/ + + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACPIOSD_H__ +#define __ACPIOSD_H__ + +#include "acenv.h" +#include "actypes.h" + + +/* Priorities for Acpi_os_queue_for_execution */ + +#define OSD_PRIORITY_HIGH 1 +#define OSD_PRIORITY_MED 2 +#define OSD_PRIORITY_LO 3 +#define OSD_PRIORITY_GPE OSD_PRIORITY_HIGH + +#define ACPI_NO_UNIT_LIMIT ((u32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* + * Types specific to the OS-dependent layer interfaces + */ + +typedef +u32 (*OSD_HANDLER) ( + void *context); + +typedef +void (*OSD_EXECUTION_CALLBACK) ( + void *context); + + +/* + * Initialization and shutdown primitives (Optional) + */ + +ACPI_STATUS +acpi_os_initialize ( + void); + +ACPI_STATUS +acpi_os_terminate ( + void); + +/* + * Synchronization primitives + */ + +ACPI_STATUS +acpi_os_create_semaphore ( + u32 max_units, + u32 initial_units, + ACPI_HANDLE *out_handle); + +ACPI_STATUS +acpi_os_delete_semaphore ( + ACPI_HANDLE handle); + +ACPI_STATUS +acpi_os_wait_semaphore ( + ACPI_HANDLE handle, + u32 units, + u32 timeout); + +ACPI_STATUS +acpi_os_signal_semaphore ( + ACPI_HANDLE handle, + u32 units); + +/* + * Memory allocation and mapping + */ + +void * +acpi_os_allocate ( + u32 size); + +void * +acpi_os_callocate ( + u32 size); + +void +acpi_os_free ( + void * memory); + +ACPI_STATUS +acpi_os_map_memory ( + void *physical_address, + u32 length, + void **logical_address); + +void +acpi_os_unmap_memory ( + void *logical_address, + u32 length); + + +/* + * Interrupt handlers + */ + +ACPI_STATUS +acpi_os_install_interrupt_handler ( + u32 interrupt_number, + OSD_HANDLER service_routine, + void *context); + +ACPI_STATUS +acpi_os_remove_interrupt_handler ( + u32 interrupt_number, + OSD_HANDLER service_routine); + + +/* + * Scheduling + */ + +ACPI_STATUS +acpi_os_queue_for_execution ( + u32 priority, + OSD_EXECUTION_CALLBACK function, + void *context); + +void +acpi_os_sleep ( + u32 seconds, + u32 milliseconds); + +void +acpi_os_sleep_usec ( + u32 microseconds); + +/* + * Platform/Hardware independent I/O interfaces + */ + +u8 +acpi_os_in8 ( + ACPI_IO_ADDRESS in_port); + + +u16 +acpi_os_in16 ( + ACPI_IO_ADDRESS in_port); + +u32 +acpi_os_in32 ( + ACPI_IO_ADDRESS in_port); + +void +acpi_os_out8 ( + ACPI_IO_ADDRESS out_port, + u8 value); + +void +acpi_os_out16 ( + ACPI_IO_ADDRESS out_port, + u16 value); + +void +acpi_os_out32 ( + ACPI_IO_ADDRESS out_port, + u32 value); + + +/* + * Standard access to PCI configuration space + */ + +ACPI_STATUS +acpi_os_read_pci_cfg_byte ( + u32 bus, + u32 device_function, + u32 register, + u8 *value); + +ACPI_STATUS +acpi_os_read_pci_cfg_word ( + u32 bus, + u32 device_function, + u32 register, + u16 *value); + +ACPI_STATUS +acpi_os_read_pci_cfg_dword ( + u32 bus, + u32 device_function, + u32 register, + u32 *value); + +ACPI_STATUS +acpi_os_write_pci_cfg_byte ( + u32 bus, + u32 device_function, + u32 register, + u8 value); + +ACPI_STATUS +acpi_os_write_pci_cfg_word ( + u32 bus, + u32 device_function, + u32 register, + u16 value); + + +ACPI_STATUS +acpi_os_write_pci_cfg_dword ( + u32 bus, + u32 device_function, + u32 register, + u32 value); + + +/* + * Miscellaneous + */ + +ACPI_STATUS +acpi_os_breakpoint ( + char *message); + +u8 +acpi_os_readable ( + void *pointer, + u32 length); + + +u8 +acpi_os_writable ( + void *pointer, + u32 length); + + +/* + * Debug print routines + */ + +s32 +acpi_os_printf ( + const char *format, + ...); + +s32 +acpi_os_vprintf ( + const char *format, + va_list args); + +/* + * Debug input + */ + +u32 +acpi_os_get_line ( + char *buffer); + + +/* + * Debug + */ + +void +acpi_os_dbg_assert( + void *failed_assertion, + void *file_name, + u32 line_number, + char *message); + + +#endif /* __ACPIOSD_H__ */ diff --git a/drivers/acpi/include/acpixf.h b/drivers/acpi/include/acpixf.h new file mode 100644 index 000000000..cc2205b63 --- /dev/null +++ b/drivers/acpi/include/acpixf.h @@ -0,0 +1,299 @@ + +/****************************************************************************** + * + * Name: acxface.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +#include "actypes.h" +#include "actables.h" + +/* + * Global interfaces + */ + +ACPI_STATUS +acpi_initialize ( + ACPI_INIT_DATA *init_data); + +ACPI_STATUS +acpi_terminate ( + void); + +ACPI_STATUS +acpi_enable ( + void); + +ACPI_STATUS +acpi_disable ( + void); + +ACPI_STATUS +acpi_get_system_info( + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_format_exception ( + ACPI_STATUS exception, + ACPI_BUFFER *out_buffer); + + +/* + * ACPI table manipulation interfaces + */ + +ACPI_STATUS +acpi_load_firmware_tables ( + void); + +ACPI_STATUS +acpi_load_table ( + ACPI_TABLE_HEADER *table_ptr); + +ACPI_STATUS +acpi_unload_table ( + ACPI_TABLE_TYPE table_type); + +ACPI_STATUS +acpi_get_table_header ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER *out_table_header); + +ACPI_STATUS +acpi_get_table ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_BUFFER *ret_buffer); + + +/* + * Namespace and name interfaces + */ + +ACPI_STATUS +acpi_load_namespace ( + void); + +ACPI_STATUS +acpi_walk_namespace ( + ACPI_OBJECT_TYPE type, + ACPI_HANDLE start_object, + u32 max_depth, + WALK_CALLBACK user_function, + void *context, + void * *return_value); + +ACPI_STATUS +acpi_get_name ( + ACPI_HANDLE handle, + u32 name_type, + ACPI_BUFFER *ret_path_ptr); + +ACPI_STATUS +acpi_get_handle ( + ACPI_HANDLE parent, + ACPI_STRING pathname, + ACPI_HANDLE *ret_handle); + + +/* + * Object manipulation and enumeration + */ + +ACPI_STATUS +acpi_evaluate_object ( + ACPI_HANDLE object, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *parameter_objects, + ACPI_BUFFER *return_object_buffer); + +ACPI_STATUS +acpi_get_object_info ( + ACPI_HANDLE device, + ACPI_DEVICE_INFO *info); + +ACPI_STATUS +acpi_get_next_object ( + ACPI_OBJECT_TYPE type, + ACPI_HANDLE parent, + ACPI_HANDLE child, + ACPI_HANDLE *out_handle); + +ACPI_STATUS +acpi_get_type ( + ACPI_HANDLE object, + ACPI_OBJECT_TYPE *out_type); + +ACPI_STATUS +acpi_get_parent ( + ACPI_HANDLE object, + ACPI_HANDLE *out_handle); + + +/* + * Acpi_event handler interfaces + */ + +ACPI_STATUS +acpi_install_fixed_event_handler ( + u32 acpi_event, + FIXED_EVENT_HANDLER handler, + void *context); + +ACPI_STATUS +acpi_remove_fixed_event_handler ( + u32 acpi_event, + FIXED_EVENT_HANDLER handler); + +ACPI_STATUS +acpi_install_notify_handler ( + ACPI_HANDLE device, + u32 handler_type, + NOTIFY_HANDLER handler, + void *context); + +ACPI_STATUS +acpi_remove_notify_handler ( + ACPI_HANDLE device, + u32 handler_type, + NOTIFY_HANDLER handler); + +ACPI_STATUS +acpi_install_address_space_handler ( + ACPI_HANDLE device, + ACPI_ADDRESS_SPACE_TYPE space_id, + ADDRESS_SPACE_HANDLER handler, + ADDRESS_SPACE_SETUP setup, + void *context); + +ACPI_STATUS +acpi_remove_address_space_handler ( + ACPI_HANDLE device, + ACPI_ADDRESS_SPACE_TYPE space_id, + ADDRESS_SPACE_HANDLER handler); + +ACPI_STATUS +acpi_install_gpe_handler ( + u32 gpe_number, + u32 type, + GPE_HANDLER handler, + void *context); + +ACPI_STATUS +acpi_remove_gpe_handler ( + u32 gpe_number, + GPE_HANDLER handler); + +ACPI_STATUS +acpi_enable_event ( + u32 acpi_event, + u32 type); + +ACPI_STATUS +acpi_disable_event ( + u32 acpi_event, + u32 type); + +ACPI_STATUS +acpi_clear_event ( + u32 acpi_event, + u32 type); + +ACPI_STATUS +acpi_get_event_status ( + u32 acpi_event, + u32 type, + ACPI_EVENT_STATUS *event_status); + +/* + * Resource interfaces + */ + +ACPI_STATUS +acpi_get_current_resources( + ACPI_HANDLE device_handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_get_possible_resources( + ACPI_HANDLE device_handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_set_current_resources ( + ACPI_HANDLE device_handle, + ACPI_BUFFER *in_buffer); + +ACPI_STATUS +acpi_get_irq_routing_table ( + ACPI_HANDLE bus_device_handle, + ACPI_BUFFER *ret_buffer); + + +/* + * Hardware (ACPI device) interfaces + */ + +ACPI_STATUS +acpi_set_firmware_waking_vector ( + void *physical_address); + +ACPI_STATUS +acpi_get_firmware_waking_vector ( + void **physical_address); + +ACPI_STATUS +acpi_get_processor_throttling_info ( + ACPI_HANDLE processor_handle, + ACPI_BUFFER *user_buffer); + +ACPI_STATUS +acpi_set_processor_throttling_state ( + ACPI_HANDLE processor_handle, + u32 throttle_state); + +ACPI_STATUS +acpi_get_processor_throttling_state ( + ACPI_HANDLE processor_handle, + u32 *throttle_state); + +ACPI_STATUS +acpi_get_processor_cx_info ( + ACPI_HANDLE processor_handle, + ACPI_BUFFER *user_buffer); + +ACPI_STATUS +acpi_set_processor_sleep_state ( + ACPI_HANDLE processor_handle, + u32 cx_state); + +ACPI_STATUS +acpi_processor_sleep ( + ACPI_HANDLE processor_handle, + u32 *pm_timer_ticks); + + +#endif /* __ACXFACE_H__ */ diff --git a/drivers/acpi/include/actables.h b/drivers/acpi/include/actables.h new file mode 100644 index 000000000..67d2d84bb --- /dev/null +++ b/drivers/acpi/include/actables.h @@ -0,0 +1,188 @@ + +/****************************************************************************** + * + * Name: actables.h - Table data structures defined in ACPI specification + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +/* + * Values for description table header signatures + */ + +#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */ +#define APIC_SIG "APIC" /* Multiple APIC Description Table */ +#define DSDT_SIG "DSDT" /* Differentiated System Description Table */ +#define FACP_SIG "FACP" /* Fixed ACPI Description Table */ +#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */ +#define PSDT_SIG "PSDT" /* Persistent System Description Table */ +#define RSDT_SIG "RSDT" /* Root System Description Table */ +#define SSDT_SIG "SSDT" /* Secondary System Description Table */ +#define SBST_SIG "SBST" /* Smart Battery Specification Table */ +#define BOOT_SIG "BOOT" /* Boot table */ + + +#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */ + +/* values of Mapic.Model */ + +#define DUAL_PIC 0 +#define MULTIPLE_APIC 1 + +/* values of Type in APIC_HEADER */ + +#define APIC_PROC 0 +#define APIC_IO 1 + + +/* + * Architecture-independent tables + * The architecture dependent tables are in separate files + */ + +typedef struct /* Root System Descriptor Pointer */ +{ + char signature [8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + char oem_id [6]; /* OEM identification */ + u8 reserved; /* reserved - must be zero */ + u32 rsdt_physical_address; /* physical address of RSDT */ + +} ROOT_SYSTEM_DESCRIPTOR_POINTER; + + +typedef struct /* ACPI common table header */ +{ + char signature [4]; /* identifies type of table */ + u32 length; /* length of table, in bytes, + * including header */ + u8 revision; /* specification minor version # */ + u8 checksum; /* to make sum of entire table == 0 */ + char oem_id [6]; /* OEM identification */ + char oem_table_id [8]; /* OEM table identification */ + u32 oem_revision; /* OEM revision number */ + char asl_compiler_id [4]; /* ASL compiler vendor ID */ + u32 asl_compiler_revision; /* ASL compiler revision number */ + +} ACPI_TABLE_HEADER; + + +typedef struct /* APIC Table */ +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 local_apic_address; /* Physical address for accessing local APICs */ + u32 PCATcompat : 1; /* a one indicates system also has dual 8259s */ + u32 reserved1 : 31; + +} APIC_TABLE; + + +typedef struct /* APIC Header */ +{ + u8 type; /* APIC type. Either APIC_PROC or APIC_IO */ + u8 length; /* Length of APIC structure */ + +} APIC_HEADER; + + +typedef struct /* Processor APIC */ +{ + APIC_HEADER header; + u8 processor_apic_id; /* ACPI processor id */ + u8 local_apic_id; /* processor's local APIC id */ + u32 processor_enabled: 1; /* Processor is usable if set */ + u32 reserved1 : 32; + +} PROCESSOR_APIC; + + +typedef struct /* IO APIC */ +{ + APIC_HEADER header; + u8 io_apic_id; /* I/O APIC ID */ + u8 reserved; /* reserved - must be zero */ + u32 io_apic_address; /* APIC's physical address */ + u32 vector; /* interrupt vector index where INTI + * lines start */ +} IO_APIC; + + +/* +** IA64 TODO: Add SAPIC Tables +*/ + +/* +** IA64 TODO: Modify Smart Battery Description to comply with ACPI IA64 +** extensions. +*/ +typedef struct /* Smart Battery Description Table */ +{ + ACPI_TABLE_HEADER header; + u32 warning_level; + u32 low_level; + u32 critical_level; + +} SMART_BATTERY_DESCRIPTION_TABLE; + + +/* + * ACPI Table information. We save the table address, length, + * and type of memory allocation (mapped or allocated) for each + * table for 1) when we exit, and 2) if a new table is installed + */ + +#define ACPI_MEM_NOT_ALLOCATED 0 +#define ACPI_MEM_ALLOCATED 1 +#define ACPI_MEM_MAPPED 2 + +#define ACPI_TABLE_SINGLE 0 +#define ACPI_TABLE_MULTIPLE 1 + + +/* Data about each known table type */ + +typedef struct _acpi_table_support +{ + char *name; + char *signature; + u8 sig_length; + u8 flags; + u16 status; + void **global_ptr; + +} ACPI_TABLE_SUPPORT; + + +/* + * Get the architecture-specific tables + */ + +#ifdef IA64 +#include "actbl64.h" +#else +#include "actbl32.h" +#endif + + +#endif /* __ACTABLES_H__ */ diff --git a/drivers/acpi/include/actbl32.h b/drivers/acpi/include/actbl32.h new file mode 100644 index 000000000..50e92fc30 --- /dev/null +++ b/drivers/acpi/include/actbl32.h @@ -0,0 +1,114 @@ +/****************************************************************************** + * + * Name: actbl32.h - ACPI tables specific to IA32 + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTBL32_H__ +#define __ACTBL32_H__ + + +/* IA32 Root System Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + void *table_offset_entry [1]; /* Array of pointers to other */ + /* tables' headers */ +} ROOT_SYSTEM_DESCRIPTION_TABLE; + + +/* IA32 Firmware ACPI Control Structure */ + +typedef struct +{ + char signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 firmware_waking_vector; /* ACPI OS waking vector */ + u32 global_lock; /* Global Lock */ + u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ + u32 reserved1 : 31; /* must be 0 */ + u8 resverved3 [40]; /* reserved - must be zero */ + +} FIRMWARE_ACPI_CONTROL_STRUCTURE; + + +/* IA32 Fixed ACPI Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + ACPI_TBLPTR firmware_ctrl; /* Physical address of FACS */ + ACPI_TBLPTR dsdt; /* Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 reserved1; /* reserved */ + u16 sci_int; /* System vector of SCI interrupt */ + ACPI_IO_ADDRESS smi_cmd; /* Port address of SMI command port */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ + u8 reserved2; /* reserved - must be zero */ + ACPI_IO_ADDRESS pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ + ACPI_IO_ADDRESS pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ + ACPI_IO_ADDRESS pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + ACPI_IO_ADDRESS pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + ACPI_IO_ADDRESS pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + ACPI_IO_ADDRESS pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + ACPI_IO_ADDRESS gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ + ACPI_IO_ADDRESS gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u16 flush_size; /* Size of area read to flush caches */ + u16 flush_stride; /* Stride used in flushing caches */ + u8 duty_offset; /* bit location of duty cycle field in p_cnt reg */ + u8 duty_width; /* bit width of duty cycle field in p_cnt reg */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u8 reserved4a; /* reserved */ + u8 reserved4b; /* reserved */ + u32 wb_invd : 1; /* wbinvd instruction works properly */ + u32 wb_invd_flush : 1; /* wbinvd flushes but does not invalidate */ + u32 proc_c1 : 1; /* all processors support C1 state */ + u32 plvl2_up : 1; /* C2 state works on MP system */ + u32 pwr_button : 1; /* Power button is handled as a generic feature */ + u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ + u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ + u32 reserved5 : 23; /* reserved - must be zero */ + +} FIXED_ACPI_DESCRIPTION_TABLE; + + +#endif /* __ACTBL32_H__ */ + + diff --git a/drivers/acpi/include/actbl64.h b/drivers/acpi/include/actbl64.h new file mode 100644 index 000000000..f2a331349 --- /dev/null +++ b/drivers/acpi/include/actbl64.h @@ -0,0 +1,115 @@ + +/****************************************************************************** + * + * Name: actbl64.h - ACPI tables specific to IA64 + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTBL64_H__ +#define __ACTBL64_H__ + + +typedef UINT64 IO_ADDRESS; /* Only for clarity in declarations */ + + +/* IA64 Root System Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + void *table_offset_entry [1]; /* Array of pointers to other */ + /* tables' headers */ +} ROOT_SYSTEM_DESCRIPTION_TABLE; + + +/* IA64 Firmware ACPI Control Structure */ + +typedef struct +{ + char signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 reserved4; /* must be 0 */ + UINT64 firmware_waking_vector; /* ACPI OS waking vector */ + UINT64 global_lock; /* Global Lock */ + u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ + u32 reserved1 : 31; /* must be 0 */ + u8 resverved3 [28]; /* reserved - must be zero */ + +} FIRMWARE_ACPI_CONTROL_STRUCTURE; + + +/* IA64 Fixed ACPI Description Table */ + +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + ACPI_TBLPTR firmware_ctrl; /* Physical address of FACS */ + ACPI_TBLPTR acpi_dsdt; /* Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 address_space; /* Address Space Bitmask */ + u16 sci_int; /* System vector of SCI interrupt */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ + u8 reserved2; /* reserved - must be zero */ + UINT64 smi_cmd; /* Port address of SMI command port */ + UINT64 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ + UINT64 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ + UINT64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + UINT64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + UINT64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + UINT64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT64 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ + UINT64 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 Plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 Plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ + u32 reserved5 : 1; /* reserved - must be zero */ + u32 proc_c1 : 1; /* all processors support C1 state */ + u32 Plvl2_up : 1; /* C2 state works on MP system */ + u32 pwr_button : 1; /* Power button is handled as a generic feature */ + u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ + u32 RTCS4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ + u32 dock_cap : 1; /* Supports Docking */ + u32 reserved6 : 22; /* reserved - must be zero */ + +} FIXED_ACPI_DESCRIPTION_TABLE; + + +#endif /* __ACTBL64_H__ */ + diff --git a/drivers/acpi/include/actypes.h b/drivers/acpi/include/actypes.h new file mode 100644 index 000000000..669bb3b7f --- /dev/null +++ b/drivers/acpi/include/actypes.h @@ -0,0 +1,970 @@ + +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _ACTYPES_H +#define _ACTYPES_H + +/*! [Begin] no source code translation (keep the typedefs) */ + +/* + * Data types - Fixed across all compilation models + * + * BOOLEAN Logical Boolean. 1 byte value containing a 0 for FALSE or a 1 for TRUE. Other values are undefined. + * INT8 8-bit (1 byte) signed value + * UINT8 8-bit (1 byte) unsigned value + * INT16 16-bit (2 byte) signed value + * UINT16 16-bit (2 byte) unsigned value + * INT32 32-bit (4 byte) signed value + * UINT32 32-bit (4 byte) unsigned value + * INT64 64-bit (8 byte) signed value + * UINT64 64-bit (8 byte) unsigned value + * NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value + * NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value + * UCHAR Character. 1 byte unsigned value. + */ + +#ifdef _IA64 +/* + * 64-bit type definitions + */ +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef short INT16; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef long INT64; +typedef unsigned long UINT64; + +typedef UINT64 NATIVE_UINT; +typedef INT64 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT64 ACPI_IO_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000008 + +/* (No hardware alignment support in IA64) */ + + +#elif _IA16 +/* + * 16-bit type definitions + */ +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef int INT16; +typedef unsigned int UINT16; +typedef long INT32; +typedef unsigned long UINT32; + +typedef UINT16 NATIVE_UINT; +typedef INT16 NATIVE_INT; + +typedef UINT32 ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000002 +#define _HW_ALIGNMENT_SUPPORT + + +#else +/* + * 32-bit type definitions (default) + */ +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef short INT16; +typedef unsigned short UINT16; +typedef int INT32; +typedef unsigned int UINT32; + +typedef UINT32 NATIVE_UINT; +typedef INT32 NATIVE_INT; + +typedef NATIVE_UINT ACPI_TBLPTR; +typedef UINT32 ACPI_IO_ADDRESS; + +#define ALIGNED_ADDRESS_BOUNDARY 0x00000004 +#define _HW_ALIGNMENT_SUPPORT + + +#endif + + + +/* + * Miscellaneous common types + */ + +typedef UINT8 BOOLEAN; +typedef UINT32 UINT32_BIT; +typedef NATIVE_INT ACPI_PTRDIFF; +typedef NATIVE_UINT ACPI_SIZE; + + +/* + * Data type ranges + */ + +#define ACPI_UCHAR_MAX (UCHAR) 0xFF +#define ACPI_INT32_MAX (INT32) 0x7FFFFFFF +#define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF + + +#ifdef DEFINE_ALTERNATE_TYPES +/* + * Types used only in translated source + */ +typedef INT8 s8; +typedef INT16 s16; +typedef INT32 s32; +typedef UINT8 u8; +typedef UINT16 u16; +typedef UINT32 u32; +#endif + +/*! [End] no source code translation !*/ + + +/* + * Useful defines + */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Local datatypes + */ + +typedef u32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef u32 ACPI_NAME; /* 4-char ACPI name */ +typedef char* ACPI_STRING; /* Null terminated ASCII string */ +typedef void* ACPI_HANDLE; /* Actually a ptr to an NTE */ + + +/* + * Constants with special meanings + */ + +#define ACPI_ROOT_OBJECT (ACPI_HANDLE)(-1) + + +/* + * Sleep state constants + */ +#define ACPI_STATE_S0 (u8) 0 +#define ACPI_STATE_S1 (u8) 1 +#define ACPI_STATE_S2 (u8) 2 +#define ACPI_STATE_S3 (u8) 3 +#define ACPI_STATE_S4 (u8) 4 +#define ACPI_STATE_S4_bIOS (u8) 5 +#define ACPI_STATE_S5 (u8) 6 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 + + +/* + * Table types. These values are passed to the table related APIs + */ + +typedef u32 ACPI_TABLE_TYPE; + +#define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 +#define ACPI_TABLE_APIC (ACPI_TABLE_TYPE) 1 +#define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 2 +#define ACPI_TABLE_FACP (ACPI_TABLE_TYPE) 3 +#define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 4 +#define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 5 +#define ACPI_TABLE_RSDT (ACPI_TABLE_TYPE) 6 +#define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 7 +#define ACPI_TABLE_SBST (ACPI_TABLE_TYPE) 8 +#define ACPI_TABLE_BOOT (ACPI_TABLE_TYPE) 9 +#define ACPI_TABLE_MAX 9 +#define NUM_ACPI_TABLES 10 + + +/* + * Types associated with names. The first group of + * values correspond to the definition of the ACPI Object_type operator (See the ACPI Spec). + * Therefore, only add to the first group if the spec changes! + * + * Types must be kept in sync with the Acpi_ns_properties and Acpi_ns_type_names arrays + */ + +typedef u32 ACPI_OBJECT_TYPE; +typedef u8 OBJECT_TYPE_INTERNAL; + +#define ACPI_TYPE_ANY 0 /* 0x00 */ +#define ACPI_TYPE_NUMBER 1 /* 0x01 Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 2 /* 0x02 */ +#define ACPI_TYPE_BUFFER 3 /* 0x03 */ +#define ACPI_TYPE_PACKAGE 4 /* 0x04 Byte_const, multiple Data_term/Constant/Super_name */ +#define ACPI_TYPE_FIELD_UNIT 5 /* 0x05 */ +#define ACPI_TYPE_DEVICE 6 /* 0x06 Name, multiple Named_object */ +#define ACPI_TYPE_EVENT 7 /* 0x07 */ +#define ACPI_TYPE_METHOD 8 /* 0x08 Name, Byte_const, multiple Code */ +#define ACPI_TYPE_MUTEX 9 /* 0x09 */ +#define ACPI_TYPE_REGION 10 /* 0x0A */ +#define ACPI_TYPE_POWER 11 /* 0x0B Name,Byte_const,Word_const,multi Named_object */ +#define ACPI_TYPE_PROCESSOR 12 /* 0x0C Name,Byte_const,DWord_const,Byte_const,multi Nm_o */ +#define ACPI_TYPE_THERMAL 13 /* 0x0D Name, multiple Named_object */ +#define ACPI_TYPE_BUFFER_FIELD 14 /* 0x0E */ +#define ACPI_TYPE_DDB_HANDLE 15 /* 0x0F */ +#define ACPI_TYPE_DEBUG_OBJECT 16 /* 0x10 */ + +#define ACPI_TYPE_MAX 16 + +/* + * This section contains object types that do not relate to the ACPI Object_type operator. + * They are used for various internal purposes only. A numerical gap is provided in + * case additional "official" Object_types are added in the future. Also, values exceeding + * the largest official ACPI Object_type must not overlap with defined AML opcodes. + */ +#define INTERNAL_TYPE_BEGIN 25 +#define INTERNAL_TYPE_DEF_FIELD 25 /* 0x19 */ +#define INTERNAL_TYPE_BANK_FIELD 26 /* 0x1A */ +#define INTERNAL_TYPE_INDEX_FIELD 27 /* 0x1B */ +#define INTERNAL_TYPE_DEF_FIELD_DEFN 28 /* 0x1C Name, Byte_const, multiple Field_element */ +#define INTERNAL_TYPE_BANK_FIELD_DEFN 29 /* 0x1D 2 Name,DWord_const,Byte_const,multi Field_element */ +#define INTERNAL_TYPE_INDEX_FIELD_DEFN 30 /* 0x1E 2 Name, Byte_const, multiple Field_element */ +#define INTERNAL_TYPE_IF 31 /* 0x1F Op_code, multiple Code */ +#define INTERNAL_TYPE_ELSE 32 /* 0x20 multiple Code */ +#define INTERNAL_TYPE_WHILE 33 /* 0x21 Op_code, multiple Code */ +#define INTERNAL_TYPE_SCOPE 34 /* 0x22 Name, multiple Named_object */ +#define INTERNAL_TYPE_DEF_ANY 35 /* 0x23 type is Any, suppress search of enclosing scopes */ +#define INTERNAL_TYPE_REFERENCE 36 /* 0x24 Arg#, Local#, Name, Debug; used only in descriptors */ +#define INTERNAL_TYPE_ALIAS 37 /* 0x25 */ +#define INTERNAL_TYPE_NOTIFY 38 /* 0x26 */ +#define INTERNAL_TYPE_ADDRESS_HANDLER 39 /* 0x27 */ +#define INTERNAL_TYPE_METHOD_ARGUMENT 40 /* 0x28 */ +#define INTERNAL_TYPE_METHOD_LOCAL_VAR 41 /* 0x29 */ + +#define INTERNAL_TYPE_MAX 41 + +#define INTERNAL_TYPE_INVALID 42 +#define ACPI_TYPE_NOT_FOUND 0xFF + +/* + * Acpi_event Types: + * ------------ + * Fixed & general purpose... + */ + +typedef u32 ACPI_EVENT_TYPE; + +#define ACPI_EVENT_FIXED (ACPI_EVENT_TYPE) 0 +#define ACPI_EVENT_GPE (ACPI_EVENT_TYPE) 1 + +/* + * Fixed events + */ + +#define ACPI_EVENT_PMTIMER (ACPI_EVENT_TYPE) 0 + /* + * There's no bus master event so index 1 is used for IRQ's that are not + * handled by the SCI handler + */ +#define ACPI_EVENT_NOT_USED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_GLOBAL (ACPI_EVENT_TYPE) 2 +#define ACPI_EVENT_POWER_BUTTON (ACPI_EVENT_TYPE) 3 +#define ACPI_EVENT_SLEEP_BUTTON (ACPI_EVENT_TYPE) 4 +#define ACPI_EVENT_RTC (ACPI_EVENT_TYPE) 5 +#define ACPI_EVENT_GENERAL (ACPI_EVENT_TYPE) 6 +#define ACPI_EVENT_MAX 6 +#define NUM_FIXED_EVENTS (ACPI_EVENT_TYPE) 7 + +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define NUM_GPE 256 + +#define ACPI_EVENT_LEVEL_TRIGGERED (ACPI_EVENT_TYPE) 1 +#define ACPI_EVENT_EDGE_TRIGGERED (ACPI_EVENT_TYPE) 2 + +/* + * Acpi_event Status: + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +---------------+-+-+ + * | Bits 31:2 |1|0| + * +---------------+-+-+ + * | | | + * | | +- Enabled? + * | +--- Set? + * +----------- <Reserved> + */ +typedef u32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x02 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0 +#define ACPI_DEVICE_NOTIFY 1 +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 + +#define MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef u32 ACPI_ADDRESS_SPACE_TYPE; + +#define ADDRESS_SPACE_SYSTEM_MEMORY (ACPI_ADDRESS_SPACE_TYPE) 0 +#define ADDRESS_SPACE_SYSTEM_IO (ACPI_ADDRESS_SPACE_TYPE) 1 +#define ADDRESS_SPACE_PCI_CONFIG (ACPI_ADDRESS_SPACE_TYPE) 2 +#define ADDRESS_SPACE_EC (ACPI_ADDRESS_SPACE_TYPE) 3 +#define ADDRESS_SPACE_SMBUS (ACPI_ADDRESS_SPACE_TYPE) 4 + + +/* + * External ACPI object definition + */ + +typedef union acpi_obj +{ + ACPI_OBJECT_TYPE type; /* See definition of Acpi_ns_type for values */ + struct + { + ACPI_OBJECT_TYPE type; + u32 value; /* The actual number */ + } number; + + struct + { + ACPI_OBJECT_TYPE type; + u32 length; /* # of bytes in string, excluding trailing null */ + char *pointer; /* points to the string value */ + } string; + + struct + { + ACPI_OBJECT_TYPE type; + u32 length; /* # of bytes in buffer */ + u8 *pointer; /* points to the buffer */ + } buffer; + + struct + { + ACPI_OBJECT_TYPE type; + u32 fill1; + ACPI_HANDLE handle; /* object reference */ + } reference; + + struct + { + ACPI_OBJECT_TYPE type; + u32 count; /* # of elements in package */ + union acpi_obj *elements; /* Pointer to an array of ACPI_OBJECTs */ + } package; + + struct + { + ACPI_OBJECT_TYPE type; + u32 proc_id; + u32 pblk_address; + u32 pblk_length; + } processor; + + struct + { + ACPI_OBJECT_TYPE type; + u32 system_level; + u32 resource_order; + } power_resource; + +} ACPI_OBJECT, *PACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ + +typedef struct acpi_obj_list +{ + u32 count; + ACPI_OBJECT *pointer; + +} ACPI_OBJECT_LIST, *PACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ + +typedef struct +{ + u32 length; /* Length in bytes of the buffer */ + void *pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * Name_type for Acpi_get_name + */ + +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Structure and flags for Acpi_get_system_info + */ + +#define SYS_MODE_UNKNOWN 0x0000 +#define SYS_MODE_ACPI 0x0001 +#define SYS_MODE_LEGACY 0x0002 +#define SYS_MODES_MASK 0x0003 + +/* + * ACPI CPU Cx state handler + */ +typedef +ACPI_STATUS (*ACPI_SET_C_STATE_HANDLER) ( + NATIVE_UINT pblk_address); + +/* + * ACPI Cx State info + */ +typedef struct +{ + u32 state_number; + u32 latency; +} ACPI_CX_STATE; + +/* + * ACPI CPU throttling info + */ +typedef struct +{ + u32 state_number; + u32 percent_of_clock; +} ACPI_CPU_THROTTLING_STATE; + +/* + * ACPI Table Info. One per ACPI table _type_ + */ +typedef struct acpi_table_info +{ + u32 count; + +} ACPI_TABLE_INFO; + + +/* + * System info returned by Acpi_get_system_info() + */ + +typedef struct _acpi_sys_info +{ + u32 acpi_ca_version; + u32 flags; + u32 timer_resolution; + u32 reserved1; + u32 reserved2; + u32 debug_level; + u32 debug_layer; + u32 num_table_types; + ACPI_TABLE_INFO table_info [NUM_ACPI_TABLES]; + +} ACPI_SYSTEM_INFO; + + +/* + * System Initiailization data. This data is passed to ACPIInitialize + * copyied to global data and retained by ACPI CA + */ + +typedef struct _acpi_init_data +{ + void *RSDP_physical_address; /* Address of RSDP, needed it it is */ + /* not found in the IA32 manner */ +} ACPI_INIT_DATA; + +/* + * Various handlers and callback procedures + */ + +typedef +u32 (*FIXED_EVENT_HANDLER) ( + void *context); + +typedef +void (*GPE_HANDLER) ( + void *context); + +typedef +void (*NOTIFY_HANDLER) ( + ACPI_HANDLE device, + u32 value, + void *context); + +#define ADDRESS_SPACE_READ 1 +#define ADDRESS_SPACE_WRITE 2 + +typedef +ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + +#define ACPI_DEFAULT_HANDLER ((ADDRESS_SPACE_HANDLER) NULL) + + +typedef +ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( + ACPI_HANDLE region_handle, + u32 function, + void *handler_context, + void **return_context); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*WALK_CALLBACK) ( + ACPI_HANDLE obj_handle, + u32 nesting_level, + void *context, + void **return_value); + + +/* Interrupt handler return values */ + +#define INTERRUPT_NOT_HANDLED 0x00 +#define INTERRUPT_HANDLED 0x01 + + +/* Structure and flags for Acpi_get_device_info */ + +#define ACPI_VALID_HID 0x1 +#define ACPI_VALID_UID 0x2 +#define ACPI_VALID_ADR 0x4 +#define ACPI_VALID_STA 0x8 + + +#define ACPI_COMMON_OBJ_INFO \ + ACPI_OBJECT_TYPE type; /* ACPI object type */\ + ACPI_NAME name; /* ACPI object Name */\ + /*\ + * TBD: [Restructure] Do we want or need these next two??\ + */\ + ACPI_HANDLE parent; /* Parent object */\ + ACPI_HANDLE children; /* Linked list of children */\ + u32 valid /* ????? */ + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; +} ACPI_OBJ_INFO_HEADER; + + +typedef struct +{ + ACPI_COMMON_OBJ_INFO; + + /* + * TBD: [Restructure]: a HID or a _UID can return either a number or a string + */ + char hardware_id [9]; /* _HID value if any */ + char unique_id[9]; /* _UID value if any */ + u32 address; /* _ADR value if any */ + u32 current_status; /* _STA value */ +} ACPI_DEVICE_INFO; + + +/* Context structs for address space handlers */ + +typedef struct +{ + void *handler_context; + u32 seg; + u32 bus; + u32 dev_func; +} PCI_HANDLER_CONTEXT; + + +typedef struct +{ + void *handler_context; + char *mapped_physical_address; + char *mapped_logical_address; + u32 mapped_length; + +} MEM_HANDLER_CONTEXT; + + +/* + * C-state handler + */ + +typedef ACPI_STATUS (*ACPI_C_STATE_HANDLER) (ACPI_IO_ADDRESS, u32*); + + +/* + * Definitions for Resource Attributes + */ + +/* + * Memory Attributes + */ +#define READ_ONLY_MEMORY (u8) 0x00 +#define READ_WRITE_MEMORY (u8) 0x01 + +#define NON_CACHEABLE_MEMORY (u8) 0x00 +#define CACHABLE_MEMORY (u8) 0x01 +#define WRITE_COMBINING_MEMORY (u8) 0x02 +#define PREFETCHABLE_MEMORY (u8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4_fFh, n800-n8_fFh, n_c00-n_cFFh. + * The non-ISA IO ranges are: n100-n3_fFh, n500-n7_fFh, n900-n_bFFh, n_cD0-n_fFFh. + */ +#define NON_ISA_ONLY_RANGES (u8) 0x01 +#define ISA_ONLY_RANGES (u8) 0x02 +#define ENTIRE_RANGE (NON_ISA_ONLY_RANGES | ISA_ONLY_RANGES) + +/* + * IO Port Descriptor Decode + */ +#define DECODE_10 (u8) 0x00 /* 10-bit IO address decode */ +#define DECODE_16 (u8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define EDGE_SENSITIVE (u8) 0x00 +#define LEVEL_SENSITIVE (u8) 0x01 + +#define ACTIVE_HIGH (u8) 0x00 +#define ACTIVE_LOW (u8) 0x01 + +#define EXCLUSIVE (u8) 0x00 +#define SHARED (u8) 0x01 + +/* + * DMA Attributes + */ +#define COMPATIBILITY (u8) 0x00 +#define TYPE_A (u8) 0x01 +#define TYPE_B (u8) 0x02 +#define TYPE_F (u8) 0x03 + +#define NOT_BUS_MASTER (u8) 0x00 +#define BUS_MASTER (u8) 0x01 + +#define TRANSFER_8 (u8) 0x00 +#define TRANSFER_8_16 (u8) 0x01 +#define TRANSFER_16 (u8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define GOOD_CONFIGURATION (u8) 0x00 +#define ACCEPTABLE_CONFIGURATION (u8) 0x01 +#define SUB_OPTIMAL_CONFIGURATION (u8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define MEMORY_RANGE (u8) 0x00 +#define IO_RANGE (u8) 0x01 +#define BUS_NUMBER_RANGE (u8) 0x02 + +#define ADDRESS_NOT_FIXED (u8) 0x00 +#define ADDRESS_FIXED (u8) 0x01 + +#define POS_DECODE (u8) 0x00 +#define SUB_DECODE (u8) 0x01 + +#define PRODUCER (u8) 0x00 +#define CONSUMER (u8) 0x01 + + +/* + * Structures used to describe device resources + */ +typedef struct +{ + u32 edge_level; + u32 active_high_low; + u32 shared_exclusive; + u32 number_of_interrupts; + u32 interrupts[1]; + +} IRQ_RESOURCE; + +typedef struct +{ + u32 type; + u32 bus_master; + u32 transfer; + u32 number_of_channels; + u32 channels[1]; + +} DMA_RESOURCE; + +typedef struct +{ + u32 compatibility_priority; + u32 performance_robustness; + +} START_DEPENDENT_FUNCTIONS_RESOURCE; + +/* + * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + +typedef struct +{ + u32 io_decode; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; + +} IO_RESOURCE; + +typedef struct +{ + u32 base_address; + u32 range_length; + +} FIXED_IO_RESOURCE; + +typedef struct +{ + u32 length; + u8 reserved[1]; + +} VENDOR_RESOURCE; + +typedef struct +{ + u32 read_write_attribute; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; + +} MEMORY24_RESOURCE; + +typedef struct +{ + u32 read_write_attribute; + u32 min_base_address; + u32 max_base_address; + u32 alignment; + u32 range_length; + +} MEMORY32_RESOURCE; + +typedef struct +{ + u32 read_write_attribute; + u32 range_base_address; + u32 range_length; + +} FIXED_MEMORY32_RESOURCE; + +typedef struct +{ + u16 cache_attribute; + u16 read_write_attribute; + +} MEMORY_ATTRIBUTE; + +typedef struct +{ + u16 range_attribute; + u16 reserved; + +} IO_ATTRIBUTE; + +typedef struct +{ + u16 reserved1; + u16 reserved2; + +} BUS_ATTRIBUTE; + +typedef union +{ + MEMORY_ATTRIBUTE memory; + IO_ATTRIBUTE io; + BUS_ATTRIBUTE bus; + +} ATTRIBUTE_DATA; + +typedef struct +{ + u32 resource_type; + u32 producer_consumer; + u32 decode; + u32 min_address_fixed; + u32 max_address_fixed; + ATTRIBUTE_DATA attribute; + u32 granularity; + u32 min_address_range; + u32 max_address_range; + u32 address_translation_offset; + u32 address_length; + u32 resource_source_index; + u32 resource_source_string_length; + u8 resource_source[1]; + +} ADDRESS16_RESOURCE; + +typedef struct +{ + u32 resource_type; + u32 producer_consumer; + u32 decode; + u32 min_address_fixed; + u32 max_address_fixed; + ATTRIBUTE_DATA attribute; + u32 granularity; + u32 min_address_range; + u32 max_address_range; + u32 address_translation_offset; + u32 address_length; + u32 resource_source_index; + u32 resource_source_string_length; + u8 resource_source[1]; + +} ADDRESS32_RESOURCE; + +typedef struct +{ + u32 producer_consumer; + u32 edge_level; + u32 active_high_low; + u32 shared_exclusive; + u32 number_of_interrupts; + u32 interrupts[1]; + u32 resource_source_index; + u32 resource_source_string_length; + u8 resource_source[1]; + +} EXTENDED_IRQ_RESOURCE; + +typedef enum +{ + irq, + dma, + start_dependent_functions, + end_dependent_functions, + io, + fixed_io, + vendor_specific, + end_tag, + memory24, + memory32, + fixed_memory32, + address16, + address32, + extended_irq +} RESOURCE_TYPE; + +typedef union +{ + IRQ_RESOURCE irq; + DMA_RESOURCE dma; + START_DEPENDENT_FUNCTIONS_RESOURCE start_dependent_functions; + IO_RESOURCE io; + FIXED_IO_RESOURCE fixed_io; + VENDOR_RESOURCE vendor_specific; + MEMORY24_RESOURCE memory24; + MEMORY32_RESOURCE memory32; + FIXED_MEMORY32_RESOURCE fixed_memory32; + ADDRESS16_RESOURCE address16; + ADDRESS32_RESOURCE address32; + EXTENDED_IRQ_RESOURCE extended_irq; +} RESOURCE_DATA; + +typedef struct _resource_tag +{ + RESOURCE_TYPE id; + u32 length; + RESOURCE_DATA data; +} RESOURCE; + +#define RESOURCE_LENGTH 12 +#define RESOURCE_LENGTH_NO_DATA 8 + +/* + * END: Definitions for Resource Attributes + */ + +/* + * Definitions for PCI Routing tables + */ +typedef struct +{ + u32 address; + u32 pin; + u32 source_index; + u8 source[1]; + +} PRT_ENTRY; + +typedef struct _prt_tag +{ + u32 length; + PRT_ENTRY data; + +} PCI_ROUTING_TABLE; + + +/* + * END: Definitions for PCI Routing tables + */ + +#endif /* ACTYPES_H */ diff --git a/drivers/acpi/include/amlcode.h b/drivers/acpi/include/amlcode.h new file mode 100644 index 000000000..464e0cd6b --- /dev/null +++ b/drivers/acpi/include/amlcode.h @@ -0,0 +1,452 @@ + +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + + +/* primary opcodes */ + +#define AML_NULL_CHAR (u16) 0x00 + +#define AML_ZERO_OP (u16) 0x00 +#define AML_ONE_OP (u16) 0x01 +#define AML_UNASSIGNED (u16) 0x02 +#define AML_ALIAS_OP (u16) 0x06 +#define AML_NAME_OP (u16) 0x08 +#define AML_BYTE_OP (u16) 0x0a +#define AML_WORD_OP (u16) 0x0b +#define AML_DWORD_OP (u16) 0x0c +#define AML_STRING_OP (u16) 0x0d +#define AML_SCOPE_OP (u16) 0x10 +#define AML_BUFFER_OP (u16) 0x11 +#define AML_PACKAGE_OP (u16) 0x12 +#define AML_METHOD_OP (u16) 0x14 +#define AML_DUAL_NAME_PREFIX (u16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (u16) 0x30 +#define AML_NAME_CHAR_FIRST (u16) 0x41 +#define AML_OP_PREFIX (u16) 0x5b +#define AML_ROOT_PREFIX (u16) 0x5c +#define AML_PARENT_PREFIX (u16) 0x5e +#define AML_LOCAL_OP (u16) 0x60 +#define AML_LOCAL0 (u16) 0x60 +#define AML_LOCAL1 (u16) 0x61 +#define AML_LOCAL2 (u16) 0x62 +#define AML_LOCAL3 (u16) 0x63 +#define AML_LOCAL4 (u16) 0x64 +#define AML_LOCAL5 (u16) 0x65 +#define AML_LOCAL6 (u16) 0x66 +#define AML_LOCAL7 (u16) 0x67 +#define AML_ARG_OP (u16) 0x68 +#define AML_ARG0 (u16) 0x68 +#define AML_ARG1 (u16) 0x69 +#define AML_ARG2 (u16) 0x6a +#define AML_ARG3 (u16) 0x6b +#define AML_ARG4 (u16) 0x6c +#define AML_ARG5 (u16) 0x6d +#define AML_ARG6 (u16) 0x6e +#define AML_STORE_OP (u16) 0x70 +#define AML_REF_OF_OP (u16) 0x71 +#define AML_ADD_OP (u16) 0x72 +#define AML_CONCAT_OP (u16) 0x73 +#define AML_SUBTRACT_OP (u16) 0x74 +#define AML_INCREMENT_OP (u16) 0x75 +#define AML_DECREMENT_OP (u16) 0x76 +#define AML_MULTIPLY_OP (u16) 0x77 +#define AML_DIVIDE_OP (u16) 0x78 +#define AML_SHIFT_LEFT_OP (u16) 0x79 +#define AML_SHIFT_RIGHT_OP (u16) 0x7a +#define AML_BIT_AND_OP (u16) 0x7b +#define AML_BIT_NAND_OP (u16) 0x7c +#define AML_BIT_OR_OP (u16) 0x7d +#define AML_BIT_NOR_OP (u16) 0x7e +#define AML_BIT_XOR_OP (u16) 0x7f +#define AML_BIT_NOT_OP (u16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82 +#define AML_DEREF_OF_OP (u16) 0x83 +#define AML_NOTIFY_OP (u16) 0x86 +#define AML_SIZE_OF_OP (u16) 0x87 +#define AML_INDEX_OP (u16) 0x88 +#define AML_MATCH_OP (u16) 0x89 +#define AML_DWORD_FIELD_OP (u16) 0x8a +#define AML_WORD_FIELD_OP (u16) 0x8b +#define AML_BYTE_FIELD_OP (u16) 0x8c +#define AML_BIT_FIELD_OP (u16) 0x8d +#define AML_TYPE_OP (u16) 0x8e +#define AML_LAND_OP (u16) 0x90 +#define AML_LOR_OP (u16) 0x91 +#define AML_LNOT_OP (u16) 0x92 +#define AML_LEQUAL_OP (u16) 0x93 +#define AML_LGREATER_OP (u16) 0x94 +#define AML_LLESS_OP (u16) 0x95 +#define AML_IF_OP (u16) 0xa0 +#define AML_ELSE_OP (u16) 0xa1 +#define AML_WHILE_OP (u16) 0xa2 +#define AML_NOOP_CODE (u16) 0xa3 +#define AML_RETURN_OP (u16) 0xa4 +#define AML_BREAK_OP (u16) 0xa5 +#define AML_BREAK_POINT_OP (u16) 0xcc +#define AML_ONES_OP (u16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTOP (u16) 0x005b + + +#define AML_MUTEX_OP (u16) 0x5b01 +#define AML_EVENT_OP (u16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11 +#define AML_COND_REF_OF_OP (u16) 0x5b12 +#define AML_CREATE_FIELD_OP (u16) 0x5b13 +#define AML_LOAD_OP (u16) 0x5b20 +#define AML_STALL_OP (u16) 0x5b21 +#define AML_SLEEP_OP (u16) 0x5b22 +#define AML_ACQUIRE_OP (u16) 0x5b23 +#define AML_SIGNAL_OP (u16) 0x5b24 +#define AML_WAIT_OP (u16) 0x5b25 +#define AML_RESET_OP (u16) 0x5b26 +#define AML_RELEASE_OP (u16) 0x5b27 +#define AML_FROM_BCDOP (u16) 0x5b28 +#define AML_TO_BCDOP (u16) 0x5b29 +#define AML_UN_LOAD_OP (u16) 0x5b2a +#define AML_REVISION_OP (u16) 0x5b30 +#define AML_DEBUG_OP (u16) 0x5b31 +#define AML_FATAL_OP (u16) 0x5b32 +#define AML_REGION_OP (u16) 0x5b80 +#define AML_DEF_FIELD_OP (u16) 0x5b81 +#define AML_DEVICE_OP (u16) 0x5b82 +#define AML_PROCESSOR_OP (u16) 0x5b83 +#define AML_POWER_RES_OP (u16) 0x5b84 +#define AML_THERMAL_ZONE_OP (u16) 0x5b85 +#define AML_INDEX_FIELD_OP (u16) 0x5b86 +#define AML_BANK_FIELD_OP (u16) 0x5b87 + + +/* Bogus opcodes (they are actually two separate opcodes) */ + +#define AML_LGREATEREQUAL_OP (u16) 0x9295 +#define AML_LLESSEQUAL_OP (u16) 0x9294 +#define AML_LNOTEQUAL_OP (u16) 0x9293 + + +/* Internal opcodes */ + +#define AML_NAMEPATH_OP (u16) 0x002d +#define AML_NAMEDFIELD_OP (u16) 0x0030 +#define AML_RESERVEDFIELD_OP (u16) 0x0031 +#define AML_ACCESSFIELD_OP (u16) 0x0032 +#define AML_BYTELIST_OP (u16) 0x0033 +#define AML_STATICSTRING_OP (u16) 0x0034 +#define AML_METHODCALL_OP (u16) 0x0035 + + +/* + * argument types + */ + +/* +#define AML_ASCIICHARLIST_ARG 'A' +#define AML_BYTEDATA_ARG 'b' +#define AML_BYTELIST_ARG 'B' +#define AML_DWORDDATA_ARG 'd' +#define AML_DATAOBJECT_ARG 'o' +#define AML_DATAOBJECTLIST_ARG 'O' +#define AML_FIELDLIST_ARG 'F' +#define AML_NAMESTRING_ARG 'n' +#define AML_OBJECTLIST_ARG 'P' +#define AML_PKGLENGTH_ARG 'p' +#define AML_SUPERNAME_ARG 's' +#define AML_TARGET_ARG 'l' +#define AML_TERMARG_ARG 't' +#define AML_TERMLIST_ARG 'T' +#define AML_WORDDATA_ARG 'w' +*/ + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the Arg_types u32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + */ + +#define ARGI_ANYTYPE 0x01 +#define ARGI_TARGETREF 0x02 +#define ARGI_REFERENCE 0x03 +#define ARGI_IF 0x04 +#define ARGI_NUMBER 0x05 +#define ARGI_STRING 0x06 +#define ARGI_BUFFER 0x07 +#define ARGI_PACKAGE 0x08 +#define ARGI_DATAOBJECT 0x09 /* Buffer, string, package or NTE reference - Used only by Size_of operator*/ +#define ARGI_COMPLEXOBJ 0x0A /* Buffer or package */ +#define ARGI_MUTEX 0x0B +#define ARGI_EVENT 0x0C +#define ARGI_REGION 0x0D +#define ARGI_DDBHANDLE 0x0E + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ + +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + +#define OPTYPE_UNDEFINED 0 + + +#define OPTYPE_LITERAL 1 +#define OPTYPE_CONSTANT 2 +#define OPTYPE_METHOD_ARGUMENT 3 +#define OPTYPE_LOCAL_VARIABLE 4 +#define OPTYPE_DATA_TERM 5 + +/* Type 1 opcodes */ + +#define OPTYPE_MONADIC1 6 +#define OPTYPE_DYADIC1 7 + + +/* Type 2 opcodes */ + +#define OPTYPE_MONADIC2 8 +#define OPTYPE_MONADIC2_r 9 +#define OPTYPE_DYADIC2 10 +#define OPTYPE_DYADIC2_r 11 +#define OPTYPE_DYADIC2_s 12 +#define OPTYPE_INDEX 13 +#define OPTYPE_MATCH 14 + +/* Generic for an op that returns a value */ + +#define OPTYPE_METHOD_CALL 15 + + +/* Misc */ + +#define OPTYPE_CREATE_FIELD 16 +#define OPTYPE_FATAL 17 +#define OPTYPE_CONTROL 18 +#define OPTYPE_RECONFIGURATION 19 +#define OPTYPE_NAMED_OBJECT 20 + +#define OPTYPE_BOGUS 21 + + +/* Comparison operation codes for Match_op operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* Field Access Types */ + +#define ACCESS_TYPE_MASK 0x0f +#define ACCESS_TYPE_SHIFT 0 + +typedef enum +{ + ACCESS_ANY_ACC = 0, + ACCESS_BYTE_ACC = 1, + ACCESS_WORD_ACC = 2, + ACCESS_DWORD_ACC = 3, + ACCESS_BLOCK_ACC = 4, + ACCESS_SMBSEND_RECV_ACC = 5, + ACCESS_SMBQUICK_ACC = 6 + +} AML_ACCESS_TYPE; + + +/* Field Lock Rules */ + +#define LOCK_RULE_MASK 0x10 +#define LOCK_RULE_SHIFT 4 + +typedef enum +{ + GLOCK_NEVER_LOCK = 0, + GLOCK_ALWAYS_LOCK = 1 + +} AML_LOCK_RULE; + + +/* Field Update Rules */ + +#define UPDATE_RULE_MASK 0x060 +#define UPDATE_RULE_SHIFT 5 + +typedef enum +{ + UPDATE_PRESERVE = 0, + UPDATE_WRITE_AS_ONES = 1, + UPDATE_WRITE_AS_ZEROS = 2 + +} AML_UPDATE_RULE; + + +/* bit fields in Method_flags byte */ + +#define METHOD_FLAGS_ARG_COUNT 0x07 +#define METHOD_FLAGS_SERIALIZED 0x08 + + +/* Array sizes. Used for range checking also */ + +#define NUM_REGION_TYPES 5 +#define NUM_ACCESS_TYPES 7 +#define NUM_UPDATE_RULES 3 +#define NUM_MATCH_OPS 7 +#define NUM_OPCODES 256 +#define NUM_FIELD_NAMES 2 + +/* External declarations of the AML tables */ + +extern u8 acpi_gbl_aml [NUM_OPCODES]; +extern u16 acpi_gbl_pfx [NUM_OPCODES]; +extern char *acpi_gbl_short_ops [NUM_OPCODES]; +extern char *acpi_gbl_long_ops [NUM_OPCODES]; +extern char *acpi_gbl_region_types [NUM_REGION_TYPES]; +extern char *acpi_gbl_match_ops [NUM_MATCH_OPS]; +extern char *acpi_gbl_access_types [NUM_ACCESS_TYPES]; +extern char *acpi_gbl_update_rules [NUM_UPDATE_RULES]; +extern char *acpi_gbl_FEnames [NUM_FIELD_NAMES]; + + +/* + * AML tables + */ + +#ifdef DEFINE_AML_GLOBALS + +/* Data used in keeping track of fields */ + +char *acpi_gbl_FEnames[NUM_FIELD_NAMES] = +{ + "skip", + "?access?" +}; /* FE = Field Element */ + + +/* Region type decoding */ + +char *acpi_gbl_region_types[NUM_REGION_TYPES] = +{ + "System_memory", + "System_iO", + "PCIConfig", + "Embedded_control", + "SMBus" +}; + + +char *acpi_gbl_match_ops[NUM_MATCH_OPS] = +{ + "Error", + "MTR", + "MEQ", + "MLE", + "MLT", + "MGE", + "MGT" +}; + + +/* Access type decoding */ + +char *acpi_gbl_access_types[NUM_ACCESS_TYPES] = +{ + "Any_acc", + "Byte_acc", + "Word_acc", + "DWord_acc", + "Block_acc", + "SMBSend_recv_acc", + "SMBQuick_acc" +}; + + +/* Update rule decoding */ + +char *acpi_gbl_update_rules[NUM_UPDATE_RULES] = +{ + "Preserve", + "Write_as_ones", + "Write_as_zeros" +}; + + +#endif /* DEFINE_AML_GLOBALS */ + +#endif /* __AMLCODE_H__ */ diff --git a/drivers/acpi/include/common.h b/drivers/acpi/include/common.h new file mode 100644 index 000000000..f35ba795d --- /dev/null +++ b/drivers/acpi/include/common.h @@ -0,0 +1,650 @@ + +/****************************************************************************** + * + * Name: common.h -- prototypes for the common (subsystem-wide) procedures + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _COMMON_H +#define _COMMON_H + + +#define REF_INCREMENT (u16) 0 +#define REF_DECREMENT (u16) 1 +#define REF_FORCE_DELETE (u16) 2 + +/* Acpi_cm_dump_buffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* Global initialization interfaces */ + +void +acpi_cm_init_globals ( + ACPI_INIT_DATA *init_data); + +void +acpi_cm_terminate ( + void); + + +/* + * Acpi_cm_init - miscellaneous initialization and shutdown + */ + +ACPI_STATUS +acpi_cm_hardware_initialize ( + void); + +ACPI_STATUS +acpi_cm_subsystem_shutdown ( + void); + +/* + * Acpi_cm_global - Global data structures and procedures + */ + +char * +acpi_cm_get_mutex_name ( + u32 mutex_id); + +char * +acpi_cm_get_type_name ( + u32 type); + +u8 +acpi_cm_valid_object_type ( + u32 type); + +ACPI_OWNER_ID +acpi_cm_allocate_owner_id ( + u32 id_type); + + +/* + * Acpi_cm_clib - Local implementations of C library functions + */ + +ACPI_SIZE +acpi_cm_strlen ( + const char *string); + +char * +acpi_cm_strcpy ( + char *dst_string, + const char *src_string); + +char * +acpi_cm_strncpy ( + char *dst_string, + const char *src_string, + ACPI_SIZE count); + +u32 +acpi_cm_strncmp ( + const char *string1, + const char *string2, + ACPI_SIZE count); + +u32 +acpi_cm_strcmp ( + const char *string1, + const char *string2); + +char * +acpi_cm_strcat ( + char *dst_string, + const char *src_string); + +char * +acpi_cm_strncat ( + char *dst_string, + const char *src_string, + ACPI_SIZE count); + +u32 +acpi_cm_strtoul ( + const char *string, + char **terminator, + s32 base); + +char * +acpi_cm_strstr ( + char *string1, + char *string2); + +char * +acpi_cm_strupr ( + char *src_string); + +void * +acpi_cm_memcpy ( + void *dest, + const void *src, + ACPI_SIZE count); + +void * +acpi_cm_memset ( + void *dest, + s32 value, + ACPI_SIZE count); + +s32 +acpi_cm_to_upper ( + s32 c); + +s32 +acpi_cm_to_lower ( + s32 c); + + +/* + * Acpi_cm_copy - Object construction and conversion interfaces + */ + +ACPI_STATUS +acpi_cm_build_simple_object( + ACPI_OBJECT_INTERNAL *obj, + ACPI_OBJECT *user_obj, + char *data_space, + u32 *buffer_space_used); + +ACPI_STATUS +acpi_cm_build_package_object ( + ACPI_OBJECT_INTERNAL *obj, + char *buffer, + u32 *space_used); + +ACPI_STATUS +acpi_cm_build_external_object ( + ACPI_OBJECT_INTERNAL *obj, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_cm_build_internal_simple_object( + ACPI_OBJECT *user_obj, + ACPI_OBJECT_INTERNAL *obj); + +ACPI_STATUS +acpi_cm_build_internal_object ( + ACPI_OBJECT *obj, + ACPI_OBJECT_INTERNAL *internal_obj); + +ACPI_STATUS +acpi_cm_copy_internal_simple_object ( + ACPI_OBJECT_INTERNAL *source_obj, + ACPI_OBJECT_INTERNAL *dest_obj); + +ACPI_STATUS +acpi_cm_build_copy_internal_package_object ( + ACPI_OBJECT_INTERNAL *source_obj, + ACPI_OBJECT_INTERNAL *dest_obj); + + +/* + * Acpi_cm_create - Object creation + */ + +ACPI_STATUS +acpi_cm_update_object_reference ( + ACPI_OBJECT_INTERNAL *object, + u16 action); + +ACPI_OBJECT_INTERNAL * +_cm_create_internal_object ( + char *module_name, + s32 line_number, + s32 component_id, + OBJECT_TYPE_INTERNAL type); + + +/* + * Acpi_cm_debug - Debug interfaces + */ + +s32 +get_debug_level ( + void); + +void +set_debug_level ( + s32 level); + +void +function_trace ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name); + +void +function_trace_ptr ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + void *pointer); + +void +function_trace_u32 ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + u32 integer); + +void +function_trace_str ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + char *string); + +void +function_exit ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name); + +void +function_status_exit ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + ACPI_STATUS status); + +void +function_value_exit ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + NATIVE_UINT value); + +void +function_ptr_exit ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING function_name, + char *ptr); + +void +debug_print_prefix ( + ACPI_STRING module_name, + s32 line_number); + +void +debug_print ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + s32 print_level, + char *format, ...); + +void +debug_print_raw ( + char *format, ...); + +void +_report_info ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING message); + +void +_report_error ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING message); + +void +_report_warning ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING message); + +void +_report_success ( + ACPI_STRING module_name, + s32 line_number, + s32 component_id, + ACPI_STRING message); + +void +acpi_cm_dump_buffer ( + char *buffer, + u32 count, + u32 display, + s32 component_id); + + +/* + * Acpi_cm_delete - Object deletion + */ + +void +acpi_cm_delete_internal_obj ( + ACPI_OBJECT_INTERNAL *object); + +void +acpi_cm_delete_internal_package_object ( + ACPI_OBJECT_INTERNAL *object); + +void +acpi_cm_delete_internal_simple_object ( + ACPI_OBJECT_INTERNAL *object); + +ACPI_STATUS +acpi_cm_delete_internal_object_list ( + ACPI_OBJECT_INTERNAL **obj_list); + + +/* + * Acpi_cm_eval - object evaluation + */ + +/* Method name strings */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" + + +ACPI_STATUS +acpi_cm_evaluate_numeric_object ( + char *method_name, + ACPI_NAMED_OBJECT *acpi_device, + u32 *address); + +ACPI_STATUS +acpi_cm_execute_HID ( + ACPI_NAMED_OBJECT *acpi_device, + DEVICE_ID *hid); + +ACPI_STATUS +acpi_cm_execute_STA ( + ACPI_NAMED_OBJECT *acpi_device, + u32 *status_flags); + +ACPI_STATUS +acpi_cm_execute_UID ( + ACPI_NAMED_OBJECT *acpi_device, + DEVICE_ID *uid); + + +/* + * Acpi_cm_error - exception interfaces + */ + +char * +acpi_cm_format_exception ( + ACPI_STATUS status); + + +/* + * Acpi_cm_mutex - mutual exclusion interfaces + */ + +ACPI_STATUS +acpi_cm_mutex_initialize ( + void); + +void +acpi_cm_mutex_terminate ( + void); + +ACPI_STATUS +acpi_cm_create_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_delete_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_acquire_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + +ACPI_STATUS +acpi_cm_release_mutex ( + ACPI_MUTEX_HANDLE mutex_id); + + +/* + * Acpi_cm_object - internal object create/delete/cache routines + */ + +#define acpi_cm_create_internal_object(t) _cm_create_internal_object(_THIS_MODULE,__LINE__,_COMPONENT,t) +#define acpi_cm_allocate_object_desc() _cm_allocate_object_desc(_THIS_MODULE,__LINE__,_COMPONENT) + +void * +_cm_allocate_object_desc ( + char *module_name, + s32 line_number, + s32 component_id); + +void +acpi_cm_delete_object_desc ( + ACPI_OBJECT_INTERNAL *object); + +u8 +acpi_cm_valid_internal_object ( + void *object); + + +/* + * Acpi_cm_ref_cnt - Object reference count management + */ + +void +acpi_cm_add_reference ( + ACPI_OBJECT_INTERNAL *object); + +void +acpi_cm_remove_reference ( + ACPI_OBJECT_INTERNAL *object); + +/* + * Acpi_cm_size - Object size routines + */ + +ACPI_STATUS +acpi_cm_get_simple_object_size ( + ACPI_OBJECT_INTERNAL *obj, + u32 *obj_length); + +ACPI_STATUS +acpi_cm_get_package_object_size ( + ACPI_OBJECT_INTERNAL *obj, + u32 *obj_length); + +ACPI_STATUS +acpi_cm_get_object_size( + ACPI_OBJECT_INTERNAL *obj, + u32 *obj_length); + + +/* + * Acpi_cm_state - Generic state creation/cache routines + */ + +void +acpi_cm_push_generic_state ( + ACPI_GENERIC_STATE **list_head, + ACPI_GENERIC_STATE *state); + +ACPI_GENERIC_STATE * +acpi_cm_pop_generic_state ( + ACPI_GENERIC_STATE **list_head); + + +ACPI_GENERIC_STATE * +acpi_cm_create_generic_state ( + void); + +ACPI_GENERIC_STATE * +acpi_cm_create_update_state ( + ACPI_OBJECT_INTERNAL *object, + u16 action); + +ACPI_STATUS +acpi_cm_create_update_state_and_push ( + ACPI_OBJECT_INTERNAL *object, + u16 action, + ACPI_GENERIC_STATE **state_list); + +ACPI_GENERIC_STATE * +acpi_cm_create_control_state ( + void); + +void +acpi_cm_delete_generic_state ( + ACPI_GENERIC_STATE *state); + +void +acpi_cm_delete_generic_state_cache ( + void); + +void +acpi_cm_delete_object_cache ( + void); + +/* + * Acpi_cmutils + */ + +u8 +acpi_cm_valid_acpi_name ( + u32 name); + +u8 +acpi_cm_valid_acpi_character ( + char character); + + +/* + * Memory allocation functions and related macros. + * Macros that expand to include filename and line number + */ + +void * +_cm_allocate ( + u32 size, + u32 component, + ACPI_STRING module, + s32 line); + +void * +_cm_callocate ( + u32 size, + u32 component, + ACPI_STRING module, + s32 line); + +void +_cm_free ( + void *address, + u32 component, + ACPI_STRING module, + s32 line); + +void +acpi_cm_init_static_object ( + ACPI_OBJECT_INTERNAL *obj_desc); + +#define acpi_cm_allocate(a) _cm_allocate(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define acpi_cm_callocate(a) _cm_callocate(a, _COMPONENT,_THIS_MODULE,__LINE__) +#define acpi_cm_free(a) _cm_free(a,_COMPONENT,_THIS_MODULE,__LINE__) + +#ifndef ACPI_DEBUG + +#define acpi_cm_add_element_to_alloc_list(a,b,c,d,e,f) +#define acpi_cm_delete_element_from_alloc_list(a,b,c,d) +#define acpi_cm_dump_current_allocations(a,b) +#define acpi_cm_dump_allocation_info() + +#define DECREMENT_OBJECT_METRICS(a) +#define INCREMENT_OBJECT_METRICS(a) +#define INITIALIZE_ALLOCATION_METRICS() + +#else + +#define INITIALIZE_ALLOCATION_METRICS() \ + acpi_gbl_current_object_count = 0; \ + acpi_gbl_current_object_size = 0; \ + acpi_gbl_running_object_count = 0; \ + acpi_gbl_running_object_size = 0; \ + acpi_gbl_max_concurrent_object_count = 0; \ + acpi_gbl_max_concurrent_object_size = 0; \ + acpi_gbl_current_alloc_size = 0; \ + acpi_gbl_current_alloc_count = 0; \ + acpi_gbl_running_alloc_size = 0; \ + acpi_gbl_running_alloc_count = 0; \ + acpi_gbl_max_concurrent_alloc_size = 0; \ + acpi_gbl_max_concurrent_alloc_count = 0 + +#define DECREMENT_OBJECT_METRICS(a) \ + acpi_gbl_current_object_count--; \ + acpi_gbl_current_object_size -= a + +#define INCREMENT_OBJECT_METRICS(a) \ + acpi_gbl_current_object_count++; \ + acpi_gbl_running_object_count++; \ + if (acpi_gbl_max_concurrent_object_count < acpi_gbl_current_object_count) \ + { \ + acpi_gbl_max_concurrent_object_count = acpi_gbl_current_object_count; \ + } \ + acpi_gbl_running_object_size += a; \ + acpi_gbl_current_object_size += a; \ + if (acpi_gbl_max_concurrent_object_size < acpi_gbl_current_object_size) \ + { \ + acpi_gbl_max_concurrent_object_size = acpi_gbl_current_object_size; \ + } + + +void +acpi_cm_dump_allocation_info ( + void); + +void +acpi_cm_dump_current_allocations ( + u32 component, + ACPI_STRING module); + +#endif + + +#endif /* _COMMON_H */ diff --git a/drivers/acpi/include/config.h b/drivers/acpi/include/config.h new file mode 100644 index 000000000..a0e77e113 --- /dev/null +++ b/drivers/acpi/include/config.h @@ -0,0 +1,185 @@ + +/****************************************************************************** + * + * Name: config.h - Global configuration constants + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _CONFIG_H +#define _CONFIG_H + + +/****************************************************************************** + * + * Compile-time options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG - This switch enables all the debug facilities of the ACPI + * subsystem. This includes the DEBUG_PRINT output statements + * When disabled, all DEBUG_PRINT statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + + +/* Version string */ + +#define ACPI_CA_VERSION __DATE__ + +/* Name of host operating system (returned by the _OS_ namespace object) */ + +#ifdef _LINUX +#define ACPI_OS_NAME "Linux" +#else +#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem" +#endif + + +/* + * How and when control methods will be parsed + * The default action is to parse all methods at table load time to verify them, but delete the parse trees + * to conserve memory. Methods are parsed just in time before execution and the parse tree is deleted + * when execution completes. + */ +#define METHOD_PARSE_AT_INIT 0x0 /* Parse at table init, never delete the method parse tree */ +#define METHOD_PARSE_JUST_IN_TIME 0x1 /* Parse only when a method is invoked */ +#define METHOD_DELETE_AT_COMPLETION 0x2 /* Delete parse tree on method completion */ + +/* Default parsing configuration */ + +#define METHOD_PARSE_CONFIGURATION (METHOD_PARSE_JUST_IN_TIME | METHOD_DELETE_AT_COMPLETION) + + +/* Maximum objects in the various object caches */ + +#define MAX_STATE_CACHE_DEPTH 24 /* State objects for stacks */ +#define MAX_PARSE_CACHE_DEPTH 512 /* Parse tree objects */ +#define MAX_OBJECT_CACHE_DEPTH 32 /* Interpreter operand objects */ +#define MAX_WALK_CACHE_DEPTH 2 /* Objects for parse tree walks (method execution) */ + +/* + * Name_space Table size + * + * All tables are the same size to simplify the implementation. + * Tables may be extended by allocating additional tables that + * are in turn linked together to form a chain of tables. + */ + +#define NS_TABLE_SIZE 16 + +/* String size constants */ + +#define MAX_STRING_LENGTH 512 +#define PATHNAME_MAX 256 /* A full namespace pathname */ + + +/* Maximum count for a semaphore object */ + +#define MAX_SEMAPHORE_COUNT 256 + + +/* Max reference count (for debug only) */ + +#define MAX_REFERENCE_COUNT 0x200 + + +/* Size of cached memory mapping for system memory operation region */ + +#define SYSMEM_REGION_WINDOW_SIZE 4096 + + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* + * Method info (in WALK_STATE), containing local variables and argumetns + */ + +#define MTH_NUM_LOCALS 8 +#define MTH_MAX_LOCAL 7 + +#define MTH_NUM_ARGS 7 +#define MTH_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain MTH_MAX_ARG + */ + +#define OBJ_NUM_OPERANDS 8 +#define OBJ_MAX_OPERAND 7 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define PATH_SEPARATOR '.' + + +/* Constants used in searching for the RSDP in low memory */ + +#define LO_RSDP_WINDOW_BASE (void *) 0 +#define HI_RSDP_WINDOW_BASE (void *) 0xE0000 +#define LO_RSDP_WINDOW_SIZE 0x400 +#define HI_RSDP_WINDOW_SIZE 0x20000 +#define RSDP_SCAN_STEP 16 + + +/* Maximum nesting of package objects */ + +#define MAX_PACKAGE_DEPTH 16 + + +#endif /* _CONFIG_H */ + diff --git a/drivers/acpi/include/debugger.h b/drivers/acpi/include/debugger.h new file mode 100644 index 000000000..0d27d59b3 --- /dev/null +++ b/drivers/acpi/include/debugger.h @@ -0,0 +1,394 @@ + +/****************************************************************************** + * + * Name: debugger.h - ACPI/AML debugger + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __DEBUGGER_H__ +#define __DEBUGGER_H__ + + +#define DB_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define DB_COMMAND_PROMPT '-' +#define DB_EXECUTE_PROMPT '%' + + +extern int optind; +extern char *optarg; +extern u8 *aml_ptr; +extern u32 acpi_aml_length; + +extern u8 opt_tables; +extern u8 opt_disasm; +extern u8 opt_stats; +extern u8 opt_parse_jit; +extern u8 opt_verbose; + + +extern char *args[DB_MAX_ARGS]; +extern char line_buf[80]; +extern char scope_buf[40]; +extern char debug_filename[40]; +extern u8 output_to_file; +extern char *buffer; +extern char *filename; +extern char *INDENT_STRING; +extern u32 acpi_gbl_method_breakpoint; +extern u8 acpi_gbl_db_output_flags; +extern u32 acpi_gbl_db_debug_level; +extern u32 acpi_gbl_db_console_debug_level; + +extern u32 num_names; +extern u32 num_methods; +extern u32 num_regions; +extern u32 num_packages; +extern u32 num_aliases; +extern u32 num_devices; +extern u32 num_field_defs; +extern u32 num_thermal_zones; +extern u32 num_named_objects; +extern u32 num_grammar_elements; +extern u32 num_method_elements ; +extern u32 num_mutexes; +extern u32 num_power_resources; +extern u32 num_bank_fields ; +extern u32 num_index_fields; +extern u32 num_events; + +extern u32 size_of_parse_tree; +extern u32 size_of_method_trees; +extern u32 size_of_nTes; +extern u32 size_of_acpi_objects; + + +#define BUFFER_SIZE 4196 + +#define DB_REDIRECTABLE_OUTPUT 0x01 +#define DB_CONSOLE_OUTPUT 0x02 +#define DB_DUPLICATE_OUTPUT 0x03 + + +typedef struct command_info +{ + char *name; /* Command Name */ + char min_args; /* Minimum arguments required */ + +} COMMAND_INFO; + + +typedef struct argument_info +{ + char *name; /* Argument Name */ + +} ARGUMENT_INFO; + + +#define PARAM_LIST(pl) pl + +#define DBTEST_OUTPUT_LEVEL(lvl) if (opt_verbose) + +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + acpi_os_printf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* Prototypes */ + + +/* + * dbapi - external debugger interfaces + */ + +int +acpi_db_initialize ( + void); + +ACPI_STATUS +acpi_db_single_step ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op, + u8 op_type); + + +/* + * dbcmds - debug commands and output routines + */ + + +void +acpi_db_display_table_info ( + char *table_arg); + +void +acpi_db_unload_acpi_table ( + char *table_arg, + char *instance_arg); + +void +acpi_db_set_method_breakpoint ( + char *location, + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +void +acpi_db_set_method_call_breakpoint ( + ACPI_GENERIC_OP *op); + +void +acpi_db_disassemble_aml ( + char *statements, + ACPI_GENERIC_OP *op); + +void +acpi_db_dump_namespace ( + char *start_arg, + char *depth_arg); + +void +acpi_db_dump_namespace_by_owner ( + char *owner_arg, + char *depth_arg); + +void +acpi_db_send_notify ( + char *name, + u32 value); + +void +acpi_db_set_method_data ( + char *type_arg, + char *index_arg, + char *value_arg); + +ACPI_STATUS +acpi_db_display_objects ( + char *obj_type_arg, + char *display_count_arg); + +ACPI_STATUS +acpi_db_find_name_in_namespace ( + char *name_arg); + +void +acpi_db_set_scope ( + char *name); + +void +acpi_db_find_references ( + char *object_arg); + + +/* + * dbdisasm - AML disassembler + */ + +void +acpi_db_display_op ( + ACPI_GENERIC_OP *origin, + u32 num_opcodes); + +void +acpi_db_display_namestring ( + char *name); + +void +acpi_db_display_path ( + ACPI_GENERIC_OP *op); + +void +acpi_db_display_opcode ( + ACPI_GENERIC_OP *op); + + +/* + * dbdisply - debug display commands + */ + + +void +acpi_db_display_method_info ( + ACPI_GENERIC_OP *op); + +void +acpi_db_decode_and_display_object ( + char *target, + char *output_type); + +void +acpi_db_display_result_object ( + ACPI_OBJECT_INTERNAL *ret_desc); + +ACPI_STATUS +acpi_db_display_all_methods ( + char *display_count_arg); + +void +acpi_db_display_internal_object ( + ACPI_OBJECT_INTERNAL *obj_desc); + +void +acpi_db_display_arguments ( + void); + +void +acpi_db_display_locals ( + void); + +void +acpi_db_display_results ( + void); + +void +acpi_db_display_calling_tree ( + void); + +void +acpi_db_display_argument_object ( + ACPI_OBJECT_INTERNAL *obj_desc); + + +/* + * dbexec - debugger control method execution + */ + +void +acpi_db_execute ( + char *name, + char **args, + u32 flags); + +void +acpi_db_create_execution_threads ( + char *num_threads_arg, + char *num_loops_arg, + char *method_name_arg); + + +/* + * dbfileio - Debugger file I/O commands + */ + +OBJECT_TYPE_INTERNAL +acpi_db_match_argument ( + char *user_argument, + ARGUMENT_INFO *arguments); + + +void +acpi_db_close_debug_file ( + void); + +void +acpi_db_open_debug_file ( + char *name); + +ACPI_STATUS +acpi_db_load_acpi_table ( + char *filename); + + +/* + * dbhistry - debugger HISTORY command + */ + +void +acpi_db_add_to_history ( + char *command_line); + +void +acpi_db_display_history (void); + +char * +acpi_db_get_from_history ( + char *command_num_arg); + + +/* + * dbinput - user front-end to the AML debugger + */ + +ACPI_STATUS +acpi_db_command_dispatch ( + char *input_buffer, + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +void +acpi_db_execute_thread ( + void *context); + +ACPI_STATUS +acpi_db_user_commands ( + char prompt, + ACPI_GENERIC_OP *op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ + +void +acpi_db_generate_statistics ( + ACPI_GENERIC_OP *root, + u8 is_method); + + +ACPI_STATUS +acpi_db_display_statistics ( + char *type_arg); + + +/* + * dbutils - AML debugger utilities + */ + +void +acpi_db_set_output_destination ( + s32 where); + +void +acpi_db_dump_buffer ( + u32 address); + +void +acpi_db_dump_object ( + ACPI_OBJECT *obj_desc, + u32 level); + +void +acpi_db_prep_namestring ( + char *name); + + +ACPI_STATUS +acpi_db_second_pass_parse ( + ACPI_GENERIC_OP *root); + +ACPI_NAMED_OBJECT* +acpi_db_local_ns_lookup ( + char *name); + + +#endif /* __DEBUGGER_H__ */ diff --git a/drivers/acpi/include/dispatch.h b/drivers/acpi/include/dispatch.h new file mode 100644 index 000000000..e1d44be7a --- /dev/null +++ b/drivers/acpi/include/dispatch.h @@ -0,0 +1,383 @@ +/****************************************************************************** + * + * Module Name: dispatch.h + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _DISPATCH_H_ +#define _DISPATCH_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* For Acpi_ds_method_data_set_value */ + +#define MTH_TYPE_LOCAL 0 +#define MTH_TYPE_ARG 1 + + +/* Common interfaces */ + +ACPI_STATUS +acpi_ds_obj_stack_push ( + void *object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop ( + u32 pop_count, + ACPI_WALK_STATE *walk_state); + +void * +acpi_ds_obj_stack_get_value ( + u32 index, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop_object ( + ACPI_OBJECT_INTERNAL **object, + ACPI_WALK_STATE *walk_state); + + +/* dsregion - Op region support */ + +ACPI_STATUS +acpi_ds_get_region_arguments ( + ACPI_OBJECT_INTERNAL *rgn_desc); + + +/* dsctrl - Parser/Interpreter interface, control stack routines */ + +/* +ACPI_CTRL_STATE * +Acpi_ds_create_control_state (void); + +void +Acpi_ds_push_control_state ( + ACPI_CTRL_STATE *Control_state, + ACPI_WALK_STATE *Walk_state); + +ACPI_CTRL_STATE * +Acpi_ds_pop_control_state ( + ACPI_WALK_STATE *Walk_state); +*/ + +ACPI_STATUS +acpi_ds_exec_begin_control_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_exec_end_control_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + + +/* dsexec - Parser/Interpreter interface, method execution callbacks */ + +ACPI_STATUS +acpi_ds_exec_begin_op ( + ACPI_WALK_STATE *state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_exec_end_op ( + ACPI_WALK_STATE *state, + ACPI_GENERIC_OP *op); + + +/* dsfield - Parser/Interpreter interface for AML fields */ + + +ACPI_STATUS +acpi_ds_create_field ( + ACPI_GENERIC_OP *op, + ACPI_HANDLE region, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_bank_field ( + ACPI_GENERIC_OP *op, + ACPI_HANDLE region, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_index_field ( + ACPI_GENERIC_OP *op, + ACPI_HANDLE region, + ACPI_WALK_STATE *walk_state); + + +/* dsload - Parser/Interpreter interface, namespace load callbacks */ + +ACPI_STATUS +acpi_ds_load1_begin_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_load1_end_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_load2_begin_op ( + ACPI_WALK_STATE *state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_load2_end_op ( + ACPI_WALK_STATE *state, + ACPI_GENERIC_OP *op); + + +/* dsmthdat - method data (locals/args) */ + + +ACPI_STATUS +acpi_ds_method_data_delete_all ( + ACPI_WALK_STATE *walk_state); + +u8 +acpi_ds_is_method_value ( + ACPI_OBJECT_INTERNAL *obj_desc); + +OBJECT_TYPE_INTERNAL +acpi_ds_method_data_get_type ( + u32 type, + u32 index); + +ACPI_STATUS +acpi_ds_method_data_get_value ( + u32 type, + u32 index, + ACPI_OBJECT_INTERNAL **obj_desc); + +ACPI_STATUS +acpi_ds_method_data_set_value ( + u32 type, + u32 index, + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_ds_method_data_delete_value ( + u32 type, + u32 index); + +ACPI_STATUS +acpi_ds_method_data_init_args ( + ACPI_OBJECT_INTERNAL **params, + u32 param_count); + +ACPI_NAMED_OBJECT* +acpi_ds_method_data_get_nte ( + u32 type, + u32 index); + +ACPI_STATUS +acpi_ds_method_data_init ( + ACPI_WALK_STATE *walk_state); + + +/* dsmethod - Parser/Interpreter interface - control method parsing */ + +ACPI_STATUS +acpi_ds_parse_method ( + ACPI_HANDLE obj_handle); + +ACPI_STATUS +acpi_ds_call_control_method ( + ACPI_WALK_LIST *walk_list, + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_restart_control_method ( + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL *return_desc); + +ACPI_STATUS +acpi_ds_terminate_control_method ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_begin_method_execution ( + ACPI_NAMED_OBJECT *method_entry, + ACPI_OBJECT_INTERNAL *obj_desc); + + +/* dsobj - Parser/Interpreter interface - object initialization and conversion */ + +ACPI_STATUS +acpi_ds_init_one_object ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +ACPI_STATUS +acpi_ds_initialize_objects ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAMED_OBJECT *start_entry); + +ACPI_STATUS +acpi_ds_build_internal_package_obj ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op, + ACPI_OBJECT_INTERNAL **obj_desc); + +ACPI_STATUS +acpi_ds_build_internal_object ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op, + ACPI_OBJECT_INTERNAL **obj_desc_ptr); + +ACPI_STATUS +acpi_ds_init_object_from_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op, + u16 opcode, + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_ds_create_named_object ( + ACPI_WALK_STATE *walk_state, + ACPI_NAMED_OBJECT *entry, + ACPI_GENERIC_OP *op); + + +/* dsregn - Parser/Interpreter interface - Op Region parsing */ + +ACPI_STATUS +acpi_ds_eval_region_operands ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op); + +ACPI_STATUS +acpi_ds_initialize_region ( + ACPI_HANDLE obj_handle); + + +/* dsutils - Parser/Interpreter interface utility routines */ + +void +acpi_ds_delete_result_if_not_used ( + ACPI_GENERIC_OP *op, + ACPI_OBJECT_INTERNAL *result_obj, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_create_operand ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *arg); + +ACPI_STATUS +acpi_ds_create_operands ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *first_arg); + +ACPI_STATUS +acpi_ds_resolve_operands ( + ACPI_WALK_STATE *walk_state); + +OBJECT_TYPE_INTERNAL +acpi_ds_map_opcode_to_data_type ( + u16 opcode, + u32 *out_flags); + +OBJECT_TYPE_INTERNAL +acpi_ds_map_named_opcode_to_data_type ( + u16 opcode); + + +/* + * dswscope - Scope Stack manipulation + */ + +ACPI_STATUS +acpi_ds_scope_stack_push ( + ACPI_NAME_TABLE *new_scope, + OBJECT_TYPE_INTERNAL type, + ACPI_WALK_STATE *walk_state); + + +ACPI_STATUS +acpi_ds_scope_stack_pop ( + ACPI_WALK_STATE *walk_state); + +void +acpi_ds_scope_stack_clear ( + ACPI_WALK_STATE *walk_state); + + +/* Acpi_dswstate - parser WALK_STATE management routines */ + +ACPI_WALK_STATE * +acpi_ds_create_walk_state ( + ACPI_OWNER_ID owner_id, + ACPI_GENERIC_OP *origin, + ACPI_OBJECT_INTERNAL *mth_desc, + ACPI_WALK_LIST *walk_list); + +ACPI_STATUS +acpi_ds_obj_stack_delete_all ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_obj_stack_pop_and_delete ( + u32 pop_count, + ACPI_WALK_STATE *walk_state); + +void +acpi_ds_delete_walk_state ( + ACPI_WALK_STATE *walk_state); + +ACPI_WALK_STATE * +acpi_ds_pop_walk_state ( + ACPI_WALK_LIST *walk_list); + +ACPI_STATUS +acpi_ds_result_stack_pop ( + ACPI_OBJECT_INTERNAL **object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_result_stack_push ( + void *object, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ds_result_stack_clear ( + ACPI_WALK_STATE *walk_state); + +ACPI_WALK_STATE * +acpi_ds_get_current_walk_state ( + ACPI_WALK_LIST *walk_list); + +void +acpi_ds_delete_walk_state_cache ( + void); + + +#endif /* _DISPATCH_H_ */
\ No newline at end of file diff --git a/drivers/acpi/include/events.h b/drivers/acpi/include/events.h new file mode 100644 index 000000000..398157004 --- /dev/null +++ b/drivers/acpi/include/events.h @@ -0,0 +1,209 @@ + +/****************************************************************************** + * + * Name: events.h - Acpi_event subcomponent prototypes and defines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __EVENTS_H__ +#define __EVENTS_H__ + + +/* + * Acpi_evfixed - Fixed event handling + */ + +ACPI_STATUS +acpi_ev_fixed_event_initialize ( + void); + +u32 +acpi_ev_fixed_event_detect ( + void); + +u32 +acpi_ev_fixed_event_dispatch ( + u32 acpi_event); + + +/* + * Acpi_evglock - Global Lock support + */ + +ACPI_STATUS +acpi_ev_acquire_global_lock( + void); + +void +acpi_ev_release_global_lock( + void); + +ACPI_STATUS +acpi_ev_init_global_lock_handler ( + void); + + +/* + * Acpi_evgpe - GPE handling and dispatch + */ + +ACPI_STATUS +acpi_ev_gpe_initialize ( + void); + +ACPI_STATUS +acpi_ev_init_gpe_control_methods ( + void); + +u32 +acpi_ev_gpe_dispatch ( + u32 gpe_number); + +u32 +acpi_ev_gpe_detect ( + void); + + +/* + * Acpi_evnotify - Device Notify handling and dispatch + */ + +void +acpi_ev_notify_dispatch ( + ACPI_HANDLE device, + u32 notify_value); + + +/* + * Acpi_evregion - Address Space handling + */ + +ACPI_STATUS +acpi_ev_install_default_address_space_handlers ( + void); + +ACPI_STATUS +acpi_ev_address_space_dispatch ( + ACPI_OBJECT_INTERNAL *region_obj, + u32 function, + u32 address, + u32 bit_width, + u32 *value); + + +ACPI_STATUS +acpi_ev_addr_handler_helper ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +void +acpi_ev_disassociate_region_from_handler( + ACPI_OBJECT_INTERNAL *region_obj); + + +ACPI_STATUS +acpi_ev_associate_region_and_handler( + ACPI_OBJECT_INTERNAL *handler_obj, + ACPI_OBJECT_INTERNAL *region_obj); + + +/* + * Acpi_evregini - Region initialization and setup + */ + +ACPI_STATUS +acpi_ev_system_memory_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **return_context); + +ACPI_STATUS +acpi_ev_io_space_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **return_context); + +ACPI_STATUS +acpi_ev_pci_config_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **return_context); + +ACPI_STATUS +acpi_ev_default_region_setup ( + ACPI_HANDLE handle, + u32 function, + void *handler_context, + void **return_context); + +ACPI_STATUS +acpi_ev_initialize_region ( + ACPI_OBJECT_INTERNAL *region_obj, + u8 acpi_ns_locked); + + +/* + * Acpi_evsci - SCI (System Control Interrupt) handling/dispatch + */ + +u32 +acpi_ev_install_sci_handler ( + void); + +ACPI_STATUS +acpi_ev_remove_sci_handler ( + void); + +s32 +acpi_ev_initialize_sCI ( + s32 program_sCI); + +void +acpi_ev_restore_acpi_state ( + void); + +void +acpi_ev_terminate ( + void); + + +/* Debug support */ + +#ifdef ACPI_DEBUG + +s32 +acpi_ev_sci_count ( + u32 acpi_event); + +#define DEBUG_INCREMENT_EVENT_COUNT(a) acpi_gbl_event_count[a]++; + +#else + +#define DEBUG_INCREMENT_EVENT_COUNT(a) +#endif + + +#endif /* __EVENTS_H__ */ diff --git a/drivers/acpi/include/globals.h b/drivers/acpi/include/globals.h new file mode 100644 index 000000000..7857d6f39 --- /dev/null +++ b/drivers/acpi/include/globals.h @@ -0,0 +1,311 @@ + +/****************************************************************************** + * + * Name: globals.h - Declarations for global variables + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + + +/* + * Ensure that the globals are actually defined only once + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#else +#define ACPI_EXTERN extern +#endif + + +extern char *msg_acpi_error_break; + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Runtime configuration of debug print levels */ + +extern u32 acpi_dbg_level; +extern u32 acpi_dbg_layer; + + +/* Procedure nesting level for debug output */ + +extern u32 acpi_gbl_nesting_level; + + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * Table pointers. + * Although these pointers are somewhat redundant with the global Acpi_table, + * they are convenient because they are typed pointers. + * + * These tables are single-table only; meaning that there can be at most one + * of each in the system. Each global points to the actual table. + * + */ +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTOR_POINTER *acpi_gbl_RSDP; +ACPI_EXTERN ROOT_SYSTEM_DESCRIPTION_TABLE *acpi_gbl_RSDT; +ACPI_EXTERN FIRMWARE_ACPI_CONTROL_STRUCTURE *acpi_gbl_FACS; +ACPI_EXTERN FIXED_ACPI_DESCRIPTION_TABLE *acpi_gbl_FACP; +ACPI_EXTERN APIC_TABLE *acpi_gbl_APIC; +ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_DSDT; +ACPI_EXTERN ACPI_TABLE_HEADER *acpi_gbl_SBST; +/* + * Since there may be multiple SSDTs and PSDTS, a single pointer is not + * sufficient; Therefore, there isn't one! + */ + + +/* + * ACPI Table info arrays + */ +extern ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES]; +extern ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES]; + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO acpi_gbl_acpi_mutex_info [NUM_MTX]; +extern ACPI_INIT_DATA acpi_gbl_acpi_init_data; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + + +ACPI_EXTERN u8 *acpi_gbl_gpe0enable_register_save; +ACPI_EXTERN u8 *acpi_gbl_gpe1_enable_register_save; +ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_breakpoint_walk; +ACPI_EXTERN ACPI_GENERIC_STATE *acpi_gbl_generic_state_cache; +ACPI_EXTERN ACPI_GENERIC_OP *acpi_gbl_parse_cache; +ACPI_EXTERN ACPI_OBJECT_INTERNAL *acpi_gbl_object_cache; +ACPI_EXTERN ACPI_WALK_STATE *acpi_gbl_walk_state_cache; +ACPI_EXTERN ACPI_HANDLE acpi_gbl_global_lock_semaphore; + + +ACPI_EXTERN u32 acpi_gbl_global_lock_thread_count; +ACPI_EXTERN u32 acpi_gbl_restore_acpi_chipset; +ACPI_EXTERN u32 acpi_gbl_original_mode; +ACPI_EXTERN u32 acpi_gbl_edge_level_save; +ACPI_EXTERN u32 acpi_gbl_irq_enable_save; +ACPI_EXTERN u32 acpi_gbl_rsdp_original_location; + +ACPI_EXTERN u32 acpi_gbl_state_cache_requests; +ACPI_EXTERN u32 acpi_gbl_state_cache_hits; +ACPI_EXTERN u32 acpi_gbl_parse_cache_requests; +ACPI_EXTERN u32 acpi_gbl_parse_cache_hits; +ACPI_EXTERN u32 acpi_gbl_object_cache_requests; +ACPI_EXTERN u32 acpi_gbl_object_cache_hits; +ACPI_EXTERN u32 acpi_gbl_walk_state_cache_requests; +ACPI_EXTERN u32 acpi_gbl_walk_state_cache_hits; +ACPI_EXTERN u32 acpi_gbl_ns_lookup_count; +ACPI_EXTERN u32 acpi_gbl_ps_find_count; + + +ACPI_EXTERN u16 acpi_gbl_generic_state_cache_depth; +ACPI_EXTERN u16 acpi_gbl_parse_cache_depth; +ACPI_EXTERN u16 acpi_gbl_object_cache_depth; +ACPI_EXTERN u16 acpi_gbl_walk_state_cache_depth; +ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; +ACPI_EXTERN u16 acpi_gbl_next_table_owner_id; +ACPI_EXTERN u16 acpi_gbl_next_method_owner_id; + +ACPI_EXTERN u8 acpi_gbl_debugger_configuration; +ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; +ACPI_EXTERN u8 acpi_gbl_global_lock_set; /* TBD: [Restructure] OBSOLETE?? */ +ACPI_EXTERN u8 acpi_gbl_step_to_next_call; +ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; + + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_drv_notify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER acpi_gbl_sys_notify; + + +extern u8 acpi_gbl_shutdown; +extern u32 acpi_gbl_system_flags; +extern u32 acpi_gbl_startup_flags; + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 +#define NUM_PREDEFINED_NAMES 9 + + +ACPI_EXTERN ACPI_NAME_TABLE acpi_gbl_root_name_table; +ACPI_EXTERN ACPI_NAMED_OBJECT *acpi_gbl_root_object; + +extern u8 acpi_gbl_ns_properties[NUM_NS_TYPES]; +extern PREDEFINED_NAMES acpi_gbl_pre_defined_names [NUM_PREDEFINED_NAMES]; + + +/* Used to detect memory leaks (DEBUG ONLY) */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_head_alloc_ptr; +ACPI_EXTERN ALLOCATION_INFO *acpi_gbl_tail_alloc_ptr; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN u32 acpi_gbl_when_to_parse_methods; +ACPI_EXTERN ACPI_WALK_LIST *acpi_gbl_current_walk_list; + +/* Base of AML block, and pointer to current location in it */ + +ACPI_EXTERN u8 *acpi_gbl_Pcode_base; +ACPI_EXTERN u8 *acpi_gbl_Pcode; + +/* + * Length of AML block, and remaining length of current package. + */ +ACPI_EXTERN u32 acpi_gbl_Pcode_block_len; +ACPI_EXTERN u32 acpi_gbl_Pcode_len; + +ACPI_EXTERN u32 acpi_gbl_buf_seq; /* Counts allocated Buffer descriptors */ +ACPI_EXTERN s32 acpi_gbl_named_object_err; /* Indicate if inc_error should be called */ + +/* + * Handle to the last method found - used during pass1 of load + */ +ACPI_EXTERN ACPI_HANDLE acpi_gbl_last_method; + +/* + * Table of Address Space handlers + */ + +ACPI_EXTERN ACPI_ADDRESS_SPACE_INFO acpi_gbl_address_spaces[ACPI_NUM_ADDRESS_SPACES]; + + +/* Control method single step flag */ + +ACPI_EXTERN u8 acpi_gbl_cm_single_step; + + +/***************************************************************************** + * + * Parser globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_GENERIC_OP *acpi_gbl_parsed_namespace_root; + +extern ACPI_OP_INFO acpi_gbl_aml_op_info[]; +extern u8 acpi_gbl_aml_op_info_index[256]; +extern char *acpi_gbl_parser_id; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_C_STATE_HANDLER acpi_hw_cx_handlers[MAX_CX_STATES]; +extern u32 acpi_hw_active_cx_state; + + +/***************************************************************************** + * + * Event globals + * + ****************************************************************************/ + +ACPI_EXTERN ACPI_FIXED_EVENT_INFO acpi_gbl_fixed_event_handlers[NUM_FIXED_EVENTS]; + +ACPI_EXTERN ACPI_HANDLE acpi_gbl_gpe_obj_handle; +ACPI_EXTERN u32 acpi_gbl_gpe_register_count; +ACPI_EXTERN ACPI_GPE_REGISTERS *acpi_gbl_gpe_registers; +ACPI_EXTERN ACPI_GPE_LEVEL_INFO *acpi_gbl_gpe_info; + +/* + * Gpe validation and translation table + * Indexed by the GPE number, returns GPE_INVALID if the GPE is not supported. + * Otherwise, returns a valid index into the global GPE table. + * + * This table is needed because the GPE numbers supported by block 1 do not + * have to be contiguous with the GPE numbers supported by block 0. + */ +ACPI_EXTERN u8 acpi_gbl_gpe_valid [NUM_GPE]; + +/* Acpi_event counter for debug only */ + +#ifdef ACPI_DEBUG +ACPI_EXTERN u32 acpi_gbl_event_count[NUM_FIXED_EVENTS]; +#endif + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN u8 acpi_gbl_method_executing; +ACPI_EXTERN u8 acpi_gbl_db_terminate_threads; + + +/* Memory allocation metrics - Debug Only! */ + +#ifdef ACPI_DEBUG + +ACPI_EXTERN u32 acpi_gbl_current_alloc_size; +ACPI_EXTERN u32 acpi_gbl_current_alloc_count; +ACPI_EXTERN u32 acpi_gbl_running_alloc_size; +ACPI_EXTERN u32 acpi_gbl_running_alloc_count; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_alloc_count; +ACPI_EXTERN u32 acpi_gbl_current_object_count; +ACPI_EXTERN u32 acpi_gbl_current_object_size; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_count; +ACPI_EXTERN u32 acpi_gbl_max_concurrent_object_size; +ACPI_EXTERN u32 acpi_gbl_running_object_count; +ACPI_EXTERN u32 acpi_gbl_running_object_size; + +#endif + + +#endif /* __GLOBALS_H__ */ diff --git a/drivers/acpi/include/hardware.h b/drivers/acpi/include/hardware.h new file mode 100644 index 000000000..4191f17dd --- /dev/null +++ b/drivers/acpi/include/hardware.h @@ -0,0 +1,169 @@ + +/****************************************************************************** + * + * Name: hardware.h -- hardware specific interfaces + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __HARDWARE_H__ +#define __HARDWARE_H__ + + +/* Prototypes */ + + +ACPI_STATUS +acpi_hw_initialize( + void); + +ACPI_STATUS +acpi_hw_shutdown( + void); + +ACPI_STATUS +acpi_hw_initialize_system_info( + void); + +ACPI_STATUS +acpi_hw_set_mode ( + u32 mode); + +u32 +acpi_hw_get_mode ( + void); + +u32 +acpi_hw_get_mode_capabilities ( + void); + +/* Register I/O Prototypes */ + +u32 +acpi_hw_register_access ( + NATIVE_UINT read_write, + u8 use_lock, + u32 register_id, ... /* DWORD Value */); + +void +acpi_hw_clear_acpi_status ( + void); + + +/* GPE support */ + +void +acpi_hw_enable_gpe ( + u32 gpe_index); + +void +acpi_hw_disable_gpe ( + u32 gpe_index); + +void +acpi_hw_clear_gpe ( + u32 gpe_index); + +void +acpi_hw_get_gpe_status ( + u32 gpe_number, + ACPI_EVENT_STATUS *event_status); + +/* Sleep Prototypes */ + +ACPI_STATUS +acpi_hw_obtain_sleep_type_register_data ( + u8 sleep_state, + u8 *slp_typ_a, + u8 *slp_typ_b); + + +/* Cx State Prototypes */ + +ACPI_STATUS +acpi_hw_enter_c1( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_c2( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_c3( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_enter_cx ( + ACPI_IO_ADDRESS pblk_address, + u32 *pm_timer_ticks); + +ACPI_STATUS +acpi_hw_set_cx ( + u32 cx_state); + +ACPI_STATUS +acpi_hw_get_cx_info ( + u32 cx_states[]); + + +/* Throttling Prototypes */ + +void +acpi_hw_enable_throttling ( + ACPI_IO_ADDRESS pblk_address); + +void +acpi_hw_disable_throttling ( + ACPI_IO_ADDRESS pblk_address); + +u32 +acpi_hw_get_duty_cycle ( + u8 duty_offset, + ACPI_IO_ADDRESS pblk_address, + u32 num_throttle_states); + +void +acpi_hw_program_duty_cycle ( + u8 duty_offset, + u32 duty_cycle, + ACPI_IO_ADDRESS pblk_address, + u32 num_throttle_states); + +NATIVE_UINT +acpi_hw_local_pow ( + NATIVE_UINT x, + NATIVE_UINT y); + + +/* ACPI Timer prototypes */ + +u32 +acpi_hw_pmt_ticks ( + void); + +u32 +acpi_hw_pmt_resolution ( + void); + + +#endif /* __HARDWARE_H__ */ diff --git a/drivers/acpi/include/internal.h b/drivers/acpi/include/internal.h new file mode 100644 index 000000000..68c903cf7 --- /dev/null +++ b/drivers/acpi/include/internal.h @@ -0,0 +1,850 @@ + +/****************************************************************************** + * + * Name: internal.h - Internal data types used across the ACPI subsystem + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _ACPI_INTERNAL_H +#define _ACPI_INTERNAL_H + +#include "config.h" + + +#define WAIT_FOREVER ((u32) -1) + +typedef void* ACPI_MUTEX; +typedef u32 ACPI_MUTEX_HANDLE; + + +/* Object descriptor types */ + +#define ACPI_DESC_TYPE_INTERNAL 0xAA +#define ACPI_DESC_TYPE_PARSER 0xBB +#define ACPI_DESC_TYPE_STATE 0xCC +#define ACPI_DESC_TYPE_WALK 0xDD +#define ACPI_DESC_TYPE_NAMED 0xEE + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by Acpi_cm_mutex_initialize. + * NOTE: any changes here must be reflected in the Acpi_gbl_Mutex_names table also! + */ + +#define ACPI_MTX_HARDWARE 0 +#define ACPI_MTX_MEMORY 1 +#define ACPI_MTX_CACHES 2 +#define ACPI_MTX_TABLES 3 +#define ACPI_MTX_PARSER 4 +#define ACPI_MTX_DISPATCHER 5 +#define ACPI_MTX_INTERPRETER 6 +#define ACPI_MTX_EXECUTE 7 +#define ACPI_MTX_NAMESPACE 8 +#define ACPI_MTX_EVENTS 9 +#define ACPI_MTX_OP_REGIONS 10 +#define ACPI_MTX_DEBUG_CMD_READY 11 +#define ACPI_MTX_DEBUG_CMD_COMPLETE 12 + +#define MAX_MTX 12 +#define NUM_MTX MAX_MTX+1 + + +#ifdef ACPI_DEBUG +#ifdef DEFINE_ACPI_GLOBALS + +/* Names for the mutexes used in the subsystem */ + +static char *acpi_gbl_mutex_names[] = +{ + "ACPI_MTX_Hardware", + "ACPI_MTX_Memory", + "ACPI_MTX_Caches", + "ACPI_MTX_Tables", + "ACPI_MTX_Parser", + "ACPI_MTX_Dispatcher", + "ACPI_MTX_Interpreter", + "ACPI_MTX_Execute", + "ACPI_MTX_Namespace", + "ACPI_MTX_Events", + "ACPI_MTX_Op_regions", + "ACPI_MTX_Debug_cmd_ready", + "ACPI_MTX_Debug_cmd_complete" +}; + +#endif +#endif + + +/* Table for the global mutexes */ + +typedef struct acpi_mutex_info +{ + ACPI_MUTEX mutex; + u32 use_count; + u8 locked; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +typedef u16 ACPI_OWNER_ID; +#define OWNER_TYPE_TABLE 0x0 +#define OWNER_TYPE_METHOD 0x1 +#define FIRST_METHOD_ID 0x0000 +#define FIRST_TABLE_ID 0x8000 + +/* TBD: [Restructure] get rid of the need for this! */ + +#define TABLE_ID_DSDT (ACPI_OWNER_ID) 0xD1D1 + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + IMODE_LOAD_PASS1 = 0x01, + IMODE_LOAD_PASS2 = 0x02, + IMODE_EXECUTE = 0x0E + +} OPERATING_MODE; + + +/* + * The Acpi_named_object describes a named object that appears in the AML + * An Acpi_name_table is used to store Acpi_named_objects. + * + * Data_type is used to differentiate between internal descriptors, and MUST + * be the first byte in this structure. + */ + +typedef struct acpi_named_object +{ + u8 data_type; + u8 type; /* Type associated with this name */ + u8 this_index; /* Entry number */ + u8 flags; + u32 name; /* ACPI Name, always 4 chars per ACPI spec */ + + + void *object; /* Pointer to attached ACPI object (optional) */ + struct acpi_name_table *child_table; /* Scope owned by this name (optional) */ + ACPI_OWNER_ID owner_id; /* ID of owner - either an ACPI table or a method */ + u16 reference_count; /* Current count of references and children */ + +#ifdef _IA64 + u32 fill1; /* 64-bit alignment */ +#endif + +} ACPI_NAMED_OBJECT; + + +typedef struct acpi_name_table +{ + struct acpi_name_table *next_table; + struct acpi_name_table *parent_table; + ACPI_NAMED_OBJECT *parent_entry; + ACPI_NAMED_OBJECT entries[1]; + +} ACPI_NAME_TABLE; + + +#define ENTRY_NOT_FOUND NULL + + +/* NTE flags */ + +#define NTE_AML_ATTACHMENT 0x1 + + +/* + * ACPI Table Descriptor. One per ACPI table + */ +typedef struct acpi_table_desc +{ + struct acpi_table_desc *prev; + struct acpi_table_desc *next; + struct acpi_table_desc *installed_desc; + ACPI_TABLE_HEADER *pointer; + void *base_pointer; + u8 *aml_pointer; + u32 aml_length; + u32 length; + u32 count; + ACPI_OWNER_ID table_id; + u8 type; + u8 allocation; + u8 loaded_into_namespace; + +} ACPI_TABLE_DESC; + + +typedef struct +{ + char *search_for; + ACPI_HANDLE *list; + s32 *count; + +} FIND_CONTEXT; + + +typedef struct +{ + ACPI_NAME_TABLE *name_table; + u32 position; + u8 table_full; + +} NS_SEARCH_DATA; + + +/* + * Predefined Namespace items + */ +#define ACPI_MAX_ADDRESS_SPACE 255 +#define ACPI_NUM_ADDRESS_SPACES 256 + + +typedef struct +{ + char *name; + ACPI_OBJECT_TYPE type; + char *val; + +} PREDEFINED_NAMES; + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + + +/* Status bits. */ + +#define ACPI_STATUS_PMTIMER 0x0001 +#define ACPI_STATUS_GLOBAL 0x0020 +#define ACPI_STATUS_POWER_BUTTON 0x0100 +#define ACPI_STATUS_SLEEP_BUTTON 0x0200 +#define ACPI_STATUS_RTC_ALARM 0x0400 + +/* Enable bits. */ + +#define ACPI_ENABLE_PMTIMER 0x0001 +#define ACPI_ENABLE_GLOBAL 0x0020 +#define ACPI_ENABLE_POWER_BUTTON 0x0100 +#define ACPI_ENABLE_SLEEP_BUTTON 0x0200 +#define ACPI_ENABLE_RTC_ALARM 0x0400 + + +/* + * Entry in the Address_space (AKA Operation Region) table + */ + +typedef struct +{ + ADDRESS_SPACE_HANDLER handler; + void *context; + +} ACPI_ADDRESS_SPACE_INFO; + + +/* Values and addresses of the GPE registers (both banks) */ + +typedef struct +{ + u8 status; /* Current value of status reg */ + u8 enable; /* Current value of enable reg */ + u16 status_addr; /* Address of status reg */ + u16 enable_addr; /* Address of enable reg */ + u8 gpe_base; /* Base GPE number */ + +} ACPI_GPE_REGISTERS; + + +#define ACPI_GPE_LEVEL_TRIGGERED 1 +#define ACPI_GPE_EDGE_TRIGGERED 2 + + +/* Information about each particular GPE level */ + +typedef struct +{ + u8 type; /* Level or Edge */ + + ACPI_HANDLE method_handle; /* Method handle for direct (fast) execution */ + GPE_HANDLER handler; /* Address of handler, if any */ + void *context; /* Context to be passed to handler */ + +} ACPI_GPE_LEVEL_INFO; + + +/* Information about each particular fixed event */ + +typedef struct +{ + FIXED_EVENT_HANDLER handler; /* Address of handler. */ + void *context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_INFO; + + +/* Information used during field processing */ + +typedef struct +{ + u8 skip_field; + u8 field_flag; + u32 pkg_length; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + + +#define OP_INFO_TYPE 0x1F +#define OP_INFO_HAS_ARGS 0x20 +#define OP_INFO_CHILD_LOCATION 0xC0 + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_op_info +{ + u16 opcode; /* AML opcode */ + u8 flags; /* Opcode type, Has_args flag */ + u32 parse_args; /* Grammar/Parse time arguments */ + u32 runtime_args; /* Interpret time arguments */ + + DEBUG_ONLY_MEMBERS ( + char *name) /* op name (debug only) */ + +} ACPI_OP_INFO; + + +typedef union acpi_op_value +{ + u32 integer; /* integer constant */ + u32 size; /* bytelist or field size */ + char *string; /* NULL terminated string */ + u8 *buffer; /* buffer or string */ + char *name; /* NULL terminated string */ + struct acpi_generic_op *arg; /* arguments and contained ops */ + ACPI_NAMED_OBJECT *entry; /* entry in interpreter namespace tbl */ + +} ACPI_OP_VALUE; + + +#define ACPI_COMMON_OP \ + u8 data_type; /* To differentiate various internal objs */\ + u8 flags; /* Type of Op */\ + u16 opcode; /* AML opcode */\ + u32 aml_offset; /* offset of declaration in AML */\ + struct acpi_generic_op *parent; /* parent op */\ + struct acpi_generic_op *next; /* next op */\ + DEBUG_ONLY_MEMBERS (\ + char op_name[16]) /* op name (debug only) */\ + /* NON-DEBUG members below: */\ + void *acpi_named_object;/* for use by interpreter */\ + ACPI_OP_VALUE value; /* Value or args associated with the opcode */\ + + +/* + * generic operation (eg. If, While, Store) + */ +typedef struct acpi_generic_op +{ + ACPI_COMMON_OP +} ACPI_GENERIC_OP; + + +/* + * operation with a name (eg. Scope, Method, Name, Named_field, ...) + */ +typedef struct acpi_named_op +{ + ACPI_COMMON_OP + u32 name; /* 4-byte name or zero if no name */ + +} ACPI_NAMED_OP; + + +/* + * special operation for methods and regions (parsing must be deferred + * until a first pass parse is completed) + */ +typedef struct acpi_deferred_op +{ + ACPI_COMMON_OP + u32 name; /* 4-byte name or 0 if none */ + u32 body_length; /* AML body size */ + u8 *body; /* AML body */ + u16 thread_count; /* Count of threads currently executing a method */ + +} ACPI_DEFERRED_OP; + + +/* + * special operation for bytelists (Byte_list only) + */ +typedef struct acpi_bytelist_op +{ + ACPI_COMMON_OP + u8 *data; /* bytelist data */ + +} ACPI_BYTELIST_OP; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ + +typedef struct acpi_parse_state +{ + u8 *aml_start; /* first AML byte */ + u8 *aml; /* next AML byte */ + u8 *aml_end; /* (last + 1) AML byte */ + u8 *pkg_end; /* current package end */ + ACPI_GENERIC_OP *start_op; /* root of parse tree */ + struct acpi_parse_scope *scope; /* current scope */ + struct acpi_parse_scope *scope_avail; /* unused (extra) scope structs */ + struct acpi_parse_state *next; + +} ACPI_PARSE_STATE; + + +/* + * Parse scope - one per ACPI scope + */ + +typedef struct acpi_parse_scope +{ + ACPI_GENERIC_OP *op; /* current op being parsed */ + u8 *arg_end; /* current argument end */ + u8 *pkg_end; /* current package end */ + struct acpi_parse_scope *parent; /* parent scope */ + u32 arg_list; /* next argument to parse */ + u32 arg_count; /* Number of fixed arguments */ + +} ACPI_PARSE_SCOPE; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + + +#define CONTROL_NORMAL 0xC0 +#define CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define CONTROL_PREDICATE_EXECUTING 0xC2 +#define CONTROL_PREDICATE_FALSE 0xC3 +#define CONTROL_PREDICATE_TRUE 0xC4 + + +#define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ + u8 data_type; /* To differentiate various internal objs */\ + u8 flags; \ + u16 value; \ + u16 state; \ + u16 acpi_eval; \ + void *next; \ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_obj_internal *object; + +} ACPI_UPDATE_STATE; + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + ACPI_GENERIC_OP *predicate_op; /* Start of if/while predicate */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ + +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAME_TABLE *name_table; + +} ACPI_SCOPE_STATE; + + +typedef union acpi_gen_state +{ + ACPI_COMMON_STATE common; + ACPI_CONTROL_STATE control; + ACPI_UPDATE_STATE update; + ACPI_SCOPE_STATE scope; + +} ACPI_GENERIC_STATE; + + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through + * the tree (for whatever reason), and for control method execution. + */ + +#define NEXT_OP_DOWNWARD 1 +#define NEXT_OP_UPWARD 2 + +typedef struct acpi_walk_state +{ + u8 data_type; /* To differentiate various internal objs */\ + ACPI_OWNER_ID owner_id; /* Owner of objects created during the walk */ + u8 last_predicate; /* Result of last predicate */ + u8 next_op_info; /* Info about Next_op */ + u8 num_operands; /* Stack pointer for Operands[] array */ + u8 num_results; /* Stack pointer for Results[] array */ + u8 current_result; /* */ + + struct acpi_walk_state *next; /* Next Walk_state in list */ + ACPI_GENERIC_OP *origin; /* Start of walk */ + ACPI_GENERIC_OP *prev_op; /* Last op that was processed */ + ACPI_GENERIC_OP *next_op; /* next op to be processed */ + ACPI_GENERIC_STATE *control_state; /* List of control states (nested IFs) */ + ACPI_GENERIC_STATE *scope_info; /* Stack of nested scopes */ + union acpi_obj_internal *return_desc; /* Return object, if any */ + union acpi_obj_internal *method_desc; /* Method descriptor if running a method */ + ACPI_GENERIC_OP *method_call_op; /* Method_call Op if running a method */ + union acpi_obj_internal *operands[OBJ_NUM_OPERANDS]; /* Operands passed to the interpreter */ + union acpi_obj_internal *results[OBJ_NUM_OPERANDS]; /* Accumulated results */ + struct acpi_named_object arguments[MTH_NUM_ARGS]; /* Control method arguments */ + struct acpi_named_object local_variables[MTH_NUM_LOCALS]; /* Control method locals */ + + +} ACPI_WALK_STATE; + + +/* + * Walk list - head of a tree of walk states. Multiple walk states are created when there + * are nested control methods executing. + */ +typedef struct acpi_walk_list +{ + + ACPI_WALK_STATE *walk_state; + +} ACPI_WALK_LIST; + + +typedef +ACPI_STATUS (*INTERPRETER_CALLBACK) ( + ACPI_WALK_STATE *state, + ACPI_GENERIC_OP *op); + + +/* Info used by Acpi_ps_init_objects */ + +typedef struct init_walk_info +{ + u32 method_count; + u32 op_region_count; + ACPI_TABLE_DESC *table_desc; + +} INIT_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + u32 debug_level; + u32 owner_id; + +} ACPI_WALK_INFO; + + +/***************************************************************************** + * + * Hardware and PNP + * + ****************************************************************************/ + + +/* Sleep states */ + +#define SLWA_DEBUG_LEVEL 4 +#define GTS_CALL 0 +#define GTS_WAKE 1 + +/* Cx States */ + +#define MAX_CX_STATE_LATENCY 0xFFFFFFFF +#define MAX_CX_STATES 4 + +/* + * The #define's and enum below establish an abstract way of identifying what + * register block and register is to be accessed. Do not change any of the + * values as they are used in switch statements and offset calculations. + */ + +#define REGISTER_BLOCK_MASK 0xFF00 +#define BIT_IN_REGISTER_MASK 0x00FF +#define PM1_EVT 0x0100 +#define PM1_CONTROL 0x0200 +#define PM2_CONTROL 0x0300 +#define PM_TIMER 0x0400 +#define PROCESSOR_BLOCK 0x0500 +#define GPE0_STS_BLOCK 0x0600 +#define GPE0_EN_BLOCK 0x0700 +#define GPE1_STS_BLOCK 0x0800 +#define GPE1_EN_BLOCK 0x0900 + +enum +{ + /* PM1 status register ids */ + + TMR_STS = (PM1_EVT | 0x01), + BM_STS, + GBL_STS, + PWRBTN_STS, + SLPBTN_STS, + RTC_STS, + WAK_STS, + + /* PM1 enable register ids */ + + TMR_EN, + /* need to skip 1 enable number since there's no bus master enable register */ + GBL_EN = (PM1_EVT | 0x0A), + PWRBTN_EN, + SLPBTN_EN, + RTC_EN, + + /* PM1 control register ids */ + + SCI_EN = (PM1_CONTROL | 0x01), + BM_RLD, + GBL_RLS, + SLP_TYPE_A, + SLP_TYPE_B, + SLP_EN, + + /* PM2 control register ids */ + + ARB_DIS = (PM2_CONTROL | 0x01), + + /* PM Timer register ids */ + + TMR_VAL = (PM_TIMER | 0x01), + + GPE0_STS = (GPE0_STS_BLOCK | 0x01), + GPE0_EN = (GPE0_EN_BLOCK | 0x01), + + GPE1_STS = (GPE1_STS_BLOCK | 0x01), + GPE1_EN = (GPE0_EN_BLOCK | 0x01), + + /* Last register value is one less than LAST_REG */ + + LAST_REG +}; + + +#define TMR_STS_MASK 0x0001 +#define BM_STS_MASK 0x0010 +#define GBL_STS_MASK 0x0020 +#define PWRBTN_STS_MASK 0x0100 +#define SLPBTN_STS_MASK 0x0200 +#define RTC_STS_MASK 0x0400 +#define WAK_STS_MASK 0x8000 + +#define ALL_FIXED_STS_BITS (TMR_STS_MASK | BM_STS_MASK | GBL_STS_MASK | PWRBTN_STS_MASK | \ + SLPBTN_STS_MASK | RTC_STS_MASK | WAK_STS_MASK) + +#define TMR_EN_MASK 0x0001 +#define GBL_EN_MASK 0x0020 +#define PWRBTN_EN_MASK 0x0100 +#define SLPBTN_EN_MASK 0x0200 +#define RTC_EN_MASK 0x0400 + +#define SCI_EN_MASK 0x0001 +#define BM_RLD_MASK 0x0002 +#define GBL_RLS_MASK 0x0004 +#define SLP_TYPE_X_MASK 0x1C00 +#define SLP_EN_MASK 0x2000 + +#define ARB_DIS_MASK 0x0001 + +#define GPE0_STS_MASK +#define GPE0_EN_MASK + +#define GPE1_STS_MASK +#define GPE1_EN_MASK + + +#define ACPI_READ 1 +#define ACPI_WRITE 2 + +#define LOW_BYTE 0x00FF +#define ONE_BYTE 0x08 + +#ifndef SET + #define SET 1 +#endif +#ifndef CLEAR + #define CLEAR 0 +#endif + + +/* Plug and play */ + +/* Pnp and ACPI data */ + +#define VERSION_NO 0x01 +#define LOGICAL_DEVICE_ID 0x02 +#define COMPATIBLE_DEVICE_ID 0x03 +#define IRQ_FORMAT 0x04 +#define DMA_FORMAT 0x05 +#define START_DEPENDENT_TAG 0x06 +#define END_DEPENDENT_TAG 0x07 +#define IO_PORT_DESCRIPTOR 0x08 +#define FIXED_LOCATION_IO_DESCRIPTOR 0x09 +#define RESERVED_TYPE0 0x0A +#define RESERVED_TYPE1 0x0B +#define RESERVED_TYPE2 0x0C +#define RESERVED_TYPE3 0x0D +#define SMALL_VENDOR_DEFINED 0x0E +#define END_TAG 0x0F + +/* Pnp and ACPI data */ + +#define MEMORY_RANGE_24 0x81 +#define ISA_MEMORY_RANGE 0x81 +#define LARGE_VENDOR_DEFINED 0x84 +#define EISA_MEMORY_RANGE 0x85 +#define MEMORY_RANGE_32 0x85 +#define FIXED_EISA_MEMORY_RANGE 0x86 +#define FIXED_MEMORY_RANGE_32 0x86 + +/* ACPI only data */ + +#define DWORD_ADDRESS_SPACE 0x87 +#define WORD_ADDRESS_SPACE 0x88 +#define EXTENDED_IRQ 0x89 + +/* MUST HAVES */ + + +typedef enum +{ + DWORD_DEVICE_ID, + STRING_PTR_DEVICE_ID, + STRING_DEVICE_ID + +} DEVICE_ID_TYPE; + +typedef struct +{ + DEVICE_ID_TYPE type; + union + { + u32 number; + char *string_ptr; + char buffer[9]; + } data; + +} DEVICE_ID; + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + + +/* Entry for a memory allocation (debug only) */ + +#ifdef ACPI_DEBUG + +#define MEM_MALLOC 0 +#define MEM_CALLOC 1 +#define MAX_MODULE_NAME 16 + +typedef struct allocation_info +{ + struct allocation_info *previous; + struct allocation_info *next; + void *address; + u32 size; + u32 component; + u32 line; + char module[MAX_MODULE_NAME]; + u8 alloc_type; + +} ALLOCATION_INFO; + +#endif + +#endif diff --git a/drivers/acpi/include/interp.h b/drivers/acpi/include/interp.h new file mode 100644 index 000000000..75db528da --- /dev/null +++ b/drivers/acpi/include/interp.h @@ -0,0 +1,660 @@ + +/****************************************************************************** + * + * Name: interp.h - Interpreter subcomponent prototypes and defines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __INTERP_H__ +#define __INTERP_H__ + + +#include "actypes.h" +#include "acobject.h" + + +#define WALK_OPERANDS &(walk_state->operands [walk_state->num_operands -1]) + + +/* Interpreter constants */ + +#define AML_END_OF_BLOCK -1 +#define PUSH_PKG_LENGTH 1 +#define DO_NOT_PUSH_PKG_LENGTH 0 + + +#define STACK_TOP 0 +#define STACK_BOTTOM (u32) -1 + +/* Constants for global "When_to_parse_methods" */ + +#define METHOD_PARSE_AT_INIT 0x0 +#define METHOD_PARSE_JUST_IN_TIME 0x1 +#define METHOD_DELETE_AT_COMPLETION 0x2 + + +ACPI_STATUS +acpi_aml_resolve_operands ( + u16 opcode, + ACPI_OBJECT_INTERNAL **stack_ptr); + + +/* + * amxface - External interpreter interfaces + */ + +ACPI_STATUS +acpi_aml_load_table ( + ACPI_TABLE_TYPE table_id); + +ACPI_STATUS +acpi_aml_execute_method ( + ACPI_NAMED_OBJECT *method_entry, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_obj_desc); + + +/* + * amcopy - Interpreter object copy support + */ + +ACPI_STATUS +acpi_aml_build_copy_internal_package_object ( + ACPI_OBJECT_INTERNAL *source_obj, + ACPI_OBJECT_INTERNAL *dest_obj); + + +/* + * amfield - ACPI AML (p-code) execution - field manipulation + */ + + +ACPI_STATUS +acpi_aml_read_field ( + ACPI_OBJECT_INTERNAL *obj_desc, + void *buffer, + u32 buffer_length, + u32 byte_length, + u32 datum_length, + u32 bit_granularity, + u32 byte_granularity); + +ACPI_STATUS +acpi_aml_write_field ( + ACPI_OBJECT_INTERNAL *obj_desc, + void *buffer, + u32 buffer_length, + u32 byte_length, + u32 datum_length, + u32 bit_granularity, + u32 byte_granularity); + +ACPI_STATUS +acpi_aml_setup_field ( + ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_OBJECT_INTERNAL *rgn_desc, + s32 field_bit_width); + +ACPI_STATUS +acpi_aml_read_field_data ( + ACPI_OBJECT_INTERNAL *obj_desc, + u32 field_byte_offset, + u32 field_bit_width, + u32 *value); + +ACPI_STATUS +acpi_aml_access_named_field ( + s32 mode, + ACPI_HANDLE named_field, + void *buffer, + u32 length); + +ACPI_STATUS +acpi_aml_set_named_field_value ( + ACPI_HANDLE named_field, + void *buffer, + u32 length); + +ACPI_STATUS +acpi_aml_get_named_field_value ( + ACPI_HANDLE named_field, + void *buffer, + u32 length); + + +/* + * ammisc - ACPI AML (p-code) execution - specific opcodes + */ + +ACPI_STATUS +acpi_aml_exec_create_field ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_reconfiguration ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_fatal ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_index ( + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + +ACPI_STATUS +acpi_aml_exec_match ( + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + +ACPI_STATUS +acpi_aml_exec_create_mutex ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_processor ( + ACPI_GENERIC_OP *op, + ACPI_HANDLE processor_nTE); + +ACPI_STATUS +acpi_aml_exec_create_power_resource ( + ACPI_GENERIC_OP *op, + ACPI_HANDLE processor_nTE); + +ACPI_STATUS +acpi_aml_exec_create_region ( + u8 *aml_ptr, + u32 acpi_aml_length, + u32 region_space, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_event ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_alias ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_create_method ( + u8 *aml_ptr, + u32 acpi_aml_length, + u32 method_flags, + ACPI_HANDLE method); + + +/* + * amprep - ACPI AML (p-code) execution - prep utilities + */ + +ACPI_STATUS +acpi_aml_prep_def_field_value ( + ACPI_NAMED_OBJECT *this_entry, + ACPI_HANDLE region, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + +ACPI_STATUS +acpi_aml_prep_bank_field_value ( + ACPI_NAMED_OBJECT *this_entry, + ACPI_HANDLE region, + ACPI_HANDLE bank_reg, + u32 bank_val, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + +ACPI_STATUS +acpi_aml_prep_index_field_value ( + ACPI_NAMED_OBJECT *this_entry, + ACPI_HANDLE index_reg, + ACPI_HANDLE data_reg, + u8 field_flags, + u8 field_attribute, + u32 field_position, + u32 field_length); + +ACPI_STATUS +acpi_aml_prep_operands ( + char *types, + ACPI_OBJECT_INTERNAL **stack_ptr); + + +/* + * iepstack - package stack utilities + */ + +/* +u32 +Acpi_aml_pkg_stack_level ( + void); + +void +Acpi_aml_clear_pkg_stack ( + void); + +ACPI_STATUS +Acpi_aml_pkg_push_length ( + u32 Length, + OPERATING_MODE Load_exec_mode); + +ACPI_STATUS +Acpi_aml_pkg_push_exec_length ( + u32 Length); + +ACPI_STATUS +Acpi_aml_pkg_push_exec ( + u8 *Code, + u32 Len); + +ACPI_STATUS +Acpi_aml_pkg_pop_length ( + s32 No_err_under, + OPERATING_MODE Load_exec_mode); + +ACPI_STATUS +Acpi_aml_pkg_pop_exec_length ( + void); + +ACPI_STATUS +Acpi_aml_pkg_pop_exec ( + void); + +*/ + +/* + * amsystem - Interface to OS services + */ + +u16 +acpi_aml_system_thread_id ( + void); + +ACPI_STATUS +acpi_aml_system_do_notify_op ( + ACPI_OBJECT_INTERNAL *value, + ACPI_OBJECT_INTERNAL *obj_desc); + +void +acpi_aml_system_do_suspend( + u32 time); + +void +acpi_aml_system_do_stall ( + u32 time); + +ACPI_STATUS +acpi_aml_system_acquire_mutex( + ACPI_OBJECT_INTERNAL *time, + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_aml_system_release_mutex( + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_aml_system_signal_event( + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_aml_system_wait_event( + ACPI_OBJECT_INTERNAL *time, + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_aml_system_reset_event( + ACPI_OBJECT_INTERNAL *obj_desc); + +ACPI_STATUS +acpi_aml_system_wait_semaphore ( + ACPI_HANDLE semaphore, + u32 timeout); + + +/* + * ammonadic - ACPI AML (p-code) execution, monadic operators + */ + +ACPI_STATUS +acpi_aml_exec_monadic1 ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_monadic2 ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + +ACPI_STATUS +acpi_aml_exec_monadic2_r ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + + +/* + * amdyadic - ACPI AML (p-code) execution, dyadic operators + */ + +ACPI_STATUS +acpi_aml_exec_dyadic1 ( + u16 opcode, + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_aml_exec_dyadic2 ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + +ACPI_STATUS +acpi_aml_exec_dyadic2_r ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + +ACPI_STATUS +acpi_aml_exec_dyadic2_s ( + u16 opcode, + ACPI_WALK_STATE *walk_state, + ACPI_OBJECT_INTERNAL **return_desc); + + +/* + * amresolv - Object resolution and get value functions + */ + +ACPI_STATUS +acpi_aml_resolve_to_value ( + ACPI_OBJECT_INTERNAL **stack_ptr); + +ACPI_STATUS +acpi_aml_resolve_entry_to_value ( + ACPI_NAMED_OBJECT **stack_ptr); + +ACPI_STATUS +acpi_aml_resolve_object_to_value ( + ACPI_OBJECT_INTERNAL **stack_ptr); + +ACPI_STATUS +acpi_aml_get_field_unit_value ( + ACPI_OBJECT_INTERNAL *field_desc, + ACPI_OBJECT_INTERNAL *result_desc); + + +/* + * amcode - Scanner AML code manipulation routines + */ + +s32 +acpi_aml_avail ( + ACPI_SIZE n); + +s32 +acpi_aml_peek ( + void); + +s32 +acpi_aml_get_pcode_byte ( + u8 *pcode); + +u16 +acpi_aml_peek_op ( + void); + +u8 * +acpi_aml_consume_bytes ( + ACPI_SIZE bytes); + +ACPI_SIZE +acpi_aml_consume_stream_bytes ( + ACPI_SIZE bytes_to_get, + u8 *aml_buffer); + +void +acpi_aml_consume_package ( + OPERATING_MODE load_exec_mode); + +void +acpi_aml_set_pcode_input ( + u8 *base, + u32 length); + +ACPI_STATUS +acpi_aml_set_method ( + void *object); + +ACPI_STATUS +acpi_aml_prep_exec ( + u8 *pcode, + u32 pcode_length); + +ACPI_HANDLE +acpi_aml_get_pcode_handle ( + void); + +void +acpi_aml_get_current_location ( + ACPI_OBJECT_INTERNAL *method_desc); + +void +acpi_aml_set_current_location ( + ACPI_OBJECT_INTERNAL *method_desc); + + +/* + * amdump - Scanner debug output routines + */ + +void +acpi_aml_show_hex_value ( + s32 byte_count, + u8 *aml_ptr, + s32 lead_space); + +void +acpi_aml_dump_buffer ( + ACPI_SIZE length); + + +ACPI_STATUS +acpi_aml_dump_operand ( + ACPI_OBJECT_INTERNAL *entry_desc); + +void +acpi_aml_dump_operands ( + ACPI_OBJECT_INTERNAL **operands, + OPERATING_MODE interpreter_mode, + char *ident, + s32 num_levels, + char *note, + char *module_name, + s32 line_number); + +void +acpi_aml_dump_object_descriptor ( + ACPI_OBJECT_INTERNAL *object, + u32 flags); + + +void +acpi_aml_dump_acpi_named_object ( + ACPI_NAMED_OBJECT *entry, + u32 flags); + + +/* + * amnames - interpreter/scanner name load/execute + */ + +char * +acpi_aml_allocate_name_string ( + u32 prefix_count, + u32 num_name_segs); + +s32 +acpi_aml_good_char ( + s32 character); + +ACPI_STATUS +acpi_aml_exec_name_segment ( + u8 **in_aml_address, + char *name_string); + +ACPI_STATUS +acpi_aml_get_name_string ( + OBJECT_TYPE_INTERNAL data_type, + u8 *in_aml_address, + char **out_name_string, + u32 *out_name_length); + +u32 +acpi_aml_decode_package_length ( + u32 last_pkg_len); + + +ACPI_STATUS +acpi_aml_do_name ( + ACPI_OBJECT_TYPE data_type, + OPERATING_MODE load_exec_mode); + + +/* + * amstore - Object store support + */ + +ACPI_STATUS +acpi_aml_exec_store ( + ACPI_OBJECT_INTERNAL *op1, + ACPI_OBJECT_INTERNAL *res); + +ACPI_STATUS +acpi_aml_store_object_to_object ( + ACPI_OBJECT_INTERNAL *val_desc, + ACPI_OBJECT_INTERNAL *dest_desc); + +ACPI_STATUS +acpi_aml_store_object_to_nte ( + ACPI_OBJECT_INTERNAL *val_desc, + ACPI_NAMED_OBJECT *entry); + + +/* + * amutils - interpreter/scanner utilities + */ + +void +acpi_aml_enter_interpreter ( + void); + +void +acpi_aml_exit_interpreter ( + void); + +u8 +acpi_aml_validate_object_type ( + ACPI_OBJECT_TYPE type); + +u8 +acpi_aml_acquire_global_lock ( + u32 rule); + +ACPI_STATUS +acpi_aml_release_global_lock ( + u8 locked); + +void +acpi_aml_append_operand_diag( + char *name, + s32 line, + u16 op_code, + ACPI_OBJECT_INTERNAL **operands, + s32 Noperands); + +u32 +acpi_aml_buf_seq ( + void); + +s32 +acpi_aml_digits_needed ( + s32 value, + s32 base); + +ACPI_STATUS +acpi_aml_eisa_id_to_string ( + u32 numeric_id, + char *out_string); + + +/* + * amregion - default Op_region handlers + */ + +ACPI_STATUS +acpi_aml_system_memory_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + +ACPI_STATUS +acpi_aml_system_io_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + +ACPI_STATUS +acpi_aml_pci_config_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + +ACPI_STATUS +acpi_aml_embedded_controller_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + +ACPI_STATUS +acpi_aml_sm_bus_space_handler ( + u32 function, + u32 address, + u32 bit_width, + u32 *value, + void *context); + + +#endif /* __INTERP_H__ */ diff --git a/drivers/acpi/include/macros.h b/drivers/acpi/include/macros.h new file mode 100644 index 000000000..7584ee8fa --- /dev/null +++ b/drivers/acpi/include/macros.h @@ -0,0 +1,423 @@ + +/****************************************************************************** + * + * Name: macros.h - C macros for the entire subsystem. + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MACROS_H__ +#define __MACROS_H__ + +/* + * Data manipulation macros + */ + +#ifndef LOWORD +#define LOWORD(l) ((u16)(NATIVE_UINT)(l)) +#endif + +#ifndef HIWORD +#define HIWORD(l) ((u16)((((NATIVE_UINT)(l)) >> 16) & 0xFFFF)) +#endif + +#ifndef LOBYTE +#define LOBYTE(l) ((u8)(u16)(l)) +#endif + +#ifndef HIBYTE +#define HIBYTE(l) ((u8)((((u16)(l)) >> 8) & 0xFF)) +#endif + +#define BIT0(x) ((((x) & 0x01) > 0) ? 1 : 0) +#define BIT1(x) ((((x) & 0x02) > 0) ? 1 : 0) +#define BIT2(x) ((((x) & 0x04) > 0) ? 1 : 0) + +#define BIT3(x) ((((x) & 0x08) > 0) ? 1 : 0) +#define BIT4(x) ((((x) & 0x10) > 0) ? 1 : 0) +#define BIT5(x) ((((x) & 0x20) > 0) ? 1 : 0) +#define BIT6(x) ((((x) & 0x40) > 0) ? 1 : 0) +#define BIT7(x) ((((x) & 0x80) > 0) ? 1 : 0) + +#define LOW_BASE(w) ((u16) ((w) & 0x0000FFFF)) +#define MID_BASE(b) ((u8) (((b) & 0x00FF0000) >> 16)) +#define HI_BASE(b) ((u8) (((b) & 0xFF000000) >> 24)) +#define LOW_LIMIT(w) ((u16) ((w) & 0x0000FFFF)) +#define HI_LIMIT(b) ((u8) (((b) & 0x00FF0000) >> 16)) + + + /* + * Extract a byte of data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below + */ +#define GET8(addr) (*(u8*)(addr)) + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ + +#ifdef _HW_ALIGNMENT_SUPPORT + +/* The hardware supports unaligned transfers, just do the move */ + +#define MOVE_UNALIGNED16_TO_16(d,s) *(u16*)(d) = *(u16*)(s) +#define MOVE_UNALIGNED32_TO_32(d,s) *(u32*)(d) = *(u32*)(s) +#define MOVE_UNALIGNED16_TO_32(d,s) *(u32*)(d) = *(u16*)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. + */ + +#define MOVE_UNALIGNED16_TO_16(d,s) {((char *)(d))[0] = ((char *)(s))[0];\ + ((char *)(d))[1] = ((char *)(s))[1];} + +#define MOVE_UNALIGNED32_TO_32(d,s) {((char *)(d))[0] = ((char *)(s))[0];\ + ((char *)(d))[1] = ((char *)(s))[1];\ + ((char *)(d))[2] = ((char *)(s))[2];\ + ((char *)(d))[3] = ((char *)(s))[3];} + +#define MOVE_UNALIGNED16_TO_32(d,s) {(*(u32*)(d)) = 0; MOVE_UNALIGNED16_TO_16(d,s);} + +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ + +#define _DIV(value,power_of2) ((value) >> (power_of2)) +#define _MUL(value,power_of2) ((value) << (power_of2)) +#define _MOD(value,divisor) ((value) & ((divisor) -1)) + +#define DIV_2(a) _DIV(a,1) +#define MUL_2(a) _MUL(a,1) +#define MOD_2(a) _MOD(a,2) + +#define DIV_4(a) _DIV(a,2) +#define MUL_4(a) _MUL(a,2) +#define MOD_4(a) _MOD(a,4) + +#define DIV_8(a) _DIV(a,3) +#define MUL_8(a) _MUL(a,3) +#define MOD_8(a) _MOD(a,8) + +#define DIV_16(a) _DIV(a,4) +#define MUL_16(a) _MUL(a,4) +#define MOD_16(a) _MOD(a,16) + + +/* + * Rounding macros (Power of two boundaries only) + */ + +#define ROUND_DOWN(value,boundary) ((value) & (~((boundary)-1))) +#define ROUND_UP(value,boundary) (((value) + ((boundary)-1)) & (~((boundary)-1))) + +#define ROUND_DOWN_TO_32_BITS(a) ROUND_DOWN(a,4) +#define ROUND_DOWN_TO_NATIVE_WORD(a) ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY) + +#define ROUND_UP_TO_32_bITS(a) ROUND_UP(a,4) +#define ROUND_UP_TO_NATIVE_WORD(a) ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY) + + +#ifdef DEBUG_ASSERT +#undef DEBUG_ASSERT +#endif + + +/* + * An ACPI_HANDLE (which is actually an ACPI_NAMED_OBJECT*) can appear in some contexts, + * such as on ap_obj_stack, where a pointer to an ACPI_OBJECT_INTERNAL can also + * appear. This macro is used to distinguish them. + * + * The Data_type field is the first field in both structures. + */ + +#define VALID_DESCRIPTOR_TYPE(d,t) (((ACPI_NAMED_OBJECT*)d)->data_type == t) + + +/* Macro to test the object type */ + +#define IS_THIS_OBJECT_TYPE(d,t) (((ACPI_OBJECT_INTERNAL *)d)->common.type == (u8)t) + + +/* + * Macro to check if a pointer is within an ACPI table. + * Parameter (a) is the pointer to check. Parameter (b) must be defined + * as a pointer to an ACPI_TABLE_HEADER. (b+1) then points past the header, + * and ((u8 *)b+b->Length) points one byte past the end of the table. + */ + +#ifndef _IA16 +#define IS_IN_ACPI_TABLE(a,b) (((u8 *)(a) >= (u8 *)(b + 1)) &&\ + ((u8 *)(a) < ((u8 *)b + b->length))) + +#else +#define IS_IN_ACPI_TABLE(a,b) (_segment)(a) == (_segment)(b) &&\ + (((u8 *)(a) >= (u8 *)(b + 1)) &&\ + ((u8 *)(a) < ((u8 *)b + b->length))) +#endif + +/* + * Macros for the master AML opcode table + */ + +#ifdef ACPI_DEBUG +#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs,name} +#else +#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((u32)(x)) +#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(list) (list & 0x1F) +#define INCREMENT_ARG_LIST(list) (list >>= ARG_TYPE_WIDTH) + + +/* + * Reporting macros that are never compiled out + */ + +/* + * Error reporting. These versions add callers module and line#. Since + * _THIS_MODULE gets compiled out when ACPI_DEBUG isn't defined, only + * use it in debug mode. + */ + +#ifdef ACPI_DEBUG + +#define REPORT_INFO(a) _report_info(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define REPORT_ERROR(a) _report_error(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define REPORT_WARNING(a) _report_warning(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define REPORT_SUCCESS(a) _report_success(_THIS_MODULE,__LINE__,_COMPONENT,a) + +#else + +#define REPORT_INFO(a) _report_info("",__LINE__,_COMPONENT,a) +#define REPORT_ERROR(a) _report_error("",__LINE__,_COMPONENT,a) +#define REPORT_WARNING(a) _report_warning("",__LINE__,_COMPONENT,a) +#define REPORT_SUCCESS(a) _report_success("",__LINE__,_COMPONENT,a) + +#endif + +/* Error reporting. These versions pass thru the module and line# */ + +#define _REPORT_INFO(a,b,c,d) _report_info(a,b,c,d) +#define _REPORT_ERROR(a,b,c,d) _report_error(a,b,c,d) +#define _REPORT_WARNING(a,b,c,d) _report_warning(a,b,c,d) + +/* Buffer dump macros */ + +#define DUMP_BUFFER(a,b) acpi_cm_dump_buffer((char *)a,b,DB_BYTE_DISPLAY,_COMPONENT) + +/* + * Debug macros that are conditionally compiled + */ + +#ifdef ACPI_DEBUG + +#define MODULE_NAME(name) static char *_THIS_MODULE = name + +/* + * Function entry tracing. + * The first parameter should be the procedure name as a quoted string. This is declared + * as a local string ("_Proc_name) so that it can be also used by the function exit macros below. + */ + +#define FUNCTION_TRACE(a) char * _proc_name = a;\ + function_trace(_THIS_MODULE,__LINE__,_COMPONENT,a) +#define FUNCTION_TRACE_PTR(a,b) char * _proc_name = a;\ + function_trace_ptr(_THIS_MODULE,__LINE__,_COMPONENT,a,(void *)b) +#define FUNCTION_TRACE_U32(a,b) char * _proc_name = a;\ + function_trace_u32(_THIS_MODULE,__LINE__,_COMPONENT,a,(u32)b) +#define FUNCTION_TRACE_STR(a,b) char * _proc_name = a;\ + function_trace_str(_THIS_MODULE,__LINE__,_COMPONENT,a,(char *)b) +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_Proc_name" is defined. + */ +#define return_VOID {function_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name);return;} +#define return_ACPI_STATUS(s) {function_status_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,s);return(s);} +#define return_VALUE(s) {function_value_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(NATIVE_UINT)s);return(s);} +#define return_PTR(s) {function_ptr_exit(_THIS_MODULE,__LINE__,_COMPONENT,_proc_name,(char *)s);return(s);} + + +/* Conditional execution */ + +#define DEBUG_EXEC(a) a; +#define NORMAL_EXEC(a) + +#define DEBUG_DEFINE(a) a; +#define DEBUG_ONLY_MEMBERS(a) a; + + +/* Stack and buffer dumping */ + +#define DUMP_STACK_ENTRY(a) acpi_aml_dump_operand(a) +#define DUMP_OPERANDS(a,b,c,d,e) acpi_aml_dump_operands(a,b,c,d,e,_THIS_MODULE,__LINE__) + + +#define DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b) +#define DUMP_TABLES(a,b) acpi_ns_dump_tables(a,b) +#define DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d) +#define BREAK_MSG(a) acpi_os_breakpoint (a) + +/* + * Generate INT3 on ACPI_ERROR (Debug only!) + */ + +#define ERROR_BREAK +#ifdef ERROR_BREAK +#define BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) acpi_os_breakpoint("Fatal error encountered\n") +#else +#define BREAK_ON_ERROR(lvl) +#endif + +/* + * Master debug print macros + * Print iff: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + * + */ + +#define PARAM_LIST(pl) pl + +#define TEST_DEBUG_SWITCH(lvl) if (((lvl) & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer)) + +#define DEBUG_PRINT(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + debug_print_prefix (_THIS_MODULE,__LINE__);\ + debug_print_raw PARAM_LIST(fp);\ + BREAK_ON_ERROR(lvl);} + +#define DEBUG_PRINT_RAW(lvl,fp) TEST_DEBUG_SWITCH(lvl) {\ + debug_print_raw PARAM_LIST(fp);} + + +/* Assert macros */ + +#define ACPI_ASSERT(exp) if(!(exp)) \ + acpi_os_dbg_assert(#exp, __FILE__, __LINE__, "Failed Assertion") + +#define DEBUG_ASSERT(msg, exp) if(!(exp)) \ + acpi_os_dbg_assert(#exp, __FILE__, __LINE__, msg) + + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ + +#define MODULE_NAME(name) +#define _THIS_MODULE "" + +#define DEBUG_EXEC(a) +#define NORMAL_EXEC(a) a; + +#define DEBUG_DEFINE(a) +#define DEBUG_ONLY_MEMBERS(a) +#define FUNCTION_TRACE(a) +#define FUNCTION_TRACE_PTR(a,b) +#define FUNCTION_TRACE_U32(a,b) +#define FUNCTION_TRACE_STR(a,b) +#define FUNCTION_EXIT +#define FUNCTION_STATUS_EXIT(s) +#define FUNCTION_VALUE_EXIT(s) +#define DUMP_STACK_ENTRY(a) +#define DUMP_OPERANDS(a,b,c,d,e) +#define DUMP_ENTRY(a,b) +#define DUMP_TABLES(a,b) +#define DUMP_PATHNAME(a,b,c,d) +#define DEBUG_PRINT(l,f) +#define DEBUG_PRINT_RAW(l,f) +#define BREAK_MSG(a) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_PTR(s) return(s) + +#define ACPI_ASSERT(exp) +#define DEBUG_ASSERT(msg, exp) + +#endif + + +/* + * For 16-bit code, we want to shrink some things even though + * we are using ACPI_DEBUG to get the debug output + */ +#ifdef _IA16 +#undef DEBUG_ONLY_MEMBERS +#define DEBUG_ONLY_MEMBERS(a) +#undef OP_INFO_ENTRY +#define OP_INFO_ENTRY(opcode,flags,name,Pargs,Iargs) {opcode,flags,Pargs,Iargs} +#endif + + +#ifndef ACPI_DEBUG + +#define ADD_OBJECT_NAME(a,b) + +#else + + +/* + * 1) Set name to blanks + * 2) Copy the object name + */ + +#define ADD_OBJECT_NAME(a,b) MEMSET (a->common.name, ' ', sizeof (a->common.name));\ + STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name)) + +#endif + + +#endif /* MACROS_H */ diff --git a/drivers/acpi/include/namesp.h b/drivers/acpi/include/namesp.h new file mode 100644 index 000000000..378b8a8c8 --- /dev/null +++ b/drivers/acpi/include/namesp.h @@ -0,0 +1,424 @@ + +/****************************************************************************** + * + * Name: namesp.h - Namespace subcomponent prototypes and defines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __NAMESPACE_H__ +#define __NAMESPACE_H__ + +#include "actables.h" + + +/* To search the entire name space, pass this as Search_base */ + +#define NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of Acpi_ns_properties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define NSP_NORMAL 0 +#define NSP_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define NSP_LOCAL 2 /* suppress search of enclosing scopes */ + + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (u32) 0x2F202020 /* Root name is "/ " */ +#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */ + +#define NS_ROOT_PATH "/" +#define NS_SYSTEM_BUS "_SB_" + + +/* Flags for Acpi_ns_lookup, Acpi_ns_search_and_enter */ + +#define NS_NO_UPSEARCH 0 +#define NS_SEARCH_PARENT 0x01 +#define NS_DONT_OPEN_SCOPE 0x02 +#define NS_NO_PEER_SEARCH 0x04 + +#define NS_WALK_UNLOCK TRUE +#define NS_WALK_NO_UNLOCK FALSE + + +ACPI_STATUS +acpi_ns_walk_namespace ( + OBJECT_TYPE_INTERNAL type, + ACPI_HANDLE start_object, + u32 max_depth, + u8 unlock_before_callback, + WALK_CALLBACK user_function, + void *context, + void **return_value); + + +ACPI_NAMED_OBJECT* +acpi_ns_get_next_object ( + OBJECT_TYPE_INTERNAL type, + ACPI_NAMED_OBJECT *parent, + ACPI_NAMED_OBJECT *child); + + +ACPI_STATUS +acpi_ns_delete_namespace_by_owner ( + u16 table_id); + +void +acpi_ns_free_table_entry ( + ACPI_NAMED_OBJECT *entry); + + +/* Namespace loading - nsload */ + +ACPI_STATUS +acpi_ns_parse_table ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAME_TABLE *scope); + +ACPI_STATUS +acpi_ns_load_table ( + ACPI_TABLE_DESC *table_desc, + ACPI_NAMED_OBJECT *entry); + +ACPI_STATUS +acpi_ns_load_table_by_type ( + ACPI_TABLE_TYPE table_type); + + +/* + * Top-level namespace access - nsaccess + */ + + +ACPI_STATUS +acpi_ns_root_initialize ( + void); + +ACPI_STATUS +acpi_ns_lookup ( + ACPI_GENERIC_STATE *scope_info, + char *name, + OBJECT_TYPE_INTERNAL type, + OPERATING_MODE interpreter_mode, + u32 flags, + ACPI_WALK_STATE *walk_state, + ACPI_NAMED_OBJECT **ret_entry); + + +/* + * Table allocation/deallocation - nsalloc + */ + +ACPI_NAME_TABLE * +acpi_ns_allocate_name_table ( + u32 num_entries); + +ACPI_STATUS +acpi_ns_delete_namespace_subtree ( + ACPI_NAMED_OBJECT *parent_handle); + +void +acpi_ns_detach_object ( + ACPI_HANDLE object); + +void +acpi_ns_delete_name_table ( + ACPI_NAME_TABLE *name_table); + + +/* + * Namespace modification - nsmodify + */ + +ACPI_STATUS +acpi_ns_unload_namespace ( + ACPI_HANDLE handle); + +ACPI_STATUS +acpi_ns_delete_subtree ( + ACPI_HANDLE start_handle); + + +/* + * Namespace dump/print utilities - nsdump + */ + +void +acpi_ns_dump_tables ( + ACPI_HANDLE search_base, + s32 max_depth); + +void +acpi_ns_dump_entry ( + ACPI_HANDLE handle, + u32 debug_level); + +ACPI_STATUS +acpi_ns_dump_pathname ( + ACPI_HANDLE handle, + char *msg, + u32 level, + u32 component); + +void +acpi_ns_dump_root_devices ( + void); + +void +acpi_ns_dump_objects ( + OBJECT_TYPE_INTERNAL type, + u32 max_depth, + u32 ownder_id, + ACPI_HANDLE start_handle); + + +/* + * Namespace evaluation functions - nseval + */ + +ACPI_STATUS +acpi_ns_evaluate_by_handle ( + ACPI_NAMED_OBJECT *object_nte, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_object); + +ACPI_STATUS +acpi_ns_evaluate_by_name ( + char *pathname, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_object); + +ACPI_STATUS +acpi_ns_evaluate_relative ( + ACPI_NAMED_OBJECT *object_nte, + char *pathname, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_object); + +ACPI_STATUS +acpi_ns_execute_control_method ( + ACPI_NAMED_OBJECT *method_entry, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_obj_desc); + +ACPI_STATUS +acpi_ns_get_object_value ( + ACPI_NAMED_OBJECT *object_entry, + ACPI_OBJECT_INTERNAL **return_obj_desc); + + +/* + * Parent/Child/Peer utility functions - nsfamily + */ + +ACPI_NAME +acpi_ns_find_parent_name ( + ACPI_NAMED_OBJECT *entry_to_search); + +u8 +acpi_ns_exist_downstream_sibling ( + ACPI_NAMED_OBJECT *this_entry); + + +/* + * Scope manipulation - nsscope + */ + +s32 +acpi_ns_opens_scope ( + OBJECT_TYPE_INTERNAL type); + +char * +acpi_ns_name_of_scope ( + ACPI_NAME_TABLE *scope); + +char * +acpi_ns_name_of_current_scope ( + ACPI_WALK_STATE *walk_state); + +ACPI_STATUS +acpi_ns_handle_to_pathname ( + ACPI_HANDLE obj_handle, + u32 *buf_size, + char *user_buffer); + +u8 +acpi_ns_pattern_match ( + ACPI_NAMED_OBJECT *obj_entry, + char *search_for); + +ACPI_STATUS +acpi_ns_name_compare ( + ACPI_HANDLE obj_handle, + u32 level, + void *context, + void **return_value); + +void +acpi_ns_low_find_names ( + ACPI_NAMED_OBJECT *this_entry, + char *search_for, + s32 *count, + ACPI_HANDLE list[], + s32 max_depth); + +ACPI_HANDLE * +acpi_ns_find_names ( + char *search_for, + ACPI_HANDLE search_base, + s32 max_depth); + +ACPI_STATUS +acpi_ns_get_named_object ( + char *pathname, + ACPI_NAME_TABLE *in_scope, + ACPI_NAMED_OBJECT **out_nte); + +/* + * Object management for NTEs - nsobject + */ + +ACPI_STATUS +acpi_ns_attach_method ( + ACPI_HANDLE obj_handle, + u8 *pcode_addr, + u32 pcode_length); + +ACPI_STATUS +acpi_ns_attach_object ( + ACPI_HANDLE obj_handle, + ACPI_HANDLE value, + OBJECT_TYPE_INTERNAL type); + + +void * +acpi_ns_compare_value ( + ACPI_HANDLE obj_handle, + u32 level, + void *obj_desc); + +ACPI_HANDLE +acpi_ns_find_attached_object ( + ACPI_OBJECT_INTERNAL *obj_desc, + ACPI_HANDLE search_base, + s32 max_depth); + + +/* + * Namespace searching and entry - nssearch + */ + +ACPI_STATUS +acpi_ns_search_and_enter ( + u32 entry_name, + ACPI_WALK_STATE *walk_state, + ACPI_NAME_TABLE *name_table, + OPERATING_MODE interpreter_mode, + OBJECT_TYPE_INTERNAL type, + u32 flags, + ACPI_NAMED_OBJECT **ret_entry); + +void +acpi_ns_initialize_table ( + ACPI_NAME_TABLE *new_table, + ACPI_NAME_TABLE *parent_scope, + ACPI_NAMED_OBJECT *parent_entry); + +ACPI_STATUS +acpi_ns_search_one_scope ( + u32 entry_name, + ACPI_NAME_TABLE *name_table, + OBJECT_TYPE_INTERNAL type, + ACPI_NAMED_OBJECT **ret_entry, + NS_SEARCH_DATA *ret_info); + + +/* + * Utility functions - nsutils + */ + +u8 +acpi_ns_valid_root_prefix ( + char prefix); + +u8 +acpi_ns_valid_path_separator ( + char sep); + +OBJECT_TYPE_INTERNAL +acpi_ns_get_type ( + ACPI_HANDLE obj_handle); + +void * +acpi_ns_get_attached_object ( + ACPI_HANDLE obj_handle); + +s32 +acpi_ns_local ( + OBJECT_TYPE_INTERNAL type); + +ACPI_STATUS +acpi_ns_internalize_name ( + char *dotted_name, + char **converted_name); + +ACPI_STATUS +acpi_ns_externalize_name ( + u32 internal_name_length, + char *internal_name, + u32 *converted_name_length, + char **converted_name); + +s32 +is_ns_object ( + ACPI_OBJECT_INTERNAL *p_oD); + +s32 +acpi_ns_mark_nS( + void); + +ACPI_NAMED_OBJECT* +acpi_ns_convert_handle_to_entry ( + ACPI_HANDLE handle); + +ACPI_HANDLE +acpi_ns_convert_entry_to_handle( + ACPI_NAMED_OBJECT*nte); + +void +acpi_ns_terminate ( + void); + +ACPI_NAMED_OBJECT * +acpi_ns_get_parent_entry ( + ACPI_NAMED_OBJECT *this_entry); + + +ACPI_NAMED_OBJECT * +acpi_ns_get_next_valid_entry ( + ACPI_NAMED_OBJECT *this_entry); + + +#endif /* __NAMESPACE_H__ */ diff --git a/drivers/acpi/include/output.h b/drivers/acpi/include/output.h new file mode 100644 index 000000000..a3be12a38 --- /dev/null +++ b/drivers/acpi/include/output.h @@ -0,0 +1,124 @@ + +/****************************************************************************** + * + * Name: output.h -- debug output + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _OUTPUT_H +#define _OUTPUT_H + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the DEBUG_PRINT macro -- on a per- + * component basis and a per-exception-type basis. + */ + +/* Component IDs -- used in the global "Debug_layer" */ + +#define GLOBAL 0x00000001 +#define COMMON 0x00000002 +#define PARSER 0x00000004 +#define DISPATCHER 0x00000008 +#define INTERPRETER 0x00000010 +#define NAMESPACE 0x00000020 +#define RESOURCE_MANAGER 0x00000040 +#define TABLE_MANAGER 0x00000080 +#define EVENT_HANDLING 0x00000100 +#define HARDWARE 0x00000200 +#define MISCELLANEOUS 0x00000400 +#define OS_DEPENDENT 0x00000800 + +#define BUS_MANAGER 0x00001000 + +#define PROCESSOR_CONTROL 0x00002000 +#define SYSTEM_CONTROL 0x00004000 +#define THERMAL_CONTROL 0x00008000 +#define POWER_CONTROL 0x00010000 + +#define EMBEDDED_CONTROLLER 0x00020000 +#define BATTERY 0x00040000 + +#define DEBUGGER 0x00100000 +#define ALL_COMPONENTS 0x001FFFFF + + +/* Exception level -- used in the global "Debug_level" */ + +#define ACPI_OK 0x00000001 +#define ACPI_INFO 0x00000002 +#define ACPI_WARN 0x00000004 +#define ACPI_ERROR 0x00000008 +#define ACPI_FATAL 0x00000010 +#define ACPI_DEBUG_OBJECT 0x00000020 +#define ACPI_ALL 0x0000003F + + +/* Trace level -- also used in the global "Debug_level" */ + +#define TRACE_PARSE 0x00000100 +#define TRACE_DISPATCH 0x00000200 +#define TRACE_LOAD 0x00000400 +#define TRACE_EXEC 0x00000800 +#define TRACE_NAMES 0x00001000 +#define TRACE_OPREGION 0x00002000 +#define TRACE_BFIELD 0x00004000 +#define TRACE_TRASH 0x00008000 +#define TRACE_TABLES 0x00010000 +#define TRACE_FUNCTIONS 0x00020000 +#define TRACE_VALUES 0x00040000 +#define TRACE_OBJECTS 0x00080000 +#define TRACE_ALLOCATIONS 0x00100000 +#define TRACE_RESOURCES 0x00200000 +#define TRACE_IO 0x00400000 +#define TRACE_INTERRUPTS 0x00800000 +#define TRACE_USER_REQUESTS 0x01000000 +#define TRACE_PACKAGE 0x02000000 +#define TRACE_MUTEX 0x04000000 + +#define TRACE_ALL 0x0FFFFF00 + + +/* Exceptionally verbose output -- also used in the global "Debug_level" */ + +#define VERBOSE_AML_DISASSEMBLE 0x10000000 +#define VERBOSE_INFO 0x20000000 +#define VERBOSE_TABLES 0x40000000 +#define VERBOSE_EVENTS 0x80000000 + +#define VERBOSE_ALL 0x70000000 + + +/* Defaults for Debug_level, debug and normal */ + +#define DEBUG_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT | TRACE_TABLES | TRACE_IO) +#define NORMAL_DEFAULT (ACPI_OK | ACPI_WARN | ACPI_ERROR | ACPI_DEBUG_OBJECT) +#define DEBUG_ALL (VERBOSE_AML_DISASSEMBLE | TRACE_ALL | ACPI_ALL) + +/* Misc defines */ + +#define HEX 0x01 +#define ASCII 0x02 +#define FULL_ADDRESS 0x04 +#define CHARS_PER_LINE 16 /* used in Dump_buf function */ + + +#endif /* _OUTPUT_H */ diff --git a/drivers/acpi/include/parser.h b/drivers/acpi/include/parser.h new file mode 100644 index 000000000..ed146756a --- /dev/null +++ b/drivers/acpi/include/parser.h @@ -0,0 +1,327 @@ +/****************************************************************************** + * + * Module Name: parser.h - AML Parser subcomponent prototypes and defines + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PARSER_H_ +#define _PARSER_H_ + + +#define OP_HAS_RETURN_VALUE 1 + +/* variable # arguments */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + +/* maximum virtual address */ + +#define ACPI_MAX_AML ((u8 *)(~0UL)) + + +#define PARSE_DELETE_TREE 1 + + +/* psapi - Parser external interfaces */ + +ACPI_STATUS +acpi_psx_load_table ( + u8 *pcode_addr, + s32 pcode_length); + +ACPI_STATUS +acpi_psx_execute ( + ACPI_NAMED_OBJECT *method_entry, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **return_obj_desc); + + +u8 +acpi_ps_is_namespace_object_op ( + u16 opcode); +u8 +acpi_ps_is_namespace_op ( + u16 opcode); + + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* psargs - Parse AML opcode arguments */ + +u8 * +acpi_ps_get_next_package_end ( + ACPI_PARSE_STATE *parser_state); + +char * +acpi_ps_get_next_namestring ( + ACPI_PARSE_STATE *parser_state); + +void +acpi_ps_get_next_simple_arg ( + ACPI_PARSE_STATE *parser_state, + s32 arg_type, /* type of argument */ + ACPI_GENERIC_OP *arg); /* (OUT) argument data */ + +void +acpi_ps_get_next_namepath ( + ACPI_PARSE_STATE *parser_state, + ACPI_GENERIC_OP *arg, + u32 *arg_count, + u8 method_call); + +ACPI_GENERIC_OP * +acpi_ps_get_next_field ( + ACPI_PARSE_STATE *parser_state); + +ACPI_GENERIC_OP * +acpi_ps_get_next_arg ( + ACPI_PARSE_STATE *parser_state, + s32 arg_type, + u32 *arg_count); + + +/* psopcode - AML Opcode information */ + +ACPI_OP_INFO * +acpi_ps_get_opcode_info ( + u16 opcode); + +char * +acpi_ps_get_opcode_name ( + u16 opcode); + + +/* psparse - top level parsing routines */ + +void +acpi_ps_delete_parse_tree ( + ACPI_GENERIC_OP *root); + +ACPI_STATUS +acpi_ps_parse_loop ( + ACPI_PARSE_STATE *parser_state, + ACPI_WALK_STATE *walk_state, + u32 parse_flags); + + +ACPI_STATUS +acpi_ps_parse_aml ( + ACPI_GENERIC_OP *start_scope, + u8 *aml, + u32 acpi_aml_size, + u32 parse_flags); + +ACPI_STATUS +acpi_ps_parse_table ( + u8 *aml, + s32 aml_size, + INTERPRETER_CALLBACK descending_callback, + INTERPRETER_CALLBACK ascending_callback, + ACPI_GENERIC_OP **root_object); + +u16 +acpi_ps_peek_opcode ( + ACPI_PARSE_STATE *state); + + +/* psscope - Scope stack management routines */ + + +ACPI_STATUS +acpi_ps_init_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_GENERIC_OP *root); + +ACPI_GENERIC_OP * +acpi_ps_get_parent_scope ( + ACPI_PARSE_STATE *state); + +u8 +acpi_ps_has_completed_scope ( + ACPI_PARSE_STATE *parser_state); + +void +acpi_ps_pop_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_GENERIC_OP **op, + u32 *arg_list); + +ACPI_STATUS +acpi_ps_push_scope ( + ACPI_PARSE_STATE *parser_state, + ACPI_GENERIC_OP *op, + u32 remaining_args, + u32 arg_count); + +void +acpi_ps_cleanup_scope ( + ACPI_PARSE_STATE *state); + + +/* pstree - parse tree manipulation routines */ + +void +acpi_ps_append_arg( + ACPI_GENERIC_OP *op, + ACPI_GENERIC_OP *arg); + +ACPI_GENERIC_OP* +acpi_ps_find ( + ACPI_GENERIC_OP *scope, + char *path, + u16 opcode, + u32 create); + +ACPI_GENERIC_OP * +acpi_ps_get_arg( + ACPI_GENERIC_OP *op, + u32 argn); + +ACPI_GENERIC_OP * +acpi_ps_get_child ( + ACPI_GENERIC_OP *op); + +ACPI_GENERIC_OP * +acpi_ps_get_depth_next ( + ACPI_GENERIC_OP *origin, + ACPI_GENERIC_OP *op); + + +/* pswalk - parse tree walk routines */ + +ACPI_STATUS +acpi_ps_walk_parsed_aml ( + ACPI_GENERIC_OP *start_op, + ACPI_GENERIC_OP *end_op, + ACPI_OBJECT_INTERNAL *mth_desc, + ACPI_NAME_TABLE *start_scope, + ACPI_OBJECT_INTERNAL **params, + ACPI_OBJECT_INTERNAL **caller_return_desc, + ACPI_OWNER_ID owner_id, + INTERPRETER_CALLBACK descending_callback, + INTERPRETER_CALLBACK ascending_callback); + +ACPI_STATUS +acpi_ps_get_next_walk_op ( + ACPI_WALK_STATE *walk_state, + ACPI_GENERIC_OP *op, + INTERPRETER_CALLBACK ascending_callback); + + +/* psutils - parser utilities */ + +void +acpi_ps_init_op ( + ACPI_GENERIC_OP *op, + u16 opcode); + +ACPI_GENERIC_OP * +acpi_ps_alloc_op ( + u16 opcode); + +void +acpi_ps_free_op ( + ACPI_GENERIC_OP *op); + +void +acpi_ps_delete_parse_cache ( + void); + +u8 +acpi_ps_is_leading_char ( + s32 c); + +u8 +acpi_ps_is_prefix_char ( + s32 c); + +u8 +acpi_ps_is_named_op ( + u16 opcode); + +u8 +acpi_ps_is_named_object_op ( + u16 opcode); + +u8 +acpi_ps_is_deferred_op ( + u16 opcode); + +u8 +acpi_ps_is_bytelist_op( + u16 opcode); + +u8 +acpi_ps_is_field_op( + u16 opcode); + +u8 +acpi_ps_is_create_field_op ( + u16 opcode); + +ACPI_NAMED_OP* +acpi_ps_to_named_op( + ACPI_GENERIC_OP *op); + +ACPI_DEFERRED_OP * +acpi_ps_to_deferred_op ( + ACPI_GENERIC_OP *op); + +ACPI_BYTELIST_OP* +acpi_ps_to_bytelist_op( + ACPI_GENERIC_OP *op); + +u32 +acpi_ps_get_name( + ACPI_GENERIC_OP *op); + +void +acpi_ps_set_name( + ACPI_GENERIC_OP *op, + u32 name); + + +/* psdump - display parser tree */ + +s32 +acpi_ps_sprint_path ( + char *buffer_start, + u32 buffer_size, + ACPI_GENERIC_OP *op); + +s32 +acpi_ps_sprint_op ( + char *buffer_start, + u32 buffer_size, + ACPI_GENERIC_OP *op); + +void +acpi_ps_show ( + ACPI_GENERIC_OP *op); + + +#endif /* _PARSER_H_ */ diff --git a/drivers/acpi/include/resource.h b/drivers/acpi/include/resource.h new file mode 100644 index 000000000..b87032ddb --- /dev/null +++ b/drivers/acpi/include/resource.h @@ -0,0 +1,300 @@ +/****************************************************************************** + * + * Name: resource.h - Resource Manager function prototypes + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __RESOURCE_H__ +#define __RESOURCE_H__ + +#include "actypes.h" +#include "acobject.h" + +/* + * Function prototypes called from Acpi* APIs + */ + +ACPI_STATUS +acpi_rs_get_prt_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + + +ACPI_STATUS +acpi_rs_get_crs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_get_prs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_set_srs_method_data ( + ACPI_HANDLE handle, + ACPI_BUFFER *ret_buffer); + +ACPI_STATUS +acpi_rs_create_resource_list ( + ACPI_OBJECT_INTERNAL *byte_stream_buffer, + u8 *output_buffer, + u32 *output_buffer_length); + +ACPI_STATUS +acpi_rs_create_byte_stream ( + RESOURCE *linked_list_buffer, + u8 *output_buffer, + u32 *output_buffer_length); + +ACPI_STATUS +acpi_rs_create_pci_routing_table ( + ACPI_OBJECT_INTERNAL *method_return_object, + u8 *output_buffer, + u32 *output_buffer_length); + + +/* + *Function prototypes called from Acpi_rs_create*APIs + */ + +void +acpi_rs_dump_resource_list ( + RESOURCE *resource); + +void +acpi_rs_dump_irq_list ( + u8 *route_table); + +ACPI_STATUS +acpi_rs_get_byte_stream_start ( + u8 *byte_stream_buffer, + u8 **byte_stream_start, + u32 *size); + +ACPI_STATUS +acpi_rs_calculate_list_length ( + u8 *byte_stream_buffer, + u32 byte_stream_buffer_length, + u32 *size_needed); + +ACPI_STATUS +acpi_rs_calculate_byte_stream_length ( + RESOURCE *linked_list_buffer, + u32 *size_needed); + +ACPI_STATUS +acpi_rs_byte_stream_to_list ( + u8 *byte_stream_buffer, + u32 byte_stream_buffer_length, + u8 **output_buffer); + +ACPI_STATUS +acpi_rs_list_to_byte_stream ( + RESOURCE *linked_list, + u32 byte_stream_size_needed, + u8 **output_buffer); + +ACPI_STATUS +acpi_rs_io_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_fixed_io_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_io_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_fixed_io_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_irq_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_irq_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_dma_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_dma_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_address16_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_address16_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_address32_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_address32_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_start_dependent_functions_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_end_dependent_functions_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_start_dependent_functions_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_end_dependent_functions_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_memory24_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_memory24_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_memory32_range_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size +); + +ACPI_STATUS +acpi_rs_fixed_memory32_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_memory32_range_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_fixed_memory32_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_extended_irq_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_extended_irq_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_end_tag_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_end_tag_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + +ACPI_STATUS +acpi_rs_vendor_resource ( + u8 *byte_stream_buffer, + u32 *bytes_consumed, + u8 **output_buffer, + u32 *structure_size); + +ACPI_STATUS +acpi_rs_vendor_stream ( + RESOURCE *linked_list, + u8 **output_buffer, + u32 *bytes_consumed); + + +#endif /*__RESOURCE_H__ */ diff --git a/drivers/acpi/include/tables.h b/drivers/acpi/include/tables.h new file mode 100644 index 000000000..d3566489e --- /dev/null +++ b/drivers/acpi/include/tables.h @@ -0,0 +1,168 @@ + +/****************************************************************************** + * + * Name: tables.h - ACPI table management + * + *****************************************************************************/ + +/* + * Copyright (C) 2000 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TABLES_H__ +#define __TABLES_H__ + +#include "actypes.h" +#include "actables.h" + + +/* Used in Acpi_tb_map_acpi_table for size parameter if table header is to be used */ + +#define SIZE_IN_HEADER 0 + + +ACPI_STATUS +acpi_tb_handle_to_object ( + u16 table_id, + ACPI_TABLE_DESC **table_desc); + + +/* + * Acpi_tbfac - FACP, FACS utilities + */ + +ACPI_STATUS +acpi_tb_get_table_facs ( + char *buffer_ptr, + ACPI_TABLE_DESC *table_info); + + +/* + * Acpi_tbget - Table "get" routines + */ + +ACPI_STATUS +acpi_tb_get_table_ptr ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER **table_ptr_loc); + +ACPI_STATUS +acpi_tb_get_table ( + void *physical_address, + char *buffer_ptr, + ACPI_TABLE_DESC *table_info); + + +/* + * Acpi_tbgetall - Get all firmware ACPI tables + */ + +ACPI_STATUS +acpi_tb_get_all_tables ( + u32 number_of_tables, + char *buffer_ptr); + + +/* + * Acpi_tbinstall - Table installation + */ + +ACPI_STATUS +acpi_tb_install_table ( + char *table_ptr, + ACPI_TABLE_DESC *table_info); + +ACPI_STATUS +acpi_tb_recognize_table ( + char *table_ptr, + ACPI_TABLE_DESC *table_info); + +ACPI_STATUS +acpi_tb_init_table_descriptor ( + ACPI_TABLE_TYPE table_type, + ACPI_TABLE_DESC *table_info); + + +/* + * Acpi_tbremove - Table removal and deletion + */ + +void +acpi_tb_delete_acpi_tables ( + void); + +void +acpi_tb_delete_acpi_table ( + ACPI_TABLE_TYPE type); + +ACPI_TABLE_DESC * +acpi_tb_delete_single_table ( + ACPI_TABLE_DESC *table_desc); + +void +acpi_tb_free_acpi_tables_of_type ( + ACPI_TABLE_DESC *table_info); + + +/* + * Acpi_tbrsd - RSDP, RSDT utilities + */ + +ACPI_STATUS +acpi_tb_get_table_rsdt ( + u32 *number_of_tables); + +char * +acpi_tb_scan_memory_for_rsdp ( + char *start_address, + u32 length); + +ACPI_STATUS +acpi_tb_find_rsdp ( + ACPI_TABLE_DESC *table_info); + + +/* + * Acpi_tbutils - common table utilities + */ + +u8 +acpi_tb_system_table_pointer ( + void *where); + +ACPI_STATUS +acpi_tb_map_acpi_table ( + void *physical_address, + u32 *size, + void **logical_address); + +ACPI_STATUS +acpi_tb_verify_table_checksum ( + ACPI_TABLE_HEADER *table_header); + +u8 +acpi_tb_checksum ( + void *buffer, + u32 length); + +ACPI_STATUS +acpi_tb_validate_table_header ( + ACPI_TABLE_HEADER *table_header); + + +#endif /* __TABLES_H__ */ |