]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/asm-nios/io.h
Implement __raw_{read,write}[bwl] on all architectures
[people/ms/u-boot.git] / include / asm-nios / io.h
CommitLineData
d06a5f7e
WD
1/*
2 * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23#ifndef __ASM_NIOS_IO_H_
24#define __ASM_NIOS_IO_H_
25
812711ce
HS
26#define __raw_writeb(v,a) (*(volatile unsigned char *)(a) = (v))
27#define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v))
28#define __raw_writel(v,a) (*(volatile unsigned int *)(a) = (v))
29
30#define __raw_readb(a) (*(volatile unsigned char *)(a))
31#define __raw_readw(a) (*(volatile unsigned short *)(a))
32#define __raw_readl(a) (*(volatile unsigned int *)(a))
33
d06a5f7e
WD
34#define readb(addr)\
35 ({unsigned char val;\
36 asm volatile( " pfxio 0 \n"\
37 " ld %0, [%1] \n"\
38 " ext8d %0, %1 \n"\
39 :"=r"(val) : "r" (addr)); val;})
40
41#define readw(addr)\
42 ({unsigned short val;\
43 asm volatile( " pfxio 0 \n"\
44 " ld %0, [%1] \n"\
45 " ext16d %0, %1 \n"\
46 :"=r"(val) : "r" (addr)); val;})
47
48#define readl(addr)\
49 ({unsigned long val;\
50 asm volatile( " pfxio 0 \n"\
51 " ld %0, [%1] \n"\
52 :"=r"(val) : "r" (addr)); val;})
53
54#define writeb(addr,val)\
55 asm volatile ( " fill8 %%r0, %1 \n"\
56 " st8d [%0], %%r0 \n"\
57 : : "r" (addr), "r" (val) : "r0")
58
59#define writew(addr,val)\
60 asm volatile ( " fill16 %%r0, %1 \n"\
61 " st16d [%0], %%r0 \n"\
62 : : "r" (addr), "r" (val) : "r0")
63
64#define writel(addr,val)\
65 asm volatile ( " st [%0], %1 \n"\
66 : : "r" (addr), "r" (val))
67
68#define inb(addr) readb(addr)
69#define inw(addr) readw(addr)
70#define inl(addr) readl(addr)
71#define outb(val,addr) writeb(addr,val)
72#define outw(val,addr) writew(addr,val)
73#define outl(val,addr) writel(addr,val)
74
75static inline void insb (unsigned long port, void *dst, unsigned long count)
76{
77 unsigned char *p = dst;
78 while (count--) *p++ = inb (port);
79}
80static inline void insw (unsigned long port, void *dst, unsigned long count)
81{
82 unsigned short *p = dst;
83 while (count--) *p++ = inw (port);
84}
85static inline void insl (unsigned long port, void *dst, unsigned long count)
86{
87 unsigned long *p = dst;
88 while (count--) *p++ = inl (port);
89}
90
91static inline void outsb (unsigned long port, const void *src, unsigned long count)
92{
93 const unsigned char *p = src;
94 while (count--) outb (*p++, port);
95}
96
97static inline void outsw (unsigned long port, const void *src, unsigned long count)
98{
99 const unsigned short *p = src;
100 while (count--) outw (*p++, port);
101}
102static inline void outsl (unsigned long port, const void *src, unsigned long count)
103{
104 const unsigned long *p = src;
105 while (count--) outl (*p++, port);
106}
107
3a197b2f
HW
108static inline void sync(void)
109{
110}
111
d06a5f7e 112#endif /* __ASM_NIOS_IO_H_ */