Rev 3155 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3155 | Rev 3205 | ||
---|---|---|---|
Line 211... | Line 211... | ||
211 | device: |
211 | device: |
Line 212... | Line 212... | ||
212 | 212 | ||
Line 213... | Line 213... | ||
213 | ETH_DEVICE |
213 | ETH_DEVICE |
214 | 214 | ||
215 | .io_addr dd ? |
215 | .io_addr dd ? |
216 | .pci_bus db ? |
216 | .pci_bus dd ? |
217 | .pci_dev db ? |
217 | .pci_dev dd ? |
218 | .irq_line db ? |
218 | .irq_line db ? |
219 | .cur_rx db ? |
219 | .cur_rx db ? |
220 | .cur_tx db ? |
220 | .cur_tx db ? |
221 | .last_tx db ? |
221 | .last_tx db ? |
- | 222 | .pci_revision db ? |
|
Line 222... | Line 223... | ||
222 | .pci_revision db ? |
223 | .table_entries db ? |
223 | .table_entries db ? |
224 | rb 2 ; alignment |
Line 224... | Line 225... | ||
224 | 225 | ||
Line 303... | Line 304... | ||
303 | 304 | ||
304 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
305 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
305 | mov ax, [eax+1] ; |
306 | mov ax, [eax+1] ; |
306 | .nextdevice: |
307 | .nextdevice: |
307 | mov ebx, [esi] |
308 | mov ebx, [esi] |
- | 309 | cmp al, byte[device.pci_bus] |
|
- | 310 | jne @f |
|
308 | cmp ax, word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte) |
311 | cmp ah, byte[device.pci_dev] |
- | 312 | je .find_devicenum ; Device is already loaded, let's find it's device number |
|
309 | je .find_devicenum ; Device is already loaded, let's find it's device number |
313 | @@: |
310 | add esi, 4 |
314 | add esi, 4 |
311 | loop .nextdevice |
315 | loop .nextdevice |
312 | ; 4e. This device doesn't have its own eth_device structure yet, let's create one |
316 | ; 4e. This device doesn't have its own eth_device structure yet, let's create one |
313 | .firstdevice: |
317 | .firstdevice: |
Line 317... | Line 321... | ||
317 | ; 4g. Allocate memory for device descriptor and receive+transmit buffers. |
321 | ; 4g. Allocate memory for device descriptor and receive+transmit buffers. |
318 | ; 4h. Zero the structure. |
322 | ; 4h. Zero the structure. |
319 | allocate_and_clear ebx, device.size, .fail |
323 | allocate_and_clear ebx, device.size, .fail |
320 | ; 4i. Save PCI coordinates |
324 | ; 4i. Save PCI coordinates |
321 | mov eax, [IOCTL.input] |
325 | mov eax, [IOCTL.input] |
322 | mov cl, [eax+1] |
326 | movzx ecx, byte[eax+1] |
323 | mov [device.pci_bus], cl |
327 | mov [device.pci_bus], ecx |
324 | mov cl, [eax+2] |
328 | movzx ecx, byte[eax+2] |
325 | mov [device.pci_dev], cl |
329 | mov [device.pci_dev], ecx |
326 | ; 4j. Fill in the direct call addresses into the struct. |
330 | ; 4j. Fill in the direct call addresses into the struct. |
327 | ; Note that get_MAC pointer is filled in initialization by probe. |
331 | ; Note that get_MAC pointer is filled in initialization by probe. |
328 | mov [device.reset], reset |
332 | mov [device.reset], reset |
329 | mov [device.transmit], transmit |
333 | mov [device.transmit], transmit |
330 | mov [device.set_MAC], write_mac |
334 | mov [device.set_MAC], write_mac |
Line 333... | Line 337... | ||
333 | 337 | ||
334 | ; 4k. Now, it's time to find the base io addres of the PCI device |
338 | ; 4k. Now, it's time to find the base io addres of the PCI device |
Line 335... | Line 339... | ||
335 | ; TODO: implement check if bus and dev exist on this machine |
339 | ; TODO: implement check if bus and dev exist on this machine |
336 | 340 | ||
Line 337... | Line 341... | ||
337 | ; Now, it's time to find the base io addres of the PCI device |
341 | ; Now, it's time to find the base io addres of the PCI device |
338 | find_io [device.pci_bus], [device.pci_dev], [device.io_addr] |
342 | PCI_find_io |
Line 339... | Line 343... | ||
339 | 343 | ||
340 | ; We've found the io address, find IRQ now |
344 | ; We've found the io address, find IRQ now |
341 | find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
345 | PCI_find_irq |
342 | 346 | ||
Line 412... | Line 416... | ||
412 | align 4 |
416 | align 4 |
413 | probe: |
417 | probe: |
414 | DEBUGF 1, "Probe\n" |
418 | DEBUGF 1, "Probe\n" |
Line 415... | Line 419... | ||
415 | 419 | ||
416 | ; wake up device CHECKME |
420 | ; wake up device CHECKME |
- | 421 | stdcall PciWrite8, [device.pci_bus], [device.pci_dev], 0x40, 0 |
|
417 | movzx eax, [device.pci_bus] |
422 | |
418 | movzx edx, [device.pci_dev] |
- | |
Line 419... | Line -... | ||
419 | stdcall PciWrite8, eax, edx, 0x40, 0 |
- | |
420 | 423 | PCI_make_bus_master |
|
Line 421... | Line 424... | ||
421 | make_bus_master [device.pci_bus], [device.pci_dev] |
424 | |
422 | adjust_latency [device.pci_bus], [device.pci_dev], 64 |
- | |
423 | - | ||
424 | ; Get Card Revision |
425 | PCI_adjust_latency 64 |
425 | movzx eax, [device.pci_bus] |
426 | |
Line 426... | Line 427... | ||
426 | movzx edx, [device.pci_dev] |
427 | ; Get Card Revision |
427 | stdcall PciRead8, eax, edx, 0x08 |
428 | stdcall PciRead8, [device.pci_bus], [device.pci_dev], 0x08 |
428 | mov [device.pci_revision], al ; save the revision for later use |
429 | mov [device.pci_revision], al ; save the revision for later use |