31static const char*
const s_tag =
"ra8_io_blockdev";
67 if (bd->
iface ==
nullptr) {
177 if (lba > (uint64_t)UINT32_MAX) {
214 if (lba > (uint64_t)UINT32_MAX) {
301 if ((lba > (uint64_t)UINT32_MAX) || (count > (uint64_t)UINT32_MAX)) {
318 out->
ctx = (
void*)(uintptr_t)bd;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_io_blockdev_sync(const ra8_io_blockdev_t *bd)
Flush any backend write buffering to the medium.
ra8_err_t ra8_io_blockdev_read(const ra8_io_blockdev_t *bd, uint32_t lba, uint32_t count, uint8_t *buf)
Read count logical blocks starting at lba into buf.
static ra8_err_t internal_fs_write(void *ctx, uint64_t lba, uint32_t count, const uint8_t *buf)
ra8_fs write trampoline – forward into the bound block device.
static ra8_err_t internal_fs_get_capacity(void *ctx, uint64_t *block_count, uint32_t *block_size)
ra8_fs capacity trampoline – map block-device caps to (count, size).
static ra8_err_t internal_fs_erase(void *ctx, uint64_t lba, uint64_t count)
ra8_fs erase trampoline – only advertise erase on zero-erase media.
ra8_err_t ra8_io_blockdev_as_fs_backend(const ra8_io_blockdev_t *bd, ra8_fs_backend_t *out)
Expose a bound block device as an ra8_fs_backend_t for ra8_fs.
ra8_err_t ra8_io_blockdev_write(const ra8_io_blockdev_t *bd, uint32_t lba, uint32_t count, const uint8_t *buf)
Write count logical blocks from buf starting at lba.
ra8_err_t ra8_io_blockdev_get_caps(const ra8_io_blockdev_t *bd, ra8_io_blockdev_caps_t *out)
Report the bound backend's medium capabilities.
ra8_err_t ra8_io_blockdev_erase(const ra8_io_blockdev_t *bd, uint32_t lba, uint32_t count)
Erase count blocks starting at lba to the medium's erase value.
static ra8_err_t internal_validate(const ra8_io_blockdev_t *bd)
Reject a handle that is NULL or has no backend bound.
static ra8_err_t internal_fs_read(void *ctx, uint64_t lba, uint32_t count, uint8_t *buf)
ra8_fs read trampoline – forward into the bound block device.
ra8_io block-device fabric – one LBA vtable across every storage medium.
@ k_ra8_io_erase_value_zero
Block reads back as 0x00 after erase.
Backend implementation contract for the ra8_io block-device fabric.
Lightweight Logging Interface for ra8-firmware.
Block-device interface that ra8_fs runs on top of.
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(* 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.
ra8_err_t(* get_capacity)(void *ctx, uint64_t *block_count, uint32_t *block_size)
Report the device size.
Static properties a backend reports about its medium.
uint32_t block_count
Total addressable logical blocks.
uint8_t erase_value
Post-erase byte (ra8_io_erase_value_t).
uint16_t logical_block_bytes
Logical block size (always 512).
ra8_err_t(* get_caps)(const void *ctx, ra8_io_blockdev_caps_t *out)
Fill *out with the medium capabilities.
ra8_err_t(* erase)(void *ctx, uint32_t lba, uint32_t count)
Erase count blocks at lba.
ra8_err_t(* read)(void *ctx, uint32_t lba, uint32_t count, uint8_t *buf)
Read count blocks at lba into buf.
ra8_err_t(* write)(void *ctx, uint32_t lba, uint32_t count, const uint8_t *buf)
Write count blocks from buf at lba.
ra8_err_t(* sync)(void *ctx)
Commit any write buffering.
Caller-allocated block-device handle binding a backend to its context.
const ra8_io_blockdev_iface_t * iface
Bound backend vtable (private).
void * ctx
Backend-private context (private).