Documentation ¶
Index ¶
- Constants
- Variables
- func BaseLimType(bar string) (uint64, uint64, uint64, error)
- func Lookup(ids map[uint16]Vendor, vendor uint16, device uint16) (string, string)
- type BAR
- type BridgeCtl
- type BridgeStatus
- type BusReader
- type Control
- type DeviceName
- type Devices
- type Filter
- type PCI
- type ROM
- type Status
- type Vendor
Constants ¶
const ( ClassNotDefined = 0x0000 ClassNotDefinedVGA = 0x0001 ClassStorage = 0x01 ClassStorageSCSI = 0x0100 ClassStorageIDE = 0x0101 ClassStorageFLOPPY = 0x0102 ClassStorageIPI = 0x0103 ClassStorageRAID = 0x0104 ClassStorageATA = 0x0105 ClassStorageSATA = 0x0106 ClassStorageSAS = 0x0107 ClassStorageOther = 0x0180 ClassNetwork = 0x02 ClassNetworkEthernet = 0x0200 ClassNetworkOther = 0x0280 ClassDisplay = 0x03 ClassDisplayVGA = 0x0300 ClassDisplayXGA = 0x0301 ClassDisplay3D = 0x0302 ClassDisplayOther = 0x0380 ClassMultimedia = 0x04 ClassMultimediaVideo = 0x0400 ClassMultimediaAudio = 0x0401 ClassMultimediaPhone = 0x0402 ClassMultimediaAudioDev = 0x0403 ClassMultimediaOther = 0x0480 ClassMemory = 0x05 ClassMemoryRAM = 0x0500 ClassMemoryFLASH = 0x0501 ClassMemoryOther = 0x0580 ClassBridge = 0x06 ClassBridgeHost = 0x0600 ClassBridgeISA = 0x0601 ClassBridgeEISA = 0x0602 ClassBridgeMC = 0x0603 ClassBridgePCI = 0x0604 ClassBridgePCMCIA = 0x0605 ClassBridgeNUBUS = 0x0606 ClassBridgeCARDBUS = 0x0607 ClassBridgeRACEWAY = 0x0608 ClassBridgePCISemi = 0x0609 ClassBridgeIBToPCI = 0x060a ClassBridgeOther = 0x0680 ClassCommunication = 0x07 ClassCommunicationSerial = 0x0700 ClassCommunicationParallel = 0x0701 ClassCommunicationMSerial = 0x0702 ClassCommunicationModem = 0x0703 ClassCommunicationOther = 0x0780 ClassSystem = 0x08 ClassSystemPIC = 0x0800 ClassSystemDMA = 0x0801 ClassSystemTimer = 0x0802 ClassSystemRTC = 0x0803 ClassSystemPCIHotplug = 0x0804 ClassSystemOther = 0x0880 ClassInput = 0x09 ClassInputKeyboard = 0x0900 ClassInputPen = 0x0901 ClassInputMouse = 0x0902 ClassInputScanner = 0x0903 ClassInputGameport = 0x0904 ClassInputOther = 0x0980 ClassDocking = 0x0a ClassDockingGeneric = 0x0a00 ClassDockingOther = 0x0a80 ClassProcessor = 0x0b ClassProcessor386 = 0x0b00 ClassProcessor486 = 0x0b01 ClassProcessorPentium = 0x0b02 ClassProcessorALPHA = 0x0b10 ClassProcessorPOWERPC = 0x0b20 ClassProcessorMIPS = 0x0b30 ClassProcessorCO = 0x0b40 ClassSerial = 0x0c ClassSerialFirewire = 0x0c00 ClassSerialAccess = 0x0c01 ClassSerialSSA = 0x0c02 ClassSerialUSB = 0x0c03 ClassSerialFIBER = 0x0c04 ClassSerialSMBUS = 0x0c05 ClassSerialINFINIBAND = 0x0c06 ClassWireless = 0x0d ClassWirelessIRDA = 0x0d00 ClassWirelessCONSUMERIR = 0x0d01 ClassWirelessRF = 0x0d10 ClassWirelessOther = 0x0d80 ClassSatellite = 0x0f ClassSatelliteTV = 0x0f00 ClassSatelliteAudio = 0x0f01 ClassSatelliteVoice = 0x0f03 ClassSatelliteData = 0x0f04 ClassCrypt = 0x10 ClassCryptNetwork = 0x1000 ClassCryptEntertainment = 0x1010 ClassCryptOther = 0x1080 ClassSignal = 0x11 ClassSignalDPIO = 0x1100 ClassSignalPERFCTR = 0x1101 ClassSignalSynchronizer = 0x1110 ClassSignalOther = 0x1180 ClassOthers = 0xff )
Class definitions for PCI.
const ( // StdConfigSize is a PCI name -- standard? StdConfigSize = 64 // ConfigSize is the pre-PCIE config size ConfigSize = 256 // FullConfigSize is the PCIE 4k config size. FullConfigSize = 4096 )
Constants for Linux kernel access.
const ( VID = 0 DID = 2 Cmd = 4 CmdIO = 1 CmdMem = 2 CmdBME = 4 CmdSpecial = 8 CmdMWINV = 0x10 CmdVGA = 0x20 CmdParity = 0x40 CmdStep = 0x80 CmdSERR = 0x100 CmdFastB2B = 0x200 CmdINTXDisable = 0x400 ClassRevision = 8 RevisionID = 8 ClassProg = 9 ClassDevice = 10 CacheLineSize = 0xc LatencyTimer = 0xd HeaderType = 0xe HeaderTypeMask = 0x7f HeaderTypeNormal = 0 HeaderTypeBridge = 1 BAR0 = 0x10 BAR1 = 0x14 BAR2 = 0x18 BAR3 = 0x1c BAR4 = 0x20 BAR5 = 0x24 // The low 3 bits tell you what type of space it is. BARTypeMask = 7 BARMem32 = 0 BARIO = 1 BARMem64 = 4 BARPrefetch = 8 BARMemMask = ^0xf BARIOMask = ^3 // Type 0 devices SubSystemVID = 0x2c SubSystemID = 0x2e ROMAddress = 0x30 ROMEnabled = 1 ROMAddressMask = ^0x7ff IRQLine = 0x3c IRQPin = 0x3d MinGnt = 0x3e MaxLat = 0x3f // Type 1 Primary = 0x18 // our bus Secondary = 0x19 // first bus behind bridge Subordinate = 0x1a // last bus behind bridge, inclusive SecondaryLatency = 0x1b IOBase = 0x1c IOLimit = 0x1d IOHighBase = 0x30 IOHighLimit = 0x32 IOTypeMask = 0xf IOType16 = 0 IOType32 = 1 IORangeMask4k = 0xf IORangeMaskIntel = 3 // Intel has ever been ready to "improve" PCI SecStatus = 0x1e // bit 14 only MemBase = 0x20 MemLimit = 0x22 MemTypeMask = 0xf MemMask = ^MemTypeMask PrefMemBase = 0x24 PrefMemLimit = 0x26 PrefMemTypeMask = 0xf PrefMemType32 = 0 PrefMemType64 = 1 PrefMemHighBase = 0x28 PrefMemHighLimit = 0x30 BridgeRomAddress = 0x38 BridgeControl = 0x3e BridgeParity = 1 BridgeSERR = 2 BridgeISA = 4 BridgeVGA = 8 BridgeMasterAbort = 0x20 BridgeBusReset = 0x40 BridgeFastB2B = 0x80 )
Config space registers
const (
StdNumBARS = 6
)
Values defining config space.
Variables ¶
var ClassNames = map[uint32]string{}/* 102 elements not displayed */
ClassNames maps class names from PCI sysfs to a name.
Functions ¶
func BaseLimType ¶
BaseLimType parses a Linux resource string into base, limit, and attributes. The string must have three hex fields. Gaul was divided into three parts. So are the BARs.
Types ¶
type BAR ¶
type BAR struct { // Index is the index of this resource in the resource list. Index int // Base is the base, derived (usually) from the resource Base uint64 // Lim is the limit. Lim uint64 // Attr are attributes of this BAR Attr uint64 }
BAR is a base address register. It can be a 32- or 64-bit quantity. Do you know that PCI was designed by DEC, in the time of Alpha, a 64-bit machine, and yet it's still full of 32-bit isms? Here's the good news: we don't have to care, since it is present as an array of strings in sysfs!
type BusReader ¶
type BusReader interface { // Read returns Devices, possibly filter by a provided ...Filter Read(...Filter) (Devices, error) }
BusReader is the interface for reading device names for a given bus.
func NewBusReader ¶
NewBusReader returns a BusReader, given a ...glob to match PCI devices against. If it can't glob in pciPath/g then it returns an error. For convenience, we use * as the glob if none are supplied.
type Control ¶
type Control uint16
Control configures how the device responds to operations. It is the 3rd 16-bit word.
type Devices ¶
type Devices []*PCI
Devices contains a slice of one or more PCI devices
func (Devices) ReadConfig ¶
ReadConfig reads the config info for all the devices.
func (Devices) ReadConfigRegister ¶
ReadConfigRegister reads the config info for all the devices.
func (Devices) SetVendorDeviceName ¶
func (d Devices) SetVendorDeviceName()
SetVendorDeviceName sets all numeric IDs of all the devices using the pci device SetVendorDeviceName.
type PCI ¶
type PCI struct { Addr string Vendor uint16 Device uint16 Class uint32 VendorName string DeviceName string ClassName string Latency byte IRQPin byte IRQLine uint Bridge bool FullPath string ExtraInfo []string Config []byte // The rest only gets filled in config space is read. // Type 0 Control Control Status Status Resource string `pci:"resource"` BARS []BAR `json:"omitempty"` // Type 1 Primary uint8 Secondary uint8 Subordinate uint8 SecLatency string IO BAR Mem BAR PrefMem BAR }
PCI is a PCI device. We will fill this in as we add options. For now it just holds two uint16 per the PCI spec.
func OnePCI ¶
OnePCI takes the name of a directory containing linux-style PCI files and returns a filled-in *PCI.
func (*PCI) ReadConfigRegister ¶
ReadConfigRegister reads a configuration register of size 8, 16, 32, or 64. It will only work on little-endian machines.
func (*PCI) SetVendorDeviceName ¶
func (p *PCI) SetVendorDeviceName()
SetVendorDeviceName changes VendorName and DeviceName from a name to a number, if possible.
type Status ¶
type Status uint16
Status contains status bits for the PCI device. It is the 4th 16-bit word.
type Vendor ¶
type Vendor struct { Name string Devices map[uint16]DeviceName }
Vendor is a PCI vendor human readable label. It contains a map of one or more Devices keyed by hex ID.