-
Notifications
You must be signed in to change notification settings - Fork 3
/
type_38_ipmi_device.go
165 lines (141 loc) · 4.6 KB
/
type_38_ipmi_device.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package dmi
import (
"fmt"
)
type IPMIDeviceInformationInterfaceType byte
const (
IPMIDeviceInformationInterfaceTypeUnknown IPMIDeviceInformationInterfaceType = 1 + iota
IPMIDeviceInformationInterfaceTypeKCSKeyboardControllerStyle
IPMIDeviceInformationInterfaceTypeSMICServerManagementInterfaceChip
IPMIDeviceInformationInterfaceTypeBTBlockTransfer
IPMIDeviceInformationInterfaceTypeReservedforfutureassignmentbythisspecification
)
func (i IPMIDeviceInformationInterfaceType) String() string {
types := [...]string{
"Unknown",
"KCS: Keyboard Controller Style",
"SMIC: Server Management Interface Chip",
"BT: Block Transfer",
"Reserved for future assignment by this specification",
}
if i <= 3 {
return types[i]
}
return types[4]
}
type IPMIDeviceInformationInfo byte
const (
IPMIDeviceInformationInfoNotSpecified IPMIDeviceInformationInfo = iota
IPMIDeviceInformationInfoSpecified
)
func (i IPMIDeviceInformationInfo) String() string {
info := [...]string{
"not specified",
"specified",
}
return info[i]
}
type IPMIDeviceInformationPolarity byte
const (
IPMIDeviceInformationPolarityActiveLow IPMIDeviceInformationPolarity = iota
IPMIDeviceInformationPolarityActiveHigh
)
func (i IPMIDeviceInformationPolarity) String() string {
polarities := [...]string{
"active low",
"active high",
}
return polarities[i]
}
type IPMIDeviceInformationTriggerMode byte
const (
IPMIDeviceInformationTriggerModeEdge IPMIDeviceInformationTriggerMode = iota
IPMIDeviceInformationTriggerModeLevel
)
func (i IPMIDeviceInformationTriggerMode) String() string {
modes := [...]string{
"edge",
"level",
}
return modes[i]
}
type IPMIDeviceInformationInterruptInfo struct {
Info IPMIDeviceInformationInfo
Polarity IPMIDeviceInformationPolarity
TriggerMode IPMIDeviceInformationTriggerMode
}
type IPMIDeviceInformationRegisterSpacing byte
const (
IPMIDeviceInformationRegisterSpacingSuccessiveByteBoundaries IPMIDeviceInformationRegisterSpacing = iota
IPMIDeviceInformationRegisterSpacing32BitBoundaries
IPMIDeviceInformationRegisterSpacing16ByteBoundaries
IPMIDeviceInformationRegisterSpacingReserved
)
func (i IPMIDeviceInformationRegisterSpacing) String() string {
space := [...]string{
"Interface registers are on successive byte boundaries",
"Interface registers are on 32-bit boundaries",
"Interface registers are on 16-byte boundaries",
"Reserved",
}
return space[i]
}
type IPMIDeviceInformationLSbit byte
type IPMIDeviceInformationBaseModifier struct {
RegisterSpacing IPMIDeviceInformationRegisterSpacing
LSbit IPMIDeviceInformationLSbit
}
type IPMIDeviceInformationAddressModiferInterruptInfo struct {
BaseAddressModifier IPMIDeviceInformationBaseModifier
InterruptInfo IPMIDeviceInformationInterruptInfo
}
func (i IPMIDeviceInformationAddressModiferInterruptInfo) String() string {
return fmt.Sprintf("\tBase Address Modifier:\n"+
"\t\tRegister spacing: %s\n"+
"\t\tLs-bit for addresses: %d\n"+
"\tInterrupt Info:\n"+
"\t\tInfo: %s\n"+
"\t\tPolarity: %s\n"+
"\t\tTrigger Mode: %s",
i.BaseAddressModifier.RegisterSpacing,
i.BaseAddressModifier.LSbit,
i.InterruptInfo.Info,
i.InterruptInfo.Polarity,
i.InterruptInfo.TriggerMode)
}
func newIPMIDeviceInformationAddressModiferInterruptInfo(base byte) IPMIDeviceInformationAddressModiferInterruptInfo {
var ipmi IPMIDeviceInformationAddressModiferInterruptInfo
ipmi.BaseAddressModifier.RegisterSpacing = IPMIDeviceInformationRegisterSpacing((base & 0xC0) >> 6)
ipmi.BaseAddressModifier.LSbit = IPMIDeviceInformationLSbit((base & 0x10) >> 4)
ipmi.InterruptInfo.Info = IPMIDeviceInformationInfo((base & 0x08) >> 3)
ipmi.InterruptInfo.Polarity = IPMIDeviceInformationPolarity((base & 0x02) >> 1)
ipmi.InterruptInfo.TriggerMode = IPMIDeviceInformationTriggerMode(base & 0x01)
return ipmi
}
type IPMIDeviceInformation struct {
infoCommon
InterfaceType IPMIDeviceInformationInterfaceType
Revision byte
I2CSlaveAddress byte
NVStorageAddress byte
BaseAddress uint64
BaseAddressModiferInterrutInfo IPMIDeviceInformationAddressModiferInterruptInfo
InterruptNumbe byte
}
func (i IPMIDeviceInformation) String() string {
return fmt.Sprintf("IPMI Device Information\n"+
"\tInterface Type: %s\n"+
"\tRevision: %d\n"+
"\tI2C Slave Address: %d\n"+
"\tNV Storage Address: %d\n"+
"\tBase Address: %d\n"+
"\tBase Address Modifer Interrut Info: %s\n"+
"\tInterrupt Numbe: %d",
i.InterfaceType,
i.Revision,
i.I2CSlaveAddress,
i.NVStorageAddress,
i.BaseAddress,
i.BaseAddressModiferInterrutInfo,
i.InterruptNumbe)
}