Documentation
¶
Overview ¶
Package device contains the small pure-Go access layer for the Xilinx XDMA character devices. It deliberately uses os.File Read/Write and ReadAt/ WriteAt rather than cgo or a vendor userspace library.
Index ¶
- Constants
- func StatusName(status uint32) string
- type Device
- func (d *Device) Close() error
- func (d *Device) CloseStreams() error
- func (d *Device) EnableRegisterMmap() error
- func (d *Device) FirmwareInfo(ctx context.Context) (firmware.Info, error)
- func (d *Device) PacketReadsEnabled() bool
- func (d *Device) ReadC2H(p []byte) (int, error)
- func (d *Device) ReadReg32(_ context.Context, offset uint32) (uint32, error)
- func (d *Device) ReadReg64Stable(ctx context.Context, loOffset, hiOffset uint32) (uint64, error)
- func (d *Device) SetRegisterBase(base uint32) error
- func (d *Device) Snapshot(ctx context.Context) (Snapshot, error)
- func (d *Device) SoftReset(ctx context.Context, timeout time.Duration) error
- func (d *Device) Start(ctx context.Context, inputSize uint64, timeout time.Duration) error
- func (d *Device) StartC2HRequest(ctx context.Context, requestLen uint32) error
- func (d *Device) TransferSnapshot(ctx context.Context) (Snapshot, error)
- func (d *Device) WriteH2C(p []byte) (int, error)
- func (d *Device) WriteReg32(_ context.Context, offset uint32, value uint32) error
- type Lease
- type Paths
- type Pool
- type Snapshot
Constants ¶
const ( RegCtrl uint32 = 0x00 RegStatus uint32 = 0x04 RegInputSizeLo uint32 = 0x08 RegInputSizeHi uint32 = 0x0c RegOutBytesLo uint32 = 0x10 RegOutBytesHi uint32 = 0x14 RegInBytesLo uint32 = 0x18 RegInBytesHi uint32 = 0x1c RegC2HRequestLen uint32 = 0x20 RegDebug uint32 = 0x24 RegCapabilities uint32 = 0x40 CapabilitiesPacketEOP uint32 = 0x475a0001 )
User-BAR register offsets for the gzip shell implemented in the FPGA.
const ( CtrlStart uint32 = 1 << 0 CtrlSoftReset uint32 = 1 << 1 CtrlC2HStart uint32 = 1 << 2 )
Control register bits.
const ( StatusBusy uint32 = 1 << 0 StatusDone uint32 = 1 << 1 StatusResetBusy uint32 = 1 << 2 StatusError uint32 = 1 << 3 StatusC2HDone uint32 = 1 << 4 )
Status register bits.
Variables ¶
This section is empty.
Functions ¶
func StatusName ¶
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device is a handle to the user BAR and one H2C/C2H streaming pair.
func Open ¶
Open opens the three device nodes. The caller owns the returned device and must call Close.
func (*Device) CloseStreams ¶
CloseStreams closes the DMA handles. It is safe to call more than once and is used by cancellation handling. An in-flight character-device syscall may remain blocked until the driver completes or times out the transfer.
func (*Device) EnableRegisterMmap ¶ added in v0.0.3
EnableRegisterMmap maps the selected bank's page through the XDMA driver's noncached BAR mapping. Select the bank before enabling it. On Linux/amd64, aligned 32-bit accesses preserve MMIO transaction width and x86 UC ordering. Other platforms retain the portable ReadAt/WriteAt register path.
func (*Device) FirmwareInfo ¶ added in v0.0.3
FirmwareInfo reads the image identity without resetting or starting a task.
func (*Device) PacketReadsEnabled ¶ added in v0.0.3
PacketReadsEnabled reports negotiated end-of-gzip packets and XDMA EOP flush.
func (*Device) ReadC2H ¶
ReadC2H reads one FPGA output packet. The caller intentionally controls the requested length because the gzip shell exposes a length-defined packetizer.
func (*Device) ReadReg64Stable ¶
ReadReg64Stable reads a 64-bit counter exposed as adjacent low/high words.
func (*Device) SetRegisterBase ¶ added in v0.0.3
SetRegisterBase selects a bank before the first transaction. Do not call it concurrently with register access or DMA. It also allows callers built with an older SDK to discover multi-bank support through an optional interface.
func (*Device) StartC2HRequest ¶
StartC2HRequest arms the packetizer for exactly requestLen bytes.
func (*Device) TransferSnapshot ¶
TransferSnapshot is the low-latency snapshot used by the C2H drain loop. The reference C implementation reads only STATUS and OUT_BYTES on this hot path; DEBUG is fetched only when the shell reports an error. Keeping IN_BYTES out of the poll loop avoids unnecessary PCIe MMIO reads at high throughput.
type Lease ¶ added in v0.0.3
type Lease struct {
*Device
// contains filtered or unexported fields
}
Lease must be closed by the caller, even after a failed or cancelled run.
type Paths ¶
type Paths struct {
User string
H2C string
C2H string
// RegisterBase selects an independent control bank. The validated four-core
// shell uses core*0x1000; DMA channel indices must match that core.
RegisterBase uint32
// LegacyPackets forces the original exact-length protocol for diagnosis.
LegacyPackets bool
}
Paths identifies the XDMA character devices created by xdma.ko.
func FourCorePaths ¶ added in v0.0.3
FourCorePaths maps the validated four-core shell's independent DMA channels to their control banks. Explicit opt-in is required: node count alone does not establish that a bitstream contains independent gzip cores.
type Pool ¶ added in v0.0.3
type Pool struct {
// contains filtered or unexported fields
}
Pool leases independent streams. Each lease opens fresh handles and retains its core until Close, including after RunReader closes the streaming FDs. Pool owns no persistent FDs and requires no shutdown call.
func (*Pool) AcquireActive ¶ added in v0.0.3
AcquireActive limits admission to the cores advertised by the current image. This lets a four-channel daemon follow a two-core Zstd image without serving alternate requests on inactive banks. Identity checks in the transaction remain mandatory because a switch can occur after this read-only probe.