summaryrefslogtreecommitdiff
path: root/src/kernel/elf.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-13 03:19:57 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-13 03:19:57 -0400
commit1e4a254674f668839e5de273916024c16814b045 (patch)
tree6774f4d4398a29c4aafb4120070975d864ffcde4 /src/kernel/elf.c
parentb8284137d4e0eec11c78bc14047243fce6a51373 (diff)
downloadportland-os-1e4a254674f668839e5de273916024c16814b045.tar.gz
(basic, not much tested) keyboard, better panic
Diffstat (limited to 'src/kernel/elf.c')
-rw-r--r--src/kernel/elf.c16
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