From c98464d1c75a5ae194ab002f7283811c93885d47 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Sun, 22 Oct 2017 21:17:12 +0100 Subject: [PATCH] Added assembly for reading/writing to IO locations. --- kernel/arch/i386/io.nim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 kernel/arch/i386/io.nim diff --git a/kernel/arch/i386/io.nim b/kernel/arch/i386/io.nim new file mode 100644 index 0000000..f72bc25 --- /dev/null +++ b/kernel/arch/i386/io.nim @@ -0,0 +1,16 @@ +type + IOPacket* = tuple + port: uint16 + value: uint8 + +{.push stackTrace:off.} +proc outb*(data: IOPacket) = + asm """ + outb `data.value` `data.port` + """ + +proc inb*(port: uint16): uint = + asm """ + inb `port` `result` + """ +{.pop.}