From b905869a35f062a4e5072f10bec3a2ba3db0e365 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 30 Jul 2025 14:32:01 -0400 Subject: working userland with some invoke syscalls --- include/device/portio.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 include/device/portio.h (limited to 'include/device/portio.h') diff --git a/include/device/portio.h b/include/device/portio.h new file mode 100644 index 0000000..76b28c4 --- /dev/null +++ b/include/device/portio.h @@ -0,0 +1,26 @@ +#ifndef _JOVE_PORTIO_H +#define _JOVE_PORTIO_H 1 + +#include + +typedef uint16_t ioport_t; + +static inline uint8_t port_inb(ioport_t port) +{ uint8_t r; __asm__ volatile("inb %w1, %b0": "=a"(r): "Nd"(port): "memory"); return r; } + +static inline uint16_t port_inw(ioport_t port) +{ uint16_t r; __asm__ volatile("inw %w1, %w0": "=a"(r): "Nd"(port): "memory"); return r; } + +static inline uint32_t port_inl(ioport_t port) +{ uint32_t r; __asm__ volatile("inl %d1, %l0": "=a"(r): "Nd"(port): "memory"); return r; } + +static inline void port_outb(ioport_t port, uint8_t v) +{ __asm__ volatile("outb %b0, %w1":: "a"(v), "Nd"(port): "memory"); } + +static inline void port_outw(ioport_t port, uint16_t v) +{ __asm__ volatile("outb %w0, %w1":: "a"(v), "Nd"(port): "memory"); } + +static inline void port_outl(ioport_t port, uint32_t v) +{ __asm__ volatile("outb %d0, %w1":: "a"(v), "Nd"(port): "memory"); } + +#endif -- cgit v1.2.1