Block storage, read and written by whole sectors.
More...
Block storage, read and written by whole sectors.
A disk is an array of sectors of one size, numbered from 0. Reads and writes take whole sectors; how the driver stores them, erase blocks and caching included, is its own. A write may stay in the driver until pbl_disk_sync(). Calls are not serialized by the class.
What a disk is made of.
Definition disk.h:35
int pbl_disk_read(const struct pbl_disk *disk, uint32_t sector, uint32_t count, void *buf)
Read sectors.
int pbl_disk_get_info(const struct pbl_disk *disk, struct pbl_disk_info *info)
Get what a disk is made of.
◆ pbl_disk_info
| Data Fields |
|
bool |
read_only |
Whether writes are refused. |
|
uint32_t |
sector_count |
Number of sectors. |
|
uint32_t |
sector_size |
Size of a sector, in bytes. |
◆ pbl_disk
◆ PBL_DISK_INIT
| #define PBL_DISK_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_parent, |
|
|
|
_ops |
|
) |
| |
Value: { \
.ops = (_ops), \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:153
const struct pbl_device_class pbl_disk_class
Class of the disks.
Initializer of a disk.
- Parameters
-
| sym | Symbol of the disk. |
| _name | Name. |
| _parent | Parent device, or NULL. |
| _ops | Driver operations. |
◆ PBL_DISK_STATE_DEFINE
Define the runtime state of a disk.
- Parameters
-
◆ pbl_disk_get_info()
Get what a disk is made of.
- Parameters
-
| disk | Disk. |
| [out] | info | Sector size and count, and whether it is read-only. |
- Returns
- 0,
-ENODEV if the disk is not ready, or a negative errno from the driver.
◆ pbl_disk_read()
| int pbl_disk_read |
( |
const struct pbl_disk * |
disk, |
|
|
uint32_t |
sector, |
|
|
uint32_t |
count, |
|
|
void * |
buf |
|
) |
| |
Read sectors.
- Parameters
-
| disk | Disk. |
| sector | First sector. |
| count | Number of sectors. |
| [out] | buf | Room for count sectors. |
- Returns
- 0,
-ENODEV if the disk is not ready, -EINVAL if the sectors are not all on the disk, or a negative errno from the driver.
◆ pbl_disk_sync()
| int pbl_disk_sync |
( |
const struct pbl_disk * |
disk | ) |
|
Store what writes left in the driver.
- Parameters
-
- Returns
- 0,
-ENODEV if the disk is not ready, or a negative errno from the driver.
◆ pbl_disk_write()
| int pbl_disk_write |
( |
const struct pbl_disk * |
disk, |
|
|
uint32_t |
sector, |
|
|
uint32_t |
count, |
|
|
const void * |
buf |
|
) |
| |
Write sectors.
- Parameters
-
| disk | Disk. |
| sector | First sector. |
| count | Number of sectors. |
| buf | count sectors. |
- Returns
- 0,
-ENODEV if the disk is not ready, -EINVAL if the sectors are not all on the disk, -EROFS if it is read-only, or a negative errno from the driver.
◆ pbl_disk_class
◆ pbl_disk_ram
A disk in RAM, of CONFIG_DISK_RAM_SIZE KiB in 512-byte sectors, zeroed at boot.