summaryrefslogtreecommitdiff
path: root/euler/source
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-05-20 17:40:47 -0400
committerBenji Dial <benji@benjidial.net>2024-05-20 17:40:47 -0400
commit9af5588c30c4126a2800aae1afcb0de2c373dc6c (patch)
treed2a48a97b1664f958b5f88a8b0c03ef8366b0f49 /euler/source
parent5a54df93c4e9368c36e69d1e9c88cd2904e92308 (diff)
downloadhilbert-os-9af5588c30c4126a2800aae1afcb0de2c373dc6c.tar.gz
rewrite application stuff in the kernel to support multitasking
Diffstat (limited to 'euler/source')
-rw-r--r--euler/source/euler/start_process.cpp35
-rw-r--r--euler/source/euler/syscall.asm18
2 files changed, 53 insertions, 0 deletions
diff --git a/euler/source/euler/start_process.cpp b/euler/source/euler/start_process.cpp
new file mode 100644
index 0000000..64e16c5
--- /dev/null
+++ b/euler/source/euler/start_process.cpp
@@ -0,0 +1,35 @@
+#include <euler/start_process.hpp>
+#include <cstring>
+
+namespace euler {
+
+ start_process::start_process(const char *path)
+ : path(path), path_len(std::strlen(path)) {}
+
+ void start_process::add_env_variable(const char *name, const char *value) {
+ env_var_specs.push_back({
+ .name_len = std::strlen(name), .name = name,
+ .value_len = std::strlen(value), .value = value });
+ }
+
+ void start_process::gift_stream(
+ __euler_stream_handle to_gifter, __euler_stream_handle to_giftee) {
+ gift_stream_specs.push_back({
+ .stream_handle_to_gifter = to_gifter,
+ .stream_handle_to_giftee = to_giftee });
+ }
+
+ __euler_stream_result start_process::start(
+ __euler_process_handle &handle_out) {
+ __euler_process_start_info info = {
+ .file_path_length = path_len,
+ .file_path = path,
+ .env_var_count = env_var_specs.size(),
+ .env_vars = env_var_specs.data(),
+ .gift_stream_count = gift_stream_specs.size(),
+ .gift_streams = gift_stream_specs.data(),
+ };
+ return __euler_start_process(info, handle_out);
+ }
+
+}
diff --git a/euler/source/euler/syscall.asm b/euler/source/euler/syscall.asm
index 41bd05c..64f08f8 100644
--- a/euler/source/euler/syscall.asm
+++ b/euler/source/euler/syscall.asm
@@ -12,6 +12,8 @@ global __euler_read_from_stream
global __euler_get_framebuffer
global __euler_encode_color
global __euler_get_input_packet
+global __euler_start_process
+global __euler_get_other_end_process_handle
section .text
@@ -124,3 +126,19 @@ __euler_get_input_packet:
mov byte [rdx], al
mov al, 1
ret
+
+__euler_start_process:
+ push rsi
+ mov rax, 16
+ syscall
+ pop rsi
+ mov qword [rsi], rdi
+ ret
+
+__euler_get_other_end_process_handle:
+ push rsi
+ mov rax, 19
+ syscall
+ pop rsi
+ mov qword [rsi], rdi
+ ret