Implement (half) simple semaphore & mutex lock, and ...
[lunaix-os.git] / lunaix-os / kernel / k_main.c
index b3b11031600f09744ac9300d123bfaa03cf9b77e..c3819d9d8050b1e54a8f15d420f328b8ca1ea3b0 100644 (file)
@@ -5,6 +5,8 @@
 #include <lunaix/spike.h>
 #include <lunaix/clock.h>
 #include <lunaix/timer.h>
+#include <lunaix/keyboard.h>
+#include <lunaix/tty/tty.h>
 #include <stdint.h>
 
 extern uint8_t __kernel_start;
@@ -51,7 +53,19 @@ _kernel_main()
     lxfree(arr);
     lxfree(big_);
 
-    timer_run_second(1, test_timer, NULL, TIMER_MODE_PERIODIC);
+    // timer_run_second(1, test_timer, NULL, TIMER_MODE_PERIODIC);
+
+    struct kdb_keyinfo_pkt keyevent;
+    while (1)
+    {
+        if (!kbd_recv_key(&keyevent)) {
+            continue;
+        }
+        if ((keyevent.state & KBD_KEY_FPRESSED) && (keyevent.keycode & 0xff00) <= KEYPAD) {
+            tty_put_char((char)(keyevent.keycode & 0x00ff));
+            tty_sync_cursor();
+        }
+    }
 
     spin();
 }