arch: arm: define and implement ARM IRQ target state API
This commit contributes the definition and the implementation of an API for ARM MCUs to configure and get the configuration of the security state targeted by a given external IRQ line. The API is only available in Secure ARM Firmware. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
1bbfdf1d1a
commit
7a864bb79b
1 changed files with 56 additions and 0 deletions
|
@ -187,3 +187,59 @@ void _arch_isr_direct_header(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ARM_SECURE_FIRMWARE)
|
||||
/**
|
||||
*
|
||||
* @brief Set the target security state for the given IRQ
|
||||
*
|
||||
* Function sets the security state (Secure or Non-Secure) targeted
|
||||
* by the given irq. It requires ARMv8-M MCU.
|
||||
* It is only compiled if ARM_SECURE_FIRMWARE is defined.
|
||||
* It should only be called while in Secure state, otherwise, a write attempt
|
||||
* to NVIC.ITNS register is write-ignored(WI), as the ITNS register is not
|
||||
* banked between security states and, therefore, has no Non-Secure instance.
|
||||
*
|
||||
* It shall assert if the operation is not performed successfully.
|
||||
*
|
||||
* @param irq IRQ line
|
||||
* @param secure_state 1 if target state is Secure, 0 otherwise.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
void irq_target_state_set(unsigned int irq, int secure_state)
|
||||
{
|
||||
if (secure_state) {
|
||||
/* Set target to Secure */
|
||||
if (NVIC_ClearTargetState(irq) != 0) {
|
||||
__ASSERT(0, "NVIC SetTargetState error");
|
||||
}
|
||||
} else {
|
||||
/* Set target state to Non-Secure */
|
||||
if (NVIC_SetTargetState(irq) != 1) {
|
||||
__ASSERT(0, "NVIC SetTargetState error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Determine whether the given IRQ targets the Secure state
|
||||
*
|
||||
* Function determines whether the given irq targets the Secure state
|
||||
* or not (i.e. targets the Non-Secure state). It requires ARMv8-M MCU.
|
||||
* It is only compiled if ARM_SECURE_FIRMWARE is defined.
|
||||
* It should only be called while in Secure state, otherwise, a read attempt
|
||||
* to NVIC.ITNS register is read-as-zero(RAZ), as the ITNS register is not
|
||||
* banked between security states and, therefore, has no Non-Secure instance.
|
||||
*
|
||||
* @param irq IRQ line
|
||||
*
|
||||
* @return 1 if target state is Secure, 0 otherwise.
|
||||
*/
|
||||
int irq_target_state_is_secure(unsigned int irq)
|
||||
{
|
||||
return NVIC_GetTargetState(irq) == 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARM_SECURE_FIRMWARE */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue