Convert from uart_puts to kprintf

This commit is contained in:
Imbus 2025-09-02 00:17:34 +02:00
parent 7018424278
commit a6ae43f583
4 changed files with 14 additions and 24 deletions

View file

@ -45,7 +45,8 @@ KERNEL_OBJ := \
kern/libkern/panic.o \
kern/libkern/memory.o \
kern/libkern/spinlock.o \
kern/libkern/mini-printf.o
kern/libkern/mini-printf.o \
kern/libkern/stdio.o
kern/kernel.elf: $(KERNEL_OBJ)
@echo LD $@

View file

@ -4,7 +4,3 @@
void uart_putc(char c) {
*UART_BASE = c;
}
void uart_puts(const char *s) {
while (*s) uart_putc(*s++);
}

View file

@ -4,7 +4,4 @@
/** Send a single character to the UART device */
void uart_putc(char c);
/** Send a **NULL TERMINATED** string to the UART device */
void uart_puts(const char *s);
#endif

View file

@ -1,10 +1,12 @@
#include <config.h>
#include <kalloc.h>
#include <memory.h>
#include <panic.h>
#include <proc.h>
#include <riscv.h>
#include <spinlock.h>
#include <stdint.h>
#include <stdio.h>
#include <uart.h>
/**
@ -37,30 +39,24 @@ void start() {
if (id == 0) {
/* Here we will do a bunch of initialization steps */
kalloc_init();
uart_puts("Hello Neptune!\n");
spinlock_init(&sl);
kprintf("Hello Neptune!\n");
__sync_synchronize();
hold = 0;
} else {
while (hold);
}
// spin_lock(&sl);
//
// uart_puts("Hart number: ");
// uart_putc(id + '0');
// uart_putc('\n');
//
// spin_unlock(&sl);
if (id == 0) {
spin_lock(&sl);
uart_puts("Core count: ");
uart_putc(max_hart + '0');
uart_putc('\n');
if (max_hart == NCPU) {
uart_puts("All cores up!");
uart_putc('\n');
}
kprintf("Core count: %d\n", max_hart);
if (max_hart == NCPU)
kprintf("All cores up!\n");
else
PANIC("Some cores seem to have been enumerated incorrectly!\n");
spin_unlock(&sl);
}