From 3d4557343fbc5ca281b621efa79e63287e38e25b Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Fri, 8 May 2020 10:16:41 -0500 Subject: [PATCH] Added an I/O port driver and made it callable from C. --- includes/io.h | 4 ++++ kernel/io.s | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 includes/io.h create mode 100644 kernel/io.s diff --git a/includes/io.h b/includes/io.h new file mode 100644 index 0000000..cc1c42e --- /dev/null +++ b/includes/io.h @@ -0,0 +1,4 @@ +#ifndef IO_H +#define IO_H +void outb(unsigned short port, unsigned char data); +#endif diff --git a/kernel/io.s b/kernel/io.s new file mode 100644 index 0000000..1c963c1 --- /dev/null +++ b/kernel/io.s @@ -0,0 +1,11 @@ +global outb + +; outb - Send a byte to an I/O port. +; stack: [esp + 8] The data byte +; [esp + 4] The I/O port +; [esp ] Return address +outb: + mov al, [esp + 8] ; Move the data to send into the AL register + mov dx, [esp + 4] ; Move the address of the I/O port into the DX register + out dx, al ; Send the data to the I/O port + ret ; Return