38#include "ra8_esp_hosted_tx_shim_sync_internal.h"
53static const char*
s_tag =
"ESPH_SYNC";
71typedef enum : uint32_t {
140 s_sync.mutex_used[idx] =
false;
143 return &
s_sync.mutexes[idx];
169 sizeof(
s_sync.mutexes[0]),
201 sizeof(
s_sync.mutexes[0]),
231 sizeof(
s_sync.mutexes[0]),
238 s_sync.mutex_used[idx] =
false;
275 if (!
s_sync.ready || (max_count <= 0)) {
286 s_sync.sem_used[idx] =
false;
416 s_sync.sem_used[idx] =
false;
esp-hosted port header: RTOS handle types, return codes and budgets.
#define RET_FAIL
Operation failed for an unspecified reason.
#define RET_FAIL_TIMEOUT
The requested wait expired before the operation could complete.
#define RET_INVALID
A parameter was out of contract (null handle, bad size).
#define RET_OK
Operation completed.
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
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_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_rtos_error
Generic RTOS error (reserved for future use).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Public entry point of the RA8D2 + ThreadX port of esp-hosted.
@ k_ra8_esp_hosted_max_mutexes
Mutexes the port can hand out, covering the bus lock and the mempool lock with headroom for the RPC l...
@ k_ra8_esp_hosted_max_semaphores
Counting semaphores the port can hand out before refusing.
uint32_t priv_ra8_esp_hosted_rtos_ms_to_ticks(int timeout_ms)
Convert an esp-hosted millisecond timeout to a ThreadX wait option.
uint32_t priv_ra8_esp_hosted_rtos_slot_take(bool *used, uint32_t count)
Claim the first free row of an occupancy bitmap.
uint32_t priv_ra8_esp_hosted_rtos_slot_index(const void *handle, const void *base, size_t stride, uint32_t count, const bool *used)
Resolve an opaque handle to its row index in a fixed table.
Module-private contract of the esp-hosted RTOS abstraction slice.
ra8_err_t priv_ra8_esp_hosted_rtos_sync_deinit(void)
Delete every outstanding mutex and semaphore.
static int internal_h_post_semaphore(void *semaphore_handle)
Post a semaphore from thread context.
static int internal_h_unlock_mutex(void *mutex_handle)
Release a mutex the caller owns.
static int internal_h_destroy_mutex(void *mutex_handle)
Delete a mutex and free its table row.
static int internal_h_lock_mutex(void *mutex_handle, int timeout_ms)
Take a mutex, blocking for at most timeout_ms.
ra8_err_t priv_ra8_esp_hosted_rtos_sync_init(void)
Clear the mutex and semaphore tables and mark them usable.
static int internal_h_get_semaphore(void *semaphore_handle, int timeout_ms)
Take a semaphore, blocking for at most timeout_ms.
ra8_err_t priv_ra8_esp_hosted_rtos_bind_sync(hosted_osi_funcs_t *out)
Populate the mutex and semaphore slots of the vtable.
static ra8_esp_hosted_sync_state_t s_sync
Singleton state of the mutex and semaphore half.
static int internal_h_destroy_semaphore(void *semaphore_handle)
Delete a semaphore and free its table row.
static void * internal_h_create_mutex(void)
Create a mutex from the fixed mutex table.
static void * internal_h_create_semaphore(int max_count)
Create a counting semaphore from the fixed semaphore table.
ra8_esp_hosted_sync_const_t
Numeric constants of the mutex and semaphore half.
@ k_ra8_esp_hosted_sem_initial
Instances a new semaphore starts with.
static int internal_h_post_semaphore_from_isr(void *semaphore_handle)
Post a semaphore from an interrupt handler.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Opaque mutex stand-in for the host build.
Module state of the mutex and semaphore half – entirely static.
TX_SEMAPHORE sems[k_ra8_esp_hosted_max_semaphores]
Semaphore table.
bool sem_used[k_ra8_esp_hosted_max_semaphores]
Semaphore occupancy.
TX_MUTEX mutexes[k_ra8_esp_hosted_max_mutexes]
Mutex table.
bool mutex_used[k_ra8_esp_hosted_max_mutexes]
Mutex occupancy.