MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / parse_me_fwsts

Function parse_me_fwsts

framework_lib/src/csme.rs:400–463  ·  view source on GitHub ↗

Parse SMBIOS type 0xDB (ME FWSTS) table Structure: - Offset 0: type (0xDB) - Offset 1: length - Offset 2-3: handle (u16le) - Offset 4: version (should be 0x01) - Offset 5: count (number of records) - Offset 6+: records, each 25 bytes: - 1 byte: component name - 24 bytes: 6 x u32le HFSTS registers

(raw: &RawStructure)

Source from the content-addressed store, hash-verified

398/// - 1 byte: component name
399/// - 24 bytes: 6 x u32le HFSTS registers
400pub fn parse_me_fwsts(raw: &RawStructure) -> Option<MeSmbiosInfo> {
401 // Verify this is type 0xDB
402 if raw.info != InfoType::Oem(SMBIOS_TYPE_ME_FWSTS) {
403 return None;
404 }
405
406 let length = raw.length as usize;
407 let handle = raw.handle;
408
409 // Minimum header size: 6 bytes (type, length, handle, version, count)
410 if length < 6 {
411 return None;
412 }
413
414 // Get version and count from offsets 4 and 5
415 let version = raw.get::<u8>(4).ok()?;
416 let count = raw.get::<u8>(5).ok()?;
417
418 // Version should be 0x01
419 if version != 0x01 {
420 return None;
421 }
422
423 let mut records = Vec::new();
424 let record_size = 25; // 1 byte component + 6 * 4 bytes HFSTS
425
426 for i in 0..count {
427 let record_offset = 6 + (i as usize * record_size);
428
429 // Check we have enough data
430 // TODO: Should this `return None;`?
431 if record_offset + record_size > length {
432 break;
433 }
434
435 let component = MeComponent::from(raw.get::<u8>(record_offset).ok()?);
436
437 // Parse 6 HFSTS registers (u32le each)
438 let hfsts1 = raw.get::<u32>(record_offset + 1).ok()?;
439 let hfsts2 = raw.get::<u32>(record_offset + 5).ok()?;
440 let hfsts3 = raw.get::<u32>(record_offset + 9).ok()?;
441 let hfsts4 = raw.get::<u32>(record_offset + 13).ok()?;
442 let hfsts5 = raw.get::<u32>(record_offset + 17).ok()?;
443 let hfsts6 = raw.get::<u32>(record_offset + 21).ok()?;
444
445 records.push(MeFwstsRecord {
446 component,
447 hfsts: HfStsRegisters {
448 hfsts1,
449 hfsts2,
450 hfsts3,
451 hfsts4,
452 hfsts5,
453 hfsts6,
454 },
455 });
456 }
457

Callers 1

me_fwsts_from_smbiosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected