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

ra8_io byte-stream sink over a caller-owned RAM buffer. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_io_stream.h"
Include dependency graph for ra8_io_stream_ram.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_ram_state_t
 Caller-owned private state for a RAM stream sink. More...

Functions

ra8_err_t ra8_io_stream_ram_init (ra8_io_stream_t *s, ra8_io_stream_ram_state_t *state, uint8_t *buf, uint32_t cap)
 Bind a RAM stream sink into a caller-owned stream handle.
ra8_err_t ra8_io_stream_ram_used (const ra8_io_stream_ram_state_t *state, uint32_t *out_used)
 Report how many bytes have been captured into the RAM sink.

Detailed Description

ra8_io byte-stream sink over a caller-owned RAM buffer.

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

Appends written bytes into a fixed caller-owned buffer until it is full, then reports k_ra8_err_no_mem. Useful as a capture buffer for tests, an in-memory log ring, or staging bytes before a bulk transfer. Host-friendly: pure memory.

Since
0.1.0

Definition in file ra8_io_stream_ram.h.

Function Documentation

◆ ra8_io_stream_ram_init()

ra8_err_t ra8_io_stream_ram_init ( ra8_io_stream_t * s,
ra8_io_stream_ram_state_t * state,
uint8_t * buf,
uint32_t cap )
nodiscard

Bind a RAM 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]bufCapture buffer of cap bytes.
[in]capBuffer capacity in bytes (>= 1).
Returns
ra8_err_t Error code.
Return values
k_ra8_okSink bound; s is usable.
k_ra8_err_null_ptrs, state, or buf was NULL.
k_ra8_err_invalid_sizecap was zero.
Precondition
buf covers at least cap bytes.
s and state out-live every call made through the stream.
Postcondition
On success s appends written bytes into buf.
On any non-ok return s and state are left unbound/untouched.
Note
Not thread-safe with respect to the same stream.
Since
0.1.0

Definition at line 80 of file ra8_io_stream_ram.c.

References ra8_io_stream_ram_state_t::buf, ra8_io_stream_ram_state_t::cap, k_ra8_err_invalid_size, ra8_io_stream_ram_state_t::len, RA8_CHECK_NULL_PTR, ra8_io_stream_bind(), s_ram_iface, and s_tag.

Referenced by main().

◆ ra8_io_stream_ram_used()

ra8_err_t ra8_io_stream_ram_used ( const ra8_io_stream_ram_state_t * state,
uint32_t * out_used )
nodiscard

Report how many bytes have been captured into the RAM sink.

Parameters
[in]stateBound RAM sink state.
[out]out_usedNumber of captured bytes.
Returns
ra8_err_t Error code.
Return values
k_ra8_ok*out_used populated.
k_ra8_err_null_ptrstate or out_used was NULL.
Precondition
state was populated by ra8_io_stream_ram_init.
out_used is writable.
Postcondition
On success *out_used holds the captured length.
No state is mutated.
Note
Thread-safe (pure read).
Since
0.1.0

Definition at line 97 of file ra8_io_stream_ram.c.

References k_ra8_ok, ra8_io_stream_ram_state_t::len, RA8_CHECK_NULL_PTR, and s_tag.

Referenced by internal_swap_replay_capture().