-
Notifications
You must be signed in to change notification settings - Fork 3
/
type_02_baseboard.go
134 lines (122 loc) · 3.25 KB
/
type_02_baseboard.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
package dmi
import (
"fmt"
)
type BaseboardFeatureFlags byte
// Baseboard feature flags
const (
BaseboardFeatureFlagsHostingBoard BaseboardFeatureFlags = 1 << iota
BaseboardFeatureFlagsAtLeastOneDaughter
BaseboardFeatureFlagsRemovable
BaseboardFeatureFlagsRepleaceable
BaseboardFeatureFlagsHotSwappable
//FeatureFlagsReserved = 000b
)
func (f BaseboardFeatureFlags) String() string {
features := [...]string{
"Board is a hosting board", /* 0 */
"Board requires at least one daughter board",
"Board is removable",
"Board is replaceable",
"Board is hot swappable", /* 4 */
}
var s string
for i := uint32(0); i < 5; i++ {
if f&(1<<i) != 0 {
s += "\n\t\t" + features[i]
}
}
return s
}
type BaseboardType byte
const (
BaseboardTypeUnknown BaseboardType = 1 + iota
BaseboardTypeOther
BaseboardTypeServerBlade
BaseboardTypeConnectivitySwitch
BaseboardTypeSystemManagementModule
BaseboardTypeProcessorModule
BaseboardTypeIOModule
BaseboardTypeMemModule
BaseboardTypeDaughterBoard
BaseboardTypeMotherboard
BaseboardTypeProcessorMemmoryModule
BaseboardTypeProcessorIOModule
BaseboardTypeInterconnectBoard
)
func (b BaseboardType) String() string {
types := [...]string{
"Unknown", /* 0x01 */
"Other",
"Server Blade",
"Connectivity Switch",
"System Management Module",
"Processor Module",
"I/O Module",
"Memory Module",
"Daughter Board",
"Motherboard",
"Processor+Memory Module",
"Processor+I/O Module",
"Interconnect Board", /* 0x0D */
}
if b > BaseboardTypeUnknown && b < BaseboardTypeInterconnectBoard {
return types[b-1]
}
return "Out Of Spec"
}
type BaseboardInformation struct {
infoCommon
Manufacturer string
ProductName string
Version string
SerialNumber string
AssetTag string
FeatureFlags BaseboardFeatureFlags
LocationInChassis string
ChassisHandle uint16
BoardType BaseboardType
NumberOfContainedObjectHandles byte
ContainedObjectHandles []byte
}
func (b BaseboardInformation) String() string {
return fmt.Sprintf("Base Board Information\n"+
"\tManufacturer: %s\n"+
"\tProduct Name: %s\n"+
"\tVersion: %s\n"+
"\tSerial Number: %s\n"+
"\tAsset Tag: %s\n"+
"\tFeatures:%s\n"+
"\tLocation In Chassis: %s\n"+
"\tType: %s",
b.Manufacturer,
b.ProductName,
b.Version,
b.SerialNumber,
b.AssetTag,
b.FeatureFlags,
b.LocationInChassis,
b.BoardType)
}
func newBaseboardInformation(h dmiHeader) dmiTyper {
data := h.data
return &BaseboardInformation{
Manufacturer: h.FieldString(int(data[0x04])),
ProductName: h.FieldString(int(data[0x05])),
Version: h.FieldString(int(data[0x06])),
SerialNumber: h.FieldString(int(data[0x07])),
AssetTag: h.FieldString(int(data[0x08])),
FeatureFlags: BaseboardFeatureFlags(data[0x09]),
LocationInChassis: h.FieldString(int(data[0x0A])),
BoardType: BaseboardType(data[0x0D]),
}
}
func GetBaseboardInformation() *BaseboardInformation {
if d, ok := gdmi[SMBIOSStructureTypeBaseBoard]; ok {
return d.(*BaseboardInformation)
}
return nil
}
func init() {
addTypeFunc(SMBIOSStructureTypeBaseBoard, newBaseboardInformation)
}