-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dce596
commit 766ff82
Showing
45 changed files
with
3,584 additions
and
3,582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
package baseboard | ||
|
||
import ( | ||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
// Parse 解析 | ||
func Parse(s *smbios.Structure) (*Information, error) { | ||
data := s.Formatted | ||
|
||
info := &Information{ | ||
Header: s.Header, | ||
Manufacturer: s.GetString(0x0), | ||
ProductName: s.GetString(0x1), | ||
Version: s.GetString(0x2), | ||
SerialNumber: s.GetString(0x3), | ||
AssetTag: s.GetString(0x4), | ||
LocationInChassis: s.GetString(0x6), | ||
} | ||
|
||
if len(s.Formatted) >= 0x05 { | ||
info.FeatureFlags = FeatureFlags(data[0x05]) | ||
} | ||
|
||
if len(s.Formatted) >= 0x09 { | ||
info.BoardType = Type(data[0x09]) | ||
} | ||
|
||
return info, nil | ||
} | ||
package baseboard | ||
|
||
import ( | ||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
// Parse 解析 | ||
func Parse(s *smbios.Structure) (*Information, error) { | ||
data := s.Formatted | ||
|
||
info := &Information{ | ||
Header: s.Header, | ||
Manufacturer: s.GetString(0x0), | ||
ProductName: s.GetString(0x1), | ||
Version: s.GetString(0x2), | ||
SerialNumber: s.GetString(0x3), | ||
AssetTag: s.GetString(0x4), | ||
LocationInChassis: s.GetString(0x6), | ||
} | ||
|
||
if len(s.Formatted) >= 0x05 { | ||
info.FeatureFlags = FeatureFlags(data[0x05]) | ||
} | ||
|
||
if len(s.Formatted) >= 0x09 { | ||
info.BoardType = Type(data[0x09]) | ||
} | ||
|
||
return info, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package baseboard_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/yumaojun03/dmidecode/parser/baseboard" | ||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
var ( | ||
s = &smbios.Structure{ | ||
Header: smbios.Header{ | ||
Type: 2, | ||
Length: 8, | ||
Handle: 512, | ||
}, | ||
Formatted: []byte{0x1, 0x2, 0x3, 0x4}, | ||
Strings: []string{"Dell Inc.", "0CNCJW", "A05", ".HVSRF52.CN7475154A0700."}, | ||
} | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
bios, err := baseboard.Parse(s) | ||
if assert.NoError(t, err) { | ||
t.Log(bios) | ||
} | ||
} | ||
package baseboard_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/yumaojun03/dmidecode/parser/baseboard" | ||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
var ( | ||
s = &smbios.Structure{ | ||
Header: smbios.Header{ | ||
Type: 2, | ||
Length: 8, | ||
Handle: 512, | ||
}, | ||
Formatted: []byte{0x1, 0x2, 0x3, 0x4}, | ||
Strings: []string{"Dell Inc.", "0CNCJW", "A05", ".HVSRF52.CN7475154A0700."}, | ||
} | ||
) | ||
|
||
func TestParse(t *testing.T) { | ||
bios, err := baseboard.Parse(s) | ||
if assert.NoError(t, err) { | ||
t.Log(bios) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
package baseboard | ||
|
||
import "fmt" | ||
|
||
// FeatureFlags 主板功能标签 | ||
type FeatureFlags byte | ||
|
||
// Baseboard feature flags | ||
const ( | ||
HostingBoard FeatureFlags = 1 << iota | ||
AtLeastOneDaughter | ||
Removable | ||
Repleaceable | ||
HotSwappable | ||
//FeatureFlagsReserved = 000b | ||
) | ||
|
||
func (f FeatureFlags) String() string { | ||
fmt.Printf("xxx,%d", f) | ||
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 主板类型 | ||
type Type byte | ||
|
||
const ( | ||
Unknown Type = 1 + iota | ||
Other | ||
ServerBlade | ||
ConnectivitySwitch | ||
ManagementModule | ||
ProcessorModule | ||
IOModule | ||
MemModule | ||
DaughterBoard | ||
Motherboard | ||
ProcessorMemmoryModule | ||
ProcessorIOModule | ||
InterconnectBoard | ||
) | ||
|
||
func (b Type) 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 > Unknown && b < InterconnectBoard { | ||
return types[b-1] | ||
} | ||
return "Out Of Spec" | ||
} | ||
package baseboard | ||
|
||
import "fmt" | ||
|
||
// FeatureFlags 主板功能标签 | ||
type FeatureFlags byte | ||
|
||
// Baseboard feature flags | ||
const ( | ||
HostingBoard FeatureFlags = 1 << iota | ||
AtLeastOneDaughter | ||
Removable | ||
Repleaceable | ||
HotSwappable | ||
//FeatureFlagsReserved = 000b | ||
) | ||
|
||
func (f FeatureFlags) String() string { | ||
fmt.Printf("xxx,%d", f) | ||
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 主板类型 | ||
type Type byte | ||
|
||
const ( | ||
Unknown Type = 1 + iota | ||
Other | ||
ServerBlade | ||
ConnectivitySwitch | ||
ManagementModule | ||
ProcessorModule | ||
IOModule | ||
MemModule | ||
DaughterBoard | ||
Motherboard | ||
ProcessorMemmoryModule | ||
ProcessorIOModule | ||
InterconnectBoard | ||
) | ||
|
||
func (b Type) 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 > Unknown && b < InterconnectBoard { | ||
return types[b-1] | ||
} | ||
return "Out Of Spec" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
package bios | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
// Information bios信息 | ||
type Information struct { | ||
smbios.Header | ||
Vendor string `json:"vendor,omitempty"` | ||
BIOSVersion string `json:"bios_version,omitempty"` | ||
StartingAddressSegment uint16 `json:"starting_address_segment,omitempty"` | ||
ReleaseDate string `json:"release_date,omitempty"` | ||
RomSize RomSize `json:"rom_size,omitempty"` | ||
RuntimeSize RuntimeSize `json:"runtime_size,omitempty"` | ||
Characteristics Characteristics `json:"characteristics,omitempty"` | ||
CharacteristicsExt1 Ext1 `json:"characteristics_ext_1,omitempty"` | ||
CharacteristicsExt2 Ext2 `json:"characteristics_ext_2,omitempty"` | ||
SystemBIOSMajorRelease byte `json:"system_bios_major_release,omitempty"` | ||
SystemBIOSMinorRelease byte `json:"system_bios_minor_release,omitempty"` | ||
EmbeddedControllerFirmwareMajorRelease byte `json:"firmware_major_release,omitempty"` | ||
EmbeddedControllerFirmawreMinorRelease byte `json:"firmawre_minor_release,omitempty"` | ||
} | ||
|
||
func (b Information) String() string { | ||
s := fmt.Sprintf("Handle %x, DMI type %d, %d bytes\n"+ | ||
"\tBIOS Information\n"+ | ||
"\tVendor: %s\n"+ | ||
"\tVersion: %s\n"+ | ||
"\tRelease Date: %s\n"+ | ||
"\tAddress: 0x%4X0\n"+ | ||
"\tRuntime Size: %s\n"+ | ||
"\tROM Size: %s\n"+ | ||
"\tCharacteristics:%s", | ||
b.Header.Handle, | ||
b.Header.Type, | ||
b.Header.Length, | ||
b.Vendor, | ||
b.BIOSVersion, | ||
b.ReleaseDate, | ||
b.StartingAddressSegment, | ||
b.RuntimeSize, | ||
b.RomSize, | ||
b.Characteristics) | ||
|
||
if b.CharacteristicsExt1 != 0 { | ||
s += b.CharacteristicsExt1.String() | ||
} | ||
if b.CharacteristicsExt2 != 0 { | ||
s += b.CharacteristicsExt2.String() | ||
} | ||
return s | ||
} | ||
package bios | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yumaojun03/dmidecode/smbios" | ||
) | ||
|
||
// Information bios信息 | ||
type Information struct { | ||
smbios.Header | ||
Vendor string `json:"vendor,omitempty"` | ||
BIOSVersion string `json:"bios_version,omitempty"` | ||
StartingAddressSegment uint16 `json:"starting_address_segment,omitempty"` | ||
ReleaseDate string `json:"release_date,omitempty"` | ||
RomSize RomSize `json:"rom_size,omitempty"` | ||
RuntimeSize RuntimeSize `json:"runtime_size,omitempty"` | ||
Characteristics Characteristics `json:"characteristics,omitempty"` | ||
CharacteristicsExt1 Ext1 `json:"characteristics_ext_1,omitempty"` | ||
CharacteristicsExt2 Ext2 `json:"characteristics_ext_2,omitempty"` | ||
SystemBIOSMajorRelease byte `json:"system_bios_major_release,omitempty"` | ||
SystemBIOSMinorRelease byte `json:"system_bios_minor_release,omitempty"` | ||
EmbeddedControllerFirmwareMajorRelease byte `json:"firmware_major_release,omitempty"` | ||
EmbeddedControllerFirmawreMinorRelease byte `json:"firmawre_minor_release,omitempty"` | ||
} | ||
|
||
func (b Information) String() string { | ||
s := fmt.Sprintf("Handle %x, DMI type %d, %d bytes\n"+ | ||
"\tBIOS Information\n"+ | ||
"\tVendor: %s\n"+ | ||
"\tVersion: %s\n"+ | ||
"\tRelease Date: %s\n"+ | ||
"\tAddress: 0x%4X0\n"+ | ||
"\tRuntime Size: %s\n"+ | ||
"\tROM Size: %s\n"+ | ||
"\tCharacteristics:%s", | ||
b.Header.Handle, | ||
b.Header.Type, | ||
b.Header.Length, | ||
b.Vendor, | ||
b.BIOSVersion, | ||
b.ReleaseDate, | ||
b.StartingAddressSegment, | ||
b.RuntimeSize, | ||
b.RomSize, | ||
b.Characteristics) | ||
|
||
if b.CharacteristicsExt1 != 0 { | ||
s += b.CharacteristicsExt1.String() | ||
} | ||
if b.CharacteristicsExt2 != 0 { | ||
s += b.CharacteristicsExt2.String() | ||
} | ||
return s | ||
} |
Oops, something went wrong.