Skip to content

Commit

Permalink
kernel/os: Add default irq callback
Browse files Browse the repository at this point in the history
Added a MYNEWT_VAL named OS_DEFAULT_IRQ_CB which, when enabled,
will call a user-defined callback as the first function called
in os_default_irq(). This will allow users to define custom
functionality when a default irq occurs.
  • Loading branch information
wes3 committed Nov 28, 2023
1 parent 22ebb10 commit e5692a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/os/include/os/os_fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ void __assert_func(const char *file, int line, const char *func, const char *e)
typedef void (*coredump_cb_t)(void *tf);
#endif

#if MYNEWT_VAL(OS_DEFAULT_IRQ_CB)
void os_default_irq_cb(void);
#endif

#if MYNEWT_VAL(OS_CRASH_FILE_LINE)
#define OS_CRASH() (HAL_DEBUG_BREAK(), __assert_func(__FILE__, __LINE__, NULL, NULL))
#else
Expand Down
4 changes: 4 additions & 0 deletions kernel/os/src/arch/cortex_m33/os_fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ os_default_irq(struct trap_frame *tf)
uint32_t orig_sp;
#endif

#if MYNEWT_VAL(OS_DEFAULT_IRQ_CB)
os_default_irq_cb();
#endif

/* Stop MTB if implemented so interrupt handler execution is not recorded */
mtb_stop();

Expand Down
6 changes: 6 additions & 0 deletions kernel/os/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ syscfg.defs:
value: 0
restriction:
- 'OS_COREDUMP if 1'
OS_DEFAULT_IRQ_CB:
description: >
Calls a custom default irq callback function inside
os_default_irq. If enabled it is the first function
executed in os_default_irq.
value: 0
OS_CRASH_STACKTRACE:
description: 'Attempt to print stack trace when system crashes.'
value: 0
Expand Down

0 comments on commit e5692a7

Please sign in to comment.