-
Notifications
You must be signed in to change notification settings - Fork 3
/
type_16_phymem.go
147 lines (132 loc) · 3.79 KB
/
type_16_phymem.go
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
package dmi
import (
"fmt"
)
type PhysicalMemoryArrayLocation byte
const (
PhysicalMemoryArrayLocationOther PhysicalMemoryArrayLocation = 1 + iota
PhysicalMemoryArrayLocationUnknown
PhysicalMemoryArrayLocationSystemboardormotherboard
PhysicalMemoryArrayLocationISAadd_oncard
PhysicalMemoryArrayLocationEISAadd_oncard
PhysicalMemoryArrayLocationPCIadd_oncard
PhysicalMemoryArrayLocationMCAadd_oncard
PhysicalMemoryArrayLocationPCMCIAadd_oncard
PhysicalMemoryArrayLocationProprietaryadd_oncard
PhysicalMemoryArrayLocationNuBus
PhysicalMemoryArrayLocationPC_98C20add_oncard
PhysicalMemoryArrayLocationPC_98C24add_oncard
PhysicalMemoryArrayLocationPC_98Eadd_oncard
PhysicalMemoryArrayLocationPC_98Localbusadd_oncard
)
func (p PhysicalMemoryArrayLocation) String() string {
locations := [...]string{
"Other",
"Unknown",
"System board or motherboard",
"ISA add-on card",
"EISA add-on card",
"PCI add-on card",
"MCA add-on card",
"PCMCIA add-on card",
"Proprietary add-on card",
"NuBus",
"PC-98/C20 add-on card",
"PC-98/C24 add-on card",
"PC-98/E add-on card",
"PC-98/Local bus add-on card",
}
return locations[p-1]
}
type PhysicalMemoryArrayUse byte
const (
PhysicalMemoryArrayUseOther PhysicalMemoryArrayUse = 1 + iota
PhysicalMemoryArrayUseUnknown
PhysicalMemoryArrayUseSystemmemory
PhysicalMemoryArrayUseVideomemory
PhysicalMemoryArrayUseFlashmemory
PhysicalMemoryArrayUseNon_volatileRAM
PhysicalMemoryArrayUseCachememory
)
func (p PhysicalMemoryArrayUse) String() string {
uses := [...]string{
"Other",
"Unknown",
"System memory",
"Video memory",
"Flash memory",
"Non-volatile RAM",
"Cache memory",
}
return uses[p-1]
}
type PhysicalMemoryArrayErrorCorrection byte
const (
PhysicalMemoryArrayErrorCorrectionOther PhysicalMemoryArrayErrorCorrection = 1 + iota
PhysicalMemoryArrayErrorCorrectionUnknown
PhysicalMemoryArrayErrorCorrectionNone
PhysicalMemoryArrayErrorCorrectionParity
PhysicalMemoryArrayErrorCorrectionSingle_bitECC
PhysicalMemoryArrayErrorCorrectionMulti_bitECC
PhysicalMemoryArrayErrorCorrectionCRC
)
func (p PhysicalMemoryArrayErrorCorrection) String() string {
types := [...]string{
"Other",
"Unknown",
"None",
"Parity",
"Single-bit ECC",
"Multi-bit ECC",
"CRC",
}
return types[p-1]
}
type PhysicalMemoryArray struct {
infoCommon
Location PhysicalMemoryArrayLocation
Use PhysicalMemoryArrayUse
ErrorCorrection PhysicalMemoryArrayErrorCorrection
MaximumCapacity uint32
ErrorInformationHandle uint16
NumberOfMemoryDevices uint16
ExtendedMaximumCapacity uint64
}
func (p PhysicalMemoryArray) String() string {
return fmt.Sprintf("Physcial Memory Array\n"+
"\tLocation: %s\n"+
"\tUse: %s\n"+
"\tMemory Error Correction: %s\n"+
"\tMaximum Capacity: %d\n"+
"\tMemory Error Information Handle: %d\n"+
"\tNumber of Memory Devices: %d\n"+
"\tExtended Maximum Capacity: %d",
p.Location,
p.Use,
p.ErrorCorrection,
p.MaximumCapacity,
p.ErrorInformationHandle,
p.NumberOfMemoryDevices,
p.ExtendedMaximumCapacity)
}
func newPhysicalMemoryArray(h dmiHeader) dmiTyper {
data := h.data
return &PhysicalMemoryArray{
Location: PhysicalMemoryArrayLocation(data[0x04]),
Use: PhysicalMemoryArrayUse(data[0x05]),
ErrorCorrection: PhysicalMemoryArrayErrorCorrection(data[0x06]),
MaximumCapacity: u32(data[0x07:0x0B]),
ErrorInformationHandle: u16(data[0x0B:0x0D]),
NumberOfMemoryDevices: u16(data[0x0D:0x0F]),
ExtendedMaximumCapacity: u64(data[0x0F:]),
}
}
func GetPhysicalMemoryArray() *PhysicalMemoryArray {
if d, ok := gdmi[SMBIOSStructureTypePhysicalMemoryArray]; ok {
return d.(*PhysicalMemoryArray)
}
return nil
}
func init() {
addTypeFunc(SMBIOSStructureTypePhysicalMemoryArray, newPhysicalMemoryArray)
}