Class InterruptController
Defined in File sim_interrupt.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public Peripheral(Class Peripheral)
Derived Types
public ArchAVR_IntCtrl(Class ArchAVR_IntCtrl)public ArchXT_IntCtrl(Class ArchXT_IntCtrl)
Class Documentation
-
class InterruptController : public Peripheral
Generic interrupt controller.
It manages an interrupt vector table that the CPU can access to know if a interrupt routine should be executed. Each interrupt vector may be allocated by a interrupt handler which controls the raise (or cancellation) of the interrupt.
The arbitration of priorities between vectors is left to concrete sub-classes.
See also
AVR_InterruptHandler
Subclassed by ArchAVR_IntCtrl, ArchXT_IntCtrl
Public Types
-
enum SignalId
Values:
-
enum State
Values:
-
enumerator State_Raised
The interrupt is raised.
-
enumerator State_Cancelled
The interrupt is cancelled.
-
enumerator State_Acknowledged
The interrupt is acknowledged by the CPU and it’s about to jump to the corresponding vector.
-
enumerator State_Returned
The CPU returned from the interrupt routine.
-
enumerator State_RaisedFromSleep
The interrupt is raised after leaving a sleep mode where it was masked.
-
enumerator State_Reset
The interrupt is reset because the MCU is reset.
-
enumerator State_Raised
Public Functions
-
explicit InterruptController(unsigned int vector_count)
Construct the controller with the given vector table size
-
virtual void reset() override
Virtual method called when the device is reset. Note that resetting I/O registers is only necessary here if their reset value is not zero.
-
virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t *data) override
Virtual method called for a CTL request. The method must return true if the request has been processed.
-
virtual void sleep(bool on, SleepMode mode) override
Virtual method called when the device enters or exits a sleep mode.
- Parameters:
on – true when entering a sleep mode, false when exiting it.
mode – one of the enum SleepMode values
-
inline bool cpu_has_irq() const
Used by the CPU to do a quick test whether an interrupt is raised.
- Returns:
true if there is an IRQ raised.
-
inline IRQ_t cpu_get_irq() const
Used by the CPU to interrogate the controller whether an interrupt is raised.
If a valid vector is returned and the Global Interrupt Enable flag is set, the CPU initiates a jump to the corresponding routine.
- Returns:
a vector index if there is an IRQ raised, AVR_INTERRUPT_NONE if not.
-
void cpu_ack_irq()
Used by the CPU to acknowledge the IRQ obtained with cpu_get_irq().
-
virtual void cpu_reti()
Called by the CPU when returning from an ISR (executing a RETI instruction).
The base implementation calls update_irq to determine the next vector to be given to the CPU.
Protected Functions
-
inline bool interrupt_raised(int_vect_t vector) const
Interrupt state getter.
-
inline int_vect_t intr_count() const
Interrupt table size getter.
-
void set_interrupt_raised(int_vect_t vector, bool raised)
Interrupt state setter.
-
virtual void cpu_ack_irq(int_vect_t vector)
Called by the CPU when it acknowledges a vector, i.e. it is about to execute the vector address in the flash.
The base implementation calls the ACK handler of the vector and raise the signal with the “Acknowledged” state.
-
virtual IRQ_t get_next_irq() const = 0
Abstract method indicating which vector should be executed next. Architecture specific behaviors can be implemented here to take into account priority arbitration between vectors.
Note
implementations should assume the GIE flag is set.
- Returns:
IRQ to be executed next or NO_INTERRUPT
-
void update_irq()
Update the controller, by storing the next vector to be given to the CPU
-
struct IRQ_t
Structure returned by the interrupt controller to the CPU containing the information of the interrupt to process.
Public Members
-
int_vect_t vector
Vector index.
-
flash_addr_t address
Address (in bytes) of the interrupt vector.
-
bool nmi
Non-maskable (by GIE) indicator flag.
-
int_vect_t vector
-
enum SignalId