Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. Bool FindPciDevice()
  4. {
  5.     Bool retval = FALSE;
  6.     u32_t bus, last_bus;
  7.     PCITAG tag;
  8.  
  9.     if( (last_bus = PciApi(1))==-1)
  10.         return retval;
  11.  
  12.     for(bus=0;bus<=last_bus;bus++)
  13.     {
  14.         u32_t devfn;
  15.  
  16.         for(devfn=0;devfn<256;devfn++)
  17.         {
  18.             hc_t *hc;
  19.  
  20.             u32_t id;
  21.             u16_t pcicmd;
  22.             u16_t devclass;
  23.             int i;
  24.  
  25.             devclass = PciRead16(bus,devfn, 0x0A);
  26.  
  27.             if( devclass != 0x0C03)
  28.                 continue;
  29.  
  30.             pcicmd = PciRead16(bus,devfn, PCI_COMMAND);
  31.             if (! pcicmd & PCI_COMMAND_IO)
  32.                 continue;
  33.  
  34.             hc = (hc_t*)malloc(sizeof(hc_t));
  35.             memset(hc, 0, sizeof(hc_t));
  36.             link_initialize(&hc->link);
  37.  
  38.             hc->pciId  = PciRead32(bus,devfn, 0);
  39.             hc->PciTag = pciTag(bus,(devfn>>3)&0x1F,devfn&0x7);
  40.  
  41.             for (i = 0; i < 6; i++)
  42.             {
  43.                 u32_t base;
  44.                 Bool validSize;
  45.  
  46.                 base = PciRead32(bus,devfn, PCI_MAP_REG_START + (i << 2));
  47.                 if(base)
  48.                 {
  49.                     if (base & PCI_MAP_IO) {
  50.                         hc->ioBase[i] = (addr_t)PCIGETIO(base);
  51.                         hc->memType[i]   = base & PCI_MAP_IO_ATTR_MASK;
  52.                     } else {
  53.                         hc->memBase[i] = (u32_t)PCIGETMEMORY(base);
  54.                         hc->memType[i] = base & PCI_MAP_MEMORY_ATTR_MASK;
  55.                     }
  56.                 }
  57.             };
  58.             list_prepend(&hc->link, &hc_list);
  59.             retval = TRUE;
  60.         };
  61.     };
  62.     return retval;
  63. };
  64.