smbios

package module
v0.0.0-...-1465ce6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAnchorNotFound = errors.New("SMBIOS anchor _SM_ or _SM3_ not found")
)

Errors for entry points.

View Source
var (
	ErrInvalidAnchor = errors.New("invalid anchor string")
)

Entry point errors.

View Source
var (
	ErrTableNotFound = errors.New("table not found")
)

Table parsing errors.

Functions

func EntryBase

func EntryBase() (int64, int64, error)

EntryBase returns SMBIOS base pointer, which points to the entry point address.

func EntryBaseFromEFI

func EntryBaseFromEFI() (base int64, size int64, err error)

EntryBaseFromEFI finds the SMBIOS entry point address in the EFI System Table.

func EntryBaseFromLegacy

func EntryBaseFromLegacy() (int64, int64, error)

EntryBaseFromLegacy searches in SMBIOS entry point address in F0000 segment.

NOTE: Legacy BIOS will store their SMBIOS in this region.

Types

type Entry32

type Entry32 struct {
	Anchor            [4]uint8
	Checksum          uint8
	Length            uint8
	MajorVersion      uint8
	MinorVersion      uint8
	StructMaxSize     uint16
	Revision          uint8
	Reserved          [5]uint8
	IntAnchor         [5]uint8
	IntChecksum       uint8
	StructTableLength uint16
	StructTableAddr   uint32
	NumberOfStructs   uint16
	BCDRevision       uint8
}

Entry32 is the SMBIOS 32-Bit entry point structure, described in DSP0134 5.2.1.

func (*Entry32) MarshalBinary

func (e *Entry32) MarshalBinary() ([]byte, error)

MarshalBinary marshals the SMBIOS 32-Bit entry point structure to binary data.

func (*Entry32) String

func (e *Entry32) String() string

String returns a summary of the SMBIOS version.

func (*Entry32) Table

func (e *Entry32) Table() (address, size int)

Table returns the physical address of the table, and its size.

func (*Entry32) UnmarshalBinary

func (e *Entry32) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the SMBIOS 32-Bit entry point structure from binary data.

func (*Entry32) Version

func (e *Entry32) Version() (major, minor, rev int)

Version returns the version associated with the table structure.

type Entry64

type Entry64 struct {
	Anchor          [5]uint8
	Checksum        uint8
	Length          uint8
	MajorVersion    uint8
	MinorVersion    uint8
	DocRev          uint8
	Revision        uint8
	Reserved        uint8
	StructMaxSize   uint32
	StructTableAddr uint64
}

Entry64 is the SMBIOS 64-Bit entry point structure, described in DSP0134 5.2.2.

func (*Entry64) MarshalBinary

func (e *Entry64) MarshalBinary() ([]byte, error)

MarshalBinary marshals the SMBIOS 64-Bit entry point structure to binary data.

func (*Entry64) String

func (e *Entry64) String() string

String returns a summary of the SMBIOS version.

func (*Entry64) Table

func (e *Entry64) Table() (address, size int)

Table returns the physical address of the table, and its size.

func (*Entry64) UnmarshalBinary

func (e *Entry64) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the SMBIOS 64-Bit entry point structure from binary data.

func (*Entry64) Version

func (e *Entry64) Version() (major, minor, rev int)

Version returns the version associated with the table structure.

type EntryPoint

type EntryPoint interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	fmt.Stringer

	// Table returns the physical address of the table, and its size.
	Table() (address, size int)

	// Version returns the version associated with the table structure.
	Version() (major, minor, rev int)
}

EntryPoint is an SMBIOS entry point.

To access detailed information, use a type assertion to *Entry32 or *Entry64.

func ParseEntry

func ParseEntry(r io.Reader) (EntryPoint, error)

ParseEntry parses SMBIOS 32 or 64-bit entrypoint structure.

type Header struct {
	Type   TableType
	Length uint8
	Handle uint16
}

Header is the header common to all table types.

func (*Header) Parse

func (h *Header) Parse(r io.Reader) error

Parse parses the header from the binary data.

func (*Header) String

func (h *Header) String() string

String returns string representation os the header.

func (*Header) ToBytes

func (h *Header) ToBytes() []byte

ToBytes returns the header as bytes.

type Table

type Table struct {
	Header `smbios:"-"`

	Data    []byte   `smbios:"-"` // Structured part of the table.
	Strings []string `smbios:"-"` // Strings section.
}

Table is a generic type of table that does not parsed fields, it only allows access to its contents by offset.

func ParseTable

func ParseTable(r io.Reader) (*Table, error)

ParseTable parses a table from byte stream.

func (*Table) GetByteAt

func (t *Table) GetByteAt(offset int) (uint8, error)

GetByteAt returns a byte from the structured part at the specified offset.

func (*Table) GetBytesAt

func (t *Table) GetBytesAt(offset, length int) ([]byte, error)

GetBytesAt returns a number of bytes from the structured part at the specified offset.

func (*Table) GetDWordAt

func (t *Table) GetDWordAt(offset int) (res uint32, err error)

GetDWordAt returns a 32-bit word from the structured part at the specified offset.

func (*Table) GetQWordAt

func (t *Table) GetQWordAt(offset int) (res uint64, err error)

GetQWordAt returns a 64-bit word from the structured part at the specified offset.

func (*Table) GetStringAt

func (t *Table) GetStringAt(offset int) (string, error)

GetStringAt returns a string pointed to by the byte at the specified offset in the structured part. NB: offset is not the string index.

func (*Table) GetWordAt

func (t *Table) GetWordAt(offset int) (res uint16, err error)

GetWordAt returns a 16-bit word from the structured part at the specified offset.

func (*Table) Len

func (t *Table) Len() int

Len returns length of the structured part of the table.

func (*Table) ReadAt

func (t *Table) ReadAt(p []byte, off int64) (int, error)

ReadAt reads from the formatted section of the table.

func (*Table) String

func (t *Table) String() string

type TableType

type TableType uint8

TableType specifies the DMI type of the table. Types are defined in DMTF DSP0134.

const (
	TableTypeBIOSInfo       TableType = 0
	TableTypeSystemInfo     TableType = 1
	TableTypeBaseboardInfo  TableType = 2
	TableTypeChassisInfo    TableType = 3
	TableTypeProcessorInfo  TableType = 4
	TableTypeCacheInfo      TableType = 7
	TableTypeSystemSlots    TableType = 9
	TableTypeMemoryDevice   TableType = 17
	TableTypeIPMIDeviceInfo TableType = 38
	TableTypeTPMDevice      TableType = 43
	TableTypeInactive       TableType = 126
	TableTypeEndOfTable     TableType = 127
)

Supported table types.

func (TableType) String

func (t TableType) String() string

type Tables

type Tables []*Table

Tables is a collection of SMBIOS tables.

func ParseTables

func ParseTables(r io.Reader) (Tables, error)

ParseTables parses all tables from a byte stream.

func (Tables) TableByType

func (t Tables) TableByType(tt TableType) *Table

TableByType returns the first table of the specified type.

TablesByType is nil-safe.

func (Tables) TablesByType

func (t Tables) TablesByType(tt TableType) Tables

TablesByType returns tables of the specified type.

TablesByType is nil-safe.

Directories

Path Synopsis
cmd
dmidecode
dmidecode - DMI table decoder
dmidecode - DMI table decoder
Package dmidecode gives access to decoded SMBIOS/DMI structures.
Package dmidecode gives access to decoded SMBIOS/DMI structures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL