summaryrefslogtreecommitdiff
path: root/code/fe310/eos/trap_entry.S
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-03-16 14:15:39 +0100
committerUros Majstorovic <majstor@majstor.org>2018-03-16 14:15:39 +0100
commitb1c3ee27894d33d9fcfca4ea4d0ccfb6d4cfc83e (patch)
tree16bfe6ba0da03cf94dec735076d2de1eac9fc761 /code/fe310/eos/trap_entry.S
parent8755ad4c0b0652f16d3505ed72ed3d8310a35c6f (diff)
fixed race conditions
Diffstat (limited to 'code/fe310/eos/trap_entry.S')
-rw-r--r--code/fe310/eos/trap_entry.S14
1 files changed, 10 insertions, 4 deletions
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)