summaryrefslogtreecommitdiff
path: root/kernel/source/syscall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/source/syscall.cpp')
-rw-r--r--kernel/source/syscall.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/kernel/source/syscall.cpp b/kernel/source/syscall.cpp
index 6b0f13f..f2a6801 100644
--- a/kernel/source/syscall.cpp
+++ b/kernel/source/syscall.cpp
@@ -700,10 +700,44 @@ namespace hilbert::kernel::syscall {
}
- typedef void (*syscall_handler)(
- uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx);
+ void start_thread_syscall(
+ uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) {
+
+ uint64_t entry_point = rdi;
+ uint64_t argument = rsi;
+ set_zero(rax, rdi, rsi, rdx);
+
+ auto *p = application::running_thread->owner;
+ auto *t = new application::thread(p, entry_point);
+ t->saved_state.rdi = argument;
+ p->add_thread(t);
+ application::paused_threads->insert(t);
+
+ }
+
+ void clear_socket_read_queue_syscall(
+ uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) {
+
+ unsigned handle = (unsigned)rdi;
+ set_zero(rax, rdi, rsi, rdx);
+
+ auto stream = application::running_thread->owner->get_stream(handle);
+
+ if (stream.is_null() || !stream.is_socket) {
+ rax = 0;
+ return;
+ }
+
+ auto &queue = stream.as_socket_stream->read_queue;
+
+ rax = queue.count;
+ queue.clear();
+
+ }
+
+ void (*handlers[])(
+ uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) = {
- syscall_handler handlers[] = {
&encode_color_syscall,
&get_framebuffer_syscall,
&open_file_syscall,
@@ -723,10 +757,13 @@ namespace hilbert::kernel::syscall {
&start_process_syscall,
&end_this_process_syscall,
&set_stream_length_syscall,
- &get_other_end_process_handle_syscall
+ &get_other_end_process_handle_syscall,
+ &start_thread_syscall,
+ &clear_socket_read_queue_syscall
+
};
- static constexpr int max_syscall_number = 19;
+ static constexpr int max_syscall_number = 20;
}