forked from jrgerber/smbios-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory_device.rs
1394 lines (1277 loc) · 48.6 KB
/
memory_device.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use crate::core::{strings::*, Handle, UndefinedStruct};
use crate::SMBiosStruct;
use serde::{ser::SerializeStruct, Serialize, Serializer};
use std::fmt;
use std::ops::Deref;
/// # Memory Device (Type 17)
///
/// This structure describes a single memory device that is part of a larger [super::SMBiosPhysicalMemoryArray] (Type 16) structure.
///
/// Compliant with:
/// DMTF SMBIOS Reference Specification 3.7.0 (DSP0134)
/// Document Date: 2023-07-21
pub struct SMBiosMemoryDevice<'a> {
parts: &'a UndefinedStruct,
}
impl<'a> SMBiosStruct<'a> for SMBiosMemoryDevice<'a> {
const STRUCT_TYPE: u8 = 17u8;
fn new(parts: &'a UndefinedStruct) -> Self {
Self { parts }
}
fn parts(&self) -> &'a UndefinedStruct {
self.parts
}
}
impl<'a> SMBiosMemoryDevice<'a> {
/// Handle, or instance number, associated with the
/// [super::SMBiosPhysicalMemoryArray] to which this device belongs
pub fn physical_memory_array_handle(&self) -> Option<Handle> {
self.parts.get_field_handle(0x04)
}
/// Handle, or instance number, associated with any
/// error that was previously detected for the device
/// If the system does not provide the error information
/// structure, the field contains FFFEh; otherwise, the
/// field contains either FFFFh (if no error was
/// detected) or the handle of the error-information
/// structure ([super::SMBiosMemoryErrorInformation32] or
/// [super::SMBiosMemoryErrorInformation64]).
pub fn memory_error_information_handle(&self) -> Option<Handle> {
self.parts.get_field_handle(0x06)
}
/// Total width, in bits, of this memory device, including
/// any check or error-correction bits
/// If there are no error-correction bits, this value
/// should be equal to Data Width. If the width is
/// unknown, the field is set to FFFFh.
pub fn total_width(&self) -> Option<u16> {
self.parts.get_field_word(0x08)
}
/// Data width, in bits, of this memory device
/// A Data Width of 0 and a Total Width of 8 indicates
/// that the device is being used solely to provide 8
/// error-correction bits. If the width is unknown, the
/// field is set to FFFFh.
pub fn data_width(&self) -> Option<u16> {
self.parts.get_field_word(0x0A)
}
/// Size of the memory device
pub fn size(&self) -> Option<MemorySize> {
self.parts
.get_field_word(0x0C)
.map(|raw| MemorySize::from(raw))
}
/// Implementation form factor for this memory device
pub fn form_factor(&self) -> Option<MemoryFormFactorData> {
self.parts
.get_field_byte(0x0E)
.map(|raw| MemoryFormFactorData::from(raw))
}
/// Identifies when the Memory Device is one of a set
/// of Memory Devices that must be populated with all
/// devices of the same type and size, and the set to
/// which this device belongs
/// A value of 0 indicates that the device is not part of a
/// set; a value of FFh indicates that the attribute is
/// unknown.
/// NOTE: A Device Set number must be unique within the
/// context of the Memory Array containing this Memory
/// Device.
pub fn device_set(&self) -> Option<u8> {
self.parts.get_field_byte(0x0F)
}
/// Identifies the physically-labeled socket or board position where
/// the memory device is located
/// EXAMPLE: “SIMM 3”
pub fn device_locator(&self) -> SMBiosString {
self.parts.get_field_string(0x10)
}
/// Identifies the physically labeled bank where the memory device is located
/// EXAMPLE: “Bank 0” or “A”
pub fn bank_locator(&self) -> SMBiosString {
self.parts.get_field_string(0x11)
}
/// Type of memory used in this device
pub fn memory_type(&self) -> Option<MemoryDeviceTypeData> {
self.parts
.get_field_byte(0x12)
.map(|raw| MemoryDeviceTypeData::from(raw))
}
/// Additional detail on the memory device type
pub fn type_detail(&self) -> Option<MemoryTypeDetails> {
self.parts
.get_field_word(0x13)
.map(|raw| MemoryTypeDetails::from(raw))
}
/// The maximum capable speed of the
/// device, in megatransfers per second (MT/s).
pub fn speed(&self) -> Option<MemorySpeed> {
self.parts
.get_field_word(0x15)
.map(|raw| MemorySpeed::from(raw))
}
/// The manufacturer of this memory device
pub fn manufacturer(&self) -> SMBiosString {
self.parts.get_field_string(0x17)
}
/// The serial number of this memory device.
/// This value is set by the manufacturer and normally
/// is not changeable.
pub fn serial_number(&self) -> SMBiosString {
self.parts.get_field_string(0x18)
}
/// The asset tag of this memory device
pub fn asset_tag(&self) -> SMBiosString {
self.parts.get_field_string(0x19)
}
/// The part number of this memory device.
/// This value is set by the manufacturer and normally
/// is not changeable.
pub fn part_number(&self) -> SMBiosString {
self.parts.get_field_string(0x1A)
}
/// Bits 7-4: reserved
/// Bits 3-0: rank
/// Value=0 for unknown rank information
pub fn attributes(&self) -> Option<u8> {
self.parts.get_field_byte(0x1B)
}
/// Extended size of the memory device in MB (complements
/// the Size field at offset 0Ch)
pub fn extended_size(&self) -> Option<MemorySizeExtended> {
self.parts
.get_field_dword(0x1C)
.map(|raw| MemorySizeExtended::from(raw))
}
/// Identifies the configured speed of the memory
/// device, in megatransfers per second (MT/s). See
/// 7.18.4 for details.
/// 0000h = the speed is unknown
/// FFFFh = the speed is 65,535 MT/s or greater,
/// and the actual speed is stored in the Extended
/// Configured Memory Speed field
pub fn configured_memory_speed(&self) -> Option<MemorySpeed> {
self.parts
.get_field_word(0x20)
.map(|raw| MemorySpeed::from(raw))
}
/// Minimum operating voltage for this device, in
/// millivolts
/// If the value is 0, the voltage is unknown.
pub fn minimum_voltage(&self) -> Option<u16> {
self.parts.get_field_word(0x22)
}
/// Maximum operating voltage for this device, in
/// millivolts
/// If the value is 0, the voltage is unknown.
pub fn maximum_voltage(&self) -> Option<u16> {
self.parts.get_field_word(0x24)
}
/// Configured voltage for this device, in millivolts
/// If the value is 0, the voltage is unknown.
pub fn configured_voltage(&self) -> Option<u16> {
self.parts.get_field_word(0x26)
}
/// Memory technology type for this memory device.
pub fn memory_technology(&self) -> Option<MemoryDeviceTechnologyData> {
self.parts
.get_field_byte(0x28)
.map(|raw| MemoryDeviceTechnologyData::from(raw))
}
/// The operating modes supported by this memory device.
pub fn memory_operating_mode_capability(&self) -> Option<MemoryOperatingModeCapabilities> {
self.parts
.get_field_word(0x29)
.map(|raw| MemoryOperatingModeCapabilities::from(raw))
}
/// The firmware version of this memory device.
pub fn firmware_version(&self) -> SMBiosString {
self.parts.get_field_string(0x2B)
}
/// The two-byte module manufacturer ID found in the SPD of this memory device; LSB first.
pub fn module_manufacturer_id(&self) -> Option<u16> {
self.parts.get_field_word(0x2C)
}
/// The two-byte module product ID found in the SPD of this memory device; LSB first.
pub fn module_product_id(&self) -> Option<u16> {
self.parts.get_field_word(0x2E)
}
/// The two-byte memory subsystem controller manufacturer ID found in the SPD of this memory device; LSB first.
pub fn memory_subsystem_controller_manufacturer_id(&self) -> Option<u16> {
self.parts.get_field_word(0x30)
}
/// The two-byte memory subsystem controller product ID found in the SPD of this memory device; LSB first.
pub fn memory_subsystem_controller_product_id(&self) -> Option<u16> {
self.parts.get_field_word(0x32)
}
/// Size of the Non-volatile portion of the memory
/// device in Bytes, if any.
///
/// If the value is 0, there is no
/// non-volatile portion.
pub fn non_volatile_size(&self) -> Option<MemoryIndicatedSize> {
self.parts
.get_field_qword(0x34)
.map(|raw| MemoryIndicatedSize::from(raw))
}
/// Size of the Volatile portion of the memory device in
/// Bytes, if any.
///
/// If the value is 0, there is no Volatile
/// portion.
pub fn volatile_size(&self) -> Option<MemoryIndicatedSize> {
self.parts
.get_field_qword(0x3C)
.map(|raw| MemoryIndicatedSize::from(raw))
}
/// Size of the Cache portion of the memory device in
/// Bytes, if any.
///
/// If the value is 0, there is no Cache
/// portion.
pub fn cache_size(&self) -> Option<MemoryIndicatedSize> {
self.parts
.get_field_qword(0x44)
.map(|raw| MemoryIndicatedSize::from(raw))
}
/// Size of the Logical memory device in Bytes.
pub fn logical_size(&self) -> Option<MemoryIndicatedSize> {
self.parts
.get_field_qword(0x4C)
.map(|raw| MemoryIndicatedSize::from(raw))
}
/// Extended speed of the memory device
/// (complements the Speed field at offset 15h).
/// Identifies the maximum capable speed of the
/// device, in megatransfers per second (MT/s).
pub fn extended_speed(&self) -> Option<MemorySpeedExtended> {
self.parts
.get_field_dword(0x54)
.map(|raw| MemorySpeedExtended::from(raw))
}
/// Extended configured memory speed of the memory
/// device (complements the 'configured_memory_speed'
/// field at offset 20h).
///
/// Identifies the configured
/// speed of the memory device, in megatransfers per
/// second (MT/s)
///
/// The 'extended_speed' and 'extended_configured_memory_speed' fields are intended to represent
/// memory devices that operate faster than 65,535 MT/s, which cannot be described using the
/// Speed or Configured Memory Speed fields. These fields are only meaningful if the value
/// in the Speed or Configured Memory Speed fields are FFFFh. For compatibility with older
/// SMBIOS parsers, memory devices slower than 65,535 MT/s should represent their speed
/// using the Speed and Configured Memory Speed fields, leaving the Extended Speed and
/// Extended Configured Memory Speed fields set to 0.
///
/// Bit 31 is reserved for future use and must be set to 0
/// Bits 30:0 represent the speed or configured memory speed of the device in MT/s.
pub fn extended_configured_memory_speed(&self) -> Option<MemorySpeedExtended> {
self.parts
.get_field_dword(0x58)
.map(|raw| MemorySpeedExtended::from(raw))
}
/// The two-byte PMIC0 manufacturer ID found in the
/// SPD of this memory device; LSB first.
///
/// The PMIC0 Manufacturer ID indicates the manufacturer of the PMIC0 on memory device. This field shall
/// be set to the value of the SPD PMIC 0 Manufacturer ID Code. A value of 0000h indicates the PMIC0
/// Manufacturer ID is unknown.
///
/// NOTE The location (byte addresses) of the SPD PMIC 0 Manufacturer ID Code may vary and is defined
/// by the memory type/technology SPD Standard. For example, for RDIMM DDR5, this field will have the
/// first byte correspond to the value in byte 198 and the second byte corresponds to the value in byte 199.
/// If SPD doesn't contain Register Revision Number, this field shall be set to 0000h
pub fn pmic0_manufacturer_id(&self) -> Option<u16> {
self.parts.get_field_word(0x5C)
}
/// The PMIC 0 Revision Number found in the SPD of
/// this memory device.
///
/// The PMIC0 Revision Number indicates the revision of the PMIC0 on memory device. This field shall be
/// set to the value of the SPD PMIC 0 Revision Number. A value of FF00h indicates the PMIC0 Revision
/// Number is unknown.
///
/// NOTE The location (byte addresses) of the SPD PMIC 0 Revision Number may vary and is defined by the
/// memory type/technology SPD Standard. For example, for RDIMM DDR5, this field will have the first byte
/// correspond to the value in byte 201 and the second byte shall be set to 00h. If SPD doesn't contain
/// Register Revision Number, this field shall be set to FF00h.
pub fn pmic0_revision_number(&self) -> Option<u16> {
self.parts.get_field_word(0x5E)
}
/// The two-byte RCD manufacturer ID found in the
/// SPD of this memory device; LSB first.
///
/// The RCD Manufacturer ID indicates the manufacturer of the RCD on memory device. This field shall be
/// set to the value of the SPD Registering Clock Driver Manufacturer ID Code. A value of 0000h indicates
/// the RCD Manufacturer ID is unknown.
///
/// NOTE The location (byte addresses) of the SPD Registering Clock Driver Manufacturer ID Code may
/// vary and is defined by the memory type/technology SPD Standard. For example, for RDIMM DDR5, this
/// field will have the first byte correspond to the value in byte 240 and the second byte corresponds to the
/// value in byte 241. If SPD doesn't contain Register Revision Number, this field shall be set to 0000h.
pub fn rcd_manufacturer_id(&self) -> Option<u16> {
self.parts.get_field_word(0x60)
}
/// The RCD 0 Revision Number found in the SPD of
/// this memory device.
///
/// The RCD Revision Number indicates the revision of the RCD on memory device. This field shall be set to
/// the value of the SPD Register Revision Number. A value of FF00h indicates the RCD Revision Number is
/// unknown.
///
/// NOTE The location (byte addresses) of the SPD Register Revision Number may vary and is defined by
/// the memory type/technology SPD Standard. For example, for RDIMM DDR5, this field will have the first
/// byte correspond to the value in byte 243 and the second byte shall be set to 00h. If SPD doesn't contain
/// Register Revision Number, this field shall be set to FF00h
pub fn rcd_revision_number(&self) -> Option<u16> {
self.parts.get_field_word(0x62)
}
}
impl fmt::Debug for SMBiosMemoryDevice<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<SMBiosMemoryDevice<'_>>())
.field("header", &self.parts.header)
.field(
"physical_memory_array_handle",
&self.physical_memory_array_handle(),
)
.field(
"memory_error_information_handle",
&self.memory_error_information_handle(),
)
.field("total_width", &self.total_width())
.field("data_width", &self.data_width())
.field("size", &self.size())
.field("form_factor", &self.form_factor())
.field("device_set", &self.device_set())
.field("device_locator", &self.device_locator())
.field("bank_locator", &self.bank_locator())
.field("memory_type", &self.memory_type())
.field("type_detail", &self.type_detail())
.field("speed", &self.speed())
.field("manufacturer", &self.manufacturer())
.field("serial_number", &self.serial_number())
.field("asset_tag", &self.asset_tag())
.field("part_number", &self.part_number())
.field("attributes", &self.attributes())
.field("extended_size", &self.extended_size())
.field("configured_memory_speed", &self.configured_memory_speed())
.field("minimum_voltage", &self.minimum_voltage())
.field("maximum_voltage", &self.maximum_voltage())
.field("configured_voltage", &self.configured_voltage())
.field("memory_technology", &self.memory_technology())
.field(
"memory_operating_mode_capability",
&self.memory_operating_mode_capability(),
)
.field("firmware_version", &self.firmware_version())
.field("module_manufacturer_id", &self.module_manufacturer_id())
.field("module_product_id", &self.module_product_id())
.field(
"memory_subsystem_controller_manufacturer_id",
&self.memory_subsystem_controller_manufacturer_id(),
)
.field(
"memory_subsystem_controller_product_id",
&self.memory_subsystem_controller_product_id(),
)
.field("non_volatile_size", &self.non_volatile_size())
.field("volatile_size", &self.volatile_size())
.field("cache_size", &self.cache_size())
.field("logical_size", &self.logical_size())
.field("extended_speed", &self.extended_speed())
.field(
"extended_configured_memory_speed",
&self.extended_configured_memory_speed(),
)
.field("pmic0_manufacturer_id", &self.pmic0_manufacturer_id())
.field("pmic0_revision_number", &self.pmic0_revision_number())
.field("rcd_manufacturer_id", &self.rcd_manufacturer_id())
.field("rcd_revision_number", &self.rcd_revision_number())
.finish()
}
}
impl Serialize for SMBiosMemoryDevice<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("SMBiosMemoryDevice", 36)?;
state.serialize_field("header", &self.parts.header)?;
state.serialize_field(
"physical_memory_array_handle",
&self.physical_memory_array_handle(),
)?;
state.serialize_field(
"memory_error_information_handle",
&self.memory_error_information_handle(),
)?;
state.serialize_field("total_width", &self.total_width())?;
state.serialize_field("data_width", &self.data_width())?;
state.serialize_field("size", &self.size())?;
state.serialize_field("form_factor", &self.form_factor())?;
state.serialize_field("device_set", &self.device_set())?;
state.serialize_field("device_locator", &self.device_locator())?;
state.serialize_field("bank_locator", &self.bank_locator())?;
state.serialize_field("memory_type", &self.memory_type())?;
state.serialize_field("type_detail", &self.type_detail())?;
state.serialize_field("speed", &self.speed())?;
state.serialize_field("manufacturer", &self.manufacturer())?;
state.serialize_field("serial_number", &self.serial_number())?;
state.serialize_field("asset_tag", &self.asset_tag())?;
state.serialize_field("part_number", &self.part_number())?;
state.serialize_field("attributes", &self.attributes())?;
state.serialize_field("extended_size", &self.extended_size())?;
state.serialize_field("configured_memory_speed", &self.configured_memory_speed())?;
state.serialize_field("minimum_voltage", &self.minimum_voltage())?;
state.serialize_field("maximum_voltage", &self.maximum_voltage())?;
state.serialize_field("configured_voltage", &self.configured_voltage())?;
state.serialize_field("memory_technology", &self.memory_technology())?;
state.serialize_field(
"memory_operating_mode_capability",
&self.memory_operating_mode_capability(),
)?;
state.serialize_field("firmware_version", &self.firmware_version())?;
state.serialize_field("module_manufacturer_id", &self.module_manufacturer_id())?;
state.serialize_field("module_product_id", &self.module_product_id())?;
state.serialize_field(
"memory_subsystem_controller_manufacturer_id",
&self.memory_subsystem_controller_manufacturer_id(),
)?;
state.serialize_field(
"memory_subsystem_controller_product_id",
&self.memory_subsystem_controller_product_id(),
)?;
state.serialize_field("non_volatile_size", &self.non_volatile_size())?;
state.serialize_field("volatile_size", &self.volatile_size())?;
state.serialize_field("cache_size", &self.cache_size())?;
state.serialize_field("logical_size", &self.logical_size())?;
state.serialize_field("extended_speed", &self.extended_speed())?;
state.serialize_field(
"extended_configured_memory_speed",
&self.extended_configured_memory_speed(),
)?;
state.serialize_field("pmic0_manufacturer_id", &self.pmic0_manufacturer_id())?;
state.serialize_field("pmic0_revision_number", &self.pmic0_revision_number())?;
state.serialize_field("rcd_manufacturer_id", &self.rcd_manufacturer_id())?;
state.serialize_field("rcd_revision_number", &self.rcd_revision_number())?;
state.end()
}
}
/// # Memory Device - Type Data
#[derive(PartialEq, Eq)]
pub struct MemoryDeviceTypeData {
/// Raw value
///
/// _raw_ is most useful when _value_ is None.
/// This is most likely to occur when the standard was updated but
/// this library code has not been updated to match the current
/// standard.
pub raw: u8,
/// The contained [MemoryDeviceType] value
pub value: MemoryDeviceType,
}
impl fmt::Debug for MemoryDeviceTypeData {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<MemoryDeviceTypeData>())
.field("raw", &self.raw)
.field("value", &self.value)
.finish()
}
}
impl Serialize for MemoryDeviceTypeData {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("MemoryDeviceTypeData", 2)?;
state.serialize_field("raw", &self.raw)?;
state.serialize_field("value", &self.value)?;
state.end()
}
}
impl fmt::Display for MemoryDeviceTypeData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.value {
MemoryDeviceType::None => write!(f, "{}", &self.raw),
_ => write!(f, "{:?}", &self.value),
}
}
}
impl Deref for MemoryDeviceTypeData {
type Target = MemoryDeviceType;
fn deref(&self) -> &Self::Target {
&self.value
}
}
/// # Memory Device -Type
#[derive(Serialize, Debug, PartialEq, Eq)]
pub enum MemoryDeviceType {
/// Other
Other,
/// Unknown
Unknown,
/// DRAM
Dram,
/// EDRAM
Edram,
/// VRAM
Vram,
/// SRAM
Sram,
/// RAM
Ram,
/// ROM
Rom,
/// FLASH
Flash,
/// EEPROM
Eeprom,
/// FEPROM
Feprom,
/// EPROM
Eprom,
/// CDRAM
Cdram,
/// 3DRAM
ThreeDram,
/// SDRAM
Sdram,
/// SGRAM
Sgram,
/// RDRAM
Rdram,
/// DDR
Ddr,
/// DDR2
Ddr2,
/// DDR2 FB-DIMM
Ddr2Fbdimm,
/// DDR3
Ddr3,
/// FBD2
Fbd2,
/// DDR4
Ddr4,
/// LPDDR
Lpddr,
/// LPDDR2
Lpddr2,
/// LPDDR3
Lpddr3,
/// LPDDR4
Lpddr4,
/// Logical non-volatile device
LogicalNonVolatileDevice,
/// HBM (High Bandwidth Memory)
Hbm,
/// HBM2 (High Bandwidth Memory Generation 2)
Hbm2,
/// DDR5
Ddr5,
/// LPDDR5
Lpddr5,
/// HBM3
Hbm3,
/// A value unknown to this standard, check the raw value
None,
}
impl From<u8> for MemoryDeviceTypeData {
fn from(raw: u8) -> Self {
MemoryDeviceTypeData {
value: match raw {
0x01 => MemoryDeviceType::Other,
0x02 => MemoryDeviceType::Unknown,
0x03 => MemoryDeviceType::Dram,
0x04 => MemoryDeviceType::Edram,
0x05 => MemoryDeviceType::Vram,
0x06 => MemoryDeviceType::Sram,
0x07 => MemoryDeviceType::Ram,
0x08 => MemoryDeviceType::Rom,
0x09 => MemoryDeviceType::Flash,
0x0A => MemoryDeviceType::Eeprom,
0x0B => MemoryDeviceType::Feprom,
0x0C => MemoryDeviceType::Eprom,
0x0D => MemoryDeviceType::Cdram,
0x0E => MemoryDeviceType::ThreeDram,
0x0F => MemoryDeviceType::Sdram,
0x10 => MemoryDeviceType::Sgram,
0x11 => MemoryDeviceType::Rdram,
0x12 => MemoryDeviceType::Ddr,
0x13 => MemoryDeviceType::Ddr2,
0x14 => MemoryDeviceType::Ddr2Fbdimm,
0x18 => MemoryDeviceType::Ddr3,
0x19 => MemoryDeviceType::Fbd2,
0x1A => MemoryDeviceType::Ddr4,
0x1B => MemoryDeviceType::Lpddr,
0x1C => MemoryDeviceType::Lpddr2,
0x1D => MemoryDeviceType::Lpddr3,
0x1E => MemoryDeviceType::Lpddr4,
0x1F => MemoryDeviceType::LogicalNonVolatileDevice,
0x20 => MemoryDeviceType::Hbm,
0x21 => MemoryDeviceType::Hbm2,
0x22 => MemoryDeviceType::Ddr5,
0x23 => MemoryDeviceType::Lpddr5,
0x24 => MemoryDeviceType::Hbm3,
_ => MemoryDeviceType::None,
},
raw,
}
}
}
/// # Memory Device — Form Factor Data
pub struct MemoryFormFactorData {
/// Raw value
///
/// _raw_ is most useful when _value_ is None.
/// This is most likely to occur when the standard was updated but
/// this library code has not been updated to match the current
/// standard.
pub raw: u8,
/// The contained [MemoryFormFactor] value
pub value: MemoryFormFactor,
}
impl fmt::Debug for MemoryFormFactorData {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<MemoryFormFactorData>())
.field("raw", &self.raw)
.field("value", &self.value)
.finish()
}
}
impl Serialize for MemoryFormFactorData {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("MemoryFormFactorData", 2)?;
state.serialize_field("raw", &self.raw)?;
state.serialize_field("value", &self.value)?;
state.end()
}
}
impl Deref for MemoryFormFactorData {
type Target = MemoryFormFactor;
fn deref(&self) -> &Self::Target {
&self.value
}
}
/// # Memory Device — Form Factor
#[derive(Serialize, Debug, PartialEq, Eq)]
pub enum MemoryFormFactor {
/// Other
Other,
/// Unknown
Unknown,
/// SIMM
Simm,
/// SIP
Sip,
/// Chip
Chip,
/// DIP
Dip,
/// ZIP
Zip,
/// Proprietary Card
ProprietaryCard,
/// DIMM
Dimm,
/// TSOP
Tsop,
/// Row of chips
RowOfChips,
/// RIMM
Rimm,
/// SODIMM
Sodimm,
/// SRIMM
Srimm,
/// FB-DIMM
Fbdimm,
/// Die
Die,
/// A value unknown to this standard, check the raw value
None,
}
impl From<u8> for MemoryFormFactorData {
fn from(raw: u8) -> Self {
MemoryFormFactorData {
value: match raw {
0x01 => MemoryFormFactor::Other,
0x02 => MemoryFormFactor::Unknown,
0x03 => MemoryFormFactor::Simm,
0x04 => MemoryFormFactor::Sip,
0x05 => MemoryFormFactor::Chip,
0x06 => MemoryFormFactor::Dip,
0x07 => MemoryFormFactor::Zip,
0x08 => MemoryFormFactor::ProprietaryCard,
0x09 => MemoryFormFactor::Dimm,
0x0A => MemoryFormFactor::Tsop,
0x0B => MemoryFormFactor::RowOfChips,
0x0C => MemoryFormFactor::Rimm,
0x0D => MemoryFormFactor::Sodimm,
0x0E => MemoryFormFactor::Srimm,
0x0F => MemoryFormFactor::Fbdimm,
0x10 => MemoryFormFactor::Die,
_ => MemoryFormFactor::None,
},
raw,
}
}
}
/// # Memory Device — Type Detail
#[derive(PartialEq, Eq)]
pub struct MemoryTypeDetails {
/// Raw value
pub raw: u16,
}
impl Deref for MemoryTypeDetails {
type Target = u16;
fn deref(&self) -> &Self::Target {
&self.raw
}
}
impl From<u16> for MemoryTypeDetails {
fn from(raw: u16) -> Self {
MemoryTypeDetails { raw }
}
}
impl MemoryTypeDetails {
/// Bit 1 Other
pub fn other(&self) -> bool {
self.raw & 0x0002 == 0x0002
}
/// Bit 2 Unknown
pub fn unknown(&self) -> bool {
self.raw & 0x0004 == 0x0004
}
/// Bit 3 Fast-paged
pub fn fast_paged(&self) -> bool {
self.raw & 0x0008 == 0x0008
}
/// Bit 4 Static column
pub fn static_column(&self) -> bool {
self.raw & 0x0010 == 0x0010
}
/// Bit 5 Pseudo-static
pub fn pseudo_static(&self) -> bool {
self.raw & 0x0020 == 0x0020
}
/// Bit 6 RAMBUS
pub fn ram_bus(&self) -> bool {
self.raw & 0x0040 == 0x0040
}
/// Bit 7 Synchronous
pub fn synchronous(&self) -> bool {
self.raw & 0x0080 == 0x0080
}
/// Bit 8 CMOS
pub fn cmos(&self) -> bool {
self.raw & 0x0100 == 0x0100
}
/// Bit 9 EDO
pub fn edo(&self) -> bool {
self.raw & 0x0200 == 0x0200
}
/// Bit 10 Window DRAM
pub fn window_dram(&self) -> bool {
self.raw & 0x0400 == 0x0400
}
/// Bit 11 Cache DRAM
pub fn cache_dram(&self) -> bool {
self.raw & 0x0800 == 0x0800
}
/// Bit 12 Non-volatile
pub fn non_volatile(&self) -> bool {
self.raw & 0x1000 == 0x1000
}
/// Bit 13 Registered (Buffered)
pub fn registered(&self) -> bool {
self.raw & 0x2000 == 0x2000
}
/// Bit 14 Unbuffered (Unregistered)
pub fn unbuffered(&self) -> bool {
self.raw & 0x4000 == 0x4000
}
/// Bit 15 LRDIMM
pub fn lrdimm(&self) -> bool {
self.raw & 0x8000 == 0x8000
}
}
impl fmt::Debug for MemoryTypeDetails {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<MemoryTypeDetails>())
.field("raw", &self.raw)
.field("other", &self.other())
.field("unknown", &self.unknown())
.field("fast_paged", &self.fast_paged())
.field("static_column", &self.static_column())
.field("pseudo_static", &self.pseudo_static())
.field("ram_bus", &self.ram_bus())
.field("synchronous", &self.synchronous())
.field("cmos", &self.cmos())
.field("edo", &self.edo())
.field("window_dram", &self.window_dram())
.field("cache_dram", &self.cache_dram())
.field("non_volatile", &self.non_volatile())
.field("registered", &self.registered())
.field("unbuffered", &self.unbuffered())
.field("lrdimm", &self.lrdimm())
.finish()
}
}
impl Serialize for MemoryTypeDetails {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("MemoryTypeDetails", 16)?;
state.serialize_field("raw", &self.raw)?;
state.serialize_field("other", &self.other())?;
state.serialize_field("unknown", &self.unknown())?;
state.serialize_field("fast_paged", &self.fast_paged())?;
state.serialize_field("static_column", &self.static_column())?;
state.serialize_field("pseudo_static", &self.pseudo_static())?;
state.serialize_field("ram_bus", &self.ram_bus())?;
state.serialize_field("synchronous", &self.synchronous())?;
state.serialize_field("cmos", &self.cmos())?;
state.serialize_field("edo", &self.edo())?;
state.serialize_field("window_dram", &self.window_dram())?;
state.serialize_field("cache_dram", &self.cache_dram())?;
state.serialize_field("non_volatile", &self.non_volatile())?;
state.serialize_field("registered", &self.registered())?;
state.serialize_field("unbuffered", &self.unbuffered())?;
state.serialize_field("lrdimm", &self.lrdimm())?;
state.end()
}
}
/// # Memory Device — Memory Technology Data
pub struct MemoryDeviceTechnologyData {
/// Raw value
///
/// _raw_ is most useful when _value_ is None.
/// This is most likely to occur when the standard was updated but
/// this library code has not been updated to match the current
/// standard.
pub raw: u8,
/// The contained [MemoryDeviceTechnology] value
pub value: MemoryDeviceTechnology,
}
impl fmt::Debug for MemoryDeviceTechnologyData {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(std::any::type_name::<MemoryDeviceTechnologyData>())
.field("raw", &self.raw)
.field("value", &self.value)
.finish()
}
}
impl Serialize for MemoryDeviceTechnologyData {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("MemoryDeviceTechnologyData", 2)?;
state.serialize_field("raw", &self.raw)?;
state.serialize_field("value", &self.value)?;
state.end()
}
}
impl Deref for MemoryDeviceTechnologyData {
type Target = MemoryDeviceTechnology;
fn deref(&self) -> &Self::Target {
&self.value
}
}
/// # Memory Device — Memory Technology
#[derive(Serialize, Debug, PartialEq, Eq)]
pub enum MemoryDeviceTechnology {
/// Other
Other,
/// Unknown
Unknown,
/// DRAM
Dram,
/// NVDIMM-N
NvdimmN,
/// NVDIMM-F
NvdimmF,
/// NVDIMM-P
NvdimmP,
/// Intel® Optane™ persistent memory
IntelOptaneDcPersistentMemory,
/// A value unknown to this standard, check the raw value
None,
}
impl From<u8> for MemoryDeviceTechnologyData {
fn from(raw: u8) -> Self {
MemoryDeviceTechnologyData {
value: match raw {
0x01 => MemoryDeviceTechnology::Other,