Menu

Expand
Rate this page:

Interrupt Functions

Microvisor Public Beta

Microvisor is in a pre-release phase and the information contained in this document is subject to change. Some features referenced below may not be fully available until Microvisor’s General Availability (GA) release.

The Microvisor system calls currently include the following functions for managing non-secure interrupt latency modes:

A ‘fast’ interrupt is one that Microvisor permits to pre-empt secure threads. This reduces latency, typically to under 20μs, but at a cost. See below for more information.

Return values and errors

All of the functions described below return a 32-bit integer that is one of the values from the standard Microvisor enumeration MvStatus. All possible error values for a given system call are provided with each function’s description.

Success is always signaled by a return value of zero (MV_STATUS_OKAY).

mvSetFastInterrupt()

Mark an interrupt to be served with low latency

Declaration

extern enum MvStatus mvSetFastInterrupt(uint32_t irqn);

Parameters

Parameter Description
irqn The number of the IRQ to be served with low latency

Possible errors

Error Value Description
MV_STATUS_INVALIDINTERRUPT irqn is not available to non-secure code
MV_STATUS_INVALIDVECTOR VTOR or interrupt vector is not in non-secure memory
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Use mvSetFastInterrupt() to allow the specified interrupt to pre-empt secure threads in order to reduce latency, typically to less than 20μs.

This call only allows the interrupt to take place in low-latency mode — you must call mvEnableFastInterrupt() or mvEnableAllFastInterrupts() to be begin using it.

You may be tempted to switch all of your application’s interrupts into low-latency mode, but switching any single interrupt comes at a cost: while it is in low-latency mode, its interrupt service routine (ISR) will not be able to perform a non-local return, such as an RTOS context switch. If your application is written in C, the ISR must be a regular function that returns early via return, or automatically at the end of the function. An ISR written in assembly must end in the usual way by branching to a value stored in the ARM Link Register on entry.

mvClearFastInterrupt()

Move an interrupt out of low-latency mode

Declaration

extern enum MvStatus mvClearFastInterrupt(uint32_t irqn);

Parameters

Parameter Description
irqn The number of the IRQ to be removed from low-latency mode

Possible errors

Error Value Description
MV_STATUS_INVALIDINTERRUPT irqn is not available to non-secure code
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Calling mvClearFastInterrupt() will bring the specified interrupt out of low-latency mode, i.e., it will not be able to pre-empt secure threads.

Specifying an interrupt that is not in low-latency has no effect. Clearing an enabled fast interrupt will implicitly deactivate it.

mvEnableFastInterrupt()

Activate a specific low-latency interrupt

Declaration

extern enum MvStatus mvEnableFastInterrupt(uint32_t irqn);

Parameters

Parameter Description
irqn The number of the fast IRQ to be activated

Possible errors

Error Value Description
MV_STATUS_INVALIDINTERRUPT irqn is not available to non-secure code
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Use mvEnableFastInterrupt() to activate an interrupt that was recently moved to low-latency mode by a call to mvSetFastInterrupt(), or to re-activate a fast interrupt that has been suspended by a call to mvDisableFastInterrupt() or mvDisableAllFastInterrupts().

mvEnableAllFastInterrupts()

Activate all low-latency interrupts simultaneously

Declaration

extern enum MvStatus mvEnableAllFastInterrupts(void);

Possible errors

Error Value Description
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Use this function to activate all deactivated low-latency interrupts at once.

mvDisableFastInterrupt()

Deactivate a specific low-latency interrupt

Declaration

extern enum MvStatus mvDisableFastInterrupt(uint32_t irqn);

Parameters

Parameter Description
irqn The number of the fast IRQ to be deactivated

Possible errors

Error Value Description
MV_STATUS_INVALIDINTERRUPT irqn is not available to non-secure code
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Use mvDisableFastInterrupt() to deactivate an interrupt before moving it out of low-latency mode, or to temporarily suspend it. Paused interrupts can be reactivated by a call to mvEnableFastInterrupt() or mvEnableAllFastInterrupts().

mvDisableAllFastInterrupts()

Deactivate all low-latency interrupts simultaneously

Declaration

extern enum MvStatus mvDisableAllFastInterrupts(void);

Possible errors

Error Value Description
MV_STATUS_UNAVAILABLE Fast interrupts are unavailable — code is being shut down after a hung interrupt or interrupt flood

Description

Use this function to deactivate all activated low-latency interrupts at once.

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

thanks-feedback-gif