Documentation
¶
Overview ¶
Package tis implements a pure-Go TPM TIS / FIFO MMIO transport. It drives the TCG PC Client TIS (FIFO) register handshake over a platform-provided common.Regs MMIO accessor and satisfies common.Transport, exchanging one fully-marshaled TPM 2.0 command buffer for the full response buffer.
Authority for the register handshake is the TCG "PC Client Platform TPM Profile (PTP) Specification", "FIFO Interface" chapter, which supersedes (and folds in) the legacy TCG "PC Client Specific TPM Interface Specification (TIS)" 1.3. Citations below name the relevant register/clause.
Conventions: pure Go, CGO_ENABLED=0, no architecture-specific assembly, BSD-3-Clause on every file, GOWORK=off, 100% statement coverage.
Index ¶
Constants ¶
const ( // ErrNoLocality is returned when locality 0 cannot be claimed: the // TPM never asserts ACCESS.activeLocality after a requestUse. // PTP "TPM_ACCESS_x", activeLocality. ErrNoLocality = Error("tis: timed out claiming locality 0") // ErrNotPresent is returned when the interface does not look like a // TPM (TPM_DID_VID reads back all-ones / all-zeros). PTP // "TPM_DID_VID_x". ErrNotPresent = Error("tis: no TPM present at register window") // ErrCommandReady is returned when the TPM never asserts // STS.commandReady, so a command cannot be staged. PTP "TPM_STS_x", // commandReady. ErrCommandReady = Error("tis: timed out waiting for commandReady") // ErrBurstTimeout is returned when burstCount stays zero for the // whole bound, so no FIFO bytes can be moved. PTP "TPM_STS_x", // burstCount. ErrBurstTimeout = Error("tis: timed out waiting for non-zero burstCount") // ErrExpect is returned when the TPM's Expect bit disagrees with the // driver's view of the command transfer: it clears before the last // byte (TPM thinks the command is complete early) or stays set after // the last byte (TPM still wants more). PTP "TPM_STS_x", Expect. ErrExpect = Error("tis: Expect/transfer length mismatch") // ErrDataAvail is returned when the TPM never asserts STS.dataAvail // after tpmGo, so no response can be read. PTP "TPM_STS_x", // dataAvail. ErrDataAvail = Error("tis: timed out waiting for response dataAvail") // ErrShortResponse is returned when the FIFO yields fewer than the // 10-byte TPM 2.0 header. TCG "TPM 2.0 Part 1", response header. ErrShortResponse = Error("tis: response shorter than TPM header") // ErrResponseSize is returned when the header's responseSize is // implausible (smaller than the header or larger than the maximum // the driver will buffer). TCG "TPM 2.0 Part 1", responseSize. ErrResponseSize = Error("tis: response size out of range") )
Error sentinels.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error string
Error is the typed, constant error returned by this package, mirroring common.Error so callers may compare values with ==.
type TIS ¶
type TIS struct {
// contains filtered or unexported fields
}
TIS is a TPM TIS / FIFO transport bound to a single locality-0 register window. It satisfies common.Transport.
func Open ¶
Open binds a TIS transport to the locality-0 register window presented by r. It validates that a TPM is present (TPM_DID_VID is neither all-zeros nor all-ones) and claims locality 0 via the ACCESS handshake so the first Send can proceed. PTP "TPM_DID_VID_x" and "TPM_ACCESS_x".
func (*TIS) Send ¶
Send transmits one fully-marshaled TPM 2.0 command buffer and returns the full response buffer (including the 10-byte header), satisfying common.Transport.
The flow follows the PTP "FIFO Interface" command sequence:
- Ensure locality 0 is active (ACCESS.requestUse / activeLocality).
- Move the TPM to the Ready state: write STS.commandReady=1 and wait until STS.commandReady reads back set. PTP "TPM_STS_x", commandReady; PTP FIFO state diagram "Idle -> Ready".
- Write the command to DATA_FIFO honoring burstCount (STS[8:23]): never write more bytes than the TPM currently advertises, and check STS.Expect after each chunk. Expect must stay set while more bytes remain and must clear on the last byte. PTP "TPM_STS_x", burstCount and Expect; PTP FIFO state diagram "Reception".
- Start execution: write STS.tpmGo=1. PTP "TPM_STS_x", tpmGo.
- Poll STS.dataAvail, then read the response from DATA_FIFO honoring burstCount: first the 10-byte header to learn responseSize, then the remaining bytes. PTP "TPM_STS_x", dataAvail and burstCount; PTP FIFO state diagram "Completion".
- Release locality 0 (ACCESS.activeLocality=1). PTP "TPM_ACCESS_x".
