* few cleanups

* libcortexa9 mutex behavior understood
* io.until replaced with spinlock
drtio_port
mwojcik 2021-09-20 14:41:15 +02:00
parent ff77204d37
commit 414cfd2fa7
4 changed files with 21 additions and 30 deletions

View File

@ -12,27 +12,19 @@ extern crate libconfig;
extern crate libcortex_a9; extern crate libcortex_a9;
extern crate log_buffer; extern crate log_buffer;
// has csr; taken from runtime main
#[path = "../../../build/pl.rs"] #[path = "../../../build/pl.rs"]
pub mod pl; pub mod pl;
pub mod drtioaux_proto; pub mod drtioaux_proto;
pub mod drtio_routing;
pub mod logger;
#[cfg(has_si5324)]
pub mod si5324;
#[cfg(has_drtio)] #[cfg(has_drtio)]
pub mod drtioaux; pub mod drtioaux;
// for now, memory map is only needed for DRTIO firmware
#[cfg(has_drtio)] #[cfg(has_drtio)]
#[path = "../../../build/mem.rs"] #[path = "../../../build/mem.rs"]
pub mod mem; pub mod mem;
pub mod drtio_routing;
pub mod logger;
#[cfg(has_si5324)]
pub mod si5324;
use core::{cmp, str}; use core::{cmp, str};
use libboard_zynq::slcr; use libboard_zynq::slcr;
use libregister::RegisterW; use libregister::RegisterW;

View File

@ -21,15 +21,13 @@ use void::Void;
use embedded_hal::blocking::delay::DelayMs; use embedded_hal::blocking::delay::DelayMs;
use libconfig::Config; use libconfig::Config;
use libcortex_a9::l2c::enable_l2_cache; use libcortex_a9::l2c::enable_l2_cache;
use libboard_artiq::{logger, identifier_read, init_gateware}; use libboard_artiq::{logger, identifier_read, init_gateware, pl};
#[cfg(has_si5324)] #[cfg(has_si5324)]
use libboard_artiq::si5324; use libboard_artiq::si5324;
mod proto_async; mod proto_async;
mod comms; mod comms;
mod rpc; mod rpc;
#[path = "../../../build/pl.rs"]
mod pl;
#[cfg(ki_impl = "csr")] #[cfg(ki_impl = "csr")]
#[path = "rtio_csr.rs"] #[path = "rtio_csr.rs"]
mod rtio; mod rtio;

View File

@ -61,10 +61,10 @@ enum DeviceMessage {
mod remote_moninj { mod remote_moninj {
use drtioaux; use drtioaux;
use rtio_mgt::drtio; use rtio_mgt::drtio;
use sched::{Io, Mutex}; use libcortexa9::Mutex;
pub fn read_probe(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, probe: u8) -> u32 { pub fn read_probe( aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, probe: u8) -> u32 {
let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::MonitorRequest { let reply = drtio::aux_transact(aux_mutex, linkno, &drtioaux::Packet::MonitorRequest {
destination: destination, destination: destination,
channel: channel, channel: channel,
probe: probe probe: probe
@ -77,8 +77,8 @@ mod remote_moninj {
0 0
} }
pub fn inject(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, overrd: u8, value: u8) { pub fn inject(aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, overrd: u8, value: u8) {
let _lock = aux_mutex.lock(io).unwrap(); let _lock = aux_mutex.lock();
drtioaux::send(linkno, &drtioaux::Packet::InjectionRequest { drtioaux::send(linkno, &drtioaux::Packet::InjectionRequest {
destination: destination, destination: destination,
channel: channel, channel: channel,
@ -87,8 +87,8 @@ mod remote_moninj {
}).unwrap(); }).unwrap();
} }
pub fn read_injection_status(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, overrd: u8) -> u8 { pub fn read_injection_status(aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, overrd: u8) -> u8 {
let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::InjectionStatusRequest { let reply = drtio::aux_transact(aux_mutex, linkno, &drtioaux::Packet::InjectionStatusRequest {
destination: destination, destination: destination,
channel: channel, channel: channel,
overrd: overrd overrd: overrd

View File

@ -50,7 +50,7 @@ pub mod drtio {
pub fn aux_transact(aux_mutex: &Mutex, linkno: u8, request: &drtioaux::Packet, pub fn aux_transact(aux_mutex: &Mutex, linkno: u8, request: &drtioaux::Packet,
timer: GlobalTimer) -> Result<drtioaux::Packet, &'static str> { timer: GlobalTimer) -> Result<drtioaux::Packet, &'static str> {
let _lock = aux_mutex.lock().unwrap(); let _lock = aux_mutex.lock();
drtioaux::send(linkno, request).unwrap(); drtioaux::send(linkno, request).unwrap();
recv_aux_timeout(io, linkno, 200, timer) recv_aux_timeout(io, linkno, 200, timer)
} }
@ -83,7 +83,7 @@ pub mod drtio {
} }
fn sync_tsc(aux_mutex: &Mutex, linkno: u8, timer: GlobalTimer) -> Result<(), &'static str> { fn sync_tsc(aux_mutex: &Mutex, linkno: u8, timer: GlobalTimer) -> Result<(), &'static str> {
let _lock = aux_mutex.lock().unwrap(); let _lock = aux_mutex.lock();
unsafe { unsafe {
(csr::DRTIO[linkno as usize].set_time_write)(1); (csr::DRTIO[linkno as usize].set_time_write)(1);
@ -137,7 +137,7 @@ pub mod drtio {
} }
fn process_unsolicited_aux(aux_mutex: &Mutex, linkno: u8) { fn process_unsolicited_aux(aux_mutex: &Mutex, linkno: u8) {
let _lock = aux_mutex.lock().unwrap(); let _lock = aux_mutex.lock();
match drtioaux::recv(linkno) { match drtioaux::recv(linkno) {
Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet), Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet),
Ok(None) => (), Ok(None) => (),
@ -320,15 +320,16 @@ pub mod drtio {
use super::*; use super::*;
pub fn startup(_aux_mutex: &Mutex, _routing_table: &Urc<RefCell<drtio_routing::RoutingTable>>, pub fn startup(_aux_mutex: &Mutex, _routing_table: &Urc<RefCell<drtio_routing::RoutingTable>>,
_up_destinations: &Urc<RefCell<[bool; drtio_routing::DEST_COUNT]>>, timer:GlobalTimer) {} _up_destinations: &Urc<RefCell<[bool; drtio_routing::DEST_COUNT]>>, _timer:GlobalTimer) {}
pub fn reset(_aux_mutex: &Mutex, timer: GlobalTimer) {} pub fn reset(_aux_mutex: &Mutex, _timer: GlobalTimer) {}
} }
// todo figure out what to do with these untils fn async_error_thread() {
fn async_error_thread(io: Io) {
loop { loop {
unsafe { unsafe {
io.until(|| csr::rtio_core::async_error_read() != 0).unwrap(); // replaced io.until with spinlock
while csr::rtio_core::async_error_read() != 0 {}
let errors = csr::rtio_core::async_error_read(); let errors = csr::rtio_core::async_error_read();
if errors & 1 != 0 { if errors & 1 != 0 {
error!("RTIO collision involving channel {}", error!("RTIO collision involving channel {}",