From b54f79b2325e54e4b6c8a1bd8dba8227ba962260 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 24 Jun 2020 16:06:22 +0200 Subject: stdlib: add getc() --- src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp | 3 +-- src/pOS/arch/x86/libc/stdio/getc.cpp | 9 +++++++++ src/pOS/include/libc/stdio.h | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/pOS/arch/x86/libc/stdio/getc.cpp diff --git a/src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp b/src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp index c32cbdb..c8088e3 100644 --- a/src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp +++ b/src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp @@ -9,6 +9,5 @@ void keyboard_handler(struct regs *r) //dbgprintf("Sc: %d\n", scancode); - if(!KB_BUF::scan(scancode)) - putc(KB_BUF::keyboard_dequeue()); + KB_BUF::scan(scancode); } diff --git a/src/pOS/arch/x86/libc/stdio/getc.cpp b/src/pOS/arch/x86/libc/stdio/getc.cpp new file mode 100644 index 0000000..e0d1b09 --- /dev/null +++ b/src/pOS/arch/x86/libc/stdio/getc.cpp @@ -0,0 +1,9 @@ +#include +#include "../../kernel/drivers/keyboard/include/kbbuf.h" + +char getc(void) +{ + char result; + while((result = KB_BUF::keyboard_dequeue()) == 0); //Sleep + return result; +} diff --git a/src/pOS/include/libc/stdio.h b/src/pOS/include/libc/stdio.h index 844c817..7b5f144 100644 --- a/src/pOS/include/libc/stdio.h +++ b/src/pOS/include/libc/stdio.h @@ -14,6 +14,8 @@ int sprintf(char* buf, const char* format, ...); int print(const char* str); int putc(const char c); +char getc(void); //for now void + class Debug { public: -- cgit 1.4.1