From cafc92c531f0e6342e46508b4583d26e2dbd776c Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 24 Jun 2020 03:33:16 +0200 Subject: Base: added outw, outl, inw and inl to the system interface --- src/pOS/arch/x86/kernel/system.cpp | 24 ++++++++++++++++++++++++ src/pOS/include/kernel/system.h | 5 +++++ 2 files changed, 29 insertions(+) (limited to 'src') diff --git a/src/pOS/arch/x86/kernel/system.cpp b/src/pOS/arch/x86/kernel/system.cpp index ade04f8..0ff405a 100644 --- a/src/pOS/arch/x86/kernel/system.cpp +++ b/src/pOS/arch/x86/kernel/system.cpp @@ -7,11 +7,35 @@ uint8_t System::inb(uint16_t port) return result; } +uint16_t System::inw(uint16_t port) +{ + uint16_t result; + asm volatile( "inw %1, %0" : "=a"(result) : "Nd"(port)); + return result; +} + +uint32_t System::inl(uint16_t port) +{ + uint32_t result; + asm volatile( "inl %1, %0" : "=a"(result) : "Nd"(port)); + return result; +} + void System::outb(uint16_t port, uint8_t data) { asm volatile( "outb %0, %1" : : "a"(data), "Nd"(port)); } +void System::outw(uint16_t port, uint16_t data) +{ + asm volatile ("outw %0, %1" : : "a" (data), "Nd" (port)); +} + +void System::outl(uint16_t port, uint32_t data) +{ + asm volatile ("outl %0, %1" : : "a" (data), "Nd" (port)); +} + int System::idle_loop(void) { while(1) diff --git a/src/pOS/include/kernel/system.h b/src/pOS/include/kernel/system.h index 146ceed..22628c3 100644 --- a/src/pOS/include/kernel/system.h +++ b/src/pOS/include/kernel/system.h @@ -7,7 +7,12 @@ class System { public: static uint8_t inb(uint16_t port); + static uint16_t inw(uint16_t port); + static uint32_t inl(uint16_t port); + static void outb(uint16_t port, uint8_t data); + static void outw(uint16_t port, uint16_t data); + static void outl(uint16_t port, uint32_t data); static int idle_loop(void); }; -- cgit 1.4.1