Skip to main content

Module block

Module block 

Source
Expand description

A block device backed by host bytes.

OffsetRegisterBehaviour
0..3SECTORWhich sector the next load transfers. Word-sized.
3CONTROLWrite 1 to load the selected sector, 2 to store it.
4STATUS0 after a successful transfer, -1 if the sector is out of range.
5..windowThe staging buffer, one byte per tryte (D-04). Readable and writable.

The backing bytes come from a host file or an in-memory image. A load past the end of the image zeroes the window and sets STATUS to -1.

§Writing

A store copies the window back to the selected sector. The window holds trytes and the image holds bytes, so every tryte in the window must be in 0..=255; one that is not fails the store with NotAByte and leaves the image untouched. The check runs over the whole window before anything is written, so a store either happens completely or not at all.

A store to the sector one past the end appends, growing the image by one sector. Anything further out is an error. This is enough for a filesystem to extend a file without needing a separate resize operation, and it stops a stray sector number from inflating the image by a wild amount.

Structs§

BlockDevice
A sector-addressed block device.

Constants§

CONTROL
Offset of the control register.
CONTROL_LOAD
Control value that loads the selected sector into the window.
CONTROL_STORE
Control value that stores the window to the selected sector.
SECTOR
Offset of the first tryte of the sector register.
STATUS
Offset of the status register.
WINDOW
Offset of the first tryte of the sector window.