ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs_fat_lock.c
Go to the documentation of this file.
1/*
2 */
36
37#include <stddef.h>
38#include <stdint.h>
39
40#include "ra8_attributes.h"
41#include "ra8_fs.h"
42#include "ra8_fs_fat_internal.h"
43
59
72static bool s_lock_installed;
73
74/* `priv_lock_acquire()`: see header for the documented contract. */
76{
77 if (!s_lock_installed) {
78 return;
79 }
80 s_lock.acquire(s_lock.ctx);
81}
82
83/* `priv_lock_release()`: see header for the documented contract. */
85{
86 if (!s_lock_installed) {
87 return;
88 }
89 s_lock.release(s_lock.ctx);
90}
91
93{
94 if (lock == nullptr) {
95 s_lock_installed = false;
97 return k_ra8_ok;
98 }
99 if ((lock->acquire == nullptr) || (lock->release == nullptr)) {
101 }
102 s_lock = *lock;
103 s_lock_installed = true;
104 return k_ra8_ok;
105}
Annotation-attribute framework macros for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
Cross-TU shared declarations for the FAT/exFAT ra8_fs adapter.
void priv_lock_release(void)
Drop the library lock taken by priv_lock_acquire.
ra8_err_t ra8_fs_set_lock(const ra8_fs_lock_t *lock)
Install (or remove) the lock taken around every public ra8_fs call.
static bool s_lock_installed
True once a complete binding has been installed.
void priv_lock_acquire(void)
Take the library lock, if the caller installed one.
static ra8_fs_lock_t s_lock
The installed lock binding; meaningful only when s_lock_installed.
Dependency-injection seam for mutual exclusion around the public API.
void(* release)(void *ctx)
Release the lock taken by the matching acquire call.
void(* acquire)(void *ctx)
Take the lock; must block until it is held.