From: Matthias Kruk Date: Mon, 23 Dec 2019 07:29:46 +0000 (+0900) Subject: Add io_inb and io_outb methods for IO-port access on Intel-based platforms X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=b9c75010e5b18797d8146d59c1f17169e63952b3;p=corax Add io_inb and io_outb methods for IO-port access on Intel-based platforms --- diff --git a/kernel/arch/Makefile b/kernel/arch/Makefile index e7e4cce..b63e608 100644 --- a/kernel/arch/Makefile +++ b/kernel/arch/Makefile @@ -1,5 +1,5 @@ OBJECTS = boot.o debug.o init.o cpu.o cpu32.o entry.o interrupt.o paging.o apic.o i8259.o task.o \ - heap.o + heap.o io.o OUTPUT = arch.o LDFLAGS += -r INCLUDES = -I../../include -I../include -I../.. diff --git a/kernel/arch/io.S b/kernel/arch/io.S new file mode 100644 index 0000000..ceca967 --- /dev/null +++ b/kernel/arch/io.S @@ -0,0 +1,22 @@ +#define __ASSEMBLY_SOURCE + +#include +#include +#include "defs.h" + + .global io_inb + .global io_outb + + .section .text + +io_inb: + movl 4(%esp), %edx + xorl %eax, %eax + inb %dx, %al + ret + +io_outb: + movl 4(%esp), %edx + movl 8(%esp), %eax + outb %al, %dx + ret diff --git a/kernel/include/arch.h b/kernel/include/arch.h index cc88308..29c8804 100644 --- a/kernel/include/arch.h +++ b/kernel/include/arch.h @@ -189,6 +189,9 @@ int pg_dir_memcpy(pg_dir_t*, void*, pg_dir_t*, void*, u32_t); int pg_dir_mmap(pg_dir_t*, void*, u32_t, int, int, void**); int pg_dir_munmap(pg_dir_t*, void*, u32_t); +u8_t io_inb(const u16_t); +void io_outb(const u16_t, const u8_t); + #endif /* !__ASSEMBLY_SOURCE */ #endif /* __ARCH_H */