Changeset 1925 for Whitix/trunk/devices/pci/pci_core.c
- Timestamp:
- 02/25/09 19:37:39 (3 years ago)
- Files:
-
- 1 modified
-
Whitix/trunk/devices/pci/pci_core.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/trunk/devices/pci/pci_core.c
r1668 r1925 70 70 default: return -EINVAL; 71 71 } 72 72 73 73 return 0; 74 74 } … … 92 92 93 93 base=0xCFC+(reg & 0x03); 94 outd(0xCF8,u.n); 94 95 outd(0xCF8, u.n); 96 95 97 switch (bytes) 96 98 { … … 126 128 }; 127 129 130 #define PCI_WRITE_TEST 0xFFFFFFFF 131 #define PCI_BAR_BASE 0x10 132 128 133 int PciDeviceProbe(struct PciDevice* device) 129 134 { 130 135 /* Fill in device-specific information, such as IRQ, I/O and memory. */ 131 DWORD v; 136 BYTE irq; 137 DWORD v, size; 132 138 int i; 133 int bus, dev, func;134 135 bus=device->bus->index;136 dev=device->dev;137 func=device->func;138 139 139 140 for (i=0; i<6; i++) 140 141 { 141 PciRead (bus, dev, func, (i*4)+0x10, 4, &v);142 if (v)143 {144 DWORD v2;145 PciWrite(bus, dev, func, i*4+0x10, 0xFFFFFFFF, 4);146 PciRead(bus, dev, func, i*4+0x10, 4, &v2);147 v2 &= 0xFFFFFFF0;148 PciWrite(bus, dev, func, i*4+0x10, v, 4);149 if (v2 == 0 || v2 == 0xFFFFFFFF)150 continue;151 152 if (v == 0xFFFFFFFF)153 v=0;154 155 device->spaces[i]=v;156 }157 }158 159 /* Why v? */ 160 PciRead (bus, dev, func, 0x3D, 1, &v);161 162 if ( v)163 { 164 PciRead (bus, dev, func, 0x3C, 1, &v);165 device->irq =(BYTE)v;142 PciReadConfigDword(device, PCI_BAR_BASE + (i << 2), &v); 143 144 PciWriteConfigDword(device, PCI_BAR_BASE + (i << 2), PCI_WRITE_TEST); 145 PciReadConfigDword(device, PCI_BAR_BASE + (i << 2), &size); 146 147 PciWriteConfigDword(device, PCI_BAR_BASE + (i << 2), v); 148 149 if (!size || size == 0xFFFFFFFF) 150 continue; 151 152 if (v == PCI_WRITE_TEST) 153 v = 0; 154 155 size &= 0xFFFFFFF0; 156 157 /* Parse the base address register. */ 158 device->spaces[i] = v; 159 } 160 161 PciReadConfigByte(device, 0x3D, &irq); 162 163 if (irq) 164 { 165 PciReadConfigByte(device, 0x3C, &irq); 166 device->irq = irq; 166 167 } 167 168 … … 264 265 { 265 266 struct PciDeviceId* currId; 267 int ret; 266 268 267 269 /* Search through each device id entry, looking for a match. */ 268 currId =driver->idTable;270 currId = driver->idTable; 269 271 270 272 while (currId->vendorId) … … 276 278 ((currId->class ^ device->devClass) & currId->classMask)*/) 277 279 { 280 device->driver = driver; 281 278 282 /* Matched! Start up the device. */ 279 return driver->initOne(device, currId); 283 ret = driver->initOne(device, currId); 284 285 if (ret) 286 device->driver = NULL; 287 288 return ret; 280 289 } 281 290 … … 364 373 PciScanBus(0); 365 374 375 /* Add devices to IcFs */ 376 366 377 return 0; 367 378 }
