From 0ad16863bad8a9fbfa8da5db39ce2a7b6679569e Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 7 Sep 2024 13:06:54 +0200 Subject: [PATCH] add: inb, outb --- headers/sys/io.h | 4 ++++ src/sys/io/inb.c | 10 ++++++++++ src/sys/io/outb.c | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 headers/sys/io.h create mode 100644 src/sys/io/inb.c create mode 100644 src/sys/io/outb.c diff --git a/headers/sys/io.h b/headers/sys/io.h new file mode 100644 index 0000000..16724da --- /dev/null +++ b/headers/sys/io.h @@ -0,0 +1,4 @@ +#pragma once + +inline uint8_t inb(uint16_t port); +inline void outb(uint16_t port, uint8_t val); \ No newline at end of file diff --git a/src/sys/io/inb.c b/src/sys/io/inb.c new file mode 100644 index 0000000..efba1f0 --- /dev/null +++ b/src/sys/io/inb.c @@ -0,0 +1,10 @@ + +inline uint8_t inb(uint16_t port) +{ + uint8_t ret; + __asm__ volatile ( "inb %w1, %b0" + : "=a"(ret) + : "Nd"(port) + : "memory"); + return ret; +} \ No newline at end of file diff --git a/src/sys/io/outb.c b/src/sys/io/outb.c new file mode 100644 index 0000000..cb3d773 --- /dev/null +++ b/src/sys/io/outb.c @@ -0,0 +1,4 @@ +inline void outb(uint16_t port, uint8_t val) +{ + __asm__ volatile ( "outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory"); +} \ No newline at end of file