MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / get_platform

Function get_platform

framework_lib/src/smbios.rs:177–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175}
176
177pub fn get_platform() -> Option<Platform> {
178 #[cfg(feature = "uefi")]
179 let mut cached_platform = CACHED_PLATFORM.lock();
180 #[cfg(not(feature = "uefi"))]
181 let mut cached_platform = CACHED_PLATFORM.lock().unwrap();
182
183 if let Some(platform) = *cached_platform {
184 return platform;
185 }
186
187 if Config::is_set() {
188 // Config::get() recursively calls get_platform.
189 // Except if it's a GenericFramework platform
190 let config = Config::get();
191 let platform = &(*config).as_ref().unwrap().platform;
192 if matches!(
193 platform,
194 Platform::GenericFramework((_, _, _), (_, _, _)) | Platform::UnknownSystem
195 ) {
196 return Some(*platform);
197 }
198 }
199
200 let product_name = get_product_name()?;
201
202 let platform = match product_name.as_str() {
203 "Laptop" => Some(Platform::IntelGen11),
204 "Laptop (12th Gen Intel Core)" => Some(Platform::IntelGen12),
205 "Laptop (13th Gen Intel Core)" => Some(Platform::IntelGen13),
206 "Laptop 13 (AMD Ryzen 7040Series)" => Some(Platform::Framework13Amd7080),
207 "Laptop 13 (AMD Ryzen 7040 Series)" => Some(Platform::Framework13Amd7080),
208 "Laptop 13 (AMD Ryzen AI 300 Series)" => Some(Platform::Framework13AmdAi300),
209 "Laptop 12 (13th Gen Intel Core)" => Some(Platform::Framework12IntelGen13),
210 "Laptop 13 (Intel Core Ultra Series 1)" => Some(Platform::IntelCoreUltra1),
211 "Laptop 13 Pro (Intel Core Ultra Series 3)" => Some(Platform::IntelCoreUltra3),
212 "Laptop 16 (AMD Ryzen 7040 Series)" => Some(Platform::Framework16Amd7080),
213 "Laptop 16 (AMD Ryzen AI 300 Series)" => Some(Platform::Framework16AmdAi300),
214 "Desktop (AMD Ryzen AI Max 300 Series)" => Some(Platform::FrameworkDesktopAmdAiMax300),
215 _ => Some(Platform::UnknownSystem),
216 };
217
218 if let Some(platform) = platform {
219 Config::set(platform);
220 } else {
221 println!("Failed to find PlatformFamily");
222 }
223
224 assert!(cached_platform.is_none());
225 *cached_platform = Some(platform);
226 platform
227}
228
229#[cfg(target_os = "freebsd")]
230pub fn get_smbios() -> Option<SmbiosStore> {

Callers 12

is_frameworkFunction · 0.85
get_familyFunction · 0.85
getMethod · 0.85
print_thermalFunction · 0.85
active_fw_verMethod · 0.85
initFunction · 0.85
print_versionsFunction · 0.85
probably_has_nvidiaFunction · 0.85
run_with_argsFunction · 0.85
selftestFunction · 0.85
smbios_infoFunction · 0.85

Calls 1

get_product_nameFunction · 0.85

Tested by

no test coverage detected