From 40ffc517e20c381ce8fdb3a881726a26a52e35db Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 21 Nov 2024 13:09:21 +0100 Subject: Initial parsing of the provided initrd file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We expect a CPIO archive with the 'newc' format for the initrd. Parse this archive from the given initrd address and fetch the address for each ELF executable while also pairing which task correspond to which ELF. This commit leaves to do the actual parsing of the ELF file for each task, while also leaving some string utilities to be refined. Signed-off-by: Miquel Sabaté Solà --- include/fbos/init.h | 6 +++++- include/fbos/sched.h | 8 ++++++++ include/fbos/string.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/fbos/init.h b/include/fbos/init.h index eb72508..c4d0a85 100644 --- a/include/fbos/init.h +++ b/include/fbos/init.h @@ -5,7 +5,11 @@ 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); + // The entry point for the kernel. -__noreturn __kernel void start_kernel(void *dtb); +void start_kernel(void *dtb); #endif /* __FBOS_INIT_H */ diff --git a/include/fbos/sched.h b/include/fbos/sched.h index 626f72f..5cfc2ba 100644 --- a/include/fbos/sched.h +++ b/include/fbos/sched.h @@ -1,6 +1,14 @@ #ifndef __FBOS_SCHED_H_ #define __FBOS_SCHED_H_ +enum task_id { + TASK_UNKNOWN = -1, + TASK_INIT = 0, + TASK_FOO = 1, + TASK_BAR = 2, + TASK_FOOBAR = 3, +}; + struct task_struct { void *stack; }; diff --git a/include/fbos/string.h b/include/fbos/string.h index af7e2ef..ade77cc 100644 --- a/include/fbos/string.h +++ b/include/fbos/string.h @@ -5,5 +5,7 @@ extern size_t strlen(const char *); extern int strcmp(const char *, const char *); +extern int memcmp(const void *, const void *, size_t); +extern void *memcpy(void *, const void *, size_t); #endif // __FBOS_STRING_H_ -- cgit v1.2.3