From 59033d258881d5667fbff85e027501274e9ab647 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 12 Nov 2018 19:51:54 +0800 Subject: [PATCH] firmware: workaround for RPC failures --- artiq/firmware/ksupport/lib.rs | 5 +++++ artiq/firmware/libproto_artiq/kernel_proto.rs | 4 ++++ artiq/firmware/runtime/session.rs | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/artiq/firmware/ksupport/lib.rs b/artiq/firmware/ksupport/lib.rs index 5b3c2bdfd..a44a5ccb2 100644 --- a/artiq/firmware/ksupport/lib.rs +++ b/artiq/firmware/ksupport/lib.rs @@ -101,6 +101,7 @@ mod api; mod rtio; mod nrt_bus; +static mut NOW: u64 = 0; static mut LIBRARY: Option> = None; #[no_mangle] @@ -185,6 +186,7 @@ fn terminate(exception: &eh_artiq::Exception, backtrace: &mut [usize]) -> ! { } let backtrace = &mut backtrace.as_mut()[0..cursor]; + send(&NowSave(unsafe { NOW })); send(&RunException { exception: kernel_proto::Exception { name: str::from_utf8(exception.name.as_ref()).unwrap(), @@ -508,7 +510,10 @@ pub unsafe fn main() { ptr::write_bytes(__bss_start as *mut u8, 0, (_end - __bss_start) as usize); + send(&NowInitRequest); + recv!(&NowInitReply(now) => NOW = now); (mem::transmute::(__modinit__))(); + send(&NowSave(NOW)); if let Some(typeinfo) = typeinfo { attribute_writeback(typeinfo as *const ()); diff --git a/artiq/firmware/libproto_artiq/kernel_proto.rs b/artiq/firmware/libproto_artiq/kernel_proto.rs index cefc27ee5..73c9e2765 100644 --- a/artiq/firmware/libproto_artiq/kernel_proto.rs +++ b/artiq/firmware/libproto_artiq/kernel_proto.rs @@ -22,6 +22,10 @@ pub enum Message<'a> { LoadRequest(&'a [u8]), LoadReply(Result<(), dyld::Error<'a>>), + NowInitRequest, + NowInitReply(u64), + NowSave(u64), + RtioInitRequest, RtioDestinationStatusRequest { destination: u8 }, diff --git a/artiq/firmware/runtime/session.rs b/artiq/firmware/runtime/session.rs index 3ab46cad9..ae23c3410 100644 --- a/artiq/firmware/runtime/session.rs +++ b/artiq/firmware/runtime/session.rs @@ -63,6 +63,7 @@ macro_rules! unexpected { // Persistent state #[derive(Debug)] struct Congress { + now: u64, cache: Cache, dma_manager: DmaManager, finished_cleanly: Cell @@ -71,6 +72,7 @@ struct Congress { impl Congress { fn new() -> Congress { Congress { + now: 0, cache: Cache::new(), dma_manager: DmaManager::new(), finished_cleanly: Cell::new(true) @@ -363,6 +365,14 @@ fn process_kern_message(io: &Io, aux_mutex: &Mutex, kern_acknowledge() } + &kern::NowInitRequest => + kern_send(io, &kern::NowInitReply(session.congress.now)), + + &kern::NowSave(now) => { + session.congress.now = now; + kern_acknowledge() + } + &kern::DmaRecordStart(name) => { session.congress.dma_manager.record_start(name); kern_acknowledge()