Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0443f83d5ee3
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4df7941a9797
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 23, 2016

  1. runtime: print trace level log messages to UART during startup.

    There's no way to retrieve them otherwise if the startup kernel
    hangs.
    whitequark committed Nov 23, 2016
    Copy the full SHA
    cd7527b View commit details
  2. runtime: don't attempt to perform writeback if disabled in kernel.

    Otherwise, the startup kernel session hangs.
    whitequark committed Nov 23, 2016
    Copy the full SHA
    4df7941 View commit details
Showing with 23 additions and 5 deletions.
  1. +4 −1 artiq/runtime.rs/libksupport/lib.rs
  2. +17 −4 artiq/runtime.rs/src/logger.rs
  3. +2 −0 artiq/runtime.rs/src/session.rs
5 changes: 4 additions & 1 deletion artiq/runtime.rs/libksupport/lib.rs
Original file line number Diff line number Diff line change
@@ -307,7 +307,10 @@ pub unsafe fn main() {
(mem::transmute::<usize, fn()>(library.lookup("__modinit__")))();
send(&NowSave(NOW));

attribute_writeback(library.lookup("typeinfo") as *const ());
let typeinfo = library.lookup("typeinfo");
if typeinfo != 0 {
attribute_writeback(typeinfo as *const ())
}

send(&RunFinished);

21 changes: 17 additions & 4 deletions artiq/runtime.rs/src/logger.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use core::{mem, ptr};
use core::cell::RefCell;
use core::cell::{Cell, RefCell};
use log::{self, Log, LogLevel, LogMetadata, LogRecord, LogLevelFilter};
use log_buffer::LogBuffer;
use clock;

pub struct BufferLogger {
buffer: RefCell<LogBuffer<&'static mut [u8]>>
buffer: RefCell<LogBuffer<&'static mut [u8]>>,
trace_to_uart: Cell<bool>
}

unsafe impl Sync for BufferLogger {}
@@ -15,7 +16,8 @@ static mut LOGGER: *const BufferLogger = ptr::null();
impl BufferLogger {
pub fn new(buffer: &'static mut [u8]) -> BufferLogger {
BufferLogger {
buffer: RefCell::new(LogBuffer::new(buffer))
buffer: RefCell::new(LogBuffer::new(buffer)),
trace_to_uart: Cell::new(true)
}
}

@@ -48,6 +50,14 @@ impl BufferLogger {
pub fn extract<R, F: FnOnce(&str) -> R>(&self, f: F) -> R {
f(self.buffer.borrow_mut().extract())
}

pub fn disable_trace_to_uart(&self) {
if self.trace_to_uart.get() {
trace!("disabling tracing to UART; all further trace messages \
are sent to core log only");
self.trace_to_uart.set(false)
}
}
}

impl Log for BufferLogger {
@@ -61,7 +71,10 @@ impl Log for BufferLogger {
writeln!(self.buffer.borrow_mut(),
"[{:12}us] {:>5}({}): {}",
clock::get_us(), record.level(), record.target(), record.args()).unwrap();
if record.level() <= LogLevel::Info {

// Printing to UART is really slow, so avoid doing that when we have an alternative
// route to retrieve the debug messages.
if self.trace_to_uart.get() || record.level() <= LogLevel::Info {
println!("[{:12}us] {:>5}({}): {}",
clock::get_us(), record.level(), record.target(), record.args());
}
2 changes: 2 additions & 0 deletions artiq/runtime.rs/src/session.rs
Original file line number Diff line number Diff line change
@@ -583,6 +583,8 @@ pub fn thread(waiter: Waiter, spawner: Spawner) {
}
}

BufferLogger::with_instance(|logger| logger.disable_trace_to_uart());

let addr = SocketAddr::new(IP_ANY, 1381);
let listener = TcpListener::bind(waiter, addr).expect("cannot bind socket");
listener.set_keepalive(true);