Subversion Repositories Kolibri OS

Rev

Rev 2005 | Rev 3031 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2005 Rev 2967
Line 11... Line 11...
11
#include 
11
#include 
12
#include 
12
#include 
13
#include 
13
#include 
14
#include 
14
#include 
Line -... Line 15...
-
 
15
 
-
 
16
#include 
-
 
17
 
-
 
18
#define __init
15
 
19
 
16
#define USHRT_MAX	((u16)(~0U))
20
#define USHRT_MAX	((u16)(~0U))
17
#define SHRT_MAX	((s16)(USHRT_MAX>>1))
21
#define SHRT_MAX	((s16)(USHRT_MAX>>1))
18
#define SHRT_MIN	((s16)(-SHRT_MAX - 1))
22
#define SHRT_MIN	((s16)(-SHRT_MAX - 1))
19
#define INT_MAX     ((int)(~0U>>1))
23
#define INT_MAX     ((int)(~0U>>1))
Line 29... Line 33...
29
#define ALIGN(x,a)      __ALIGN_MASK(x,(typeof(x))(a)-1)
33
#define ALIGN(x,a)      __ALIGN_MASK(x,(typeof(x))(a)-1)
30
#define __ALIGN_MASK(x,mask)    (((x)+(mask))&~(mask))
34
#define __ALIGN_MASK(x,mask)    (((x)+(mask))&~(mask))
31
#define PTR_ALIGN(p, a)     ((typeof(p))ALIGN((unsigned long)(p), (a)))
35
#define PTR_ALIGN(p, a)     ((typeof(p))ALIGN((unsigned long)(p), (a)))
32
#define IS_ALIGNED(x, a)        (((x) & ((typeof(x))(a) - 1)) == 0)
36
#define IS_ALIGNED(x, a)        (((x) & ((typeof(x))(a) - 1)) == 0)
Line -... Line 37...
-
 
37
 
-
 
38
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
-
 
39
 
-
 
40
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-
 
41
#define DIV_ROUND_CLOSEST(x, divisor)(                  \
-
 
42
{                                                       \
-
 
43
         typeof(divisor) __divisor = divisor;            \
-
 
44
         (((x) + ((__divisor) / 2)) / (__divisor));      \
-
 
45
}                                                       \
-
 
46
)
33
 
47
 
34
/**
48
/**
35
 * upper_32_bits - return bits 32-63 of a number
49
 * upper_32_bits - return bits 32-63 of a number
36
 * @n: the number we're accessing
50
 * @n: the number we're accessing
37
 *
51
 *
Line 218... Line 232...
218
#define time_after(a,b)         \
232
#define time_after(a,b)         \
219
        (typecheck(unsigned long, a) && \
233
        (typecheck(unsigned long, a) && \
220
        typecheck(unsigned long, b) && \
234
        typecheck(unsigned long, b) && \
221
        ((long)(b) - (long)(a) < 0))
235
        ((long)(b) - (long)(a) < 0))
Line -... Line 236...
-
 
236
 
-
 
237
struct tvec_base;
-
 
238
 
-
 
239
struct timer_list {
-
 
240
         struct list_head entry;
-
 
241
         unsigned long expires;
-
 
242
 
-
 
243
         void (*function)(unsigned long);
-
 
244
         unsigned long data;
-
 
245
 
-
 
246
//         struct tvec_base *base;
-
 
247
};
-
 
248
 
-
 
249
struct timespec {
-
 
250
    long tv_sec;                 /* seconds */
-
 
251
    long tv_nsec;                /* nanoseconds */
-
 
252
};
-
 
253
 
-
 
254
 
-
 
255
#define build_mmio_read(name, size, type, reg, barrier)     \
-
 
256
static inline type name(const volatile void __iomem *addr)  \
-
 
257
{ type ret; asm volatile("mov" size " %1,%0":reg (ret)      \
-
 
258
:"m" (*(volatile type __force *)addr) barrier); return ret; }
-
 
259
 
-
 
260
#define build_mmio_write(name, size, type, reg, barrier) \
-
 
261
static inline void name(type val, volatile void __iomem *addr) \
-
 
262
{ asm volatile("mov" size " %0,%1": :reg (val), \
-
 
263
"m" (*(volatile type __force *)addr) barrier); }
-
 
264
 
-
 
265
build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
-
 
266
build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
-
 
267
build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
-
 
268
 
-
 
269
build_mmio_read(__readb, "b", unsigned char, "=q", )
-
 
270
build_mmio_read(__readw, "w", unsigned short, "=r", )
-
 
271
build_mmio_read(__readl, "l", unsigned int, "=r", )
-
 
272
 
-
 
273
build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
-
 
274
build_mmio_write(writew, "w", unsigned short, "r", :"memory")
-
 
275
build_mmio_write(writel, "l", unsigned int, "r", :"memory")
-
 
276
 
-
 
277
build_mmio_write(__writeb, "b", unsigned char, "q", )
-
 
278
build_mmio_write(__writew, "w", unsigned short, "r", )
-
 
279
build_mmio_write(__writel, "l", unsigned int, "r", )
-
 
280
 
-
 
281
#define readb_relaxed(a) __readb(a)
-
 
282
#define readw_relaxed(a) __readw(a)
-
 
283
#define readl_relaxed(a) __readl(a)
-
 
284
#define __raw_readb __readb
-
 
285
#define __raw_readw __readw
-
 
286
#define __raw_readl __readl
-
 
287
 
-
 
288
#define __raw_writeb __writeb
-
 
289
#define __raw_writew __writew
-
 
290
#define __raw_writel __writel
-
 
291
 
-
 
292
static inline __u64 readq(const volatile void __iomem *addr)
-
 
293
{
-
 
294
        const volatile u32 __iomem *p = addr;
-
 
295
        u32 low, high;
-
 
296
 
-
 
297
        low = readl(p);
-
 
298
        high = readl(p + 1);
-
 
299
 
-
 
300
        return low + ((u64)high << 32);
-
 
301
}
-
 
302
 
-
 
303
static inline void writeq(__u64 val, volatile void __iomem *addr)
-
 
304
{
-
 
305
        writel(val, addr);
-
 
306
        writel(val >> 32, addr+4);
-
 
307
}
-
 
308
 
-
 
309
 
-
 
310
#define mmiowb() barrier()
-
 
311
 
-
 
312
#define dev_err(dev, format, arg...)            \
-
 
313
        printk("Error %s " format, __func__ , ## arg)
-
 
314
 
-
 
315
#define dev_warn(dev, format, arg...)            \
-
 
316
        printk("Warning %s " format, __func__ , ## arg)
-
 
317
 
-
 
318
#define dev_info(dev, format, arg...)       \
-
 
319
        printk("Info %s " format , __func__, ## arg)
-
 
320
 
-
 
321
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
 
322
 
-
 
323
 
-
 
324
struct scatterlist {
-
 
325
    unsigned long   page_link;
-
 
326
    unsigned int    offset;
-
 
327
    unsigned int    length;
-
 
328
    dma_addr_t      dma_address;
-
 
329
    unsigned int    dma_length;
-
 
330
};
-
 
331
 
-
 
332
struct page
-
 
333
{
-
 
334
    unsigned int addr;
-
 
335
};
-
 
336
 
-
 
337
 
-
 
338
struct vm_fault {
-
 
339
    unsigned int flags;             /* FAULT_FLAG_xxx flags */
-
 
340
    pgoff_t pgoff;                  /* Logical page offset based on vma */
-
 
341
    void __user *virtual_address;   /* Faulting virtual address */
-
 
342
 
-
 
343
    struct page *page;              /* ->fault handlers should return a
-
 
344
                                     * page here, unless VM_FAULT_NOPAGE
-
 
345
                                     * is set (which is also implied by
-
 
346
                                     * VM_FAULT_ERROR).
-
 
347
                                     */
-
 
348
};
Line 222... Line 349...
222
 
349