about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-06-24 16:06:22 +0200
committerYour Name <you@example.com>2020-06-24 16:06:22 +0200
commitb54f79b2325e54e4b6c8a1bd8dba8227ba962260 (patch)
treefc580dd81d78d4acaa490f01a801fdecdaf75275
parentstdlib: add memcmp() and strncmp() (diff)
downloadpOS-b54f79b2325e54e4b6c8a1bd8dba8227ba962260.tar.gz
pOS-b54f79b2325e54e4b6c8a1bd8dba8227ba962260.tar.bz2
pOS-b54f79b2325e54e4b6c8a1bd8dba8227ba962260.zip
stdlib: add getc()
-rw-r--r--src/pOS/arch/x86/kernel/drivers/keyboard/keyboard.cpp3
-rw-r--r--src/pOS/arch/x86/libc/stdio/getc.cpp9
-rw-r--r--src/pOS/include/libc/stdio.h2
3 files changed, 12 insertions, 2 deletions
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 <stdio.h>
+#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: