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

@ -124,6 +124,15 @@ static ALWAYS_INLINE void z_arch_irq_unlock(unsigned int key)
#endif
}
/**
* Returns true if interrupts were unlocked prior to the
* z_arch_irq_lock() call that produced the key argument.
*/
static ALWAYS_INLINE bool z_arch_irq_unlocked(unsigned int key)
{
return key & 1;
}
void z_arch_irq_enable(unsigned int irq);
void z_arch_irq_disable(unsigned int irq);