From 0ea9974512adb8cf58974646b0421669e2c6f96f Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 5 Jan 2023 21:55:21 +0100 Subject: [PATCH] First user process! Putting it all together, we have a user process that successfully calls sys_exit() w/o crashing. --- apps/app.asm | 14 -------------- kernel/src/main.cpp | 13 +++---------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/apps/app.asm b/apps/app.asm index 78dc6066..56062887 100644 --- a/apps/app.asm +++ b/apps/app.asm @@ -1,18 +1,4 @@ section .text global _start _start: - mov eax, ecx - push rdx - mov eax, 1 - mov edi, hello_world - mov esi, 14 int 42h - nop - -section .rodata -hello_world: - db 'Hello, world!', 0xa, 0 - -section .bss -array: - resb 10 \ No newline at end of file diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index d46b731b..f9ba6a30 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -51,7 +51,8 @@ Result init() kinfoln("Used memory: %s", to_dynamic_unit(MemoryManager::used()).release_value().chars()); kinfoln("Reserved memory: %s", to_dynamic_unit(MemoryManager::reserved()).release_value().chars()); - MMU::unmap(0x400000); + Thread::init(); + Scheduler::init(); TarStream::Entry entry; while (TRY(g_initrd.read_next_entry().try_set_value_with_specific_error(entry, 0))) @@ -61,18 +62,10 @@ Result init() kinfoln("Found file %s in initial ramdisk, of size %s", entry.name, to_dynamic_unit(entry.size).release_value().chars()); - if (!strcmp(entry.name, "bin/app")) - { - auto data = TRY(ELFLoader::load(entry, g_initrd)); - data.segments.consume([](ELFSegment* segment) { delete segment; }); - kinfoln("Loaded ELF with entry=%#.16lx", data.entry); - } + if (!strcmp(entry.name, "bin/app")) { TRY(Scheduler::new_userspace_thread(entry, g_initrd)); } } } - Thread::init(); - Scheduler::init(); - TRY(Scheduler::new_kernel_thread(heap_thread)); TRY(Scheduler::new_kernel_thread(reap_thread));