31static const char*
const s_tag =
"ra8_io_stream_blockdev";
39typedef enum : uint32_t {
116 const uint32_t rem = len - *done;
117 const uint32_t chunk = (rem < room) ? rem : room;
194 if (out_written !=
nullptr) {
200 if (out_written !=
nullptr) {
233 if (st->
fill == 0U) {
256 state->
lba = start_lba;
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_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.
@ k_ra8_io_block_size_bytes
Bytes per logical block (the only size).
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.
struct ra8_io_stream_iface ra8_io_stream_iface_t
Public implementer contract for ra8_io byte-stream backends.
ra8_err_t ra8_io_stream_bind(ra8_io_stream_t *stream, const ra8_io_stream_iface_t *iface, void *context)
Bind a backend vtable and caller-owned state into a stream handle.
static ra8_err_t internal_bdsink_write(void *ctx, const uint8_t *buf, uint32_t len, uint32_t *out_written)
Block-device sink: buffer bytes, auto-committing full sectors.
static ra8_err_t internal_bdsink_commit_sector(ra8_io_stream_blockdev_state_t *st)
Commit the buffered sector as one logical block and advance the LBA.
static ra8_err_t internal_bdsink_commit_if_full(ra8_io_stream_blockdev_state_t *st)
Commit the buffered sector iff it is exactly full.
static const ra8_io_stream_iface_t s_bd_iface
Block-device stream sink vtable.
ra8_err_t ra8_io_stream_blockdev_init(ra8_io_stream_t *s, ra8_io_stream_blockdev_state_t *state, const ra8_io_blockdev_t *bd, uint32_t start_lba)
Bind a block-device stream sink into a caller-owned stream handle.
static uint32_t internal_bdsink_fill_chunk(ra8_io_stream_blockdev_state_t *st, const uint8_t *buf, uint32_t len, uint32_t *done)
Copy one bounded chunk from the source into the sector buffer.
static ra8_err_t internal_bdsink_flush(void *ctx)
Block-device sink: commit a partial trailing sector (zero-padded).
ra8_io_stream_bd_const_t
Block-device sink constants.
@ k_bd_one_block
Single-block transfer count.
@ k_bd_pad_byte
Pad value for a partial trailing sector.
ra8_io byte-stream sink that buffers into a raw block device.
Caller-allocated block-device handle binding a backend to its context.
Caller-owned private state for a block-device stream sink.
const ra8_io_blockdev_t * bd
Target device (private).
uint32_t lba
Next LBA to write.
uint8_t sector[(uint32_t) k_ra8_io_block_size_bytes]
Sector buffer.
uint32_t fill
Bytes in the sector buf.
Caller-allocated byte-stream handle binding a sink to its context.