Start working on a VFS implementation #22

Closed
apio wants to merge 44 commits from oop-vfs into main
3 changed files with 22 additions and 3 deletions
Showing only changes of commit d842443869 - Show all commits

View File

@ -26,5 +26,7 @@ namespace CPU
void get_stack_trace_at(Registers* regs, void (*callback)(u64, void*), void* arg);
void print_stack_trace_at(Registers* regs);
[[noreturn]] void bootstrap_switch_stack(u64 stack, void* function);
void pause();
}

View File

@ -295,6 +295,15 @@ namespace CPU
&frame_index);
}
[[noreturn]] void bootstrap_switch_stack(u64 stack, void* function)
{
asm volatile("mov %0, %%rsp\n"
"jmp *%1"
:
: "r"(stack), "r"(function));
__builtin_unreachable();
}
void pause()
{
asm volatile("pause");

View File

@ -90,11 +90,19 @@ Result<void> init()
return {};
}
extern "C" [[noreturn]] void _start()
[[noreturn]] void init_wrapper()
{
Init::check_magic();
Init::early_init();
auto rc = init();
if (rc.has_error()) kerrorln("Runtime error: %s", rc.error_string());
CPU::idle_loop();
}
// FIXME: Add a guard page to make sure the stack doesn't end up in random kernel memory. Also reclaim this memory after
// leaving the init task.
extern "C" [[noreturn]] void _start()
{
Init::check_magic();
Init::early_init();
Stack stack { MemoryManager::alloc_for_kernel(8, MMU::ReadWrite | MMU::NoExecute).value(), 8 * ARCH_PAGE_SIZE };
CPU::bootstrap_switch_stack(stack.top(), (void*)init_wrapper);
}