aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/head.S17
-rw-r--r--kernel/main.c7
-rw-r--r--kernel/printk.c2
3 files changed, 9 insertions, 17 deletions
diff --git a/kernel/head.S b/kernel/head.S
index 638e5e8..45e66a8 100644
--- a/kernel/head.S
+++ b/kernel/head.S
@@ -71,11 +71,6 @@ _start_kernel:
amoadd.w a3, a2, (a3)
bnez a3, .Lhart_wait
- // Store the hart id as we will tamper with the 'a0' register later when
- // performing the call to `start_kernel`.
- la a3, hart_id
- sw a0, 0(a3)
-
// Explicitely nullify the 'gp' and 'sscratch' registers, as they are a bit
// special but we are not using them. For the rest of the registers, we
// explicitely do not care to reset them.
@@ -90,12 +85,12 @@ _start_kernel:
// Point 'sp' the our global stack. See fbos/sched.h for more details.
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`
- // register, so let's move it now to `a0`.
- mv a0, a1
-
- // Start the kernel.
+ // Start the kernel. Notice that both 'a0' and 'a1' have been left
+ // untouched. This is no coincidence as the values as passed from the
+ // bootloader for both these two registers will be passed down to the kernel
+ // as is. As with the Linux kernel these two registers contain:
+ // - a0: boot hart id.
+ // - a1: pointer to the flattened device tree blob.
tail start_kernel
// We really shouldn't reach this point. If so, at least mask again all
diff --git a/kernel/main.c b/kernel/main.c
index 41619d6..3ed8551 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -5,11 +5,8 @@
#include <fbos/string.h>
#include <fbos/dt.h>
-/*
- * Data related to harts and set by kernel/head.S. Defined in fbos/init.h.
- */
+// Defined in fbos/init.h.
atomic32_t hart_lottery __section(".sdata");
-uint32_t hart_id;
// Defined in fbos/sched.h.
uint64_t stack[STACK_SIZE / sizeof(uint64_t)];
@@ -30,7 +27,7 @@ struct dt_info info = {
.initrd_end = 0,
};
-__noreturn __kernel void start_kernel(void *dtb)
+__noreturn __kernel void start_kernel(uint64_t hart_id, void *dtb)
{
printk("Welcome to FizzBuzz OS!\n");
diff --git a/kernel/printk.c b/kernel/printk.c
index 1cc68db..b67eea7 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -13,7 +13,7 @@ __kernel __noreturn void die(const char *const message)
;
}
-__kernel void print_digit(uint32_t digit)
+__kernel void print_digit(uint64_t digit)
{
char buffer[2];