diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-22 07:58:15 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-22 07:58:15 +0100 |
| commit | 8231af9d8d759ae89c8214ca2410b0feab9dfb8c (patch) | |
| tree | f679c721ad1dd3daa5830da6c10425d2d3b699ab /kernel/main.c | |
| parent | 40ffc517e20c381ce8fdb3a881726a26a52e35db (diff) | |
| download | fbos-8231af9d8d759ae89c8214ca2410b0feab9dfb8c.tar.gz fbos-8231af9d8d759ae89c8214ca2410b0feab9dfb8c.zip | |
Add basic parsing for underlying ELF executables
The given initrd is a CPIO archive of multiple ELF executables. We are
already able to parse the CPIO archive to detect where each file is
located, this commit adds the mapping for each ELF executable to the
corresponding task_struct.
Note that this is still heavily under construction, since we cannot
simply jump into the entry point of an executable as we have not yet
setup the proper layout from performing context switches.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'kernel/main.c')
| -rw-r--r-- | kernel/main.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel/main.c b/kernel/main.c index 7eb2ef6..089614f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -4,9 +4,14 @@ #include <fbos/sched.h> #include <fbos/dt.h> -unsigned long init_stack[THREAD_SIZE / sizeof(unsigned long)]; +unsigned long init_stack[4][THREAD_SIZE / sizeof(unsigned long)]; -struct task_struct init_task = { .stack = init_stack }; +struct task_struct tasks[4] = { + [0] = { .stack = init_stack[0] }, + [1] = { .stack = init_stack[1] }, + [2] = { .stack = init_stack[2] }, + [3] = { .stack = init_stack[3] }, +}; /* * This is the main entry point of the kernel after head.S is done. This @@ -21,7 +26,11 @@ __noreturn __kernel void start_kernel(void *dtb) struct initrd_addr addr = find_dt_initrd_addr(dtb); - extract_initrd((char *)addr.start, addr.end - addr.start); + extract_initrd((unsigned char *)addr.start, addr.end - addr.start); + + // TODO: this is the jump address for the first task. + const char *ddr = (const char *)tasks[1].addr + tasks[1].entry_offset; + __unused(ddr); // TODO: reenable stuff |
