irq.h

Defines

EMB_IRQ_LEVEL_KERNEL_MAX

Typedefs

typedef void (*emb_isr_fn_t)(void *arg)

Functions

static inline emb_irq_key_t emb_irq_lock(void)

emb_irq_lock() - Mask kernel-aware interrupts on this CPU.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-018 KRN-IRQ-033 Since: 0.2 Stability: yes

Return: the previous mask state, to be passed to emb_irq_unlock().

static inline void emb_irq_unlock(emb_irq_key_t key)

emb_irq_unlock() - Restore the mask state returned by emb_irq_lock().

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-018 KRN-IRQ-033 Since: 0.2 Stability: yes

Parameters:
  • key – The value emb_irq_lock() returned; unlocks must be in reverse order.

static inline bool emb_irq_is_locked(void)

emb_irq_is_locked() - Are kernel-aware interrupts masked on this CPU?

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-018 Since: 0.2 Stability: yes

unsigned emb_irq_nesting_depth(void)

emb_irq_nesting_depth() - Number of nested kernel-aware interrupts active.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-012 Since: 0.2 Stability: yes

emb_status_t emb_irq_enable(emb_irq_t irq)

emb_irq_enable()

- Unmask one interrupt at the controller.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an unknown number.

Parameters:
  • irq – Interrupt number from the SoC table.

emb_status_t emb_irq_disable(emb_irq_t irq)

emb_irq_disable()

- Mask one interrupt at the controller.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an unknown number; port-specific unsupported operations may return EMB_ENOTSUP. This does not clear a pending interrupt.

Parameters:
  • irq – Interrupt number from the port/SoC table.

bool emb_irq_is_enabled(emb_irq_t irq)

emb_irq_is_enabled()

- Read one controller enable state.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: true when enabled, false when disabled or the number is unknown.

Parameters:
  • irq – Interrupt number from the port/SoC table.

emb_status_t emb_irq_set_level(emb_irq_t irq, uint8_t level)

emb_irq_set_level()

- Set a generic interrupt priority.

Context: thread prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-028 KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an invalid number on validating ports. The target convention is larger = more urgent (KRN-IRQ-028), but the current Cortex-M port maps 0 to the most urgent kernel-aware level and clamps larger values toward lower urgency. Native, AVR and current RV32 accept a known number but ignore level. This API does not yet implement generic priority numbering consistently; do not infer hardware preemption from native tests.

Parameters:
  • irq – Interrupt number from the port/SoC table.

  • level – Port priority value; see the current mapping limitation below.

emb_status_t emb_irq_pend(emb_irq_t irq)

emb_irq_pend()

- Request delivery of a kernel-aware interrupt.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an unknown number; EMB_ENOTSUP for a controller/vector that cannot be software-pended. Delivery follows the current mask and enable state. A kernel-independent ISR must use the port primitive emb_arch_irq_pend_soft(), not this public kernel API.

Parameters:
  • irq – Interrupt number supported by the port.

emb_status_t emb_irq_clear_pending(emb_irq_t irq)

emb_irq_clear_pending()

- Clear one controller pending state.

Context: thread isr prekernel Blocking: no Timing: O(1) Ownership: none Configuration: Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an unknown number; EMB_ENOTSUP where clearing is unsupported. A level source may pend again until acknowledged.

Parameters:
  • irq – Interrupt number supported by the port.

emb_status_t emb_irq_connect(emb_irq_t irq, emb_isr_fn_t fn, void *arg)

emb_irq_connect()

- Bind a handler to an interrupt at run time.

Context: thread prekernel Blocking: no Timing: O(1) Ownership: none Configuration: CONFIG_EMB_IRQ_DYNAMIC Requirements: KRN-IRQ-029 Since: 0.2 Stability: yes

Return: EMB_OK; EMB_EINVAL for an unknown number or a NULL handler.

Parameters:
  • irq – Interrupt number.

  • fn – Handler, run in interrupt context as a kernel-aware handler.

  • arg – Passed to fn.