diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2021-11-23 12:57:17 -0500 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2021-11-23 12:57:17 -0500 |
commit | 6f895bf2b6609a9b98bf8b74a6f7d140f3ed5884 (patch) | |
tree | 1a96c6d9fa858b07eb1533a2f83ef2513fc30d46 | |
parent | 5943a515fdda7b2c148122e779aed16312be7cb4 (diff) | |
download | modit-kernel-6f895bf2b6609a9b98bf8b74a6f7d140f3ed5884.tar.gz modit-kernel-6f895bf2b6609a9b98bf8b74a6f7d140f3ed5884.tar.bz2 modit-kernel-6f895bf2b6609a9b98bf8b74a6f7d140f3ed5884.zip |
make initrd module 0 only; add syscall to get initrd phys and len
-rw-r--r-- | include/arch_x86/common/syscall.h | 7 | ||||
-rw-r--r-- | src/arch_common/initrd/initrd.c | 18 | ||||
-rw-r--r-- | src/arch_x86/common/syscall/syscall.c | 23 |
3 files changed, 27 insertions, 21 deletions
diff --git a/include/arch_x86/common/syscall.h b/include/arch_x86/common/syscall.h index 4ea4755..6fc17a2 100644 --- a/include/arch_x86/common/syscall.h +++ b/include/arch_x86/common/syscall.h @@ -37,6 +37,7 @@ enum { SYSCALL_MESSAGE_RECV, SYSCALL_INITRD_GET, + SYSCALL_UNK, SYSCALL_MAX }; extern syscall_t syscalls[SYSCALL_MAX]; @@ -106,10 +107,8 @@ struct syscall_message_data { }; struct syscall_initrd_data { - const char *path; - char *buffer; - size_t length; - size_t index; + uintptr_t *phys; + uintptr_t *len; }; #endif diff --git a/src/arch_common/initrd/initrd.c b/src/arch_common/initrd/initrd.c index fe80c11..715f9fe 100644 --- a/src/arch_common/initrd/initrd.c +++ b/src/arch_common/initrd/initrd.c @@ -25,12 +25,8 @@ module_setup(struct modit_kernel_module *mod) { size_t mpagestotal = ((mod->end - mod->begin) + (PAGE_SIZE - 1)) / PAGE_SIZE; vmptr_t modpages = 0; - char *modname = (char*)((uintptr_t)mod->string & 0xFFF) + strpage; - if(strncmp("initrd", modname, 128) != 0) return; - modulefound = true; - - modpages = (uintptr_t)kmalloc_a(mpagestotal * PAGE_SIZE, PAGE_SIZE, modname); + modpages = (uintptr_t)kmalloc_a(mpagestotal * PAGE_SIZE, PAGE_SIZE, "initrd"); for(size_t i = 0; i < mpagestotal * PAGE_SIZE; i += PAGE_SIZE) { vmm_mappg(mod->begin + i, modpages + i, 0, 3); } @@ -42,20 +38,12 @@ MODULE static void initrd_constructor(void) { struct modit_kernel_module_container *modules = boot_getkernelmodules(); - strframe = (uintptr_t)modules->modules[0].string & (~0xFFF); if(modules->count == 0) { initrd_message_missing(); return; } - strpage = (uintptr_t)kmalloc_a(PAGE_SIZE, PAGE_SIZE, "initrdstrs"); - vmm_mappg(strframe, strpage, 0, 3); - - for(size_t i = 0; i < modules->count; i++) { - struct modit_kernel_module *mod = &modules->modules[i]; - module_setup(mod); - } - - if(!modulefound) initrd_message_missing(); + struct modit_kernel_module *mod = &modules->modules[0]; + module_setup(mod); } diff --git a/src/arch_x86/common/syscall/syscall.c b/src/arch_x86/common/syscall/syscall.c index 5a54d7a..2757dec 100644 --- a/src/arch_x86/common/syscall/syscall.c +++ b/src/arch_x86/common/syscall/syscall.c @@ -1,6 +1,7 @@ #include "syscall.h" #include "stdio.h" #include "task.h" +#include "boot.h" #include "vmm.h" #include "pmm.h" #include "ipc.h" @@ -64,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, 0, data->flags | PAGE_USER).value; + return vmm_mappg(data->phys, data->virt, 0x1000, data->flags | PAGE_USER).value; } int @@ -167,6 +168,23 @@ syscall_message_recv(struct syscall_message_data *data) return message_recv(data->buffer, &data->tgt); } +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) + + struct modit_kernel_module_container *modcont = boot_getkernelmodules(); + struct modit_kernel_module *initrdmod = &modcont->modules[0]; + + *(data->phys) = initrdmod->begin; + *(data->len) = initrdmod->end - *(data->phys); + return 0; +} + syscall_t syscalls[SYSCALL_MAX] = { syscall_print, @@ -184,5 +202,6 @@ syscall_t syscalls[SYSCALL_MAX] = syscall_port_read, syscall_port_write, syscall_message_send, - syscall_message_recv + syscall_message_recv, + syscall_initrd_get }; |