diff options
Diffstat (limited to 'src/kernel/io.c')
-rw-r--r-- | src/kernel/io.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/kernel/io.c b/src/kernel/io.c new file mode 100644 index 0000000..1974c35 --- /dev/null +++ b/src/kernel/io.c @@ -0,0 +1,24 @@ +#include <io.h> +#include <stdint.h> +//these functions are assumed not to be time-sensitive. +void outb_wait(uint16_t port, uint8_t value) { + outb(port, value); + io_wait(); +} + +void read_msr(uint32_t addr, uint64_t *value) { + uint32_t low, high; + asm volatile("rdmsr" : "=a"(low), "=d"(high) : "c"(addr)); + *value = low | ((uint64_t)high << 32); +} + +void write_msr(uint32_t addr, uint64_t value) { + uint32_t low = value & UINT32_MAX; + uint32_t high = value >> 32; + asm volatile("wrmsr"::"a"(low), "d"(high), "c"(addr)); +} + +void hlt() { + asm("cli\nhlt"); +} + |