Merge branch 'master' of github.com:thepowersgang/acess2
[tpg/acess2.git] / Externals / ACPICA / acacess.h
1 /******************************************************************************
2  *
3  * Name: aclinux.h - OS specific defines, etc. for Linux
4  *
5  *****************************************************************************/
6
7 #ifndef _ACPICA__ACACESS_H_
8 #define _ACPICA__ACACESS_H_
9
10 #define ACPI_USE_SYSTEM_CLIBRARY
11 #define ACPI_USE_DO_WHILE_0
12 #define ACPI_MUTEX_TYPE             ACPI_OSL_MUTEX
13
14 //#define ACPI_DEBUG_OUTPUT     1
15
16 #ifdef __KERNEL__
17
18 #include <acess.h>
19
20 /* Host-dependent types and defines for in-kernel ACPICA */
21
22 #define ACPI_MACHINE_WIDTH          BITS
23
24 typedef struct sACPICache       tACPICache;
25
26 #define ACPI_CACHE_T    tACPICache
27 #define ACPI_SPINLOCK               tShortSpinlock*
28 #define ACPI_CPU_FLAGS              unsigned long
29
30 #define COMPILER_DEPENDENT_UINT64       Uint64
31 #define COMPILER_DEPENDENT_INT64        Sint64
32
33 #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) do { \
34         Uint64  rem; \
35         Sint64  num = ((Sint64)n_hi<<32)|n_lo; \
36          int    sgn = 1; \
37         if(num < 0) {num = -num; sgn = -sgn; } \
38         if(d32 < 0) {d32 = -d32; sgn = -sgn; } \
39         q32 = sgn * DivMod64U( num, d32, &rem ); \
40         r32 = rem; \
41         }while(0)
42 #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) do { \
43         n_lo >>= 1; \
44         if(n_hi & 1)    n_lo |= (1 << 31); \
45         n_hi >>= 1; \
46         }while(0)
47
48 #else /* !__KERNEL__ */
49
50 #error "Kernel only"
51
52 #endif /* __KERNEL__ */
53
54 /* Linux uses GCC */
55
56 #include "acgcc.h"
57
58
59 #if 0
60 #ifdef __KERNEL__
61 #define ACPI_SYSTEM_XFACE
62 #include <actypes.h>
63 /*
64  * Overrides for in-kernel ACPICA
65  */
66 static inline acpi_thread_id acpi_os_get_thread_id(void)
67 {
68     return (ACPI_THREAD_ID) (unsigned long) current;
69 }
70
71 /*
72  * The irqs_disabled() check is for resume from RAM.
73  * Interrupts are off during resume, just like they are for boot.
74  * However, boot has  (system_state != SYSTEM_RUNNING)
75  * to quiet __might_sleep() in kmalloc() and resume does not.
76  */
77 static inline void *acpi_os_allocate(acpi_size size)
78 {
79     return malloc(size);
80 }
81
82 static inline void *acpi_os_allocate_zeroed(acpi_size size)
83 {
84     return calloc(size, 1);
85 }
86
87 static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
88 {
89 //    return kmem_cache_zalloc(cache,
90 //        irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL);
91 }
92
93 #define ACPI_ALLOCATE(a)        acpi_os_allocate(a)
94 #define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a)
95 #define ACPI_FREE(a)            free(a)
96
97 #ifndef CONFIG_PREEMPT
98 /*
99  * Used within ACPICA to show where it is safe to preempt execution
100  * when CONFIG_PREEMPT=n
101  */
102 #define ACPI_PREEMPTION_POINT() \
103     do { \
104         Threads_Yield(); \
105     } while (0)
106 #endif
107
108 /*
109  * When lockdep is enabled, the spin_lock_init() macro stringifies it's
110  * argument and uses that as a name for the lock in debugging.
111  * By executing spin_lock_init() in a macro the key changes from "lock" for
112  * all locks to the name of the argument of acpi_os_create_lock(), which
113  * prevents lockdep from reporting false positives for ACPICA locks.
114  */
115 #define AcpiOsCreateLock(__handle)                              \
116 ({                                                              \
117         tShortlock *lock = ACPI_ALLOCATE_ZEROED(sizeof(*lock)); \
118                                                                 \
119         if (lock) {                                             \
120                 *(__handle) = lock;                             \
121         }                                                       \
122         lock ? AE_OK : AE_NO_MEMORY;                            \
123 })
124
125 #endif /* __KERNEL__ */
126 #endif
127
128 #endif /* __ACLINUX_H__ */

UCC git Repository :: git.ucc.asn.au