src/virtio/rng.bend checks
raw source on the hub · import 0xab9fd5982a23be6a9b632b364492ce07/src/virtio/rng.bend as Rng
4 imports
import Base import ../lib/u64.bend as U import ../vmm/abi.bend as V import ./queue.bend as Q
Definitions
def Rng.room source · line 11 · raw
@ds:List<&2, 0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Desc> -> U32
The total length of a chain's writable descriptors.
def Rng.max source · line 20 · raw
U32
The most entropy one chain gets: a guest's buffer lengths must not size a host allocation (a short fill is legal; the used length reports it).
def Rng.want source · line 25 · raw
@ds:List<&2, 0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Desc> -> U32
The entropy to ask the host for: the chain's writable room, at most Rng.max() (summed over the bounded pieces, so long lengths cannot wrap).
def Rng.serve source · line 29 · raw
@-R:Type -> @q:0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq -> @c:0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Chain -> 0xab9fd5982a23be6a9b632b364492ce07/src/vmm/abi.Op<R, 0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq>
Fills one chain's writable descriptors with entropy and pushes it used.
def Rng.step source · line 39 · raw
@-R:Type -> @r:Pair(0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq, Maybe<&2, 0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Chain>) -> @used:Bool -> @k:(@_:0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq -> 0xab9fd5982a23be6a9b632b364492ce07/src/vmm/abi.Op<R, Pair(0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq, Bool)>) -> 0xab9fd5982a23be6a9b632b364492ce07/src/vmm/abi.Op<R, Pair(0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq, Bool)>
After a pop: stops on an empty queue, else serves the chain and continues with k.
def Rng.go source · line 49 · raw
@fuel:Nat -> @-R:Type -> @q:0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq -> @used:Bool -> 0xab9fd5982a23be6a9b632b364492ce07/src/vmm/abi.Op<R, Pair(0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq, Bool)>
Pops and serves chains, at most fuel of them; used tells whether any was.
def Rng.process source · line 62 · raw
@-R:Type -> @q:0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq -> 0xab9fd5982a23be6a9b632b364492ce07/src/vmm/abi.Op<R, Pair(0xab9fd5982a23be6a9b632b364492ce07/src/virtio/queue.Vq, Bool)>
Serves every available chain of the request queue: fills its writable descriptors with Op.random bytes (as many as they hold), pushes it used with that length. At most num chains per call. Answers the queue and whether any chain was used.