forked from M-Labs/artiq
Rust: don't crash kernel CPU when no flash kernel is present.
This commit is contained in:
parent
6bbaff81bf
commit
0cd87af386
|
@ -214,13 +214,6 @@ unsafe impl Send for WaitEvent {}
|
||||||
pub struct Waiter<'a>(&'a Yielder<WaitResult, WaitRequest, OwnedStack>);
|
pub struct Waiter<'a>(&'a Yielder<WaitResult, WaitRequest, OwnedStack>);
|
||||||
|
|
||||||
impl<'a> Waiter<'a> {
|
impl<'a> Waiter<'a> {
|
||||||
pub fn relinquish(&self) {
|
|
||||||
self.0.suspend(WaitRequest {
|
|
||||||
timeout: None,
|
|
||||||
event: None
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sleep(&self, duration: Duration) -> Result<()> {
|
pub fn sleep(&self, duration: Duration) -> Result<()> {
|
||||||
let request = WaitRequest {
|
let request = WaitRequest {
|
||||||
timeout: Some(Instant::now() + duration),
|
timeout: Some(Instant::now() + duration),
|
||||||
|
@ -242,6 +235,13 @@ impl<'a> Waiter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn relinquish(&self) -> Result<()> {
|
||||||
|
self.suspend(WaitRequest {
|
||||||
|
timeout: None,
|
||||||
|
event: None
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn join(&self, thread: ThreadHandle) -> Result<()> {
|
pub fn join(&self, thread: ThreadHandle) -> Result<()> {
|
||||||
self.suspend(WaitRequest {
|
self.suspend(WaitRequest {
|
||||||
timeout: None,
|
timeout: None,
|
||||||
|
|
|
@ -320,7 +320,7 @@ fn host_kernel_worker(waiter: Waiter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter.relinquish()
|
try!(waiter.relinquish())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,6 +330,13 @@ fn flash_kernel_worker(waiter: Waiter,
|
||||||
let mut session = Session::new(congress);
|
let mut session = Session::new(congress);
|
||||||
|
|
||||||
let kernel = config::read_to_end(config_key);
|
let kernel = config::read_to_end(config_key);
|
||||||
|
if kernel.len() == 0 {
|
||||||
|
info!("no kernel present in config key {}", config_key);
|
||||||
|
loop {
|
||||||
|
try!(waiter.relinquish())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try!(unsafe { kern_load(waiter, &mut session, &kernel) });
|
try!(unsafe { kern_load(waiter, &mut session, &kernel) });
|
||||||
try!(kern_run(&mut session));
|
try!(kern_run(&mut session));
|
||||||
|
|
||||||
|
@ -410,6 +417,6 @@ pub fn handler(waiter: Waiter, spawner: Spawner) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter.relinquish()
|
let _ = waiter.relinquish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue