From a8a80d326de9550b2a25b1255a2093ab43219ede Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 27 Jan 2024 23:14:29 -0500 Subject: keyboard input --- kernel/syscall.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'kernel/syscall.cpp') diff --git a/kernel/syscall.cpp b/kernel/syscall.cpp index 3c72d23..e194eb1 100644 --- a/kernel/syscall.cpp +++ b/kernel/syscall.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include namespace hilbert::kernel::syscall { @@ -82,7 +83,7 @@ namespace hilbert::kernel::syscall { set_zero(rax, rdi, rsi, rdx); vfile::vfile file; - switch (vfile::lookup_path(cp, file)) { + switch (vfile::lookup_path(cp, file, true)) { case storage::fs_result::success: break; case storage::fs_result::device_error: @@ -96,28 +97,13 @@ namespace hilbert::kernel::syscall { return; } - vfile::vfile real_file; - switch (file.follow_symlinks(real_file)) { - case storage::fs_result::success: - break; - case storage::fs_result::device_error: - rax = file_result_device_error; - return; - case storage::fs_result::fs_corrupt: - rax = file_result_file_system_corrupt; - return; - case storage::fs_result::does_not_exist: - rax = file_result_does_not_exist; - return; - } - - if (real_file.dir_entry.type != storage::file_type::regular_file) { + if (file.dir_entry.type != storage::file_type::regular_file) { rax = file_result_directory; return; } unsigned handler = - application::running_app->open_files.add_new(utility::move(real_file)); + application::running_app->open_files.add_new(utility::move(file)); rax = file_result_success; rdi = (uint64_t)handler; @@ -226,6 +212,23 @@ namespace hilbert::kernel::syscall { } + void read_key_packet_syscall( + uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx + ) { + + set_zero(rax, rdi, rsi, rdx); + + asm ("cli"); + + while (input::key_queue->count == 0) + asm ("sti\nhlt\ncli"); + + rax = (uint64_t)input::key_queue->take(); + + asm ("sti"); + + } + typedef void (*syscall_handler)( uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx); @@ -237,10 +240,11 @@ namespace hilbert::kernel::syscall { &read_from_file_syscall, &end_this_process_syscall, &get_new_pages_syscall, - &close_file_syscall + &close_file_syscall, + &read_key_packet_syscall }; - static constexpr int max_syscall_number = 7; + static constexpr int max_syscall_number = 8; } -- cgit v1.2.3