27static const char*
const s_tag =
"ra8_vsource";
59 (
ra8_vsource_obj_t){.read = read, .ctx = ctx, .xip =
nullptr, .base = base, .size = size};
78 (
ra8_vsource_obj_t){.read =
nullptr, .ctx =
nullptr, .xip = xip_base, .base = 0U, .size = size};
93 if (object_id >= vs->
count) {
97 if (offset >= o->
size) {
100 const uint64_t avail = o->
size - offset;
101 const uint32_t to_fill = (avail < (uint64_t)frame_bytes) ? (uint32_t)avail : frame_bytes;
102 (void)
memset(frame, 0, (
size_t)frame_bytes);
103 if (o->
xip !=
nullptr) {
104 (void)
memcpy(frame, &o->
xip[offset], (
size_t)to_fill);
107 return o->
read(o->
ctx, o->
base + offset, frame, to_fill);
114 const uint8_t** out_ptr)
118 if (object_id >= vs->
count) {
122 if (o->
xip ==
nullptr) {
125 if (offset >= o->
size) {
128 if ((uint64_t)len > (o->
size - offset)) {
131 *out_ptr = &o->
xip[offset];
static const char * s_tag
Logging / check tag.
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_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
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_err_t ra8_vsource_xip_ptr(const ra8_vsource_t *vs, uint32_t object_id, uint64_t offset, uint32_t len, const uint8_t **out_ptr)
Get a direct pointer into an XIP object (no copy, no cache).
ra8_err_t ra8_vsource_loader(void *ctx, uint32_t object_id, uint64_t offset, uint8_t *frame, uint32_t frame_bytes)
Fill a page frame from an object – the ra8_vmem_loader_fn adapter.
ra8_err_t ra8_vsource_add_paged(ra8_vsource_t *vs, ra8_vsource_read_fn read, void *ctx, uint64_t base, uint64_t size, uint32_t *out_id)
Register a storage-paged object; returns its object_id.
ra8_err_t ra8_vsource_add_xip(ra8_vsource_t *vs, const uint8_t *xip_base, uint64_t size, uint32_t *out_id)
Register an execute-in-place (memory-mapped) object; returns its id.
ra8_err_t ra8_vsource_init(ra8_vsource_t *vs, ra8_vsource_obj_t *objs, uint32_t cap)
Initialise an empty source registry over a caller-owned object array.
Virtual-memory object sources – the page-cache storage seam (Layer 1, #147).
ra8_err_t(* ra8_vsource_read_fn)(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
Read len bytes at offset from a paged object's backing.
One registered object's backing (paged or XIP).
ra8_vsource_read_fn read
Paged read callback (NULL for an XIP object).
void * ctx
Context passed to read.
uint64_t size
Object length in bytes.
uint64_t base
Paged: absolute base offset of the object.
const uint8_t * xip
XIP base pointer (NULL for a paged object).
Object-source registry (caller-owned; treat as private).
uint32_t count
Registered objects (next id == count).
uint32_t cap
Slot capacity.
ra8_vsource_obj_t * objs
cap object slots (caller-owned).