arch/*: Add z_arch_irq_unlocked() predicate and test

It's useful to be able to inspect the key returned from
z_arch_irq_unlock() to see if interrupts were enabled at the point
where z_arch_irq_lock() was called.  Architectures tend to represent
this is a simple way that doesn't require platform assembly to
inspect.

Adds a simple test to kernel/common that validates this predicate with
a nested lock.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-05-24 09:24:35 -07:00 committed by Andrew Boie
commit e6af0f8caa
9 changed files with 97 additions and 0 deletions

View file

@ -42,6 +42,15 @@ static inline void z_arch_irq_unlock(unsigned int key)
}
}
/**
* Returns true if interrupts were unlocked prior to the
* z_arch_irq_lock() call that produced the key argument.
*/
static inline bool z_arch_irq_unlocked(unsigned int key)
{
return (key & 0x200) != 0;
}
static inline void arch_nop(void)
{
__asm__ volatile("nop");