@@ -10,6 +10,40 @@ import (
1010// Const Array with HFSTS Offsets
1111var hfstsOffset = []int {0x40 , 0x48 , 0x60 , 0x64 , 0x68 , 0x6c }
1212
13+ type FirmwareStatus struct {
14+ // ME 16
15+ Status1 * FirmwareStatus1
16+ Status6 * FirmwareStatus6
17+ // ME 18/21
18+ Status5 * FirmwareStatus5
19+ }
20+
21+ func NewFirmwareStatus (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus , error ) {
22+ // ME 16
23+ hwsts1 , err := getHFSTS1 (hw )
24+ if err != nil {
25+ return nil , err
26+ }
27+
28+ hwsts6 , err := getHFSTS6 (hw )
29+ if err != nil {
30+ return nil , err
31+ }
32+
33+ hwsts5 , err := getHFSTS5 (hw )
34+ if err != nil {
35+ return nil , err
36+ }
37+
38+ return & FirmwareStatus {
39+ // ME 16
40+ Status1 : hwsts1 ,
41+ Status6 : hwsts6 ,
42+ // ME 18/21
43+ Status5 : hwsts5 ,
44+ }, nil
45+ }
46+
1347type FirmwareStatus1 struct {
1448 WorkingState uint32
1549 MfgMode bool
@@ -49,7 +83,7 @@ type FirmwareStatus6 struct {
4983 TXTSupported bool
5084}
5185
52- func GetHFSTS1 (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus1 , error ) {
86+ func getHFSTS1 (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus1 , error ) {
5387 hfsts1 , err := readHFSTSFromPCIConfigSpace (hw , 1 )
5488 if err != nil {
5589 return nil , fmt .Errorf ("couldn't read HFSTS6 from PCI config space: %v" , err )
@@ -77,7 +111,7 @@ func GetHFSTS1(hw hwapi.LowLevelHardwareInterfaces) (*FirmwareStatus1, error) {
77111 return & firmwareStatus , nil
78112}
79113
80- func GetHFSTS6 (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus6 , error ) {
114+ func getHFSTS6 (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus6 , error ) {
81115 hfsts6 , err := readHFSTSFromPCIConfigSpace (hw , 6 )
82116 if err != nil {
83117 return nil , fmt .Errorf ("couldn't read HFSTS6 from PCI config space: %v" , err )
@@ -109,6 +143,41 @@ func GetHFSTS6(hw hwapi.LowLevelHardwareInterfaces) (*FirmwareStatus6, error) {
109143 return & firmwareStatus , nil
110144}
111145
146+ type FirmwareStatus5 struct {
147+ BgACMStatus bool
148+ VLD bool
149+ RCS bool
150+ ErrorCode uint32
151+ TXTSupported bool
152+ CPUDebugDisabled bool
153+ BSPInitDisabled bool
154+ BPMExecStatus bool
155+ BgStatus uint32
156+ }
157+
158+ // ME 18/21
159+ func getHFSTS5 (hw hwapi.LowLevelHardwareInterfaces ) (* FirmwareStatus5 , error ) {
160+ hfsts5 , err := readHFSTSFromPCIConfigSpace (hw , 5 )
161+ if err != nil {
162+ return nil , fmt .Errorf ("couldn't read HFSTS5 from PCI config space: %v" , err )
163+ }
164+
165+ firmwareStatus := FirmwareStatus5 {}
166+
167+ configSpace := binary .LittleEndian .Uint32 (hfsts5 )
168+ firmwareStatus .BgACMStatus = (configSpace >> 0 )& 1 != 0
169+ firmwareStatus .VLD = (configSpace >> 1 )& 1 != 0
170+ firmwareStatus .RCS = (configSpace >> 2 )& 1 != 0
171+ firmwareStatus .ErrorCode = (configSpace >> 3 ) & 31
172+ firmwareStatus .TXTSupported = (configSpace >> 17 )& 1 != 0
173+ firmwareStatus .CPUDebugDisabled = (configSpace >> 21 )& 1 != 0
174+ firmwareStatus .BSPInitDisabled = (configSpace >> 22 )& 1 != 0
175+ firmwareStatus .BPMExecStatus = (configSpace >> 23 )& 1 != 0
176+ firmwareStatus .BgStatus = (configSpace >> 25 ) & 15
177+
178+ return & firmwareStatus , nil
179+ }
180+
112181func readHFSTSFromPCIConfigSpace (hw hwapi.LowLevelHardwareInterfaces , offset int ) ([]byte , error ) {
113182 if offset < 1 || offset > 6 {
114183 return nil , fmt .Errorf ("invalid HFSTS offset" )
0 commit comments