pci_find_device

Problem: Core dumped when I compile and run this

#include <stdio.h>
#include <hw/pci.h>

int main()
{
if (pci_attach(0) == -1)
printf(“pci_attach failed”);

unsigned device = 0x2411;
unsigned vendor = 0x8086; // Known device (HDD)
unsigned index = 0;
unsigned *bus;
unsigned *dev_func;

if (pci_find_device(device, vendor, index, bus, dev_func) ==
PCI_SUCCESS)
printf(“found device”);

return 0;
}

The program runs OK (ie no core dumping) if I set index = 1 but it fails to
find any device. What have I done wrong here?

Paul.

Paul Jones <paul.jones@bnc.ox.ac.uk> wrote:
: unsigned *bus;
: unsigned *dev_func;
: if (pci_find_device(device, vendor, index, bus, dev_func) ==

C 101 …

unsigned bus;
unsigned dev_func;
if (pci_find_device(device, vendor, index, &bus, &dev_func) ==