Skip to content

BlockDevice

Andrew Zonenberg edited this page Apr 29, 2017 · 5 revisions

BlockDevice device class

A BlockDevice is a node which stores data in fixed-size chunks. Nodes must read/write one or more chunks with each transaction.

Not all block devices support both reading and writing, for example a ROM is a read-only block device.

Many (but not necessarily all) BlockDevice nodes implement the ResourceManager interface.

Some BlockDevice nodes are backed by memory or storage, while others are backed by I/O (for example, a network controller). Reading and writing a memory/storage device is idempotent. In other words, two consecutive reads of the same address without a write between them will return the same data. Two consecutive writes of the same data to the same address are indistinguishable from one. With an I/O device, on the other hand, two consecutive reads will read different data from the incoming buffer and two consecutive writes will send the message twice.

Some BlockDevice nodes are backed by non-volatile memory, in which case the memory state of the device is preserved across power cycles. If the non-volatile bit is not set, the contents of memory after a power cycle are implementation defined and potentially unpredictable. (Implementers of the BlockDevice interface are strongly encouraged, but not required, to clear volatile memory to a well-defined state at power-up.)

BLOCKDEV_GETINFO (RPC call 0x04)

Gets information about a block device.

Call:

  • All fields not specified. Implementation-defined values are allowed for querying additional properties of the device, however 0x00 must return the base metadata described below.

Return success:

  • d0[19]: TRUE if the device is backed by memory/storage, FALSE if an I/O interface
  • d0[18]: TRUE if the device is nonvolatile, FALSE if volatile. Always FALSE if device is not memory/storage.
  • d0[17]: TRUE if the device is readable, FALSE if write-only
  • d0[16]: TRUE if the device is writable, FALSE if read-only
  • d0[15:0]: Block size, in 32-bit words. This value is always between 1 (4 bytes) and 512 (2 KB).
  • d1/d2: Not specified. Implementation-defined metadata is allowed.

Return fail:

  • All fields not specified. Implementation-defined metadata is allowed.

DMA read:

Reads data from the device, if supported.

The read address must be aligned to the block size. The read length must be an integer multiple of the block size; nodes must properly handle multi-block reads (up to a maximum of the DMA network MTU) even if this means performing multiple consecutive operations at the physical layer.

DMA write:

Writes data to the device, if supported.

The write address must be aligned to the block size. The write length must be an integer multiple of the block size; nodes must properly handle multi-block write (up to a maximum of the DMA network MTU) even if this means performing multiple consecutive operations at the physical layer.

Note that some block devices may require an erase operation or similar preparatory command to write to a non-blank location.

Clone this wiki locally