commit - 85231712942b13d915c19f9d168624a0516a8824
commit + 2257f59c3fcad7f544c256ad2c936495981a99cd
blob - e39e7b4977c6690f473b25fc45c192c342f30807
blob + 3ce79dca00c2b66d52b410d3bf6fec769678db60
--- kernel/log/early_console.c
+++ kernel/log/early_console.c
#include <stdbool.h>
#include "early_console.h"
#include "log/serial.h"
+#include "sync/spinlock.h"
#define EARLY_CONSOLE_BUFFER_SIZE 16384
static size_t early_console_tail = 0;
static int early_console_wrapping = 0;
static bool early_console_serial_enabled = true; /* Disabled once console service ready */
+static spinlock_t early_console_lock = SPINLOCK_INIT;
void
early_console_write(const char *data, size_t len)
if (data == NULL || len == 0)
return;
+ /* Lock to prevent concurrent writes from corrupting output */
+ spinlock_lock(&early_console_lock);
+
/* Write to ring buffer */
for (size_t i = 0; i < len; i++) {
early_console_ring[early_console_head] = data[i];
/* Also write immediately to serial for real-time visibility (if still enabled) */
if (early_console_serial_enabled)
serial_write(data, len);
+
+ spinlock_unlock(&early_console_lock);
}
size_t