Rev 1179 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1179 | Rev 1221 | ||
---|---|---|---|
1 | #ifndef __TYPES_H__ |
1 | #ifndef __TYPES_H__ |
2 | #define __TYPES_H__ |
2 | #define __TYPES_H__ |
3 | 3 | ||
4 | # define __iomem |
4 | # define __iomem |
5 | # define __force |
5 | # define __force |
6 | # define __user |
6 | # define __user |
7 | 7 | ||
8 | # define WARN(condition, format...) |
8 | # define WARN(condition, format...) |
9 | 9 | ||
10 | typedef int bool; |
10 | typedef int bool; |
11 | 11 | ||
12 | #define false 0 |
12 | #define false 0 |
13 | #define true 1 |
13 | #define true 1 |
14 | 14 | ||
15 | typedef int ssize_t; |
15 | typedef int ssize_t; |
16 | typedef long long loff_t; |
16 | typedef long long loff_t; |
17 | 17 | ||
18 | typedef unsigned int size_t; |
18 | typedef unsigned int size_t; |
19 | typedef unsigned int count_t; |
19 | typedef unsigned int count_t; |
20 | typedef unsigned int addr_t; |
20 | typedef unsigned int addr_t; |
21 | 21 | ||
22 | typedef unsigned char u8; |
22 | typedef unsigned char u8; |
23 | typedef unsigned short u16; |
23 | typedef unsigned short u16; |
24 | typedef unsigned int u32; |
24 | typedef unsigned int u32; |
25 | typedef unsigned long long u64; |
25 | typedef unsigned long long u64; |
26 | 26 | ||
27 | typedef unsigned char __u8; |
27 | typedef unsigned char __u8; |
28 | typedef unsigned short __u16; |
28 | typedef unsigned short __u16; |
29 | typedef unsigned int __u32; |
29 | typedef unsigned int __u32; |
30 | typedef unsigned long long __u64; |
30 | typedef unsigned long long __u64; |
31 | 31 | ||
32 | typedef signed char __s8; |
32 | typedef signed char __s8; |
33 | typedef signed short __s16; |
33 | typedef signed short __s16; |
34 | typedef signed int __s32; |
34 | typedef signed int __s32; |
35 | typedef signed long long __s64; |
35 | typedef signed long long __s64; |
36 | 36 | ||
- | 37 | typedef __u32 __be32; |
|
37 | 38 | ||
38 | typedef unsigned char uint8_t; |
39 | typedef unsigned char uint8_t; |
39 | typedef unsigned short uint16_t; |
40 | typedef unsigned short uint16_t; |
40 | typedef unsigned int uint32_t; |
41 | typedef unsigned int uint32_t; |
41 | typedef unsigned long long uint64_t; |
42 | typedef unsigned long long uint64_t; |
42 | 43 | ||
43 | typedef unsigned char u8_t; |
44 | typedef unsigned char u8_t; |
44 | typedef unsigned short u16_t; |
45 | typedef unsigned short u16_t; |
45 | typedef unsigned int u32_t; |
46 | typedef unsigned int u32_t; |
46 | typedef unsigned long long u64_t; |
47 | typedef unsigned long long u64_t; |
47 | 48 | ||
48 | typedef signed char int8_t; |
49 | typedef signed char int8_t; |
49 | typedef signed int int32_t; |
50 | typedef signed int int32_t; |
50 | typedef signed long long int64_t; |
51 | typedef signed long long int64_t; |
51 | 52 | ||
52 | #define NULL (void*)0 |
53 | #define NULL (void*)0 |
53 | 54 | ||
54 | typedef uint32_t dma_addr_t; |
55 | typedef uint32_t dma_addr_t; |
55 | typedef uint32_t resource_size_t; |
56 | typedef uint32_t resource_size_t; |
56 | 57 | ||
57 | 58 | ||
58 | #define cpu_to_le16(v16) (v16) |
59 | #define cpu_to_le16(v16) (v16) |
59 | #define cpu_to_le32(v32) (v32) |
60 | #define cpu_to_le32(v32) (v32) |
60 | #define cpu_to_le64(v64) (v64) |
61 | #define cpu_to_le64(v64) (v64) |
61 | #define le16_to_cpu(v16) (v16) |
62 | #define le16_to_cpu(v16) (v16) |
62 | #define le32_to_cpu(v32) (v32) |
63 | #define le32_to_cpu(v32) (v32) |
63 | #define le64_to_cpu(v64) (v64) |
64 | #define le64_to_cpu(v64) (v64) |
64 | 65 | ||
65 | #define likely(x) __builtin_expect(!!(x), 1) |
66 | #define likely(x) __builtin_expect(!!(x), 1) |
66 | #define unlikely(x) __builtin_expect(!!(x), 0) |
67 | #define unlikely(x) __builtin_expect(!!(x), 0) |
67 | 68 | ||
68 | #define BITS_PER_LONG 32 |
69 | #define BITS_PER_LONG 32 |
69 | 70 | ||
70 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
71 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
71 | 72 | ||
72 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) |
73 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) |
73 | 74 | ||
74 | #define DECLARE_BITMAP(name,bits) \ |
75 | #define DECLARE_BITMAP(name,bits) \ |
75 | unsigned long name[BITS_TO_LONGS(bits)] |
76 | unsigned long name[BITS_TO_LONGS(bits)] |
76 | 77 | ||
77 | 78 | ||
78 | #define KERN_EMERG "<0>" /* system is unusable */ |
79 | #define KERN_EMERG "<0>" /* system is unusable */ |
79 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
80 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
80 | #define KERN_CRIT "<2>" /* critical conditions */ |
81 | #define KERN_CRIT "<2>" /* critical conditions */ |
81 | #define KERN_ERR "<3>" /* error conditions */ |
82 | #define KERN_ERR "<3>" /* error conditions */ |
82 | #define KERN_WARNING "<4>" /* warning conditions */ |
83 | #define KERN_WARNING "<4>" /* warning conditions */ |
83 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
84 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
84 | #define KERN_INFO "<6>" /* informational */ |
85 | #define KERN_INFO "<6>" /* informational */ |
85 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
86 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
86 | 87 | ||
87 | //int printk(const char *fmt, ...); |
88 | //int printk(const char *fmt, ...); |
88 | 89 | ||
89 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
90 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
90 | 91 | ||
91 | 92 | ||
92 | #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */ |
93 | #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */ |
93 | 94 | ||
94 | #define DRM_INFO(fmt, arg...) dbgprintf("DRM: "fmt , ##arg) |
95 | #define DRM_INFO(fmt, arg...) dbgprintf("DRM: "fmt , ##arg) |
95 | 96 | ||
96 | #define DRM_ERROR(fmt, arg...) \ |
97 | #define DRM_ERROR(fmt, arg...) \ |
97 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
98 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
98 | 99 | ||
99 | #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) |
100 | #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) |
100 | 101 | ||
101 | #define __must_be_array(a) \ |
102 | #define __must_be_array(a) \ |
102 | BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) |
103 | BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) |
103 | 104 | ||
104 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
105 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
105 | 106 | ||
106 | 107 | ||
107 | 108 | ||
108 | 109 | ||
109 | #ifndef HAVE_ARCH_BUG |
110 | #ifndef HAVE_ARCH_BUG |
110 | #define BUG() do { \ |
111 | #define BUG() do { \ |
111 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
112 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
112 | /* panic("BUG!"); */ \ |
113 | /* panic("BUG!"); */ \ |
113 | } while (0) |
114 | } while (0) |
114 | #endif |
115 | #endif |
115 | 116 | ||
116 | #ifndef HAVE_ARCH_BUG_ON |
117 | #ifndef HAVE_ARCH_BUG_ON |
117 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
118 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
118 | #endif |
119 | #endif |
119 | 120 | ||
120 | 121 | ||
121 | 122 | ||
122 | #define MTRR_TYPE_UNCACHABLE 0 |
123 | #define MTRR_TYPE_UNCACHABLE 0 |
123 | #define MTRR_TYPE_WRCOMB 1 |
124 | #define MTRR_TYPE_WRCOMB 1 |
124 | #define MTRR_TYPE_WRTHROUGH 4 |
125 | #define MTRR_TYPE_WRTHROUGH 4 |
125 | #define MTRR_TYPE_WRPROT 5 |
126 | #define MTRR_TYPE_WRPROT 5 |
126 | #define MTRR_TYPE_WRBACK 6 |
127 | #define MTRR_TYPE_WRBACK 6 |
127 | #define MTRR_NUM_TYPES 7 |
128 | #define MTRR_NUM_TYPES 7 |
128 | 129 | ||
129 | int dbgprintf(const char* format, ...); |
130 | int dbgprintf(const char* format, ...); |
130 | 131 | ||
131 | #define GFP_KERNEL 0 |
132 | #define GFP_KERNEL 0 |
132 | 133 | ||
133 | //#include |
134 | //#include |
134 | 135 | ||
135 | int snprintf(char *str, size_t size, const char *format, ...); |
136 | int snprintf(char *str, size_t size, const char *format, ...); |
136 | 137 | ||
137 | 138 | ||
138 | //#include |
139 | //#include |
139 | 140 | ||
140 | void* memcpy(void *s1, const void *s2, size_t n); |
141 | void* memcpy(void *s1, const void *s2, size_t n); |
141 | void* memset(void *s, int c, size_t n); |
142 | void* memset(void *s, int c, size_t n); |
142 | size_t strlen(const char *s); |
143 | size_t strlen(const char *s); |
143 | char *strcpy(char *s1, const char *s2); |
144 | char *strcpy(char *s1, const char *s2); |
144 | char *strncpy (char *dst, const char *src, size_t len); |
145 | char *strncpy (char *dst, const char *src, size_t len); |
145 | 146 | ||
146 | void *malloc(size_t size); |
147 | void *malloc(size_t size); |
147 | 148 | ||
148 | #define kmalloc(s,f) malloc((s)) |
149 | #define kmalloc(s,f) malloc((s)) |
149 | #define kfree free |
150 | #define kfree free |
150 | 151 | ||
151 | static inline void *kzalloc(size_t size, u32_t flags) |
152 | static inline void *kzalloc(size_t size, u32_t flags) |
152 | { |
153 | { |
153 | void *ret = malloc(size); |
154 | void *ret = malloc(size); |
154 | memset(ret, 0, size); |
155 | memset(ret, 0, size); |
155 | return ret; |
156 | return ret; |
156 | } |
157 | } |
157 | 158 | ||
158 | struct drm_file; |
159 | struct drm_file; |
159 | 160 | ||
160 | #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER) |
161 | #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER) |
161 | 162 | ||
162 | #define container_of(ptr, type, member) ({ \ |
163 | #define container_of(ptr, type, member) ({ \ |
163 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
164 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
164 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
165 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
165 | 166 | ||
166 | 167 | ||
167 | 168 | ||
168 | #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)") |
169 | #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)") |
169 | #define mb() __asm__ __volatile__("lock; addl $0,0(%esp)") |
170 | #define mb() __asm__ __volatile__("lock; addl $0,0(%esp)") |
170 | 171 | ||
171 | 172 | ||
172 | #define PAGE_SHIFT 12 |
173 | #define PAGE_SHIFT 12 |
173 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
174 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
174 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
175 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
175 | 176 | ||
176 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
177 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
177 | 178 | ||
178 | static inline void bitmap_zero(unsigned long *dst, int nbits) |
179 | static inline void bitmap_zero(unsigned long *dst, int nbits) |
179 | { |
180 | { |
180 | if (nbits <= BITS_PER_LONG) |
181 | if (nbits <= BITS_PER_LONG) |
181 | *dst = 0UL; |
182 | *dst = 0UL; |
182 | else { |
183 | else { |
183 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
184 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); |
184 | memset(dst, 0, len); |
185 | memset(dst, 0, len); |
185 | } |
186 | } |
186 | } |
187 | } |
187 | 188 | ||
188 | #define EXPORT_SYMBOL(x) |
189 | #define EXPORT_SYMBOL(x) |
189 | 190 | ||
190 | #define min(x,y) ({ \ |
191 | #define min(x,y) ({ \ |
191 | typeof(x) _x = (x); \ |
192 | typeof(x) _x = (x); \ |
192 | typeof(y) _y = (y); \ |
193 | typeof(y) _y = (y); \ |
193 | (void) (&_x == &_y); \ |
194 | (void) (&_x == &_y); \ |
194 | _x < _y ? _x : _y; }) |
195 | _x < _y ? _x : _y; }) |
195 | 196 | ||
196 | #define max(x,y) ({ \ |
197 | #define max(x,y) ({ \ |
197 | typeof(x) _x = (x); \ |
198 | typeof(x) _x = (x); \ |
198 | typeof(y) _y = (y); \ |
199 | typeof(y) _y = (y); \ |
199 | (void) (&_x == &_y); \ |
200 | (void) (&_x == &_y); \ |
200 | _x > _y ? _x : _y; }) |
201 | _x > _y ? _x : _y; }) |
201 | 202 | ||
202 | - | ||
203 | extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); |
203 | #define do_div(n, base) \ |
204 | - | ||
205 | # define do_div(n,base) ({ \ |
204 | ({ \ |
- | 205 | unsigned long __upper, __low, __high, __mod, __base; \ |
|
206 | uint32_t __base = (base); \ |
206 | __base = (base); \ |
207 | uint32_t __rem; \ |
207 | asm("":"=a" (__low), "=d" (__high) : "A" (n)); \ |
208 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ |
208 | __upper = __high; \ |
209 | if (likely(((n) >> 32) == 0)) { \ |
209 | if (__high) { \ |
210 | __rem = (uint32_t)(n) % __base; \ |
210 | __upper = __high % (__base); \ |
211 | (n) = (uint32_t)(n) / __base; \ |
211 | __high = __high / (__base); \ |
212 | } else \ |
212 | } \ |
- | 213 | asm("divl %2":"=a" (__low), "=d" (__mod) \ |
|
213 | __rem = __div64_32(&(n), __base); \ |
214 | : "rm" (__base), "0" (__low), "1" (__upper)); \ |
- | 215 | asm("":"=A" (n) : "a" (__low), "d" (__high)); \ |
|
214 | __rem; \ |
216 | __mod; \ |
215 | }) |
217 | }) |
- | 218 | ||
216 | 219 | ||
217 | #define lower_32_bits(n) ((u32)(n)) |
220 | #define lower_32_bits(n) ((u32)(n)) |
218 | 221 | ||
219 | #define INT_MAX ((int)(~0U>>1)) |
222 | #define INT_MAX ((int)(~0U>>1)) |
220 | #define INT_MIN (-INT_MAX - 1) |
223 | #define INT_MIN (-INT_MAX - 1) |
221 | #define UINT_MAX (~0U) |
224 | #define UINT_MAX (~0U) |
222 | #define LONG_MAX ((long)(~0UL>>1)) |
225 | #define LONG_MAX ((long)(~0UL>>1)) |
223 | #define LONG_MIN (-LONG_MAX - 1) |
226 | #define LONG_MIN (-LONG_MAX - 1) |
224 | #define ULONG_MAX (~0UL) |
227 | #define ULONG_MAX (~0UL) |
225 | #define LLONG_MAX ((long long)(~0ULL>>1)) |
228 | #define LLONG_MAX ((long long)(~0ULL>>1)) |
226 | #define LLONG_MIN (-LLONG_MAX - 1) |
229 | #define LLONG_MIN (-LLONG_MAX - 1) |
227 | #define ULLONG_MAX (~0ULL) |
230 | #define ULLONG_MAX (~0ULL) |
228 | 231 | ||
229 | 232 | ||
230 | static inline void *kcalloc(size_t n, size_t size, u32_t flags) |
233 | static inline void *kcalloc(size_t n, size_t size, u32_t flags) |
231 | { |
234 | { |
232 | if (n != 0 && size > ULONG_MAX / n) |
235 | if (n != 0 && size > ULONG_MAX / n) |
233 | return NULL; |
236 | return NULL; |
234 | return kzalloc(n * size, 0); |
237 | return kzalloc(n * size, 0); |
235 | } |
238 | } |
236 | 239 | ||
237 | #define ENTER() dbgprintf("enter %s\n",__FUNCTION__) |
240 | #define ENTER() dbgprintf("enter %s\n",__FUNCTION__) |
238 | #define LEAVE() dbgprintf("leave %s\n",__FUNCTION__) |
241 | #define LEAVE() dbgprintf("leave %s\n",__FUNCTION__) |
239 | 242 | ||
240 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
243 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
241 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
244 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
242 | 245 | ||
243 | #define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 |
246 | #define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 |
244 | 247 | ||
245 | 248 | ||
246 | #endif //__TYPES_H__>=>><>>7>6>5>4>3>2>1>0> |
249 | #endif //__TYPES_H__>=>><>>7>6>5>4>3>2>1>0> |