Interrupts¶
API for registering and manipulating interrupts.
Defines
-
for_each_metal_affinity
(bit, metal_affinity)¶
-
metal_affinity_set_val
(metal_affinity, val)¶
-
metal_affinity_set_bit
(metal_affinity, bit, val)¶
Typedefs
-
typedef enum metal_interrupt_controller_
metal_intr_cntrl_type
¶ Possible interrupt controllers.
-
typedef enum metal_vector_mode_
metal_vector_mode
¶ Possible mode of interrupts to operate.
-
typedef enum metal_intr_priv_mode_
metal_intr_priv_mode
¶ Possible mode of privilege interrupts to operate.
-
typedef struct metal_affinity_
metal_affinity
¶ The bitmask of hart context.
-
typedef void (*
metal_interrupt_handler_t
)(int, void*)¶ Function signature for interrupt callback handlers.
-
typedef void (*
metal_interrupt_vector_handler_t
)(void)¶
Enums
-
enum
metal_interrupt_controller_
¶ Possible interrupt controllers.
Values:
-
enumerator
METAL_CPU_CONTROLLER
¶
-
enumerator
METAL_CLINT_CONTROLLER
¶
-
enumerator
METAL_CLIC_CONTROLLER
¶
-
enumerator
METAL_PLIC_CONTROLLER
¶
-
enumerator
Functions
-
__inline__ void
metal_interrupt_init
(struct metal_interrupt *controller)¶ Initialize a given interrupt controller.
Initialize a given interrupt controller. This function must be called before any interrupts are registered or enabled with the handler. It is invalid to initialize an interrupt controller more than once.
- Parameters
controller
: The handle for the interrupt controller
-
struct metal_interrupt *
metal_interrupt_get_controller
(metal_intr_cntrl_type cntrl, int id)¶ Get the handle for an given interrupt controller type.
- Return
A handle to the interrupt controller (CLINT, CLIC, PLIC), or NULL if none is found for the requested label
- Parameters
cntrl
: The type ofinterrupt controllerid
: The instance of the interrupt controller
-
__inline__ int
metal_interrupt_set_vector_mode
(struct metal_interrupt *controller, metal_vector_mode mode)¶ Configure vector mode for an interrupt controller.
Configure vector mode for an interrupt controller. This function must be called after initialization and before configuring individual interrupts, registering ISR.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllermode
: The vector mode of the interrupt controller.
-
__inline__ metal_vector_mode
metal_interrupt_get_vector_mode
(struct metal_interrupt *controller)¶ Get vector mode of a given an interrupt controller.
Configure vector mode for an interrupt controller. This function must be called after initialization and before configuring individual interrupts, registering ISR.
- Return
The interrupt vector mode
- Parameters
controller
: The handle for the interrupt controllermode
: The vector mode of the interrupt controller.
-
__inline__ int
metal_interrupt_set_privilege
(struct metal_interrupt *controller, metal_intr_priv_mode privilege)¶ Configure privilege mode a of given interrupt controller.
Configure privilege mode for a given interrupt controller. This function must be called after initialization and before configuring individual interrupts, registering ISR.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerprivilege
: The privilege mode of the interrupt controller.
-
__inline__ metal_intr_priv_mode
metal_interrupt_get_privilege
(struct metal_interrupt *controller)¶ Get privilege mode a of given interrupt controller.
Get privilege mode for a given interrupt controller. This function must be called after initialization and before configuring individual interrupts, registering ISR.
- Return
The interrupt privilege mode
- Parameters
controller
: The handle for the interrupt controller
-
__inline__ int
metal_interrupt_clear
(struct metal_interrupt *controller, int id)¶ clear an interrupt
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to trigger
-
__inline__ int
metal_interrupt_set
(struct metal_interrupt *controller, int id)¶ Set an interrupt.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to trigger
-
__inline__ int
metal_interrupt_register_handler
(struct metal_interrupt *controller, int id, metal_interrupt_handler_t handler, void *priv_data)¶ Register an interrupt handler.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to registerhandler
: The interrupt handler callbackpriv_data
: Private data for the interrupt handler
-
__inline__ int
metal_interrupt_register_vector_handler
(struct metal_interrupt *controller, int id, metal_interrupt_vector_handler_t handler, void *priv_data)¶ Register an interrupt vector handler.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to registerhandler
: The interrupt vector handler callbackpriv_data
: Private data for the interrupt handler
-
__inline__ int
metal_interrupt_enable
(struct metal_interrupt *controller, int id)¶ Enable an interrupt.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enable
-
__inline__ int
metal_interrupt_disable
(struct metal_interrupt *controller, int id)¶ Disable an interrupt.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to disable
-
__inline__ int
metal_interrupt_set_threshold
(struct metal_interrupt *controller, unsigned int level)¶ Set interrupt threshold level.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerthreshold
: The interrupt threshold level
-
__inline__ unsigned int
metal_interrupt_get_threshold
(struct metal_interrupt *controller)¶ Get an interrupt threshold level.
- Return
The interrupt threshold level
- Parameters
controller
: The handle for the interrupt controller
-
__inline__ int
metal_interrupt_set_priority
(struct metal_interrupt *controller, int id, unsigned int priority)¶ Set an interrupt priority level.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enablepriority
: The interrupt priority level
-
__inline__ unsigned int
metal_interrupt_get_priority
(struct metal_interrupt *controller, int id)¶ Get an interrupt priority level.
- Return
The interrupt priority level
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enable
-
__inline__ int
metal_interrupt_set_preemptive_level
(struct metal_interrupt *controller, int id, unsigned int level)¶ Set preemptive level and priority for a given interrupt ID.
Set the preemptive level and priority for a given interrupt ID.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enablelevel
: The interrupt level and priority are encoded together
-
__inline__ unsigned int
metal_interrupt_get_preemptive_level
(struct metal_interrupt *controller, int id)¶ Get an interrupt preemptive level.
- Return
The interrupt level
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enable
-
__inline__ int
metal_interrupt_vector_enable
(struct metal_interrupt *controller, int id)¶ Enable an interrupt vector.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to enable
-
__inline__ int
metal_interrupt_vector_disable
(struct metal_interrupt *controller, int id)¶ Disable an interrupt vector.
- Return
0 upon success
- Parameters
controller
: The handle for the interrupt controllerid
: The interrupt ID to disable
-
__inline__ metal_affinity
metal_interrupt_affinity_enable
(struct metal_interrupt *controller, metal_affinity bitmask, int id)¶ Enable an interrupt for the hart contexts.
- Return
The result of each hart context. 0 upon success at relevant bit.
- Parameters
controller
: The handle for the interrupt controllerbitmask
: The bit mask of hart contexts to enableid
: The interrupt ID to enable
-
__inline__ metal_affinity
metal_interrupt_affinity_disable
(struct metal_interrupt *controller, metal_affinity bitmask, int id)¶ Disable an interrupt for the hart contexts.
- Return
The result of each hart context. 0 upon success at relevant bit.
- Parameters
controller
: The handle for the interrupt controllerbitmask
: The bit mask of hart contexts to disableid
: The interrupt ID to disable
-
__inline__ metal_affinity
metal_interrupt_affinity_set_threshold
(struct metal_interrupt *controller, metal_affinity bitmask, unsigned int level)¶ Set interrupt threshold level for the hart contexts.
- Return
The result of each hart context. 0 upon success at relevant bit.
- Parameters
controller
: The handle for the interrupt controllerbitmask
: The bit mask of hart contexts to set thresholdthreshold
: The interrupt threshold level
-
__inline__ unsigned int
metal_interrupt_affinity_get_threshold
(struct metal_interrupt *controller, int context_id)¶ Get an interrupt threshold level from the hart context.
- Return
The interrupt threshold level
- Parameters
controller
: The handle for the interrupt controllercontext_id
: The hart context ID to get threshold
-
struct
metal_affinity_
¶ - #include <interrupt.h>
The bitmask of hart context.
Public Members
-
unsigned long
bitmask
¶
-
unsigned long
-
struct
metal_interrupt
¶ - #include <interrupt.h>
A handle for an interrupt.