2023-02-22 11:02:43 +08:00
|
|
|
use alloc::{string::String, vec::Vec};
|
2020-07-09 04:32:45 +08:00
|
|
|
use core::ptr;
|
|
|
|
|
2023-02-22 11:02:43 +08:00
|
|
|
use libcortex_a9::{mutex::Mutex, semaphore::Semaphore, sync_channel};
|
|
|
|
|
2020-07-09 04:32:45 +08:00
|
|
|
use crate::eh_artiq;
|
|
|
|
|
|
|
|
mod control;
|
|
|
|
pub use control::Control;
|
|
|
|
mod api;
|
2023-02-22 11:02:43 +08:00
|
|
|
pub mod core1;
|
2020-07-21 16:57:14 +08:00
|
|
|
mod dma;
|
2023-02-22 11:02:43 +08:00
|
|
|
mod rpc;
|
2020-08-05 12:25:48 +08:00
|
|
|
pub use dma::DmaRecorder;
|
2020-07-25 17:04:40 +08:00
|
|
|
mod cache;
|
2020-07-09 04:32:45 +08:00
|
|
|
|
2020-08-04 10:15:57 +08:00
|
|
|
#[derive(Debug, Clone)]
|
2020-07-09 04:32:45 +08:00
|
|
|
pub struct RPCException {
|
2022-01-14 19:24:20 +08:00
|
|
|
pub id: u32,
|
|
|
|
pub message: u32,
|
2020-07-09 04:32:45 +08:00
|
|
|
pub param: [i64; 3],
|
2022-01-14 19:24:20 +08:00
|
|
|
pub file: u32,
|
2020-07-09 04:32:45 +08:00
|
|
|
pub line: i32,
|
|
|
|
pub column: i32,
|
2023-02-22 11:02:43 +08:00
|
|
|
pub function: u32,
|
2020-07-09 04:32:45 +08:00
|
|
|
}
|
|
|
|
|
2020-08-04 10:15:57 +08:00
|
|
|
#[derive(Debug, Clone)]
|
2020-07-09 04:32:45 +08:00
|
|
|
pub enum Message {
|
2020-08-04 10:15:57 +08:00
|
|
|
LoadRequest(Vec<u8>),
|
2020-07-09 04:32:45 +08:00
|
|
|
LoadCompleted,
|
|
|
|
LoadFailed,
|
|
|
|
StartRequest,
|
2021-12-06 17:38:55 +08:00
|
|
|
KernelFinished(u8),
|
2023-02-22 11:02:43 +08:00
|
|
|
KernelException(
|
|
|
|
&'static [Option<eh_artiq::Exception<'static>>],
|
|
|
|
&'static [eh_artiq::StackPointerBacktrace],
|
|
|
|
&'static [(usize, usize)],
|
|
|
|
u8,
|
|
|
|
),
|
|
|
|
RpcSend {
|
|
|
|
is_async: bool,
|
|
|
|
data: Vec<u8>,
|
|
|
|
},
|
2020-07-09 04:32:45 +08:00
|
|
|
RpcRecvRequest(*mut ()),
|
|
|
|
RpcRecvReply(Result<usize, RPCException>),
|
2020-08-05 12:25:48 +08:00
|
|
|
|
|
|
|
CacheGetRequest(String),
|
|
|
|
CacheGetReply(Vec<i32>),
|
|
|
|
CachePutRequest(String, Vec<i32>),
|
|
|
|
|
|
|
|
DmaPutRequest(DmaRecorder),
|
|
|
|
DmaEraseRequest(String),
|
|
|
|
DmaGetRequest(String),
|
2023-03-23 15:41:08 +08:00
|
|
|
DmaGetReply(Option<(i32, i64)>),
|
2023-03-23 17:13:34 +08:00
|
|
|
#[cfg(has_drtio)]
|
|
|
|
DmaStartRemoteRequest {
|
|
|
|
id: i32,
|
|
|
|
timestamp: i64
|
|
|
|
},
|
|
|
|
#[cfg(has_drtio)]
|
|
|
|
DmaAwaitRemoteRequest {
|
|
|
|
id: i32
|
|
|
|
},
|
|
|
|
#[cfg(has_drtio)]
|
|
|
|
DmaAwaitRemoteReply {
|
|
|
|
timeout: bool,
|
|
|
|
error: u8,
|
|
|
|
channel: u32,
|
|
|
|
timestamp: u64
|
|
|
|
},
|
2022-03-25 18:20:05 +08:00
|
|
|
|
2022-03-29 10:04:39 +08:00
|
|
|
#[cfg(has_drtio)]
|
2022-03-25 18:20:05 +08:00
|
|
|
UpDestinationsRequest(i32),
|
2022-03-29 10:04:39 +08:00
|
|
|
#[cfg(has_drtio)]
|
2022-03-25 18:20:05 +08:00
|
|
|
UpDestinationsReply(bool),
|
2020-07-09 04:32:45 +08:00
|
|
|
}
|
|
|
|
|
2020-08-04 10:15:57 +08:00
|
|
|
static CHANNEL_0TO1: Mutex<Option<sync_channel::Sender<'static, Message>>> = Mutex::new(None);
|
|
|
|
static CHANNEL_1TO0: Mutex<Option<sync_channel::Receiver<'static, Message>>> = Mutex::new(None);
|
2020-09-01 09:44:34 +08:00
|
|
|
static CHANNEL_SEM: Semaphore = Semaphore::new(0, 1);
|
2020-07-09 04:32:45 +08:00
|
|
|
|
2020-08-24 16:18:31 +08:00
|
|
|
static mut KERNEL_CHANNEL_0TO1: Option<sync_channel::Receiver<'static, Message>> = None;
|
|
|
|
static mut KERNEL_CHANNEL_1TO0: Option<sync_channel::Sender<'static, Message>> = None;
|
2020-07-24 12:24:01 +08:00
|
|
|
|
2022-01-14 19:24:20 +08:00
|
|
|
pub static mut KERNEL_IMAGE: *const core1::KernelImage = ptr::null();
|
2020-07-21 16:57:14 +08:00
|
|
|
|
2020-08-05 15:54:45 +08:00
|
|
|
static INIT_LOCK: Mutex<()> = Mutex::new(());
|