diff --git a/src/mailbox.rs b/src/mailbox.rs index 1459a2db..a258f292 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -58,15 +58,16 @@ impl OneWayMailbox { write_volatile(&mut self.pointer, 0); write_volatile(&mut self.echo, 0); } + asm::dmb(); } // send a pointer from one core to be received by the other core pub fn send(&mut self, ptr: usize) -> usize { assert!(ptr != 0); // ptr may not be the NULL-like flag - asm::dmb(); // ensure data at (ptr) has been fully written unsafe { write_volatile(&mut self.pointer, ptr); } + asm::dmb(); // ensure data at (ptr) has been fully written ptr } @@ -82,13 +83,13 @@ impl OneWayMailbox { ptr } - // return true if and only if the next self.receive() will return - // actual data rather than 0 + // return true if it is guaranteed that the next self.receive() + // will return actual data rather than 0 pub fn available(&self) -> bool { let ptr = unsafe { - asm::dmb(); read_volatile(&self.pointer) }; + asm::dmb(); ptr != 0 }