src/virtio/device.bend checks
raw source on the hub · import 0x4c3545aa4609661612fe35675effd0c0/src/virtio/device.bend as Device
15 imports
import Base import ../lib/u64.bend as U import ../lib/bytes.bend as B import ../vmm/abi.bend as V import ./mmio.bend as M import ./queue.bend as Q import ./rng.bend as Rng import ./blk.bend as Blk import ../disk/store.bend as St import ./console.bend as Con import ./net.bend as N import ../fs/p9.bend as P import ./vsock.bend as Vs import ./input.bend as In import ./lan.bend as Ln
Types
type DevKind source · line 63 · raw
Data
RngKindDevKind
BlkKind@disk:U32 -> @sectors:0x4c3545aa4609661612fe35675effd0c0/src/lib/u64.U64 -> DevKind
BlkRoKind@disk:U32 -> @sectors:0x4c3545aa4609661612fe35675effd0c0/src/lib/u64.U64 -> DevKind
BlkStoreKind@store:0x4c3545aa4609661612fe35675effd0c0/src/disk/store.Store -> @sectors:0x4c3545aa4609661612fe35675effd0c0/src/lib/u64.U64 -> @ro:Bool -> DevKind
A virtio-blk over a store (a qcow2 image over its backing files), read-only when ro.
ConsoleKindDevKind
NetKind@mac:List<&2, U32> -> DevKind
P9Kind@share:U32 -> @tag:String -> DevKind
VsockKind@cid:0x4c3545aa4609661612fe35675effd0c0/src/lib/u64.U64 -> DevKind
InputKind@tablet:Bool -> DevKind
LanKind@mac:List<&2, U32> -> @ip:U32 -> @prefix:U32 -> DevKind
virtio-net on a host LAN (src/virtio/lan.bend): its MAC, and the address its DHCP answers give (ip 0: none) with its prefix length.
type DevState source · line 80 · raw
Data
The per-kind state of a device.
NoStateDevState
ConState@input:List<&2, U32> -> DevState
Console input not yet delivered.
NetState@frames:List<&2, List<&2, U32>> -> DevState
Frames for the guest not yet delivered, oldest first.
P9Dev@p9:0x4c3545aa4609661612fe35675effd0c0/src/fs/p9.P9State -> DevState
VsState@vs:0x4c3545aa4609661612fe35675effd0c0/src/virtio/vsock.Vsock -> DevState
InDev@input:0x4c3545aa4609661612fe35675effd0c0/src/virtio/input.InputState -> DevState
LanDev@lan:0x4c3545aa4609661612fe35675effd0c0/src/virtio/lan.Lan -> DevState
type Dev source · line 91 · raw
Data
Dev@kind:DevKind -> @mmio:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @queues:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @state:DevState -> Dev
type DevOut source · line 96 · raw
Data
The device after a write, the bytes the guest wrote to hvc0 and the frames the guest transmitted, in order.
DevOut@dev:Dev -> @console:List<&2, U32> -> @frames:List<&2, List<&2, U32>> -> @vsock:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.VsockCmd> -> DevOut
type Pass source · line 292 · raw
Data
What a pass on one queue did: the queue, the new state, the bytes for the host console, the frames for the host, and whether it used any chain.
Pass@q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> @state:DevState -> @console:List<&2, U32> -> @frames:List<&2, List<&2, U32>> -> @vsock:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.VsockCmd> -> @used:Bool -> Pass
Definitions
def Dev.features source · line 100 · raw
0x4c3545aa4609661612fe35675effd0c0/src/lib/u64.U64
VIRTIO_F_VERSION_1: bit 32, so bit 0 of the high word (the rng features).
def Dev.max_frames source · line 104 · raw
Nat
The most frames a net device keeps for the guest.
def Dev.mmio source · line 108 · raw
@kind:DevKind -> 0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio
The transport of a fresh device of the given kind.
def Dev.state source · line 132 · raw
@kind:DevKind -> DevState
The state of a fresh device of the given kind.
def Dev.new source · line 155 · raw
@kind:DevKind -> Dev
def Dev.read.fin source · line 159 · raw
@k:DevKind -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @r:Pair(0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio, U32) -> Pair(Dev, U32)
def Dev.read source · line 164 · raw
@d:Dev -> @off:U32 -> @size:U32 -> Pair(Dev, U32)
def Dev.build source · line 170 · raw
@cs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.QueueCfg> -> List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq>
One Q.Vq per queue configuration, in order.
def Dev.cfgs source · line 177 · raw
@m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.QueueCfg>
def Dev.qget source · line 183 · raw
@qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @+i:U32 -> @+sel:U32 -> Maybe<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq>
Queue sel of the list; i counts the list position.
def Dev.qput source · line 191 · raw
@qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @+i:U32 -> @+sel:U32 -> @+q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq>
Replaces queue sel of the list by q; i counts the list position.
def Dev.raise_if source · line 199 · raw
@used:Bool -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> 0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio
Raises the used-buffer interrupt (status bit 1) when used.
def Dev.process source · line 209 · raw
@-R:Type -> @k:DevKind -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pair(0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq, Bool)>
Runs the process of a kind without state on a queue. The kinds with state (console, net, 9p) run their passes in Dev.pass instead; here they use no chain.
def Dev.input_of source · line 233 · raw
@st:DevState -> List<&2, U32>
The pending console input of a state (none for other kinds).
def Dev.frames_of source · line 251 · raw
@st:DevState -> List<&2, List<&2, U32>>
The pending frames of a state (none for other kinds).
def Dev.p9_of source · line 269 · raw
@st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/fs/p9.P9State
The 9p server state of a state (a fresh one for other kinds).
def Dev.cap source · line 287 · raw
@+fs:List<&2, List<&2, U32>> -> List<&2, List<&2, U32>>
The last Dev.max_frames() frames.
def Dev.pass.plain source · line 295 · raw
@st:DevState -> @r:Pair(0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq, Bool) -> Pass
def Dev.pass.con_tx source · line 300 · raw
@st:DevState -> @r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/console.ConTx -> Pass
def Dev.pass.con_rx source · line 305 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/console.ConRx -> Pass
def Dev.pass.net_tx source · line 310 · raw
@st:DevState -> @r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/net.NetTx -> Pass
def Dev.pass.net_rx source · line 315 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/net.NetRx -> Pass
def Dev.pass.p9 source · line 320 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/fs/p9.P9Pass -> Pass
def Dev.pass.con source · line 326 · raw
@-R:Type -> @tx:Bool -> @st:DevState -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
The console's pass: transmitq0 (tx) or receiveq0.
def Dev.pass.net source · line 338 · raw
@-R:Type -> @tx:Bool -> @st:DevState -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
The net device's pass: transmitq1 (tx) or receiveq1.
def Dev.vs_of source · line 350 · raw
@st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/virtio/vsock.Vsock
The vsock state of a state (a fresh one, CID 3, for other kinds).
def Dev.pass.vs_tx source · line 367 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/vsock.VsTx -> Pass
def Dev.pass.vs_rx source · line 372 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/vsock.VsRx -> Pass
def Dev.pass.vsock source · line 379 · raw
@-R:Type -> @tx:Bool -> @rx:Bool -> @st:DevState -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
The vsock device's pass: tx (queue 1), rx (queue 0); the event queue (2) is never used.
def Dev.in_of source · line 393 · raw
@st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/virtio/input.InputState
The input state of a state (a fresh one for other kinds).
def Dev.pass.in_rx source · line 400 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/input.InRx -> Pass
def Dev.pass.in_status source · line 405 · raw
@st:DevState -> @r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/console.ConTx -> Pass
def Dev.pass.input source · line 412 · raw
@-R:Type -> @ev:Bool -> @st:DevState -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
The input device's pass: eventq (ev) gets the pending events; statusq chains are taken and dropped.
def Dev.lan_of source · line 424 · raw
@st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/virtio/lan.Lan
The LAN state of a state (a blank one for other kinds).
def Dev.pass.lan_tx source · line 431 · raw
@r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/lan.LanTx -> Pass
def Dev.pass.lan_rx source · line 436 · raw
@l:0x4c3545aa4609661612fe35675effd0c0/src/virtio/lan.Lan -> @r:0x4c3545aa4609661612fe35675effd0c0/src/virtio/lan.LanRxOut -> Pass
def Dev.pass.lan source · line 442 · raw
@-R:Type -> @tx:Bool -> @st:DevState -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
The LAN device's pass: transmit (queue 1) or receive (queue 0).
def Dev.pass source · line 455 · raw
@-R:Type -> @k:DevKind -> @st:DevState -> @+sel:U32 -> @q:0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Pass>
Runs the kind's pass on queue sel (q).
def Dev.out source · line 489 · raw
@d:Dev -> DevOut
A device with nothing for the host.
def Dev.notify.fin source · line 492 · raw
@k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @sel:U32 -> @r:Pass -> DevOut
def Dev.notify source · line 498 · raw
@-R:Type -> @mq:Maybe<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @+k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @+sel:U32 -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
Runs the pass on queue sel when it exists.
def DevOut.dev source · line 508 · raw
@o:DevOut -> Dev
Acts on the event of a transport write.
def Dev.flush source · line 513 · raw
@-R:Type -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
def Dev.flush.out source · line 520 · raw
@-R:Type -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
The rx pass (Dev.flush) with its vsock commands kept (VsRelease).
def DevOut.join source · line 524 · raw
@bs:List<&2, U32> -> @fs:List<&2, List<&2, U32>> -> @vc:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.VsockCmd> -> @o:DevOut -> DevOut
def Dev.after.vsock source · line 529 · raw
@-R:Type -> @again:Bool -> @o:DevOut -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
def Dev.is_vsock source · line 540 · raw
@k:DevKind -> Bool
def Dev.is_lan source · line 547 · raw
@k:DevKind -> Bool
def Dev.on_event source · line 554 · raw
@-R:Type -> @ev:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.MmioEvent -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
def Dev.write.fin source · line 570 · raw
@-R:Type -> @k:DevKind -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @r:Pair(0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.MmioEvent) -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
def Dev.is_input source · line 575 · raw
@k:DevKind -> Bool
def Dev.tablet_of source · line 582 · raw
@k:DevKind -> Bool
def Dev.write.go source · line 591 · raw
@-R:Type -> @select:Bool -> @+k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @+off:U32 -> @v:U32 -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
A write to an input device's select or subsel byte rebuilds its config space; other writes go to the transport.
def Dev.write source · line 599 · raw
@-R:Type -> @d:Dev -> @+off:U32 -> @v:U32 -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
def Dev.is_console source · line 606 · raw
@k:DevKind -> Bool
Delivers a device's pending input or frames into its queue 0, when it exists.
def Dev.is_net source · line 629 · raw
@k:DevKind -> Bool
def Dev.input.go source · line 652 · raw
@-R:Type -> @console:Bool -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @bytes:List<&2, U32> -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
def Dev.input source · line 662 · raw
@-R:Type -> @d:Dev -> @bytes:List<&2, U32> -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
Bytes typed on the host console: a console device appends them to its pending input and delivers what fits into receiveq0 (raising interrupt status bit 1 when it used a chain). Other kinds are unchanged.
def Dev.deliver.go source · line 667 · raw
@-R:Type -> @net:Bool -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @frames:List<&2, List<&2, U32>> -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
def Dev.deliver source · line 678 · raw
@-R:Type -> @d:Dev -> @frames:List<&2, List<&2, U32>> -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
Frames for the guest: a net device appends them to its pending frames (keeping the last Dev.max_frames()) and delivers what it can into receiveq1 (raising interrupt status bit 1 when it used a chain). Other kinds are unchanged.
def Dev.net source · line 684 · raw
@d:Dev -> Bool
Whether the device is a net device.
def Dev.backlog source · line 690 · raw
@d:Dev -> U32
The number of frames a net device holds for the guest (0 for other kinds).
def Dev.vsock source · line 696 · raw
@d:Dev -> Bool
Whether the device is a vsock device.
def Dev.big.mmio source · line 701 · raw
@m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> Bool
def Dev.big source · line 708 · raw
@d:Dev -> Bool
Whether a net device's driver took GUEST_CSUM and GUEST_TSO4 (bits 1 and 7): it then receives TCP segments of up to 64 KiB as host frames.
def Dev.vsock_backlog source · line 714 · raw
@d:Dev -> U32
A vsock device's backlog (Vs.Vsock.backlog; 0 for other kinds).
def Dev.host_vsock.fin source · line 719 · raw
@-R:Type -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @o:0x4c3545aa4609661612fe35675effd0c0/src/virtio/vsock.VsOut -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
def Dev.host_vsock source · line 728 · raw
@-R:Type -> @d:Dev -> @ev:0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.VsockEvent -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, DevOut>
An event from the host's vsock sockets: through the protocol, then the packets it queued go into the rx queue. Other kinds are unchanged.
def Dev.irq source · line 735 · raw
@d:Dev -> Bool
After a vsock tx pass, the replies it queued go out through the rx queue. The interrupt line's level.
def Dev.hid.go source · line 740 · raw
@-R:Type -> @input:Bool -> @+k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @ev:0x4c3545aa4609661612fe35675effd0c0/src/virtio/input.Hid -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
def Dev.hid source · line 750 · raw
@-R:Type -> @d:Dev -> @ev:0x4c3545aa4609661612fe35675effd0c0/src/virtio/input.Hid -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
A keyboard or pointer report from the host: an input device queues its events (In.Input.push: the keyboard takes keys, the tablet moves and buttons) and delivers what fits into eventq. Other kinds are unchanged.
def Dev.lan_ready.go source · line 755 · raw
@-R:Type -> @lan:Bool -> @k:DevKind -> @m:0x4c3545aa4609661612fe35675effd0c0/src/virtio/mmio.VirtioMmio -> @qs:List<&2, 0x4c3545aa4609661612fe35675effd0c0/src/virtio/queue.Vq> -> @st:DevState -> @+len:U32 -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
def Dev.lan_ready source · line 765 · raw
@-R:Type -> @d:Dev -> @+len:U32 -> 0x4c3545aa4609661612fe35675effd0c0/src/vmm/abi.Op<R, Dev>
The host holds a frame of len bytes for the LAN NIC: a LAN device queues it and delivers what fits into its receive queue (raising interrupt status bit 1 when it used a chain). Other kinds are unchanged.
def Dev.forget_lan source · line 771 · raw
@d:Dev -> Dev
The LAN state of a device (forget_held after a restore).