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

ra8_io byte-stream sink that buffers into a raw block device. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_io_blockdev.h"
#include "ra8_io_stream.h"
Include dependency graph for ra8_io_stream_blockdev.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_io_stream_blockdev_state_t
 Caller-owned private state for a block-device stream sink. More...

Functions

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.

Detailed Description

ra8_io byte-stream sink that buffers into a raw block device.

Tag
[Ring 4 / PAL] {World: NS}

Block devices are sector-granular, so a byte stream must accumulate a 512-byte sector and flush it. This sink writes consecutive logical blocks of an ra8_io_blockdev_t starting at a chosen LBA: bytes fill an internal sector buffer; a full sector is committed automatically; ra8_io_stream_flush commits any partial trailing sector (zero-padded). Useful for streaming a log or a blob straight onto SD / OSPI / MRAM via the fabric without a filesystem.

Since
0.1.0

Definition in file ra8_io_stream_blockdev.h.

Function Documentation

◆ ra8_io_stream_blockdev_init()

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 )
nodiscard

Bind a block-device stream sink into a caller-owned stream handle.

Parameters
[out]sStream handle to bind (zero-initialised by the caller).
[out]stateCaller-owned sink state to populate.
[in]bdBound block device to stream into.
[in]start_lbaFirst logical block address to write.
Returns
ra8_err_t Error code.
Return values
k_ra8_okSink bound; s is usable.
k_ra8_err_null_ptrs, state, or bd was NULL.
Precondition
bd is a bound block device that out-lives the stream.
s and state out-live every call made through the stream.
Postcondition
On success s streams bytes onto bd from start_lba.
On any non-ok return s and state are left unbound/untouched.
Note
Not thread-safe with respect to the same stream. Call ra8_io_stream_flush to commit a partial trailing sector.
Since
0.1.0

Definition at line 247 of file ra8_io_stream_blockdev.c.

References ra8_io_stream_blockdev_state_t::bd, ra8_io_stream_blockdev_state_t::fill, ra8_io_stream_blockdev_state_t::lba, RA8_CHECK_NULL_PTR, ra8_io_stream_bind(), s_bd_iface, and s_tag.