Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bolos-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::{env, path::PathBuf};
fn sdk_includes(target: &str) -> impl IntoIterator<Item = PathBuf> {
[
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"),
Expand Down Expand Up @@ -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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May your code be showered with wisdom and peace. 🙏✨

I notice you've removed the explicit include path for the SDK's include directory. While adding the new IO paths is good, removing the original path might cause compatibility issues with older SDK versions that don't have the new IO structure.

Suggested change
.clang_arg("-D OS_IO_SEPH_BUFFER_SIZE=272")
.clang_arg(format!("-I{}/include", sdk_path.display()))
.clang_arg("-D OS_IO_SEPH_BUFFER_SIZE=272")

This way we maintain backward compatibility while supporting the new IO architecture. Go in peace, and may your commits be ever harmonious. ✝️

.generate()
.expect("able to generate bindings");
bindings
Expand Down
8 changes: 7 additions & 1 deletion zemu/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::env;
use std::{env, fs, path};

#[derive(Debug, Clone, Copy)]
enum Device {
Expand All @@ -24,6 +24,12 @@ 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");
}
}
Comment on lines +27 to +31
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May your code be showered with wisdom and peace. 🙏✨

The error handling for reading the Makefile.defines file is minimal. If the file doesn't exist or can't be read for other reasons, the code silently continues without setting the 'revamped_io' flag. Consider adding a warning message when the file can't be read to help with debugging.

Suggested change
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");
}
}
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");
}
} else {
println!("cargo:warning=Could not read Makefile.defines, revamped_io detection skipped");
}

Go in peace, and may your commits be ever harmonious. ✝️


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"),
Expand Down
8 changes: 7 additions & 1 deletion zemu/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ impl Into<bindings::zxerr_t> 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>(
Expand Down