1use crate::core::{strings::*, Handle, UndefinedStruct};
2use crate::SMBiosStruct;
3use serde::{ser::SerializeStruct, Serialize, Serializer};
4use std::convert::TryInto;
5use std::fmt;
6use std::ops::Deref;
7
8pub struct SMBiosProcessorInformation<'a> {
24 parts: &'a UndefinedStruct,
25}
26
27impl<'a> SMBiosStruct<'a> for SMBiosProcessorInformation<'a> {
28 const STRUCT_TYPE: u8 = 4u8;
29
30 fn new(parts: &'a UndefinedStruct) -> Self {
31 Self { parts }
32 }
33
34 fn parts(&self) -> &'a UndefinedStruct {
35 self.parts
36 }
37}
38
39impl<'a> SMBiosProcessorInformation<'a> {
40 pub fn socket_designation(&self) -> SMBiosString {
44 self.parts.get_field_string(0x04)
45 }
46
47 pub fn processor_type(&self) -> Option<ProcessorTypeData> {
49 self.parts
50 .get_field_byte(0x05)
51 .map(|raw| ProcessorTypeData::from(raw))
52 }
53
54 pub fn processor_family(&self) -> Option<ProcessorFamilyData> {
56 self.parts
57 .get_field_byte(0x06)
58 .map(|raw| ProcessorFamilyData::from(raw))
59 }
60
61 pub fn processor_manufacturer(&self) -> SMBiosString {
63 self.parts.get_field_string(0x07)
64 }
65
66 pub fn processor_id(&self) -> Option<&[u8; 8]> {
68 self.parts
74 .get_field_data(0x08, 0x10)
75 .map(|raw| raw.try_into().expect("incorrect length"))
76 }
77
78 pub fn processor_version(&self) -> SMBiosString {
80 self.parts.get_field_string(0x10)
81 }
82
83 pub fn voltage(&self) -> Option<ProcessorVoltage> {
85 self.parts
86 .get_field_byte(0x11)
87 .map(|raw| ProcessorVoltage::from(raw))
88 }
89
90 pub fn external_clock(&self) -> Option<ProcessorExternalClock> {
94 self.parts
95 .get_field_word(0x12)
96 .map(|raw| ProcessorExternalClock::from(raw))
97 }
98
99 pub fn max_speed(&self) -> Option<ProcessorSpeed> {
107 self.parts
108 .get_field_word(0x14)
109 .map(|raw| ProcessorSpeed::from(raw))
110 }
111
112 pub fn current_speed(&self) -> Option<ProcessorSpeed> {
120 self.parts
121 .get_field_word(0x16)
122 .map(|raw| ProcessorSpeed::from(raw))
123 }
124
125 pub fn status(&self) -> Option<ProcessorStatus> {
127 self.parts
128 .get_field_byte(0x18)
129 .map(|raw| ProcessorStatus::from(raw))
130 }
131
132 pub fn processor_upgrade(&self) -> Option<ProcessorUpgradeData> {
134 self.parts
135 .get_field_byte(0x19)
136 .map(|raw| ProcessorUpgradeData::from(raw))
137 }
138
139 pub fn l1cache_handle(&self) -> Option<Handle> {
149 self.parts.get_field_handle(0x1A)
150 }
151
152 pub fn l2cache_handle(&self) -> Option<Handle> {
162 self.parts.get_field_handle(0x1C)
163 }
164
165 pub fn l3cache_handle(&self) -> Option<Handle> {
175 self.parts.get_field_handle(0x1E)
176 }
177
178 pub fn serial_number(&self) -> SMBiosString {
183 self.parts.get_field_string(0x20)
184 }
185
186 pub fn asset_tag(&self) -> SMBiosString {
188 self.parts.get_field_string(0x21)
189 }
190
191 pub fn part_number(&self) -> SMBiosString {
196 self.parts.get_field_string(0x22)
197 }
198
199 pub fn core_count(&self) -> Option<CoreCount> {
204 self.parts
205 .get_field_byte(0x23)
206 .map(|raw| CoreCount::from(raw))
207 }
208
209 pub fn cores_enabled(&self) -> Option<CoresEnabled> {
215 self.parts
216 .get_field_byte(0x24)
217 .map(|raw| CoresEnabled::from(raw))
218 }
219
220 pub fn thread_count(&self) -> Option<ThreadCount> {
226 self.parts
227 .get_field_byte(0x25)
228 .map(|raw| ThreadCount::from(raw))
229 }
230
231 pub fn processor_characteristics(&self) -> Option<ProcessorCharacteristics> {
233 self.parts
234 .get_field_word(0x26)
235 .map(|raw| ProcessorCharacteristics::from(raw))
236 }
237
238 pub fn processor_family_2(&self) -> Option<ProcessorFamilyData2> {
240 self.parts
241 .get_field_word(0x28)
242 .map(|raw| ProcessorFamilyData2::from(raw))
243 }
244
245 pub fn core_count_2(&self) -> Option<CoreCount2> {
254 self.parts
255 .get_field_word(0x2A)
256 .map(|raw| CoreCount2::from(raw))
257 }
258
259 pub fn cores_enabled_2(&self) -> Option<CoresEnabled2> {
269 self.parts
270 .get_field_word(0x2C)
271 .map(|raw| CoresEnabled2::from(raw))
272 }
273
274 pub fn thread_count_2(&self) -> Option<ThreadCount2> {
284 self.parts
285 .get_field_word(0x2E)
286 .map(|raw| ThreadCount2::from(raw))
287 }
288
289 pub fn thread_enabled(&self) -> Option<ThreadEnabled> {
297 self.parts
298 .get_field_word(0x30)
299 .map(|raw| ThreadEnabled::from(raw))
300 }
301}
302
303impl fmt::Debug for SMBiosProcessorInformation<'_> {
304 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
305 fmt.debug_struct(std::any::type_name::<SMBiosProcessorInformation<'_>>())
306 .field("header", &self.parts.header)
307 .field("socket_designation", &self.socket_designation())
308 .field("processor_type", &self.processor_type())
309 .field("processor_family", &self.processor_family())
310 .field("processor_manufacturer", &self.processor_manufacturer())
311 .field("processor_id", &self.processor_id())
312 .field("processor_version", &self.processor_version())
313 .field("voltage", &self.voltage())
314 .field("external_clock", &self.external_clock())
315 .field("max_speed", &self.max_speed())
316 .field("current_speed", &self.current_speed())
317 .field("status", &self.status())
318 .field("processor_upgrade", &self.processor_upgrade())
319 .field("l1cache_handle", &self.l1cache_handle())
320 .field("l2cache_handle", &self.l2cache_handle())
321 .field("l3cache_handle", &self.l3cache_handle())
322 .field("serial_number", &self.serial_number())
323 .field("asset_tag", &self.asset_tag())
324 .field("part_number", &self.part_number())
325 .field("core_count", &self.core_count())
326 .field("cores_enabled", &self.cores_enabled())
327 .field("thread_count", &self.thread_count())
328 .field(
329 "processor_characteristics",
330 &self.processor_characteristics(),
331 )
332 .field("processor_family_2", &self.processor_family_2())
333 .field("core_count_2", &self.core_count_2())
334 .field("cores_enabled_2", &self.cores_enabled_2())
335 .field("thread_count_2", &self.thread_count_2())
336 .field("thread_enabled", &self.thread_enabled())
337 .finish()
338 }
339}
340
341impl Serialize for SMBiosProcessorInformation<'_> {
342 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
343 where
344 S: Serializer,
345 {
346 let mut state = serializer.serialize_struct("SMBiosProcessorInformation", 27)?;
347 state.serialize_field("header", &self.parts.header)?;
348 state.serialize_field("socket_designation", &self.socket_designation())?;
349 state.serialize_field("processor_type", &self.processor_type())?;
350 state.serialize_field("processor_family", &self.processor_family())?;
351 state.serialize_field("processor_manufacturer", &self.processor_manufacturer())?;
352 state.serialize_field("processor_id", &self.processor_id())?;
353 state.serialize_field("processor_version", &self.processor_version())?;
354 state.serialize_field("voltage", &self.voltage())?;
355 state.serialize_field("external_clock", &self.external_clock())?;
356 state.serialize_field("max_speed", &self.max_speed())?;
357 state.serialize_field("current_speed", &self.current_speed())?;
358 state.serialize_field("status", &self.status())?;
359 state.serialize_field("processor_upgrade", &self.processor_upgrade())?;
360 state.serialize_field("l1cache_handle", &self.l1cache_handle())?;
361 state.serialize_field("l2cache_handle", &self.l2cache_handle())?;
362 state.serialize_field("l3cache_handle", &self.l3cache_handle())?;
363 state.serialize_field("serial_number", &self.serial_number())?;
364 state.serialize_field("asset_tag", &self.asset_tag())?;
365 state.serialize_field("part_number", &self.part_number())?;
366 state.serialize_field("core_count", &self.core_count())?;
367 state.serialize_field("cores_enabled", &self.cores_enabled())?;
368 state.serialize_field("thread_count", &self.thread_count())?;
369 state.serialize_field(
370 "processor_characteristics",
371 &self.processor_characteristics(),
372 )?;
373 state.serialize_field("processor_family_2", &self.processor_family_2())?;
374 state.serialize_field("core_count_2", &self.core_count_2())?;
375 state.serialize_field("cores_enabled_2", &self.cores_enabled_2())?;
376 state.serialize_field("thread_count_2", &self.thread_count_2())?;
377 state.serialize_field("thread_enabled", &self.thread_enabled())?;
378 state.end()
379 }
380}
381
382pub struct ProcessorTypeData {
384 pub raw: u8,
391 pub value: ProcessorType,
393}
394
395impl fmt::Debug for ProcessorTypeData {
396 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
397 fmt.debug_struct(std::any::type_name::<ProcessorTypeData>())
398 .field("raw", &self.raw)
399 .field("value", &self.value)
400 .finish()
401 }
402}
403
404impl Serialize for ProcessorTypeData {
405 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
406 where
407 S: Serializer,
408 {
409 let mut state = serializer.serialize_struct("ProcessorTypeData", 2)?;
410 state.serialize_field("raw", &self.raw)?;
411 state.serialize_field("value", &self.value)?;
412 state.end()
413 }
414}
415
416impl fmt::Display for ProcessorTypeData {
417 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
418 match &self.value {
419 ProcessorType::None => write!(f, "{}", &self.raw),
420 _ => write!(f, "{:?}", &self.value),
421 }
422 }
423}
424
425impl Deref for ProcessorTypeData {
426 type Target = ProcessorType;
427
428 fn deref(&self) -> &Self::Target {
429 &self.value
430 }
431}
432
433#[derive(Serialize, Debug, PartialEq, Eq)]
435pub enum ProcessorType {
436 Other,
438 Unknown,
440 CentralProcessor,
442 MathProcessor,
444 DspProcessor,
446 VideoProcessor,
448 None,
450}
451
452impl From<u8> for ProcessorTypeData {
453 fn from(raw: u8) -> Self {
454 ProcessorTypeData {
455 value: match raw {
456 0x01 => ProcessorType::Other,
457 0x02 => ProcessorType::Unknown,
458 0x03 => ProcessorType::CentralProcessor,
459 0x04 => ProcessorType::MathProcessor,
460 0x05 => ProcessorType::DspProcessor,
461 0x06 => ProcessorType::VideoProcessor,
462 _ => ProcessorType::None,
463 },
464 raw,
465 }
466 }
467}
468
469pub struct ProcessorFamilyData {
471 pub raw: u8,
478 pub value: ProcessorFamily,
480}
481
482impl fmt::Debug for ProcessorFamilyData {
483 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
484 fmt.debug_struct(std::any::type_name::<ProcessorFamilyData>())
485 .field("raw", &self.raw)
486 .field("value", &self.value)
487 .finish()
488 }
489}
490
491impl Serialize for ProcessorFamilyData {
492 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
493 where
494 S: Serializer,
495 {
496 let mut state = serializer.serialize_struct("ProcessorFamilyData", 2)?;
497 state.serialize_field("raw", &self.raw)?;
498 state.serialize_field("value", &self.value)?;
499 state.end()
500 }
501}
502
503impl fmt::Display for ProcessorFamilyData {
504 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
506 match &self.value {
507 ProcessorFamily::None => write!(f, "{:#X}", &self.raw),
508 _ => write!(f, "{:?}", &self.value),
509 }
510 }
511}
512
513impl Deref for ProcessorFamilyData {
514 type Target = ProcessorFamily;
515
516 fn deref(&self) -> &Self::Target {
517 &self.value
518 }
519}
520
521impl From<u8> for ProcessorFamilyData {
522 fn from(raw: u8) -> Self {
523 ProcessorFamilyData {
524 value: ProcessorFamily::from(raw as u16),
525 raw,
526 }
527 }
528}
529
530pub struct ProcessorFamilyData2 {
532 pub raw: u16,
539 pub value: ProcessorFamily,
541}
542
543impl fmt::Debug for ProcessorFamilyData2 {
544 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
545 fmt.debug_struct(std::any::type_name::<ProcessorFamilyData2>())
546 .field("raw", &self.raw)
547 .field("value", &self.value)
548 .finish()
549 }
550}
551
552impl Serialize for ProcessorFamilyData2 {
553 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
554 where
555 S: Serializer,
556 {
557 let mut state = serializer.serialize_struct("ProcessorFamilyData2", 2)?;
558 state.serialize_field("raw", &self.raw)?;
559 state.serialize_field("value", &self.value)?;
560 state.end()
561 }
562}
563
564impl fmt::Display for ProcessorFamilyData2 {
565 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
567 match &self.value {
568 ProcessorFamily::None => write!(f, "{:#X}", &self.raw),
569 _ => write!(f, "{:?}", &self.value),
570 }
571 }
572}
573
574impl Deref for ProcessorFamilyData2 {
575 type Target = ProcessorFamily;
576
577 fn deref(&self) -> &Self::Target {
578 &self.value
579 }
580}
581
582impl From<u16> for ProcessorFamilyData2 {
583 fn from(raw: u16) -> Self {
584 ProcessorFamilyData2 {
585 value: ProcessorFamily::from(raw),
586 raw,
587 }
588 }
589}
590#[derive(Serialize, Debug, PartialEq, Eq)]
592pub enum ProcessorFamily {
593 Other,
595 Unknown,
597 I8086,
599 I80286,
601 Intel386Processor,
603 Intel486Processor,
605 I8087,
607 I80287,
609 I80387,
611 I80487,
613 IntelPentiumProcessor,
615 PentiumProProcessor,
617 PentiumIIProcessor,
619 PentiumprocessorwithMMXtechnology,
621 IntelCeleronProcessor,
623 PentiumIIXeonProcessor,
625 PentiumIIIProcessor,
627 M1Family,
629 M2Family,
631 IntelCeleronMProcessor,
633 IntelPentium4HTProcessor,
635 AMDDuronProcessorFamily,
637 K5Family,
639 K6Family,
641 K62,
643 K63,
645 AMDAthlonProcessorFamily,
647 AMD29000Family,
649 K62Plus,
651 PowerPCFamily,
653 PowerPC601,
655 PowerPC603,
657 PowerPC603Plus,
659 PowerPC604,
661 PowerPC620,
663 PowerPCx704,
665 PowerPC750,
667 IntelCoreDuoProcessor,
669 IntelCoreDuomobileProcessor,
671 IntelCoreSolomobileProcessor,
673 IntelAtomProcessor,
675 IntelCoreMProcessor,
677 IntelCorem3Processor,
679 IntelCorem5Processor,
681 IntelCorem7Processor,
683 AlphaFamily,
685 Alpha21064,
687 Alpha21066,
689 Alpha21164,
691 Alpha21164PC,
693 Alpha21164a,
695 Alpha21264,
697 Alpha21364,
699 AMDTurionIIUltraDualCoreMobileMProcessorFamily,
701 AMDTurionIIDualCoreMobileMProcessorFamily,
703 AMDAthlonIIDualCoreMProcessorFamily,
705 AMDOpteron6100SeriesProcessor,
707 AMDOpteron4100SeriesProcessor,
709 AMDOpteron6200SeriesProcessor,
711 AMDOpteron4200SeriesProcessor,
713 AMDFXSeriesProcessor,
715 MIPSFamily,
717 MIPSR4000,
719 MIPSR4200,
721 MIPSR4400,
723 MIPSR4600,
725 MIPSR10000,
727 AMDCSeriesProcessor,
729 AMDESeriesProcessor,
731 AMDASeriesProcessor,
733 AMDGSeriesProcessor,
735 AMDZSeriesProcessor,
737 AMDRSeriesProcessor,
739 AMDOpteron4300SeriesProcessor,
741 AMDOpteron6300SeriesProcessor,
743 AMDOpteron3300SeriesProcessor,
745 AMDFireProSeriesProcessor,
747 SPARCFamily,
749 SuperSPARC,
751 MicroSparcii,
753 MicroSparciiep,
755 UltraSPARC,
757 UltraSPARCII,
759 UltraSPARCIii,
761 UltraSPARCIII,
763 UltraSPARCIIIi,
765 M68040Family,
767 M68xxx,
769 M68000,
771 M68010,
773 M68020,
775 M68030,
777 AMDAthlonX4QuadCoreProcessorFamily,
779 AMDOpteronX1000SeriesProcessor,
781 AMDOpteronX2000SeriesAPU,
783 AMDOpteronASeriesProcessor,
785 AMDOpteronX3000SeriesAPU,
787 AMDZenProcessorFamily,
789 HobbitFamily,
791 CrusoeTM5000Family,
793 CrusoeTM3000Family,
795 EfficeonTM8000Family,
797 Weitek,
799 Itaniumprocessor,
801 AMDAthlon64ProcessorFamily,
803 AMDOpteronProcessorFamily,
805 AMDSempronProcessorFamily,
807 AMDTurion64MobileTechnology,
809 DualCoreAMDOpteronProcessorFamily,
811 AMDAthlon64X2DualCoreProcessorFamily,
813 AMDTurion64X2MobileTechnology,
815 QuadCoreAMDOpteronProcessorFamily,
817 ThirdGenerationAMDOpteronProcessorFamily,
819 AMDPhenomFXQuadCoreProcessorFamily,
821 AMDPhenomX4QuadCoreProcessorFamily,
823 AMDPhenomX2DualCoreProcessorFamily,
825 AMDAthlonX2DualCoreProcessorFamily,
827 PARISCFamily,
829 PARISC8500,
831 PARISC8000,
833 PARISC7300LC,
835 PARISC7200,
837 PARISC7100LC,
839 PARISC7100,
841 V30Family,
843 QuadCoreIntelXeonProcessor3200Series,
845 DualCoreIntelXeonProcessor3000Series,
847 QuadCoreIntelXeonProcessor5300Series,
849 DualCoreIntelXeonProcessor5100Series,
851 DualCoreIntelXeonProcessor5000Series,
853 DualCoreIntelXeonProcessorLV,
855 DualCoreIntelXeonProcessorULV,
857 DualCoreIntelXeonProcessor7100Series,
859 QuadCoreIntelXeonProcessor5400Series,
861 QuadCoreIntelXeonProcessor,
863 DualCoreIntelXeonProcessor5200Series,
865 DualCoreIntelXeonProcessor7200Series,
867 QuadCoreIntelXeonProcessor7300Series,
869 QuadCoreIntelXeonProcessor7400Series,
871 MultiCoreIntelXeonProcessor7400Series,
873 PentiumIIIXeonProcessor,
875 PentiumIIIProcessorwithIntelSpeedStepTechnology,
877 Pentium4Processor,
879 IntelXeonProcessor,
881 AS400Family,
883 IntelXeonProcessorMP,
885 AMDAthlonXPProcessorFamily,
887 AMDAthlonMPProcessorFamily,
889 IntelItanium2Processor,
891 IntelPentiumMProcessor,
893 IntelCeleronDProcessor,
895 IntelPentiumDProcessor,
897 IntelPentiumProcessorExtremeEdition,
899 IntelCoreSoloProcessor,
901 IntelCore2DuoProcessor,
903 IntelCore2SoloProcessor,
905 IntelCore2ExtremeProcessor,
907 IntelCore2QuadProcessor,
909 IntelCore2ExtremeMobileProcessor,
911 IntelCore2DuoMobileProcessor,
913 IntelCore2SoloMobileProcessor,
915 IntelCorei7Processor,
917 DualCoreIntelCeleronProcessor,
919 IBM390Family,
921 G4,
923 G5,
925 ESA390G6,
927 ZArchitecturebase,
929 IntelCorei5processor,
931 IntelCorei3processor,
933 IntelCorei9processor,
935 VIAC7MProcessorFamily,
937 VIAC7DProcessorFamily,
939 VIAC7ProcessorFamily,
941 VIAEdenProcessorFamily,
943 MultiCoreIntelXeonProcessor,
945 DualCoreIntelXeonProcessor3xxxSeries,
947 QuadCoreIntelXeonProcessor3xxxSeries,
949 VIANanoProcessorFamily,
951 DualCoreIntelXeonProcessor5xxxSeries,
953 QuadCoreIntelXeonProcessor5xxxSeries,
955 DualCoreIntelXeonProcessor7xxxSeries,
957 QuadCoreIntelXeonProcessor7xxxSeries,
959 MultiCoreIntelXeonProcessor7xxxSeries,
961 MultiCoreIntelXeonProcessor3400Series,
963 AMDOpteron3000SeriesProcessor,
965 AMDSempronIIProcessor,
967 EmbeddedAMDOpteronQuadCoreProcessorFamily,
969 AMDPhenomTripleCoreProcessorFamily,
971 AMDTurionUltraDualCoreMobileProcessorFamily,
973 AMDTurionDualCoreMobileProcessorFamily,
975 AMDAthlonDualCoreProcessorFamily,
977 AMDSempronSIProcessorFamily,
979 AMDPhenomIIProcessorFamily,
981 AMDAthlonIIProcessorFamily,
983 SixCoreAMDOpteronProcessorFamily,
985 AMDSempronMProcessorFamily,
987 I860,
989 I960,
991 SeeProcessorFamily2,
993 ARMv7,
995 ARMv8,
997 ARMv9,
999 SH3,
1001 SH4,
1003 ARM,
1005 StrongARM,
1007 Cyrix6x86,
1009 MediaGX,
1011 MII,
1013 WinChip,
1015 DSP,
1017 VideoProcessor,
1019 RISCVRV32,
1021 RISCVRV64,
1023 RISCVRV128,
1025 LoongArch,
1027 Longsoon1ProcessorFamily,
1029 Longsoon2ProcessorFamily,
1031 Longsoon3ProcessorFamily,
1033 Longsoon2KProcessorFamily,
1035 Longsoon3AProcessorFamily,
1037 Longsoon3BProcessorFamily,
1039 Longsoon3CProcessorFamily,
1041 Longsoon3DProcessorFamily,
1043 Longsoon3EProcessorFamily,
1045 DualCoreLoongson2KProcessor2xxxSeries,
1047 QuadCoreLoongson3AProcessor5xxxSeries,
1049 MultiCoreLoongson3AProcessor5xxxSeries,
1051 QuadCoreLoongson3BProcessor5xxxSeries,
1053 MultiCoreLoongson3BProcessor5xxxSeries,
1055 MultiCoreLoongson3CProcessor5xxxSeries,
1057 MultiCoreLoongson3DProcessor5xxxSeries,
1059 None,
1061}
1062
1063impl From<u16> for ProcessorFamily {
1064 fn from(raw: u16) -> Self {
1065 match raw {
1066 0x01 => ProcessorFamily::Other,
1067 0x02 => ProcessorFamily::Unknown,
1068 0x03 => ProcessorFamily::I8086,
1069 0x04 => ProcessorFamily::I80286,
1070 0x05 => ProcessorFamily::Intel386Processor,
1071 0x06 => ProcessorFamily::Intel486Processor,
1072 0x07 => ProcessorFamily::I8087,
1073 0x08 => ProcessorFamily::I80287,
1074 0x09 => ProcessorFamily::I80387,
1075 0x0A => ProcessorFamily::I80487,
1076 0x0B => ProcessorFamily::IntelPentiumProcessor,
1077 0x0C => ProcessorFamily::PentiumProProcessor,
1078 0x0D => ProcessorFamily::PentiumIIProcessor,
1079 0x0E => ProcessorFamily::PentiumprocessorwithMMXtechnology,
1080 0x0F => ProcessorFamily::IntelCeleronProcessor,
1081 0x10 => ProcessorFamily::PentiumIIXeonProcessor,
1082 0x11 => ProcessorFamily::PentiumIIIProcessor,
1083 0x12 => ProcessorFamily::M1Family,
1084 0x13 => ProcessorFamily::M2Family,
1085 0x14 => ProcessorFamily::IntelCeleronMProcessor,
1086 0x15 => ProcessorFamily::IntelPentium4HTProcessor,
1087 0x18 => ProcessorFamily::AMDDuronProcessorFamily,
1088 0x19 => ProcessorFamily::K5Family,
1089 0x1A => ProcessorFamily::K6Family,
1090 0x1B => ProcessorFamily::K62,
1091 0x1C => ProcessorFamily::K63,
1092 0x1D => ProcessorFamily::AMDAthlonProcessorFamily,
1093 0x1E => ProcessorFamily::AMD29000Family,
1094 0x1F => ProcessorFamily::K62Plus,
1095 0x20 => ProcessorFamily::PowerPCFamily,
1096 0x21 => ProcessorFamily::PowerPC601,
1097 0x22 => ProcessorFamily::PowerPC603,
1098 0x23 => ProcessorFamily::PowerPC603Plus,
1099 0x24 => ProcessorFamily::PowerPC604,
1100 0x25 => ProcessorFamily::PowerPC620,
1101 0x26 => ProcessorFamily::PowerPCx704,
1102 0x27 => ProcessorFamily::PowerPC750,
1103 0x28 => ProcessorFamily::IntelCoreDuoProcessor,
1104 0x29 => ProcessorFamily::IntelCoreDuomobileProcessor,
1105 0x2A => ProcessorFamily::IntelCoreSolomobileProcessor,
1106 0x2B => ProcessorFamily::IntelAtomProcessor,
1107 0x2C => ProcessorFamily::IntelCoreMProcessor,
1108 0x2D => ProcessorFamily::IntelCorem3Processor,
1109 0x2E => ProcessorFamily::IntelCorem5Processor,
1110 0x2F => ProcessorFamily::IntelCorem7Processor,
1111 0x30 => ProcessorFamily::AlphaFamily,
1112 0x31 => ProcessorFamily::Alpha21064,
1113 0x32 => ProcessorFamily::Alpha21066,
1114 0x33 => ProcessorFamily::Alpha21164,
1115 0x34 => ProcessorFamily::Alpha21164PC,
1116 0x35 => ProcessorFamily::Alpha21164a,
1117 0x36 => ProcessorFamily::Alpha21264,
1118 0x37 => ProcessorFamily::Alpha21364,
1119 0x38 => ProcessorFamily::AMDTurionIIUltraDualCoreMobileMProcessorFamily,
1120 0x39 => ProcessorFamily::AMDTurionIIDualCoreMobileMProcessorFamily,
1121 0x3A => ProcessorFamily::AMDAthlonIIDualCoreMProcessorFamily,
1122 0x3B => ProcessorFamily::AMDOpteron6100SeriesProcessor,
1123 0x3C => ProcessorFamily::AMDOpteron4100SeriesProcessor,
1124 0x3D => ProcessorFamily::AMDOpteron6200SeriesProcessor,
1125 0x3E => ProcessorFamily::AMDOpteron4200SeriesProcessor,
1126 0x3F => ProcessorFamily::AMDFXSeriesProcessor,
1127 0x40 => ProcessorFamily::MIPSFamily,
1128 0x41 => ProcessorFamily::MIPSR4000,
1129 0x42 => ProcessorFamily::MIPSR4200,
1130 0x43 => ProcessorFamily::MIPSR4400,
1131 0x44 => ProcessorFamily::MIPSR4600,
1132 0x45 => ProcessorFamily::MIPSR10000,
1133 0x46 => ProcessorFamily::AMDCSeriesProcessor,
1134 0x47 => ProcessorFamily::AMDESeriesProcessor,
1135 0x48 => ProcessorFamily::AMDASeriesProcessor,
1136 0x49 => ProcessorFamily::AMDGSeriesProcessor,
1137 0x4A => ProcessorFamily::AMDZSeriesProcessor,
1138 0x4B => ProcessorFamily::AMDRSeriesProcessor,
1139 0x4C => ProcessorFamily::AMDOpteron4300SeriesProcessor,
1140 0x4D => ProcessorFamily::AMDOpteron6300SeriesProcessor,
1141 0x4E => ProcessorFamily::AMDOpteron3300SeriesProcessor,
1142 0x4F => ProcessorFamily::AMDFireProSeriesProcessor,
1143 0x50 => ProcessorFamily::SPARCFamily,
1144 0x51 => ProcessorFamily::SuperSPARC,
1145 0x52 => ProcessorFamily::MicroSparcii,
1146 0x53 => ProcessorFamily::MicroSparciiep,
1147 0x54 => ProcessorFamily::UltraSPARC,
1148 0x55 => ProcessorFamily::UltraSPARCII,
1149 0x56 => ProcessorFamily::UltraSPARCIii,
1150 0x57 => ProcessorFamily::UltraSPARCIII,
1151 0x58 => ProcessorFamily::UltraSPARCIIIi,
1152 0x60 => ProcessorFamily::M68040Family,
1153 0x61 => ProcessorFamily::M68xxx,
1154 0x62 => ProcessorFamily::M68000,
1155 0x63 => ProcessorFamily::M68010,
1156 0x64 => ProcessorFamily::M68020,
1157 0x65 => ProcessorFamily::M68030,
1158 0x66 => ProcessorFamily::AMDAthlonX4QuadCoreProcessorFamily,
1159 0x67 => ProcessorFamily::AMDOpteronX1000SeriesProcessor,
1160 0x68 => ProcessorFamily::AMDOpteronX2000SeriesAPU,
1161 0x69 => ProcessorFamily::AMDOpteronASeriesProcessor,
1162 0x6A => ProcessorFamily::AMDOpteronX3000SeriesAPU,
1163 0x6B => ProcessorFamily::AMDZenProcessorFamily,
1164 0x70 => ProcessorFamily::HobbitFamily,
1165 0x78 => ProcessorFamily::CrusoeTM5000Family,
1166 0x79 => ProcessorFamily::CrusoeTM3000Family,
1167 0x7A => ProcessorFamily::EfficeonTM8000Family,
1168 0x80 => ProcessorFamily::Weitek,
1169 0x82 => ProcessorFamily::Itaniumprocessor,
1170 0x83 => ProcessorFamily::AMDAthlon64ProcessorFamily,
1171 0x84 => ProcessorFamily::AMDOpteronProcessorFamily,
1172 0x85 => ProcessorFamily::AMDSempronProcessorFamily,
1173 0x86 => ProcessorFamily::AMDTurion64MobileTechnology,
1174 0x87 => ProcessorFamily::DualCoreAMDOpteronProcessorFamily,
1175 0x88 => ProcessorFamily::AMDAthlon64X2DualCoreProcessorFamily,
1176 0x89 => ProcessorFamily::AMDTurion64X2MobileTechnology,
1177 0x8A => ProcessorFamily::QuadCoreAMDOpteronProcessorFamily,
1178 0x8B => ProcessorFamily::ThirdGenerationAMDOpteronProcessorFamily,
1179 0x8C => ProcessorFamily::AMDPhenomFXQuadCoreProcessorFamily,
1180 0x8D => ProcessorFamily::AMDPhenomX4QuadCoreProcessorFamily,
1181 0x8E => ProcessorFamily::AMDPhenomX2DualCoreProcessorFamily,
1182 0x8F => ProcessorFamily::AMDAthlonX2DualCoreProcessorFamily,
1183 0x90 => ProcessorFamily::PARISCFamily,
1184 0x91 => ProcessorFamily::PARISC8500,
1185 0x92 => ProcessorFamily::PARISC8000,
1186 0x93 => ProcessorFamily::PARISC7300LC,
1187 0x94 => ProcessorFamily::PARISC7200,
1188 0x95 => ProcessorFamily::PARISC7100LC,
1189 0x96 => ProcessorFamily::PARISC7100,
1190 0xA0 => ProcessorFamily::V30Family,
1191 0xA1 => ProcessorFamily::QuadCoreIntelXeonProcessor3200Series,
1192 0xA2 => ProcessorFamily::DualCoreIntelXeonProcessor3000Series,
1193 0xA3 => ProcessorFamily::QuadCoreIntelXeonProcessor5300Series,
1194 0xA4 => ProcessorFamily::DualCoreIntelXeonProcessor5100Series,
1195 0xA5 => ProcessorFamily::DualCoreIntelXeonProcessor5000Series,
1196 0xA6 => ProcessorFamily::DualCoreIntelXeonProcessorLV,
1197 0xA7 => ProcessorFamily::DualCoreIntelXeonProcessorULV,
1198 0xA8 => ProcessorFamily::DualCoreIntelXeonProcessor7100Series,
1199 0xA9 => ProcessorFamily::QuadCoreIntelXeonProcessor5400Series,
1200 0xAA => ProcessorFamily::QuadCoreIntelXeonProcessor,
1201 0xAB => ProcessorFamily::DualCoreIntelXeonProcessor5200Series,
1202 0xAC => ProcessorFamily::DualCoreIntelXeonProcessor7200Series,
1203 0xAD => ProcessorFamily::QuadCoreIntelXeonProcessor7300Series,
1204 0xAE => ProcessorFamily::QuadCoreIntelXeonProcessor7400Series,
1205 0xAF => ProcessorFamily::MultiCoreIntelXeonProcessor7400Series,
1206 0xB0 => ProcessorFamily::PentiumIIIXeonProcessor,
1207 0xB1 => ProcessorFamily::PentiumIIIProcessorwithIntelSpeedStepTechnology,
1208 0xB2 => ProcessorFamily::Pentium4Processor,
1209 0xB3 => ProcessorFamily::IntelXeonProcessor,
1210 0xB4 => ProcessorFamily::AS400Family,
1211 0xB5 => ProcessorFamily::IntelXeonProcessorMP,
1212 0xB6 => ProcessorFamily::AMDAthlonXPProcessorFamily,
1213 0xB7 => ProcessorFamily::AMDAthlonMPProcessorFamily,
1214 0xB8 => ProcessorFamily::IntelItanium2Processor,
1215 0xB9 => ProcessorFamily::IntelPentiumMProcessor,
1216 0xBA => ProcessorFamily::IntelCeleronDProcessor,
1217 0xBB => ProcessorFamily::IntelPentiumDProcessor,
1218 0xBC => ProcessorFamily::IntelPentiumProcessorExtremeEdition,
1219 0xBD => ProcessorFamily::IntelCoreSoloProcessor,
1220 0xBF => ProcessorFamily::IntelCore2DuoProcessor,
1221 0xC0 => ProcessorFamily::IntelCore2SoloProcessor,
1222 0xC1 => ProcessorFamily::IntelCore2ExtremeProcessor,
1223 0xC2 => ProcessorFamily::IntelCore2QuadProcessor,
1224 0xC3 => ProcessorFamily::IntelCore2ExtremeMobileProcessor,
1225 0xC4 => ProcessorFamily::IntelCore2DuoMobileProcessor,
1226 0xC5 => ProcessorFamily::IntelCore2SoloMobileProcessor,
1227 0xC6 => ProcessorFamily::IntelCorei7Processor,
1228 0xC7 => ProcessorFamily::DualCoreIntelCeleronProcessor,
1229 0xC8 => ProcessorFamily::IBM390Family,
1230 0xC9 => ProcessorFamily::G4,
1231 0xCA => ProcessorFamily::G5,
1232 0xCB => ProcessorFamily::ESA390G6,
1233 0xCC => ProcessorFamily::ZArchitecturebase,
1234 0xCD => ProcessorFamily::IntelCorei5processor,
1235 0xCE => ProcessorFamily::IntelCorei3processor,
1236 0xCF => ProcessorFamily::IntelCorei9processor,
1237 0xD2 => ProcessorFamily::VIAC7MProcessorFamily,
1238 0xD3 => ProcessorFamily::VIAC7DProcessorFamily,
1239 0xD4 => ProcessorFamily::VIAC7ProcessorFamily,
1240 0xD5 => ProcessorFamily::VIAEdenProcessorFamily,
1241 0xD6 => ProcessorFamily::MultiCoreIntelXeonProcessor,
1242 0xD7 => ProcessorFamily::DualCoreIntelXeonProcessor3xxxSeries,
1243 0xD8 => ProcessorFamily::QuadCoreIntelXeonProcessor3xxxSeries,
1244 0xD9 => ProcessorFamily::VIANanoProcessorFamily,
1245 0xDA => ProcessorFamily::DualCoreIntelXeonProcessor5xxxSeries,
1246 0xDB => ProcessorFamily::QuadCoreIntelXeonProcessor5xxxSeries,
1247 0xDD => ProcessorFamily::DualCoreIntelXeonProcessor7xxxSeries,
1248 0xDE => ProcessorFamily::QuadCoreIntelXeonProcessor7xxxSeries,
1249 0xDF => ProcessorFamily::MultiCoreIntelXeonProcessor7xxxSeries,
1250 0xE0 => ProcessorFamily::MultiCoreIntelXeonProcessor3400Series,
1251 0xE4 => ProcessorFamily::AMDOpteron3000SeriesProcessor,
1252 0xE5 => ProcessorFamily::AMDSempronIIProcessor,
1253 0xE6 => ProcessorFamily::EmbeddedAMDOpteronQuadCoreProcessorFamily,
1254 0xE7 => ProcessorFamily::AMDPhenomTripleCoreProcessorFamily,
1255 0xE8 => ProcessorFamily::AMDTurionUltraDualCoreMobileProcessorFamily,
1256 0xE9 => ProcessorFamily::AMDTurionDualCoreMobileProcessorFamily,
1257 0xEA => ProcessorFamily::AMDAthlonDualCoreProcessorFamily,
1258 0xEB => ProcessorFamily::AMDSempronSIProcessorFamily,
1259 0xEC => ProcessorFamily::AMDPhenomIIProcessorFamily,
1260 0xED => ProcessorFamily::AMDAthlonIIProcessorFamily,
1261 0xEE => ProcessorFamily::SixCoreAMDOpteronProcessorFamily,
1262 0xEF => ProcessorFamily::AMDSempronMProcessorFamily,
1263 0xFA => ProcessorFamily::I860,
1264 0xFB => ProcessorFamily::I960,
1265 0xFE => ProcessorFamily::SeeProcessorFamily2,
1266 0x100 => ProcessorFamily::ARMv7,
1267 0x101 => ProcessorFamily::ARMv8,
1268 0x102 => ProcessorFamily::ARMv9,
1269 0x104 => ProcessorFamily::SH3,
1270 0x105 => ProcessorFamily::SH4,
1271 0x118 => ProcessorFamily::ARM,
1272 0x119 => ProcessorFamily::StrongARM,
1273 0x12C => ProcessorFamily::Cyrix6x86,
1274 0x12D => ProcessorFamily::MediaGX,
1275 0x12E => ProcessorFamily::MII,
1276 0x140 => ProcessorFamily::WinChip,
1277 0x15E => ProcessorFamily::DSP,
1278 0x1F4 => ProcessorFamily::VideoProcessor,
1279 0x200 => ProcessorFamily::RISCVRV32,
1280 0x201 => ProcessorFamily::RISCVRV64,
1281 0x202 => ProcessorFamily::RISCVRV128,
1282 0x258 => ProcessorFamily::LoongArch,
1283 0x259 => ProcessorFamily::Longsoon1ProcessorFamily,
1284 0x25A => ProcessorFamily::Longsoon2ProcessorFamily,
1285 0x25B => ProcessorFamily::Longsoon3ProcessorFamily,
1286 0x25C => ProcessorFamily::Longsoon2KProcessorFamily,
1287 0x25D => ProcessorFamily::Longsoon3AProcessorFamily,
1288 0x25E => ProcessorFamily::Longsoon3BProcessorFamily,
1289 0x25F => ProcessorFamily::Longsoon3CProcessorFamily,
1290 0x260 => ProcessorFamily::Longsoon3DProcessorFamily,
1291 0x261 => ProcessorFamily::Longsoon3EProcessorFamily,
1292 0x262 => ProcessorFamily::DualCoreLoongson2KProcessor2xxxSeries,
1293 0x26C => ProcessorFamily::QuadCoreLoongson3AProcessor5xxxSeries,
1294 0x26D => ProcessorFamily::MultiCoreLoongson3AProcessor5xxxSeries,
1295 0x26E => ProcessorFamily::QuadCoreLoongson3BProcessor5xxxSeries,
1296 0x26F => ProcessorFamily::MultiCoreLoongson3BProcessor5xxxSeries,
1297 0x270 => ProcessorFamily::MultiCoreLoongson3CProcessor5xxxSeries,
1298 0x271 => ProcessorFamily::MultiCoreLoongson3DProcessor5xxxSeries,
1299 _ => ProcessorFamily::None,
1300 }
1301 }
1302}
1303
1304pub struct ProcessorUpgradeData {
1306 pub raw: u8,
1313 pub value: ProcessorUpgrade,
1315}
1316
1317impl fmt::Debug for ProcessorUpgradeData {
1318 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1319 fmt.debug_struct(std::any::type_name::<ProcessorUpgradeData>())
1320 .field("raw", &self.raw)
1321 .field("value", &self.value)
1322 .finish()
1323 }
1324}
1325
1326impl Serialize for ProcessorUpgradeData {
1327 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1328 where
1329 S: Serializer,
1330 {
1331 let mut state = serializer.serialize_struct("ProcessorUpgradeData", 2)?;
1332 state.serialize_field("raw", &self.raw)?;
1333 state.serialize_field("value", &self.value)?;
1334 state.end()
1335 }
1336}
1337
1338impl Deref for ProcessorUpgradeData {
1339 type Target = ProcessorUpgrade;
1340
1341 fn deref(&self) -> &Self::Target {
1342 &self.value
1343 }
1344}
1345
1346#[derive(Serialize, Debug, PartialEq, Eq)]
1348pub enum ProcessorUpgrade {
1349 Other,
1351 Unknown,
1353 DaughterBoard,
1355 ZIFSocket,
1357 ReplaceablePiggyBack,
1359 NoUpgrade,
1361 LIFSocket,
1363 Slot1,
1365 Slot2,
1367 PinSocket370,
1369 SlotA,
1371 SlotM,
1373 Socket423,
1375 SocketASocket462,
1377 Socket478,
1379 Socket754,
1381 Socket940,
1383 Socket939,
1385 SocketmPGA604,
1387 SocketLGA771,
1389 SocketLGA775,
1391 SocketS1,
1393 SocketAM2,
1395 SocketF1207,
1397 SocketLGA1366,
1399 SocketG34,
1401 SocketAM3,
1403 SocketC32,
1405 SocketLGA1156,
1407 SocketLGA1567,
1409 SocketPGA988A,
1411 SocketBGA1288,
1413 SocketrPGA988B,
1415 SocketBGA1023,
1417 SocketBGA1224,
1419 SocketLGA1155,
1421 SocketLGA1356,
1423 SocketLGA2011,
1425 SocketFS1,
1427 SocketFS2,
1429 SocketFM1,
1431 SocketFM2,
1433 SocketLGA2011_3,
1435 SocketLGA1356_3,
1437 SocketLGA1150,
1439 SocketBGA1168,
1441 SocketBGA1234,
1443 SocketBGA1364,
1445 SocketAM4,
1447 SocketLGA1151,
1449 SocketBGA1356,
1451 SocketBGA1440,
1453 SocketBGA1515,
1455 SocketLGA3647_1,
1457 SocketSP3,
1459 SocketSP3r23,
1461 SocketLGA2066,
1463 SocketBGA1392,
1465 SocketBGA1510,
1467 SocketBGA1528,
1469 SocketLGA4189,
1471 SocketLGA1200,
1473 SocketLGA4677,
1475 SocketLGA1700,
1477 SocketBGA1744,
1479 SocketBGA1781,
1481 SocketBGA1211,
1483 SocketBGA2422,
1485 SocketLGA1211,
1487 SocketLGA2422,
1489 SocketLGA5773,
1491 SocketBGA5773,
1493 SocketAM5,
1495 SocketSP5,
1497 SocketSP6,
1499 SocketBGA883,
1501 SocketBGA1190,
1503 SocketBGA4129,
1505 SocketLGA4710,
1507 SocketLGA7529,
1509 None,
1511}
1512
1513impl From<u8> for ProcessorUpgradeData {
1514 fn from(raw: u8) -> Self {
1515 ProcessorUpgradeData {
1516 value: match raw {
1517 0x01 => ProcessorUpgrade::Other,
1518 0x02 => ProcessorUpgrade::Unknown,
1519 0x03 => ProcessorUpgrade::DaughterBoard,
1520 0x04 => ProcessorUpgrade::ZIFSocket,
1521 0x05 => ProcessorUpgrade::ReplaceablePiggyBack,
1522 0x06 => ProcessorUpgrade::NoUpgrade,
1523 0x07 => ProcessorUpgrade::LIFSocket,
1524 0x08 => ProcessorUpgrade::Slot1,
1525 0x09 => ProcessorUpgrade::Slot2,
1526 0x0A => ProcessorUpgrade::PinSocket370,
1527 0x0B => ProcessorUpgrade::SlotA,
1528 0x0C => ProcessorUpgrade::SlotM,
1529 0x0D => ProcessorUpgrade::Socket423,
1530 0x0E => ProcessorUpgrade::SocketASocket462,
1531 0x0F => ProcessorUpgrade::Socket478,
1532 0x10 => ProcessorUpgrade::Socket754,
1533 0x11 => ProcessorUpgrade::Socket940,
1534 0x12 => ProcessorUpgrade::Socket939,
1535 0x13 => ProcessorUpgrade::SocketmPGA604,
1536 0x14 => ProcessorUpgrade::SocketLGA771,
1537 0x15 => ProcessorUpgrade::SocketLGA775,
1538 0x16 => ProcessorUpgrade::SocketS1,
1539 0x17 => ProcessorUpgrade::SocketAM2,
1540 0x18 => ProcessorUpgrade::SocketF1207,
1541 0x19 => ProcessorUpgrade::SocketLGA1366,
1542 0x1A => ProcessorUpgrade::SocketG34,
1543 0x1B => ProcessorUpgrade::SocketAM3,
1544 0x1C => ProcessorUpgrade::SocketC32,
1545 0x1D => ProcessorUpgrade::SocketLGA1156,
1546 0x1E => ProcessorUpgrade::SocketLGA1567,
1547 0x1F => ProcessorUpgrade::SocketPGA988A,
1548 0x20 => ProcessorUpgrade::SocketBGA1288,
1549 0x21 => ProcessorUpgrade::SocketrPGA988B,
1550 0x22 => ProcessorUpgrade::SocketBGA1023,
1551 0x23 => ProcessorUpgrade::SocketBGA1224,
1552 0x24 => ProcessorUpgrade::SocketLGA1155,
1553 0x25 => ProcessorUpgrade::SocketLGA1356,
1554 0x26 => ProcessorUpgrade::SocketLGA2011,
1555 0x27 => ProcessorUpgrade::SocketFS1,
1556 0x28 => ProcessorUpgrade::SocketFS2,
1557 0x29 => ProcessorUpgrade::SocketFM1,
1558 0x2A => ProcessorUpgrade::SocketFM2,
1559 0x2B => ProcessorUpgrade::SocketLGA2011_3,
1560 0x2C => ProcessorUpgrade::SocketLGA1356_3,
1561 0x2D => ProcessorUpgrade::SocketLGA1150,
1562 0x2E => ProcessorUpgrade::SocketBGA1168,
1563 0x2F => ProcessorUpgrade::SocketBGA1234,
1564 0x30 => ProcessorUpgrade::SocketBGA1364,
1565 0x31 => ProcessorUpgrade::SocketAM4,
1566 0x32 => ProcessorUpgrade::SocketLGA1151,
1567 0x33 => ProcessorUpgrade::SocketBGA1356,
1568 0x34 => ProcessorUpgrade::SocketBGA1440,
1569 0x35 => ProcessorUpgrade::SocketBGA1515,
1570 0x36 => ProcessorUpgrade::SocketLGA3647_1,
1571 0x37 => ProcessorUpgrade::SocketSP3,
1572 0x38 => ProcessorUpgrade::SocketSP3r23,
1573 0x39 => ProcessorUpgrade::SocketLGA2066,
1574 0x3A => ProcessorUpgrade::SocketBGA1392,
1575 0x3B => ProcessorUpgrade::SocketBGA1510,
1576 0x3C => ProcessorUpgrade::SocketBGA1528,
1577 0x3D => ProcessorUpgrade::SocketLGA4189,
1578 0x3E => ProcessorUpgrade::SocketLGA1200,
1579 0x3F => ProcessorUpgrade::SocketLGA4677,
1580 0x40 => ProcessorUpgrade::SocketLGA1700,
1581 0x41 => ProcessorUpgrade::SocketBGA1744,
1582 0x42 => ProcessorUpgrade::SocketBGA1781,
1583 0x43 => ProcessorUpgrade::SocketBGA1211,
1584 0x44 => ProcessorUpgrade::SocketBGA2422,
1585 0x45 => ProcessorUpgrade::SocketLGA1211,
1586 0x46 => ProcessorUpgrade::SocketLGA2422,
1587 0x47 => ProcessorUpgrade::SocketLGA5773,
1588 0x48 => ProcessorUpgrade::SocketBGA5773,
1589 0x49 => ProcessorUpgrade::SocketAM5,
1590 0x4A => ProcessorUpgrade::SocketSP5,
1591 0x4B => ProcessorUpgrade::SocketSP6,
1592 0x4C => ProcessorUpgrade::SocketBGA883,
1593 0x4D => ProcessorUpgrade::SocketBGA1190,
1594 0x4E => ProcessorUpgrade::SocketBGA4129,
1595 0x4F => ProcessorUpgrade::SocketLGA4710,
1596 0x50 => ProcessorUpgrade::SocketLGA7529,
1597 _ => ProcessorUpgrade::None,
1598 },
1599 raw,
1600 }
1601 }
1602}
1603
1604#[derive(PartialEq, Eq)]
1606pub struct ProcessorCharacteristics {
1607 pub raw: u16,
1609}
1610
1611impl Deref for ProcessorCharacteristics {
1612 type Target = u16;
1613
1614 fn deref(&self) -> &Self::Target {
1615 &self.raw
1616 }
1617}
1618
1619impl From<u16> for ProcessorCharacteristics {
1620 fn from(raw: u16) -> Self {
1621 ProcessorCharacteristics { raw }
1622 }
1623}
1624
1625impl ProcessorCharacteristics {
1626 pub fn unknown(&self) -> bool {
1628 self.raw & 0x0002 == 0x0002
1629 }
1630
1631 pub fn bit_64capable(&self) -> bool {
1633 self.raw & 0x0004 == 0x0004
1634 }
1635
1636 pub fn multi_core(&self) -> bool {
1638 self.raw & 0x0008 == 0x0008
1639 }
1640
1641 pub fn hardware_thread(&self) -> bool {
1643 self.raw & 0x0010 == 0x0010
1644 }
1645
1646 pub fn execute_protection(&self) -> bool {
1648 self.raw & 0x0020 == 0x0020
1649 }
1650
1651 pub fn enhanced_virtualization(&self) -> bool {
1653 self.raw & 0x0040 == 0x0040
1654 }
1655
1656 pub fn power_performance_control(&self) -> bool {
1658 self.raw & 0x0080 == 0x0080
1659 }
1660
1661 pub fn bit_128capable(&self) -> bool {
1663 self.raw & 0x0100 == 0x0100
1664 }
1665
1666 pub fn arm_64soc_id(&self) -> bool {
1668 self.raw & 0x200 == 0x200
1669 }
1670}
1671
1672impl fmt::Debug for ProcessorCharacteristics {
1673 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1674 fmt.debug_struct(std::any::type_name::<ProcessorCharacteristics>())
1675 .field("raw", &self.raw)
1676 .field("unknown", &self.unknown())
1677 .field("bit_64capable", &self.bit_64capable())
1678 .field("multi_core", &self.multi_core())
1679 .field("hardware_thread", &self.hardware_thread())
1680 .field("execute_protection", &self.execute_protection())
1681 .field("enhanced_virtualization", &self.enhanced_virtualization())
1682 .field(
1683 "power_performance_control",
1684 &self.power_performance_control(),
1685 )
1686 .field("bit_128capable", &self.bit_128capable())
1687 .field("arm_64soc_id", &self.arm_64soc_id())
1688 .finish()
1689 }
1690}
1691
1692impl Serialize for ProcessorCharacteristics {
1693 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1694 where
1695 S: Serializer,
1696 {
1697 let mut state = serializer.serialize_struct("ProcessorCharacteristics", 10)?;
1698 state.serialize_field("raw", &self.raw)?;
1699 state.serialize_field("unknown", &self.unknown())?;
1700 state.serialize_field("bit_64capable", &self.bit_64capable())?;
1701 state.serialize_field("multi_core", &self.multi_core())?;
1702 state.serialize_field("hardware_thread", &self.hardware_thread())?;
1703 state.serialize_field("execute_protection", &self.execute_protection())?;
1704 state.serialize_field("enhanced_virtualization", &self.enhanced_virtualization())?;
1705 state.serialize_field(
1706 "power_performance_control",
1707 &self.power_performance_control(),
1708 )?;
1709 state.serialize_field("bit_128capable", &self.bit_128capable())?;
1710 state.serialize_field("arm_64soc_id", &self.arm_64soc_id())?;
1711 state.end()
1712 }
1713}
1714
1715#[derive(Serialize, Debug)]
1717pub enum ProcessorVoltage {
1718 CurrentVolts(f32),
1720 SupportedVolts(ProcessorSupportedVoltages),
1722}
1723
1724impl From<u8> for ProcessorVoltage {
1725 fn from(raw: u8) -> Self {
1726 if raw & 0b1000_0000 == 0b1000_0000 {
1727 ProcessorVoltage::CurrentVolts((raw & 0b0111_1111) as f32 / 10.0)
1728 } else {
1729 ProcessorVoltage::SupportedVolts(ProcessorSupportedVoltages::from(raw))
1730 }
1731 }
1732}
1733
1734#[derive(PartialEq, Eq)]
1736pub struct ProcessorSupportedVoltages {
1737 pub raw: u8,
1739}
1740
1741impl Deref for ProcessorSupportedVoltages {
1742 type Target = u8;
1743
1744 fn deref(&self) -> &Self::Target {
1745 &self.raw
1746 }
1747}
1748
1749impl From<u8> for ProcessorSupportedVoltages {
1750 fn from(raw: u8) -> Self {
1751 debug_assert_eq!(raw, raw & 0b0111_1111);
1752 ProcessorSupportedVoltages { raw }
1753 }
1754}
1755
1756impl ProcessorSupportedVoltages {
1757 pub fn volts_5_0(&self) -> bool {
1759 self.raw & 0x01 == 0x01
1760 }
1761
1762 pub fn volts_3_3(&self) -> bool {
1764 self.raw & 0x02 == 0x02
1765 }
1766
1767 pub fn volts_2_9(&self) -> bool {
1769 self.raw & 0x04 == 0x04
1770 }
1771
1772 pub fn voltages(&self) -> Vec<f32> {
1774 let mut result = Vec::new();
1775
1776 if self.volts_2_9() {
1777 result.push(2.9);
1778 }
1779
1780 if self.volts_3_3() {
1781 result.push(3.3);
1782 }
1783
1784 if self.volts_5_0() {
1785 result.push(5.0);
1786 }
1787
1788 result
1789 }
1790}
1791
1792impl fmt::Debug for ProcessorSupportedVoltages {
1793 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1794 fmt.debug_struct(std::any::type_name::<ProcessorSupportedVoltages>())
1795 .field("raw", &self.raw)
1796 .field("voltages", &self.voltages().as_slice())
1797 .finish()
1798 }
1799}
1800
1801impl Serialize for ProcessorSupportedVoltages {
1802 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1803 where
1804 S: Serializer,
1805 {
1806 let mut state = serializer.serialize_struct("ProcessorSupportedVoltages", 2)?;
1807 state.serialize_field("raw", &self.raw)?;
1808 state.serialize_field("voltages", &self.voltages().as_slice())?;
1809 state.end()
1810 }
1811}
1812
1813#[derive(Serialize)]
1815pub enum ProcessorExternalClock {
1816 Unknown,
1818 MHz(u16),
1820}
1821
1822impl From<u16> for ProcessorExternalClock {
1823 fn from(raw: u16) -> Self {
1824 match raw {
1825 0 => ProcessorExternalClock::Unknown,
1826 _ => ProcessorExternalClock::MHz(raw),
1827 }
1828 }
1829}
1830
1831impl fmt::Debug for ProcessorExternalClock {
1832 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1833 use ProcessorExternalClock::*;
1834 match self {
1835 Unknown => write! {fmt, "Unknown"},
1836 MHz(n) => write! {fmt, "{} MHz", n},
1837 }
1838 }
1839}
1840
1841#[derive(Serialize)]
1843pub enum ProcessorSpeed {
1844 Unknown,
1846 MHz(u16),
1848}
1849
1850impl From<u16> for ProcessorSpeed {
1851 fn from(raw: u16) -> Self {
1852 match raw {
1853 0 => ProcessorSpeed::Unknown,
1854 _ => ProcessorSpeed::MHz(raw),
1855 }
1856 }
1857}
1858
1859impl fmt::Debug for ProcessorSpeed {
1860 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1861 use ProcessorSpeed::*;
1862 match self {
1863 Unknown => write! {fmt, "Unknown"},
1864 MHz(n) => write! {fmt, "{} MHz", n},
1865 }
1866 }
1867}
1868
1869#[derive(PartialEq, Eq)]
1871pub struct ProcessorStatus {
1872 pub raw: u8,
1874}
1875
1876impl Deref for ProcessorStatus {
1877 type Target = u8;
1878
1879 fn deref(&self) -> &Self::Target {
1880 &self.raw
1881 }
1882}
1883
1884impl From<u8> for ProcessorStatus {
1885 fn from(raw: u8) -> Self {
1886 ProcessorStatus { raw }
1887 }
1888}
1889
1890impl ProcessorStatus {
1891 pub fn socket_populated(&self) -> bool {
1893 self.raw & 0b0100_0000 == 0b0100_0000
1894 }
1895
1896 pub fn cpu_status(&self) -> CpuStatus {
1898 CpuStatus::from(self.raw)
1899 }
1900}
1901
1902impl fmt::Debug for ProcessorStatus {
1903 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
1904 fmt.debug_struct(std::any::type_name::<ProcessorStatus>())
1905 .field("raw", &self.raw)
1906 .field("socket_populated", &self.socket_populated())
1907 .field("cpu_status", &self.cpu_status())
1908 .finish()
1909 }
1910}
1911
1912impl Serialize for ProcessorStatus {
1913 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1914 where
1915 S: Serializer,
1916 {
1917 let mut state = serializer.serialize_struct("ProcessorStatus", 3)?;
1918 state.serialize_field("raw", &self.raw)?;
1919 state.serialize_field("socket_populated", &self.socket_populated())?;
1920 state.serialize_field("cpu_status", &self.cpu_status())?;
1921 state.end()
1922 }
1923}
1924
1925#[derive(Serialize, Debug, PartialEq, Eq)]
1927pub enum CpuStatus {
1928 Unknown,
1930 Enabled,
1932 UserDisabled,
1934 BiosDisabled,
1936 Idle,
1938 Other,
1940 None,
1942}
1943
1944impl From<u8> for CpuStatus {
1945 fn from(raw: u8) -> Self {
1946 match raw & 0b0000_0111 {
1947 0 => CpuStatus::Unknown,
1948 1 => CpuStatus::Enabled,
1949 2 => CpuStatus::UserDisabled,
1950 3 => CpuStatus::BiosDisabled,
1951 4 => CpuStatus::Idle,
1952 7 => CpuStatus::Other,
1953 _ => CpuStatus::None,
1954 }
1955 }
1956}
1957
1958#[derive(Serialize, Debug)]
1960pub enum CoreCount {
1961 Unknown,
1963 Count(u8),
1965 SeeCoreCount2,
1968}
1969
1970impl From<u8> for CoreCount {
1971 fn from(raw: u8) -> Self {
1972 match raw {
1973 0 => CoreCount::Unknown,
1974 0xFF => CoreCount::SeeCoreCount2,
1975 _ => CoreCount::Count(raw),
1976 }
1977 }
1978}
1979
1980#[derive(Serialize, Debug)]
1982pub enum CoreCount2 {
1983 Unknown,
1985 Count(u16),
1987 Reserved,
1989}
1990
1991impl From<u16> for CoreCount2 {
1992 fn from(raw: u16) -> Self {
1993 match raw {
1994 0 => CoreCount2::Unknown,
1995 0xFFFF => CoreCount2::Reserved,
1996 _ => CoreCount2::Count(raw),
1997 }
1998 }
1999}
2000
2001#[derive(Serialize, Debug)]
2003pub enum CoresEnabled {
2004 Unknown,
2006 Count(u8),
2008 SeeCoresEnabled2,
2011}
2012
2013impl From<u8> for CoresEnabled {
2014 fn from(raw: u8) -> Self {
2015 match raw {
2016 0 => CoresEnabled::Unknown,
2017 0xFF => CoresEnabled::SeeCoresEnabled2,
2018 _ => CoresEnabled::Count(raw),
2019 }
2020 }
2021}
2022
2023#[derive(Serialize, Debug)]
2025pub enum CoresEnabled2 {
2026 Unknown,
2028 Count(u16),
2030 Reserved,
2032}
2033
2034impl From<u16> for CoresEnabled2 {
2035 fn from(raw: u16) -> Self {
2036 match raw {
2037 0 => CoresEnabled2::Unknown,
2038 0xFFFF => CoresEnabled2::Reserved,
2039 _ => CoresEnabled2::Count(raw),
2040 }
2041 }
2042}
2043
2044#[derive(Serialize, Debug)]
2046pub enum ThreadCount {
2047 Unknown,
2049 Count(u8),
2051 SeeThreadCount2,
2054}
2055
2056impl From<u8> for ThreadCount {
2057 fn from(raw: u8) -> Self {
2058 match raw {
2059 0 => ThreadCount::Unknown,
2060 0xFF => ThreadCount::SeeThreadCount2,
2061 _ => ThreadCount::Count(raw),
2062 }
2063 }
2064}
2065
2066#[derive(Serialize, Debug)]
2068pub enum ThreadCount2 {
2069 Unknown,
2071 Count(u16),
2073 Reserved,
2075}
2076
2077impl From<u16> for ThreadCount2 {
2078 fn from(raw: u16) -> Self {
2079 match raw {
2080 0 => ThreadCount2::Unknown,
2081 0xFFFF => ThreadCount2::Reserved,
2082 _ => ThreadCount2::Count(raw),
2083 }
2084 }
2085}
2086
2087#[derive(Serialize, Debug)]
2089pub enum ThreadEnabled {
2090 Unknown,
2092 Count(u16),
2094 Reserved,
2096}
2097
2098impl From<u16> for ThreadEnabled {
2099 fn from(raw: u16) -> Self {
2100 match raw {
2101 0 => ThreadEnabled::Unknown,
2102 0xFFFF => ThreadEnabled::Reserved,
2103 _ => ThreadEnabled::Count(raw),
2104 }
2105 }
2106}
2107
2108#[cfg(test)]
2109mod tests {
2110 use super::*;
2111
2112 #[test]
2113 fn unit_test() {
2114 let struct_type4 = vec![
2115 0x04, 0x30, 0x56, 0x00, 0x01, 0x03, 0xB3, 0x02, 0x54, 0x06, 0x05, 0x00, 0xFF, 0xFB,
2116 0xEB, 0xBF, 0x03, 0x90, 0x64, 0x00, 0x3C, 0x0F, 0x10, 0x0E, 0x41, 0x01, 0x53, 0x00,
2117 0x54, 0x00, 0x55, 0x00, 0x00, 0x04, 0x00, 0x06, 0x06, 0x0C, 0xFC, 0x00, 0xB3, 0x00,
2118 0x06, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x43, 0x50, 0x55, 0x30, 0x00, 0x49, 0x6E, 0x74,
2119 0x65, 0x6C, 0x28, 0x52, 0x29, 0x20, 0x43, 0x6F, 0x72, 0x70, 0x6F, 0x72, 0x61, 0x74,
2120 0x69, 0x6F, 0x6E, 0x00, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x28, 0x52, 0x29, 0x20, 0x58,
2121 0x65, 0x6F, 0x6E, 0x28, 0x52, 0x29, 0x20, 0x57, 0x2D, 0x32, 0x31, 0x33, 0x33, 0x20,
2122 0x43, 0x50, 0x55, 0x20, 0x40, 0x20, 0x33, 0x2E, 0x36, 0x30, 0x47, 0x48, 0x7A, 0x00,
2123 0x55, 0x4E, 0x4B, 0x4E, 0x4F, 0x57, 0x4E, 0x00, 0x00,
2124 ];
2125
2126 let parts = UndefinedStruct::new(&struct_type4);
2127 let test_struct = SMBiosProcessorInformation::new(&parts);
2128
2129 assert_eq!(
2130 test_struct.socket_designation().to_string(),
2131 "CPU0".to_string()
2132 );
2133 assert_eq!(
2134 *test_struct.processor_type().unwrap(),
2135 ProcessorType::CentralProcessor
2136 );
2137 assert_eq!(
2138 *test_struct.processor_family().unwrap(),
2139 ProcessorFamily::IntelXeonProcessor
2140 );
2141 assert_eq!(
2142 test_struct.processor_manufacturer().to_string(),
2143 "Intel(R) Corporation".to_string()
2144 );
2145 assert_eq!(
2146 test_struct.processor_id(),
2147 Some(&[0x54u8, 0x06, 0x05, 0x00, 0xFF, 0xFB, 0xEB, 0xBF])
2148 );
2149 assert_eq!(
2150 test_struct.processor_version().to_string(),
2151 "Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz".to_string()
2152 );
2153 match test_struct.voltage().unwrap() {
2154 ProcessorVoltage::CurrentVolts(volts) => assert_eq!(volts, 1.6),
2155 ProcessorVoltage::SupportedVolts(_) => panic!("expected current volts"),
2156 }
2157 match test_struct.external_clock().unwrap() {
2158 ProcessorExternalClock::MHz(mhz) => assert_eq!(mhz, 100),
2159 ProcessorExternalClock::Unknown => panic!("expected MHz"),
2160 }
2161 match test_struct.max_speed().unwrap() {
2162 ProcessorSpeed::MHz(mhz) => assert_eq!(mhz, 3900),
2163 ProcessorSpeed::Unknown => panic!("expected MHz"),
2164 }
2165 match test_struct.current_speed().unwrap() {
2166 ProcessorSpeed::MHz(mhz) => assert_eq!(mhz, 3600),
2167 ProcessorSpeed::Unknown => panic!("expected MHz"),
2168 }
2169 let processor_status = test_struct.status().unwrap();
2170 assert!(processor_status.socket_populated());
2171 assert_eq!(processor_status.cpu_status(), CpuStatus::Enabled);
2172 assert_eq!(
2173 *test_struct.processor_upgrade().unwrap(),
2174 ProcessorUpgrade::Other
2175 );
2176 assert_eq!(*test_struct.l1cache_handle().unwrap(), 83);
2177 assert_eq!(*test_struct.l2cache_handle().unwrap(), 84);
2178 assert_eq!(*test_struct.l3cache_handle().unwrap(), 85);
2179 assert_eq!(test_struct.serial_number().to_string(), "".to_string());
2180 assert_eq!(test_struct.asset_tag().to_string(), "UNKNOWN".to_string());
2181 assert_eq!(test_struct.part_number().to_string(), "".to_string());
2182 match test_struct.core_count().unwrap() {
2183 CoreCount::Count(number) => assert_eq!(number, 6),
2184 CoreCount::Unknown => panic!("expected number"),
2185 CoreCount::SeeCoreCount2 => panic!("expected number"),
2186 }
2187 match test_struct.cores_enabled().unwrap() {
2188 CoresEnabled::Count(number) => assert_eq!(number, 6),
2189 CoresEnabled::Unknown => panic!("expected number"),
2190 CoresEnabled::SeeCoresEnabled2 => panic!("expected number"),
2191 }
2192 match test_struct.thread_count().unwrap() {
2193 ThreadCount::Count(number) => assert_eq!(number, 12),
2194 ThreadCount::Unknown => panic!("expected number"),
2195 ThreadCount::SeeThreadCount2 => panic!("expected number"),
2196 }
2197 assert_eq!(
2198 test_struct.processor_characteristics(),
2199 Some(ProcessorCharacteristics::from(252))
2200 );
2201 assert_eq!(
2202 *test_struct.processor_family_2().unwrap(),
2203 ProcessorFamily::IntelXeonProcessor
2204 );
2205
2206 match test_struct.core_count_2().unwrap() {
2207 CoreCount2::Count(number) => assert_eq!(number, 6),
2208 CoreCount2::Unknown => panic!("expected number"),
2209 CoreCount2::Reserved => panic!("expected number"),
2210 }
2211 match test_struct.cores_enabled_2().unwrap() {
2212 CoresEnabled2::Count(number) => assert_eq!(number, 6),
2213 CoresEnabled2::Unknown => panic!("expected number"),
2214 CoresEnabled2::Reserved => panic!("expected number"),
2215 }
2216 match test_struct.thread_count_2().unwrap() {
2217 ThreadCount2::Count(number) => assert_eq!(number, 12),
2218 ThreadCount2::Unknown => panic!("expected number"),
2219 ThreadCount2::Reserved => panic!("expected number"),
2220 }
2221 }
2222}