pmbus

package
v0.628.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pmbus decodes PMBus — the Power Management Bus, an SMBus/I2C command set (PMBus spec) that PSUs, voltage regulators (VRMs), battery chargers and hot-swap controllers expose to set and read their power rails. PMBus is a real and current hardware-attack surface: the 2023 "PMFault" research showed that writing the PSU's VOUT_COMMAND / OPERATION over PMBus can overvolt a server's CPU rail to induce faults — so a captured PMBus transaction (from an I2C/SMBus sniffer, cf. the project's i2c_scan) is real recon. A PMBus message identifies the **command** in flight — a voltage-setting OPERATION / VOUT_COMMAND / VOUT_MARGIN (the attack-relevant writes, flagged), a READ_VIN / READ_VOUT / READ_IOUT / READ_TEMPERATURE telemetry read, a STATUS query, a manufacturer-ID query — and, for the LINEAR11 telemetry reads, the decoded physical value. It joins the project's hardware-bus tooling (internal/jtag, internal/buspirate, internal/spiflash).

Wrap-vs-native judgement

Native. A PMBus transaction is a 1-byte command code optionally followed
by little-endian data; telemetry values use the LINEAR11 (5-bit signed
exponent + 11-bit signed mantissa) float encoding and STATUS words are
bit-fields. A byte read + an opcode table + a couple of bit/float decodes;
stdlib only, no new go.mod dep.

Verifiable / no confidently-wrong output

The decoded command codes are the PMBus-specification standard set
(OPERATION, VOUT_COMMAND, the VOUT margins/limits, the READ_* telemetry,
the STATUS_* registers, PMBUS_REVISION, MFR_ID, …); a code outside the set
is reported as unknown / manufacturer-specific rather than guessed. The
LINEAR11 decode (deterministic two's-complement exponent × mantissa) is
applied only to the commands defined as LINEAR11 (the current / power /
temperature / input-voltage reads); VOUT-format values (ULINEAR16, scaled
by the device's VOUT_MODE exponent which is not on the wire) are surfaced
raw with a note, and STATUS bit-fields are decoded from the spec. Other
command data is surfaced as raw hex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Command     int    `json:"command"`
	CommandHex  string `json:"command_hex"`
	CommandName string `json:"command_name"`

	Value             string   `json:"value,omitempty"`
	StatusFlags       []string `json:"status_flags,omitempty"`
	SecurityRelevance string   `json:"security_relevance,omitempty"`

	DataHex string   `json:"data_hex,omitempty"`
	Notes   []string `json:"notes,omitempty"`
}

Result is the decoded view of a PMBus transaction.

func Decode

func Decode(input string) (*Result, error)

Decode parses a PMBus transaction (command code + little-endian data) from hex (whitespace / ':' / '-' / '_' separators and a '0x' prefix tolerated).

Jump to

Keyboard shortcuts

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