From b1c3ee27894d33d9fcfca4ea4d0ccfb6d4cfc83e Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 16 Mar 2018 14:15:39 +0100 Subject: fixed race conditions --- code/fe310/eos/trap_entry.S | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'code/fe310/eos/trap_entry.S') diff --git a/code/fe310/eos/trap_entry.S b/code/fe310/eos/trap_entry.S index 1c164d3..7d834f6 100644 --- a/code/fe310/eos/trap_entry.S +++ b/code/fe310/eos/trap_entry.S @@ -168,7 +168,7 @@ handler_sd: xori x8, x8, 0x55 andi x8, x8, 0xff - # push to mic but + # push to mic buf la x9, _eos_i2s_mic_buf lhu x18, I2S_ABUF_OFF_IDXR(x9) lhu x19, I2S_ABUF_OFF_IDXW(x9) @@ -186,16 +186,22 @@ handler_sd: addi x19, x19, 1 sh x19, I2S_ABUF_OFF_IDXW(x9) - # push to event queue + # check for push to event queue la x9, _eos_i2s_mic_wm - lhu x20, 0(x9) + lw x20, 0(x9) beqz x20, handler_sd_exit la x9, _eos_i2s_mic_buf lhu x18, I2S_ABUF_OFF_IDXR(x9) sub x18, x19, x18 - bne x18, x20, handler_sd_exit + blt x18, x20, handler_sd_exit + + la x9, _eos_i2s_mic_rd + lw x18, 0(x9) + beqz x18, handler_sd_exit + sw x0, 0(x9) + # push to event queue la x9, _eos_event_q lbu x18, MSGQ_OFF_IDXR(x9) lbu x19, MSGQ_OFF_IDXW(x9) -- cgit v1.2.3