mirror of
https://github.com/trussed-dev/pc-usbip-runner.git
synced 2026-06-20 04:16:19 -07:00
Update trussed to remove clients-? features
This patch updates trussed to remove the need for the clients-? feature and manage the endpoints in the runner instead.
This commit is contained in:
Generated
+1
-1
@@ -1453,7 +1453,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "trussed"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/trussed-dev/trussed.git?rev=6bba8fde36d05c0227769eb63345744e87d84b2b#6bba8fde36d05c0227769eb63345744e87d84b2b"
|
||||
source = "git+https://github.com/trussed-dev/trussed.git?rev=805fe7657e79e06b3220324481cd6325b94877d7#805fe7657e79e06b3220324481cd6325b94877d7"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"bitflags 2.6.0",
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ delog = { version = "0.1.6", features = ["std-log"] }
|
||||
heapless-bytes = "0.3"
|
||||
littlefs2-core = "0.1"
|
||||
pretty_env_logger = "0.4.0"
|
||||
trussed = { version = "0.1", features = ["clients-1"] }
|
||||
trussed = "0.1"
|
||||
|
||||
[features]
|
||||
default = ["ctaphid", "ccid"]
|
||||
@@ -34,4 +34,4 @@ ctaphid = ["ctaphid-dispatch", "usbd-ctaphid"]
|
||||
ccid = ["apdu-dispatch", "usbd-ccid"]
|
||||
|
||||
[patch.crates-io]
|
||||
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "6bba8fde36d05c0227769eb63345744e87d84b2b" }
|
||||
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "805fe7657e79e06b3220324481cd6325b94877d7" }
|
||||
|
||||
+16
-9
@@ -18,11 +18,12 @@ use clap::Parser;
|
||||
use clap_num::maybe_hex;
|
||||
use littlefs2_core::path;
|
||||
use trussed::{
|
||||
backend::CoreOnly,
|
||||
client::{Client, ClientBuilder},
|
||||
backend::{CoreOnly, NoId},
|
||||
client::Client,
|
||||
pipe::{ServiceEndpoint, TrussedChannel},
|
||||
service::Service,
|
||||
syscall,
|
||||
types::Vec,
|
||||
types::{CoreContext, NoData},
|
||||
virt::{self, Platform, StoreProvider},
|
||||
};
|
||||
use trussed_usbip::Syscall;
|
||||
@@ -57,7 +58,7 @@ struct DummyApp<C: Client> {
|
||||
}
|
||||
|
||||
impl<C: Client> DummyApp<C> {
|
||||
fn rng<const N: usize>(&mut self, response: &mut Vec<u8, N>) {
|
||||
fn rng<const N: usize>(&mut self, response: &mut heapless_bytes::Bytes<N>) {
|
||||
let bytes = syscall!(self.client.random_bytes(57)).bytes;
|
||||
response.extend_from_slice(&bytes).unwrap();
|
||||
}
|
||||
@@ -95,11 +96,17 @@ impl<'a, S: StoreProvider> trussed_usbip::Apps<'a, S, CoreOnly>
|
||||
{
|
||||
type Data = ();
|
||||
|
||||
fn new(service: &mut Service<Platform<S>, CoreOnly>, syscall: Syscall, _data: ()) -> Self {
|
||||
let client = ClientBuilder::new(path!("dummy"))
|
||||
.prepare(service)
|
||||
.unwrap()
|
||||
.build(syscall);
|
||||
fn new(
|
||||
_service: &mut Service<Platform<S>, CoreOnly>,
|
||||
endpoints: &mut Vec<ServiceEndpoint<'static, NoId, NoData>>,
|
||||
syscall: Syscall,
|
||||
_data: (),
|
||||
) -> Self {
|
||||
static CHANNEL: TrussedChannel = TrussedChannel::new();
|
||||
let (requester, responder) = CHANNEL.split().unwrap();
|
||||
let context = CoreContext::new(path!("dummy").into());
|
||||
endpoints.push(ServiceEndpoint::new(responder, context, &[]));
|
||||
let client = trussed_usbip::Client::new(requester, syscall, None);
|
||||
let dummy = DummyApp { client };
|
||||
Self { dummy }
|
||||
}
|
||||
|
||||
+16
-5
@@ -15,6 +15,7 @@ use std::{
|
||||
|
||||
use trussed::{
|
||||
backend::{CoreOnly, Dispatch},
|
||||
pipe::ServiceEndpoint,
|
||||
service::Service,
|
||||
virt::{self, Platform, StoreProvider},
|
||||
ClientImplementation,
|
||||
@@ -31,7 +32,7 @@ pub fn set_waiting(waiting: bool) {
|
||||
IS_WAITING.store(waiting, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
pub type Client<D = CoreOnly> = ClientImplementation<Syscall, D>;
|
||||
pub type Client<D = CoreOnly> = ClientImplementation<'static, Syscall, D>;
|
||||
|
||||
pub type InitPlatform<S> = Box<dyn Fn(&mut Platform<S>)>;
|
||||
|
||||
@@ -52,7 +53,12 @@ impl Options {
|
||||
pub trait Apps<'interrupt, S: StoreProvider, D: Dispatch> {
|
||||
type Data;
|
||||
|
||||
fn new(service: &mut Service<Platform<S>, D>, syscall: Syscall, data: Self::Data) -> Self;
|
||||
fn new(
|
||||
service: &mut Service<Platform<S>, D>,
|
||||
endpoints: &mut Vec<ServiceEndpoint<'static, D::BackendId, D::Context>>,
|
||||
syscall: Syscall,
|
||||
data: Self::Data,
|
||||
) -> Self;
|
||||
|
||||
#[cfg(feature = "ctaphid")]
|
||||
fn with_ctaphid_apps<T>(
|
||||
@@ -80,7 +86,11 @@ pub struct Runner<S: StoreProvider, D, A> {
|
||||
_marker: PhantomData<A>,
|
||||
}
|
||||
|
||||
impl<'interrupt, S: StoreProvider, D: Dispatch, A: Apps<'interrupt, S, D>> Runner<S, D, A> {
|
||||
impl<'interrupt, S: StoreProvider, D: Dispatch, A: Apps<'interrupt, S, D>> Runner<S, D, A>
|
||||
where
|
||||
D::BackendId: Send + Sync,
|
||||
D::Context: Send + Sync,
|
||||
{
|
||||
pub fn builder(store: S, options: Options) -> Builder<S> {
|
||||
Builder::new(store, options)
|
||||
}
|
||||
@@ -107,9 +117,10 @@ impl<'interrupt, S: StoreProvider, D: Dispatch, A: Apps<'interrupt, S, D>> Runne
|
||||
|
||||
let mut usb_device = build_device(&bus_allocator, &self.options);
|
||||
let mut service = Service::with_dispatch(platform, self.dispatch);
|
||||
let mut endpoints = Vec::new();
|
||||
let (syscall_sender, syscall_receiver) = mpsc::channel();
|
||||
let syscall = Syscall(syscall_sender);
|
||||
let mut apps = A::new(&mut service, syscall, data);
|
||||
let mut apps = A::new(&mut service, &mut endpoints, syscall, data);
|
||||
|
||||
log::info!("Ready for work");
|
||||
thread::scope(|s| {
|
||||
@@ -140,7 +151,7 @@ impl<'interrupt, S: StoreProvider, D: Dispatch, A: Apps<'interrupt, S, D>> Runne
|
||||
// trussed task
|
||||
s.spawn(move || {
|
||||
for _ in syscall_receiver.iter() {
|
||||
service.process()
|
||||
service.process(&mut endpoints)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user