From d43d7caf15a01dd9c2ef1d9e975df3ef7c4e9204 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 27 Sep 2024 06:02:49 -0400 Subject: wip: initial commit --- portio.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 portio.hpp (limited to 'portio.hpp') diff --git a/portio.hpp b/portio.hpp new file mode 100644 index 0000000..0a10651 --- /dev/null +++ b/portio.hpp @@ -0,0 +1,24 @@ +#ifndef PORTIO_HPP +#define PORTIO_HPP + +#include + +inline void outb(std::uint16_t port, std::uint8_t val) +{ + asm volatile("outb %b0, %w1" :: "a"(val), "Nd"(port) : "memory"); +} + +inline std::uint8_t inb(std::uint16_t port) +{ + std::uint8_t val; + asm volatile("inb %w1, %b0" : "=a"(val) : "Nd"(port) : "memory"); + return val; +} + +inline void io_wait() +{ + outb(0x80, 0); +} + +#endif // PORTIO_HPP + -- cgit v1.2.3