Documentation ¶
Overview ¶
Generic devices on PCI bus.
Index ¶
- Variables
- func CloseDiscoveredDevices(bus Bus) (err error)
- func DiscoverDevices(bus Bus) (err error)
- func SetDriver(v Driver, args ...interface{}) (err error)
- type BaseAddressReg
- type Bus
- type BusAddress
- type BusDevice
- type Capability
- type CapabilityHeader
- type Command
- type ConfigHeader
- type Device
- func (d *Device) ConfigRw(offset, vʹ, nBytes uint, isWrite bool) (v uint)
- func (d *Device) DeviceID() VendorDeviceID
- func (d *Device) FindCap(c Capability) (offset uint, found bool)
- func (d *Device) FindExtCap(c ExtCapability) (offset uint, found bool)
- func (d *Device) ForeachCap(f func(h *CapabilityHeader, offset uint) (done bool, err error)) (err error)
- func (d *Device) ForeachExtCap(f func(h *ExtCapabilityHeader, offset uint) (done bool, err error)) (err error)
- func (d *Device) GetCap(c Capability) (p unsafe.Pointer)
- func (d *Device) GetConfig() *ConfigHeader
- func (d *Device) GetDeviceConfig() *DeviceConfig
- func (d *Device) GetExtCap(c ExtCapability) (p unsafe.Pointer)
- func (d *Device) MapResource(bar uint) (res uintptr, err error)
- func (d *Device) ReadConfigUint16(o uint) (v uint16)
- func (d *Device) ReadConfigUint32(o uint) (v uint32)
- func (d *Device) ReadConfigUint8(o uint) (v uint8)
- func (d *Device) ReadRawConfigUint16(o uint) (v uint16)
- func (d *Device) ReadRawConfigUint32(o uint) (v uint32)
- func (d *Device) ReadRawConfigUint8(o uint) (v uint8)
- func (d *Device) SetMaster(enable bool)
- func (d *Device) String() string
- func (d *Device) SysfsOpenFile(format string, mode int, args ...interface{}) (f *os.File, err error)
- func (d *Device) SysfsPath(format string, args ...interface{}) (path string)
- func (d *Device) SysfsReadHexFile(format string, mode int, args ...interface{}) (v uint, err error)
- func (d *Device) UnmapResource(bar uint) (err error)
- func (d *Device) VendorID() VendorID
- func (d *Device) WriteConfigUint16(o uint, value uint16)
- func (d *Device) WriteConfigUint32(o uint, value uint32)
- func (d *Device) WriteConfigUint8(o uint, value uint8)
- func (d *Device) WriteRawConfigUint16(o uint, value uint16)
- func (d *Device) WriteRawConfigUint32(o uint, value uint32)
- func (d *Device) WriteRawConfigUint8(o uint, value uint8)
- type DeviceClass
- type DeviceConfig
- type DeviceID
- type Driver
- type DriverDevice
- type ExtCapability
- type ExtCapabilityHeader
- type HeaderType
- type Resource
- type SoftwareInterface
- type Status
- type U16
- type U32
- type U8
- type VendorDeviceID
- type VendorID
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultBus = &vfio_main{}
Functions ¶
func CloseDiscoveredDevices ¶
func DiscoverDevices ¶
Types ¶
type BaseAddressReg ¶
type BaseAddressReg U32
func (BaseAddressReg) Addr ¶
func (b BaseAddressReg) Addr() uint32
func (BaseAddressReg) IsMem ¶
func (b BaseAddressReg) IsMem() bool
func (BaseAddressReg) String ¶
func (b BaseAddressReg) String() string
func (BaseAddressReg) Valid ¶
func (b BaseAddressReg) Valid() bool
type BusAddress ¶
func (BusAddress) String ¶
func (a BusAddress) String() string
type BusDevice ¶
type BusDevice interface { ConfigRw(offset, vʹ, nBytes uint, isWrite bool) (v uint) GetDevice() *Device Open() error Close() error MapResource(index uint) (res uintptr, err error) UnmapResource(index uint) (err error) InterruptEnable(UseMsi bool) (err error) }
Things a bus driver device must do.
type Capability ¶
type Capability U8
const ( PowerManagement Capability = iota + 1 AGP VitalProductData SlotIdentification MSI CompactPCIHotSwap PCIX HyperTransport VendorSpecific DebugPort CompactPciCentralControl PCIHotPlugController SSVID AGP3 SecureDevice PCIE MSIX SATA AdvancedFeatures )
func (Capability) String ¶
func (i Capability) String() string
type CapabilityHeader ¶
type CapabilityHeader struct { Capability // Pointer to next capability header NextCapabilityHeader U8 }
Common header for capabilities.
type ConfigHeader ¶
type ConfigHeader struct { DeviceID Command Status Revision U8 // Distinguishes programming interface for device. // For example, different standards for USB controllers. SoftwareInterface DeviceClass CacheSize uint8 LatencyTimer uint8 // If bit 7 of this register is set, the device has multiple functions; // otherwise, it is a single function device. Tp uint8 Bist uint8 }
Under PCI, each device has 256 bytes of configuration address space, of which the first 64 bytes are standardized as follows:
func (ConfigHeader) Type ¶
func (c ConfigHeader) Type() HeaderType
type Device ¶
type Device struct { ID DeviceID Addr BusAddress Resources []Resource Driver DriverDevice BusDevice }
func (*Device) DeviceID ¶
func (d *Device) DeviceID() VendorDeviceID
func (*Device) FindExtCap ¶
func (d *Device) FindExtCap(c ExtCapability) (offset uint, found bool)
func (*Device) ForeachCap ¶
func (*Device) ForeachExtCap ¶
func (*Device) GetConfig ¶
func (d *Device) GetConfig() *ConfigHeader
func (*Device) GetDeviceConfig ¶
func (d *Device) GetDeviceConfig() *DeviceConfig
func (*Device) ReadConfigUint16 ¶
func (*Device) ReadConfigUint32 ¶
func (*Device) ReadConfigUint8 ¶
func (*Device) ReadRawConfigUint16 ¶
func (*Device) ReadRawConfigUint32 ¶
func (*Device) ReadRawConfigUint8 ¶
func (*Device) SetMaster ¶
Set bus master in pci command register. Otherwise no love with device dma or msi interrupts.
func (*Device) SysfsOpenFile ¶
func (*Device) SysfsReadHexFile ¶
func (*Device) UnmapResource ¶
func (*Device) WriteConfigUint16 ¶
func (*Device) WriteConfigUint32 ¶
func (*Device) WriteConfigUint8 ¶
func (*Device) WriteRawConfigUint16 ¶
func (*Device) WriteRawConfigUint32 ¶
func (*Device) WriteRawConfigUint8 ¶
type DeviceClass ¶
type DeviceClass uint16
const ( Undefined DeviceClass = 0x0000 Undefined_VGA DeviceClass = 0x0001 Storage_SCSI DeviceClass = 0x0100 Storage_IDE DeviceClass = 0x0101 Storage_Floppy DeviceClass = 0x0102 Storage_IPI DeviceClass = 0x0103 Storage_RAID DeviceClass = 0x0104 Storage_SATA DeviceClass = 0x0106 Storage_SAS DeviceClass = 0x0107 Storage_Other DeviceClass = 0x0180 Network_Ethernet DeviceClass = 0x0200 Network_Token_Ring DeviceClass = 0x0201 Network_FDDI DeviceClass = 0x0202 Network_ATM DeviceClass = 0x0203 Network_Other DeviceClass = 0x0280 Display_VGA DeviceClass = 0x0300 Display_XGA DeviceClass = 0x0301 Display_3D DeviceClass = 0x0302 Display_Other DeviceClass = 0x0380 Multimedia_Video DeviceClass = 0x0400 Multimedia_Audio DeviceClass = 0x0401 Multimedia_Phone DeviceClass = 0x0402 Multimedia_Audio_Device DeviceClass = 0x0403 Multimedia_Other DeviceClass = 0x0480 Memory_RAM DeviceClass = 0x0500 Memory_Flash DeviceClass = 0x0501 Memory_Other DeviceClass = 0x0580 Bridge_Host DeviceClass = 0x0600 Bridge_ISA DeviceClass = 0x0601 Bridge_EISA DeviceClass = 0x0602 Bridge_MC DeviceClass = 0x0603 Bridge_PCI DeviceClass = 0x0604 Bridge_PCMCIA DeviceClass = 0x0605 Bridge_NUBUS DeviceClass = 0x0606 Bridge_CARDBUS DeviceClass = 0x0607 Bridge_RACEWAY DeviceClass = 0x0608 Bridge_Other DeviceClass = 0x0680 Communication_Serial DeviceClass = 0x0700 Communication_Parallel DeviceClass = 0x0701 Communication_Multi_Serial DeviceClass = 0x0702 Communication_Modem DeviceClass = 0x0703 Communication_Other DeviceClass = 0x0780 System_PIC DeviceClass = 0x0800 System_DMA DeviceClass = 0x0801 System_Timer DeviceClass = 0x0802 System_RTC DeviceClass = 0x0803 System_PCI_Hotplug DeviceClass = 0x0804 System_SDHCI DeviceClass = 0x0805 System_Other DeviceClass = 0x0880 Input_Keyboard DeviceClass = 0x0900 Input_Pen DeviceClass = 0x0901 Input_Mouse DeviceClass = 0x0902 Input_Scanner DeviceClass = 0x0903 Input_GAMEPORT DeviceClass = 0x0904 Input_Other DeviceClass = 0x0980 Docking_GENERIC DeviceClass = 0x0a00 Docking_Other DeviceClass = 0x0a80 Processor_386 DeviceClass = 0x0b00 Processor_486 DeviceClass = 0x0b01 Processor_Pentium DeviceClass = 0x0b02 Processor_Alpha DeviceClass = 0x0b10 Processor_Powerpc DeviceClass = 0x0b20 Processor_MIPS DeviceClass = 0x0b30 Processor_CO DeviceClass = 0x0b40 Serial_Firewire DeviceClass = 0x0c00 Serial_Access DeviceClass = 0x0c01 Serial_SSA DeviceClass = 0x0c02 Serial_USB DeviceClass = 0x0c03 Serial_Fiber DeviceClass = 0x0c04 Serial_SMBUS DeviceClass = 0x0c05 Wireless_RF_Controller DeviceClass = 0x0d10 Intelligent_I2O DeviceClass = 0x0e00 Satellite_TV DeviceClass = 0x0f00 Satellite_Audio DeviceClass = 0x0f01 Satellite_Voice DeviceClass = 0x0f03 Satellite_Data DeviceClass = 0x0f04 Crypt_Network DeviceClass = 0x1000 Crypt_entertainment DeviceClass = 0x1001 Crypt_Other DeviceClass = 0x1080 SP_DPIO DeviceClass = 0x1100 SP_Other DeviceClass = 0x1180 )
func (DeviceClass) String ¶
func (i DeviceClass) String() string
type DeviceConfig ¶
type DeviceConfig struct { ConfigHeader // Base addresses specify locations in memory or I/O space. // Decoded size can be determined by writing a value of 0xffffffff to the register, and reading it back. // Only 1 bits are decoded. BaseAddressRegs [6]BaseAddressReg CardBusCIS U32 SubID DeviceID RomAddress U32 // Config space offset of start of capability list. CapabilityOffset U8 InterruptLine U8 InterruptPin U8 MinGrant U8 MaxLatency U8 // contains filtered or unexported fields }
Header type 0 (normal devices)
type Driver ¶
type Driver interface { // Device matches registered devices for this driver. NewDevice(d BusDevice) (i DriverDevice, err error) }
Things a driver must do.
type DriverDevice ¶
This a device handled by driver must do.
type ExtCapability ¶
type ExtCapability U16
const ( AdvancedErrorReporting ExtCapability = iota + 1 VirtualChannel DeviceSerialNumber PowerBudgeting RootComplexLinkDeclaration RootComplexInternalLinkControl RootComplexEventCollector MultiFunctionVC VirtualChannel9 RootComplexRB ExtVendorSpecific ConfigAccess AccessControlServices AlternateRoutingID AddressTranslationServices SingleRootIOVirtualization MultiRootIOVirtualization Multicast PageRequestInterface ReservedAMD ResizableBAR DynamicPowerAllocation TPHRequester LatencyToleranceReporting SecondaryPCIeCapability ProtocolMultiplexing ProcessAddressSpaceID )
func (ExtCapability) String ¶
func (i ExtCapability) String() string
type ExtCapabilityHeader ¶
type ExtCapabilityHeader struct { ExtCapability // [15:4] next pointer // [3:0] version VersionAndNextOffset U16 }
Common header for extended capabilities.
type HeaderType ¶
type HeaderType uint8
const ( Normal HeaderType = iota Bridge CardBus )
func (HeaderType) String ¶
func (i HeaderType) String() string
type SoftwareInterface ¶
type SoftwareInterface U8
func (SoftwareInterface) String ¶
func (x SoftwareInterface) String() string
type VendorDeviceID ¶
type VendorDeviceID U16
func (*VendorDeviceID) Get ¶
func (r *VendorDeviceID) Get(d *Device) VendorDeviceID
func (VendorDeviceID) String ¶
func (d VendorDeviceID) String() string
Click to show internal directories.
Click to hide internal directories.