Wrote inb and outb for <sys/io.h>
This commit is contained in:
parent
9922fa882d
commit
c8c0b03b23
4 changed files with 27 additions and 1 deletions
12
arch/i386/inb.c
Normal file
12
arch/i386/inb.c
Normal 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;
|
||||||
|
}
|
|
@ -4,5 +4,7 @@ KERNEL_ARCH_CFLAGS=
|
||||||
KERNEL_ARCH_CPPFLAGS=
|
KERNEL_ARCH_CPPFLAGS=
|
||||||
|
|
||||||
ARCH_FREEOBJS=\
|
ARCH_FREEOBJS=\
|
||||||
|
$(ARCHDIR)/inb.o \
|
||||||
|
$(ARCHDIR)/outb.o
|
||||||
|
|
||||||
ARCH_HOSTEDOBJS=\
|
ARCH_HOSTEDOBJS=\
|
10
arch/i386/outb.c
Normal file
10
arch/i386/outb.c
Normal 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));
|
||||||
|
}
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef _SYS_IO_H
|
#ifndef _SYS_IO_H
|
||||||
#define _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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue