diff options
author | dzwdz | 2022-07-23 19:28:43 +0200 |
---|---|---|
committer | dzwdz | 2022-07-23 19:28:43 +0200 |
commit | 20c7b5be3bbb5f56a31536c018e20706100f57ae (patch) | |
tree | 47dde902a7d2a2ff464c600d76b4743fe8153e63 /src/user_bootstrap | |
parent | 3badc5ac30fcc0836a2604146788158b16b64f2d (diff) |
user_bootstrap: pass the initrd in an argument to init's main
Diffstat (limited to 'src/user_bootstrap')
-rw-r--r-- | src/user_bootstrap/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/user_bootstrap/main.c b/src/user_bootstrap/main.c index 71647c4..52d7058 100644 --- a/src/user_bootstrap/main.c +++ b/src/user_bootstrap/main.c @@ -10,7 +10,7 @@ extern char _initrd; /* libc stubs */ int printf(const char *fmt, ...) {(void)fmt; return 0;} void *malloc(size_t size) {(void)size; _syscall_exit(1);} -void free(void *ptr) {} +void free(void *ptr) {(void)ptr;} int file_read(libc_file *f, char *buf, size_t len) {(void)f; (void)buf; (void)len; _syscall_exit(1);} @@ -52,8 +52,12 @@ int main(void) { _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); void *init = tar_find(&_initrd, "init.elf"); - elf_exec(init); - _syscall_debug_klog("bootstrap failed", sizeof("bootstrap failed")); - + void (*entry)(void*) = elf_partialexec(init); + if (entry) { + // TODO dynamically link initrd + entry(&_initrd); + } else { + _syscall_debug_klog("bootstrap failed", sizeof("bootstrap failed")); + } _syscall_exit(0); } |