xref: /openbmc/linux/arch/ia64/lib/io.c (revision 2f164822)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/module.h>
3 #include <linux/types.h>
4 
5 #include <asm/io.h>
6 
7 /*
8  * Copy data from IO memory space to "real" memory space.
9  * This needs to be optimized.
10  */
11 void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
12 {
13 	char *dst = to;
14 
15 	while (count) {
16 		count--;
17 		*dst++ = readb(from++);
18 	}
19 }
20 EXPORT_SYMBOL(memcpy_fromio);
21 
22 /*
23  * Copy data from "real" memory space to IO memory space.
24  * This needs to be optimized.
25  */
26 void memcpy_toio(volatile void __iomem *to, const void *from, long count)
27 {
28 	const char *src = from;
29 
30 	while (count) {
31 		count--;
32 		writeb(*src++, to++);
33 	}
34 }
35 EXPORT_SYMBOL(memcpy_toio);
36 
37 /*
38  * "memset" on IO memory space.
39  * This needs to be optimized.
40  */
41 void memset_io(volatile void __iomem *dst, int c, long count)
42 {
43 	unsigned char ch = (char)(c & 0xff);
44 
45 	while (count) {
46 		count--;
47 		writeb(ch, dst);
48 		dst++;
49 	}
50 }
51 EXPORT_SYMBOL(memset_io);
52