universalisos/kernel/arch/arm/uart.c
Fábio Coutada 173b2c3330 feat(kernel): add Stage 1 bare-metal hypervisor skeleton for QEMU ARM virt
- Add kernel/arch/arm/boot.S with ARMv7 assembly entry, stack setup, BSS clear
- Add kernel/arch/arm/linker.ld for QEMU virt memory layout (load at 0x40000000)
- Add kernel/arch/arm/uart.c/uart.h for PL011 serial output
- Add kernel/kernel.c with kernel_main() idle loop
- Add kernel/Makefile for arm-none-eabi-gcc cross-compile and QEMU launch
- Add kernel/README.md with build/run instructions
- Ignore kernel build artifacts in .gitignore
2026-07-06 22:51:56 +01:00

32 lines
677 B
C

/*
* PL011 UART driver for QEMU ARM virt machine.
*
* The virt machine exposes a PL011 UART at 0x09000000.
*/
#include "uart.h"
#define UART0_BASE 0x09000000U
#define UART_DR (*(volatile unsigned int *)(UART0_BASE + 0x00U))
#define UART_FR (*(volatile unsigned int *)(UART0_BASE + 0x18U))
#define UART_FR_TXFF (1U << 5)
void uart_init(void)
{
/* QEMU initializes the UART for us. */
}
void uart_putc(char c)
{
while ((UART_FR & UART_FR_TXFF) != 0U) {
/* Wait until the transmit FIFO is not full. */
}
UART_DR = (unsigned int)c;
}
void uart_puts(const char *s)
{
while (*s != '\0') {
uart_putc(*s++);
}
}