34static const char*
const s_tag =
"ra8_io_blockdev_vsource";
42typedef enum : uint32_t {
171 uint64_t block_bytes)
173 const uint32_t head_in_block = (uint32_t)(cur->
cur % block_bytes);
174 if (head_in_block == 0U) {
177 uint32_t head_n = (uint32_t)(block_bytes - (uint64_t)head_in_block);
178 if (head_n > cur->
remain) {
182 (uint32_t)(cur->
cur / block_bytes),
189 cur->
cur += (uint64_t)head_n;
223 uint64_t block_bytes)
225 const uint32_t mid_blocks = (uint32_t)((uint64_t)cur->
remain / block_bytes);
226 if (mid_blocks == 0U) {
234 const uint32_t mid_bytes = (uint32_t)((uint64_t)mid_blocks * block_bytes);
235 cur->
cur += (uint64_t)mid_bytes;
236 cur->
out += mid_bytes;
269 uint64_t block_bytes)
294 if (offset > (UINT64_MAX - (uint64_t)len)) {
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_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
ra8_io block-device fabric – one LBA vtable across every storage 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.
@ k_ra8_io_block_size_bytes
Bytes per logical block (the only size).
static ra8_err_t internal_bd_read_tail(ra8_io_blockdev_vsource_ctx_t *ctx, ra8_io_bd_vsource_cursor_t *cur, uint64_t block_bytes)
Service the unaligned tail sector of a byte-offset read.
static ra8_err_t internal_bd_read_sector(ra8_io_blockdev_vsource_ctx_t *ctx, uint32_t lba)
Read one sector at lba into the context bounce buffer.
ra8_err_t ra8_io_blockdev_vsource_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
Read len bytes at byte offset from the bound block device.
static ra8_err_t internal_bd_read_head(ra8_io_blockdev_vsource_ctx_t *ctx, ra8_io_bd_vsource_cursor_t *cur, uint64_t block_bytes)
Service the unaligned head sector of a byte-offset read.
static ra8_err_t internal_bd_read_middle(ra8_io_blockdev_vsource_ctx_t *ctx, ra8_io_bd_vsource_cursor_t *cur, uint64_t block_bytes)
Service the aligned middle of a byte-offset read.
ra8_io_bd_vsource_const_t
Adapter layout constants.
@ k_ra8_io_bd_vsource_one_block
Blocks transferred per bounce read.
ra8_err_t ra8_io_blockdev_vsource_init(ra8_io_blockdev_vsource_ctx_t *ctx, const ra8_io_blockdev_t *bd)
Bind a block device into a vsource adapter context.
static ra8_err_t internal_bd_copy_slice(ra8_io_blockdev_vsource_ctx_t *ctx, uint32_t lba, uint32_t in_block, uint32_t n, uint8_t *dst)
Copy a slice out of the bounce buffer after a one-sector read.
Thin adapter exposing an ra8_io block device as an ra8_vsource reader.
Virtual-memory object sources – the page-cache storage seam (Layer 1, #147).
Mutable walk state shared by the head/middle/tail read segments.
uint64_t cur
Absolute device byte offset of the next unread byte.
uint8_t * out
Next unwritten byte of the caller's destination buffer.
uint32_t remain
Bytes still owed to the caller.
Caller-allocated block-device handle binding a backend to its context.
Caller-owned adapter context binding a block device to a vsource read.
uint8_t scratch[(uint32_t) k_ra8_io_block_size_bytes]
One-sector bounce buffer (private).
const ra8_io_blockdev_t * bd
Bound block device (private; read-only use).