342,9 → 342,10 |
.prev_dpd dd ? |
|
.io_addr dd ? |
.pci_bus db ? |
.pci_dev db ? |
.pci_bus dd ? |
.pci_dev dd ? |
.irq_line db ? |
rb 3 ; alignment |
|
.prev_tx_frame dd ? |
.ver_id db ? |
438,8 → 439,11 |
mov ax , [eax+1] ; |
.nextdevice: |
mov ebx, [esi] |
cmp ax , word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte) |
cmp al, byte[device.pci_bus] |
jne @f |
cmp ah, byte[device.pci_dev] |
je .find_devicenum ; Device is already loaded, let's find it's device number |
@@: |
add esi, 4 |
loop .nextdevice |
|
454,8 → 458,11 |
mov ax , [eax+1] ; |
.nextdevice2: |
mov ebx, [esi] |
cmp ax , word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte) |
cmp al, byte[device.pci_bus] |
jne @f |
cmp ah, byte[device.pci_dev] |
je .find_devicenum ; Device is already loaded, let's find it's device number |
@@: |
add esi, 4 |
loop .nextdevice2 |
|
481,16 → 488,16 |
; save the pci bus and device numbers |
|
mov eax, [IOCTL.input] |
mov cl , [eax+1] |
mov [device.pci_bus], cl |
mov cl , [eax+2] |
mov [device.pci_dev], cl |
movzx ecx, byte[eax+1] |
mov [device.pci_bus], ecx |
movzx ecx, byte[eax+2] |
mov [device.pci_dev], ecx |
|
; Now, it's time to find the base io addres of the PCI device |
find_io [device.pci_bus], [device.pci_dev], [device.io_addr] |
PCI_find_io |
|
; We've found the io address, find IRQ now |
find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
PCI_find_irq |
|
DEBUGF 1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4 |
578,14 → 585,12 |
|
DEBUGF 1,"Probing 3com card\n" |
|
make_bus_master [device.pci_bus], [device.pci_dev] |
PCI_make_bus_master |
|
; wake up the card |
call wake_up |
|
movzx ecx, [device.pci_bus] |
movzx edx, [device.pci_dev] |
stdcall PciRead32, ecx ,edx ,0 ; get device/vendor id |
stdcall PciRead32, [device.pci_bus], [device.pci_dev], 0 ; get device/vendor id |
|
DEBUGF 1,"Vendor id: 0x%x\n", ax |
|
618,9 → 623,7 |
jz .not_vortex |
|
mov eax, 11111000b ; 248 = max latency |
movzx ecx, [device.pci_bus] |
movzx edx, [device.pci_dev] |
stdcall PciWrite32, ecx, edx, PCI_REG_LATENCY, eax |
stdcall PciWrite32, [device.pci_bus], [device.pci_dev], PCI_REG_LATENCY, eax |
|
.not_vortex: |
; set RX/TX functions |
1803,15 → 1806,13 |
|
; wake up - we directly do it by programming PCI |
; check if the device is power management capable |
movzx ecx, [device.pci_bus] |
movzx edx, [device.pci_dev] |
stdcall PciRead32, ecx, edx, PCI_REG_STATUS |
stdcall PciRead32, [device.pci_bus], [device.pci_dev], PCI_REG_STATUS |
|
test al, 10000b ; is there "new capabilities" linked list? |
jz .device_awake |
|
; search for power management register |
stdcall PciRead16, ecx, edx, PCI_REG_CAP_PTR |
stdcall PciRead16, [device.pci_bus], [device.pci_dev], PCI_REG_CAP_PTR |
cmp al, 0x3f |
jbe .device_awake |
|
1818,7 → 1819,7 |
; traverse the list |
movzx esi, al |
.pm_loop: |
stdcall PciRead32, ecx, edx, esi |
stdcall PciRead32, [device.pci_bus], [device.pci_dev], esi |
|
cmp al , 1 |
je .set_pm_state |
1833,11 → 1834,11 |
.set_pm_state: |
|
add esi, PCI_REG_PM_CTRL |
stdcall PciRead32, ecx, edx, esi |
stdcall PciRead32, [device.pci_bus], [device.pci_dev], esi |
test al, 3 |
jz .device_awake |
and al, not 11b ; set state to D0 |
stdcall PciWrite32, ecx, edx, esi, eax |
stdcall PciWrite32, [device.pci_bus], [device.pci_dev], esi, eax |
|
.device_awake: |
DEBUGF 1,"Device is awake\n" |