PebbleOS v4.47.0-1362-gd278268fe
Loading...
Searching...
No Matches

Block storage, read and written by whole sectors. More...

Data Structures

struct  pbl_disk_info
 What a disk is made of. More...
 
struct  pbl_disk_ops
 Driver operations. More...
 
struct  pbl_disk
 Disk. More...
 

Macros

#define PBL_DISK_STATE_DEFINE(sym)   PBL_DEVICE_STATE_DEFINE(sym)
 Define the runtime state of a disk.
 
#define PBL_DISK_INIT(sym, _name, _parent, _ops)
 Initializer of a disk.
 

Functions

int pbl_disk_get_info (const struct pbl_disk *disk, struct pbl_disk_info *info)
 Get what a disk is made of.
 
int pbl_disk_read (const struct pbl_disk *disk, uint32_t sector, uint32_t count, void *buf)
 Read sectors.
 
int pbl_disk_write (const struct pbl_disk *disk, uint32_t sector, uint32_t count, const void *buf)
 Write sectors.
 
int pbl_disk_sync (const struct pbl_disk *disk)
 Store what writes left in the driver.
 

Variables

const struct pbl_device_class pbl_disk_class
 Class of the disks.
 
const struct pbl_disk pbl_disk_ram
 A disk in RAM, of CONFIG_DISK_RAM_SIZE KiB in 512-byte sectors, zeroed at boot.
 

Detailed Description

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.

struct pbl_disk_info info;
ret = pbl_disk_get_info(disk, &info);
ret = pbl_disk_read(disk, 0U, 1U, buf);
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.

Data Structure Documentation

◆ pbl_disk_info

struct pbl_disk_info

What a disk is made of.

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

struct pbl_disk

Disk.

Data Fields
struct pbl_device dev Device.
const struct pbl_disk_ops * ops Driver operations.

Macro Definition Documentation

◆ PBL_DISK_INIT

#define PBL_DISK_INIT (   sym,
  _name,
  _parent,
  _ops 
)
Value:
{ \
.dev = PBL_DEVICE_INIT_CLASS(sym, _name, pbl_disk_dev_init, _parent, &pbl_disk_class), \
.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
symSymbol of the disk.
_nameName.
_parentParent device, or NULL.
_opsDriver operations.

◆ PBL_DISK_STATE_DEFINE

#define PBL_DISK_STATE_DEFINE (   sym)    PBL_DEVICE_STATE_DEFINE(sym)

Define the runtime state of a disk.

Parameters
symSymbol of the disk.

Function Documentation

◆ pbl_disk_get_info()

int pbl_disk_get_info ( const struct pbl_disk *  disk,
struct pbl_disk_info *  info 
)

Get what a disk is made of.

Parameters
diskDisk.
[out]infoSector 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
diskDisk.
sectorFirst sector.
countNumber of sectors.
[out]bufRoom 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
diskDisk.
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
diskDisk.
sectorFirst sector.
countNumber of sectors.
bufcount 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.

Variable Documentation

◆ pbl_disk_class

const struct pbl_device_class pbl_disk_class
extern

Class of the disks.

◆ pbl_disk_ram

const struct pbl_disk pbl_disk_ram
extern

A disk in RAM, of CONFIG_DISK_RAM_SIZE KiB in 512-byte sectors, zeroed at boot.