forked from KolibriOS/kolibrios
Updated PCI macros for network drivers.
git-svn-id: svn://kolibrios.org@3205 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
44f2d6661d
commit
c4c2da3caa
@ -342,9 +342,10 @@ virtual at ebx
|
||||
.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 @@ proc service_proc stdcall, ioctl:dword
|
||||
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 @@ proc service_proc stdcall, ioctl:dword
|
||||
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 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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 @@ probe:
|
||||
|
||||
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 @@ probe:
|
||||
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,22 +1806,20 @@ wake_up:
|
||||
|
||||
; 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
|
||||
|
||||
; 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 @@ wake_up:
|
||||
.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"
|
||||
|
@ -192,11 +192,11 @@ virtual at ebx
|
||||
.mcr1 dw ?
|
||||
.switch_sig dw ?
|
||||
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
|
||||
rb 1 ; dword alignment
|
||||
rb 3 ; dword alignment
|
||||
|
||||
.tx_ring: rb (((x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0)
|
||||
.rx_ring: rb (((x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0)
|
||||
@ -285,8 +285,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -310,18 +313,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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
|
||||
@ -416,7 +419,7 @@ align 4
|
||||
probe:
|
||||
DEBUGF 2,"Probing R6040 device\n"
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
; If PHY status change register is still set to zero
|
||||
; it means the bootloader didn't initialize it
|
||||
|
@ -40,8 +40,8 @@ virtual at ebx
|
||||
|
||||
.io_addr dd ?
|
||||
.irq_line db ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
|
||||
.flags db ?
|
||||
.vendor db ?
|
||||
@ -238,8 +238,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
mov ax, [eax+1] ; get the pci bus and device numbers
|
||||
.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
|
||||
|
||||
@ -247,18 +250,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
call create_new_struct
|
||||
|
||||
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
|
||||
|
||||
jmp .hook
|
||||
|
||||
|
@ -208,8 +208,8 @@ virtual at ebx
|
||||
.io_addr dd ?
|
||||
|
||||
.curr_tx_desc db ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
.hw_ver_id db ?
|
||||
|
||||
@ -298,8 +298,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
mov ax , [eax+1] ; get the pci bus and device numbers
|
||||
.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
|
||||
|
||||
@ -323,18 +326,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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 2, "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
|
||||
@ -422,7 +425,7 @@ align 4
|
||||
probe:
|
||||
DEBUGF 2, "Probing %s device\n", my_service
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
; get chip version
|
||||
|
||||
|
@ -253,8 +253,8 @@ virtual at ebx
|
||||
ETH_DEVICE
|
||||
|
||||
.io_addr dd ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
|
||||
rb 256-(($ - device) and 255) ; align 256
|
||||
@ -442,8 +442,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -467,20 +470,19 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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]
|
||||
mov eax, [device.io_addr]
|
||||
mov [tpc.mmio_addr], eax
|
||||
PCI_find_io
|
||||
mov [tpc.mmio_addr], eax ; CHECKME
|
||||
|
||||
; We've found the io address, find IRQ now
|
||||
|
||||
find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
|
||||
PCI_find_irq
|
||||
|
||||
DEBUGF 2,"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]:8
|
||||
@ -542,7 +544,7 @@ init_board:
|
||||
|
||||
DEBUGF 1,"init_board\n"
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
; Soft reset the chip
|
||||
set_io 0
|
||||
|
@ -40,18 +40,14 @@
|
||||
PCI_BIT_MASTER = 4 ; bit2: device acts as a PCI master
|
||||
|
||||
|
||||
macro find_io bus, dev, io {
|
||||
macro PCI_find_io {
|
||||
|
||||
local .check, .inc, .got
|
||||
|
||||
xor eax, eax
|
||||
mov esi, PCI_BASE_ADDRESS_0
|
||||
movzx ecx, bus
|
||||
movzx edx, dev
|
||||
.check:
|
||||
push ecx edx
|
||||
stdcall PciRead32, ecx ,edx ,esi
|
||||
pop edx ecx
|
||||
stdcall PciRead32, [device.pci_bus], [device.pci_dev], esi
|
||||
|
||||
test eax, PCI_BASE_ADDRESS_IO_MASK
|
||||
jz .inc
|
||||
@ -69,18 +65,18 @@ macro find_io bus, dev, io {
|
||||
xor eax, eax
|
||||
|
||||
.got:
|
||||
mov io, eax
|
||||
mov [device.io_addr], eax
|
||||
|
||||
}
|
||||
|
||||
|
||||
macro find_mmio32 bus, dev, io {
|
||||
macro PCI_find_mmio32 {
|
||||
|
||||
local .check, .inc, .got
|
||||
|
||||
mov esi, PCI_BASE_ADDRESS_0
|
||||
.check:
|
||||
stdcall PciRead32, bus, dev, esi
|
||||
stdcall PciRead32, [device.pci_bus], [device.pci_dev], esi
|
||||
|
||||
test eax, PCI_BASE_ADDRESS_SPACE_IO ; mmio address?
|
||||
jnz .inc
|
||||
@ -97,54 +93,40 @@ macro find_mmio32 bus, dev, io {
|
||||
xor eax, eax
|
||||
|
||||
.got:
|
||||
mov io, eax
|
||||
mov [device.mmio_addr], eax
|
||||
}
|
||||
|
||||
macro find_irq bus, dev, irq {
|
||||
macro PCI_find_irq {
|
||||
|
||||
push eax edx ecx
|
||||
movzx ecx, bus
|
||||
movzx edx, dev
|
||||
stdcall PciRead8, ecx, edx, PCI_REG_IRQ
|
||||
mov irq, al
|
||||
pop ecx edx eax
|
||||
stdcall PciRead8, [device.pci_bus], [device.pci_dev], PCI_REG_IRQ
|
||||
mov [device.irq_line], al
|
||||
|
||||
}
|
||||
|
||||
macro find_rev bus, dev, rev {
|
||||
macro PCI_find_rev {
|
||||
|
||||
push eax edx ecx
|
||||
movzx ecx, bus
|
||||
movzx edx, dev
|
||||
stdcall PciRead8, ecx ,edx ,0x8
|
||||
mov rev, al
|
||||
pop ecx edx eax
|
||||
stdcall PciRead8, [device.pci_bus], [device.pci_dev], PCI_REVISION_ID
|
||||
mov [device.revision], al
|
||||
|
||||
}
|
||||
|
||||
macro make_bus_master bus, dev {
|
||||
macro PCI_make_bus_master bus, dev {
|
||||
|
||||
movzx ecx, bus
|
||||
movzx edx, dev
|
||||
push ecx edx
|
||||
stdcall PciRead32, ecx ,edx, PCI_REG_COMMAND
|
||||
pop edx ecx
|
||||
stdcall PciRead32, [device.pci_bus], [device.pci_dev], PCI_REG_COMMAND
|
||||
or al, PCI_BIT_MASTER
|
||||
stdcall PciWrite32, ecx, edx, PCI_REG_COMMAND, eax
|
||||
stdcall PciWrite32, [device.pci_bus], [device.pci_dev], PCI_REG_COMMAND, eax
|
||||
|
||||
}
|
||||
|
||||
macro adjust_latency bus, dev, min {
|
||||
macro PCI_adjust_latency min {
|
||||
|
||||
movzx ecx, bus
|
||||
movzx edx, dev
|
||||
push ecx edx
|
||||
stdcall PciRead8, ecx ,edx, PCI_REG_LATENCY
|
||||
pop edx ecx
|
||||
local .not
|
||||
|
||||
stdcall PciRead8, [device.pci_bus], [device.pci_dev], PCI_REG_LATENCY
|
||||
cmp al, min
|
||||
ja @f
|
||||
ja .not
|
||||
mov al, min
|
||||
stdcall PciWrite8, ecx, edx, PCI_REG_LATENCY, eax
|
||||
@@:
|
||||
stdcall PciWrite8, [device.pci_bus], [device.pci_dev], PCI_REG_LATENCY, eax
|
||||
.not:
|
||||
|
||||
}
|
||||
|
@ -57,9 +57,10 @@ virtual at ebx
|
||||
.rx_crt_des dd ? ; Rx current descriptor
|
||||
|
||||
.io_addr dd ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
rb 3 ; alignment
|
||||
|
||||
.size = $ - device
|
||||
|
||||
@ -384,8 +385,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -414,18 +418,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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 2,"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]:8
|
||||
@ -525,11 +529,9 @@ probe:
|
||||
|
||||
DEBUGF 2,"Probing dec21x4x device: "
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
movzx eax, [device.pci_bus]
|
||||
movzx ecx, [device.pci_dev]
|
||||
stdcall PciRead32, eax ,ecx ,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
|
||||
|
||||
cmp ax, 0x1011
|
||||
@ -552,10 +554,8 @@ probe:
|
||||
|
||||
; wake up the 21143
|
||||
|
||||
movzx ecx, [device.pci_bus]
|
||||
movzx edx, [device.pci_dev]
|
||||
xor eax, eax
|
||||
stdcall PciWrite32, ecx, edx, 0x40, eax
|
||||
stdcall PciWrite32, [device.pci_bus], [device.pci_dev], 0x40, eax
|
||||
|
||||
|
||||
.supported_device:
|
||||
|
@ -389,7 +389,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
|
||||
; Now, it's time to find the base mmio addres of the PCI device
|
||||
|
||||
find_mmio32 [device.pci_bus], [device.pci_dev], [device.mmio_addr]
|
||||
PCI_find_mmio32
|
||||
|
||||
; Create virtual mapping of the physical memory
|
||||
|
||||
@ -401,7 +401,7 @@ proc service_proc stdcall, ioctl:dword
|
||||
|
||||
; We've found the mmio address, find IRQ now
|
||||
|
||||
find_irq byte [device.pci_bus], byte [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.mmio_addr]:8
|
||||
@ -484,7 +484,7 @@ probe:
|
||||
|
||||
DEBUGF 1,"Probe\n"
|
||||
|
||||
make_bus_master byte [device.pci_bus], byte [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
; TODO: validate the device
|
||||
|
||||
|
@ -276,8 +276,8 @@ virtual at ebx
|
||||
.rx_desc rb NUM_RX_DESC*mtd_desc.size
|
||||
|
||||
.io_addr dd ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
.dev_id dw ?
|
||||
|
||||
@ -386,8 +386,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -411,18 +414,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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 2,"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]:8
|
||||
@ -513,13 +516,11 @@ probe:
|
||||
|
||||
DEBUGF 2,"Probing mtd80x device\n"
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
movzx eax, [device.pci_bus]
|
||||
movzx ecx, [device.pci_dev]
|
||||
stdcall PciRead32, eax ,ecx ,0
|
||||
stdcall PciRead32, [device.pci_bus], [device.pci_dev], 0
|
||||
|
||||
cmp ax , 0x1516
|
||||
cmp ax, 0x1516
|
||||
jne .notfound
|
||||
shr eax, 16
|
||||
mov [device.dev_id], ax
|
||||
|
@ -316,8 +316,8 @@ virtual at ebx
|
||||
|
||||
.io_addr dd ?
|
||||
.irq_line db ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
|
||||
.read_csr dd ?
|
||||
.write_csr dd ?
|
||||
@ -426,8 +426,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -451,18 +454,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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
|
||||
@ -697,7 +700,7 @@ probe:
|
||||
mov [device.ltint],1
|
||||
.L11:
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
mov [device.options], PORT_ASEL
|
||||
mov [device.mode_], MODE_RXD + MODE_TXD ; disable receive and transmit
|
||||
|
@ -489,8 +489,8 @@ virtual at ebx
|
||||
ETH_DEVICE
|
||||
|
||||
.io_addr dd ?
|
||||
.pci_dev db ?
|
||||
.pci_bus db ?
|
||||
.pci_dev dd ?
|
||||
.pci_bus dd ?
|
||||
.revision db ?
|
||||
.irq_line db ?
|
||||
.chip_id dw ?
|
||||
@ -614,8 +614,11 @@ proc service_proc stdcall, ioctl:dword
|
||||
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
|
||||
|
||||
@ -639,18 +642,18 @@ proc service_proc stdcall, ioctl:dword
|
||||
; 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
|
||||
@ -718,16 +721,14 @@ probe:
|
||||
DEBUGF 1, "Probing card at 0x%x\n", eax
|
||||
|
||||
; make the card a bus master
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
PCI_make_bus_master
|
||||
|
||||
; get device id
|
||||
movzx ecx, [device.pci_bus]
|
||||
movzx edx, [device.pci_dev]
|
||||
stdcall PciRead16, ecx, edx, PCI_DEVICE_ID
|
||||
stdcall PciRead16, [device.pci_bus], [device.pci_dev], PCI_DEVICE_ID
|
||||
mov [device.chip_id], ax
|
||||
|
||||
; get revision id.
|
||||
find_rev [device.pci_bus], [device.pci_dev], [device.revision]
|
||||
PCI_find_rev
|
||||
|
||||
movzx eax, [device.revision]
|
||||
DEBUGF 1, "Card revision = 0x%x\n", eax
|
||||
@ -808,11 +809,9 @@ probe:
|
||||
out dx, al
|
||||
|
||||
; turn on bit2 in PCI configuration register 0x53 , only for 3065
|
||||
movzx ecx, [device.pci_bus]
|
||||
movzx edx, [device.pci_dev]
|
||||
stdcall PciRead8, ecx, edx, PCI_REG_MODE3
|
||||
stdcall PciRead8, [device.pci_bus], [device.pci_dev], PCI_REG_MODE3
|
||||
or al, MODE3_MIION
|
||||
stdcall PciWrite8, ecx, edx, PCI_REG_MODE3, eax
|
||||
stdcall PciWrite8, [device.pci_bus], [device.pci_dev], PCI_REG_MODE3, eax
|
||||
.not_vt3065:
|
||||
|
||||
; back off algorithm, disable the right-most 4-bit off CFGD
|
||||
|
@ -213,14 +213,15 @@ virtual at ebx
|
||||
ETH_DEVICE
|
||||
|
||||
.io_addr dd ?
|
||||
.pci_bus db ?
|
||||
.pci_dev db ?
|
||||
.pci_bus dd ?
|
||||
.pci_dev dd ?
|
||||
.irq_line db ?
|
||||
.cur_rx db ?
|
||||
.cur_tx db ?
|
||||
.last_tx db ?
|
||||
.pci_revision db ?
|
||||
.table_entries db ?
|
||||
rb 2 ; alignment
|
||||
|
||||
.txd rd (4 * NUM_TX_DESC)
|
||||
.rxd rd (4 * NUM_RX_DESC)
|
||||
@ -305,8 +306,11 @@ service_proc:
|
||||
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
|
||||
; 4e. This device doesn't have its own eth_device structure yet, let's create one
|
||||
@ -319,10 +323,10 @@ service_proc:
|
||||
allocate_and_clear ebx, device.size, .fail
|
||||
; 4i. Save PCI coordinates
|
||||
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
|
||||
; 4j. Fill in the direct call addresses into the struct.
|
||||
; Note that get_MAC pointer is filled in initialization by probe.
|
||||
mov [device.reset], reset
|
||||
@ -335,10 +339,10 @@ service_proc:
|
||||
; TODO: implement check if bus and dev exist on this machine
|
||||
|
||||
; 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
|
||||
|
||||
; 4m. Add new device to the list (required for int_handler).
|
||||
mov eax, [devices]
|
||||
@ -414,17 +418,14 @@ probe:
|
||||
DEBUGF 1, "Probe\n"
|
||||
|
||||
; wake up device CHECKME
|
||||
movzx eax, [device.pci_bus]
|
||||
movzx edx, [device.pci_dev]
|
||||
stdcall PciWrite8, eax, edx, 0x40, 0
|
||||
stdcall PciWrite8, [device.pci_bus], [device.pci_dev], 0x40, 0
|
||||
|
||||
make_bus_master [device.pci_bus], [device.pci_dev]
|
||||
adjust_latency [device.pci_bus], [device.pci_dev], 64
|
||||
PCI_make_bus_master
|
||||
|
||||
PCI_adjust_latency 64
|
||||
|
||||
; Get Card Revision
|
||||
movzx eax, [device.pci_bus]
|
||||
movzx edx, [device.pci_dev]
|
||||
stdcall PciRead8, eax, edx, 0x08
|
||||
stdcall PciRead8, [device.pci_bus], [device.pci_dev], 0x08
|
||||
mov [device.pci_revision], al ; save the revision for later use
|
||||
|
||||
; Look up through the specific_table
|
||||
|
Loading…
Reference in New Issue
Block a user