forked from Firmware/Firmwares
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.
|
||||
plic_instance_t g_plic;
|
||||
std::array<function_ptr_t,PLIC_NUM_INTERRUPTS> g_ext_interrupt_handlers;
|
||||
bool spn1_hw_interrupt{true};
|
||||
bool spn2_hw_interrupt{true};
|
||||
volatile bool spn1_hw_interrupt{true};
|
||||
volatile bool spn2_hw_interrupt{true};
|
||||
|
||||
|
||||
/*! \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() {
|
||||
// wait until HW is done
|
||||
if(spn1_hw_interrupt) {
|
||||
do{
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
while(spn1_hw_interrupt) {
|
||||
set_csr(mie, MIP_MEIP);
|
||||
asm("wfi");
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
asm("nop");
|
||||
}while(spn1_hw_interrupt);
|
||||
}
|
||||
spn1_hw_interrupt=true;
|
||||
set_csr(mie, MIP_MEIP);
|
||||
}
|
||||
|
||||
void wait_for_spn2_interrupt() {
|
||||
// wait until HW is done
|
||||
if(spn2_hw_interrupt) {
|
||||
do{
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
while(spn2_hw_interrupt) {
|
||||
set_csr(mie, MIP_MEIP);
|
||||
asm("wfi");
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
asm("nop");
|
||||
}while(spn2_hw_interrupt);
|
||||
}
|
||||
spn2_hw_interrupt=true;
|
||||
set_csr(mie, MIP_MEIP);
|
||||
}
|
||||
|
||||
void wait_for_spn_interrupts() {
|
||||
if(spn1_hw_interrupt || spn2_hw_interrupt) {
|
||||
do{
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
while(spn1_hw_interrupt || spn2_hw_interrupt) {
|
||||
set_csr(mie, MIP_MEIP);
|
||||
asm("wfi");
|
||||
asm("nop");
|
||||
}while(spn1_hw_interrupt || spn2_hw_interrupt);
|
||||
clear_csr(mie, MIP_MEIP);
|
||||
}
|
||||
spn1_hw_interrupt=true;
|
||||
spn2_hw_interrupt=true;
|
||||
set_csr(mie, MIP_MEIP);
|
||||
}
|
||||
|
||||
/*!\brief initializes platform
|
||||
|
Loading…
Reference in New Issue
Block a user