diff --git a/src/runtime/src/kernel/dma.rs b/src/runtime/src/kernel/dma.rs index 63b8318..2cae479 100644 --- a/src/runtime/src/kernel/dma.rs +++ b/src/runtime/src/kernel/dma.rs @@ -167,6 +167,9 @@ pub extern "C" fn dma_playback(timestamp: i64, ptr: i32) { csr::cri_con::selected_write(1); csr::rtio_dma::enable_write(1); + #[cfg(has_drtio)] + KERNEL_CHANNEL_1TO0.as_mut().unwrap().send( + Message::DmaStartRemoteRequest{ id: ptr, timestamp: timestamp }); while csr::rtio_dma::enable_read() != 0 {} csr::cri_con::selected_write(0); @@ -194,5 +197,41 @@ pub extern "C" fn dma_playback(timestamp: i64, ptr: i32) { ); } } + #[cfg(has_drtio)] + { + KERNEL_CHANNEL_1TO0.as_mut().unwrap().send( + Message::DmaAwaitRemoteRequest(ptr)); + match KERNEL_CHANNEL_0TO1.as_mut().unwrap().recv() { + Message::DmaAwaitRemoteReply { + timeout: timeout, error: error, channel: channel, timestamp: timestamp + } => { + if timeout { + artiq_raise!( + "DMAError", + "Error running DMA on satellite device, timed out waiting for results" + ); + } + if error & 1 != 0 { + artiq_raise!( + "RTIOUnderflow", + "RTIO underflow at {1} mu, channel {rtio_channel_info:0}", + channel as i64, + timestamp as i64, + 0 + ); + } + if error & 2 != 0 { + artiq_raise!( + "RTIODestinationUnreachable", + "RTIO destination unreachable, output, at {1} mu, channel {rtio_channel_info:0}", + channel as i64, + timestamp as i64, + 0 + ); + } + } + _ => panic!("Expected DmaAwaitRemoteReply after DmaAwaitRemoteRequest!"), + } + } } } diff --git a/src/runtime/src/kernel/mod.rs b/src/runtime/src/kernel/mod.rs index 883c615..b72d311 100644 --- a/src/runtime/src/kernel/mod.rs +++ b/src/runtime/src/kernel/mod.rs @@ -59,9 +59,7 @@ pub enum Message { timestamp: i64 }, #[cfg(has_drtio)] - DmaAwaitRemoteRequest { - id: i32 - }, + DmaAwaitRemoteRequest(i32), #[cfg(has_drtio)] DmaAwaitRemoteReply { timeout: bool,