diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 514e6f0..10d0e7a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -20,6 +20,11 @@ jobs: uses: actions/checkout@v2 with: submodules: true + - name: Update Rust toolchain + run: | + rustup update stable + rustup default stable + rustup component add rustfmt clippy - name: Install Miri run: | rustup toolchain install nightly --component miri diff --git a/bolos-sys/build.rs b/bolos-sys/build.rs index 2399c2f..c5cd3d7 100644 --- a/bolos-sys/build.rs +++ b/bolos-sys/build.rs @@ -3,6 +3,8 @@ use std::{env, path::PathBuf}; fn sdk_includes(target: &str) -> impl IntoIterator { [ PathBuf::from("include"), + PathBuf::from("io/include"), + PathBuf::from("io_legacy/include"), PathBuf::from("target").join(target).join("include"), PathBuf::from("lib_ux").join("include"), PathBuf::from("lib_cxng").join("include"), @@ -151,7 +153,7 @@ fn main() { .map(|path| format!("-I{}", path.display())), ) .clang_arg(format!("-I{}", sdk_path.display())) - .clang_arg(format!("-I{}/include", sdk_path.display())) + .clang_arg("-D OS_IO_SEPH_BUFFER_SIZE=272") .generate() .expect("able to generate bindings"); bindings diff --git a/zemu/build.rs b/zemu/build.rs index d3c4e17..c860671 100644 --- a/zemu/build.rs +++ b/zemu/build.rs @@ -1,4 +1,4 @@ -use std::env; +use std::{env, fs, path}; #[derive(Debug, Clone, Copy)] enum Device { @@ -24,6 +24,11 @@ fn main() { if let Some(v) = env::var_os("BOLOS_SDK") { if !v.is_empty() { + if let Ok(contents) = fs::read_to_string(path::Path::new(&v).join("Makefile.defines")) { + if contents.contains("REVAMPED_IO") { + println!("cargo:rustc-cfg=revamped_io"); + } + } match detect_device().expect("invalid or unable to retrieve TARGET_NAME") { Device::NanoS => println!("cargo:rustc-cfg=nanos"), Device::NanoX => println!("cargo:rustc-cfg=nanox"), diff --git a/zemu/src/ui.rs b/zemu/src/ui.rs index d66f81e..fe35743 100644 --- a/zemu/src/ui.rs +++ b/zemu/src/ui.rs @@ -42,7 +42,13 @@ impl Into for ViewError { } pub(crate) fn apdu_buffer_mut() -> &'static mut [u8] { - PIC::new(unsafe { &mut bolos_sys::raw::G_io_apdu_buffer }).into_inner() + PIC::new(unsafe { + cfg_if::cfg_if! { + if #[cfg(revamped_io)] { &mut bolos_sys::raw::G_io_tx_buffer } + else { &mut bolos_sys::raw::G_io_apdu_buffer } + } + }) + .into_inner() } pub(crate) fn store_into<'buf, T: Sized>(