/* * Copyright (c) 2024, Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: MIT * * RBOOTROM v1.0 * Modified by Rodrigo Arias Mallo * * This is a custom bootrom that prints some information to the UART when * starting, as well as when it hangs. It assumes the UART is at UART_BASE and * it will jump to DRAM_BASE to continue the boot. */ #define DRAM_BASE 0x80000000 #define UART_BASE 0x40001000 #define UART_BAUDRATE 115200 #define UART_CLOCK 50000000 #define UART_BDIV ((UART_CLOCK + 8 * UART_BAUDRATE) / (16 * UART_BAUDRATE)) #define UART_SHIFT 2 #define UART_RBR_OFFSET (0<> 8) & 0xff // Set divisor high byte sb t1, UART_DLM_OFFSET(t0) la t1, 0x03 // 8 bits, no parity, one stop bit sb t1, UART_LCR_OFFSET(t0) la t1, 0x01 // Enable FIFO sb t1, UART_FCR_OFFSET(t0) la t1, 0x00 // No modem control DTR RTS sb t1, UART_MCR_OFFSET(t0) /* TODO: Clear line status */ /* TODO: Read receive buffer */ la t1, 0x00 // Set scratchpad to 0 sb t1, UART_SCR_OFFSET(t0) ret print_hello: csrr t0, mhartid // Load HART ID into a0 beq t0, zero, 1f // Print message on HART 0 only ret 1: mv s0, ra // Save return address PUTC '\n' // Identify bootroom PUTC '\r' PUTC 'R' PUTC 'B' PUTC 'O' PUTC 'O' PUTC 'T' PUTC 'R' PUTC 'O' PUTC 'M' PUTC ' ' PUTC 'v' PUTC '1' PUTC '.' PUTC '0' PUTC ' ' PUTC ':' PUTC '^' PUTC ')' PUTC '\n' PUTC '\r' // Print jumping address PUTC 'J' PUTC 'u' PUTC 'm' PUTC 'p' PUTC 'i' PUTC 'n' PUTC 'g' PUTC ' ' PUTC 't' PUTC 'o' PUTC ' ' PUTC '0' // TODO: Compute from DRAM_BASE PUTC 'x' PUTC '8' PUTC '0' PUTC '0' PUTC '0' PUTC '_' PUTC '0' PUTC '0' PUTC '0' PUTC '0' PUTC '.' PUTC '.' PUTC '.' PUTC '\n' PUTC '\r' mv ra, s0 // Restore return address ret