From 39ef34d41e9676cf8df8c8034e3602bb307b9ca9 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sat, 16 Aug 2025 15:01:01 +0200 Subject: [PATCH] Restructure, use ispinlock --- start.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/start.c b/start.c index d9ca8ef..7f72faf 100644 --- a/start.c +++ b/start.c @@ -1,9 +1,9 @@ #include +#include #include #include #include #include -#include #include #include @@ -16,8 +16,8 @@ char stack0[4096 * NCPU] __attribute__((aligned(16))); /* Keep this here and sync on it until we have synchronized printf */ -struct Spinlock sl = {0}; -volatile int greeted = 0; +spinlock_t sl = {0}; +volatile int hold = 1; /* This is where entry.S drops us of. All cores land here */ void start() { @@ -29,24 +29,22 @@ void start() { // cpu (struct Cpu). write_tp(id); - acquire(&sl); - - if (!greeted) { - uart_puts("Hello Neptune!\n"); - greeted = 1; - } - - uart_puts("Hart number: "); - uart_putc(id + '0'); - uart_putc('\n'); - - release(&sl); - if (id == 0) { /* Here we will do a bunch of initialization steps */ kalloc_init(); + uart_puts("Hello Neptune!\n"); + spinlock_init(&sl); + hold = 0; } + while (hold); + + spin_lock(&sl); + uart_puts("Hart number: "); + uart_putc(id + '0'); + uart_putc('\n'); + spin_unlock(&sl); + // We should not arrive here, but if we do, hang in a while on wfi. while (1) __asm__ volatile("wfi"); // (Wait For Interrupt) }