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

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