oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Typedefs | Functions
Interrupt context

Critical sections and interrupt-context detection. More...

Collaboration diagram for Interrupt context:

Typedefs

typedef uint64_t ove_irq_key_t
 Opaque cookie returned by ove_irq_lock for use with ove_irq_unlock.
 

Functions

ove_irq_key_t ove_irq_lock (void)
 Enter a critical section: disable interrupts (or equivalent backend mechanism) and return an opaque restore cookie.
 
void ove_irq_unlock (ove_irq_key_t key)
 Leave a critical section, restoring the interrupt state captured by the corresponding ove_irq_lock.
 
bool ove_is_in_isr (void)
 Return true if the caller is currently in interrupt context.
 

Detailed Description

Critical sections and interrupt-context detection.

Public primitives used by the async runtime (Embassy on Rust) to implement a critical-section provider and dispatch between thread- and ISR-context paths. The C API itself does not need these for normal blocking-style code — they are wired so that higher-level bindings can layer an async executor on top.

Note
All functions in this group require CONFIG_OVE_ASYNC. When CONFIG_OVE_ASYNC is not set, every function is replaced by a static inline stub that returns OVE_ERR_NOT_SUPPORTED (or zero, where the signature precludes an error return).

Typedef Documentation

◆ ove_irq_key_t

typedef uint64_t ove_irq_key_t

Opaque cookie returned by ove_irq_lock for use with ove_irq_unlock.

The width is sized to fit each backend's native restore state:

  • Zephyr: unsigned int returned by irq_lock().
  • FreeRTOS: 0 (the FreeRTOS taskENTER_CRITICAL macros are symmetric and don't return a value).
  • NuttX: irqstate_t (typically uint32_t).
  • POSIX: uint64_t (a TLS nesting depth — no real ISR-mask).

The C ABI commits to uint64_t so the Rust binding's critical-section::Impl::RawRestoreState can be a single fixed size across every target.

Function Documentation

◆ ove_irq_lock()

ove_irq_key_t ove_irq_lock ( void  )

Enter a critical section: disable interrupts (or equivalent backend mechanism) and return an opaque restore cookie.

Safe to call from both thread and ISR context. Nestable — each ove_irq_lock must be paired with a matching ove_irq_unlock passing the same cookie back, in LIFO order. The outermost ove_irq_unlock restores the previous interrupt state.

Returns
Opaque cookie to pass to ove_irq_unlock.
Note
Requires CONFIG_OVE_ASYNC.

◆ ove_irq_unlock()

void ove_irq_unlock ( ove_irq_key_t  key)

Leave a critical section, restoring the interrupt state captured by the corresponding ove_irq_lock.

Parameters
[in]keyCookie returned by the matching ove_irq_lock.
Note
Requires CONFIG_OVE_ASYNC.

◆ ove_is_in_isr()

bool ove_is_in_isr ( void  )

Return true if the caller is currently in interrupt context.

Used by higher-level bindings (Rust async runtime) to dispatch between the thread-context and ISR-context variants of a wake primitive (e.g. ove_event_signal vs ove_event_signal_from_isr).

Returns
true if the caller is in an ISR or equivalent interrupt-handling context, false otherwise.
Note
On host-sim backends (POSIX, WASM) the simulator sets a thread-local flag inside its ISR wrappers; outside those paths the function returns false.
Requires CONFIG_OVE_ASYNC.