blob: c3e02462ed1694b809a0d59650396ae72f58adb7 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#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 */
11void 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}
20EXPORT_SYMBOL(memcpy_fromio);
21
22/*
23 * Copy data from "real" memory space to IO memory space.
24 * This needs to be optimized.
25 */
26void 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}
35EXPORT_SYMBOL(memcpy_toio);
36
37/*
38 * "memset" on IO memory space.
39 * This needs to be optimized.
40 */
41void 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}
51EXPORT_SYMBOL(memset_io);