Documentation
¶
Overview ¶
Package firmware describes the versioned compression shell shared by FPGA images. Algorithm IDs identify the bytes on C2H, independently of the SDK's historical gzip API and of the number of compression engines in an image.
Index ¶
- Constants
- Variables
- func DeviceOwners() ([]string, error)
- func StageBitstream(bitPath, checksum string) (string, func(), error)
- type Algorithm
- type CardLock
- type Info
- func Inspect(ctx context.Context, r RegisterReader) (Info, error)
- func InspectBAR(ctx context.Context, user string, bank uint32) (Info, error)
- func Require(ctx context.Context, hardware any, want Algorithm) (Info, error)
- func Switch(ctx context.Context, manifest Manifest, bitPath string, options SwitchOptions) (Info, error)
- type Manifest
- type Provider
- type RegisterReader
- type SwitchOptions
Constants ¶
const ( RegMagic uint32 = 0x44 RegABI uint32 = 0x48 RegAlgorithm uint32 = 0x4c RegFormat uint32 = 0x50 RegCores uint32 = 0x54 RegFeatures uint32 = 0x58 RegBuildLo uint32 = 0x5c RegBuildHi uint32 = 0x60 Magic uint32 = 0x434d5058 // CMPX ABI uint32 = 0x00010000 // major 1, minor 0 FormatV1 uint32 = 1 FeatureEOP uint32 = 1 << 0 FeatureStandardFrame uint32 = 1 << 1 LegacyEOP uint32 = 0x475a0001 )
Variables ¶
var ( ErrIncompatible = errors.New("incompatible FPGA firmware") ErrAlgorithm = errors.New("FPGA firmware algorithm mismatch") )
var ErrSwitching = errors.New("FPGA firmware switch is in progress")
Functions ¶
func DeviceOwners ¶
DeviceOwners reports all XDMA descriptors because unloading a shared xdma module affects every card. It reads only descriptor links and process names.
func StageBitstream ¶
StageBitstream copies and hashes an artifact before any device is quiesced. Programming the private verified copy prevents replacement during the switch.
Types ¶
type CardLock ¶
type CardLock struct {
// contains filtered or unexported fields
}
CardLock serializes programming against all cooperating DMA handles of the current Unix user. An exclusive gate first stops new admissions, then the activity lock waits for existing transactions to close. SIGKILL releases both.
func LockProgramming ¶
LockProgramming blocks new DMA opens, then drains existing handles. It does not stop processes or unload drivers; the caller owns the programming steps.
func LockTransaction ¶
LockTransaction is nonblocking so callers can apply backpressure or use CPU fallback while an image is being loaded. Keep the returned lock until all stream syscalls have finished and the BAR has closed.
type Info ¶
type Info struct {
Magic uint32 `json:"magic"`
ABI uint32 `json:"abi"`
Algorithm Algorithm `json:"algorithm_id"`
Format uint32 `json:"format"`
Cores uint32 `json:"cores"`
Features uint32 `json:"features"`
Build uint64 `json:"build"`
Legacy bool `json:"legacy"`
}
Info is read-only and repeated in each independent 0x1000-byte control bank. Legacy is true only for the previously validated gzip EOP shell. An unrecognized/uninitialized BAR is never inferred to be a compression image.
func InspectBAR ¶
InspectBAR opens only the user BAR and performs read-only identity queries. The caller must hold a transaction or programming lock for the complete call.
func Require ¶
Require runs before RESET, START and DMA. Non-device gzip simulators without register access retain the original Hardware interface. Every other algorithm requires an explicit, versioned identity; legacy firmware is gzip-only.
func Switch ¶
func Switch(ctx context.Context, manifest Manifest, bitPath string, options SwitchOptions) (Info, error)
Switch programs volatile SRAM through JTAG. It never writes configuration Flash. The complete artifact is verified before blocking admissions, and the programming lock is retained through post-load identity verification. Older clients are checked through /proc and must finish before driver unload.
type Manifest ¶
type Manifest struct {
Schema uint32 `json:"schema"`
Name string `json:"name"`
Part string `json:"part"`
Algorithm string `json:"algorithm"`
ABI uint32 `json:"abi"`
Format uint32 `json:"format"`
Cores uint32 `json:"cores"`
Build uint64 `json:"build"`
Legacy bool `json:"legacy,omitempty"`
Bitstream string `json:"bitstream"`
SHA256 string `json:"sha256"`
Validation string `json:"validation"`
Source string `json:"source,omitempty"`
}
Manifest travels alongside an immutable bitstream. JSON here is an artifact description, not filesystem metadata. All images share ABI/format IDs; each image declares its actual algorithm, available DMA banks and build ID.