From 1e4a254674f668839e5de273916024c16814b045 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 13 Sep 2020 03:19:57 -0400 Subject: (basic, not much tested) keyboard, better panic --- src/kernel/elf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/kernel/elf.c') 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 -- cgit v1.2.3