diff --git a/arch/i386/inb.c b/arch/i386/inb.c new file mode 100644 index 0000000..7e84684 --- /dev/null +++ b/arch/i386/inb.c @@ -0,0 +1,12 @@ +#include + +/* + This was practically copied from musl, but it's + not like there's much there to copy anyways. + -Kat + */ +unsigned char inb(unsigned short int port) { + unsigned short val; + __asm__ volatile("inb %1,%0" : "=a" (val) : "dN" (port)); + return val; +} \ No newline at end of file diff --git a/arch/i386/make.config b/arch/i386/make.config index fbb211a..580f075 100755 --- a/arch/i386/make.config +++ b/arch/i386/make.config @@ -4,5 +4,7 @@ KERNEL_ARCH_CFLAGS= KERNEL_ARCH_CPPFLAGS= ARCH_FREEOBJS=\ +$(ARCHDIR)/inb.o \ +$(ARCHDIR)/outb.o ARCH_HOSTEDOBJS=\ \ No newline at end of file diff --git a/arch/i386/outb.c b/arch/i386/outb.c new file mode 100644 index 0000000..551356c --- /dev/null +++ b/arch/i386/outb.c @@ -0,0 +1,10 @@ +#include + +/* + This was also practically lifted + from musl. + -Kat + */ +void outb(unsigned char val, unsigned short port) { + __asm__ volatile("outb %0,%1" : : "a" (val), "dN" (port)); +} \ No newline at end of file diff --git a/include/sys/io.h b/include/sys/io.h index 9b7cb1e..d738dae 100644 --- a/include/sys/io.h +++ b/include/sys/io.h @@ -12,6 +12,8 @@ #ifndef _SYS_IO_H #define _SYS_IO_H -extern unsigned char inb(unsigned short int port); +unsigned char inb(unsigned short int port); + +void outb(unsigned char val, unsigned short port); #endif