code wiki / _hdl_build / rv64im_min_uart.nx

rv64im_min_uart.nx

buildroot/runtime/_hdl_build/rv64im_min_uart.nx

8708 B218 linesdepth 3pulls 3 transitivereach 45 importersview sourcekind librarytopic rv64im
docsdependenciesstructsconstsfunctions

about

rv64im_min_uart.nx -- 16550-compatible UART MMIO device. The kernel's only observable output channel. Without this, no "[m0-mcs-live]" marker prints, no bench output reaches the host, nothing about the kernel's run is visible. Tier A FPGA bring-up exit criterion #2 from rv64im_min_target_spec.md depends on this module producing the QEMU-reference selftest output. Tier A scope: TX-only, polled (no RX, no FIFO, no interrupts). Kernel never reads stdin and uses busy-wait on LSR.THRE between bytes (uart.nx:38-41); the kernel's MIE-masking-for-atomicity pattern still works because nothing else generates interrupts during a write. Memory map (matches QEMU virt machine; kernel hardcodes 0x10000000): 0x10000000 THR (offset 0) TX holding register; 8-bit write 0x10000001..4 unused; reads return 0 0x10000005 LSR (offset 5) Line status; bit 5 = THRE 0x10000006.. reads return 0 LSR bit semantics (subset relevant to kernel): bit 0: DR (data ready -- not used, RX absent) bit 5: THRE (TX holding empty -- always 1 in Tier A; no FIFO) bit 6: TEMT (TX empty -- always 1; alias of THRE for this device) Status: SEED. 2026-05-26. Register storage + TX byte sink (host stdout for simulator; real UART line for FPGA bitstream).

dependencies 2 imports · 35 importers

nx_syscalls.nx nishi_hdl_primitives.nx rv64im_min_uart.nx _gpu_run.nx _nvme_diag.nx nx_bootcap.nx nx_emu_bench.nx nx_evo_isa_sov.nx nx_geneal_energy_sov.nx nx_isa_cf_sov.nx nx_isa_equiv_sov.nx nx_isa_loop_sov.nx nx_isa_run_sov.nx

diagram shows first 10 each side; +0 more imports, +25 more importers in the complete lists below.

imports: nx_syscalls.nxnishi_hdl_primitives.nx

imported by: _gpu_run.nx_nvme_diag.nxnx_bootcap.nxnx_emu_bench.nxnx_evo_isa_sov.nxnx_geneal_energy_sov.nxnx_isa_cf_sov.nxnx_isa_equiv_sov.nxnx_isa_loop_sov.nxnx_isa_run_sov.nxnx_isa_synth_sov.nxnx_nishios_window.nxnx_nxc_baremetal.nxnx_nxc_run.nxnx_rv64_amo_gate.nxnx_rv64_csr_trap_oracle.nxnx_rv64_fast_dev_gate.nxnx_rv64_fast_gate.nxnx_rv64_kernel_gate.nxnx_rv64_mmu_oracle.nxnx_rv64_qemu_fuzz.nxnx_rv64_qemu_oracle.nxnx_rv64_realc_gate.nxnx_rv64_run_bin.nxnx_rv64_sdeleg_oracle.nxnx_rv64_snapshot_gate.nxnx_rv64_timer_oracle.nxnx_rv64im_cpu_crosscheck.nxrv64im_min_cpu_crosscheck.nxrv64im_min_elf_loader.nxrv64im_min_gfx_gate.nxrv64im_min_hot_report.nxrv64im_min_kernel_boot_smoke.nxrv64im_min_sim.nxrv64im_min_sim_smoke.nx

structs

66struct NxUart
167struct NxUartPorts

consts

33const NX_UART_BASE: i64 = 0x10000000
34const NX_UART_OFFSET_THR: i64 = 0
35const NX_UART_OFFSET_LSR: i64 = 5
36const NX_UART_END: i64 = 0x10000008 // 8 bytes covers all registers
39const NX_UART_LSR_DR_BIT: i64 = 0x01 // bit 0: data ready
40const NX_UART_LSR_THRE_BIT: i64 = 0x20 // bit 5: TX holding empty
41const NX_UART_LSR_TEMT_BIT: i64 = 0x40 // bit 6: TX shift empty
45const NX_UART_LSR_TIER_A: i64 = 0x60 // 0b01100000
48const NX_UART_OK: i64 = 0
49const NX_UART_ADDR_OUT_OF_RANGE: i64 = 1
50const NX_UART_BAD_ALIGNMENT: i64 = 2 // 1-byte access required for THR/LSR
63const NX_UART_SLOT_TX_COUNT: i64 = 0
64const NX_UART_SLOT_N: i64 = 1
162const NX_UART_WIDTH_ADDR: i64 = 32
163const NX_UART_WIDTH_BYTE: i64 = 8
164const NX_UART_WIDTH_VERDICT: i64 = 4
165const NX_UART_WIDTH_TXD: i64 = 1 // serial line pin

functions

73func nx_uart_init(u: *NxUart, storage: *i64, tx_buf: *u8, tx_cap: i64) -> i64
85func nx_uart_addr_in_range(addr: i64) -> i64
98func nx_uart_read8(u: *NxUart, addr: i64, value_out: *i64) -> i64
124func nx_uart_write8(u: *NxUart, addr: i64, value: i64) -> i64
151func nx_uart_tx_count(u: *NxUart) -> i64
180func nx_uart_build(m: *NxHdlModule, ports: *NxUartPorts) -> i64