diff options
Diffstat (limited to 'src/kernel/elf.c')
-rw-r--r-- | src/kernel/elf.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/kernel/elf.c b/src/kernel/elf.c index bd2f12d..423d51a 100644 --- a/src/kernel/elf.c +++ b/src/kernel/elf.c @@ -73,7 +73,7 @@ struct ph_entry { uint32_t align; } __attribute__ ((packed)); -bool try_elf_run(const struct drive *d, const char *path) { +bool try_elf_run(const struct drive *d, const char *path, const char *pass_old_vma) { file_id_t h = d->get_file(d, path); if (!h) return false; @@ -109,9 +109,23 @@ bool try_elf_run(const struct drive *d, const char *path) { free_pages(phtable, phtable_pages); d->free_file(d, h); + const char *pass = vma_to_pma(active_task->page_directory, pass_old_vma); + + uint32_t pass_l = 0; + while (pass[pass_l++]) + ; + + void *pass_vma; + void *pass_pma; + user_allocate_anywhere_readonly_together(pd, ((pass_l - 1) >> 12) + 1, &pass_vma, &pass_pma); + //TODO: handle error condition + + memcpy(pass_pma, pass, pass_l); + struct task_state tstate; tstate.page_directory = pd; tstate.ret_addr = ehead.entry_vma; + tstate.edx = (uint32_t)pass_vma; new_task(tstate); return true; }
\ No newline at end of file |