From 9af5588c30c4126a2800aae1afcb0de2c373dc6c Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 20 May 2024 17:40:47 -0400 Subject: rewrite application stuff in the kernel to support multitasking --- kernel/source/entry.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'kernel/source/entry.cpp') diff --git a/kernel/source/entry.cpp b/kernel/source/entry.cpp index 5db3515..2389bb1 100644 --- a/kernel/source/entry.cpp +++ b/kernel/source/entry.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -201,25 +202,29 @@ extern "C" [[noreturn]] void entry() { vfile::canonize_path(init_path_string, init_path); vfile::vfile init_file; - if (vfile::lookup_path(init_path, init_file, true) != + if (vfile::look_up_path(init_path, init_file, true) != storage::fs_result::success) panic(0x7e874d); - application::process *init_process; - application::thread *init_thread; - if (application::create_application(init_file, init_process, init_thread) != - application::stream_result::success) + app_memory *init_memory = new app_memory(); + uint64_t init_entry_point; + load_app_result load_init_result = + load_app(init_file, *init_memory, init_entry_point); + + if (load_init_result != load_app_result::success) panic(0xc39db3); - init_process->environment.add_end({ - .a = utility::string("ARGC", 4), - .b = utility::string("1", 1)}); - init_process->environment.add_end({ - .a = utility::string("ARGV0", 5), - .b = utility::string("/bin/init", 9)}); + application::process *init_process = new application::process(init_memory); + init_process->add_environment_variable( + utility::string("ARGC", 4), utility::string("1", 1)); + init_process->add_environment_variable( + utility::string("ARGV0", 5), utility::string("/bin/init", 9)); + application::add_process(init_process); - init_thread->state = application::thread_state::paused; + application::thread *init_thread = + new application::thread(init_process, init_entry_point); + init_process->add_thread(init_thread); application::paused_threads->insert(init_thread); - application::resume_next(); + application::resume_next_thread(); } -- cgit v1.2.3