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