xref: /linux/rust/helpers/io.c (revision d3cac8a343241a547445e8a651f1d4ecc276b828)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/io.h>
4 #include <linux/ioport.h>
5 
6 __rust_helper void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
7 {
8 	return ioremap(offset, size);
9 }
10 
11 __rust_helper void __iomem *rust_helper_ioremap_np(phys_addr_t offset,
12 						   size_t size)
13 {
14 	return ioremap_np(offset, size);
15 }
16 
17 __rust_helper void rust_helper_iounmap(void __iomem *addr)
18 {
19 	iounmap(addr);
20 }
21 
22 __rust_helper void rust_helper_memcpy_fromio(void *dst,
23 					     const volatile void __iomem *src,
24 					     size_t count)
25 {
26 	memcpy_fromio(dst, src, count);
27 }
28 
29 __rust_helper void rust_helper_memcpy_toio(volatile void __iomem *dst,
30 					   const void *src, size_t count)
31 {
32 	memcpy_toio(dst, src, count);
33 }
34 
35 __rust_helper u8 rust_helper_readb(const void __iomem *addr)
36 {
37 	return readb(addr);
38 }
39 
40 __rust_helper u16 rust_helper_readw(const void __iomem *addr)
41 {
42 	return readw(addr);
43 }
44 
45 __rust_helper u32 rust_helper_readl(const void __iomem *addr)
46 {
47 	return readl(addr);
48 }
49 
50 #ifdef CONFIG_64BIT
51 __rust_helper u64 rust_helper_readq(const void __iomem *addr)
52 {
53 	return readq(addr);
54 }
55 #endif
56 
57 __rust_helper void rust_helper_writeb(u8 value, void __iomem *addr)
58 {
59 	writeb(value, addr);
60 }
61 
62 __rust_helper void rust_helper_writew(u16 value, void __iomem *addr)
63 {
64 	writew(value, addr);
65 }
66 
67 __rust_helper void rust_helper_writel(u32 value, void __iomem *addr)
68 {
69 	writel(value, addr);
70 }
71 
72 #ifdef CONFIG_64BIT
73 __rust_helper void rust_helper_writeq(u64 value, void __iomem *addr)
74 {
75 	writeq(value, addr);
76 }
77 #endif
78 
79 __rust_helper u8 rust_helper_readb_relaxed(const void __iomem *addr)
80 {
81 	return readb_relaxed(addr);
82 }
83 
84 __rust_helper u16 rust_helper_readw_relaxed(const void __iomem *addr)
85 {
86 	return readw_relaxed(addr);
87 }
88 
89 __rust_helper u32 rust_helper_readl_relaxed(const void __iomem *addr)
90 {
91 	return readl_relaxed(addr);
92 }
93 
94 #ifdef CONFIG_64BIT
95 __rust_helper u64 rust_helper_readq_relaxed(const void __iomem *addr)
96 {
97 	return readq_relaxed(addr);
98 }
99 #endif
100 
101 __rust_helper void rust_helper_writeb_relaxed(u8 value, void __iomem *addr)
102 {
103 	writeb_relaxed(value, addr);
104 }
105 
106 __rust_helper void rust_helper_writew_relaxed(u16 value, void __iomem *addr)
107 {
108 	writew_relaxed(value, addr);
109 }
110 
111 __rust_helper void rust_helper_writel_relaxed(u32 value, void __iomem *addr)
112 {
113 	writel_relaxed(value, addr);
114 }
115 
116 #ifdef CONFIG_64BIT
117 __rust_helper void rust_helper_writeq_relaxed(u64 value, void __iomem *addr)
118 {
119 	writeq_relaxed(value, addr);
120 }
121 #endif
122 
123 __rust_helper resource_size_t rust_helper_resource_size(struct resource *res)
124 {
125 	return resource_size(res);
126 }
127 
128 __rust_helper struct resource *
129 rust_helper_request_mem_region(resource_size_t start, resource_size_t n,
130 			       const char *name)
131 {
132 	return request_mem_region(start, n, name);
133 }
134 
135 __rust_helper void rust_helper_release_mem_region(resource_size_t start,
136 						  resource_size_t n)
137 {
138 	release_mem_region(start, n);
139 }
140 
141 __rust_helper struct resource *rust_helper_request_region(resource_size_t start,
142 							  resource_size_t n,
143 							  const char *name)
144 {
145 	return request_region(start, n, name);
146 }
147 
148 __rust_helper struct resource *
149 rust_helper_request_muxed_region(resource_size_t start, resource_size_t n,
150 				 const char *name)
151 {
152 	return request_muxed_region(start, n, name);
153 }
154 
155 __rust_helper void rust_helper_release_region(resource_size_t start,
156 					      resource_size_t n)
157 {
158 	release_region(start, n);
159 }
160