From d400c80ecf0d06c70ecd6e7eda68a9b372aad230 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 6 Aug 2025 14:38:53 +0800 Subject: [PATCH 1/2] redox_hwio: Build from crates.io on non-FreeBSD Signed-off-by: Daniel Schaefer --- Cargo.lock | 12 +++++++++++- framework_lib/Cargo.toml | 9 +++++++-- framework_lib/src/chromium_ec/portio.rs | 4 +++- framework_lib/src/chromium_ec/portio_mec.rs | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be5f5f4d..7d5478f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,7 +426,8 @@ dependencies = [ "num-derive", "num-traits", "plain", - "redox_hwio", + "redox_hwio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_hwio 0.1.6 (git+https://github.com/FrameworkComputer/rust-hwio?branch=freebsd)", "regex", "rusb", "sha2", @@ -995,6 +996,15 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_hwio" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb516ad341a84372b5b15a5a35cf136ba901a639c8536f521b108253d7fce74" +dependencies = [ + "lazy_static", +] + [[package]] name = "redox_hwio" version = "0.1.6" diff --git a/framework_lib/Cargo.toml b/framework_lib/Cargo.toml index 162538f4..bc1fa8b6 100644 --- a/framework_lib/Cargo.toml +++ b/framework_lib/Cargo.toml @@ -40,7 +40,7 @@ guid-create = { version = "0.5.0", default-features = false } uefi = { version = "0.20", features = ["alloc"] } uefi-services = "0.17" plain = "0.2.3" -redox_hwio = { git = "https://github.com/FrameworkComputer/rust-hwio", branch = "freebsd", default-features = false } +redox_hwio = { version = "0.1.6", default-features = false } smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std", default-features = false } [target.'cfg(windows)'.dependencies] @@ -56,13 +56,18 @@ winreg = "0.55.0" [target.'cfg(unix)'.dependencies] libc = "0.2.155" nix = { version = "0.29.0", features = ["ioctl", "user"] } -redox_hwio = { git = "https://github.com/FrameworkComputer/rust-hwio", branch = "freebsd" } smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std" } env_logger = "0.11" clap = { version = "4.5", features = ["derive", "cargo"] } clap-num = { version = "1.2.0" } clap-verbosity-flag = { version = "2.2.1" } +[target.'cfg(target_os="linux")'.dependencies] +redox_hwio = "0.1.6" + +[target.'cfg(target_os="freebsd")'.dependencies] +redox_hwio_freebsd = { package = "redox_hwio", git = "https://github.com/FrameworkComputer/rust-hwio", branch = "freebsd" } + [target.'cfg(windows)'.dependencies.windows] version = "0.59.0" features = [ diff --git a/framework_lib/src/chromium_ec/portio.rs b/framework_lib/src/chromium_ec/portio.rs index d76f8a6b..3b55dda5 100644 --- a/framework_lib/src/chromium_ec/portio.rs +++ b/framework_lib/src/chromium_ec/portio.rs @@ -4,8 +4,10 @@ use alloc::string::ToString; use alloc::vec; use alloc::vec::Vec; use core::convert::TryInto; -#[cfg(not(windows))] +#[cfg(all(not(windows), not(target_os = "freebsd")))] use hwio::{Io, Pio}; +#[cfg(target_os = "freebsd")] +use hwio_freebsd::{Io, Pio}; #[cfg(target_os = "linux")] use libc::ioperm; use log::Level; diff --git a/framework_lib/src/chromium_ec/portio_mec.rs b/framework_lib/src/chromium_ec/portio_mec.rs index 1f855d0f..0cbd3bca 100644 --- a/framework_lib/src/chromium_ec/portio_mec.rs +++ b/framework_lib/src/chromium_ec/portio_mec.rs @@ -4,7 +4,10 @@ use alloc::vec::Vec; use log::Level; +#[cfg(all(not(windows), not(target_os = "freebsd")))] use hwio::{Io, Pio}; +#[cfg(target_os = "freebsd")] +use hwio_freebsd::{Io, Pio}; #[cfg(target_os = "linux")] use libc::ioperm; From 047b35103325a5bef403e8d94a2835bd3c0193fb Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 6 Aug 2025 14:43:12 +0800 Subject: [PATCH 2/2] smbioslib: Build from crates.io on non-UEFI Signed-off-by: Daniel Schaefer --- Cargo.lock | 59 ++++++++++++++++++++++++---- framework_lib/Cargo.toml | 6 +-- framework_lib/src/commandline/mod.rs | 3 ++ framework_lib/src/smbios.rs | 3 ++ 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d5478f9..da2e8569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,6 +256,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys 0.8.7", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.6.2" @@ -264,9 +274,9 @@ checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" @@ -431,7 +441,8 @@ dependencies = [ "regex", "rusb", "sha2", - "smbios-lib", + "smbios-lib 0.9.1", + "smbios-lib 0.9.2", "spin 0.9.8", "uefi", "uefi-services", @@ -630,7 +641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", - "core-foundation-sys 0.8.4", + "core-foundation-sys 0.8.7", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", @@ -677,6 +688,16 @@ dependencies = [ "mach 0.2.3", ] +[[package]] +name = "io-kit-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +dependencies = [ + "core-foundation-sys 0.8.7", + "mach2", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -801,6 +822,15 @@ dependencies = [ "libc", ] +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + [[package]] name = "memchr" version = "2.7.2" @@ -1154,10 +1184,9 @@ name = "smbios-lib" version = "0.9.1" source = "git+https://github.com/FrameworkComputer/smbios-lib.git?branch=no-std#b3e2fff8a6f4b8c2d729467cbbf0c8c41974cd1c" dependencies = [ - "core-foundation", + "core-foundation 0.6.4", "core-foundation-sys 0.6.2", - "getopts", - "io-kit-sys", + "io-kit-sys 0.1.0", "libc", "mach 0.3.2", "no-std-compat", @@ -1165,6 +1194,22 @@ dependencies = [ "serde_json", ] +[[package]] +name = "smbios-lib" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c18320ad3d997a100cb948fc020111936c530eddfde947f467083730e39e72" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys 0.8.7", + "getopts", + "io-kit-sys 0.4.1", + "libc", + "mach2", + "serde", + "serde_json", +] + [[package]] name = "spin" version = "0.5.2" diff --git a/framework_lib/Cargo.toml b/framework_lib/Cargo.toml index bc1fa8b6..3f2a48ca 100644 --- a/framework_lib/Cargo.toml +++ b/framework_lib/Cargo.toml @@ -41,11 +41,11 @@ uefi = { version = "0.20", features = ["alloc"] } uefi-services = "0.17" plain = "0.2.3" redox_hwio = { version = "0.1.6", default-features = false } -smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std", default-features = false } +smbios-lib-no-std = { package = "smbios-lib", git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std", default-features = false } [target.'cfg(windows)'.dependencies] wmi = "0.15.0" -smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std" } +smbios-lib = "0.9.2" env_logger = "0.11" clap = { version = "4.5", features = ["derive", "cargo"] } clap-num = { version = "1.2.0" } @@ -56,7 +56,7 @@ winreg = "0.55.0" [target.'cfg(unix)'.dependencies] libc = "0.2.155" nix = { version = "0.29.0", features = ["ioctl", "user"] } -smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std" } +smbios-lib = "0.9.2" env_logger = "0.11" clap = { version = "4.5", features = ["derive", "cargo"] } clap-num = { version = "1.2.0" } diff --git a/framework_lib/src/commandline/mod.rs b/framework_lib/src/commandline/mod.rs index dab66c02..6c3bd743 100644 --- a/framework_lib/src/commandline/mod.rs +++ b/framework_lib/src/commandline/mod.rs @@ -70,6 +70,9 @@ use crate::util::{self, Config, Platform, PlatformFamily}; use hidapi::HidApi; use sha2::{Digest, Sha256, Sha384, Sha512}; //use smbioslib::*; +#[cfg(feature = "uefi")] +use smbios_lib_no_std::{DefinedStruct, SMBiosInformation}; +#[cfg(not(feature = "uefi"))] use smbioslib::{DefinedStruct, SMBiosInformation}; use crate::chromium_ec::{CrosEc, CrosEcDriverType, HardwareDeviceType}; diff --git a/framework_lib/src/smbios.rs b/framework_lib/src/smbios.rs index a55b8eff..a61e71a0 100644 --- a/framework_lib/src/smbios.rs +++ b/framework_lib/src/smbios.rs @@ -9,6 +9,9 @@ use crate::util::Config; pub use crate::util::{Platform, PlatformFamily}; use num_derive::FromPrimitive; use num_traits::FromPrimitive; +#[cfg(feature = "uefi")] +use smbios_lib_no_std::*; +#[cfg(not(feature = "uefi"))] use smbioslib::*; #[cfg(feature = "uefi")] use spin::Mutex;