runtime/rpc: use Arc to reduce copy

This commit is contained in:
pca006132 2020-09-03 13:44:29 +08:00
parent 56834f152b
commit 3a29d48900
4 changed files with 10 additions and 10 deletions

View File

@ -15,7 +15,7 @@ let
version = "0.1.0";
src = ./src;
cargoSha256 = "1r8yjzixkknivawi286iyjjhaf5q8ll3a53q54dc9m9dhx20358b";
cargoSha256 = "1q5s193qcqjcvln7zphminfdg8by3dr05zq242965bmh0q46246v";
nativeBuildInputs = [
pkgs.gnumake

10
src/Cargo.lock generated
View File

@ -187,7 +187,7 @@ dependencies = [
[[package]]
name = "libasync"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#157439bc88cbb18bb40009428acf1fdee800e32e"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#a116142f6346193f272528e68c09af5eda771c0d"
dependencies = [
"embedded-hal",
"libcortex_a9",
@ -199,7 +199,7 @@ dependencies = [
[[package]]
name = "libboard_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#157439bc88cbb18bb40009428acf1fdee800e32e"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#a116142f6346193f272528e68c09af5eda771c0d"
dependencies = [
"bit_field",
"embedded-hal",
@ -233,7 +233,7 @@ dependencies = [
[[package]]
name = "libcortex_a9"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#157439bc88cbb18bb40009428acf1fdee800e32e"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#a116142f6346193f272528e68c09af5eda771c0d"
dependencies = [
"bit_field",
"libregister",
@ -249,7 +249,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "libregister"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#157439bc88cbb18bb40009428acf1fdee800e32e"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#a116142f6346193f272528e68c09af5eda771c0d"
dependencies = [
"bit_field",
"vcell",
@ -259,7 +259,7 @@ dependencies = [
[[package]]
name = "libsupport_zynq"
version = "0.0.0"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#157439bc88cbb18bb40009428acf1fdee800e32e"
source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#a116142f6346193f272528e68c09af5eda771c0d"
dependencies = [
"compiler_builtins",
"libboard_zynq",

View File

@ -1,5 +1,5 @@
use core::ptr;
use alloc::{vec::Vec, string::String};
use alloc::{vec::Vec, string::String, sync::Arc};
use libcortex_a9::{mutex::Mutex, sync_channel, semaphore::Semaphore};
use crate::eh_artiq;
@ -32,7 +32,7 @@ pub enum Message {
StartRequest,
KernelFinished,
KernelException(&'static eh_artiq::Exception<'static>, &'static [usize]),
RpcSend { is_async: bool, data: Vec<u8> },
RpcSend { is_async: bool, data: Arc<Vec<u8>> },
RpcRecvRequest(*mut ()),
RpcRecvReply(Result<usize, RPCException>),

View File

@ -1,6 +1,6 @@
//! Kernel-side RPC API
use alloc::vec::Vec;
use alloc::{vec::Vec, sync::Arc};
use cslice::{CSlice, AsCSlice};
use crate::eh_artiq;
@ -14,7 +14,7 @@ fn rpc_send_common(is_async: bool, service: u32, tag: &CSlice<u8>, data: *const
let core1_tx = unsafe { KERNEL_CHANNEL_1TO0.as_mut().unwrap() };
let mut buffer = Vec::<u8>::new();
send_args(&mut buffer, service, tag.as_ref(), data).expect("RPC encoding failed");
core1_tx.send(Message::RpcSend { is_async, data: buffer });
core1_tx.send(Message::RpcSend { is_async, data: Arc::new(buffer) });
}
pub extern fn rpc_send(service: u32, tag: &CSlice<u8>, data: *const *const ()) {