ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs_backend_t Struct Reference

Block-device interface that ra8_fs runs on top of. More...

#include <ra8_fs_types.h>

Data Fields

ra8_err_t(* read_block )(void *ctx, uint64_t lba, uint32_t count, uint8_t *buf)
 Read count consecutive blocks starting at lba.
ra8_err_t(* write_block )(void *ctx, uint64_t lba, uint32_t count, const uint8_t *buf)
 Write count consecutive blocks starting at lba.
ra8_err_t(* get_capacity )(void *ctx, uint64_t *block_count, uint32_t *block_size)
 Report the device size.
ra8_err_t(* erase_blocks )(void *ctx, uint64_t lba, uint64_t count)
 OPTIONAL: bulk-erase count blocks at lba to all-zero bytes.
void * ctx
 Caller-owned context passed back into the function pointers.

Detailed Description

Block-device interface that ra8_fs runs on top of.

Three function pointers + a context cookie. Each implementation (SDHI, USB MSC, mock) fills these in and passes the struct to ra8_fs_mount().

LBAs and the block count are 64-bit so media past the 32-bit-LBA reach (2 TiB at 512-byte blocks) are addressable end to end – through the mount's partition base, the GPT parser and every cluster computation (#683). The block size is the medium's real sector size: 512-byte and 4096-byte-native (4Kn) devices are both supported, 1024/2048 included.

Warning
The 4Kn and beyond-2-TiB paths are verified by host-side simulation against fake backends only – no such medium has been on the bench. The 512-byte, sub-2-TiB path is the hardware-proven one.
Invariant
read_block, write_block, get_capacity are non-NULL for a usable backend. erase_blocks and ctx may be NULL.

Definition at line 149 of file ra8_fs_types.h.

Field Documentation

◆ ctx

◆ erase_blocks

ra8_err_t(* ra8_fs_backend_t::erase_blocks) (void *ctx, uint64_t lba, uint64_t count)

OPTIONAL: bulk-erase count blocks at lba to all-zero bytes.

May be NULL. When non-NULL and it returns k_ra8_ok, the range [lba, lba+count) is guaranteed to read back as 0x00 – letting the formatter skip an explicit zero-write of that region (much faster on flash media that erases internally). A backend that cannot guarantee a zero post-erase value (or does not implement erase) must return k_ra8_err_not_supported so the formatter falls back to writing zeros; any other non-OK error aborts the format.

Parameters
[in]ctxBackend cookie.
[in]lbaFirst block to erase.
[in]countNumber of blocks to erase.

Definition at line 186 of file ra8_fs_types.h.

Referenced by lx_fs_backend_bind(), priv_fmt_clear_region(), ra8_io_blockdev_as_fs_backend(), and ra8_sdmmc_spi_bind_fs_backend().

◆ get_capacity

ra8_err_t(* ra8_fs_backend_t::get_capacity) (void *ctx, uint64_t *block_count, uint32_t *block_size)

Report the device size.

Parameters
[out]block_countTotal blocks (sectors).
[out]block_sizeBytes per block: a power of two in k_ra8_fs_sector_min..k_ra8_fs_sector_max.

Definition at line 170 of file ra8_fs_types.h.

Referenced by internal_mount_probe_bps(), lx_fs_backend_bind(), ra8_io_blockdev_as_fs_backend(), and ra8_sdmmc_spi_bind_fs_backend().

◆ read_block

ra8_err_t(* ra8_fs_backend_t::read_block) (void *ctx, uint64_t lba, uint32_t count, uint8_t *buf)

Read count consecutive blocks starting at lba.

Parameters
[in]ctxBackend cookie.
[in]lbaLogical block address (0 = BPB).
[in]countNumber of blocks to read.
[out]bufDestination buffer of at least count * block_size bytes.

Definition at line 157 of file ra8_fs_types.h.

Referenced by internal_stub_probe(), lx_fs_backend_bind(), priv_read_sector(), ra8_io_blockdev_as_fs_backend(), and ra8_sdmmc_spi_bind_fs_backend().

◆ write_block


The documentation for this struct was generated from the following file: