2008-12-13 06:32:16 +03:00
|
|
|
|
|
|
|
|
2010-03-10 13:23:24 +03:00
|
|
|
Bool FindPciDevice()
|
2008-12-13 06:32:16 +03:00
|
|
|
{
|
|
|
|
Bool retval = FALSE;
|
|
|
|
u32_t bus, last_bus;
|
|
|
|
PCITAG tag;
|
|
|
|
|
|
|
|
if( (last_bus = PciApi(1))==-1)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
for(bus=0;bus<=last_bus;bus++)
|
|
|
|
{
|
|
|
|
u32_t devfn;
|
|
|
|
|
|
|
|
for(devfn=0;devfn<256;devfn++)
|
|
|
|
{
|
|
|
|
hc_t *hc;
|
|
|
|
|
|
|
|
u32_t id;
|
|
|
|
u16_t pcicmd;
|
|
|
|
u16_t devclass;
|
2010-03-10 13:23:24 +03:00
|
|
|
u8_t interface;
|
2008-12-13 06:32:16 +03:00
|
|
|
int i;
|
|
|
|
|
2010-03-10 13:23:24 +03:00
|
|
|
interface = PciRead8(bus,devfn, 0x09);
|
2008-12-13 06:32:16 +03:00
|
|
|
devclass = PciRead16(bus,devfn, 0x0A);
|
|
|
|
if( devclass != 0x0C03)
|
|
|
|
continue;
|
|
|
|
|
2010-03-10 13:23:24 +03:00
|
|
|
if( interface != 0)
|
|
|
|
continue;
|
|
|
|
|
2008-12-13 06:32:16 +03:00
|
|
|
pcicmd = PciRead16(bus,devfn, PCI_COMMAND);
|
|
|
|
if (! pcicmd & PCI_COMMAND_IO)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hc = (hc_t*)malloc(sizeof(hc_t));
|
|
|
|
memset(hc, 0, sizeof(hc_t));
|
|
|
|
link_initialize(&hc->link);
|
|
|
|
|
|
|
|
hc->pciId = PciRead32(bus,devfn, 0);
|
|
|
|
hc->PciTag = pciTag(bus,(devfn>>3)&0x1F,devfn&0x7);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
u32_t base;
|
|
|
|
Bool validSize;
|
|
|
|
|
|
|
|
base = PciRead32(bus,devfn, PCI_MAP_REG_START + (i << 2));
|
|
|
|
if(base)
|
|
|
|
{
|
|
|
|
if (base & PCI_MAP_IO) {
|
|
|
|
hc->ioBase[i] = (addr_t)PCIGETIO(base);
|
|
|
|
hc->memType[i] = base & PCI_MAP_IO_ATTR_MASK;
|
|
|
|
} else {
|
|
|
|
hc->memBase[i] = (u32_t)PCIGETMEMORY(base);
|
|
|
|
hc->memType[i] = base & PCI_MAP_MEMORY_ATTR_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
list_prepend(&hc->link, &hc_list);
|
|
|
|
retval = TRUE;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return retval;
|
|
|
|
};
|