ksupport: move device map to core0
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#![feature(naked_functions)]
|
||||
#![allow(unexpected_cfgs)]
|
||||
|
||||
#[cfg(has_drtio_eem)]
|
||||
extern crate alloc;
|
||||
extern crate core_io;
|
||||
extern crate crc;
|
||||
@@ -42,8 +41,14 @@ pub mod grabber;
|
||||
pub mod si5324;
|
||||
#[cfg(has_si549)]
|
||||
pub mod si549;
|
||||
use alloc::{collections::BTreeMap, string::String};
|
||||
use core::{cmp, str};
|
||||
|
||||
use byteorder::NativeEndian;
|
||||
use io::{Cursor, ProtoRead};
|
||||
use libcortex_a9::once_lock::OnceLock;
|
||||
use log::warn;
|
||||
|
||||
#[cfg(has_cxp_grabber)]
|
||||
pub mod cxp_camera_setup;
|
||||
#[cfg(has_cxp_grabber)]
|
||||
@@ -88,3 +93,50 @@ pub fn identifier_read(buf: &mut [u8]) -> &str {
|
||||
str::from_utf8_unchecked(&buf[..len as usize])
|
||||
}
|
||||
}
|
||||
|
||||
static RTIO_DEVICE_MAP: OnceLock<BTreeMap<u32, String>> = OnceLock::new();
|
||||
|
||||
fn read_device_map() -> BTreeMap<u32, String> {
|
||||
let mut device_map: BTreeMap<u32, String> = BTreeMap::new();
|
||||
let _ = libconfig::read("device_map")
|
||||
.and_then(|raw_bytes| {
|
||||
let mut bytes_cr = Cursor::new(raw_bytes);
|
||||
let size = bytes_cr.read_u32::<NativeEndian>().unwrap();
|
||||
for _ in 0..size {
|
||||
let channel = bytes_cr.read_u32::<NativeEndian>().unwrap();
|
||||
let device_name = bytes_cr.read_string::<NativeEndian>().unwrap();
|
||||
if let Some(old_entry) = device_map.insert(channel, device_name.clone()) {
|
||||
warn!(
|
||||
"conflicting device map entries for RTIO channel {}: '{}' and '{}'",
|
||||
channel, old_entry, device_name
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.or_else(|err| {
|
||||
warn!(
|
||||
"error reading device map ({}), device names will not be available in RTIO error messages",
|
||||
err
|
||||
);
|
||||
Err(err)
|
||||
});
|
||||
device_map
|
||||
}
|
||||
|
||||
pub fn resolve_channel_name(channel: u32) -> String {
|
||||
match RTIO_DEVICE_MAP
|
||||
.get()
|
||||
.expect("cannot get device map before it is set up")
|
||||
.get(&channel)
|
||||
{
|
||||
Some(val) => val.clone(),
|
||||
None => String::from("unknown"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_device_map() {
|
||||
RTIO_DEVICE_MAP
|
||||
.set(read_device_map())
|
||||
.expect("device map can only be initialized once");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use vcell::VolatileCell;
|
||||
|
||||
#[cfg(has_drtio)]
|
||||
use super::{KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0, Message};
|
||||
use crate::{artiq_raise, pl::csr, resolve_channel_name, rtio_core};
|
||||
use crate::{artiq_raise, pl::csr, rtio_core};
|
||||
|
||||
pub const RTIO_O_STATUS_WAIT: i32 = 1;
|
||||
pub const RTIO_O_STATUS_UNDERFLOW: i32 = 2;
|
||||
@@ -99,11 +99,7 @@ unsafe fn process_exceptional_status(channel: i32, status: i32) {
|
||||
if status & RTIO_O_STATUS_UNDERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOUnderflow",
|
||||
format!(
|
||||
"RTIO underflow at {{1}} mu, channel 0x{:04x}:{}, slack {{2}} mu",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO underflow at {1} mu, channel {rtio_channel_info:0}, slack {2} mu",
|
||||
channel as i64,
|
||||
timestamp,
|
||||
timestamp - get_counter()
|
||||
@@ -112,13 +108,9 @@ unsafe fn process_exceptional_status(channel: i32, status: i32) {
|
||||
if status & RTIO_O_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, output, at {{0}} mu, channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
timestamp,
|
||||
"RTIO destination unreachable, output, at {1} mu, channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
timestamp,
|
||||
0
|
||||
);
|
||||
}
|
||||
@@ -204,11 +196,7 @@ pub extern "C" fn input_timestamp(timeout: i64, channel: i32) -> i64 {
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -220,11 +208,7 @@ pub extern "C" fn input_timestamp(timeout: i64, channel: i32) -> i64 {
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -258,11 +242,7 @@ pub extern "C" fn input_data(channel: i32) -> i32 {
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -271,11 +251,7 @@ pub extern "C" fn input_data(channel: i32) -> i32 {
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -309,11 +285,7 @@ pub extern "C" fn input_timestamped_data(timeout: i64, channel: i32) -> Timestam
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -322,11 +294,7 @@ pub extern "C" fn input_timestamped_data(timeout: i64, channel: i32) -> Timestam
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
|
||||
@@ -4,7 +4,7 @@ use cslice::CSlice;
|
||||
|
||||
#[cfg(has_drtio)]
|
||||
use super::{KERNEL_CHANNEL_0TO1, KERNEL_CHANNEL_1TO0, Message};
|
||||
use crate::{artiq_raise, pl::csr, resolve_channel_name, rtio_core};
|
||||
use crate::{artiq_raise, pl::csr, rtio_core};
|
||||
|
||||
pub const RTIO_O_STATUS_WAIT: u8 = 1;
|
||||
pub const RTIO_O_STATUS_UNDERFLOW: u8 = 2;
|
||||
@@ -80,11 +80,7 @@ unsafe fn process_exceptional_status(channel: i32, status: u8) {
|
||||
if status & RTIO_O_STATUS_UNDERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOUnderflow",
|
||||
format!(
|
||||
"RTIO underflow at {{1}} mu, channel 0x{:04x}:{}, slack {{2}} mu",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO underflow at {1} mu, channel {rtio_channel_info:0}, slack {2} mu",
|
||||
channel as i64,
|
||||
timestamp,
|
||||
timestamp - get_counter()
|
||||
@@ -93,13 +89,9 @@ unsafe fn process_exceptional_status(channel: i32, status: u8) {
|
||||
if status & RTIO_O_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, output, at {{0}} mu, channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
timestamp,
|
||||
"RTIO destination unreachable, output, at {1} mu, channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
timestamp,
|
||||
0
|
||||
);
|
||||
}
|
||||
@@ -144,11 +136,7 @@ pub extern "C" fn input_timestamp(timeout: i64, channel: i32) -> i64 {
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -160,11 +148,7 @@ pub extern "C" fn input_timestamp(timeout: i64, channel: i32) -> i64 {
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -188,11 +172,7 @@ pub extern "C" fn input_data(channel: i32) -> i32 {
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -201,11 +181,7 @@ pub extern "C" fn input_data(channel: i32) -> i32 {
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -229,11 +205,7 @@ pub extern "C" fn input_timestamped_data(timeout: i64, channel: i32) -> Timestam
|
||||
if status & RTIO_I_STATUS_OVERFLOW != 0 {
|
||||
artiq_raise!(
|
||||
"RTIOOverflow",
|
||||
format!(
|
||||
"RTIO input overflow on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO input overflow on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
@@ -245,11 +217,7 @@ pub extern "C" fn input_timestamped_data(timeout: i64, channel: i32) -> Timestam
|
||||
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
|
||||
artiq_raise!(
|
||||
"RTIODestinationUnreachable",
|
||||
format!(
|
||||
"RTIO destination unreachable, input, on channel 0x{:04x}:{}",
|
||||
channel,
|
||||
resolve_channel_name(channel as u32)
|
||||
),
|
||||
"RTIO destination unreachable, input, on channel {rtio_channel_info:0}",
|
||||
channel as i64,
|
||||
0,
|
||||
0
|
||||
|
||||
@@ -8,14 +8,8 @@
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{collections::BTreeMap, string::String};
|
||||
|
||||
use byteorder::NativeEndian;
|
||||
use io::{Cursor, ProtoRead};
|
||||
use libasync::block_async;
|
||||
use libconfig;
|
||||
use libcortex_a9::once_lock::OnceLock;
|
||||
use log::{error, warn};
|
||||
use log::error;
|
||||
#[cfg(has_drtiosat)]
|
||||
pub use pl::csr::drtiosat as rtio_core;
|
||||
#[cfg(has_rtio_core)]
|
||||
|
||||
@@ -9,14 +9,15 @@ use dyld::elf;
|
||||
use futures::{future::FutureExt, select_biased};
|
||||
#[cfg(has_drtio)]
|
||||
use io::Cursor;
|
||||
use ksupport::kernel;
|
||||
#[cfg(has_drtio)]
|
||||
use ksupport::rpc;
|
||||
use ksupport::{kernel, resolve_channel_name};
|
||||
use libasync::{smoltcp::{Sockets, TcpStream},
|
||||
task};
|
||||
use libboard_artiq::drtio_routing::{self, RoutingTable};
|
||||
#[cfg(has_drtio)]
|
||||
use libboard_artiq::drtioaux::Packet;
|
||||
use libboard_artiq::{drtio_routing::{self, RoutingTable},
|
||||
resolve_channel_name};
|
||||
#[cfg(feature = "target_kasli_soc")]
|
||||
use libboard_zynq::error_led::ErrorLED;
|
||||
use libboard_zynq::{self as zynq,
|
||||
@@ -993,7 +994,7 @@ pub fn main() {
|
||||
drtio_routing::interconnect_disable_all();
|
||||
|
||||
rtio_mgt::startup(&up_destinations);
|
||||
ksupport::setup_device_map();
|
||||
libboard_artiq::setup_device_map();
|
||||
|
||||
analyzer::start(&up_destinations);
|
||||
moninj::start();
|
||||
|
||||
@@ -11,14 +11,15 @@ pub mod drtio {
|
||||
use core::fmt;
|
||||
|
||||
use ksupport::{ASYNC_ERROR_BUSY, ASYNC_ERROR_COLLISION, ASYNC_ERROR_SEQUENCE_ERROR, SEEN_ASYNC_ERRORS,
|
||||
kernel::Message as KernelMessage, resolve_channel_name};
|
||||
kernel::Message as KernelMessage};
|
||||
use libasync::task;
|
||||
#[cfg(has_drtio_eem)]
|
||||
use libboard_artiq::drtio_eem;
|
||||
use libboard_artiq::{drtioaux::Error as DrtioError,
|
||||
drtioaux_async,
|
||||
drtioaux_async::Packet,
|
||||
drtioaux_proto::{MASTER_PAYLOAD_MAX_SIZE, PayloadStatus}};
|
||||
drtioaux_proto::{MASTER_PAYLOAD_MAX_SIZE, PayloadStatus},
|
||||
resolve_channel_name};
|
||||
use libboard_zynq::timer;
|
||||
use libcortex_a9::mutex::Mutex;
|
||||
use log::{error, info, warn};
|
||||
|
||||
@@ -1079,7 +1079,7 @@ fn write_exception<W: ProtoWrite>(
|
||||
&format!(
|
||||
"0x{:04x}:{}",
|
||||
exception.param[0],
|
||||
ksupport::resolve_channel_name(exception.param[0] as u32)
|
||||
libboard_artiq::resolve_channel_name(exception.param[0] as u32)
|
||||
),
|
||||
);
|
||||
writer.write_string::<NativeEndian>(&msg)?;
|
||||
|
||||
Reference in New Issue
Block a user