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/panic.o \
kern/libkern/memory.o \ kern/libkern/memory.o \
kern/libkern/spinlock.o \ kern/libkern/spinlock.o \
kern/libkern/mini-printf.o kern/libkern/mini-printf.o \
kern/libkern/stdio.o
kern/kernel.elf: $(KERNEL_OBJ) kern/kernel.elf: $(KERNEL_OBJ)
@echo LD $@ @echo LD $@

View file

@ -4,7 +4,3 @@
void uart_putc(char c) { void uart_putc(char c) {
*UART_BASE = 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 */ /** Send a single character to the UART device */
void uart_putc(char c); void uart_putc(char c);
/** Send a **NULL TERMINATED** string to the UART device */
void uart_puts(const char *s);
#endif #endif

View file

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