Skip to content

Commit 459323c

Browse files
Merge pull request #34 from FrameworkComputer/serial-config
smbios: Decode config digit 0 of serialnumber
2 parents a8230e7 + 5e110de commit 459323c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

framework_lib/src/commandline/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use alloc::string::String;
77
use alloc::string::ToString;
88
use alloc::vec::Vec;
99
use log::Level;
10+
use num_traits::FromPrimitive;
1011

1112
#[cfg(not(feature = "uefi"))]
1213
pub mod clap_std;
@@ -39,6 +40,7 @@ use crate::ec_binary;
3940
use crate::esrt;
4041
use crate::power;
4142
use crate::smbios;
43+
use crate::smbios::ConfigDigit0;
4244
use crate::smbios::{dmidecode_string_val, get_smbios, is_framework};
4345
#[cfg(feature = "uefi")]
4446
use crate::uefi::enable_page_break;
@@ -786,7 +788,16 @@ fn smbios_info() {
786788
DefinedStruct::SystemInformation(data) => {
787789
println!("System Information");
788790
if let Some(version) = dmidecode_string_val(&data.version()) {
789-
println!(" Version: {}", version);
791+
// Assumes it's ASCII, which is guaranteed by SMBIOS
792+
let config_digit0 = &version[0..1];
793+
let config_digit0 = u8::from_str_radix(config_digit0, 16).unwrap();
794+
if let Some(version_config) =
795+
<ConfigDigit0 as FromPrimitive>::from_u8(config_digit0)
796+
{
797+
println!(" Version: {:?} ({})", version_config, version);
798+
} else {
799+
println!(" Version: {}", version);
800+
}
790801
}
791802
if let Some(manufacturer) = dmidecode_string_val(&data.manufacturer()) {
792803
println!(" Manufacturer: {}", manufacturer);

framework_lib/src/smbios.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::prelude::v1::*;
66
use std::io::ErrorKind;
77

88
use crate::util::Platform;
9+
use num_derive::FromPrimitive;
910
use smbioslib::*;
1011
#[cfg(feature = "uefi")]
1112
use spin::Mutex;
@@ -18,6 +19,25 @@ static CACHED_PLATFORM: Mutex<Option<Option<Platform>>> = Mutex::new(None);
1819
// TODO: Should cache SMBIOS and values gotten from it
1920
// SMBIOS is fixed after boot. Oh, so maybe not cache when we're running in UEFI
2021

22+
#[repr(u8)]
23+
#[derive(Debug, PartialEq, FromPrimitive, Clone, Copy)]
24+
pub enum ConfigDigit0 {
25+
Poc1 = 0x01,
26+
Proto1 = 0x02,
27+
Proto2 = 0x03,
28+
Evt1 = 0x04,
29+
Evt2 = 0x05,
30+
Dvt1 = 0x07,
31+
Dvt2 = 0x08,
32+
Pvt = 0x09,
33+
MassProduction = 0x0A,
34+
MassProductionB = 0x0B,
35+
MassProductionC = 0x0C,
36+
MassProductionD = 0x0D,
37+
MassProductionE = 0x0E,
38+
MassProductionF = 0x0F,
39+
}
40+
2141
/// Check whether the manufacturer in the SMBIOS says Framework
2242
pub fn is_framework() -> bool {
2343
let smbios = if let Some(smbios) = get_smbios() {

0 commit comments

Comments
 (0)