Subversion Repositories shark

Rev

Rev 54 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 pj 1
#include <stdint.h>
80 pj 2
#include "ll/sys/cdefs.h"
54 pj 3
 
80 pj 4
__BEGIN_DECLS
5
 
54 pj 6
#ifndef __alpha__
7
 
8
#define v_readb(addr) (*(volatile uint8_t *) (MMIO_POINTER+(addr)))
9
#define v_readw(addr) (*(volatile uint16_t *) (MMIO_POINTER+(addr)))
10
#define v_readl(addr) (*(volatile uint32_t *) (MMIO_POINTER+(addr)))
11
 
12
#define v_writeb(b,addr) (*(volatile uint8_t *) (MMIO_POINTER+(addr)) = (b))
13
#define v_writew(b,addr) (*(volatile uint16_t *) (MMIO_POINTER+(addr)) = (b))
14
#define v_writel(b,addr) (*(volatile uint32_t *) (MMIO_POINTER+(addr)) = (b))
15
 
16
#else
17
 
18
#define vip     volatile int *
19
#define vuip    volatile unsigned int *
20
#define vulp    volatile unsigned long *
21
 
22
#define mb() \
23
__asm__ __volatile__("mb": : :"memory")
24
 
25
#define __kernel_extbl(val, shift)                                      \
26
  ({ unsigned long __kir;                                               \
27
     __asm__("extbl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val));   \
28
     __kir; })
29
#define __kernel_extwl(val, shift)                                      \
30
  ({ unsigned long __kir;                                               \
31
     __asm__("extwl %2,%1,%0" : "=r"(__kir) : "rI"(shift), "r"(val));   \
32
     __kir; })
33
 
34
static inline uint8_t v_readb(unsigned long addr)
35
{
36
        unsigned long result;
37
 
38
        result = *(vip) ((addr << 5) + SPARSE_MMIO + 0x00);
39
        return __kernel_extbl(result, addr & 3);
40
}
41
 
42
static inline uint16_t v_readw(unsigned long addr)
43
{
44
        unsigned long result;
45
 
46
        result = *(vip) ((addr << 5) + SPARSE_MMIO + 0x08);
47
        return __kernel_extwl(result, addr & 3);
48
}
49
 
50
static inline uint32_t v_readl(unsigned long addr)
51
{
52
        return *(vuip) ((addr << 5) + SPARSE_MMIO + 0x18);
53
}
54
 
55
static inline void v_writeb(uint8_t b, unsigned long addr)
56
{
57
        *(vuip) ((addr << 5) + SPARSE_MMIO + 0x00) = b * 0x01010101;
58
        mb();
59
}
60
 
61
static inline void v_writew(uint16_t b, unsigned long addr)
62
{
63
        *(vuip) ((addr << 5) + SPARSE_MMIO + 0x08) = b * 0x00010001;
64
        mb();
65
}
66
 
67
static inline void v_writel(uint32_t b, unsigned long addr)
68
{
69
        *(vuip) ((addr << 5) + SPARSE_MMIO + 0x18) = b;
70
        mb();
71
}
72
 
80 pj 73
__END_DECLS
54 pj 74
#endif /* __alpha__ */