C6-Reticulum-ASM/tests/uart/test_uart_rx_byte.py
DeFiDude 27e75f5281 uart_rx_byte + uart_rx_available: verified
Polled NS16550A receive primitives. uart_rx_byte spins on LSR.DR
(bit 0) until a byte arrives, then reads RBR. uart_rx_available
returns 1/0 of the same DR bit, non-blocking.

Both stay as the polled fall-back even after uart_isr lands; the
IRQ-driven ring-buffer path will become the production hot path
on the C6, the polled forms keep working on qemu-virt where qemu
does not model the PLIC for our IRQ wiring.
2026-05-01 22:54:33 -06:00

35 lines
1.1 KiB
Python

"""Tests for src/uart/uart_rx_byte.S — polled NS16550A read."""
from __future__ import annotations
import re
import pytest
from harness import build
@pytest.fixture(scope="module")
def artifacts() -> build.BuildArtifacts:
return build.build("qemu-virt")
def test_function_exists(artifacts: build.BuildArtifacts) -> None:
assert build.symbol_address(artifacts.elf, "uart_rx_byte") > 0
def test_loads_uart0_base(artifacts: build.BuildArtifacts) -> None:
body = build.objdump_disassemble(artifacts.elf, symbol="uart_rx_byte")
assert re.search(r"\blui\b\s+t0,\s*0x10000\b", body), body
def test_polls_dr_bit(artifacts: build.BuildArtifacts) -> None:
body = build.objdump_disassemble(artifacts.elf, symbol="uart_rx_byte")
assert re.search(r"\blbu\b\s+t1,\s*5\(t0\)", body), body
assert re.search(r"\bandi\b\s+t1,\s*t1,\s*1\b", body), body
assert re.search(r"\bbeqz\b\s+t1", body), body
def test_reads_from_rbr_into_a0(artifacts: build.BuildArtifacts) -> None:
body = build.objdump_disassemble(artifacts.elf, symbol="uart_rx_byte")
assert re.search(r"\blbu\b\s+a0,\s*0\(t0\)", body), body