|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Dependency-injection seam for mutual exclusion around the public API. More...
#include <ra8_fs_seams.h>
Data Fields | |
| void(* | acquire )(void *ctx) |
| Take the lock; must block until it is held. | |
| void(* | release )(void *ctx) |
| Release the lock taken by the matching acquire call. | |
| void * | ctx |
| Caller-owned cookie handed back to both callbacks. | |
Dependency-injection seam for mutual exclusion around the public API.
Two function pointers and a cookie. ra8_fs never creates, destroys or names a lock primitive: the caller owns one and hands over the two operations that drive it, exactly as ra8_fs_backend_t hands over the two operations that drive a block device. A ThreadX consumer binds tx_mutex_get / tx_mutex_put over a TX_MUTEX*; a bare-metal-with-interrupts consumer binds a PRIMASK save / restore pair. Neither adapter belongs in this library and neither is present in it.
Both callbacks are invoked with ctx as their only argument, and neither may fail: a lock whose acquire can return an error is not a lock this seam can express, and swallowing that error would be worse than not offering the seam. Wrap such a primitive in an adapter that blocks until it succeeds.
The pair must be re-entrant-free: acquire is never called twice without an intervening release, so a plain non-recursive mutex is the right shape.
Definition at line 89 of file ra8_fs_seams.h.
| void(* ra8_fs_lock_t::acquire) (void *ctx) |
Take the lock; must block until it is held.
Definition at line 94 of file ra8_fs_seams.h.
Referenced by ra8_fs_set_lock().
| void* ra8_fs_lock_t::ctx |
Caller-owned cookie handed back to both callbacks.
Definition at line 103 of file ra8_fs_seams.h.
| void(* ra8_fs_lock_t::release) (void *ctx) |
Release the lock taken by the matching acquire call.
Definition at line 100 of file ra8_fs_seams.h.
Referenced by ra8_fs_set_lock().