aboutsummaryrefslogtreecommitdiffstats
path: root/src/generic/io.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-06-10 21:04:27 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-06-13 23:18:59 -0400
commit8e1c0941b0664b102ec18a60ac61719aa9d7f9bc (patch)
tree6e52e15013e0d8604290526d31ac0f1566423a26 /src/generic/io.h
parent62f96f09115edca4ce090dc062916dc95f61a1e3 (diff)
downloadkutter-8e1c0941b0664b102ec18a60ac61719aa9d7f9bc.tar.gz
kutter-8e1c0941b0664b102ec18a60ac61719aa9d7f9bc.tar.xz
kutter-8e1c0941b0664b102ec18a60ac61719aa9d7f9bc.zip
generic: Add new file generic/io.h and move read/writeb() to it
Move the definitions of the readb() style functions to a new header generic/io.h. This eliminates the dependency of stdint.h on compiler.h. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/generic/io.h')
-rw-r--r--src/generic/io.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/generic/io.h b/src/generic/io.h
new file mode 100644
index 00000000..2a16cf20
--- /dev/null
+++ b/src/generic/io.h
@@ -0,0 +1,25 @@
+#ifndef __GENERIC_IO_H
+#define __GENERIC_IO_H
+
+#include <stdint.h> // uint32_t
+
+static inline void writel(void *addr, uint32_t val) {
+ *(volatile uint32_t *)addr = val;
+}
+static inline void writew(void *addr, uint16_t val) {
+ *(volatile uint16_t *)addr = val;
+}
+static inline void writeb(void *addr, uint8_t val) {
+ *(volatile uint8_t *)addr = val;
+}
+static inline uint32_t readl(const void *addr) {
+ return *(volatile const uint32_t *)addr;
+}
+static inline uint16_t readw(const void *addr) {
+ return *(volatile const uint16_t *)addr;
+}
+static inline uint8_t readb(const void *addr) {
+ return *(volatile const uint8_t *)addr;
+}
+
+#endif // io.h