From f4986dab75fa612f4f3d525187cd04c029d9bc6b Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 24 Nov 2024 23:27:13 +0100 Subject: Accept tasks as a parameter on initrd extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows this functionality to be properly extracted for unit tests. Signed-off-by: Miquel Sabaté Solà --- kernel/main.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'kernel/main.c') diff --git a/kernel/main.c b/kernel/main.c index 58d67f5..fdcef1f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -4,13 +4,16 @@ #include #include -unsigned long init_stack[4][THREAD_SIZE / sizeof(unsigned long)]; +// Stacks to be used by our processes. +unsigned long stack[4][THREAD_SIZE / sizeof(unsigned long)]; +// Initialize the list of structs by providing a fixed stack address and empty +// values everywhere else. struct task_struct tasks[4] = { - [TASK_INIT] = { .stack = init_stack[0], .entry_addr = nullptr, }, - [TASK_FIZZ] = { .stack = init_stack[1], .entry_addr = nullptr, }, - [TASK_BUZZ] = { .stack = init_stack[2], .entry_addr = nullptr, }, - [TASK_FIZZBUZZ] = { .stack = init_stack[3], .entry_addr = nullptr, }, + [TASK_INIT] = { .stack = stack[0], .entry_addr = nullptr, }, + [TASK_FIZZ] = { .stack = stack[1], .entry_addr = nullptr, }, + [TASK_BUZZ] = { .stack = stack[2], .entry_addr = nullptr, }, + [TASK_FIZZBUZZ] = { .stack = stack[3], .entry_addr = nullptr, }, }; /* @@ -24,7 +27,7 @@ __noreturn __kernel void start_kernel(void *dtb) // Extract information from the DTB blob. struct initrd_addr addr = find_dt_initrd_addr(dtb); - extract_initrd((unsigned char *)addr.start, addr.end - addr.start); + extract_initrd((unsigned char *)addr.start, addr.end - addr.start, tasks); // At this point everything has already been handled: setup the interrupt // vector and enable the timer to start ticking and scheduling the three -- cgit v1.2.3