Wrote inb and outb for <sys/io.h>

This commit is contained in:
Gitea 2020-12-18 12:39:04 -06:00
parent 9922fa882d
commit c8c0b03b23
4 changed files with 27 additions and 1 deletions

12
arch/i386/inb.c Normal file
View file

@ -0,0 +1,12 @@
#include <sys/io.h>
/*
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;
}

View file

@ -4,5 +4,7 @@ KERNEL_ARCH_CFLAGS=
KERNEL_ARCH_CPPFLAGS=
ARCH_FREEOBJS=\
$(ARCHDIR)/inb.o \
$(ARCHDIR)/outb.o
ARCH_HOSTEDOBJS=\

10
arch/i386/outb.c Normal file
View file

@ -0,0 +1,10 @@
#include <sys/io.h>
/*
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));
}

View file

@ -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