@@ -104,7 +104,27 @@ pub fn get_smbios() -> Option<SMBiosData> {
104
104
println ! ( "Failed to get SMBIOS: {:?}" , err) ;
105
105
None
106
106
}
107
+
108
+ fn get_product_name( ) -> Option < String > {
109
+ // On FreeBSD we can short-circuit and avoid parsing SMBIOS
110
+ #[ cfg( target_os = "freebsd" ) ]
111
+ if let Ok ( product) = kenv_get( "smbios.system.product" ) {
112
+ return Some ( product) ;
113
+ }
114
+
115
+ let smbios = get_smbios( ) ;
116
+ if smbios. is_none( ) {
117
+ println ! ( "Failed to find SMBIOS" ) ;
107
118
}
119
+ let mut smbios = smbios. into_iter( ) . flatten( ) ;
120
+ smbios. find_map( |undefined_struct| {
121
+ if let DefinedStruct :: SystemInformation ( data) = undefined_struct. defined_struct( ) {
122
+ if let Some ( product_name) = dmidecode_string_val( & data. product_name( ) ) {
123
+ return Some ( product_name. as_str( ) . to_string( ) ) ;
124
+ }
125
+ }
126
+ None
127
+ } )
108
128
}
109
129
110
130
pub fn get_platform( ) -> Option < Platform > {
@@ -127,46 +147,18 @@ pub fn get_platform() -> Option<Platform> {
127
147
}
128
148
}
129
149
130
- let smbios = get_smbios ( ) ;
131
- if smbios. is_none ( ) {
132
- println ! ( "Failed to find SMBIOS" ) ;
133
- }
134
- let mut smbios = smbios. into_iter ( ) . flatten ( ) ;
135
- let platform = smbios. find_map ( |undefined_struct| {
136
- if let DefinedStruct :: SystemInformation ( data) = undefined_struct. defined_struct ( ) {
137
- if let Some ( product_name) = dmidecode_string_val ( & data. product_name ( ) ) {
138
- match product_name. as_str ( ) {
139
- "Laptop" => return Some ( Platform :: IntelGen11 ) ,
140
- "Laptop (12th Gen Intel Core)" => return Some ( Platform :: IntelGen12 ) ,
141
- "Laptop (13th Gen Intel Core)" => return Some ( Platform :: IntelGen13 ) ,
142
- "Laptop 13 (AMD Ryzen 7040Series)" => return Some ( Platform :: Framework13Amd ) ,
143
- "Laptop 13 (AMD Ryzen 7040 Series)" => return Some ( Platform :: Framework13Amd ) ,
144
- "Laptop 13 (Intel Core Ultra Series 1)" => {
145
- return Some ( Platform :: IntelCoreUltra1 )
146
- }
147
- "Laptop 16 (AMD Ryzen 7040 Series)" => return Some ( Platform :: Framework16 ) ,
148
- _ => { }
149
- }
150
- }
151
- if let Some ( family) = dmidecode_string_val ( & data. family ( ) ) {
152
- // Actually "Laptop", "13in Laptop", and "16in Laptop"
153
- match family. as_str ( ) {
154
- // TGL Mainboard (I don't this ever appears in family)
155
- "FRANBMCP" => return Some ( Platform :: IntelGen11 ) ,
156
- // ADL Mainboard (I don't this ever appears in family)
157
- "FRANMACP" => return Some ( Platform :: IntelGen12 ) ,
158
- // RPL Mainboard (I don't this ever appears in family)
159
- "FRANMCCP" => return Some ( Platform :: IntelGen13 ) ,
160
- // Framework 13 AMD Mainboard
161
- "FRANMDCP" => return Some ( Platform :: Framework13Amd ) ,
162
- // Framework 16 Mainboard
163
- "FRANMZCP" => return Some ( Platform :: Framework16 ) ,
164
- _ => { }
165
- }
166
- }
167
- }
168
- None
169
- } ) ;
150
+ let product_name = get_product_name( ) ?;
151
+
152
+ let platform = match product_name. as_str( ) {
153
+ "Laptop" => Some ( Platform :: IntelGen11 ) ,
154
+ "Laptop (12th Gen Intel Core)" => Some ( Platform :: IntelGen12 ) ,
155
+ "Laptop (13th Gen Intel Core)" => Some ( Platform :: IntelGen13 ) ,
156
+ "Laptop 13 (AMD Ryzen 7040Series)" => Some ( Platform :: Framework13Amd ) ,
157
+ "Laptop 13 (AMD Ryzen 7040 Series)" => Some ( Platform :: Framework13Amd ) ,
158
+ "Laptop 13 (Intel Core Ultra Series 1)" => Some ( Platform :: IntelCoreUltra1 ) ,
159
+ "Laptop 16 (AMD Ryzen 7040 Series)" => Some ( Platform :: Framework16 ) ,
160
+ _ => None ,
161
+ } ;
170
162
171
163
if platform. is_none( ) {
172
164
println ! ( "Failed to find PlatformFamily" ) ;
0 commit comments