26 unsigned int pci_read(
unsigned int bus,
31 unsigned int addr = (1 << 31) | (bus << 16) | (dev << 11) | (fun << 8) | (reg & 0xfc);
32 unsigned int val = -1;
34 outl(PCI_CONFIG_ADDRESS, addr);
35 val =
inl(PCI_CONFIG_DATA);
37 return (val >> ((reg & 3) << 3));
41 unsigned int pci_read_reg(s_pci_device* d,
44 return (pci_read(d->bus, d->dev, d->fun, reg));
48 int pci_open(s_pci_device* d)
54 for (bus = 0; bus < PCI_BUS_MAX; bus++)
55 for (dev = 0; dev < PCI_DEV_MAX; dev++)
56 for (fun = 0; fun < PCI_FUN_MAX; fun++)
57 if (((
unsigned short) pci_read(bus, dev, fun, PCI_REG_VENDORID)) == d->vendorid &&
58 ((
unsigned short) pci_read(bus, dev, fun, PCI_REG_DEVICEID)) == d->deviceid)
61 if (pci_read(bus, dev, fun, PCI_REG_HEADERTYPE) != 0)
67 d->bar[0] = pci_read(bus, dev, fun, PCI_REG_BAR0);
68 d->irq_line = (
unsigned char) pci_read_reg(d, PCI_REG_IRQLINE);
76 void pci_handler(
void);
78 void dummy_pci_handler(
void)
82 ".globl pci_handler\n"
97 void* ne2000_dev =
NULL;
102 if (pci_open(dev) != 0)
105 pok_partitions[part_id].io_min = (dev->bar[0] & (~0x1F));
106 pok_partitions[part_id].io_max = (dev->bar[0] & (~0x1F)) + dev->io_range;