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

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