Skip to main content

Module uart

Module uart 

Source
Expand description

s9vm : 16550A-compatible UART device (pure model, COM1).

The guest sees the eight-byte register window of a COM1 16550A at BASE_PORT. The kernel bridges the model onto the host: bytes written to the transmit holding register are collected by Uart::drain_output (the kernel logs them), and host input is queued with Uart::push_input for the guest to read from the receive buffer. Uart::irq_asserted drives the UART interrupt line IRQ_LINE.

The model implements the register semantics a booting guest relies on: divisor latch access through LCR.DLAB, the IIR priority chain (line status, receive data, transmitter empty, modem status), IER masking, loopback mode through MCR, scratch register and the LSR/MSR status bits. It is transport-agnostic and host-tested; the only extra dependency is the alloc vector holding output and input bytes.

Re-exportsยง

use alloc::collections::VecDeque; ๐Ÿ”’
use alloc::vec::Vec; ๐Ÿ”’

Modulesยง

ier
Interrupt enable bits in reg::IER.
iir
Interrupt identification values returned by reg::IIR_FCR reads.
lsr
Bits of the line status register.
mcr
Bits of the modem control register.
msr
Bits of the modem status register.
reg
Register offsets, relative to BASE_PORT.

Structsยง

Uart
Software model of the COM1 16550A UART.

Constantsยง

BASE_PORT
Base I/O port of COM1.
INPUT_CAPACITY
Receive FIFO capacity (bytes pushed by the kernel but not yet read).
IRQ_LINE
IRQ line driven by the COM1 UART.
LSR_IDLE ๐Ÿ”’
Value of reg::LSR at reset: transmitter holding register empty and transmitter empty. The data-ready bit depends on the receive FIFO.
MSR_IDLE ๐Ÿ”’
Value of reg::MSR at reset: CTS, DSR and DCD asserted (the host is considered connected), no delta bit pending.
PORT_COUNT
Number of consecutive I/O ports used by the UART.

Functionsยง

handles_port
True when port belongs to the COM1 register window.