From 8231af9d8d759ae89c8214ca2410b0feab9dfb8c Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 22 Nov 2024 07:58:15 +0100 Subject: Add basic parsing for underlying ELF executables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- include/fbos/compiler.h | 6 ++++-- include/fbos/init.h | 4 +--- include/fbos/sched.h | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/fbos/compiler.h b/include/fbos/compiler.h index b88bb0b..c26c05c 100644 --- a/include/fbos/compiler.h +++ b/include/fbos/compiler.h @@ -19,16 +19,18 @@ #endif /* __KERNEL__ */ /* - * Multiple aliases for 32/64-bit integers which have their definition on the + * Multiple aliases for integer types which have their definition on the * standard library. */ +typedef short int16_t; typedef int int32_t; typedef long ssize_t; typedef long int64_t; -typedef unsigned long size_t; +typedef unsigned short uint16_t; typedef unsigned int uint32_t; +typedef unsigned long size_t; typedef unsigned long uint64_t; typedef unsigned long uintptr_t; diff --git a/include/fbos/init.h b/include/fbos/init.h index c4d0a85..978eebe 100644 --- a/include/fbos/init.h +++ b/include/fbos/init.h @@ -3,11 +3,9 @@ #include -extern struct task_struct init_task; - // Extract the executables from the initrd that is located at `base_addr` and // has the given `size`. -void extract_initrd(const char *const base_addr, uint64_t size); +void extract_initrd(const unsigned char *const base_addr, uint64_t size); // The entry point for the kernel. void start_kernel(void *dtb); diff --git a/include/fbos/sched.h b/include/fbos/sched.h index 5cfc2ba..ff56f32 100644 --- a/include/fbos/sched.h +++ b/include/fbos/sched.h @@ -1,6 +1,8 @@ #ifndef __FBOS_SCHED_H_ #define __FBOS_SCHED_H_ +#include + enum task_id { TASK_UNKNOWN = -1, TASK_INIT = 0, @@ -11,6 +13,10 @@ enum task_id { struct task_struct { void *stack; + const void *addr; + uint64_t entry_offset; }; +extern struct task_struct tasks[4]; + #endif // __FBOS_SCHED_H_ -- cgit v1.2.3