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