mirror of
https://github.com/clearml/go-nvlib
synced 2025-01-31 10:57:14 +00:00
Add the status byte check
This commit is contained in:
parent
1f718a1568
commit
9196546dcc
@ -27,6 +27,8 @@ const (
|
|||||||
pciCfgSpaceStandardSize = 256
|
pciCfgSpaceStandardSize = 256
|
||||||
pciCfgSpaceExtendedSize = 4096
|
pciCfgSpaceExtendedSize = 4096
|
||||||
pciCapabilityListPointer = 0x34
|
pciCapabilityListPointer = 0x34
|
||||||
|
pciStatusCapabilityList = 0x10
|
||||||
|
pciStatusBytePosition = 0x06
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigSpace PCI configuration space (standard extended) file path
|
// ConfigSpace PCI configuration space (standard extended) file path
|
||||||
@ -85,6 +87,11 @@ func (cs *configSpaceIO) GetPCICapabilities() (*PCICapabilities, error) {
|
|||||||
make(map[uint16]*PCIExtendedCapability),
|
make(map[uint16]*PCIExtendedCapability),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
support := cs.Read8(pciStatusBytePosition) & pciStatusCapabilityList
|
||||||
|
if support == 0 {
|
||||||
|
return nil, fmt.Errorf("pci device does not support capability list")
|
||||||
|
}
|
||||||
|
|
||||||
soffset := cs.Read8(pciCapabilityListPointer)
|
soffset := cs.Read8(pciCapabilityListPointer)
|
||||||
if int(soffset) >= cs.Len() {
|
if int(soffset) >= cs.Len() {
|
||||||
return nil, fmt.Errorf("capability list pointer out of bounds")
|
return nil, fmt.Errorf("capability list pointer out of bounds")
|
||||||
|
@ -108,6 +108,7 @@ func (m *MockNvpci) AddMockA100(address string, numaNode int) error {
|
|||||||
data := bytes.New(&_data)
|
data := bytes.New(&_data)
|
||||||
data.Write16(0, pciNvidiaVendorID)
|
data.Write16(0, pciNvidiaVendorID)
|
||||||
data.Write16(2, uint16(0x20bf))
|
data.Write16(2, uint16(0x20bf))
|
||||||
|
data.Write8(pciStatusBytePosition, pciStatusCapabilityList)
|
||||||
_, err = config.Write(*data.Raw())
|
_, err = config.Write(*data.Raw())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user