summaryrefslogtreecommitdiff
path: root/purgatory/arch/ia64/io.h
blob: 73701595ee184083f3ebced9ccf6e1d5f0c34b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef IO_H
#define IO_H
#define UNCACHED(x) (void *)((x)|(1UL<<63))
#define MF()	asm volatile ("mf.a" ::: "memory")
#define IO_SPACE_ENCODING(p)     ((((p) >> 2) << 12) | (p & 0xfff))

static inline void *io_addr (unsigned long port)
{
        unsigned long offset;
	unsigned long io_base;
	asm volatile ("mov %0=ar.k0":"=r"(io_base));
	offset = IO_SPACE_ENCODING(port);
        return UNCACHED(io_base | offset);
}

static inline unsigned int inb (unsigned long port)
{
        volatile unsigned char *addr = io_addr(port);
        unsigned char ret;
        ret = *addr;
        MF();
        return ret;
}

static inline unsigned int inw (unsigned long port)
{
        volatile unsigned short *addr = io_addr(port);
        unsigned short ret;

        ret = *addr;
	MF();
        return ret;
}

static inline unsigned int ia64_inl (unsigned long port)
{
        volatile unsigned int *addr = __ia64_mk_io_addr(port);
        unsigned int ret;
        ret = *addr;
	MF();
        return ret;
}

static inline void outb (unsigned char val, unsigned long port)
{
        volatile unsigned char *addr = io_addr(port);

        *addr = val;
	MF();
}

static inline void outw (unsigned short val, unsigned long port)
{
        volatile unsigned short *addr = io_addr(port);

        *addr = val;
	MF();
}

static inline void outl (unsigned int val, unsigned long port)
{
        volatile unsigned int *addr = io_addr(port);

        *addr = val;
	MF();
}


static inline unsigned char readb(const volatile void  *addr)
{
        return *(volatile unsigned char *) addr;
}
static inline unsigned short readw(const volatile void  *addr)
{
        return *(volatile unsigned short *) addr;
}
static inline unsigned int readl(const volatile void  *addr)
{
        return *(volatile unsigned int *) addr;
}

static inline void writeb(unsigned char b, volatile void  *addr)
{
        *(volatile unsigned char *) addr = b;
}
static inline void writew(unsigned short b, volatile void  *addr)
{
        *(volatile unsigned short *) addr = b;
}
static inline void writel(unsigned int b, volatile void  *addr)
{
        *(volatile unsigned int *) addr = b;
}
#endif