improve interrupt handling
This commit is contained in:
parent
46f197c287
commit
02ce96eed8
Binary file not shown.
|
@ -12,8 +12,8 @@ typedef void (*function_ptr_t) (void);
|
||||||
//! Instance data for the PLIC.
|
//! Instance data for the PLIC.
|
||||||
plic_instance_t g_plic;
|
plic_instance_t g_plic;
|
||||||
std::array<function_ptr_t,PLIC_NUM_INTERRUPTS> g_ext_interrupt_handlers;
|
std::array<function_ptr_t,PLIC_NUM_INTERRUPTS> g_ext_interrupt_handlers;
|
||||||
bool spn1_hw_interrupt{true};
|
volatile bool spn1_hw_interrupt{true};
|
||||||
bool spn2_hw_interrupt{true};
|
volatile bool spn2_hw_interrupt{true};
|
||||||
|
|
||||||
|
|
||||||
/*! \brief external interrupt handler
|
/*! \brief external interrupt handler
|
||||||
|
@ -45,36 +45,40 @@ void configure_irq(size_t irq_num, function_ptr_t handler, unsigned char prio=1)
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_for_spn1_interrupt() {
|
void wait_for_spn1_interrupt() {
|
||||||
// wait until HW is done
|
clear_csr(mie, MIP_MEIP);
|
||||||
if(spn1_hw_interrupt) {
|
while(spn1_hw_interrupt) {
|
||||||
do{
|
set_csr(mie, MIP_MEIP);
|
||||||
asm("wfi");
|
asm("wfi");
|
||||||
asm("nop");
|
clear_csr(mie, MIP_MEIP);
|
||||||
}while(spn1_hw_interrupt);
|
asm("nop");
|
||||||
}
|
}
|
||||||
spn1_hw_interrupt=true;
|
spn1_hw_interrupt=true;
|
||||||
|
set_csr(mie, MIP_MEIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_for_spn2_interrupt() {
|
void wait_for_spn2_interrupt() {
|
||||||
// wait until HW is done
|
clear_csr(mie, MIP_MEIP);
|
||||||
if(spn2_hw_interrupt) {
|
while(spn2_hw_interrupt) {
|
||||||
do{
|
set_csr(mie, MIP_MEIP);
|
||||||
asm("wfi");
|
asm("wfi");
|
||||||
asm("nop");
|
clear_csr(mie, MIP_MEIP);
|
||||||
}while(spn2_hw_interrupt);
|
asm("nop");
|
||||||
}
|
}
|
||||||
spn2_hw_interrupt=true;
|
spn2_hw_interrupt=true;
|
||||||
|
set_csr(mie, MIP_MEIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_for_spn_interrupts() {
|
void wait_for_spn_interrupts() {
|
||||||
if(spn1_hw_interrupt || spn2_hw_interrupt) {
|
clear_csr(mie, MIP_MEIP);
|
||||||
do{
|
while(spn1_hw_interrupt || spn2_hw_interrupt) {
|
||||||
asm("wfi");
|
set_csr(mie, MIP_MEIP);
|
||||||
asm("nop");
|
asm("wfi");
|
||||||
}while(spn1_hw_interrupt || spn2_hw_interrupt);
|
asm("nop");
|
||||||
|
clear_csr(mie, MIP_MEIP);
|
||||||
}
|
}
|
||||||
spn1_hw_interrupt=true;
|
spn1_hw_interrupt=true;
|
||||||
spn2_hw_interrupt=true;
|
spn2_hw_interrupt=true;
|
||||||
|
set_csr(mie, MIP_MEIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!\brief initializes platform
|
/*!\brief initializes platform
|
||||||
|
|
Loading…
Reference in New Issue