diff --git a/kernel/include/kernel/MMIO.h b/kernel/include/kernel/MMIO.h new file mode 100644 index 0000000000..9b9cd2d3f0 --- /dev/null +++ b/kernel/include/kernel/MMIO.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include + +namespace MMIO +{ + + static inline void write8(uintptr_t addr, uint8_t val) + { + *(volatile uint8_t*)addr = val; + } + + static inline void write16(uintptr_t addr, uint16_t val) + { + *(volatile uint16_t*)addr = val; + } + + static inline void write32(uintptr_t addr, uint32_t val) + { + *(volatile uint32_t*)addr = val; + } + + static inline void write64(uintptr_t addr, uint64_t val) + { + *(volatile uint64_t*)addr = val; + } + + static inline uint8_t read8(uintptr_t addr) + { + return *(volatile uint8_t*)addr; + } + + static inline uint16_t read16(uintptr_t addr) + { + return *(volatile uint16_t*)addr; + } + + static inline uint32_t read32(uintptr_t addr) + { + return *(volatile uint32_t*)addr; + } + + static inline uint64_t read64(uintptr_t addr) + { + return *(volatile uint64_t*)addr; + } + +} \ No newline at end of file