summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/toxic/io.h9
-rw-r--r--src/io/io.asm56
2 files changed, 65 insertions, 0 deletions
diff --git a/src/include/toxic/io.h b/src/include/toxic/io.h
new file mode 100644
index 0000000..f2a869a
--- /dev/null
+++ b/src/include/toxic/io.h
@@ -0,0 +1,9 @@
+#ifndef IO_H
+#define IO_H
+
+unsigned char insb(unsigned short port);
+unsigned short insw(unsigned short port);
+
+void outb(unsigned short port, unsigned char val);
+void outw(unsigned short port, unsigned short val);
+#endif /* IO_H */
diff --git a/src/io/io.asm b/src/io/io.asm
new file mode 100644
index 0000000..37ad7eb
--- /dev/null
+++ b/src/io/io.asm
@@ -0,0 +1,56 @@
+section .asm
+
+global insb
+global insw
+global outb
+global outw
+
+insb:
+ push ebp
+ mov ebp, esp
+
+ xor eax, eax ; Zero out eax
+ mov dx, [ebp+8]
+ in al, dx
+
+ mov esp, ebp
+ pop ebp
+ ret
+
+insw:
+ push ebp
+ mov ebp, esp
+
+ xor eax, eax ; Zero out eax
+ mov dx, [ebp+8]
+ in ax, dx
+
+ mov esp, ebp
+ pop ebp
+ ret
+
+outb:
+ push ebp
+ mov ebp, esp
+
+ xor eax, eax
+ mov ax, [ebp+12] ; val to write
+ mov dx, [ebp+8] ; to this port
+ out dx, al
+
+ mov esp, ebp
+ pop ebp
+ ret
+
+outw:
+ push ebp
+ mov ebp, esp
+
+ xor eax, eax
+ mov ax, [ebp+12] ; val to write
+ mov dx, [ebp+8] ; to this port
+ out dx, ax
+
+ mov esp, ebp
+ pop ebp
+ ret