-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtype_01_system.go
96 lines (86 loc) · 2.04 KB
/
type_01_system.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
package dmi
import (
"fmt"
)
type SystemInformationWakeUpType byte
const (
SystemInformationReserved SystemInformationWakeUpType = iota
SystemInformationOther
SystemInformationUnknown
SystemInformationAPM_Timer
SystemInformationModem_Ring
SystemInformationLAN_Remote
SystemInformationPower_Switch
SystemInformationPCI_PME
SystemInformationAC_Power_Restored
)
func (w SystemInformationWakeUpType) String() string {
types := [...]string{
"Reserved", /* 0x00 */
"Other",
"Unknown",
"APM Timer",
"Modem Ring",
"LAN Remote",
"Power Switch",
"PCI PME#",
"AC Power Restored", /* 0x08 */
}
return types[w]
}
type SystemInformation struct {
infoCommon
Manufacturer string
ProductName string
Version string
SerialNumber string
UUID string
WakeUpType SystemInformationWakeUpType
SKUNumber string
Family string
}
func (s SystemInformation) String() string {
return fmt.Sprintf("System Information\n"+
"\tManufacturer: %s\n"+
"\tProduct Name: %s\n"+
"\tVersion: %s\n"+
"\tSerial Number: %s\n"+
"\tUUID: %s\n"+
"\tWake-up Type: %s\n"+
"\tSKU Number: %s\n"+
"\tFamily: %s",
s.Manufacturer,
s.ProductName,
s.Version,
s.SerialNumber,
s.UUID,
s.WakeUpType,
s.SKUNumber,
s.Family)
}
func (s SystemInformation) GetUUID() string {
return fmt.Sprint("%s", s.UUID)
}
func newSystemInformation(h dmiHeader) dmiTyper {
data := h.data
version := h.FieldString(int(data[0x06]))
return &SystemInformation{
Manufacturer: h.FieldString(int(data[0x04])),
ProductName: h.FieldString(int(data[0x05])),
Version: version,
SerialNumber: h.FieldString(int(data[0x07])),
UUID: uuid(data[0x08:0x18], version),
WakeUpType: SystemInformationWakeUpType(data[0x18]),
SKUNumber: h.FieldString(int(data[0x19])),
Family: h.FieldString(int(data[0x1A])),
}
}
func GetSystemInformation() *SystemInformation {
if d, ok := gdmi[SMBIOSStructureTypeSystem]; ok {
return d.(*SystemInformation)
}
return nil
}
func init() {
addTypeFunc(SMBIOSStructureTypeSystem, newSystemInformation)
}