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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [include/] [asm/] [io.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#ifndef _OR1K_IO_H
2
#define _OR1K_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
#if 0
25
 
26
/* There is no difference between I/O and memory on 68k, these are the same */
27
#define inb(addr) \
28
    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); printk("inb(%x)=%02x\n", (addr), __v); __v; })
29
#define inw(addr) \
30
    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); printk("inw(%x)=%04x\n", (addr), __v); __v; })
31
#define inl(addr) \
32
    ({ unsigned int __v = (*(volatile unsigned int *) (addr)); printk("inl(%x)=%08x\n", (addr), __v); __v; })
33
 
34
#define outb(b,addr) { ((*(volatile unsigned char *) (addr)) = (b)) ; printk("outb(%x)=%02x\n", (addr), (b)); }
35
#define outw(b,addr) { ((*(volatile unsigned short *) (addr)) = (b)) ; printk("outw(%x)=%04x\n", (addr), (b)); }
36
#define outl(b,addr) { ((*(volatile unsigned int *) (addr)) = (b)) ; printk("outl(%x)=%08x\n", (addr), (b)); }
37
 
38
#else
39
 
40
/* There is no difference between I/O and memory on 68k, these are the same */
41
#define inb(addr) \
42
    ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
43
#define inw(addr) \
44
    ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
45
#define inl(addr) \
46
    ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
47
 
48
#define outb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
49
#define outw(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
50
#define outl(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
51
 
52
#endif
53
 
54
#define inb_p   inb
55
#define inw_p   inw
56
#define outb_p  outb
57
#define outw_p  outw
58
 
59
 
60
static inline void outsb(void *addr, void *buf, int len)
61
{
62
        volatile unsigned char *ap = (volatile unsigned char *) addr;
63
        unsigned char *bp = (unsigned char *) buf;
64
        while (len--)
65
                *ap = *bp++;
66
}
67
 
68
static inline void outsw(void *addr, void *buf, int len)
69
{
70
        volatile unsigned short *ap = (volatile unsigned short *) addr;
71
        unsigned short *bp = (unsigned short *) buf;
72
        while (len--)
73
                *ap = *bp++;
74
}
75
 
76
static inline void outsl(void *addr, void *buf, int len)
77
{
78
        volatile unsigned int *ap = (volatile unsigned int *) addr;
79
        unsigned int *bp = (unsigned int *) buf;
80
        while (len--)
81
                *ap = *bp++;
82
}
83
 
84
static inline void insb(void *addr, void *buf, int len)
85
{
86
        volatile unsigned char *ap = (volatile unsigned char *) addr;
87
        unsigned char *bp = (unsigned char *) buf;
88
        while (len--)
89
                *bp++ = *ap;
90
}
91
 
92
static inline void insw(void *addr, void *buf, int len)
93
{
94
        volatile unsigned short *ap = (volatile unsigned short *) addr;
95
        unsigned short *bp = (unsigned short *) buf;
96
        while (len--)
97
                *bp++ = *ap;
98
}
99
 
100
static inline void insl(void *addr, void *buf, int len)
101
{
102
        volatile unsigned int *ap = (volatile unsigned int *) addr;
103
        unsigned int *bp = (unsigned int *) buf;
104
        while (len--)
105
                *bp++ = *ap;
106
}
107
 
108
/*
109
 * Change virtual addresses to physical addresses and vv.
110
 * These are trivial on the 1:1 Linux/i386 mapping (but if we ever
111
 * make the kernel segment mapped at 0, we need to do translation
112
 * on the i386 as well)
113
 */
114
extern unsigned long mm_vtop(unsigned long addr);
115
extern unsigned long mm_ptov(unsigned long addr);
116
 
117
extern inline unsigned long virt_to_phys(volatile void * address)
118
{
119
        return (unsigned long) mm_vtop((unsigned long)address);
120
}
121
 
122
extern inline void * phys_to_virt(unsigned long address)
123
{
124
        return (void *) mm_ptov(address);
125
}
126
 
127
/*
128
 * IO bus memory addresses are also 1:1 with the physical address
129
 */
130
#define virt_to_bus virt_to_phys
131
#define bus_to_virt phys_to_virt
132
 
133
 
134
#endif /* _OR1K_IO_H */

powered by: WebSVN 2.1.0

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