Loading...
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 */
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);
52
53#ifdef CONFIG_IA64_GENERIC
54
55#undef __ia64_inb
56#undef __ia64_inw
57#undef __ia64_inl
58#undef __ia64_outb
59#undef __ia64_outw
60#undef __ia64_outl
61#undef __ia64_readb
62#undef __ia64_readw
63#undef __ia64_readl
64#undef __ia64_readq
65#undef __ia64_readb_relaxed
66#undef __ia64_readw_relaxed
67#undef __ia64_readl_relaxed
68#undef __ia64_readq_relaxed
69#undef __ia64_writeb
70#undef __ia64_writew
71#undef __ia64_writel
72#undef __ia64_writeq
73#undef __ia64_mmiowb
74
75unsigned int
76__ia64_inb (unsigned long port)
77{
78 return ___ia64_inb(port);
79}
80
81unsigned int
82__ia64_inw (unsigned long port)
83{
84 return ___ia64_inw(port);
85}
86
87unsigned int
88__ia64_inl (unsigned long port)
89{
90 return ___ia64_inl(port);
91}
92
93void
94__ia64_outb (unsigned char val, unsigned long port)
95{
96 ___ia64_outb(val, port);
97}
98
99void
100__ia64_outw (unsigned short val, unsigned long port)
101{
102 ___ia64_outw(val, port);
103}
104
105void
106__ia64_outl (unsigned int val, unsigned long port)
107{
108 ___ia64_outl(val, port);
109}
110
111unsigned char
112__ia64_readb (void __iomem *addr)
113{
114 return ___ia64_readb (addr);
115}
116
117unsigned short
118__ia64_readw (void __iomem *addr)
119{
120 return ___ia64_readw (addr);
121}
122
123unsigned int
124__ia64_readl (void __iomem *addr)
125{
126 return ___ia64_readl (addr);
127}
128
129unsigned long
130__ia64_readq (void __iomem *addr)
131{
132 return ___ia64_readq (addr);
133}
134
135unsigned char
136__ia64_readb_relaxed (void __iomem *addr)
137{
138 return ___ia64_readb (addr);
139}
140
141unsigned short
142__ia64_readw_relaxed (void __iomem *addr)
143{
144 return ___ia64_readw (addr);
145}
146
147unsigned int
148__ia64_readl_relaxed (void __iomem *addr)
149{
150 return ___ia64_readl (addr);
151}
152
153unsigned long
154__ia64_readq_relaxed (void __iomem *addr)
155{
156 return ___ia64_readq (addr);
157}
158
159void
160__ia64_mmiowb(void)
161{
162 ___ia64_mmiowb();
163}
164
165#endif /* CONFIG_IA64_GENERIC */
1#include <linux/module.h>
2#include <linux/types.h>
3
4#include <asm/io.h>
5
6/*
7 * Copy data from IO memory space to "real" memory space.
8 * This needs to be optimized.
9 */
10void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
11{
12 char *dst = to;
13
14 while (count) {
15 count--;
16 *dst++ = readb(from++);
17 }
18}
19EXPORT_SYMBOL(memcpy_fromio);
20
21/*
22 * Copy data from "real" memory space to IO memory space.
23 * This needs to be optimized.
24 */
25void memcpy_toio(volatile void __iomem *to, const void *from, long count)
26{
27 const char *src = from;
28
29 while (count) {
30 count--;
31 writeb(*src++, to++);
32 }
33}
34EXPORT_SYMBOL(memcpy_toio);
35
36/*
37 * "memset" on IO memory space.
38 * This needs to be optimized.
39 */
40void memset_io(volatile void __iomem *dst, int c, long count)
41{
42 unsigned char ch = (char)(c & 0xff);
43
44 while (count) {
45 count--;
46 writeb(ch, dst);
47 dst++;
48 }
49}
50EXPORT_SYMBOL(memset_io);
51
52#ifdef CONFIG_IA64_GENERIC
53
54#undef __ia64_inb
55#undef __ia64_inw
56#undef __ia64_inl
57#undef __ia64_outb
58#undef __ia64_outw
59#undef __ia64_outl
60#undef __ia64_readb
61#undef __ia64_readw
62#undef __ia64_readl
63#undef __ia64_readq
64#undef __ia64_readb_relaxed
65#undef __ia64_readw_relaxed
66#undef __ia64_readl_relaxed
67#undef __ia64_readq_relaxed
68#undef __ia64_writeb
69#undef __ia64_writew
70#undef __ia64_writel
71#undef __ia64_writeq
72#undef __ia64_mmiowb
73
74unsigned int
75__ia64_inb (unsigned long port)
76{
77 return ___ia64_inb(port);
78}
79
80unsigned int
81__ia64_inw (unsigned long port)
82{
83 return ___ia64_inw(port);
84}
85
86unsigned int
87__ia64_inl (unsigned long port)
88{
89 return ___ia64_inl(port);
90}
91
92void
93__ia64_outb (unsigned char val, unsigned long port)
94{
95 ___ia64_outb(val, port);
96}
97
98void
99__ia64_outw (unsigned short val, unsigned long port)
100{
101 ___ia64_outw(val, port);
102}
103
104void
105__ia64_outl (unsigned int val, unsigned long port)
106{
107 ___ia64_outl(val, port);
108}
109
110unsigned char
111__ia64_readb (void __iomem *addr)
112{
113 return ___ia64_readb (addr);
114}
115
116unsigned short
117__ia64_readw (void __iomem *addr)
118{
119 return ___ia64_readw (addr);
120}
121
122unsigned int
123__ia64_readl (void __iomem *addr)
124{
125 return ___ia64_readl (addr);
126}
127
128unsigned long
129__ia64_readq (void __iomem *addr)
130{
131 return ___ia64_readq (addr);
132}
133
134unsigned char
135__ia64_readb_relaxed (void __iomem *addr)
136{
137 return ___ia64_readb (addr);
138}
139
140unsigned short
141__ia64_readw_relaxed (void __iomem *addr)
142{
143 return ___ia64_readw (addr);
144}
145
146unsigned int
147__ia64_readl_relaxed (void __iomem *addr)
148{
149 return ___ia64_readl (addr);
150}
151
152unsigned long
153__ia64_readq_relaxed (void __iomem *addr)
154{
155 return ___ia64_readq (addr);
156}
157
158void
159__ia64_mmiowb(void)
160{
161 ___ia64_mmiowb();
162}
163
164#endif /* CONFIG_IA64_GENERIC */