Skip to main content

Crate ternaria_dev

Crate ternaria_dev 

Source
Expand description

Memory-mapped devices, and the bus that routes addresses to them.

§Address layout

Addresses are signed with zero at the centre, so the negative half is used for devices and the positive half for RAM. No separate I/O instruction space is needed: a device register is reached by an ordinary load or store.

Devices occupy DEVICE_BASE upward, one DEVICE_STRIDE-tryte slot each. Both constants are powers of three and divisible by 3, so every device base is word-aligned.

  -19683  console   data, status
  -18954  timer     ticks
  -18225  block     sector, status, control, then the sector window

Device registers are tryte-granular, so they are reached with lt and st rather than lw and sw.

Re-exports§

pub use block::BlockDevice;
pub use bus::Bus;
pub use console::Console;
pub use timer::Timer;

Modules§

block
A block device backed by host bytes.
bus
Routes addresses to RAM or to a device.
console
A character console.
timer
A monotonic tick counter.

Constants§

BLOCK_BASE
Base address of the block device.
CONSOLE_BASE
Base address of the console.
DEVICE_BASE
Lowest address used by devices: -3^9.
DEVICE_STRIDE
Trytes reserved per device: 3^6.
SECTOR_SIZE
Trytes per block-device sector: 3^5.
TIMER_BASE
Base address of the timer.

Traits§

Device
A device occupying a contiguous range of addresses.

Functions§

prelude
Assembler .equ lines naming every device address and register offset.