summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2021-11-26 16:22:27 -0500
committerJon Santmyer <jon@jonsantmyer.com>2021-11-26 16:22:27 -0500
commitc070667252e6db6bde6cb6b1d96a0c5bbb52b435 (patch)
treeb99f3369f6d0574a72bff2aa1b1d1425e0ab487b
parent6f895bf2b6609a9b98bf8b74a6f7d140f3ed5884 (diff)
downloadmodit-kernel-c070667252e6db6bde6cb6b1d96a0c5bbb52b435.tar.gz
modit-kernel-c070667252e6db6bde6cb6b1d96a0c5bbb52b435.tar.bz2
modit-kernel-c070667252e6db6bde6cb6b1d96a0c5bbb52b435.zip
add proper arg and env processing for ld
-rw-r--r--include/arch_x86/common/syscall.h4
-rw-r--r--src/arch_common/init/init.c12
-rw-r--r--src/arch_x86/common/syscall/syscall.c16
3 files changed, 22 insertions, 10 deletions
diff --git a/include/arch_x86/common/syscall.h b/include/arch_x86/common/syscall.h
index 6fc17a2..7eb84c9 100644
--- a/include/arch_x86/common/syscall.h
+++ b/include/arch_x86/common/syscall.h
@@ -37,7 +37,9 @@ enum {
SYSCALL_MESSAGE_RECV,
SYSCALL_INITRD_GET,
- SYSCALL_UNK,
+ SYSCALL_DETACH,
+ SYSCALL_EXEC,
+ SYSCALL_SPAWN,
SYSCALL_MAX
};
extern syscall_t syscalls[SYSCALL_MAX];
diff --git a/src/arch_common/init/init.c b/src/arch_common/init/init.c
index a53c0b0..2edfba3 100644
--- a/src/arch_common/init/init.c
+++ b/src/arch_common/init/init.c
@@ -12,22 +12,20 @@
#include <stdbool.h>
struct ldexpect {
- char **argv;
- char **envp;
+ char nulterm[2];
char elf[];
};
static void
init_spawn(struct initrd_file *init, struct initrd_file *ld)
{
- struct ldexpect *ldstk = kmalloc(init->size + (2 * sizeof(uintptr_t)), "initstk");
- ldstk->argv = NULL;
- ldstk->envp = NULL;
- memcpy(&(ldstk->elf), init->data, init->size);
+ struct ldexpect *ldstk = kmalloc(init->size + 2, "initstk");
+ memcpy(ldstk->elf, init->data, init->size);
+ memset(ldstk->nulterm, 0, 2);
struct execution_context *initctx = excontext_spawn(ld->data, ld->size,
(const uint8_t*)ldstk,
- init->size + (2 * sizeof(uintptr_t)));
+ init->size + 2);
excontext_switch(initctx);
while(1) asm("hlt");
diff --git a/src/arch_x86/common/syscall/syscall.c b/src/arch_x86/common/syscall/syscall.c
index 2757dec..ee13205 100644
--- a/src/arch_x86/common/syscall/syscall.c
+++ b/src/arch_x86/common/syscall/syscall.c
@@ -65,7 +65,7 @@ syscall_map(struct syscall_map_data *data)
POINTER_BOUND_CHECK(data->virt)
PRIV_CHECK(SYSCALL_PRIV_PAGE)
- return vmm_mappg(data->phys, data->virt, 0x1000, data->flags | PAGE_USER).value;
+ return vmm_mappg(data->phys, data->virt, 0, data->flags | PAGE_USER).value;
}
int
@@ -172,7 +172,6 @@ int
syscall_initrd_get(struct syscall_initrd_data *data)
{
POINTER_CHECK(data)
- printk(KERNEL_INFO, "IRD GOT %lX %lX\n", data->phys, data->len);
POINTER_CHECK(data->phys)
POINTER_CHECK(data->len)
@@ -185,6 +184,19 @@ syscall_initrd_get(struct syscall_initrd_data *data)
return 0;
}
+int
+syscall_detach(void *unused)
+{
+ (void)unused;
+ uintptr_t cr3 = (uintptr_t)kmalloc_a(PAGE_SIZE, PAGE_SIZE, "cr3");
+ uintptr_t pcr3 = tlb_clonecr3();
+
+ vmm_mappg(pcr3, cr3, 0, 3);
+ current_excontext->vcr3 = cr3;
+
+ excontext_switch(current_excontext);
+}
+
syscall_t syscalls[SYSCALL_MAX] =
{
syscall_print,