src/x86/pio.bend checks
raw source on the hub · import 0x7fea7bfac3f0390a60760e0485feacff/src/x86/pio.bend as Pio
6 imports
import Base import ../lib/u64.bend as U import ../vmm/abi.bend as V import ../vmm/layout.bend as L import ../vmm/machine.bend as M import ./acpi.bend as A
Types
type Uart source · line 26 · raw
Data
The 16550A: interrupt enable, line control, modem control, scratch, the divisor latch, FIFO control, the transmit-empty interrupt pending, the receive FIFO (at most 64 bytes), and the interrupt line's level.
Uart@ier:U32 -> @lcr:U32 -> @mcr:U32 -> @scr:U32 -> @dll:U32 -> @dlm:U32 -> @fcr:U32 -> @thri:Bool -> @rx:List<&2, U32> -> @line:Bool -> Uart
type Pio source · line 30 · raw
Data
The port machine: the UART, the CMOS index register.
Pio@uart:Uart -> @cmos:U32 -> Pio
type XStep source · line 34 · raw
Data
The machine after a port access, and what the vCPU does next.
XStep@pio:Pio -> @control:0x7fea7bfac3f0390a60760e0485feacff/src/vmm/machine.Control -> XStep
type URead source · line 101 · raw
Data
A read of register off (0..7): the value, and the UART after it.
URead@uart:Uart -> @value:U32 -> URead
type UWrite source · line 124 · raw
Data
What a write does: the UART after it, and the byte transmitted (THR) when there is one.
UWrite@uart:Uart -> @out:List<&2, U32> -> UWrite
type Date source · line 176 · raw
Data
The CMOS clock from the host's wall clock (seconds since the epoch, the low 32 bits: good to 2106), in BCD 24-hour mode (status B 2: x86 Linux reads the clock as BCD whatever status B says, RTC_ALWAYS_BCD); each date and time register below holds its value in BCD: 0 seconds, 2 minutes, 4 hours, 6 the day of the week (1 Sunday), 7 the day, 8 the month, 9 the year in the century, 50 (0x32) the century, 10 status A (38: no update in progress), 11 status B (2), 13 status D (128: the battery is good); every other register reads 0. Civil dates from days since 1970-01-01 (H. Hinnant's days_from_civil inverse, all in unsigned arithmetic).
Date@year:U32 -> @month:U32 -> @day:U32 -> Date
Definitions
def Uart.new source · line 37 · raw
Uart
def Pio.new source · line 40 · raw
Pio
def Uart.fifo source · line 43 · raw
Nat
def Uart.base source · line 46 · raw
U32
def Pio.bit source · line 50 · raw
@+v:U32 -> @+b:U32 -> Bool
Bit helpers.
def Uart.iid source · line 55 · raw
@u:Uart -> U32
The interrupt identification: 0xC0 when the FIFOs are on, then received data (4) before transmit empty (2); 1 when nothing is pending.
def Uart.level source · line 64 · raw
@+u:Uart -> Bool
The line: an interrupt pending and OUT2 (MCR bit 3) set, as on a PC.
def Uart.with_line source · line 69 · raw
@u:Uart -> @+l:Bool -> Uart
def Uart.line source · line 74 · raw
@u:Uart -> Bool
def Pio.irq_if source · line 79 · raw
@-R:Type -> @change:Bool -> @level:Bool -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, Unit>
def Uart.sync source · line 87 · raw
@-R:Type -> @+u:Uart -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, Uart>
Sets the line to the UART's level, raising or lowering it when it changed.
def Uart.msr source · line 96 · raw
@+mcr:U32 -> U32
The modem status: in loopback (MCR bit 4) the outputs fed back (RTS to CTS, DTR to DSR, OUT1 to RI, OUT2 to DCD), else carrier, ready, clear to send (0xB0).
def Uart.read source · line 104 · raw
@u:Uart -> @+off:U32 -> URead
def Uart.push source · line 127 · raw
@+rx:List<&2, U32> -> @+bs:List<&2, U32> -> List<&2, U32>
def Uart.write source · line 130 · raw
@u:Uart -> @+off:U32 -> @+v:U32 -> UWrite
def Uart.input source · line 156 · raw
@u:Uart -> @+bs:List<&2, U32> -> Uart
Console input: queued in the receive FIFO (what does not fit is dropped, as by the hardware).
def Uart.room source · line 161 · raw
@u:Uart -> Nat
def Cmos.date source · line 179 · raw
@+days:U32 -> Date
def Cmos.bcd source · line 192 · raw
@+v:U32 -> U32
Two decimal digits as BCD.
def Cmos.reg.at source · line 195 · raw
@+idx:U32 -> @+days:U32 -> @+tod:U32 -> @date:Date -> U32
def Cmos.reg source · line 210 · raw
@+idx:U32 -> @+secs:U32 -> U32
def Pio.ones source · line 217 · raw
@+size:U32 -> U32
The value of an access of size bytes (1, 2 or 4) with no device: all ones.
def Pio.in_uart source · line 220 · raw
@+port:U32 -> Bool
def Pio.answer source · line 224 · raw
@-R:Type -> @+v:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, Unit>
A read answers in RAX (VmSetReg 0; KVM moves it to the IN's destination).
def Pio.run source · line 227 · raw
@-R:Type -> @+p:Pio -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.stop source · line 230 · raw
@-R:Type -> @+p:Pio -> @+code:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.read.uart.fin source · line 235 · raw
@-R:Type -> @r:URead -> @+cmos:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.read.uart source · line 243 · raw
@-R:Type -> @+u:Uart -> @+cmos:U32 -> @+off:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.read.cmos source · line 246 · raw
@-R:Type -> @+p:Pio -> @+idx:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.read source · line 253 · raw
@-R:Type -> @p:Pio -> @+port:U32 -> @+size:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
IN of size bytes from port.
def Pio.console source · line 262 · raw
@-R:Type -> @+out:List<&2, U32> -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, Unit>
def Pio.write.uart.fin source · line 265 · raw
@-R:Type -> @w:UWrite -> @+cmos:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.write.uart source · line 273 · raw
@-R:Type -> @+u:Uart -> @+cmos:U32 -> @+off:U32 -> @+v:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
def Pio.sleeps source · line 277 · raw
@+v:U32 -> Bool
Power off: SLP_EN with SLP_TYP 5 (\_S5) in the sleep control register.
def Pio.resets source · line 280 · raw
@+port:U32 -> @+v:U32 -> Bool
def Pio.write source · line 286 · raw
@-R:Type -> @p:Pio -> @+port:U32 -> @+size:U32 -> @+v:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
OUT of size bytes of v to port.
def Pio.io source · line 295 · raw
@-R:Type -> @p:Pio -> @write:Bool -> @+port:U32 -> @+size:U32 -> @+v:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, XStep>
One port access: a write of v, or a read answered in RAX.
def Pio.on_io source · line 303 · raw
@p:Pio -> @write:Bool -> @port:U32 -> @size:U32 -> @v:U32 -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Vm<XStep>
The port machine's program for one access (an exit).
def Pio.input.go source · line 307 · raw
@-R:Type -> @p:Pio -> @+bs:List<&2, U32> -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Op<R, Pio>
Console input: into the receive FIFO, then the line.
def Pio.input source · line 314 · raw
@p:Pio -> @bs:List<&2, U32> -> 0x7fea7bfac3f0390a60760e0485feacff/src/vmm/abi.Vm<Pio>
def Pio.room source · line 317 · raw
@p:Pio -> Nat
def Pio.saved source · line 328 · raw
@p:Pio -> List<&2, U32>
The port machine in a snapshot (X86.vm_plan's kind 25): the UART's interrupt enable, line and modem control, scratch, divisor, FIFO control, the CMOS index, then the receive FIFO. Not kept: whether a transmit-empty interrupt is pending (a restore raises one: the register is empty, and a driver that was waiting for it goes on) and the line's level (Pio.input syncs it).
def Pio.restored source · line 333 · raw
@ws:List<&2, U32> -> Pio
def Pio.same source · line 340 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> Bool
def Uart.restored_uart source · line 349 · raw
@p:Pio -> Uart