Skip to content

Commit

Permalink
crates/sel4-shared-ring-buffer/smoltcp: Add can_{receive,transmit}
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Jul 11, 2024
1 parent 4fa77ad commit 8db496d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,16 @@ impl<A: AbstractBounceBufferAllocator> Inner<A> {
Ok(notify_rx || notify_tx)
}

pub(crate) fn can_receive(&mut self) -> bool {
self.can_claim_rx_buffer() && self.can_claim_tx_buffer()
}

pub(crate) fn can_transmit(&mut self) -> bool {
self.can_claim_tx_buffer()
}

pub(crate) fn receive(&mut self) -> Option<(RxBufferIndex, TxBufferIndex)> {
if self.can_claim_rx_buffer() && self.can_claim_tx_buffer() {
if self.can_receive() {
let rx = self.claim_rx_buffer().unwrap();
let tx = self.claim_tx_buffer().unwrap();
Some((rx, tx))
Expand Down
8 changes: 8 additions & 0 deletions crates/sel4-shared-ring-buffer/smoltcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ impl<A: AbstractBounceBufferAllocator> DeviceImpl<A> {
self.inner().borrow_mut().poll().unwrap()
}

pub fn can_receive(&self) -> bool {
self.inner().borrow_mut().can_receive()
}

pub fn can_transmit(&self) -> bool {
self.inner().borrow_mut().can_transmit()
}

fn new_rx_token(&self, rx_buffer: RxBufferIndex) -> RxToken<A> {
RxToken {
buffer: rx_buffer,
Expand Down

0 comments on commit 8db496d

Please sign in to comment.