⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module blk

Module blk 

Source
Expand description

Virtio-blk device driver

Implements a block device driver for virtio-blk PCI devices as described in the virtio specification, section 5.2. Supports read and write operations using the legacy (transitional) PCI transport.

§Virtio-blk request format

Each request is a three-descriptor chain:

  1. Header (device-readable): VirtioBlkReqHeader with request type + sector
  2. Data (device-readable for write, device-writable for read): sector data
  3. Status (device-writable): single byte result (0 = OK, 1 = IOERR, 2 = UNSUPP)

§QEMU usage

-drive file=disk.img,if=none,id=vd0,format=raw -device virtio-blk-pci,drive=vd0

Modules§

features
Virtio-blk feature bits (virtio spec 5.2.3)

Structs§

VirtioBlkDevice
Virtio block device.

Constants§

BLOCK_SIZE
Block size in bytes (standard sector)

Traits§

BlockDevice
Block device trait for generic block I/O operations.

Functions§

get_device
Get a reference to the global virtio-blk device, if initialized.
init
Probe PCI bus for virtio-blk devices and initialize the first one found.
is_initialized
Check if a virtio-blk device has been initialized.