forked from M-Labs/nac3
fix cargo fmt
This commit is contained in:
parent
ad076dd4e9
commit
6088e6bb6f
|
@ -137,7 +137,7 @@ pub enum Packet {
|
||||||
},
|
},
|
||||||
|
|
||||||
AnalyzerHeaderRequest {
|
AnalyzerHeaderRequest {
|
||||||
destination: u8
|
destination: u8,
|
||||||
},
|
},
|
||||||
AnalyzerHeader {
|
AnalyzerHeader {
|
||||||
sent_bytes: u32,
|
sent_bytes: u32,
|
||||||
|
@ -316,7 +316,7 @@ impl Packet {
|
||||||
},
|
},
|
||||||
|
|
||||||
0xa0 => Packet::AnalyzerHeaderRequest {
|
0xa0 => Packet::AnalyzerHeaderRequest {
|
||||||
destination: reader.read_u8()?
|
destination: reader.read_u8()?,
|
||||||
},
|
},
|
||||||
0xa1 => Packet::AnalyzerHeader {
|
0xa1 => Packet::AnalyzerHeader {
|
||||||
sent_bytes: reader.read_u32()?,
|
sent_bytes: reader.read_u32()?,
|
||||||
|
@ -324,7 +324,7 @@ impl Packet {
|
||||||
overflow_occurred: reader.read_bool()?,
|
overflow_occurred: reader.read_bool()?,
|
||||||
},
|
},
|
||||||
0xa2 => Packet::AnalyzerDataRequest {
|
0xa2 => Packet::AnalyzerDataRequest {
|
||||||
destination: reader.read_u8()?
|
destination: reader.read_u8()?,
|
||||||
},
|
},
|
||||||
0xa3 => {
|
0xa3 => {
|
||||||
let last = reader.read_bool()?;
|
let last = reader.read_bool()?;
|
||||||
|
@ -334,9 +334,9 @@ impl Packet {
|
||||||
Packet::AnalyzerData {
|
Packet::AnalyzerData {
|
||||||
last: last,
|
last: last,
|
||||||
length: length,
|
length: length,
|
||||||
data: data
|
data: data,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
0xb0 => {
|
0xb0 => {
|
||||||
let destination = reader.read_u8()?;
|
let destination = reader.read_u8()?;
|
||||||
|
@ -573,7 +573,7 @@ impl Packet {
|
||||||
Packet::AnalyzerHeader {
|
Packet::AnalyzerHeader {
|
||||||
sent_bytes,
|
sent_bytes,
|
||||||
total_byte_count,
|
total_byte_count,
|
||||||
overflow_occurred
|
overflow_occurred,
|
||||||
} => {
|
} => {
|
||||||
writer.write_u8(0xa1)?;
|
writer.write_u8(0xa1)?;
|
||||||
writer.write_u32(sent_bytes)?;
|
writer.write_u32(sent_bytes)?;
|
||||||
|
@ -584,11 +584,7 @@ impl Packet {
|
||||||
writer.write_u8(0xa2)?;
|
writer.write_u8(0xa2)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
Packet::AnalyzerData {
|
Packet::AnalyzerData { last, length, data } => {
|
||||||
last,
|
|
||||||
length,
|
|
||||||
data
|
|
||||||
} => {
|
|
||||||
writer.write_u8(0xa3)?;
|
writer.write_u8(0xa3)?;
|
||||||
writer.write_bool(last)?;
|
writer.write_bool(last)?;
|
||||||
writer.write_u16(length)?;
|
writer.write_u16(length)?;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use alloc::{rc::Rc, vec::Vec};
|
||||||
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use libasync::{smoltcp::TcpStream, task};
|
use libasync::{smoltcp::TcpStream, task};
|
||||||
|
use libboard_artiq::drtio_routing;
|
||||||
use libboard_zynq::{smoltcp::Error, timer::GlobalTimer};
|
use libboard_zynq::{smoltcp::Error, timer::GlobalTimer};
|
||||||
use libcortex_a9::{cache, mutex::Mutex};
|
use libcortex_a9::{cache, mutex::Mutex};
|
||||||
use log::{debug, info, warn, error};
|
use log::{debug, error, info, warn};
|
||||||
use core::cell::RefCell;
|
|
||||||
use alloc::{rc::Rc, vec::Vec};
|
|
||||||
use libboard_artiq::drtio_routing;
|
|
||||||
|
|
||||||
use crate::{pl, proto_async::*};
|
use crate::{pl, proto_async::*};
|
||||||
|
|
||||||
|
@ -49,13 +50,15 @@ pub mod remote_analyzer {
|
||||||
pub total_byte_count: u64,
|
pub total_byte_count: u64,
|
||||||
pub sent_bytes: u32,
|
pub sent_bytes: u32,
|
||||||
pub error: bool,
|
pub error: bool,
|
||||||
pub data: Vec<u8>
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_data(aux_mutex: &Rc<Mutex<bool>>,
|
pub async fn get_data(
|
||||||
|
aux_mutex: &Rc<Mutex<bool>>,
|
||||||
routing_table: &drtio_routing::RoutingTable,
|
routing_table: &drtio_routing::RoutingTable,
|
||||||
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
||||||
timer: GlobalTimer) -> Result<RemoteBuffer, &'static str> {
|
timer: GlobalTimer,
|
||||||
|
) -> Result<RemoteBuffer, &'static str> {
|
||||||
// gets data from satellites and returns consolidated data
|
// gets data from satellites and returns consolidated data
|
||||||
let mut remote_data: Vec<u8> = Vec::new();
|
let mut remote_data: Vec<u8> = Vec::new();
|
||||||
let mut remote_error = false;
|
let mut remote_error = false;
|
||||||
|
@ -64,7 +67,7 @@ pub mod remote_analyzer {
|
||||||
|
|
||||||
let data_vec = match drtio::analyzer_query(aux_mutex, routing_table, up_destinations, timer).await {
|
let data_vec = match drtio::analyzer_query(aux_mutex, routing_table, up_destinations, timer).await {
|
||||||
Ok(data_vec) => data_vec,
|
Ok(data_vec) => data_vec,
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
for data in data_vec {
|
for data in data_vec {
|
||||||
remote_total_bytes += data.total_byte_count;
|
remote_total_bytes += data.total_byte_count;
|
||||||
|
@ -77,7 +80,7 @@ pub mod remote_analyzer {
|
||||||
total_byte_count: remote_total_bytes,
|
total_byte_count: remote_total_bytes,
|
||||||
sent_bytes: remote_sent_bytes,
|
sent_bytes: remote_sent_bytes,
|
||||||
error: remote_error,
|
error: remote_error,
|
||||||
data: remote_data
|
data: remote_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,10 +104,13 @@ async fn write_header(stream: &mut TcpStream, header: &Header) -> Result<(), Err
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_connection(stream: &mut TcpStream, _aux_mutex: &Rc<Mutex<bool>>,
|
async fn handle_connection(
|
||||||
|
stream: &mut TcpStream,
|
||||||
|
_aux_mutex: &Rc<Mutex<bool>>,
|
||||||
_routing_table: &drtio_routing::RoutingTable,
|
_routing_table: &drtio_routing::RoutingTable,
|
||||||
_up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
_up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
||||||
_timer: GlobalTimer) -> Result<(), Error> {
|
_timer: GlobalTimer,
|
||||||
|
) -> Result<(), Error> {
|
||||||
info!("received connection");
|
info!("received connection");
|
||||||
|
|
||||||
let data = unsafe { &BUFFER.data[..] };
|
let data = unsafe { &BUFFER.data[..] };
|
||||||
|
@ -113,7 +119,11 @@ async fn handle_connection(stream: &mut TcpStream, _aux_mutex: &Rc<Mutex<bool>>,
|
||||||
let total_byte_count = unsafe { pl::csr::rtio_analyzer::dma_byte_count_read() as u64 };
|
let total_byte_count = unsafe { pl::csr::rtio_analyzer::dma_byte_count_read() as u64 };
|
||||||
let pointer = (total_byte_count % BUFFER_SIZE as u64) as usize;
|
let pointer = (total_byte_count % BUFFER_SIZE as u64) as usize;
|
||||||
let wraparound = total_byte_count >= BUFFER_SIZE as u64;
|
let wraparound = total_byte_count >= BUFFER_SIZE as u64;
|
||||||
let sent_bytes = if wraparound { BUFFER_SIZE as u32 } else { total_byte_count as u32 };
|
let sent_bytes = if wraparound {
|
||||||
|
BUFFER_SIZE as u32
|
||||||
|
} else {
|
||||||
|
total_byte_count as u32
|
||||||
|
};
|
||||||
|
|
||||||
if overflow_occurred {
|
if overflow_occurred {
|
||||||
warn!("overflow occured");
|
warn!("overflow occured");
|
||||||
|
@ -126,23 +136,28 @@ async fn handle_connection(stream: &mut TcpStream, _aux_mutex: &Rc<Mutex<bool>>,
|
||||||
let remote = remote_analyzer::get_data(_aux_mutex, _routing_table, _up_destinations, _timer).await;
|
let remote = remote_analyzer::get_data(_aux_mutex, _routing_table, _up_destinations, _timer).await;
|
||||||
#[cfg(has_drtio)]
|
#[cfg(has_drtio)]
|
||||||
let (header, remote_data) = match remote {
|
let (header, remote_data) = match remote {
|
||||||
Ok(remote) => (Header {
|
Ok(remote) => (
|
||||||
|
Header {
|
||||||
total_byte_count: total_byte_count + remote.total_byte_count,
|
total_byte_count: total_byte_count + remote.total_byte_count,
|
||||||
sent_bytes: sent_bytes + remote.sent_bytes,
|
sent_bytes: sent_bytes + remote.sent_bytes,
|
||||||
error_occurred: overflow_occurred | bus_error_occurred | remote.error,
|
error_occurred: overflow_occurred | bus_error_occurred | remote.error,
|
||||||
log_channel: pl::csr::CONFIG_RTIO_LOG_CHANNEL as u8,
|
log_channel: pl::csr::CONFIG_RTIO_LOG_CHANNEL as u8,
|
||||||
dds_onehot_sel: true
|
dds_onehot_sel: true,
|
||||||
}, remote.data),
|
},
|
||||||
|
remote.data,
|
||||||
|
),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error getting remote analyzer data: {}", e);
|
error!("Error getting remote analyzer data: {}", e);
|
||||||
(Header {
|
(
|
||||||
|
Header {
|
||||||
total_byte_count: total_byte_count,
|
total_byte_count: total_byte_count,
|
||||||
sent_bytes: sent_bytes,
|
sent_bytes: sent_bytes,
|
||||||
error_occurred: true,
|
error_occurred: true,
|
||||||
log_channel: pl::csr::CONFIG_RTIO_LOG_CHANNEL as u8,
|
log_channel: pl::csr::CONFIG_RTIO_LOG_CHANNEL as u8,
|
||||||
dds_onehot_sel: true
|
dds_onehot_sel: true,
|
||||||
},
|
},
|
||||||
Vec::new())
|
Vec::new(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,10 +184,12 @@ async fn handle_connection(stream: &mut TcpStream, _aux_mutex: &Rc<Mutex<bool>>,
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(aux_mutex: &Rc<Mutex<bool>>,
|
pub fn start(
|
||||||
|
aux_mutex: &Rc<Mutex<bool>>,
|
||||||
routing_table: &Rc<RefCell<drtio_routing::RoutingTable>>,
|
routing_table: &Rc<RefCell<drtio_routing::RoutingTable>>,
|
||||||
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
||||||
timer: GlobalTimer,) {
|
timer: GlobalTimer,
|
||||||
|
) {
|
||||||
let aux_mutex = aux_mutex.clone();
|
let aux_mutex = aux_mutex.clone();
|
||||||
let routing_table = routing_table.clone();
|
let routing_table = routing_table.clone();
|
||||||
let up_destinations = up_destinations.clone();
|
let up_destinations = up_destinations.clone();
|
||||||
|
|
|
@ -21,8 +21,8 @@ pub mod drtio {
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{rtio_dma::remote_dma, ASYNC_ERROR_BUSY, ASYNC_ERROR_COLLISION, ASYNC_ERROR_SEQUENCE_ERROR,
|
use crate::{analyzer::remote_analyzer::RemoteBuffer, rtio_dma::remote_dma, ASYNC_ERROR_BUSY,
|
||||||
SEEN_ASYNC_ERRORS, analyzer::remote_analyzer::RemoteBuffer};
|
ASYNC_ERROR_COLLISION, ASYNC_ERROR_SEQUENCE_ERROR, SEEN_ASYNC_ERRORS};
|
||||||
|
|
||||||
pub fn startup(
|
pub fn startup(
|
||||||
aux_mutex: &Rc<Mutex<bool>>,
|
aux_mutex: &Rc<Mutex<bool>>,
|
||||||
|
@ -527,37 +527,48 @@ pub mod drtio {
|
||||||
aux_mutex: &Rc<Mutex<bool>>,
|
aux_mutex: &Rc<Mutex<bool>>,
|
||||||
routing_table: &drtio_routing::RoutingTable,
|
routing_table: &drtio_routing::RoutingTable,
|
||||||
timer: GlobalTimer,
|
timer: GlobalTimer,
|
||||||
destination: u8
|
destination: u8,
|
||||||
) -> Result<RemoteBuffer, &'static str> {
|
) -> Result<RemoteBuffer, &'static str> {
|
||||||
let linkno = routing_table.0[destination as usize][0] - 1;
|
let linkno = routing_table.0[destination as usize][0] - 1;
|
||||||
let reply = aux_transact(
|
let reply = aux_transact(
|
||||||
aux_mutex,
|
aux_mutex,
|
||||||
linkno,
|
linkno,
|
||||||
&Packet::AnalyzerHeaderRequest { destination: destination },
|
&Packet::AnalyzerHeaderRequest {
|
||||||
|
destination: destination,
|
||||||
|
},
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let (sent, total, overflow) = match reply {
|
let (sent, total, overflow) = match reply {
|
||||||
Ok(Packet::AnalyzerHeader {
|
Ok(Packet::AnalyzerHeader {
|
||||||
sent_bytes, total_byte_count, overflow_occurred }
|
sent_bytes,
|
||||||
) => (sent_bytes, total_byte_count, overflow_occurred),
|
total_byte_count,
|
||||||
|
overflow_occurred,
|
||||||
|
}) => (sent_bytes, total_byte_count, overflow_occurred),
|
||||||
Ok(_) => return Err("received unexpected aux packet during remote analyzer header request"),
|
Ok(_) => return Err("received unexpected aux packet during remote analyzer header request"),
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut remote_data: Vec<u8> = Vec::new();
|
let mut remote_data: Vec<u8> = Vec::new();
|
||||||
if sent > 0 {
|
if sent > 0 {
|
||||||
let mut last_packet = false;
|
let mut last_packet = false;
|
||||||
while !last_packet {
|
while !last_packet {
|
||||||
let reply = aux_transact(aux_mutex, linkno,
|
let reply = aux_transact(
|
||||||
&Packet::AnalyzerDataRequest { destination: destination }, timer,).await;
|
aux_mutex,
|
||||||
|
linkno,
|
||||||
|
&Packet::AnalyzerDataRequest {
|
||||||
|
destination: destination,
|
||||||
|
},
|
||||||
|
timer,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
match reply {
|
match reply {
|
||||||
Ok(Packet::AnalyzerData { last, length, data }) => {
|
Ok(Packet::AnalyzerData { last, length, data }) => {
|
||||||
last_packet = last;
|
last_packet = last;
|
||||||
remote_data.extend(&data[0..length as usize]);
|
remote_data.extend(&data[0..length as usize]);
|
||||||
},
|
}
|
||||||
Ok(_) => return Err("received unexpected aux packet during remote analyzer data request"),
|
Ok(_) => return Err("received unexpected aux packet during remote analyzer data request"),
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,11 +577,12 @@ pub mod drtio {
|
||||||
sent_bytes: sent,
|
sent_bytes: sent,
|
||||||
total_byte_count: total,
|
total_byte_count: total,
|
||||||
error: overflow,
|
error: overflow,
|
||||||
data: remote_data
|
data: remote_data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn analyzer_query(aux_mutex: &Rc<Mutex<bool>>,
|
pub async fn analyzer_query(
|
||||||
|
aux_mutex: &Rc<Mutex<bool>>,
|
||||||
routing_table: &drtio_routing::RoutingTable,
|
routing_table: &drtio_routing::RoutingTable,
|
||||||
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
up_destinations: &Rc<RefCell<[bool; drtio_routing::DEST_COUNT]>>,
|
||||||
timer: GlobalTimer,
|
timer: GlobalTimer,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use libboard_artiq::pl::csr;
|
use libboard_artiq::{drtioaux_proto::ANALYZER_MAX_SIZE, pl::csr};
|
||||||
use libcortex_a9::cache;
|
use libcortex_a9::cache;
|
||||||
use libboard_artiq::drtioaux_proto::ANALYZER_MAX_SIZE;
|
|
||||||
|
|
||||||
const BUFFER_SIZE: usize = 512 * 1024;
|
const BUFFER_SIZE: usize = 512 * 1024;
|
||||||
|
|
||||||
|
@ -9,9 +8,7 @@ struct Buffer {
|
||||||
data: [u8; BUFFER_SIZE],
|
data: [u8; BUFFER_SIZE],
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut BUFFER: Buffer = Buffer {
|
static mut BUFFER: Buffer = Buffer { data: [0; BUFFER_SIZE] };
|
||||||
data: [0; BUFFER_SIZE]
|
|
||||||
};
|
|
||||||
|
|
||||||
fn arm() {
|
fn arm() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -36,18 +33,18 @@ fn disarm() {
|
||||||
pub struct Analyzer {
|
pub struct Analyzer {
|
||||||
// necessary for keeping track of sent data
|
// necessary for keeping track of sent data
|
||||||
sent_bytes: usize,
|
sent_bytes: usize,
|
||||||
data_iter: usize
|
data_iter: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
pub total_byte_count: u64,
|
pub total_byte_count: u64,
|
||||||
pub sent_bytes: u32,
|
pub sent_bytes: u32,
|
||||||
pub error: bool
|
pub error: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AnalyzerSliceMeta {
|
pub struct AnalyzerSliceMeta {
|
||||||
pub len: u16,
|
pub len: u16,
|
||||||
pub last: bool
|
pub last: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Analyzer {
|
impl Analyzer {
|
||||||
|
@ -56,7 +53,7 @@ impl Analyzer {
|
||||||
arm();
|
arm();
|
||||||
Analyzer {
|
Analyzer {
|
||||||
sent_bytes: 0,
|
sent_bytes: 0,
|
||||||
data_iter: 0
|
data_iter: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +68,16 @@ impl Analyzer {
|
||||||
let bus_err = unsafe { csr::rtio_analyzer::dma_bus_error_read() != 0 };
|
let bus_err = unsafe { csr::rtio_analyzer::dma_bus_error_read() != 0 };
|
||||||
let total_byte_count = unsafe { csr::rtio_analyzer::dma_byte_count_read() as u64 };
|
let total_byte_count = unsafe { csr::rtio_analyzer::dma_byte_count_read() as u64 };
|
||||||
let wraparound = total_byte_count >= BUFFER_SIZE as u64;
|
let wraparound = total_byte_count >= BUFFER_SIZE as u64;
|
||||||
self.sent_bytes = if wraparound { BUFFER_SIZE } else { total_byte_count as usize };
|
self.sent_bytes = if wraparound {
|
||||||
self.data_iter = if wraparound { (total_byte_count % BUFFER_SIZE as u64) as usize } else { 0 };
|
BUFFER_SIZE
|
||||||
|
} else {
|
||||||
|
total_byte_count as usize
|
||||||
|
};
|
||||||
|
self.data_iter = if wraparound {
|
||||||
|
(total_byte_count % BUFFER_SIZE as u64) as usize
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if overflow {
|
if overflow {
|
||||||
warn!("overflow occured");
|
warn!("overflow occured");
|
||||||
|
@ -84,14 +89,18 @@ impl Analyzer {
|
||||||
Header {
|
Header {
|
||||||
total_byte_count: total_byte_count,
|
total_byte_count: total_byte_count,
|
||||||
sent_bytes: self.sent_bytes as u32,
|
sent_bytes: self.sent_bytes as u32,
|
||||||
error: overflow | bus_err
|
error: overflow | bus_err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_data(&mut self, data_slice: &mut [u8; ANALYZER_MAX_SIZE]) -> AnalyzerSliceMeta {
|
pub fn get_data(&mut self, data_slice: &mut [u8; ANALYZER_MAX_SIZE]) -> AnalyzerSliceMeta {
|
||||||
let data = unsafe { &BUFFER.data[..] };
|
let data = unsafe { &BUFFER.data[..] };
|
||||||
let i = self.data_iter;
|
let i = self.data_iter;
|
||||||
let len = if i + ANALYZER_MAX_SIZE < self.sent_bytes { ANALYZER_MAX_SIZE } else { self.sent_bytes - i };
|
let len = if i + ANALYZER_MAX_SIZE < self.sent_bytes {
|
||||||
|
ANALYZER_MAX_SIZE
|
||||||
|
} else {
|
||||||
|
self.sent_bytes - i
|
||||||
|
};
|
||||||
let last = i + len == self.sent_bytes;
|
let last = i + len == self.sent_bytes;
|
||||||
if i + len >= BUFFER_SIZE {
|
if i + len >= BUFFER_SIZE {
|
||||||
data_slice[..len].clone_from_slice(&data[i..BUFFER_SIZE]);
|
data_slice[..len].clone_from_slice(&data[i..BUFFER_SIZE]);
|
||||||
|
@ -107,7 +116,7 @@ impl Analyzer {
|
||||||
|
|
||||||
AnalyzerSliceMeta {
|
AnalyzerSliceMeta {
|
||||||
len: len as u16,
|
len: len as u16,
|
||||||
last: last
|
last: last,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,14 @@ extern crate alloc;
|
||||||
|
|
||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use analyzer::Analyzer as Analyzer;
|
use analyzer::Analyzer;
|
||||||
use dma::Manager as DmaManager;
|
use dma::Manager as DmaManager;
|
||||||
use embedded_hal::blocking::delay::DelayUs;
|
use embedded_hal::blocking::delay::DelayUs;
|
||||||
#[cfg(feature = "target_kasli_soc")]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
use libboard_artiq::io_expander;
|
use libboard_artiq::io_expander;
|
||||||
#[cfg(has_si5324)]
|
#[cfg(has_si5324)]
|
||||||
use libboard_artiq::si5324;
|
use libboard_artiq::si5324;
|
||||||
use libboard_artiq::{drtio_routing, drtioaux, identifier_read, logger, pl::csr};
|
use libboard_artiq::{drtio_routing, drtioaux, drtioaux_proto::ANALYZER_MAX_SIZE, identifier_read, logger, pl::csr};
|
||||||
use libboard_artiq::{drtioaux_proto::ANALYZER_MAX_SIZE};
|
|
||||||
#[cfg(feature = "target_kasli_soc")]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
use libboard_zynq::error_led::ErrorLED;
|
use libboard_zynq::error_led::ErrorLED;
|
||||||
use libboard_zynq::{gic, i2c::I2c, mpcore, print, println, stdio, time::Milliseconds, timer::GlobalTimer};
|
use libboard_zynq::{gic, i2c::I2c, mpcore, print, println, stdio, time::Milliseconds, timer::GlobalTimer};
|
||||||
|
@ -40,9 +39,9 @@ use libcortex_a9::{asm, interrupt_handler,
|
||||||
use libregister::{RegisterR, RegisterW};
|
use libregister::{RegisterR, RegisterW};
|
||||||
use libsupport_zynq::ram;
|
use libsupport_zynq::ram;
|
||||||
|
|
||||||
|
mod analyzer;
|
||||||
mod dma;
|
mod dma;
|
||||||
mod repeater;
|
mod repeater;
|
||||||
mod analyzer;
|
|
||||||
|
|
||||||
fn drtiosat_reset(reset: bool) {
|
fn drtiosat_reset(reset: bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -416,24 +415,34 @@ fn process_aux_packet(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
drtioaux::Packet::AnalyzerHeaderRequest { destination: _destination } => {
|
drtioaux::Packet::AnalyzerHeaderRequest {
|
||||||
|
destination: _destination,
|
||||||
|
} => {
|
||||||
forward!(_routing_table, _destination, *_rank, _repeaters, &packet, timer);
|
forward!(_routing_table, _destination, *_rank, _repeaters, &packet, timer);
|
||||||
let header = analyzer.get_header();
|
let header = analyzer.get_header();
|
||||||
drtioaux::send(0, &drtioaux::Packet::AnalyzerHeader {
|
drtioaux::send(
|
||||||
|
0,
|
||||||
|
&drtioaux::Packet::AnalyzerHeader {
|
||||||
total_byte_count: header.total_byte_count,
|
total_byte_count: header.total_byte_count,
|
||||||
sent_bytes: header.sent_bytes,
|
sent_bytes: header.sent_bytes,
|
||||||
overflow_occurred: header.error,
|
overflow_occurred: header.error,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
drtioaux::Packet::AnalyzerDataRequest { destination: _destination } => {
|
drtioaux::Packet::AnalyzerDataRequest {
|
||||||
|
destination: _destination,
|
||||||
|
} => {
|
||||||
forward!(_routing_table, _destination, *_rank, _repeaters, &packet, timer);
|
forward!(_routing_table, _destination, *_rank, _repeaters, &packet, timer);
|
||||||
let mut data_slice: [u8; ANALYZER_MAX_SIZE] = [0; ANALYZER_MAX_SIZE];
|
let mut data_slice: [u8; ANALYZER_MAX_SIZE] = [0; ANALYZER_MAX_SIZE];
|
||||||
let meta = analyzer.get_data(&mut data_slice);
|
let meta = analyzer.get_data(&mut data_slice);
|
||||||
drtioaux::send(0, &drtioaux::Packet::AnalyzerData {
|
drtioaux::send(
|
||||||
|
0,
|
||||||
|
&drtioaux::Packet::AnalyzerData {
|
||||||
last: meta.last,
|
last: meta.last,
|
||||||
length: meta.len,
|
length: meta.len,
|
||||||
data: data_slice,
|
data: data_slice,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
drtioaux::Packet::DmaAddTraceRequest {
|
drtioaux::Packet::DmaAddTraceRequest {
|
||||||
|
@ -483,7 +492,16 @@ fn process_aux_packets(
|
||||||
) {
|
) {
|
||||||
let result = drtioaux::recv(0).and_then(|packet| {
|
let result = drtioaux::recv(0).and_then(|packet| {
|
||||||
if let Some(packet) = packet {
|
if let Some(packet) = packet {
|
||||||
process_aux_packet(repeaters, routing_table, rank, packet, timer, i2c, dma_manager, analyzer)
|
process_aux_packet(
|
||||||
|
repeaters,
|
||||||
|
routing_table,
|
||||||
|
rank,
|
||||||
|
packet,
|
||||||
|
timer,
|
||||||
|
i2c,
|
||||||
|
dma_manager,
|
||||||
|
analyzer,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue