Skip to content

Commit

Permalink
Use Service::try_new_client to construct clients
Browse files Browse the repository at this point in the history
This reduces the dependency on Trussed internals for client creation.
  • Loading branch information
robin-nitrokey authored and nickray committed Jan 24, 2023
1 parent 20d7e56 commit 276d096
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions runners/lpc55/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include!(concat!(env!("OUT_DIR"), "/build_constants.rs"));

use crate::hal;
use hal::drivers::timer;
use interchange::Interchange;
use littlefs2::{const_ram_storage, consts};
use trussed::types::{LfsResult, LfsStorage};
use trussed::{platform, store};
Expand Down Expand Up @@ -117,21 +116,9 @@ pub trait TrussedApp: Sized {
fn with_client(trussed: TrussedClient, non_portable: Self::NonPortable) -> Self;

fn with(trussed: &mut trussed::Service<crate::Board>, non_portable: Self::NonPortable) -> Self {
let (trussed_requester, trussed_responder) = trussed::pipe::TrussedInterchange::claim()
.expect("could not setup TrussedInterchange");

let mut client_id = littlefs2::path::PathBuf::new();
client_id.push(Self::CLIENT_ID.try_into().unwrap());
assert!(trussed.add_endpoint(trussed_responder, client_id).is_ok());

let syscaller = Syscall::default();
let trussed_client = TrussedClient::new(
trussed_requester,
syscaller,
);

let app = Self::with_client(trussed_client, non_portable);
app
let client_id = core::str::from_utf8(Self::CLIENT_ID).unwrap();
let client = trussed.try_new_client(client_id, Syscall::default()).unwrap();
Self::with_client(client, non_portable)
}
}

Expand Down

0 comments on commit 276d096

Please sign in to comment.