/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 *//****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem * * Copyright (C) 2000 - 2020, Intel Corp. * *****************************************************************************/ #ifndef __ACTYPES_H__#define __ACTYPES_H__ /* acpisrc:struct_defs -- for acpisrc conversion */ /* * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent * header and must be either 32 or 64. 16-bit ACPICA is no longer * supported, as of 12/2006. */#ifndef ACPI_MACHINE_WIDTH#error ACPI_MACHINE_WIDTH not defined#endif /* * Data type ranges * Note: These macros are designed to be compiler independent as well as * working around problems that some 32-bit compilers have with 64-bit * constants. */#define ACPI_UINT8_MAX (u8) (~((u8) 0)) /* 0xFF */#define ACPI_UINT16_MAX (u16)(~((u16) 0)) /* 0xFFFF */#define ACPI_UINT32_MAX (u32)(~((u32) 0)) /* 0xFFFFFFFF */#define ACPI_UINT64_MAX (u64)(~((u64) 0)) /* 0xFFFFFFFFFFFFFFFF */#define ACPI_ASCII_MAX 0x7F /* * Architecture-specific ACPICA Subsystem Data Types * * The goal of these types is to provide source code portability across * 16-bit, 32-bit, and 64-bit targets. * * 1) The following types are of fixed size for all targets (16/32/64): * * u8 Logical boolean * * u8 8-bit (1 byte) unsigned value * u16 16-bit (2 byte) unsigned value * u32 32-bit (4 byte) unsigned value * u64 64-bit (8 byte) unsigned value * * s16 16-bit (2 byte) signed value * s32 32-bit (4 byte) signed value * s64 64-bit (8 byte) signed value * * COMPILER_DEPENDENT_UINT64/s64 - These types are defined in the * compiler-dependent header(s) and were introduced because there is no * common 64-bit integer type across the various compilation models, as * shown in the table below. * * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit * char 8 8 8 8 8 8 * short 16 16 16 16 16 16 * _int32 32 * int 32 64 32 32 16 16 * long 64 64 32 32 32 32 * long long 64 64 * pointer 64 64 64 32 32 32 * * Note: ILP64 and LP32 are currently not supported. * * * 2) These types represent the native word size of the target mode of the * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are * usually used for memory allocation, efficient loop counters, and array * indexes. The types are similar to the size_t type in the C library and * are required because there is no C type that consistently represents the * native data width. acpi_size is needed because there is no guarantee * that a kernel-level C library is present. * * acpi_size 16/32/64-bit unsigned value * acpi_native_int 16/32/64-bit signed value */ /******************************************************************************* * * Common types for all compilers, all targets * ******************************************************************************/ #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned char u8;typedef unsigned short u16;typedef short s16;typedef COMPILER_DEPENDENT_UINT64 u64;typedef COMPILER_DEPENDENT_INT64 s64; #endif /* ACPI_USE_SYSTEM_INTTYPES */ /* * Value returned by acpi_os_get_thread_id. There is no standard "thread_id" * across operating systems or even the various UNIX systems. Since ACPICA * only needs the thread ID as a unique thread identifier, we use a u64 * as the only common data type - it will accommodate any type of pointer or * any type of integer. It is up to the host-dependent OSL to cast the * native thread ID type to a u64 (in acpi_os_get_thread_id). */#define acpi_thread_id u64 /******************************************************************************* * * Types specific to 64-bit targets * ******************************************************************************/ #if ACPI_MACHINE_WIDTH == 64 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int u32;typedef int s32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef s64 acpi_native_int; typedef u64 acpi_size;typedef u64 acpi_io_address;typedef u64 acpi_physical_address; #define ACPI_MAX_PTR ACPI_UINT64_MAX#define ACPI_SIZE_MAX ACPI_UINT64_MAX #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */#define ACPI_USE_NATIVE_MATH64 /* Has native 64-bit integer support */ /* * In the case of the Itanium Processor Family (IPF), the hardware does not * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED * flag to indicate that special precautions must be taken to avoid alignment * faults. (IA64 or ia64 is currently used by existing compilers to indicate * IPF.) * * Note: EM64T and other X86-64 processors support misaligned transfers, * so there is no need to define this flag. */#if defined (__IA64__) || defined (__ia64__)#define ACPI_MISALIGNMENT_NOT_SUPPORTED#endif /******************************************************************************* * * Types specific to 32-bit targets * ******************************************************************************/ #elif ACPI_MACHINE_WIDTH == 32 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int u32;typedef int s32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef s32 acpi_native_int; typedef u32 acpi_size; #ifdef ACPI_32BIT_PHYSICAL_ADDRESS /* * OSPMs can define this to shrink the size of the structures for 32-bit * none PAE environment. ASL compiler may always define this to generate * 32-bit OSPM compliant tables. */typedef u32 acpi_io_address;typedef u32 acpi_physical_address; #else /* ACPI_32BIT_PHYSICAL_ADDRESS */ /* * It is reported that, after some calculations, the physical addresses can * wrap over the 32-bit boundary on 32-bit PAE environment. * https://bugzilla.kernel.org/show_bug.cgi?id=87971 */typedef u64 acpi_io_address;typedef u64 acpi_physical_address; #endif /* ACPI_32BIT_PHYSICAL_ADDRESS */ #define ACPI_MAX_PTR ACPI_UINT32_MAX#define ACPI_SIZE_MAX ACPI_UINT32_MAX #else /* ACPI_MACHINE_WIDTH must be either 64 or 32 */ #error unknown ACPI_MACHINE_WIDTH#endif /******************************************************************************* * * OS-dependent types * * If the defaults below are not appropriate for the host system, they can * be defined in the OS-specific header, and this will take precedence. * ******************************************************************************/ /* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ #ifndef acpi_cpu_flags#define acpi_cpu_flags acpi_size#endif /* Object returned from acpi_os_create_cache */ #ifndef acpi_cache_t#ifdef ACPI_USE_LOCAL_CACHE#define acpi_cache_t struct acpi_memory_list#else#define acpi_cache_t void *#endif#endif /* * Synchronization objects - Mutexes, Semaphores, and spin_locks */#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE)/* * These macros are used if the host OS does not support a mutex object. * Map the OSL Mutex interfaces to binary semaphores. */#define acpi_mutex acpi_semaphore#define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle)#define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle)#define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time)#define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1)#endif /* Configurable types for synchronization objects */ #ifndef acpi_spinlock#define acpi_spinlock void *#endif #ifndef acpi_raw_spinlock#define acpi_raw_spinlock acpi_spinlock#endif #ifndef acpi_semaphore#define acpi_semaphore void *#endif #ifndef acpi_mutex#define acpi_mutex void *#endif /******************************************************************************* * * Compiler-dependent types * * If the defaults below are not appropriate for the host compiler, they can * be defined in the compiler-specific header, and this will take precedence. * ******************************************************************************/ /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ #ifndef acpi_uintptr_t#define acpi_uintptr_t void *#endif /* * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because * some compilers can catch printf format string problems */#ifndef ACPI_PRINTF_LIKE#define ACPI_PRINTF_LIKE(c)#endif /* * Some compilers complain about unused variables. Sometimes we don't want * to use all the variables (for example, _acpi_module_name). This allows us * to tell the compiler in a per-variable manner that a variable * is unused */#ifndef ACPI_UNUSED_VAR#define ACPI_UNUSED_VAR#endif /* * All ACPICA external functions that are available to the rest of the * kernel are tagged with these macros which can be defined as appropriate * for the host. * * Notes: * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination * interfaces that may need special processing. * ACPI_EXPORT_SYMBOL is used for all other public external functions. */#ifndef ACPI_EXPORT_SYMBOL_INIT#define ACPI_EXPORT_SYMBOL_INIT(symbol)#endif #ifndef ACPI_EXPORT_SYMBOL#define ACPI_EXPORT_SYMBOL(symbol)#endif /* * Compiler/Clibrary-dependent debug initialization. Used for ACPICA * utilities only. */#ifndef ACPI_DEBUG_INITIALIZE#define ACPI_DEBUG_INITIALIZE()#endif /******************************************************************************* * * Configuration * ******************************************************************************/ #ifdef ACPI_NO_MEM_ALLOCATIONS #define ACPI_ALLOCATE(a) NULL#define ACPI_ALLOCATE_ZEROED(a) NULL#define ACPI_FREE(a)#define ACPI_MEM_TRACKING(a) #else /* ACPI_NO_MEM_ALLOCATIONS */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS/* * Memory allocation tracking (used by acpi_exec to detect memory leaks) */#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS)#define ACPI_FREE(a) acpi_ut_free_and_track (a, ACPI_MEM_PARAMETERS)#define ACPI_MEM_TRACKING(a) a #else/* * Normal memory allocation directly via the OS services layer */#define ACPI_ALLOCATE(a) acpi_os_allocate ((acpi_size) (a))#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed ((acpi_size) (a))#define ACPI_FREE(a) acpi_os_free (a)#define ACPI_MEM_TRACKING(a) #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #endif /* ACPI_NO_MEM_ALLOCATIONS */ /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification * changes) * *****************************************************************************/ /* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ #define ACPI_MAX_GPE_BLOCKS 2 /* Default ACPI register widths */ #define ACPI_GPE_REGISTER_WIDTH 8#define ACPI_PM1_REGISTER_WIDTH 16#define ACPI_PM2_REGISTER_WIDTH 8#define ACPI_PM_TIMER_WIDTH 32#define ACPI_RESET_REGISTER_WIDTH 8 /* Names within the namespace are 4 bytes long */ #define ACPI_NAMESEG_SIZE 4 /* Fixed by ACPI spec */#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */#define ACPI_PATH_SEPARATOR '.' /* Sizes for ACPI table headers */ #define ACPI_OEM_ID_SIZE 6#define ACPI_OEM_TABLE_ID_SIZE 8 /* ACPI/PNP hardware IDs */ #define PCI_ROOT_HID_STRING "PNP0A03"#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" /* PM Timer ticks per second (HZ) */ #define ACPI_PM_TIMER_FREQUENCY 3579545 /******************************************************************************* * * Independent types * ******************************************************************************/ /* Logical defines and NULL */ #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 /* * Miscellaneous types */typedef u32 acpi_status; /* All ACPI Exceptions */typedef u32 acpi_name; /* 4-byte ACPI name */typedef char *acpi_string; /* Null terminated ASCII string */typedef void *acpi_handle; /* Actually a ptr to a NS Node */ /* Time constants for timer calculations */ #define ACPI_MSEC_PER_SEC 1000L #define ACPI_USEC_PER_MSEC 1000L#define ACPI_USEC_PER_SEC 1000000L #define ACPI_100NSEC_PER_USEC 10L#define ACPI_100NSEC_PER_MSEC 10000L#define ACPI_100NSEC_PER_SEC 10000000L #define ACPI_NSEC_PER_USEC 1000L#define ACPI_NSEC_PER_MSEC 1000000L#define ACPI_NSEC_PER_SEC 1000000000L #define ACPI_TIME_AFTER(a, b) ((s64)((b) - (a)) < 0) /* Owner IDs are used to track namespace nodes for selective deletion */ typedef u16 acpi_owner_id;#define ACPI_OWNER_ID_MAX 0xFFF /* 4095 possible owner IDs */ #define ACPI_INTEGER_BIT_SIZE 64#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */#define ACPI_MAX64_DECIMAL_DIGITS 20#define ACPI_MAX32_DECIMAL_DIGITS 10#define ACPI_MAX16_DECIMAL_DIGITS 5#define ACPI_MAX8_DECIMAL_DIGITS 3 /* * Constants with special meanings */#define ACPI_ROOT_OBJECT ((acpi_handle) ACPI_TO_POINTER (ACPI_MAX_PTR))#define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */#define ACPI_DO_NOT_WAIT 0 /* * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are * 32 bits. In ACPI version 2 (2000) and later, integers are max 64 bits. * Note that this pertains to the ACPI integer type only, not to other * integers used in the implementation of the ACPICA subsystem. * * 01/2010: This type is obsolete and has been removed from the entire ACPICA * code base. It remains here for compatibility with device drivers that use * the type. However, it will be removed in the future. */typedef u64 acpi_integer;#define ACPI_INTEGER_MAX ACPI_UINT64_MAX /******************************************************************************* * * Commonly used macros * ******************************************************************************/ /* Data manipulation */ #define ACPI_LOBYTE(integer) ((u8) (u16)(integer))#define ACPI_HIBYTE(integer) ((u8) (((u16)(integer)) >> 8))#define ACPI_LOWORD(integer) ((u16) (u32)(integer))#define ACPI_HIWORD(integer) ((u16)(((u32)(integer)) >> 16))#define ACPI_LODWORD(integer64) ((u32) (u64)(integer64))#define ACPI_HIDWORD(integer64) ((u32)(((u64)(integer64)) >> 32)) #define ACPI_SET_BIT(target,bit) ((target) |= (bit))#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit))#define ACPI_MIN(a,b) (((a)<(b))?(a):(b))#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) /* Size calculation */ #define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) /* Pointer manipulation */ Lines 1–500 of 1289. Load more
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem * * Copyright (C) 2000 - 2020, Intel Corp. * *****************************************************************************/ #ifndef __ACTYPES_H__ #define __ACTYPES_H__ /* acpisrc:struct_defs -- for acpisrc conversion */ /* * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent * header and must be either 32 or 64. 16-bit ACPICA is no longer * supported, as of 12/2006. */ #ifndef ACPI_MACHINE_WIDTH #error ACPI_MACHINE_WIDTH not defined #endif /* * Data type ranges * Note: These macros are designed to be compiler independent as well as * working around problems that some 32-bit compilers have with 64-bit * constants. */ #define ACPI_UINT8_MAX (u8) (~((u8) 0)) /* 0xFF */ #define ACPI_UINT16_MAX (u16)(~((u16) 0)) /* 0xFFFF */ #define ACPI_UINT32_MAX (u32)(~((u32) 0)) /* 0xFFFFFFFF */ #define ACPI_UINT64_MAX (u64)(~((u64) 0)) /* 0xFFFFFFFFFFFFFFFF */ #define ACPI_ASCII_MAX 0x7F /* * Architecture-specific ACPICA Subsystem Data Types * * The goal of these types is to provide source code portability across * 16-bit, 32-bit, and 64-bit targets. * * 1) The following types are of fixed size for all targets (16/32/64): * * u8 Logical boolean * * u8 8-bit (1 byte) unsigned value * u16 16-bit (2 byte) unsigned value * u32 32-bit (4 byte) unsigned value * u64 64-bit (8 byte) unsigned value * * s16 16-bit (2 byte) signed value * s32 32-bit (4 byte) signed value * s64 64-bit (8 byte) signed value * * COMPILER_DEPENDENT_UINT64/s64 - These types are defined in the * compiler-dependent header(s) and were introduced because there is no * common 64-bit integer type across the various compilation models, as * shown in the table below. * * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit * char 8 8 8 8 8 8 * short 16 16 16 16 16 16 * _int32 32 * int 32 64 32 32 16 16 * long 64 64 32 32 32 32 * long long 64 64 * pointer 64 64 64 32 32 32 * * Note: ILP64 and LP32 are currently not supported. * * * 2) These types represent the native word size of the target mode of the * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are * usually used for memory allocation, efficient loop counters, and array * indexes. The types are similar to the size_t type in the C library and * are required because there is no C type that consistently represents the * native data width. acpi_size is needed because there is no guarantee * that a kernel-level C library is present. * * acpi_size 16/32/64-bit unsigned value * acpi_native_int 16/32/64-bit signed value */ /******************************************************************************* * * Common types for all compilers, all targets * ******************************************************************************/ #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned char u8; typedef unsigned short u16; typedef short s16; typedef COMPILER_DEPENDENT_UINT64 u64; typedef COMPILER_DEPENDENT_INT64 s64; #endif /* ACPI_USE_SYSTEM_INTTYPES */ /* * Value returned by acpi_os_get_thread_id. There is no standard "thread_id" * across operating systems or even the various UNIX systems. Since ACPICA * only needs the thread ID as a unique thread identifier, we use a u64 * as the only common data type - it will accommodate any type of pointer or * any type of integer. It is up to the host-dependent OSL to cast the * native thread ID type to a u64 (in acpi_os_get_thread_id). */ #define acpi_thread_id u64 /******************************************************************************* * * Types specific to 64-bit targets * ******************************************************************************/ #if ACPI_MACHINE_WIDTH == 64 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int u32; typedef int s32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef s64 acpi_native_int; typedef u64 acpi_size; typedef u64 acpi_io_address; typedef u64 acpi_physical_address; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX #define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ #define ACPI_USE_NATIVE_MATH64 /* Has native 64-bit integer support */ /* * In the case of the Itanium Processor Family (IPF), the hardware does not * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED * flag to indicate that special precautions must be taken to avoid alignment * faults. (IA64 or ia64 is currently used by existing compilers to indicate * IPF.) * * Note: EM64T and other X86-64 processors support misaligned transfers, * so there is no need to define this flag. */ #if defined (__IA64__) || defined (__ia64__) #define ACPI_MISALIGNMENT_NOT_SUPPORTED #endif /******************************************************************************* * * Types specific to 32-bit targets * ******************************************************************************/ #elif ACPI_MACHINE_WIDTH == 32 #ifndef ACPI_USE_SYSTEM_INTTYPES typedef unsigned int u32; typedef int s32; #endif /* ACPI_USE_SYSTEM_INTTYPES */ typedef s32 acpi_native_int; typedef u32 acpi_size; #ifdef ACPI_32BIT_PHYSICAL_ADDRESS /* * OSPMs can define this to shrink the size of the structures for 32-bit * none PAE environment. ASL compiler may always define this to generate * 32-bit OSPM compliant tables. */ typedef u32 acpi_io_address; typedef u32 acpi_physical_address; #else /* ACPI_32BIT_PHYSICAL_ADDRESS */ /* * It is reported that, after some calculations, the physical addresses can * wrap over the 32-bit boundary on 32-bit PAE environment. * https://bugzilla.kernel.org/show_bug.cgi?id=87971 */ typedef u64 acpi_io_address; typedef u64 acpi_physical_address; #endif /* ACPI_32BIT_PHYSICAL_ADDRESS */ #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX #else /* ACPI_MACHINE_WIDTH must be either 64 or 32 */ #error unknown ACPI_MACHINE_WIDTH #endif /******************************************************************************* * * OS-dependent types * * If the defaults below are not appropriate for the host system, they can * be defined in the OS-specific header, and this will take precedence. * ******************************************************************************/ /* Flags for acpi_os_acquire_lock/acpi_os_release_lock */ #ifndef acpi_cpu_flags #define acpi_cpu_flags acpi_size #endif /* Object returned from acpi_os_create_cache */ #ifndef acpi_cache_t #ifdef ACPI_USE_LOCAL_CACHE #define acpi_cache_t struct acpi_memory_list #else #define acpi_cache_t void * #endif #endif /* * Synchronization objects - Mutexes, Semaphores, and spin_locks */ #if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) /* * These macros are used if the host OS does not support a mutex object. * Map the OSL Mutex interfaces to binary semaphores. */ #define acpi_mutex acpi_semaphore #define acpi_os_create_mutex(out_handle) acpi_os_create_semaphore (1, 1, out_handle) #define acpi_os_delete_mutex(handle) (void) acpi_os_delete_semaphore (handle) #define acpi_os_acquire_mutex(handle,time) acpi_os_wait_semaphore (handle, 1, time) #define acpi_os_release_mutex(handle) (void) acpi_os_signal_semaphore (handle, 1) #endif /* Configurable types for synchronization objects */ #ifndef acpi_spinlock #define acpi_spinlock void * #endif #ifndef acpi_raw_spinlock #define acpi_raw_spinlock acpi_spinlock #endif #ifndef acpi_semaphore #define acpi_semaphore void * #endif #ifndef acpi_mutex #define acpi_mutex void * #endif /******************************************************************************* * * Compiler-dependent types * * If the defaults below are not appropriate for the host compiler, they can * be defined in the compiler-specific header, and this will take precedence. * ******************************************************************************/ /* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ #ifndef acpi_uintptr_t #define acpi_uintptr_t void * #endif /* * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because * some compilers can catch printf format string problems */ #ifndef ACPI_PRINTF_LIKE #define ACPI_PRINTF_LIKE(c) #endif /* * Some compilers complain about unused variables. Sometimes we don't want * to use all the variables (for example, _acpi_module_name). This allows us * to tell the compiler in a per-variable manner that a variable * is unused */ #ifndef ACPI_UNUSED_VAR #define ACPI_UNUSED_VAR #endif /* * All ACPICA external functions that are available to the rest of the * kernel are tagged with these macros which can be defined as appropriate * for the host. * * Notes: * ACPI_EXPORT_SYMBOL_INIT is used for initialization and termination * interfaces that may need special processing. * ACPI_EXPORT_SYMBOL is used for all other public external functions. */ #ifndef ACPI_EXPORT_SYMBOL_INIT #define ACPI_EXPORT_SYMBOL_INIT(symbol) #endif #ifndef ACPI_EXPORT_SYMBOL #define ACPI_EXPORT_SYMBOL(symbol) #endif /* * Compiler/Clibrary-dependent debug initialization. Used for ACPICA * utilities only. */ #ifndef ACPI_DEBUG_INITIALIZE #define ACPI_DEBUG_INITIALIZE() #endif /******************************************************************************* * * Configuration * ******************************************************************************/ #ifdef ACPI_NO_MEM_ALLOCATIONS #define ACPI_ALLOCATE(a) NULL #define ACPI_ALLOCATE_ZEROED(a) NULL #define ACPI_FREE(a) #define ACPI_MEM_TRACKING(a) #else /* ACPI_NO_MEM_ALLOCATIONS */ #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* * Memory allocation tracking (used by acpi_exec to detect memory leaks) */ #define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__ #define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS) #define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track ((acpi_size) (a), ACPI_MEM_PARAMETERS) #define ACPI_FREE(a) acpi_ut_free_and_track (a, ACPI_MEM_PARAMETERS) #define ACPI_MEM_TRACKING(a) a #else /* * Normal memory allocation directly via the OS services layer */ #define ACPI_ALLOCATE(a) acpi_os_allocate ((acpi_size) (a)) #define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed ((acpi_size) (a)) #define ACPI_FREE(a) acpi_os_free (a) #define ACPI_MEM_TRACKING(a) #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ #endif /* ACPI_NO_MEM_ALLOCATIONS */ /****************************************************************************** * * ACPI Specification constants (Do not change unless the specification * changes) * *****************************************************************************/ /* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ #define ACPI_MAX_GPE_BLOCKS 2 /* Default ACPI register widths */ #define ACPI_GPE_REGISTER_WIDTH 8 #define ACPI_PM1_REGISTER_WIDTH 16 #define ACPI_PM2_REGISTER_WIDTH 8 #define ACPI_PM_TIMER_WIDTH 32 #define ACPI_RESET_REGISTER_WIDTH 8 /* Names within the namespace are 4 bytes long */ #define ACPI_NAMESEG_SIZE 4 /* Fixed by ACPI spec */ #define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ #define ACPI_PATH_SEPARATOR '.' /* Sizes for ACPI table headers */ #define ACPI_OEM_ID_SIZE 6 #define ACPI_OEM_TABLE_ID_SIZE 8 /* ACPI/PNP hardware IDs */ #define PCI_ROOT_HID_STRING "PNP0A03" #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" /* PM Timer ticks per second (HZ) */ #define ACPI_PM_TIMER_FREQUENCY 3579545 /******************************************************************************* * * Independent types * ******************************************************************************/ /* Logical defines and NULL */ #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 /* * Miscellaneous types */ typedef u32 acpi_status; /* All ACPI Exceptions */ typedef u32 acpi_name; /* 4-byte ACPI name */ typedef char *acpi_string; /* Null terminated ASCII string */ typedef void *acpi_handle; /* Actually a ptr to a NS Node */ /* Time constants for timer calculations */ #define ACPI_MSEC_PER_SEC 1000L #define ACPI_USEC_PER_MSEC 1000L #define ACPI_USEC_PER_SEC 1000000L #define ACPI_100NSEC_PER_USEC 10L #define ACPI_100NSEC_PER_MSEC 10000L #define ACPI_100NSEC_PER_SEC 10000000L #define ACPI_NSEC_PER_USEC 1000L #define ACPI_NSEC_PER_MSEC 1000000L #define ACPI_NSEC_PER_SEC 1000000000L #define ACPI_TIME_AFTER(a, b) ((s64)((b) - (a)) < 0) /* Owner IDs are used to track namespace nodes for selective deletion */ typedef u16 acpi_owner_id; #define ACPI_OWNER_ID_MAX 0xFFF /* 4095 possible owner IDs */ #define ACPI_INTEGER_BIT_SIZE 64 #define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ #define ACPI_MAX64_DECIMAL_DIGITS 20 #define ACPI_MAX32_DECIMAL_DIGITS 10 #define ACPI_MAX16_DECIMAL_DIGITS 5 #define ACPI_MAX8_DECIMAL_DIGITS 3 /* * Constants with special meanings */ #define ACPI_ROOT_OBJECT ((acpi_handle) ACPI_TO_POINTER (ACPI_MAX_PTR)) #define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */ #define ACPI_DO_NOT_WAIT 0 /* * Obsolete: Acpi integer width. In ACPI version 1 (1996), integers are * 32 bits. In ACPI version 2 (2000) and later, integers are max 64 bits. * Note that this pertains to the ACPI integer type only, not to other * integers used in the implementation of the ACPICA subsystem. * * 01/2010: This type is obsolete and has been removed from the entire ACPICA * code base. It remains here for compatibility with device drivers that use * the type. However, it will be removed in the future. */ typedef u64 acpi_integer; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX /******************************************************************************* * * Commonly used macros * ******************************************************************************/ /* Data manipulation */ #define ACPI_LOBYTE(integer) ((u8) (u16)(integer)) #define ACPI_HIBYTE(integer) ((u8) (((u16)(integer)) >> 8)) #define ACPI_LOWORD(integer) ((u16) (u32)(integer)) #define ACPI_HIWORD(integer) ((u16)(((u32)(integer)) >> 16)) #define ACPI_LODWORD(integer64) ((u32) (u64)(integer64)) #define ACPI_HIDWORD(integer64) ((u32)(((u64)(integer64)) >> 32)) #define ACPI_SET_BIT(target,bit) ((target) |= (bit)) #define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) #define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) #define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) /* Size calculation */ #define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) /* Pointer manipulation */