OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [include/] [asm-or32/] [io.h] - Blame information for rev 666

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 666 simons
#ifndef _OR32_IO_H
2
#define _OR32_IO_H
3
 
4
/*
5
 * readX/writeX() are used to access memory mapped devices. On some
6
 * architectures the memory mapped IO stuff needs to be accessed
7
 * differently. On the m68k architecture, we just read/write the
8
 * memory location directly.
9
 */
10
/* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
11
 * two accesses to memory, which may be undesireable for some devices.
12
 */
13
#define readb(addr) \
14
    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
15
#define readw(addr) \
16
    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
17
#define readl(addr) \
18
    ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
19
 
20
#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
21
#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
22
#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
23
 
24
/* There is no difference between I/O and memory on 68k, these are the same */
25
#define inb(addr) \
26
    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
27
#define inw(addr) \
28
    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
29
#define inl(addr) \
30
    ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
31
 
32
#define outb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
33
#define outw(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
34
#define outl(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
35
 
36
#define inb_p   inb
37
#define inw_p   inw
38
#define outb_p  outb
39
#define outw_p  outw
40
 
41
#define REG8(addr)  (*(volatile unsigned char *) (addr))
42
#define REG16(addr) (*(volatile unsigned short *) (addr))
43
#define REG32(addr) (*(volatile unsigned int *) (addr))
44
 
45
 
46
static inline void outsb(void *addr, void *buf, int len)
47
{
48
        volatile unsigned char *ap = (volatile unsigned char *) addr;
49
        unsigned char *bp = (unsigned char *) buf;
50
        while (len--)
51
                *ap = *bp++;
52
}
53
 
54
static inline void outsw(void *addr, void *buf, int len)
55
{
56
        volatile unsigned short *ap = (volatile unsigned short *) addr;
57
        unsigned short *bp = (unsigned short *) buf;
58
        while (len--)
59
                *ap = *bp++;
60
}
61
 
62
static inline void outsl(void *addr, void *buf, int len)
63
{
64
        volatile unsigned int *ap = (volatile unsigned int *) addr;
65
        unsigned int *bp = (unsigned int *) buf;
66
        while (len--)
67
                *ap = *bp++;
68
}
69
 
70
static inline void insb(void *addr, void *buf, int len)
71
{
72
        volatile unsigned char *ap = (volatile unsigned char *) addr;
73
        unsigned char *bp = (unsigned char *) buf;
74
        while (len--)
75
                *bp++ = *ap;
76
}
77
 
78
static inline void insw(void *addr, void *buf, int len)
79
{
80
        volatile unsigned short *ap = (volatile unsigned short *) addr;
81
        unsigned short *bp = (unsigned short *) buf;
82
        while (len--)
83
                *bp++ = *ap;
84
}
85
 
86
static inline void insl(void *addr, void *buf, int len)
87
{
88
        volatile unsigned int *ap = (volatile unsigned int *) addr;
89
        unsigned int *bp = (unsigned int *) buf;
90
        while (len--)
91
                *bp++ = *ap;
92
}
93
 
94
/*
95
 * Change virtual addresses to physical addresses and vv.
96
 * These are trivial on the 1:1 Linux/i386 mapping (but if we ever
97
 * make the kernel segment mapped at 0, we need to do translation
98
 * on the i386 as well)
99
 */
100
extern unsigned long mm_vtop(unsigned long addr);
101
extern unsigned long mm_ptov(unsigned long addr);
102
 
103
extern inline unsigned long virt_to_phys(volatile void * address)
104
{
105
        return (unsigned long) mm_vtop((unsigned long)address);
106
}
107
 
108
extern inline void * phys_to_virt(unsigned long address)
109
{
110
        return (void *) mm_ptov(address);
111
}
112
 
113
/*
114
 * IO bus memory addresses are also 1:1 with the physical address
115
 */
116
#define virt_to_bus virt_to_phys
117
#define bus_to_virt phys_to_virt
118
 
119
 
120
#endif /* _OR32_IO_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.