nios2: implement _IS_IN_ISR()

We check to see if the stack pointer is somwhere on the
interrupt stack.

Change-Id: Ic9d21e9f03476b9c8955c44cbfa2e61dd1daed22
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2016-06-23 13:48:58 -07:00
commit 99b2866ed2

View file

@ -186,8 +186,15 @@ FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
static ALWAYS_INLINE int _IS_IN_ISR(void)
{
/* STUB */
char *sp = (char *)_nios2_read_sp();
/* Make sure we're on the interrupt stack somewhere */
if (sp < _interrupt_stack ||
sp >= (char *)(STACK_ROUND_DOWN(_interrupt_stack +
CONFIG_ISR_STACK_SIZE))) {
return 0;
}
return 1;
}
#endif /* _ASMLANGUAGE */