minos/common/console.c
auser 8c44d12357 minos M1: minimal multi-arch kernel (x86 + RISC-V + ARM/Zynq)
Boots under QEMU on all three ISAs from one clang build:
- shared C core (kmain, console) calls a small per-arch contract (arch.h)
- per-arch asm entry + trap/vector table + UART driver
- parallel Makefile (make -j), 'make run-<arch>', 'make sizes'
M1 = boot, UART up, trap vector installed, banner from kmain().
2026-09-25 00:41:24 +03:00

27 lines
594 B
C

/* console.c — portable text output built on arch_uart_putc().
* No libc: we implement the tiny bit of formatting we need. */
#include "arch.h"
#include "console.h"
void putc(char c)
{
if (c == '\n')
arch_uart_putc('\r'); /* CRLF for dumb terminals */
arch_uart_putc(c);
}
void puts(const char *s)
{
while (*s)
putc(*s++);
}
/* Minimal unsigned hex printer — enough to show addresses/registers. */
void puthex(unsigned long v)
{
static const char d[] = "0123456789abcdef";
int i;
puts("0x");
for (i = (int)(sizeof(v) * 2) - 1; i >= 0; i--)
putc(d[(v >> (i * 4)) & 0xf]);
}