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