Rev 1117 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1117 | Rev 1119 | ||
---|---|---|---|
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 | #define NULL (void*)0 |
40 | #define NULL (void*)0 |
41 | 41 | ||
42 | typedef uint32_t dma_addr_t; |
42 | typedef uint32_t dma_addr_t; |
43 | typedef uint32_t resource_size_t; |
43 | typedef uint32_t resource_size_t; |
44 | 44 | ||
45 | #define __user |
45 | #define __user |
46 | 46 | ||
47 | #define cpu_to_le16(v16) (v16) |
47 | #define cpu_to_le16(v16) (v16) |
48 | #define cpu_to_le32(v32) (v32) |
48 | #define cpu_to_le32(v32) (v32) |
49 | #define cpu_to_le64(v64) (v64) |
49 | #define cpu_to_le64(v64) (v64) |
50 | #define le16_to_cpu(v16) (v16) |
50 | #define le16_to_cpu(v16) (v16) |
51 | #define le32_to_cpu(v32) (v32) |
51 | #define le32_to_cpu(v32) (v32) |
52 | #define le64_to_cpu(v64) (v64) |
52 | #define le64_to_cpu(v64) (v64) |
53 | 53 | ||
54 | #define likely(x) __builtin_expect(!!(x), 1) |
54 | #define likely(x) __builtin_expect(!!(x), 1) |
55 | #define unlikely(x) __builtin_expect(!!(x), 0) |
55 | #define unlikely(x) __builtin_expect(!!(x), 0) |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | #define KERN_EMERG "<0>" /* system is unusable */ |
59 | #define KERN_EMERG "<0>" /* system is unusable */ |
60 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
60 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
61 | #define KERN_CRIT "<2>" /* critical conditions */ |
61 | #define KERN_CRIT "<2>" /* critical conditions */ |
62 | #define KERN_ERR "<3>" /* error conditions */ |
62 | #define KERN_ERR "<3>" /* error conditions */ |
63 | #define KERN_WARNING "<4>" /* warning conditions */ |
63 | #define KERN_WARNING "<4>" /* warning conditions */ |
64 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
64 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
65 | #define KERN_INFO "<6>" /* informational */ |
65 | #define KERN_INFO "<6>" /* informational */ |
66 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
66 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
67 | 67 | ||
68 | //int printk(const char *fmt, ...); |
68 | //int printk(const char *fmt, ...); |
69 | 69 | ||
70 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
70 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
71 | 71 | ||
72 | 72 | ||
73 | #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */ |
73 | #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */ |
74 | 74 | ||
75 | #define DRM_INFO(fmt, arg...) dbgprintf("DRM: "fmt , ##arg) |
75 | #define DRM_INFO(fmt, arg...) dbgprintf("DRM: "fmt , ##arg) |
76 | 76 | ||
77 | #define DRM_DEBUG(fmt, arg...) \ |
77 | #define DRM_DEBUG(fmt, arg...) \ |
78 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
78 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
79 | 79 | ||
80 | #define DRM_ERROR(fmt, arg...) \ |
80 | #define DRM_ERROR(fmt, arg...) \ |
81 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
81 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg) |
82 | 82 | ||
83 | #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) |
83 | #define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1) |
84 | 84 | ||
85 | #define __must_be_array(a) \ |
85 | #define __must_be_array(a) \ |
86 | BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) |
86 | BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) |
87 | 87 | ||
88 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
88 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | #ifndef HAVE_ARCH_BUG |
93 | #ifndef HAVE_ARCH_BUG |
94 | #define BUG() do { \ |
94 | #define BUG() do { \ |
95 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
95 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
96 | /* panic("BUG!"); */ \ |
96 | /* panic("BUG!"); */ \ |
97 | } while (0) |
97 | } while (0) |
98 | #endif |
98 | #endif |
99 | 99 | ||
100 | #ifndef HAVE_ARCH_BUG_ON |
100 | #ifndef HAVE_ARCH_BUG_ON |
101 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
101 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
102 | #endif |
102 | #endif |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | #define MTRR_TYPE_UNCACHABLE 0 |
106 | #define MTRR_TYPE_UNCACHABLE 0 |
107 | #define MTRR_TYPE_WRCOMB 1 |
107 | #define MTRR_TYPE_WRCOMB 1 |
108 | #define MTRR_TYPE_WRTHROUGH 4 |
108 | #define MTRR_TYPE_WRTHROUGH 4 |
109 | #define MTRR_TYPE_WRPROT 5 |
109 | #define MTRR_TYPE_WRPROT 5 |
110 | #define MTRR_TYPE_WRBACK 6 |
110 | #define MTRR_TYPE_WRBACK 6 |
111 | #define MTRR_NUM_TYPES 7 |
111 | #define MTRR_NUM_TYPES 7 |
112 | 112 | ||
113 | int dbgprintf(const char* format, ...); |
113 | int dbgprintf(const char* format, ...); |
114 | 114 | ||
115 | #define GFP_KERNEL 0 |
115 | #define GFP_KERNEL 0 |
116 | 116 | ||
117 | //#include |
117 | //#include |
118 | 118 | ||
119 | void* memcpy(void *s1, const void *s2, size_t n); |
119 | void* memcpy(void *s1, const void *s2, size_t n); |
120 | void* memset(void *s, int c, size_t n); |
120 | void* memset(void *s, int c, size_t n); |
121 | size_t strlen(const char *s); |
121 | size_t strlen(const char *s); |
122 | 122 | ||
123 | void *malloc(size_t size); |
123 | void *malloc(size_t size); |
124 | 124 | ||
125 | #define kfree free |
125 | #define kfree free |
126 | 126 | ||
127 | static inline void *kzalloc(size_t size, u32_t flags) |
127 | static inline void *kzalloc(size_t size, u32_t flags) |
128 | { |
128 | { |
129 | void *ret = malloc(size); |
129 | void *ret = malloc(size); |
130 | memset(ret, 0, size); |
130 | memset(ret, 0, size); |
131 | return ret; |
131 | return ret; |
132 | } |
132 | } |
133 | 133 | ||
134 | struct drm_gem_object { |
134 | struct drm_gem_object { |
135 | 135 | ||
136 | /** Reference count of this object */ |
136 | /** Reference count of this object */ |
137 | // struct kref refcount; |
137 | // struct kref refcount; |
138 | 138 | ||
139 | /** Handle count of this object. Each handle also holds a reference */ |
139 | /** Handle count of this object. Each handle also holds a reference */ |
140 | // struct kref handlecount; |
140 | // struct kref handlecount; |
141 | 141 | ||
142 | /** Related drm device */ |
142 | /** Related drm device */ |
143 | // struct drm_device *dev; |
143 | // struct drm_device *dev; |
144 | 144 | ||
145 | /** File representing the shmem storage */ |
145 | /** File representing the shmem storage */ |
146 | // struct file *filp; |
146 | // struct file *filp; |
147 | 147 | ||
148 | /* Mapping info for this object */ |
148 | /* Mapping info for this object */ |
149 | // struct drm_map_list map_list; |
149 | // struct drm_map_list map_list; |
150 | 150 | ||
151 | /** |
151 | /** |
152 | * Size of the object, in bytes. Immutable over the object's |
152 | * Size of the object, in bytes. Immutable over the object's |
153 | * lifetime. |
153 | * lifetime. |
154 | */ |
154 | */ |
155 | size_t size; |
155 | size_t size; |
156 | 156 | ||
157 | /** |
157 | /** |
158 | * Global name for this object, starts at 1. 0 means unnamed. |
158 | * Global name for this object, starts at 1. 0 means unnamed. |
159 | * Access is covered by the object_name_lock in the related drm_device |
159 | * Access is covered by the object_name_lock in the related drm_device |
160 | */ |
160 | */ |
161 | int name; |
161 | int name; |
162 | 162 | ||
163 | /** |
163 | /** |
164 | * Memory domains. These monitor which caches contain read/write data |
164 | * Memory domains. These monitor which caches contain read/write data |
165 | * related to the object. When transitioning from one set of domains |
165 | * related to the object. When transitioning from one set of domains |
166 | * to another, the driver is called to ensure that caches are suitably |
166 | * to another, the driver is called to ensure that caches are suitably |
167 | * flushed and invalidated |
167 | * flushed and invalidated |
168 | */ |
168 | */ |
169 | uint32_t read_domains; |
169 | uint32_t read_domains; |
170 | uint32_t write_domain; |
170 | uint32_t write_domain; |
171 | 171 | ||
172 | /** |
172 | /** |
173 | * While validating an exec operation, the |
173 | * While validating an exec operation, the |
174 | * new read/write domain values are computed here. |
174 | * new read/write domain values are computed here. |
175 | * They will be transferred to the above values |
175 | * They will be transferred to the above values |
176 | * at the point that any cache flushing occurs |
176 | * at the point that any cache flushing occurs |
177 | */ |
177 | */ |
178 | uint32_t pending_read_domains; |
178 | uint32_t pending_read_domains; |
179 | uint32_t pending_write_domain; |
179 | uint32_t pending_write_domain; |
180 | 180 | ||
181 | void *driver_private; |
181 | void *driver_private; |
182 | }; |
182 | }; |
183 | 183 | ||
184 | struct drm_file; |
184 | struct drm_file; |
185 | 185 | ||
186 | #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER) |
186 | #define offsetof(TYPE,MEMBER) __builtin_offsetof(TYPE,MEMBER) |
187 | 187 | ||
188 | #define container_of(ptr, type, member) ({ \ |
188 | #define container_of(ptr, type, member) ({ \ |
189 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
189 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
190 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
190 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
191 | 191 | ||
192 | 192 | ||
193 | 193 | ||
194 | #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)") |
194 | #define DRM_MEMORYBARRIER() __asm__ __volatile__("lock; addl $0,0(%esp)") |
195 | 195 | #define mb() __asm__ __volatile__("lock; addl $0,0(%esp)") |
|
- | 196 | ||
- | 197 | #define PAGE_SIZE 4096 |
|
- | 198 | #define PAGE_SHIFT 12 |
|
- | 199 | ||
- | 200 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
|
196 | 201 | ||
197 | 202 | ||
198 | #endif //__TYPES_H__>7>6>5>4>3>2>1>0> |
203 | #endif //__TYPES_H__>7>6>5>4>3>2>1>0> |