Skip to content

Commit f176b3c

Browse files
committed
1 parent 78ded37 commit f176b3c

File tree

4 files changed

+393
-0
lines changed

4 files changed

+393
-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
@@ -198,6 +198,118 @@ void *rust_helper_pci_get_drvdata(struct pci_dev *pdev)
198198
}
199199
EXPORT_SYMBOL_GPL(rust_helper_pci_get_drvdata);
200200

201+
/* io.h */
202+
u8 rust_helper_readb(const volatile void __iomem *addr)
203+
{
204+
return readb(addr);
205+
}
206+
EXPORT_SYMBOL_GPL(rust_helper_readb);
207+
208+
u16 rust_helper_readw(const volatile void __iomem *addr)
209+
{
210+
return readw(addr);
211+
}
212+
EXPORT_SYMBOL_GPL(rust_helper_readw);
213+
214+
u32 rust_helper_readl(const volatile void __iomem *addr)
215+
{
216+
return readl(addr);
217+
}
218+
EXPORT_SYMBOL_GPL(rust_helper_readl);
219+
220+
#ifdef CONFIG_64BIT
221+
u64 rust_helper_readq(const volatile void __iomem *addr)
222+
{
223+
return readq(addr);
224+
}
225+
EXPORT_SYMBOL_GPL(rust_helper_readq);
226+
#endif
227+
228+
void rust_helper_writeb(u8 value, volatile void __iomem *addr)
229+
{
230+
writeb(value, addr);
231+
}
232+
EXPORT_SYMBOL_GPL(rust_helper_writeb);
233+
234+
void rust_helper_writew(u16 value, volatile void __iomem *addr)
235+
{
236+
writew(value, addr);
237+
}
238+
EXPORT_SYMBOL_GPL(rust_helper_writew);
239+
240+
void rust_helper_writel(u32 value, volatile void __iomem *addr)
241+
{
242+
writel(value, addr);
243+
}
244+
EXPORT_SYMBOL_GPL(rust_helper_writel);
245+
246+
#ifdef CONFIG_64BIT
247+
void rust_helper_writeq(u64 value, volatile void __iomem *addr)
248+
{
249+
writeq(value, addr);
250+
}
251+
EXPORT_SYMBOL_GPL(rust_helper_writeq);
252+
#endif
253+
254+
u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
255+
{
256+
return readb_relaxed(addr);
257+
}
258+
EXPORT_SYMBOL_GPL(rust_helper_readb_relaxed);
259+
260+
u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
261+
{
262+
return readw_relaxed(addr);
263+
}
264+
EXPORT_SYMBOL_GPL(rust_helper_readw_relaxed);
265+
266+
u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
267+
{
268+
return readl_relaxed(addr);
269+
}
270+
EXPORT_SYMBOL_GPL(rust_helper_readl_relaxed);
271+
272+
#ifdef CONFIG_64BIT
273+
u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
274+
{
275+
return readq_relaxed(addr);
276+
}
277+
EXPORT_SYMBOL_GPL(rust_helper_readq_relaxed);
278+
#endif
279+
280+
void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr)
281+
{
282+
writeb_relaxed(value, addr);
283+
}
284+
EXPORT_SYMBOL_GPL(rust_helper_writeb_relaxed);
285+
286+
void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr)
287+
{
288+
writew_relaxed(value, addr);
289+
}
290+
EXPORT_SYMBOL_GPL(rust_helper_writew_relaxed);
291+
292+
void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr)
293+
{
294+
writel_relaxed(value, addr);
295+
}
296+
EXPORT_SYMBOL_GPL(rust_helper_writel_relaxed);
297+
298+
#ifdef CONFIG_64BIT
299+
void rust_helper_writeq_relaxed(u64 value, volatile void __iomem *addr)
300+
{
301+
writeq_relaxed(value, addr);
302+
}
303+
EXPORT_SYMBOL_GPL(rust_helper_writeq_relaxed);
304+
#endif
305+
306+
void rust_helper_memcpy_fromio(void *to, const volatile void __iomem *from, long count)
307+
{
308+
memcpy_fromio(to, from, count);
309+
}
310+
EXPORT_SYMBOL_GPL(rust_helper_memcpy_fromio);
311+
/* end io.h */
312+
201313
/*
202314
* `bindgen` binds the C `size_t` type as the Rust `usize` type, so we can
203315
* use it in contexts where Rust expects a `usize` like slice (array) indices.

0 commit comments

Comments
 (0)