KallistiOS git master
Independent SDK for the Sega Dreamcast
|
A simple block device. More...
#include <kos/blockdev.h>
Data Fields | |
void * | dev_data |
Internal device data. | |
uint32_t | l_block_size |
Log base 2 of the bytes per block. | |
int(* | init )(struct kos_blockdev *d) |
Initialize the block device. | |
int(* | shutdown )(struct kos_blockdev *d) |
Shut down the block device. | |
int(* | read_blocks )(struct kos_blockdev *d, uint64_t block, size_t count, void *buf) |
Read a number of blocks from the device. | |
int(* | write_blocks )(struct kos_blockdev *d, uint64_t block, size_t count, const void *buf) |
Write a number of blocks to the device. | |
uint64_t(* | count_blocks )(struct kos_blockdev *d) |
Count the number of blocks on the device. | |
int(* | flush )(struct kos_blockdev *d) |
Flush the write cache (if any) of the device. | |
A simple block device.
This structure represents a single block device. Each block device should be associated with exactly one filesystem and is used to actually read the data from the disk (or other device) where it is stored.
By using a block device with any new filesystems, we can abstract away a few things so that filesystems can be used with a variety of different "devices", such as the SD card reader for the Dreamcast or a disk image file of some sort.
uint64_t(* kos_blockdev_t::count_blocks) (struct kos_blockdev *d) |
Count the number of blocks on the device.
This function should return the total number of blocks on the device. There is no expectation of the device to keep track of which blocks are in use or anything else of the sort.
d | The device to read the block count from. |
void* kos_blockdev_t::dev_data |
Internal device data.
int(* kos_blockdev_t::flush) (struct kos_blockdev *d) |
Flush the write cache (if any) of the device.
This function shall signal to the device that any write caches that are present on the device shall be flushed so that all data written to this point shall persist to the underlying storage.
d | The device to flush caches on. |
0 | On success. |
-1 | On failure. Set errno as appropriate. |
int(* kos_blockdev_t::init) (struct kos_blockdev *d) |
Initialize the block device.
This function should do any necessary initialization to use the block device passed in.
d | The device to initialize. |
0 | On success. |
-1 | On failure. Set errno as appropriate. |
uint32_t kos_blockdev_t::l_block_size |
Log base 2 of the bytes per block.
int(* kos_blockdev_t::read_blocks) (struct kos_blockdev *d, uint64_t block, size_t count, void *buf) |
Read a number of blocks from the device.
This function should read the specified number of device blocks into the given buffer. The buffer will already be allocated by the caller.
d | The device to read from. |
block | The first block to read. |
count | The number of blocks to read. |
buf | The buffer to read into. |
0 | On success. |
-1 | On failure. Set errno as appropriate. |
int(* kos_blockdev_t::shutdown) (struct kos_blockdev *d) |
Shut down the block device.
This function should do any teardown work that is needed to clean up the block device.
d | The device to shut down. |
0 | On success. |
-1 | On failure. Set errno as appropriate. |
int(* kos_blockdev_t::write_blocks) (struct kos_blockdev *d, uint64_t block, size_t count, const void *buf) |
Write a number of blocks to the device.
This function should write the specified number of device blocks onto the device from the given buffer.
d | The device to write to. |
block | The first block to write. |
count | The number of blocks to write. |
buf | The buffer to write from. |
0 | On success. |
-1 | On failure. Set errno as appropriate. |