aboutsummaryrefslogtreecommitdiff
path: root/test/test_initrd.c
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-22 07:58:15 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-22 07:58:15 +0100
commit8231af9d8d759ae89c8214ca2410b0feab9dfb8c (patch)
treef679c721ad1dd3daa5830da6c10425d2d3b699ab /test/test_initrd.c
parent40ffc517e20c381ce8fdb3a881726a26a52e35db (diff)
downloadfbos-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 'test/test_initrd.c')
-rw-r--r--test/test_initrd.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/test_initrd.c b/test/test_initrd.c
index 3662eaa..73429b8 100644
--- a/test/test_initrd.c
+++ b/test/test_initrd.c
@@ -3,6 +3,17 @@
#include <assert.h>
#include <fbos/init.h>
+#include <fbos/sched.h>
+#include <fbos/mm.h>
+
+unsigned long init_stack[4][THREAD_SIZE / sizeof(unsigned long)];
+
+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] },
+};
int main(void)
{
@@ -13,7 +24,7 @@ int main(void)
long fsize = ftell(fh);
rewind(fh);
- char *contents = malloc((unsigned long)fsize + 1);
+ unsigned char *contents = malloc((unsigned long)fsize + 1);
fread(contents, (unsigned long)fsize, 1, fh);
fclose(fh);