firmware: workaround for RPC failures

This commit is contained in:
Sebastien Bourdeauducq 2018-11-12 19:51:54 +08:00
parent 84a6b3d09b
commit 59033d2588
3 changed files with 19 additions and 0 deletions

View File

@ -101,6 +101,7 @@ mod api;
mod rtio;
mod nrt_bus;
static mut NOW: u64 = 0;
static mut LIBRARY: Option<Library<'static>> = 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::<u32, fn()>(__modinit__))();
send(&NowSave(NOW));
if let Some(typeinfo) = typeinfo {
attribute_writeback(typeinfo as *const ());

View File

@ -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 },

View File

@ -63,6 +63,7 @@ macro_rules! unexpected {
// Persistent state
#[derive(Debug)]
struct Congress {
now: u64,
cache: Cache,
dma_manager: DmaManager,
finished_cleanly: Cell<bool>
@ -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()