From 46063e75f3f81dfb532fa5772c88e9027a0faebd Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 20 Aug 2014 10:45:40 +0200 Subject: added x86.h and removed some test-bugs. --- kernel/x86.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 kernel/x86.h (limited to 'kernel/x86.h') diff --git a/kernel/x86.h b/kernel/x86.h new file mode 100644 index 0000000..1f2179d --- /dev/null +++ b/kernel/x86.h @@ -0,0 +1,42 @@ +#ifndef FOOLOS_X86_H +#define FOOLOS_X86_H + +#include "kernel.h" + +void x86_outb(int port, uint8_t data) +{ + __asm __volatile("outb %0,%w1" : : "a" (data), "d" (port)); +} + +uint8_t x86_inb(int port) +{ + uint8_t data; + __asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port)); + return data; +} + +void x86_outw(int port, uint16_t data) +{ + __asm __volatile("outw %0,%w1" : : "a" (data), "d" (port)); +} + +uint16_t x86_inw(int port) +{ + uint16_t data; + __asm __volatile("inw %w1,%0" : "=a" (data) : "d" (port)); + return data; +} + +void x86_outl(int port, uint32_t data) +{ + __asm __volatile("outl %0,%w1" : : "a" (data), "d" (port)); +} + +uint32_t x86_inl(int port) +{ + uint32_t data; + __asm __volatile("inl %w1,%0" : "=a" (data) : "d" (port)); + return data; +} + +#endif -- cgit v1.2.3