diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2025-07-30 14:32:01 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2025-07-30 14:32:01 -0400 |
commit | b905869a35f062a4e5072f10bec3a2ba3db0e365 (patch) | |
tree | 0666691804878857b4bb07daca8a54f5ddb8ae0b /include/device/portio.h | |
download | jove-kernel-b905869a35f062a4e5072f10bec3a2ba3db0e365.tar.gz jove-kernel-b905869a35f062a4e5072f10bec3a2ba3db0e365.tar.bz2 jove-kernel-b905869a35f062a4e5072f10bec3a2ba3db0e365.zip |
working userland with some invoke syscalls
Diffstat (limited to 'include/device/portio.h')
-rw-r--r-- | include/device/portio.h | 26 |
1 files changed, 26 insertions, 0 deletions
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 <stdint.h> + +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 |