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: 780d6d152ced
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: fdfaa377dbfb
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Jan 8, 2017

  1. typo

    sbourdeauducq committed Jan 8, 2017
    Copy the full SHA
    1b49aff View commit details
  2. Copy the full SHA
    fdfaa37 View commit details
22 changes: 22 additions & 0 deletions artiq/coredevice/drtio_dbg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from artiq.language.core import syscall
from artiq.language.types import TTuple, TInt32, TInt64, TNone


@syscall(flags={"nounwind", "nowrite"})
def drtio_get_channel_state(channel: TInt32) -> TTuple([TInt32, TInt64]):
raise NotImplementedError("syscall not simulated")


@syscall(flags={"nounwind", "nowrite"})
def drtio_reset_channel_state(channel: TInt32) -> TNone:
raise NotImplementedError("syscall not simulated")


@syscall(flags={"nounwind", "nowrite"})
def drtio_get_fifo_space(channel: TInt32) -> TNone:
raise NotImplementedError("syscall not simulated")


@syscall(flags={"nounwind", "nowrite"})
def drtio_get_packet_counts() -> TTuple([TInt32, TInt32]):
raise NotImplementedError("syscall not simulated")
2 changes: 1 addition & 1 deletion artiq/coredevice/i2c.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@


class I2CError(Exception):
"""Raised with a I2C transaction fails."""
"""Raised when a I2C transaction fails."""
pass


5 changes: 5 additions & 0 deletions artiq/firmware/libksupport/api.rs
Original file line number Diff line number Diff line change
@@ -106,6 +106,11 @@ static mut API: &'static [(&'static str, *const ())] = &[
api!(rtio_input_timestamp = ::rtio::input_timestamp),
api!(rtio_input_data = ::rtio::input_data),

api!(drtio_get_channel_state = ::rtio::drtio_dbg::get_channel_state),
api!(drtio_reset_channel_state = ::rtio::drtio_dbg::reset_channel_state),
api!(drtio_get_fifo_space = ::rtio::drtio_dbg::get_fifo_space),
api!(drtio_get_packet_counts = ::rtio::drtio_dbg::get_packet_counts),

api!(i2c_start = ::i2c_start),
api!(i2c_stop = ::i2c_stop),
api!(i2c_write = ::i2c_write),
3 changes: 1 addition & 2 deletions artiq/firmware/libksupport/lib.rs
Original file line number Diff line number Diff line change
@@ -47,8 +47,6 @@ macro_rules! artiq_raise {
});
}

mod rtio;

use core::{mem, ptr, slice, str};
use std::io::Cursor;
use libc::{c_char, size_t};
@@ -91,6 +89,7 @@ macro_rules! println {

#[path = "../runtime/rpc_queue.rs"]
mod rpc_queue;
mod rtio;

#[no_mangle]
#[lang = "panic_fmt"]
33 changes: 33 additions & 0 deletions artiq/firmware/libksupport/rtio.rs
Original file line number Diff line number Diff line change
@@ -183,3 +183,36 @@ pub fn log(timestamp: i64, data: &[u8]) {

#[cfg(not(has_rtio_log))]
pub fn log(_timestamp: i64, _data: &[u8]) {}

pub mod drtio_dbg {
use ::send;
use ::recv;
use kernel_proto::*;


#[repr(C)]
pub struct ChannelState(i32, i64);

pub extern fn get_channel_state(channel: i32) -> ChannelState {
send(&DRTIOChannelStateRequest { channel: channel as u32 });
recv!(&DRTIOChannelStateReply { fifo_space, last_timestamp }
=> ChannelState(fifo_space as i32, last_timestamp as i64))
}

pub extern fn reset_channel_state(channel: i32) {
send(&DRTIOResetChannelStateRequest { channel: channel as u32 })
}

pub extern fn get_fifo_space(channel: i32) {
send(&DRTIOGetFIFOSpaceRequest { channel: channel as u32 })
}

#[repr(C)]
pub struct PacketCounts(i32, i32);

pub extern fn get_packet_counts() -> PacketCounts {
send(&DRTIOPacketCountRequest);
recv!(&DRTIOPacketCountReply { tx_cnt, rx_cnt }
=> PacketCounts(tx_cnt as i32, rx_cnt as i32))
}
}
7 changes: 7 additions & 0 deletions artiq/firmware/runtime/kernel_proto.rs
Original file line number Diff line number Diff line change
@@ -32,6 +32,13 @@ pub enum Message<'a> {

RTIOInitRequest,

DRTIOChannelStateRequest { channel: u32 },
DRTIOChannelStateReply { fifo_space: u16, last_timestamp: u64 },
DRTIOResetChannelStateRequest { channel: u32 },
DRTIOGetFIFOSpaceRequest { channel: u32 },
DRTIOPacketCountRequest,
DRTIOPacketCountReply { tx_cnt: u32, rx_cnt: u32 },

RunFinished,
RunException {
exception: Exception<'a>,
52 changes: 52 additions & 0 deletions artiq/firmware/runtime/rtio_mgt.rs
Original file line number Diff line number Diff line change
@@ -177,3 +177,55 @@ pub fn init_core() {
}
drtio::init()
}

#[cfg(has_drtio)]
pub mod drtio_dbg {
use board::csr;

pub fn get_channel_state(channel: u32) -> (u16, u64) {
unsafe {
csr::drtio::chan_sel_override_write(channel as u16);
csr::drtio::chan_sel_override_en_write(1);
let fifo_space = csr::drtio::o_dbg_fifo_space_read();
let last_timestamp = csr::drtio::o_dbg_last_timestamp_read();
csr::drtio::chan_sel_override_en_write(0);
(fifo_space, last_timestamp)
}
}

pub fn reset_channel_state(channel: u32) {
unsafe {
csr::drtio::chan_sel_override_write(channel as u16);
csr::drtio::chan_sel_override_en_write(1);
csr::drtio::o_reset_channel_status_write(1);
csr::drtio::chan_sel_override_en_write(0);
}
}

pub fn get_fifo_space(channel: u32) {
unsafe {
csr::drtio::chan_sel_override_write(channel as u16);
csr::drtio::chan_sel_override_en_write(1);
csr::drtio::o_get_fifo_space_write(1);
csr::drtio::chan_sel_override_en_write(0);
}
}

pub fn get_packet_counts() -> (u32, u32) {
unsafe {
csr::drtio::update_packet_cnt_write(1);
(csr::drtio::packet_cnt_tx_read(), csr::drtio::packet_cnt_rx_read())
}
}
}

#[cfg(not(has_drtio))]
pub mod drtio_dbg {
pub fn get_channel_state(_channel: u32) -> (u16, u64) { (0, 0) }

pub fn reset_channel_state(_channel: u32) {}

pub fn get_fifo_space(_channel: u32) {}

pub fn get_packet_counts() -> (u32, u32) { (0, 0) }
}
18 changes: 18 additions & 0 deletions artiq/firmware/runtime/session.rs
Original file line number Diff line number Diff line change
@@ -384,6 +384,24 @@ fn process_kern_message(waiter: Waiter,
kern_acknowledge()
}

&kern::DRTIOChannelStateRequest { channel } => {
let (fifo_space, last_timestamp) = rtio_mgt::drtio_dbg::get_channel_state(channel);
kern_send(waiter, &kern::DRTIOChannelStateReply { fifo_space: fifo_space,
last_timestamp: last_timestamp })
}
&kern::DRTIOResetChannelStateRequest { channel } => {
rtio_mgt::drtio_dbg::reset_channel_state(channel);
kern_acknowledge()
}
&kern::DRTIOGetFIFOSpaceRequest { channel } => {
rtio_mgt::drtio_dbg::get_fifo_space(channel);
kern_acknowledge()
}
&kern::DRTIOPacketCountRequest => {
let (tx_cnt, rx_cnt) = rtio_mgt::drtio_dbg::get_packet_counts();
kern_send(waiter, &kern::DRTIOPacketCountReply { tx_cnt: tx_cnt, rx_cnt: rx_cnt })
}

&kern::WatchdogSetRequest { ms } => {
let id = try!(session.watchdog_set.set_ms(ms)
.map_err(|()| io_error("out of watchdogs")));