Rev 3262 | Rev 3480 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3262 | Rev 3391 | ||
---|---|---|---|
1 | #ifndef _LINUX_KERNEL_H |
1 | #ifndef _LINUX_KERNEL_H |
2 | #define _LINUX_KERNEL_H |
2 | #define _LINUX_KERNEL_H |
3 | 3 | ||
4 | /* |
4 | /* |
5 | * 'kernel.h' contains some often-used function prototypes etc |
5 | * 'kernel.h' contains some often-used function prototypes etc |
6 | */ |
6 | */ |
7 | 7 | ||
8 | #ifdef __KERNEL__ |
8 | #ifdef __KERNEL__ |
9 | 9 | ||
10 | #include |
10 | #include |
11 | #include |
11 | #include |
12 | #include |
12 | #include |
13 | #include |
13 | #include |
14 | #include |
14 | #include |
15 | 15 | ||
16 | #include |
16 | #include |
17 | 17 | ||
18 | #define __init |
18 | #define __init |
19 | 19 | ||
20 | #define USHRT_MAX ((u16)(~0U)) |
20 | #define USHRT_MAX ((u16)(~0U)) |
21 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
21 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
22 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) |
22 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) |
23 | #define INT_MAX ((int)(~0U>>1)) |
23 | #define INT_MAX ((int)(~0U>>1)) |
24 | #define INT_MIN (-INT_MAX - 1) |
24 | #define INT_MIN (-INT_MAX - 1) |
25 | #define UINT_MAX (~0U) |
25 | #define UINT_MAX (~0U) |
26 | #define LONG_MAX ((long)(~0UL>>1)) |
26 | #define LONG_MAX ((long)(~0UL>>1)) |
27 | #define LONG_MIN (-LONG_MAX - 1) |
27 | #define LONG_MIN (-LONG_MAX - 1) |
28 | #define ULONG_MAX (~0UL) |
28 | #define ULONG_MAX (~0UL) |
29 | #define LLONG_MAX ((long long)(~0ULL>>1)) |
29 | #define LLONG_MAX ((long long)(~0ULL>>1)) |
30 | #define LLONG_MIN (-LLONG_MAX - 1) |
30 | #define LLONG_MIN (-LLONG_MAX - 1) |
31 | #define ULLONG_MAX (~0ULL) |
31 | #define ULLONG_MAX (~0ULL) |
32 | #define SIZE_MAX (~(size_t)0) |
32 | #define SIZE_MAX (~(size_t)0) |
33 | 33 | ||
34 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
34 | #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) |
35 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
35 | #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) |
36 | #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) |
36 | #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) |
37 | #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) |
37 | #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) |
38 | 38 | ||
39 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ |
39 | /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ |
40 | #define roundup(x, y) ( \ |
40 | #define roundup(x, y) ( \ |
41 | { \ |
41 | { \ |
42 | const typeof(y) __y = y; \ |
42 | const typeof(y) __y = y; \ |
43 | (((x) + (__y - 1)) / __y) * __y; \ |
43 | (((x) + (__y - 1)) / __y) * __y; \ |
44 | } \ |
44 | } \ |
45 | ) |
45 | ) |
46 | 46 | ||
47 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
47 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
48 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
48 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
49 | { \ |
49 | { \ |
50 | typeof(divisor) __divisor = divisor; \ |
50 | typeof(divisor) __divisor = divisor; \ |
51 | (((x) + ((__divisor) / 2)) / (__divisor)); \ |
51 | (((x) + ((__divisor) / 2)) / (__divisor)); \ |
52 | } \ |
52 | } \ |
53 | ) |
53 | ) |
54 | 54 | ||
55 | /** |
55 | /** |
56 | * upper_32_bits - return bits 32-63 of a number |
56 | * upper_32_bits - return bits 32-63 of a number |
57 | * @n: the number we're accessing |
57 | * @n: the number we're accessing |
58 | * |
58 | * |
59 | * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress |
59 | * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress |
60 | * the "right shift count >= width of type" warning when that quantity is |
60 | * the "right shift count >= width of type" warning when that quantity is |
61 | * 32-bits. |
61 | * 32-bits. |
62 | */ |
62 | */ |
63 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
63 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
64 | 64 | ||
65 | /** |
65 | /** |
66 | * lower_32_bits - return bits 0-31 of a number |
66 | * lower_32_bits - return bits 0-31 of a number |
67 | * @n: the number we're accessing |
67 | * @n: the number we're accessing |
68 | */ |
68 | */ |
69 | #define lower_32_bits(n) ((u32)(n)) |
69 | #define lower_32_bits(n) ((u32)(n)) |
70 | 70 | ||
71 | #define KERN_EMERG "<0>" /* system is unusable */ |
71 | #define KERN_EMERG "<0>" /* system is unusable */ |
72 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
72 | #define KERN_ALERT "<1>" /* action must be taken immediately */ |
73 | #define KERN_CRIT "<2>" /* critical conditions */ |
73 | #define KERN_CRIT "<2>" /* critical conditions */ |
74 | #define KERN_ERR "<3>" /* error conditions */ |
74 | #define KERN_ERR "<3>" /* error conditions */ |
75 | #define KERN_WARNING "<4>" /* warning conditions */ |
75 | #define KERN_WARNING "<4>" /* warning conditions */ |
76 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
76 | #define KERN_NOTICE "<5>" /* normal but significant condition */ |
77 | #define KERN_INFO "<6>" /* informational */ |
77 | #define KERN_INFO "<6>" /* informational */ |
78 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
78 | #define KERN_DEBUG "<7>" /* debug-level messages */ |
79 | extern const char hex_asc[]; |
79 | extern const char hex_asc[]; |
80 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
80 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] |
81 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
81 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] |
82 | 82 | ||
83 | static inline char *pack_hex_byte(char *buf, u8 byte) |
83 | static inline char *pack_hex_byte(char *buf, u8 byte) |
84 | { |
84 | { |
85 | *buf++ = hex_asc_hi(byte); |
85 | *buf++ = hex_asc_hi(byte); |
86 | *buf++ = hex_asc_lo(byte); |
86 | *buf++ = hex_asc_lo(byte); |
87 | return buf; |
87 | return buf; |
88 | } |
88 | } |
89 | 89 | ||
90 | extern int hex_to_bin(char ch); |
90 | extern int hex_to_bin(char ch); |
91 | extern void hex2bin(u8 *dst, const char *src, size_t count); |
91 | extern void hex2bin(u8 *dst, const char *src, size_t count); |
92 | 92 | ||
93 | 93 | ||
94 | //int printk(const char *fmt, ...); |
94 | //int printk(const char *fmt, ...); |
95 | 95 | ||
96 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
96 | #define printk(fmt, arg...) dbgprintf(fmt , ##arg) |
97 | 97 | ||
98 | 98 | ||
99 | /* |
99 | /* |
100 | * min()/max()/clamp() macros that also do |
100 | * min()/max()/clamp() macros that also do |
101 | * strict type-checking.. See the |
101 | * strict type-checking.. See the |
102 | * "unnecessary" pointer comparison. |
102 | * "unnecessary" pointer comparison. |
103 | */ |
103 | */ |
104 | #define min(x, y) ({ \ |
104 | #define min(x, y) ({ \ |
105 | typeof(x) _min1 = (x); \ |
105 | typeof(x) _min1 = (x); \ |
106 | typeof(y) _min2 = (y); \ |
106 | typeof(y) _min2 = (y); \ |
107 | (void) (&_min1 == &_min2); \ |
107 | (void) (&_min1 == &_min2); \ |
108 | _min1 < _min2 ? _min1 : _min2; }) |
108 | _min1 < _min2 ? _min1 : _min2; }) |
109 | 109 | ||
110 | #define max(x, y) ({ \ |
110 | #define max(x, y) ({ \ |
111 | typeof(x) _max1 = (x); \ |
111 | typeof(x) _max1 = (x); \ |
112 | typeof(y) _max2 = (y); \ |
112 | typeof(y) _max2 = (y); \ |
113 | (void) (&_max1 == &_max2); \ |
113 | (void) (&_max1 == &_max2); \ |
114 | _max1 > _max2 ? _max1 : _max2; }) |
114 | _max1 > _max2 ? _max1 : _max2; }) |
115 | 115 | ||
116 | #define min3(x, y, z) ({ \ |
116 | #define min3(x, y, z) ({ \ |
117 | typeof(x) _min1 = (x); \ |
117 | typeof(x) _min1 = (x); \ |
118 | typeof(y) _min2 = (y); \ |
118 | typeof(y) _min2 = (y); \ |
119 | typeof(z) _min3 = (z); \ |
119 | typeof(z) _min3 = (z); \ |
120 | (void) (&_min1 == &_min2); \ |
120 | (void) (&_min1 == &_min2); \ |
121 | (void) (&_min1 == &_min3); \ |
121 | (void) (&_min1 == &_min3); \ |
122 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ |
122 | _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ |
123 | (_min2 < _min3 ? _min2 : _min3); }) |
123 | (_min2 < _min3 ? _min2 : _min3); }) |
124 | 124 | ||
125 | #define max3(x, y, z) ({ \ |
125 | #define max3(x, y, z) ({ \ |
126 | typeof(x) _max1 = (x); \ |
126 | typeof(x) _max1 = (x); \ |
127 | typeof(y) _max2 = (y); \ |
127 | typeof(y) _max2 = (y); \ |
128 | typeof(z) _max3 = (z); \ |
128 | typeof(z) _max3 = (z); \ |
129 | (void) (&_max1 == &_max2); \ |
129 | (void) (&_max1 == &_max2); \ |
130 | (void) (&_max1 == &_max3); \ |
130 | (void) (&_max1 == &_max3); \ |
131 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ |
131 | _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ |
132 | (_max2 > _max3 ? _max2 : _max3); }) |
132 | (_max2 > _max3 ? _max2 : _max3); }) |
133 | 133 | ||
134 | /** |
134 | /** |
135 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero |
135 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero |
136 | * @x: value1 |
136 | * @x: value1 |
137 | * @y: value2 |
137 | * @y: value2 |
138 | */ |
138 | */ |
139 | #define min_not_zero(x, y) ({ \ |
139 | #define min_not_zero(x, y) ({ \ |
140 | typeof(x) __x = (x); \ |
140 | typeof(x) __x = (x); \ |
141 | typeof(y) __y = (y); \ |
141 | typeof(y) __y = (y); \ |
142 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) |
142 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) |
143 | 143 | ||
144 | /** |
144 | /** |
145 | * clamp - return a value clamped to a given range with strict typechecking |
145 | * clamp - return a value clamped to a given range with strict typechecking |
146 | * @val: current value |
146 | * @val: current value |
147 | * @min: minimum allowable value |
147 | * @min: minimum allowable value |
148 | * @max: maximum allowable value |
148 | * @max: maximum allowable value |
149 | * |
149 | * |
150 | * This macro does strict typechecking of min/max to make sure they are of the |
150 | * This macro does strict typechecking of min/max to make sure they are of the |
151 | * same type as val. See the unnecessary pointer comparisons. |
151 | * same type as val. See the unnecessary pointer comparisons. |
152 | */ |
152 | */ |
153 | #define clamp(val, min, max) ({ \ |
153 | #define clamp(val, min, max) ({ \ |
154 | typeof(val) __val = (val); \ |
154 | typeof(val) __val = (val); \ |
155 | typeof(min) __min = (min); \ |
155 | typeof(min) __min = (min); \ |
156 | typeof(max) __max = (max); \ |
156 | typeof(max) __max = (max); \ |
157 | (void) (&__val == &__min); \ |
157 | (void) (&__val == &__min); \ |
158 | (void) (&__val == &__max); \ |
158 | (void) (&__val == &__max); \ |
159 | __val = __val < __min ? __min: __val; \ |
159 | __val = __val < __min ? __min: __val; \ |
160 | __val > __max ? __max: __val; }) |
160 | __val > __max ? __max: __val; }) |
161 | 161 | ||
162 | /* |
162 | /* |
163 | * ..and if you can't take the strict |
163 | * ..and if you can't take the strict |
164 | * types, you can specify one yourself. |
164 | * types, you can specify one yourself. |
165 | * |
165 | * |
166 | * Or not use min/max/clamp at all, of course. |
166 | * Or not use min/max/clamp at all, of course. |
167 | */ |
167 | */ |
168 | #define min_t(type, x, y) ({ \ |
168 | #define min_t(type, x, y) ({ \ |
169 | type __min1 = (x); \ |
169 | type __min1 = (x); \ |
170 | type __min2 = (y); \ |
170 | type __min2 = (y); \ |
171 | __min1 < __min2 ? __min1: __min2; }) |
171 | __min1 < __min2 ? __min1: __min2; }) |
172 | 172 | ||
173 | #define max_t(type, x, y) ({ \ |
173 | #define max_t(type, x, y) ({ \ |
174 | type __max1 = (x); \ |
174 | type __max1 = (x); \ |
175 | type __max2 = (y); \ |
175 | type __max2 = (y); \ |
176 | __max1 > __max2 ? __max1: __max2; }) |
176 | __max1 > __max2 ? __max1: __max2; }) |
177 | 177 | ||
178 | /** |
178 | /** |
179 | * container_of - cast a member of a structure out to the containing structure |
179 | * container_of - cast a member of a structure out to the containing structure |
180 | * @ptr: the pointer to the member. |
180 | * @ptr: the pointer to the member. |
181 | * @type: the type of the container struct this is embedded in. |
181 | * @type: the type of the container struct this is embedded in. |
182 | * @member: the name of the member within the struct. |
182 | * @member: the name of the member within the struct. |
183 | * |
183 | * |
184 | */ |
184 | */ |
185 | #define container_of(ptr, type, member) ({ \ |
185 | #define container_of(ptr, type, member) ({ \ |
186 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
186 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
187 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
187 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
188 | 188 | ||
189 | 189 | ||
190 | static inline void *kcalloc(size_t n, size_t size, uint32_t flags) |
190 | static inline void *kcalloc(size_t n, size_t size, uint32_t flags) |
191 | { |
191 | { |
192 | if (n != 0 && size > ULONG_MAX / n) |
192 | if (n != 0 && size > ULONG_MAX / n) |
193 | return NULL; |
193 | return NULL; |
194 | return kzalloc(n * size, 0); |
194 | return kzalloc(n * size, 0); |
195 | } |
195 | } |
196 | 196 | ||
197 | 197 | ||
198 | void free (void *ptr); |
198 | void free (void *ptr); |
199 | 199 | ||
200 | #endif /* __KERNEL__ */ |
200 | #endif /* __KERNEL__ */ |
201 | 201 | ||
202 | typedef unsigned long pgprotval_t; |
202 | typedef unsigned long pgprotval_t; |
203 | 203 | ||
204 | typedef struct pgprot { pgprotval_t pgprot; } pgprot_t; |
204 | typedef struct pgprot { pgprotval_t pgprot; } pgprot_t; |
205 | 205 | ||
206 | struct file |
206 | struct file |
207 | { |
207 | { |
208 | struct page **pages; /* physical memory backend */ |
208 | struct page **pages; /* physical memory backend */ |
209 | unsigned int count; |
209 | unsigned int count; |
210 | unsigned int allocated; |
210 | unsigned int allocated; |
211 | void *vma; |
211 | void *vma; |
212 | }; |
212 | }; |
213 | 213 | ||
214 | struct vm_area_struct {}; |
214 | struct vm_area_struct {}; |
215 | struct address_space {}; |
215 | struct address_space {}; |
216 | 216 | ||
217 | struct device |
217 | struct device |
218 | { |
218 | { |
219 | struct device *parent; |
219 | struct device *parent; |
220 | void *driver_data; |
220 | void *driver_data; |
221 | }; |
221 | }; |
222 | 222 | ||
223 | static inline void dev_set_drvdata(struct device *dev, void *data) |
223 | static inline void dev_set_drvdata(struct device *dev, void *data) |
224 | { |
224 | { |
225 | dev->driver_data = data; |
225 | dev->driver_data = data; |
226 | } |
226 | } |
227 | 227 | ||
228 | static inline void *dev_get_drvdata(struct device *dev) |
228 | static inline void *dev_get_drvdata(struct device *dev) |
229 | { |
229 | { |
230 | return dev->driver_data; |
230 | return dev->driver_data; |
231 | } |
231 | } |
232 | 232 | ||
233 | #define preempt_disable() do { } while (0) |
233 | #define preempt_disable() do { } while (0) |
234 | #define preempt_enable_no_resched() do { } while (0) |
234 | #define preempt_enable_no_resched() do { } while (0) |
235 | #define preempt_enable() do { } while (0) |
235 | #define preempt_enable() do { } while (0) |
236 | #define preempt_check_resched() do { } while (0) |
236 | #define preempt_check_resched() do { } while (0) |
237 | 237 | ||
238 | #define preempt_disable_notrace() do { } while (0) |
238 | #define preempt_disable_notrace() do { } while (0) |
239 | #define preempt_enable_no_resched_notrace() do { } while (0) |
239 | #define preempt_enable_no_resched_notrace() do { } while (0) |
240 | #define preempt_enable_notrace() do { } while (0) |
240 | #define preempt_enable_notrace() do { } while (0) |
241 | 241 | ||
242 | #define in_dbg_master() (0) |
242 | #define in_dbg_master() (0) |
243 | 243 | ||
244 | #define HZ 100 |
244 | #define HZ 100 |
245 | 245 | ||
246 | #define time_after(a,b) \ |
246 | #define time_after(a,b) \ |
247 | (typecheck(unsigned long, a) && \ |
247 | (typecheck(unsigned long, a) && \ |
248 | typecheck(unsigned long, b) && \ |
248 | typecheck(unsigned long, b) && \ |
249 | ((long)(b) - (long)(a) < 0)) |
249 | ((long)(b) - (long)(a) < 0)) |
250 | 250 | ||
251 | struct tvec_base; |
251 | struct tvec_base; |
252 | 252 | ||
253 | struct timer_list { |
253 | struct timer_list { |
254 | struct list_head entry; |
254 | struct list_head entry; |
255 | unsigned long expires; |
255 | unsigned long expires; |
256 | 256 | ||
257 | void (*function)(unsigned long); |
257 | void (*function)(unsigned long); |
258 | unsigned long data; |
258 | unsigned long data; |
259 | 259 | ||
260 | // struct tvec_base *base; |
260 | // struct tvec_base *base; |
261 | }; |
261 | }; |
262 | 262 | ||
263 | struct timespec { |
263 | struct timespec { |
264 | long tv_sec; /* seconds */ |
264 | long tv_sec; /* seconds */ |
265 | long tv_nsec; /* nanoseconds */ |
265 | long tv_nsec; /* nanoseconds */ |
266 | }; |
266 | }; |
267 | 267 | ||
268 | 268 | ||
269 | #define build_mmio_read(name, size, type, reg, barrier) \ |
269 | #define build_mmio_read(name, size, type, reg, barrier) \ |
270 | static inline type name(const volatile void __iomem *addr) \ |
270 | static inline type name(const volatile void __iomem *addr) \ |
271 | { type ret; asm volatile("mov" size " %1,%0":reg (ret) \ |
271 | { type ret; asm volatile("mov" size " %1,%0":reg (ret) \ |
272 | :"m" (*(volatile type __force *)addr) barrier); return ret; } |
272 | :"m" (*(volatile type __force *)addr) barrier); return ret; } |
273 | 273 | ||
274 | #define build_mmio_write(name, size, type, reg, barrier) \ |
274 | #define build_mmio_write(name, size, type, reg, barrier) \ |
275 | static inline void name(type val, volatile void __iomem *addr) \ |
275 | static inline void name(type val, volatile void __iomem *addr) \ |
276 | { asm volatile("mov" size " %0,%1": :reg (val), \ |
276 | { asm volatile("mov" size " %0,%1": :reg (val), \ |
277 | "m" (*(volatile type __force *)addr) barrier); } |
277 | "m" (*(volatile type __force *)addr) barrier); } |
278 | 278 | ||
279 | build_mmio_read(readb, "b", unsigned char, "=q", :"memory") |
279 | build_mmio_read(readb, "b", unsigned char, "=q", :"memory") |
280 | build_mmio_read(readw, "w", unsigned short, "=r", :"memory") |
280 | build_mmio_read(readw, "w", unsigned short, "=r", :"memory") |
281 | build_mmio_read(readl, "l", unsigned int, "=r", :"memory") |
281 | build_mmio_read(readl, "l", unsigned int, "=r", :"memory") |
282 | 282 | ||
283 | build_mmio_read(__readb, "b", unsigned char, "=q", ) |
283 | build_mmio_read(__readb, "b", unsigned char, "=q", ) |
284 | build_mmio_read(__readw, "w", unsigned short, "=r", ) |
284 | build_mmio_read(__readw, "w", unsigned short, "=r", ) |
285 | build_mmio_read(__readl, "l", unsigned int, "=r", ) |
285 | build_mmio_read(__readl, "l", unsigned int, "=r", ) |
286 | 286 | ||
287 | build_mmio_write(writeb, "b", unsigned char, "q", :"memory") |
287 | build_mmio_write(writeb, "b", unsigned char, "q", :"memory") |
288 | build_mmio_write(writew, "w", unsigned short, "r", :"memory") |
288 | build_mmio_write(writew, "w", unsigned short, "r", :"memory") |
289 | build_mmio_write(writel, "l", unsigned int, "r", :"memory") |
289 | build_mmio_write(writel, "l", unsigned int, "r", :"memory") |
290 | 290 | ||
291 | build_mmio_write(__writeb, "b", unsigned char, "q", ) |
291 | build_mmio_write(__writeb, "b", unsigned char, "q", ) |
292 | build_mmio_write(__writew, "w", unsigned short, "r", ) |
292 | build_mmio_write(__writew, "w", unsigned short, "r", ) |
293 | build_mmio_write(__writel, "l", unsigned int, "r", ) |
293 | build_mmio_write(__writel, "l", unsigned int, "r", ) |
294 | 294 | ||
295 | #define readb_relaxed(a) __readb(a) |
295 | #define readb_relaxed(a) __readb(a) |
296 | #define readw_relaxed(a) __readw(a) |
296 | #define readw_relaxed(a) __readw(a) |
297 | #define readl_relaxed(a) __readl(a) |
297 | #define readl_relaxed(a) __readl(a) |
298 | #define __raw_readb __readb |
298 | #define __raw_readb __readb |
299 | #define __raw_readw __readw |
299 | #define __raw_readw __readw |
300 | #define __raw_readl __readl |
300 | #define __raw_readl __readl |
301 | 301 | ||
302 | #define __raw_writeb __writeb |
302 | #define __raw_writeb __writeb |
303 | #define __raw_writew __writew |
303 | #define __raw_writew __writew |
304 | #define __raw_writel __writel |
304 | #define __raw_writel __writel |
305 | 305 | ||
306 | static inline __u64 readq(const volatile void __iomem *addr) |
306 | static inline __u64 readq(const volatile void __iomem *addr) |
307 | { |
307 | { |
308 | const volatile u32 __iomem *p = addr; |
308 | const volatile u32 __iomem *p = addr; |
309 | u32 low, high; |
309 | u32 low, high; |
310 | 310 | ||
311 | low = readl(p); |
311 | low = readl(p); |
312 | high = readl(p + 1); |
312 | high = readl(p + 1); |
313 | 313 | ||
314 | return low + ((u64)high << 32); |
314 | return low + ((u64)high << 32); |
315 | } |
315 | } |
316 | 316 | ||
317 | static inline void writeq(__u64 val, volatile void __iomem *addr) |
317 | static inline void writeq(__u64 val, volatile void __iomem *addr) |
318 | { |
318 | { |
319 | writel(val, addr); |
319 | writel(val, addr); |
320 | writel(val >> 32, addr+4); |
320 | writel(val >> 32, addr+4); |
321 | } |
321 | } |
322 | 322 | ||
323 | #define swap(a, b) \ |
323 | #define swap(a, b) \ |
324 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) |
324 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) |
325 | 325 | ||
326 | 326 | ||
327 | #define mmiowb() barrier() |
327 | #define mmiowb() barrier() |
328 | 328 | ||
329 | #define dev_err(dev, format, arg...) \ |
329 | #define dev_err(dev, format, arg...) \ |
330 | printk("Error %s " format, __func__ , ## arg) |
330 | printk("Error %s " format, __func__ , ## arg) |
331 | 331 | ||
332 | #define dev_warn(dev, format, arg...) \ |
332 | #define dev_warn(dev, format, arg...) \ |
333 | printk("Warning %s " format, __func__ , ## arg) |
333 | printk("Warning %s " format, __func__ , ## arg) |
334 | 334 | ||
335 | #define dev_info(dev, format, arg...) \ |
335 | #define dev_info(dev, format, arg...) \ |
336 | printk("Info %s " format , __func__, ## arg) |
336 | printk("Info %s " format , __func__, ## arg) |
337 | 337 | ||
338 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) |
338 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) |
339 | 339 | ||
340 | - | ||
341 | - | ||
342 | - | ||
343 | 340 | ||
344 | struct page |
341 | struct page |
345 | { |
342 | { |
346 | unsigned int addr; |
343 | unsigned int addr; |
347 | }; |
344 | }; |
348 | 345 | ||
349 | #define page_to_phys(page) ((dma_addr_t)(page)) |
346 | #define page_to_phys(page) ((dma_addr_t)(page)) |
350 | 347 | ||
351 | struct vm_fault { |
348 | struct vm_fault { |
352 | unsigned int flags; /* FAULT_FLAG_xxx flags */ |
349 | unsigned int flags; /* FAULT_FLAG_xxx flags */ |
353 | pgoff_t pgoff; /* Logical page offset based on vma */ |
350 | pgoff_t pgoff; /* Logical page offset based on vma */ |
354 | void __user *virtual_address; /* Faulting virtual address */ |
351 | void __user *virtual_address; /* Faulting virtual address */ |
355 | 352 | ||
356 | struct page *page; /* ->fault handlers should return a |
353 | struct page *page; /* ->fault handlers should return a |
357 | * page here, unless VM_FAULT_NOPAGE |
354 | * page here, unless VM_FAULT_NOPAGE |
358 | * is set (which is also implied by |
355 | * is set (which is also implied by |
359 | * VM_FAULT_ERROR). |
356 | * VM_FAULT_ERROR). |
360 | */ |
357 | */ |
361 | }; |
358 | }; |
362 | 359 | ||
363 | struct pagelist { |
360 | struct pagelist { |
364 | dma_addr_t *page; |
361 | dma_addr_t *page; |
365 | unsigned int nents; |
362 | unsigned int nents; |
366 | }; |
363 | }; |
367 | 364 | ||
368 | #define page_cache_release(page) FreePage((addr_t)(page)) |
365 | #define page_cache_release(page) FreePage(page_to_phys(page)) |
369 | 366 | ||
370 | #define alloc_page(gfp_mask) (struct page*)AllocPage() |
367 | #define alloc_page(gfp_mask) (struct page*)AllocPage() |
- | 368 | ||
- | 369 | #define __free_page(page) FreePage(page_to_phys(page)) |
|
- | 370 | ||
- | 371 | #define get_page(a) |
|
- | 372 | #define put_page(a) |
|
- | 373 | #define set_pages_uc(a,b) |
|
- | 374 | #define set_pages_wb(a,b) |
|
- | 375 | ||
- | 376 | #define pci_map_page(dev, page, offset, size, direction) \ |
|
- | 377 | (dma_addr_t)( (offset)+page_to_phys(page)) |
|
- | 378 | ||
- | 379 | #define pci_unmap_page(dev, dma_address, size, direction) |
|
- | 380 | ||
- | 381 | #define GFP_TEMPORARY 0 |
|
- | 382 | #define __GFP_NOWARN 0 |
|
- | 383 | #define __GFP_NORETRY 0 |
|
- | 384 | #define GFP_NOWAIT 0 |
|
- | 385 | ||
- | 386 | #define IS_ENABLED(a) 0 |
|
- | 387 | ||
- | 388 | ||
- | 389 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) |
|
- | 390 | ||
- | 391 | #define RCU_INIT_POINTER(p, v) \ |
|
- | 392 | do { \ |
|
- | 393 | p = (typeof(*v) __force __rcu *)(v); \ |
|
- | 394 | } while (0) |
|
- | 395 | ||
- | 396 | ||
- | 397 | #define rcu_dereference_raw(p) ({ \ |
|
- | 398 | typeof(p) _________p1 = ACCESS_ONCE(p); \ |
|
- | 399 | (_________p1); \ |
|
- | 400 | }) |
|
- | 401 | #define rcu_assign_pointer(p, v) \ |
|
- | 402 | ({ \ |
|
- | 403 | if (!__builtin_constant_p(v) || \ |
|
- | 404 | ((v) != NULL)) \ |
|
- | 405 | (p) = (v); \ |
|
- | 406 | }) |
|
371 | 407 | ||
372 | #endif><>>>>>>>>7>6>5>4>3>2>1>0> |
408 | #endif><>>>>>>>>7>6>5>4>3>2>1>0> |