summaryrefslogtreecommitdiff
path: root/kernel/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/x86.c')
-rw-r--r--kernel/x86.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/kernel/x86.c b/kernel/x86.c
new file mode 100644
index 0000000..ee38599
--- /dev/null
+++ b/kernel/x86.c
@@ -0,0 +1,38 @@
+#include "x86.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;
+}
+