Skip to content

Commit 3dcbf56

Browse files
committed
1 parent 9f95e83 commit 3dcbf56

File tree

4 files changed

+392
-0
lines changed

4 files changed

+392
-0
lines changed

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/device.h>
1111
#include <linux/errname.h>
1212
#include <linux/ethtool.h>
13+
#include <linux/io.h>
1314
#include <linux/mdio.h>
1415
#include <linux/pci.h>
1516
#include <linux/phy.h>

rust/helpers.c

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,118 @@ void *rust_helper_pci_get_drvdata(struct pci_dev *pdev)
170170
}
171171
EXPORT_SYMBOL_GPL(rust_helper_pci_get_drvdata);
172172

173+
/* io.h */
174+
u8 rust_helper_readb(const volatile void __iomem *addr)
175+
{
176+
return readb(addr);
177+
}
178+
EXPORT_SYMBOL_GPL(rust_helper_readb);
179+
180+
u16 rust_helper_readw(const volatile void __iomem *addr)
181+
{
182+
return readw(addr);
183+
}
184+
EXPORT_SYMBOL_GPL(rust_helper_readw);
185+
186+
u32 rust_helper_readl(const volatile void __iomem *addr)
187+
{
188+
return readl(addr);
189+
}
190+
EXPORT_SYMBOL_GPL(rust_helper_readl);
191+
192+
#ifdef CONFIG_64BIT
193+
u64 rust_helper_readq(const volatile void __iomem *addr)
194+
{
195+
return readq(addr);
196+
}
197+
EXPORT_SYMBOL_GPL(rust_helper_readq);
198+
#endif
199+
200+
void rust_helper_writeb(u8 value, volatile void __iomem *addr)
201+
{
202+
writeb(value, addr);
203+
}
204+
EXPORT_SYMBOL_GPL(rust_helper_writeb);
205+
206+
void rust_helper_writew(u16 value, volatile void __iomem *addr)
207+
{
208+
writew(value, addr);
209+
}
210+
EXPORT_SYMBOL_GPL(rust_helper_writew);
211+
212+
void rust_helper_writel(u32 value, volatile void __iomem *addr)
213+
{
214+
writel(value, addr);
215+
}
216+
EXPORT_SYMBOL_GPL(rust_helper_writel);
217+
218+
#ifdef CONFIG_64BIT
219+
void rust_helper_writeq(u64 value, volatile void __iomem *addr)
220+
{
221+
writeq(value, addr);
222+
}
223+
EXPORT_SYMBOL_GPL(rust_helper_writeq);
224+
#endif
225+
226+
u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
227+
{
228+
return readb_relaxed(addr);
229+
}
230+
EXPORT_SYMBOL_GPL(rust_helper_readb_relaxed);
231+
232+
u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
233+
{
234+
return readw_relaxed(addr);
235+
}
236+
EXPORT_SYMBOL_GPL(rust_helper_readw_relaxed);
237+
238+
u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
239+
{
240+
return readl_relaxed(addr);
241+
}
242+
EXPORT_SYMBOL_GPL(rust_helper_readl_relaxed);
243+
244+
#ifdef CONFIG_64BIT
245+
u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
246+
{
247+
return readq_relaxed(addr);
248+
}
249+
EXPORT_SYMBOL_GPL(rust_helper_readq_relaxed);
250+
#endif
251+
252+
void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr)
253+
{
254+
writeb_relaxed(value, addr);
255+
}
256+
EXPORT_SYMBOL_GPL(rust_helper_writeb_relaxed);
257+
258+
void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr)
259+
{
260+
writew_relaxed(value, addr);
261+
}
262+
EXPORT_SYMBOL_GPL(rust_helper_writew_relaxed);
263+
264+
void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr)
265+
{
266+
writel_relaxed(value, addr);
267+
}
268+
EXPORT_SYMBOL_GPL(rust_helper_writel_relaxed);
269+
270+
#ifdef CONFIG_64BIT
271+
void rust_helper_writeq_relaxed(u64 value, volatile void __iomem *addr)
272+
{
273+
writeq_relaxed(value, addr);
274+
}
275+
EXPORT_SYMBOL_GPL(rust_helper_writeq_relaxed);
276+
#endif
277+
278+
void rust_helper_memcpy_fromio(void *to, const volatile void __iomem *from, long count)
279+
{
280+
memcpy_fromio(to, from, count);
281+
}
282+
EXPORT_SYMBOL_GPL(rust_helper_memcpy_fromio);
283+
/* end io.h */
284+
173285
/*
174286
* `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can
175287
* use it in contexts where Rust expects a `usize` like slice (array) indices.

0 commit comments

Comments
 (0)