aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-03 07:41:45 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-03 07:41:45 +0100
commit58fcecc381be82992f718a6ef9bf7ddcd3bca369 (patch)
treedb3fedc5bc6ea2eef84ae9f8951a84a088d9721e
parent7b1b8ebb48174445083bc7fa336dc00619cbf126 (diff)
downloadfbos-58fcecc381be82992f718a6ef9bf7ddcd3bca369.tar.gz
fbos-58fcecc381be82992f718a6ef9bf7ddcd3bca369.zip
Simplify the constant on the size of the stack
At the beginning I carried over things from the Linux kernel just in case I would need them in the future. As this project is very much at a stage where I'm already happy with it, let's remove unneeded complexity. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rw-r--r--include/fbos/mm.h11
-rw-r--r--kernel/head.S2
-rw-r--r--kernel/main.c2
-rw-r--r--test/test_initrd.c2
4 files changed, 7 insertions, 10 deletions
diff --git a/include/fbos/mm.h b/include/fbos/mm.h
index e913fa7..017e28a 100644
--- a/include/fbos/mm.h
+++ b/include/fbos/mm.h
@@ -2,16 +2,13 @@
#define __FBOS_MM_H
/*
- * Page = 4KB.
+ * Page = 4KB. We don't actually use pagination, but this value is still useful
+ * when aligning in the linker file.
*/
#define PAGE_SIZE 0x1000
-/*
- * Initial size of the thread, which coincides with the size of the stack for a
- * given thread.
- */
-#define THREAD_SIZE_ORDER 2
-#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
+// Size of the stack as used by processes on this kernel.
+#define STACK_SIZE PAGE_SIZE
/*
* The code will be linked to start at the first page, which will have a given
diff --git a/kernel/head.S b/kernel/head.S
index 4390cc9..ac69967 100644
--- a/kernel/head.S
+++ b/kernel/head.S
@@ -100,7 +100,7 @@ _start_kernel:
la tp, tasks
// Point 'sp' the our general stack.
- la sp, stack + THREAD_SIZE
+ la sp, stack + STACK_SIZE
// The `start_kernel` function requires an argument to be passed, which is
// the pointer to the `fdt` blob. The bootloader puts this on the `a1`
diff --git a/kernel/main.c b/kernel/main.c
index 3d2b524..5a11816 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -12,7 +12,7 @@
// memory protection of any kind, it's not like separating stacks for each
// process and kernel space would make much of a difference. Hence, let's keep
// it simple and have the same stack everwhere.
-uint64_t stack[THREAD_SIZE / sizeof(uint64_t)];
+uint64_t stack[STACK_SIZE / sizeof(uint64_t)];
// Initialize the list of structs by providing a fixed stack address and empty
// values everywhere else.
diff --git a/test/test_initrd.c b/test/test_initrd.c
index 3d07b67..fb5197b 100644
--- a/test/test_initrd.c
+++ b/test/test_initrd.c
@@ -6,7 +6,7 @@
#include <fbos/sched.h>
#include <fbos/mm.h>
-unsigned long stack[THREAD_SIZE / sizeof(unsigned long)];
+unsigned long stack[STACK_SIZE / sizeof(unsigned long)];
struct task_struct tasks[4] = {
[TASK_INIT] = { .stack = stack, .entry_addr = NULL, },