seed_riscv/block/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub mod virtio;

use core::ptr::NonNull;

pub trait BlockDevice {
    type ReadTokenMetadata;

    fn read(&mut self, block: u64) -> ReadToken<Self::ReadTokenMetadata>;
    fn free_read_block(&mut self, token: ReadToken<Self::ReadTokenMetadata>);
}

/// Represents a block that has been read from a `BlockDevice`. Must be freed using
/// `BlockDevice::free_read_block`.
pub struct ReadToken<M> {
    pub data: NonNull<[u8; 512]>,
    meta: M,
}