From 294b8b1ac82352e23a83ce9cad7af9d3b98365ef Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 9 Aug 2021 22:48:19 +0200 Subject: move the x86 port io code to a separate file --- src/kernel/arch/i386/port_io.h | 12 ++++++++++++ src/kernel/arch/i386/tty/serial.c | 12 +----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 src/kernel/arch/i386/port_io.h (limited to 'src') diff --git a/src/kernel/arch/i386/port_io.h b/src/kernel/arch/i386/port_io.h new file mode 100644 index 0000000..db755b4 --- /dev/null +++ b/src/kernel/arch/i386/port_io.h @@ -0,0 +1,12 @@ +#include + +inline void port_outb(uint16_t port, uint8_t val) { + asm volatile("outb %0, %1" : : "a" (val), "Nd" (port)); +} + +inline uint8_t port_inb(uint16_t port) { + uint8_t val; + asm volatile("inb %1, %0" : "=a" (val) : "Nd" (port)); + return val; +} + diff --git a/src/kernel/arch/i386/tty/serial.c b/src/kernel/arch/i386/tty/serial.c index bf55c41..6bfe212 100644 --- a/src/kernel/arch/i386/tty/serial.c +++ b/src/kernel/arch/i386/tty/serial.c @@ -1,19 +1,9 @@ #include +#include #include const int COM1 = 0x3f8; -// TODO move to some header file -inline void port_outb(uint16_t port, uint8_t val) { - asm volatile("outb %0, %1" : : "a" (val), "Nd" (port)); -} - -inline uint8_t port_inb(uint16_t port) { - uint8_t val; - asm volatile("inb %1, %0" : "=a" (val) : "Nd" (port)); - return val; -} - void serial_init() { // see https://www.sci.muni.cz/docs/pc/serport.txt -- cgit v1.2.3