diff options
author | Benji Dial <benji@benjidial.net> | 2024-01-27 23:14:29 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-01-27 23:14:29 -0500 |
commit | a8a80d326de9550b2a25b1255a2093ab43219ede (patch) | |
tree | d42a800f735caf93679d1728e2d5f20004db3b65 /kernel/syscall.cpp | |
parent | 7199e74aa22e592a3b77bdd81f735edca5470596 (diff) | |
download | hilbert-os-a8a80d326de9550b2a25b1255a2093ab43219ede.tar.gz |
keyboard input
Diffstat (limited to 'kernel/syscall.cpp')
-rw-r--r-- | kernel/syscall.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
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 <hilbert/kernel/application.hpp> #include <hilbert/kernel/framebuffer.hpp> #include <hilbert/kernel/paging.hpp> +#include <hilbert/kernel/input.hpp> #include <hilbert/kernel/vfile.hpp> 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; } |