From 90af8825a41981ce2ee52e0a9ce84f624eb022e6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 26 Jul 2022 00:38:45 +0200 Subject: move user_bootstrap to user/bootstrap for consistency's sake --- src/user/bootstrap/main.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/user/bootstrap/main.c (limited to 'src/user/bootstrap/main.c') diff --git a/src/user/bootstrap/main.c b/src/user/bootstrap/main.c new file mode 100644 index 0000000..5f36aa1 --- /dev/null +++ b/src/user/bootstrap/main.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include + +#include "tar.h" + +extern char _bss_start; +extern char _bss_end; +extern char _initrd; + +__attribute__((section(".text.startup"))) +int main(void) { + _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); + + /* move everything provided by the kernel to /kdev */ + MOUNT("/kdev/", fs_passthru(NULL)); + if (!fork2_n_mount("/")) { + const char *l[] = {"/kdev/", NULL}; + fs_whitelist(l); + } + if (!fork2_n_mount("/")) fs_dir_inject("/kdev/"); // TODO should be part of fs_whitelist + + MOUNT("/init/", tar_driver(&_initrd)); + + void *init = tar_find("init.elf", 8, &_initrd, ~0) + 512; + if (init) { + _klogf("execing init.elf"); + elf_exec(init); + _klogf("elf_exec failed"); + } else { + _klogf("couldn't find init.elf"); + } + _syscall_exit(1); +} -- cgit v1.2.3