diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc6a0f8b..622456ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,27 +3,6 @@ on: push: jobs: - build-freebsd: - permissions: - contents: read - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Build - id: test - uses: vmactions/freebsd-vm@v1 - with: - release: "15.0" - arch: x86_64 - usesh: true - mem: 8192 - sync: rsync - prepare: | - pkg install -y rust hidapi pkgconf - run: | - cargo build -p framework_lib - cargo build -p framework_tool - build: name: Build Linux runs-on: ubuntu-24.04 diff --git a/CLAUDE.md b/CLAUDE.md index a27cc3aa..d3e3cf69 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -Framework System is a Rust library and CLI tool for interacting with Framework Computer hardware. It targets Linux, Windows, UEFI, and FreeBSD. The MSRV is 1.81. +Framework System is a Rust library and CLI tool for interacting with Framework Computer hardware. It targets Linux, Windows, and UEFI. The MSRV is 1.81. ## Development and Testing advice @@ -12,7 +12,7 @@ Most commands must be run as root, try to run them with sudo, usually I have fin By default build in debug mode that's way faster than `--release` builds. On every commit all builds, lints and tests must keep working. -We also must not break other platforms (Windows, Linux, FreeBSD, UEFI). +We also must not break other platforms (Windows, Linux, UEFI). ## Build Commands @@ -53,7 +53,7 @@ cargo run -- --completions fish > completions/fish/framework_tool.fish ### Key Modules in framework_lib -- `chromium_ec/` — Chrome EC controller communication. Multiple driver backends: `cros_ec` (Linux kernel), `portio` (direct I/O for UEFI/FreeBSD), `windows` (Windows driver). Commands defined in `commands.rs`. +- `chromium_ec/` — Chrome EC controller communication. Multiple driver backends: `cros_ec` (Linux kernel), `portio` (direct I/O for UEFI), `windows` (Windows driver). Commands defined in `commands.rs`. - `ccgx/` — USB Power Delivery controller (CCG5/CCG6/CCG8) firmware parsing and device management. `binary.rs` handles firmware binary parsing. - `commandline/` — CLI implementation. `clap_std.rs` for std platforms (uses clap), `uefi.rs` for UEFI-specific parsing. - `smbios.rs` — SMBIOS table parsing for hardware identification. @@ -63,7 +63,7 @@ cargo run -- --completions fish > completions/fish/framework_tool.fish ### Platform Abstraction Patterns -- **OS-level:** `#[cfg(target_os = "linux")]`, `#[cfg(windows)]`, `#[cfg(target_os = "freebsd")]` +- **OS-level:** `#[cfg(target_os = "linux")]`, `#[cfg(windows)]` - **Feature-level:** `#[cfg(feature = "rusb")]`, `#[cfg(feature = "hidapi")]`, `#[cfg(feature = "uefi")]` - **no_std compatibility:** UEFI builds use `#![no_std]` with `alloc`. `lazy_static` uses `spin::Mutex` for no_std, `std::sync::Mutex` for std. Custom `no_std_compat` wrapper bridges standard library types. @@ -78,11 +78,11 @@ cargo run -- --completions fish > completions/fish/framework_tool.fish ### Custom Dependency Forks -The project patches `uefi`, `uefi-services`, and uses custom forks of `smbios-lib` and `rust-hwio` for no_std/FreeBSD support. See `[patch.crates-io]` in the root Cargo.toml. +The project uses a custom fork of `smbios-lib` for no_std/UEFI support. See `[patch.crates-io]` in the root Cargo.toml. This can be removed once upstream `smbios-lib` supports no_std. ## CI Pipeline -Runs on every push: Linux build, Windows build, UEFI build, FreeBSD build, tests, lints (clippy + fmt), doc generation. CI also verifies shell completions are up-to-date and that no untracked changes are introduced by the build. +Runs on every push: Linux build, Windows build, UEFI build, tests, lints (clippy + fmt), doc generation. CI also verifies shell completions are up-to-date and that no untracked changes are introduced by the build. ## Test Binaries diff --git a/Cargo.lock b/Cargo.lock index b05b2ec6..8aff57fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -229,12 +229,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.6.4" @@ -311,19 +305,6 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "derive_more" -version = "0.99.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.114", -] - [[package]] name = "digest" version = "0.10.7" @@ -424,7 +405,7 @@ dependencies = [ "lazy_static", "libc", "log", - "nix 0.30.1", + "nix", "no-std-compat", "num", "num-derive", @@ -947,29 +928,6 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset", - "pin-utils", -] - [[package]] name = "nix" version = "0.30.1" @@ -1196,10 +1154,10 @@ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "redox_hwio" version = "0.1.6" -source = "git+https://github.com/FrameworkComputer/rust-hwio?branch=freebsd#9bcff4277d8f3d7dce2b12c6ad81d092ae35c4ba" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb516ad341a84372b5b15a5a35cf136ba901a639c8536f521b108253d7fce74" dependencies = [ "lazy_static", - "nix 0.25.1", ] [[package]] @@ -1544,10 +1502,10 @@ dependencies = [ [[package]] name = "uefi" version = "0.20.0" -source = "git+https://github.com/FrameworkComputer/uefi-rs?branch=merged#95165e1adde99da7a460320538d908af8b55f87f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab39d5e7740f21ed4c46d6659f31038bbe3fe7a8be1f702d8a984348837c43b1" dependencies = [ "bitflags 1.3.2", - "derive_more", "log", "ptr_meta", "ucs2", @@ -1568,7 +1526,8 @@ dependencies = [ [[package]] name = "uefi-services" version = "0.17.0" -source = "git+https://github.com/FrameworkComputer/uefi-rs?branch=merged#95165e1adde99da7a460320538d908af8b55f87f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d8ffbcc532083312224b4540737c1102ede6a81360fa9320a60deff329a3a1" dependencies = [ "cfg-if", "log", diff --git a/Cargo.toml b/Cargo.toml index d8108e1b..c7367839 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,9 @@ default-members = [ ] [patch.crates-io] -uefi = { git = "https://github.com/FrameworkComputer/uefi-rs", branch = "merged" } -uefi-services = { git = "https://github.com/FrameworkComputer/uefi-rs", branch = "merged" } +# The crates.io smbios-lib requires std; this fork adds no_std support needed for UEFI builds. +# Can be removed once upstream smbios-lib supports no_std. +smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std" } [profile.release] lto = true diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index 00c22186..00000000 --- a/Cross.toml +++ /dev/null @@ -1,7 +0,0 @@ -[target.x86_64-unknown-freebsd] -image = "ghcr.io/cross-rs/x86_64-unknown-freebsd:main" -pre-build = [""" -export FREEBSD_MIRROR=$(/freebsd-fetch-best-mirror.sh) && -/freebsd-setup-packagesite.sh && -/freebsd-install-package.sh hidapi -"""] diff --git a/README.md b/README.md index 2d1641ca..58876084 100644 --- a/README.md +++ b/README.md @@ -41,9 +41,7 @@ winget install framework_tool ### FreeBSD -``` -sudo pkg install framework-system -``` +> **Note:** FreeBSD support has been dropped. Use Linux or Windows instead. ## Features @@ -57,11 +55,10 @@ The following operating environments are supported. - Linux - Windows - UEFI -- FreeBSD Most functionality depends communication with the EC. For Linux and Windows there are dedicated drivers. -On UEFI and FreeBSD raw port I/O is used - on Linux this can also be used as a fallback, if the driver is not available or not working. +On UEFI raw port I/O is used - on Linux this can also be used as a fallback, if the driver is not available or not working. | | Port I/O | Linux | Windows | |---------------------|----------| ------|---------| @@ -83,7 +80,7 @@ On UEFI and FreeBSD raw port I/O is used - on Linux this can also be used as a f ###### Firmware Information - [x] Show system information - - [x] ESRT table (UEFI, Linux, FreeBSD only) (`--esrt`) + - [x] ESRT table (UEFI, Linux only) (`--esrt`) - [x] SMBIOS - [x] Get firmware version from binary file - [x] EC (Legacy and Zephyr based) (`--ec-bin`) @@ -104,8 +101,8 @@ On UEFI and FreeBSD raw port I/O is used - on Linux this can also be used as a f - [x] PD Controller - [x] ME (Only on Linux) - [x] Retimer - - [x] Touchpad (Linux, Windows, FreeBSD, not UEFI) - - [x] Touchscreen (Linux, Windows, FreeBSD, not UEFI) + - [x] Touchpad (Linux, Windows, not UEFI) + - [x] Touchscreen (Linux, Windows, not UEFI) - [x] Get Expansion Card Firmware (Not on UEFI so far) - [x] HDMI Expansion Card (`--dp-hdmi-info`) - [x] DisplayPort Expansion Card (`--dp-hdmi-info`) @@ -145,7 +142,6 @@ All of these need EC communication support in order to work. - [x] Framework Desktop (AMD Ryzen AI Max 300) - [x] Port I/O communication on Linux - [x] Port I/O communication in UEFI -- [x] Port I/O communication on FreeBSD - [x] Using `cros_ec` driver in Linux kernel - [x] Using [Framework EC Windows driver](https://github.com/FrameworkComputer/crosecbus) based on [coolstar's](https://github.com/coolstar/crosecbus) - [x] Using [DHowett's Windows CrosEC driver](https://github.com/DHowett/FrameworkWindowsUtils) @@ -174,9 +170,6 @@ nix develop # Fedora sudo dnf install systemd-devel hidapi-devel -# FreeBSD -sudo pkg install rust hidapi pkgconf - # Ubuntu sudo apt install rustup build-essential libhidapi-dev libsystemd-dev libudev-dev libusb-1.0-0-dev pkg-config ``` diff --git a/flake.nix b/flake.nix index c42a9162..0e3e1973 100644 --- a/flake.nix +++ b/flake.nix @@ -85,9 +85,7 @@ # Git dependency output hashes gitDependencyHashes = { - "redox_hwio-0.1.6" = "sha256-knLIZ7yp42SQYk32NGq3SUGvJFVumFhD64Njr5TRdFs="; "smbios-lib-0.9.1" = "sha256-3L8JaA75j9Aaqg1z9lVs61m6CvXDeQprEFRq+UDCHQo="; - "uefi-0.20.0" = "sha256-2lUd2a+7NvS94LyAHE2BwGV4j6607mbPXE5htrwdz04="; }; # Build function for the CLI tool (Linux/macOS) diff --git a/framework_lib/Cargo.toml b/framework_lib/Cargo.toml index 3ab8a043..c4f7f6c4 100644 --- a/framework_lib/Cargo.toml +++ b/framework_lib/Cargo.toml @@ -40,12 +40,12 @@ 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 } -smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std", default-features = false } +redox_hwio = { version = "0.1.6", default-features = false } +smbios-lib = { version = "0.9.1", default-features = false } [target.'cfg(windows)'.dependencies] wmi = "0.18" -smbios-lib = { git = "https://github.com/FrameworkComputer/smbios-lib.git", branch = "no-std" } +smbios-lib = "0.9.1" env_logger = "0.11" clap = { version = "4.5", features = ["derive", "cargo"] } clap-num = { version = "1.2.0" } @@ -58,8 +58,8 @@ nvml-wrapper = { version = "0.11.0", optional = true } [target.'cfg(unix)'.dependencies] libc = "0.2.155" nix = { version = "0.30", 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" } +redox_hwio = "0.1.6" +smbios-lib = "0.9.1" env_logger = "0.11" clap = { version = "4.5", features = ["derive", "cargo"] } clap-num = { version = "1.2.0" } diff --git a/framework_lib/src/ccgx/hid.rs b/framework_lib/src/ccgx/hid.rs index c36aeebb..da23212f 100644 --- a/framework_lib/src/ccgx/hid.rs +++ b/framework_lib/src/ccgx/hid.rs @@ -266,12 +266,7 @@ pub fn find_devices(api: &HidApi, filter_devs: &[u16], sn: Option<&str>) -> Vec< let usage_page = dev_info.usage_page(); debug!("Found {:X}:{:X} Usage Page: {}", vid, pid, usage_page); - #[cfg(not(target_os = "freebsd"))] let usage_page_filter = usage_page == CCG_USAGE_PAGE; - // On FreeBSD it seems we don't get different usage pages - // There's just one entry overall - #[cfg(target_os = "freebsd")] - let usage_page_filter = true; if vid == FRAMEWORK_VID && filter_devs.contains(&pid) diff --git a/framework_lib/src/esrt/mod.rs b/framework_lib/src/esrt/mod.rs index 7283d580..a03a9881 100644 --- a/framework_lib/src/esrt/mod.rs +++ b/framework_lib/src/esrt/mod.rs @@ -29,15 +29,6 @@ use winreg::enums::HKEY_LOCAL_MACHINE; #[cfg(target_os = "windows")] use winreg::RegKey; -#[cfg(target_os = "freebsd")] -use nix::ioctl_readwrite; -#[cfg(target_os = "freebsd")] -use std::fs::OpenOptions; -#[cfg(target_os = "freebsd")] -use std::os::fd::AsRawFd; -#[cfg(target_os = "freebsd")] -use std::os::unix::fs::OpenOptionsExt; - pub const TGL_BIOS_GUID: GUID = GUID::build_from_components( 0xb3bdb2e4, 0xc5cb, @@ -455,49 +446,6 @@ pub fn get_esrt() -> Option { Some(esrt_table) } -#[cfg(target_os = "freebsd")] -#[repr(C)] -pub struct EfiGetTableIoc { - buf: *mut u8, - uuid: [u8; 16], - table_len: usize, - buf_len: usize, -} -#[cfg(target_os = "freebsd")] -ioctl_readwrite!(efi_get_table, b'E', 1, EfiGetTableIoc); - -#[cfg(all(not(feature = "uefi"), target_os = "freebsd"))] -pub fn get_esrt() -> Option { - let path = "/dev/efi"; - let file = OpenOptions::new() - .read(true) - .write(true) - .custom_flags(libc::O_NONBLOCK) - .open(path) - .unwrap(); - - let mut buf: Vec = Vec::new(); - let mut table = EfiGetTableIoc { - buf: std::ptr::null_mut(), - uuid: SYSTEM_RESOURCE_TABLE_GUID_BYTES, - table_len: 0, - buf_len: 0, - }; - unsafe { - let fd = file.as_raw_fd(); - if let Err(err) = efi_get_table(fd, &mut table) { - error!("Failed to access ESRT at {}: {:?}", path, err); - return None; - } - buf.resize(table.table_len, 0); - table.buf_len = table.table_len; - table.buf = buf.as_mut_ptr(); - - let _res = efi_get_table(fd, &mut table).unwrap(); - esrt_from_buf(table.buf) - } -} - /// gEfiSystemResourceTableGuid from MdePkg/MdePkg.dec pub const SYSTEM_RESOURCE_TABLE_GUID: GUID = GUID::build_from_components( 0xb122a263, @@ -505,9 +453,6 @@ pub const SYSTEM_RESOURCE_TABLE_GUID: GUID = GUID::build_from_components( 0x4f68, &[0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80], ); -pub const SYSTEM_RESOURCE_TABLE_GUID_BYTES: [u8; 16] = [ - 0x63, 0xa2, 0x22, 0xb1, 0x61, 0x36, 0x68, 0x4f, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80, -]; #[cfg(feature = "uefi")] pub fn get_esrt() -> Option { @@ -530,7 +475,7 @@ pub fn get_esrt() -> Option { } /// Parse the ESRT table buffer -#[cfg(any(feature = "uefi", target_os = "freebsd"))] +#[cfg(feature = "uefi")] unsafe fn esrt_from_buf(ptr: *const u8) -> Option { let raw_esrt = &*(ptr as *const _Esrt); let mut esrt = Esrt { diff --git a/framework_lib/src/smbios.rs b/framework_lib/src/smbios.rs index aaac1cf5..39fa7c84 100644 --- a/framework_lib/src/smbios.rs +++ b/framework_lib/src/smbios.rs @@ -2,7 +2,7 @@ use std::prelude::v1::*; -#[cfg(all(not(feature = "uefi"), not(target_os = "freebsd")))] +#[cfg(not(feature = "uefi"))] use std::io::ErrorKind; use crate::util::Config; @@ -15,9 +15,6 @@ use spin::Mutex; #[cfg(not(feature = "uefi"))] use std::sync::Mutex; -#[cfg(target_os = "freebsd")] -use std::io::{Read, Seek, SeekFrom}; - /// Current platform. Won't ever change during the program's runtime static CACHED_PLATFORM: Mutex>> = Mutex::new(None); @@ -57,12 +54,6 @@ pub fn is_framework() -> bool { return true; } - // Don't need to parse SMBIOS on FreeBSD, can just read kenv - #[cfg(target_os = "freebsd")] - if let Ok(maker) = kenv_get("smbios.system.maker") { - return maker == "Framework"; - } - let smbios = if let Some(smbios) = get_smbios() { smbios } else { @@ -92,104 +83,6 @@ pub fn dmidecode_string_val(s: &SMBiosString) -> Option { } } -#[cfg(target_os = "freebsd")] -#[repr(C)] -pub struct Smbios3 { - pub anchor: [u8; 5], - pub checksum: u8, - pub length: u8, - pub major_version: u8, - pub minor_version: u8, - pub docrev: u8, - pub revision: u8, - _reserved: u8, - pub table_length: u32, - pub table_address: u64, -} - -#[cfg(target_os = "freebsd")] -#[repr(C, packed)] -pub struct Smbios { - pub anchor: [u8; 4], - pub checksum: u8, - pub length: u8, - pub major_version: u8, - pub minor_version: u8, - pub max_structure_size: u16, - pub revision: u8, - pub formatted: [u8; 5], - pub inter_anchor: [u8; 5], - pub inter_checksum: u8, - pub table_length: u16, - pub table_address: u32, - pub structure_count: u16, - pub bcd_revision: u8, -} - -#[cfg(target_os = "freebsd")] -pub fn get_smbios() -> Option { - trace!("get_smbios() FreeBSD entry"); - // Get the SMBIOS entrypoint address from the kernel environment - let addr_hex = kenv_get("hint.smbios.0.mem").ok()?; - let addr_hex = addr_hex.trim_start_matches("0x"); - let addr = u64::from_str_radix(addr_hex, 16).unwrap(); - trace!("SMBIOS Entrypoint Addr: {} 0x{:x}", addr_hex, addr); - - let mut dev_mem = std::fs::File::open("/dev/mem").ok()?; - // Smbios struct is larger than Smbios3 struct - let mut header_buf = [0; std::mem::size_of::()]; - dev_mem.seek(SeekFrom::Start(addr)).ok()?; - dev_mem.read_exact(&mut header_buf).ok()?; - - let entrypoint = unsafe { &*(header_buf.as_ptr() as *const Smbios3) }; - - trace!("SMBIOS Anchor {:?} = ", entrypoint.anchor); - let (addr, len, version) = match entrypoint.anchor { - [b'_', b'S', b'M', b'3', b'_'] => { - trace!("_SM3_"); - let entrypoint = unsafe { &*(header_buf.as_ptr() as *const Smbios3) }; - let ver = Some(SMBiosVersion { - major: entrypoint.major_version, - minor: entrypoint.minor_version, - revision: 0, - }); - - (entrypoint.table_address, entrypoint.table_length, ver) - } - [b'_', b'S', b'M', b'_', _] => { - trace!("_SM_"); - let entrypoint = unsafe { &*(header_buf.as_ptr() as *const Smbios) }; - let ver = Some(SMBiosVersion { - major: entrypoint.major_version, - minor: entrypoint.minor_version, - revision: 0, - }); - - ( - entrypoint.table_address as u64, - entrypoint.table_length as u32, - ver, - ) - } - [b'_', b'D', b'M', b'I', b'_'] => { - error!("_DMI_ - UNSUPPORTED"); - return None; - } - _ => { - error!(" Unknown - UNSUPPORTED"); - return None; - } - }; - - // Get actual SMBIOS table data - let mut smbios_buf = vec![0; len as usize]; - dev_mem.seek(SeekFrom::Start(addr)).ok()?; - dev_mem.read_exact(&mut smbios_buf).ok()?; - - let smbios = SMBiosData::from_vec_and_version(smbios_buf, version); - Some(smbios) -} - #[cfg(feature = "uefi")] pub fn get_smbios() -> Option { trace!("get_smbios() uefi entry"); @@ -200,9 +93,9 @@ pub fn get_smbios() -> Option { } // On Linux this reads either from /dev/mem or sysfs // On Windows from the kernel API -#[cfg(all(not(feature = "uefi"), not(target_os = "freebsd")))] +#[cfg(not(feature = "uefi"))] pub fn get_smbios() -> Option { - trace!("get_smbios() linux entry"); + trace!("get_smbios() entry"); match smbioslib::table_load_from_device() { Ok(data) => Some(data), Err(ref e) if e.kind() == ErrorKind::PermissionDenied => { @@ -217,12 +110,6 @@ pub fn get_smbios() -> Option { } pub fn get_product_name() -> Option { - // On FreeBSD we can short-circuit and avoid parsing SMBIOS - #[cfg(target_os = "freebsd")] - if let Ok(product) = kenv_get("smbios.system.product") { - return Some(product); - } - let smbios = get_smbios(); if smbios.is_none() { println!("Failed to find SMBIOS"); @@ -240,12 +127,6 @@ pub fn get_product_name() -> Option { } pub fn get_baseboard_version() -> Option { - // TODO: On FreeBSD we can short-circuit and avoid parsing SMBIOS - // #[cfg(target_os = "freebsd")] - // if let Ok(product) = kenv_get("smbios.system.product") { - // return Some(product); - // } - let smbios = get_smbios(); if smbios.is_none() { error!("Failed to find SMBIOS"); @@ -325,30 +206,3 @@ pub fn get_platform() -> Option { *cached_platform = Some(platform); platform } - -#[cfg(target_os = "freebsd")] -fn kenv_get(name: &str) -> nix::Result { - use libc::{c_int, KENV_GET, KENV_MVALLEN}; - use nix::errno::Errno; - use std::ffi::{CStr, CString}; - - let cname = CString::new(name).unwrap(); - let name_ptr = cname.as_ptr(); - - let mut value_buf = [0; 1 + KENV_MVALLEN as usize]; - - unsafe { - let res: c_int = libc::kenv( - KENV_GET, - name_ptr, - value_buf.as_mut_ptr(), - value_buf.len() as c_int, - ); - Errno::result(res)?; - - let cvalue = CStr::from_ptr(value_buf.as_ptr()); - let value = cvalue.to_string_lossy().into_owned(); - - Ok(value) - } -}