forked from KolibriOS/kolibrios
Introduced new application event for network subsystem changes (link changed, ip changed, ...)
Removed get_mac and set_mac procedures from device structure, kernel does not need them. Added link state detection capabilities for kernel and some drivers. git-svn-id: svn://kolibrios.org@3346 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b2da70be62
commit
f685c27c07
@ -76,6 +76,9 @@ redraw:
|
|||||||
add ebx, 18
|
add ebx, 18
|
||||||
mov edx, str_MAC
|
mov edx, str_MAC
|
||||||
mcall
|
mcall
|
||||||
|
add ebx, 18
|
||||||
|
mov edx, str_link
|
||||||
|
mcall
|
||||||
|
|
||||||
mov ebx, API_ETH + 4
|
mov ebx, API_ETH + 4
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
@ -201,14 +204,21 @@ draw_stats:
|
|||||||
inc bl
|
inc bl
|
||||||
cmp bl, 3
|
cmp bl, 3
|
||||||
jbe @r
|
jbe @r
|
||||||
|
inc bl
|
||||||
|
mcall 76
|
||||||
|
push eax
|
||||||
|
|
||||||
mov ebx, 0x000a0000
|
mov ebx, 0x000a0000
|
||||||
pop ecx
|
pop ecx
|
||||||
mov edx, 135 shl 16 + 75 + 3*18
|
mov edx, 135 shl 16 + 75 + 5*18
|
||||||
mov esi, 0x40000000
|
mov esi, 0x40000000
|
||||||
mov edi, 0x00bcbcbc
|
mov edi, 0x00bcbcbc
|
||||||
mcall 47
|
mcall 47
|
||||||
|
|
||||||
|
sub edx, 18*2
|
||||||
|
pop ecx
|
||||||
|
mcall
|
||||||
|
|
||||||
sub edx, 18
|
sub edx, 18
|
||||||
pop ecx
|
pop ecx
|
||||||
mcall
|
mcall
|
||||||
@ -591,6 +601,7 @@ str_conflicts db 'ARP conflicts:', 0
|
|||||||
str_unknown db 'unknown', 0
|
str_unknown db 'unknown', 0
|
||||||
str_missed db 'Packets missed:',0
|
str_missed db 'Packets missed:',0
|
||||||
str_dumped db 'Packets dumped:',0
|
str_dumped db 'Packets dumped:',0
|
||||||
|
str_link db 'Link state:',0
|
||||||
|
|
||||||
namebuf rb 64
|
namebuf rb 64
|
||||||
|
|
||||||
|
@ -480,8 +480,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], null_op
|
mov [device.transmit], null_op
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], null_op
|
mov [device.unload], null_op
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -829,7 +827,7 @@ start_device:
|
|||||||
|
|
||||||
; print link type
|
; print link type
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
bsr ax, word [device.mode]
|
bsr ax, word [device.state]
|
||||||
jz @f
|
jz @f
|
||||||
sub ax, 4
|
sub ax, 4
|
||||||
@@:
|
@@:
|
||||||
@ -1108,7 +1106,7 @@ try_link_detect:
|
|||||||
.finish:
|
.finish:
|
||||||
test al, al
|
test al, al
|
||||||
jz @f
|
jz @f
|
||||||
or byte [device.mode+1], 100b
|
or byte [device.state+1], 100b
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1219,7 +1217,7 @@ try_phy:
|
|||||||
and eax, 1111100000b
|
and eax, 1111100000b
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
mov word[device.mode+2], ax
|
mov word[device.state+2], ax
|
||||||
|
|
||||||
; switch to register window 3
|
; switch to register window 3
|
||||||
set_io 0
|
set_io 0
|
||||||
@ -1508,7 +1506,7 @@ try_loopback:
|
|||||||
mov cl, al
|
mov cl, al
|
||||||
inc cl
|
inc cl
|
||||||
shl cl, 3
|
shl cl, 3
|
||||||
or byte [device.mode+1], cl
|
or byte [device.state+1], cl
|
||||||
|
|
||||||
test al, al ; aui or coax?
|
test al, al ; aui or coax?
|
||||||
jz .complete_loopback
|
jz .complete_loopback
|
||||||
@ -1540,7 +1538,7 @@ try_loopback:
|
|||||||
|
|
||||||
test al, al
|
test al, al
|
||||||
jnz @f
|
jnz @f
|
||||||
and byte [device.mode+1], not 11000b
|
and byte [device.state+1], not 11000b
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -1713,7 +1711,7 @@ set_available_media:
|
|||||||
DEBUGF 1,"base TX is available\n"
|
DEBUGF 1,"base TX is available\n"
|
||||||
or eax, (100b shl 20)
|
or eax, (100b shl 20)
|
||||||
if defined FORCE_FD
|
if defined FORCE_FD
|
||||||
mov word [device.mode], (1 shl 8)
|
mov word [device.state], (1 shl 8)
|
||||||
else
|
else
|
||||||
mov word [device.mode], (1 shl 7)
|
mov word [device.mode], (1 shl 7)
|
||||||
end if
|
end if
|
||||||
@ -1725,7 +1723,7 @@ end if
|
|||||||
|
|
||||||
DEBUGF 1,"base FX is available\n"
|
DEBUGF 1,"base FX is available\n"
|
||||||
or eax, (101b shl 20)
|
or eax, (101b shl 20)
|
||||||
mov word [device.mode], (1 shl 10)
|
mov word [device.state], (1 shl 10)
|
||||||
jmp .set_media
|
jmp .set_media
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -1734,7 +1732,7 @@ end if
|
|||||||
|
|
||||||
DEBUGF 1,"mii-device is available\n"
|
DEBUGF 1,"mii-device is available\n"
|
||||||
or eax, (0110b shl 20)
|
or eax, (0110b shl 20)
|
||||||
mov word [device.mode], (1 shl 13)
|
mov word [device.state], (1 shl 13)
|
||||||
jmp .set_media
|
jmp .set_media
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -1744,9 +1742,9 @@ end if
|
|||||||
DEBUGF 1,"10base-T is available\n"
|
DEBUGF 1,"10base-T is available\n"
|
||||||
.set_default:
|
.set_default:
|
||||||
if FORCE_FD
|
if FORCE_FD
|
||||||
mov word [device.mode], (1 shl 6)
|
mov word [device.state], (1 shl 6)
|
||||||
else
|
else
|
||||||
mov word [device.mode], (1 shl 5)
|
mov word [device.state], (1 shl 5)
|
||||||
end if
|
end if
|
||||||
jmp .set_media
|
jmp .set_media
|
||||||
@@:
|
@@:
|
||||||
@ -1762,7 +1760,7 @@ end if
|
|||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
or eax, (11b shl 20)
|
or eax, (11b shl 20)
|
||||||
mov word [device.mode], (1 shl 12)
|
mov word [device.state], (1 shl 12)
|
||||||
jmp .set_media
|
jmp .set_media
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -1771,7 +1769,7 @@ end if
|
|||||||
|
|
||||||
DEBUGF 1,"AUI is available\n"
|
DEBUGF 1,"AUI is available\n"
|
||||||
or eax, (1 shl 20)
|
or eax, (1 shl 20)
|
||||||
mov word [device.mode], (1 shl 11)
|
mov word [device.state], (1 shl 11)
|
||||||
|
|
||||||
.set_media:
|
.set_media:
|
||||||
set_io 0
|
set_io 0
|
||||||
|
@ -305,8 +305,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], .fail
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -620,9 +618,11 @@ reset:
|
|||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
DEBUGF 1,"Reset ok\n"
|
DEBUGF 1,"Reset ok\n"
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -350,8 +350,6 @@ create_new_struct:
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -653,6 +651,9 @@ reset:
|
|||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], ETH_FRAME_LEN
|
mov [device.mtu], ETH_FRAME_LEN
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
; Indicate that we have successfully reset the card
|
; Indicate that we have successfully reset the card
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
DEBUGF 2,"Done!\n"
|
DEBUGF 2,"Done!\n"
|
||||||
|
@ -32,7 +32,6 @@ format MS COFF
|
|||||||
include 'proc32.inc'
|
include 'proc32.inc'
|
||||||
include 'imports.inc'
|
include 'imports.inc'
|
||||||
include 'fdo.inc'
|
include 'fdo.inc'
|
||||||
include '../struct.inc'
|
|
||||||
include 'netdrv.inc'
|
include 'netdrv.inc'
|
||||||
|
|
||||||
public START
|
public START
|
||||||
@ -59,7 +58,7 @@ public version
|
|||||||
REG_HLTCLK = 0x5b ; undocumented halt clock register
|
REG_HLTCLK = 0x5b ; undocumented halt clock register
|
||||||
REG_BMCR = 0x62 ; basic mode control register
|
REG_BMCR = 0x62 ; basic mode control register
|
||||||
REG_ANAR = 0x66 ; auto negotiation advertisement register
|
REG_ANAR = 0x66 ; auto negotiation advertisement register
|
||||||
REG_9346CR_WE = 11b SHL 6
|
REG_9346CR_WE = 11b shl 6
|
||||||
|
|
||||||
BIT_RUNT = 4 ; total packet length < 64 bytes
|
BIT_RUNT = 4 ; total packet length < 64 bytes
|
||||||
BIT_LONG = 3 ; total packet length > 4k
|
BIT_LONG = 3 ; total packet length > 4k
|
||||||
@ -166,16 +165,16 @@ public version
|
|||||||
IDX_RTL8139D = 6
|
IDX_RTL8139D = 6
|
||||||
IDX_RTL8101 = 7
|
IDX_RTL8101 = 7
|
||||||
|
|
||||||
ISR_SERR = 1 SHL 15
|
ISR_SERR = 1 shl 15
|
||||||
ISR_TIMEOUT = 1 SHL 14
|
ISR_TIMEOUT = 1 shl 14
|
||||||
ISR_LENCHG = 1 SHL 13
|
ISR_LENCHG = 1 shl 13
|
||||||
ISR_FIFOOVW = 1 SHL 6
|
ISR_FIFOOVW = 1 shl 6
|
||||||
ISR_PUN = 1 SHL 5
|
ISR_PUN = 1 shl 5
|
||||||
ISR_RXOVW = 1 SHL 4
|
ISR_RXOVW = 1 shl 4
|
||||||
ISR_TER = 1 SHL 3
|
ISR_TER = 1 shl 3
|
||||||
ISR_TOK = 1 SHL 2
|
ISR_TOK = 1 shl 2
|
||||||
ISR_RER = 1 SHL 1
|
ISR_RER = 1 shl 1
|
||||||
ISR_ROK = 1 SHL 0
|
ISR_ROK = 1 shl 0
|
||||||
|
|
||||||
INTERRUPT_MASK = ISR_ROK or \
|
INTERRUPT_MASK = ISR_ROK or \
|
||||||
ISR_RXOVW or \
|
ISR_RXOVW or \
|
||||||
@ -185,14 +184,14 @@ public version
|
|||||||
ISR_TOK or \
|
ISR_TOK or \
|
||||||
ISR_TER
|
ISR_TER
|
||||||
|
|
||||||
TSR_OWN = 1 SHL 13
|
TSR_OWN = 1 shl 13
|
||||||
TSR_TUN = 1 SHL 14
|
TSR_TUN = 1 shl 14
|
||||||
TSR_TOK = 1 SHL 15
|
TSR_TOK = 1 shl 15
|
||||||
|
|
||||||
TSR_CDH = 1 SHL 28
|
TSR_CDH = 1 shl 28
|
||||||
TSR_OWC = 1 SHL 29
|
TSR_OWC = 1 shl 29
|
||||||
TSR_TABT = 1 SHL 30
|
TSR_TABT = 1 shl 30
|
||||||
TSR_CRS = 1 SHL 31
|
TSR_CRS = 1 shl 31
|
||||||
|
|
||||||
|
|
||||||
virtual at ebx
|
virtual at ebx
|
||||||
@ -202,7 +201,6 @@ virtual at ebx
|
|||||||
ETH_DEVICE
|
ETH_DEVICE
|
||||||
|
|
||||||
.rx_buffer dd ?
|
.rx_buffer dd ?
|
||||||
.tx_buffer dd ?
|
|
||||||
|
|
||||||
.rx_data_offset dd ?
|
.rx_data_offset dd ?
|
||||||
.io_addr dd ?
|
.io_addr dd ?
|
||||||
@ -295,7 +293,7 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .firstdevice
|
jz .firstdevice
|
||||||
|
|
||||||
mov ax , [eax+1] ; get the pci bus and device numbers
|
mov ax, [eax+1] ; get the pci bus and device numbers
|
||||||
.nextdevice:
|
.nextdevice:
|
||||||
mov ebx, [esi]
|
mov ebx, [esi]
|
||||||
cmp al, byte[device.pci_bus]
|
cmp al, byte[device.pci_bus]
|
||||||
@ -318,8 +316,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -339,7 +335,7 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
PCI_find_irq
|
PCI_find_irq
|
||||||
|
|
||||||
DEBUGF 2, "Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
|
DEBUGF 2, "Hooking into device, dev:%x, bus:%x, irq:%x, I/O addr:%x\n",\
|
||||||
[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
|
[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
|
||||||
|
|
||||||
; Allocate the receive buffer
|
; Allocate the receive buffer
|
||||||
@ -428,7 +424,6 @@ probe:
|
|||||||
PCI_make_bus_master
|
PCI_make_bus_master
|
||||||
|
|
||||||
; get chip version
|
; get chip version
|
||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_TXCONFIG + 2
|
set_io REG_TXCONFIG + 2
|
||||||
in ax, dx
|
in ax, dx
|
||||||
@ -436,6 +431,7 @@ probe:
|
|||||||
shr ax, 6
|
shr ax, 6
|
||||||
and al, 01111111b
|
and al, 01111111b
|
||||||
|
|
||||||
|
; now find it in our array
|
||||||
mov ecx, HW_VER_ARRAY_SIZE-1
|
mov ecx, HW_VER_ARRAY_SIZE-1
|
||||||
.chip_ver_loop:
|
.chip_ver_loop:
|
||||||
cmp al, [hw_ver_array + ecx]
|
cmp al, [hw_ver_array + ecx]
|
||||||
@ -456,30 +452,31 @@ probe:
|
|||||||
DEBUGF 2, "Chip version: %s\n", ecx
|
DEBUGF 2, "Chip version: %s\n", ecx
|
||||||
|
|
||||||
; wake up the chip
|
; wake up the chip
|
||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_HLTCLK
|
set_io REG_HLTCLK
|
||||||
mov al, 'R' ; run the clock
|
mov al, 'R' ; run the clock
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; unlock config and BMCR registers
|
; unlock config and BMCR registers
|
||||||
|
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; enable power management
|
; enable power management
|
||||||
|
|
||||||
set_io REG_CONFIG1
|
set_io REG_CONFIG1
|
||||||
in al, dx
|
in al, dx
|
||||||
cmp [device.hw_ver_id], IDX_RTL8139B
|
cmp [device.hw_ver_id], IDX_RTL8139B
|
||||||
jb .old_chip
|
jae .new_chip
|
||||||
|
; wake up older chips
|
||||||
|
and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN))
|
||||||
|
out dx, al
|
||||||
|
jmp .finish_wake_up
|
||||||
|
|
||||||
; set LWAKE pin to active high (default value).
|
; set LWAKE pin to active high (default value).
|
||||||
; it is for Wake-On-LAN functionality of some motherboards.
|
; it is for Wake-On-LAN functionality of some motherboards.
|
||||||
; this signal is used to inform the motherboard to execute a wake-up process.
|
; this signal is used to inform the motherboard to execute a wake-up process.
|
||||||
; only at newer chips.
|
; only at newer chips.
|
||||||
|
.new_chip:
|
||||||
or al, (1 shl BIT_PMEn)
|
or al, (1 shl BIT_PMEn)
|
||||||
and al, not (1 shl BIT_LWACT)
|
and al, not (1 shl BIT_LWACT)
|
||||||
out dx, al
|
out dx, al
|
||||||
@ -489,17 +486,8 @@ probe:
|
|||||||
and al, not (1 shl BIT_LWPTN)
|
and al, not (1 shl BIT_LWPTN)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
jmp .finish_wake_up
|
|
||||||
.old_chip:
|
|
||||||
|
|
||||||
; wake up older chips
|
|
||||||
|
|
||||||
and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN))
|
|
||||||
out dx, al
|
|
||||||
.finish_wake_up:
|
|
||||||
|
|
||||||
; lock config and BMCR registers
|
; lock config and BMCR registers
|
||||||
|
.finish_wake_up:
|
||||||
xor al, al
|
xor al, al
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
@ -514,12 +502,11 @@ probe:
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
DEBUGF 2, "Resetting\n"
|
DEBUGF 2, "Reset\n"
|
||||||
|
|
||||||
; attach int handler
|
; attach int handler
|
||||||
|
|
||||||
movzx eax, [device.irq_line]
|
movzx eax, [device.irq_line]
|
||||||
DEBUGF 1, "Attaching int handler to irq %x, ", eax:1
|
DEBUGF 1, "Attaching int handler to irq %x\n", eax:1
|
||||||
stdcall AttachIntHandler, eax, int_handler, dword 0
|
stdcall AttachIntHandler, eax, int_handler, dword 0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
@ -529,123 +516,106 @@ reset:
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
; reset chip
|
; reset chip
|
||||||
|
|
||||||
DEBUGF 1, "Resetting chip\n"
|
DEBUGF 1, "Resetting chip\n"
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_COMMAND
|
set_io REG_COMMAND
|
||||||
mov al , 1 shl BIT_RST
|
mov al, 1 shl BIT_RST
|
||||||
out dx , al
|
out dx, al
|
||||||
mov cx , 1000 ; wait no longer for the reset
|
mov cx, 1000 ; wait no longer for the reset
|
||||||
.wait_for_reset:
|
.wait_for_reset:
|
||||||
in al , dx
|
in al, dx
|
||||||
test al , 1 shl BIT_RST
|
test al, 1 shl BIT_RST
|
||||||
jz .reset_completed ; RST remains 1 during reset
|
jz .reset_completed ; RST remains 1 during reset
|
||||||
dec cx
|
dec cx
|
||||||
jns .wait_for_reset
|
jns .wait_for_reset
|
||||||
|
DEBUGF 1, "Reset timeout!\n"
|
||||||
.reset_completed:
|
.reset_completed:
|
||||||
|
|
||||||
; unlock config and BMCR registers
|
; unlock config and BMCR registers
|
||||||
|
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; initialize multicast registers (no filtering)
|
; initialize multicast registers (no filtering)
|
||||||
|
|
||||||
mov eax, 0xffffffff
|
mov eax, 0xffffffff
|
||||||
set_io REG_MAR0
|
set_io REG_MAR0
|
||||||
out dx, eax
|
out dx, eax
|
||||||
set_io REG_MAR4
|
set_io REG_MAR4
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; enable Rx/Tx
|
|
||||||
|
|
||||||
mov al, (1 shl BIT_RE) or (1 shl BIT_TE)
|
|
||||||
set_io REG_COMMAND
|
|
||||||
out dx, al
|
|
||||||
|
|
||||||
; Rxbuffer size, unlimited dma burst, no wrapping, no rx threshold
|
; Rxbuffer size, unlimited dma burst, no wrapping, no rx threshold
|
||||||
; accept broadcast packets, accept physical match packets
|
; accept broadcast packets, accept physical match packets
|
||||||
|
|
||||||
mov ax, RX_CONFIG
|
mov ax, RX_CONFIG
|
||||||
set_io REG_RXCONFIG
|
set_io REG_RXCONFIG
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
|
|
||||||
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
|
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
|
||||||
|
|
||||||
mov eax, (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
|
mov eax, (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
|
||||||
set_io REG_TXCONFIG
|
set_io REG_TXCONFIG
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; enable auto negotiation
|
; enable auto negotiation
|
||||||
|
|
||||||
set_io REG_BMCR
|
set_io REG_BMCR
|
||||||
in ax, dx
|
in ax, dx
|
||||||
or ax, (1 shl BIT_ANE)
|
or ax, (1 shl BIT_ANE)
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; set auto negotiation advertisement
|
; set auto negotiation advertisement
|
||||||
|
|
||||||
set_io REG_ANAR
|
set_io REG_ANAR
|
||||||
in ax, dx
|
in ax, dx
|
||||||
or ax, (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
|
or ax, (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; lock config and BMCR registers
|
; lock config and BMCR registers
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; init RX/TX pointers
|
; init RX/TX pointers
|
||||||
|
|
||||||
mov [device.rx_data_offset], eax
|
mov [device.rx_data_offset], eax
|
||||||
mov [device.curr_tx_desc], al
|
mov [device.curr_tx_desc], al
|
||||||
|
|
||||||
; set_io REG_CAPR
|
; set_io REG_CAPR
|
||||||
; out dx, ax
|
; out dx, ax
|
||||||
|
|
||||||
; clear packet/byte counters
|
; clear packet/byte counters
|
||||||
|
|
||||||
lea edi, [device.bytes_tx]
|
lea edi, [device.bytes_tx]
|
||||||
mov ecx, 6
|
mov ecx, 6
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
; clear missing packet counter
|
; clear missing packet counter
|
||||||
|
|
||||||
set_io REG_MPC
|
set_io REG_MPC
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; set RxBuffer address, init RX buffer offset
|
; set RxBuffer address, init RX buffer offset
|
||||||
|
|
||||||
mov eax, [device.rx_buffer]
|
mov eax, [device.rx_buffer]
|
||||||
mov dword[eax], 0
|
mov dword[eax], 0 ; clear receive flags for first packet (really needed??)
|
||||||
DEBUGF 2, "RX buffer: %x\n", eax
|
DEBUGF 2, "RX buffer virtual addr=0x%x\n", eax
|
||||||
GetRealAddr
|
GetRealAddr
|
||||||
DEBUGF 2, "RX buffer: %x\n", eax
|
DEBUGF 2, "RX buffer real addr=0x%x\n", eax
|
||||||
set_io REG_RBSTART
|
set_io REG_RBSTART
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; Read MAC address
|
; Read MAC address
|
||||||
|
|
||||||
call read_mac
|
call read_mac
|
||||||
|
|
||||||
; enable interrupts
|
; enable Rx/Tx
|
||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
|
mov al, (1 shl BIT_RE) or (1 shl BIT_TE)
|
||||||
|
set_io REG_COMMAND
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
; enable interrupts
|
||||||
set_io REG_IMR
|
set_io REG_IMR
|
||||||
mov eax, INTERRUPT_MASK
|
mov ax, INTERRUPT_MASK
|
||||||
out dx , ax
|
out dx, ax
|
||||||
|
|
||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
call cable
|
||||||
|
|
||||||
; Indicate that we have successfully reset the card
|
; Indicate that we have successfully reset the card
|
||||||
|
|
||||||
DEBUGF 2, "Done!\n"
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -750,7 +720,6 @@ int_handler:
|
|||||||
DEBUGF 1, "\n%s int\n", my_service
|
DEBUGF 1, "\n%s int\n", my_service
|
||||||
|
|
||||||
; find pointer of device wich made IRQ occur
|
; find pointer of device wich made IRQ occur
|
||||||
|
|
||||||
mov ecx, [devices]
|
mov ecx, [devices]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .nothing
|
jz .nothing
|
||||||
@ -760,8 +729,8 @@ int_handler:
|
|||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_ISR
|
set_io REG_ISR
|
||||||
in ax, dx
|
in ax, dx ; Get interrupt status
|
||||||
out dx, ax ; send it back to ACK
|
out dx, ax ; send it back to ACK
|
||||||
test ax, ax
|
test ax, ax
|
||||||
jnz .got_it
|
jnz .got_it
|
||||||
.continue:
|
.continue:
|
||||||
@ -769,7 +738,7 @@ int_handler:
|
|||||||
dec ecx
|
dec ecx
|
||||||
jnz .nextdevice
|
jnz .nextdevice
|
||||||
.nothing:
|
.nothing:
|
||||||
ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
|
ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
|
||||||
|
|
||||||
.got_it:
|
.got_it:
|
||||||
|
|
||||||
@ -785,42 +754,41 @@ int_handler:
|
|||||||
.receive:
|
.receive:
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_COMMAND
|
set_io REG_COMMAND
|
||||||
in al , dx
|
in al, dx
|
||||||
test al , BUFE ; test if RX buffer is empty
|
test al, BUFE ; test if RX buffer is empty
|
||||||
jnz .finish ;
|
jnz .finish
|
||||||
|
|
||||||
DEBUGF 1, "RX: "
|
DEBUGF 1, "RX: "
|
||||||
|
|
||||||
mov eax, [device.rx_buffer]
|
mov eax, [device.rx_buffer]
|
||||||
add eax, [device.rx_data_offset]
|
add eax, [device.rx_data_offset]
|
||||||
test byte [eax], (1 shl BIT_ROK) ; check if packet is ok
|
test byte [eax], (1 shl BIT_ROK) ; check if packet is ok
|
||||||
jz .reset_rx
|
jz .reset_rx
|
||||||
|
|
||||||
; packet is ok, copy it
|
; packet is ok, copy it
|
||||||
movzx ecx, word [eax+2] ; packet length
|
movzx ecx, word [eax+2] ; packet length
|
||||||
|
sub cx, 4 ; don't copy CRC
|
||||||
sub ecx, 4 ; don't copy CRC
|
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
add dword [device.bytes_rx], ecx
|
add dword [device.bytes_rx], ecx
|
||||||
adc dword [device.bytes_rx + 4], 0
|
adc dword [device.bytes_rx + 4], 0
|
||||||
inc dword [device.packets_rx]
|
inc [device.packets_rx]
|
||||||
|
|
||||||
DEBUGF 1, "Received %u bytes\n", ecx
|
DEBUGF 1, "Received %u bytes\n", ecx
|
||||||
|
|
||||||
push ebx eax ecx
|
push ebx eax ecx
|
||||||
stdcall KernelAlloc, ecx ; Allocate a buffer to put packet into
|
stdcall KernelAlloc, ecx ; Allocate a buffer to put packet into
|
||||||
pop ecx
|
pop ecx
|
||||||
test eax, eax ; Test if we allocated succesfully
|
test eax, eax ; Test if we allocated succesfully
|
||||||
jz .abort
|
jz .abort
|
||||||
|
|
||||||
mov edi, eax ; Where we will copy too
|
mov edi, eax ; Where we will copy too
|
||||||
|
|
||||||
mov esi, [esp] ; The buffer we will copy from
|
mov esi, [esp] ; The buffer we will copy from
|
||||||
add esi, 4 ; Dont copy CRC
|
add esi, 4 ; Dont copy CRC
|
||||||
|
|
||||||
push dword .abort ; Kernel will return to this address after EthReceiver
|
push dword .abort ; Kernel will return to this address after EthReceiver
|
||||||
push ecx edi ; Save buffer pointer and size, to pass to kernel
|
push ecx edi ; Save buffer pointer and size, to pass to kernel
|
||||||
|
|
||||||
.copy:
|
.copy:
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
@ -835,15 +803,15 @@ int_handler:
|
|||||||
rep movsd
|
rep movsd
|
||||||
.nd:
|
.nd:
|
||||||
|
|
||||||
jmp Eth_input ; Send it to kernel
|
jmp Eth_input ; Send it to kernel
|
||||||
|
|
||||||
.abort:
|
.abort:
|
||||||
pop eax ebx
|
pop eax ebx
|
||||||
; update eth_data_start_offset
|
; update eth_data_start_offset
|
||||||
movzx eax, word [eax+2] ; packet length
|
movzx eax, word [eax+2] ; packet length
|
||||||
add eax, [device.rx_data_offset]
|
add eax, [device.rx_data_offset]
|
||||||
add eax, 4+3 ; packet header is 4 bytes long + dword alignment
|
add eax, 4+3 ; packet header is 4 bytes long + dword alignment
|
||||||
and eax, not 3 ; dword alignment
|
and eax, not 3 ; dword alignment
|
||||||
|
|
||||||
cmp eax, RX_BUFFER_SIZE
|
cmp eax, RX_BUFFER_SIZE
|
||||||
jb .no_wrap
|
jb .no_wrap
|
||||||
@ -854,11 +822,11 @@ int_handler:
|
|||||||
DEBUGF 1, "New RX ptr: %d\n", eax
|
DEBUGF 1, "New RX ptr: %d\n", eax
|
||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_CAPR ; update 'Current Address of Packet Read register'
|
set_io REG_CAPR ; update 'Current Address of Packet Read register'
|
||||||
sub eax, 0x10 ; value 0x10 is a constant for CAPR
|
sub eax, 0x10 ; value 0x10 is a constant for CAPR
|
||||||
out dx , ax
|
out dx , ax
|
||||||
|
|
||||||
jmp .receive ; check for multiple packets
|
jmp .receive ; check for multiple packets
|
||||||
|
|
||||||
.reset_rx:
|
.reset_rx:
|
||||||
test byte [eax], (1 shl BIT_CRC)
|
test byte [eax], (1 shl BIT_CRC)
|
||||||
@ -872,16 +840,14 @@ int_handler:
|
|||||||
|
|
||||||
.no_fae_error:
|
.no_fae_error:
|
||||||
DEBUGF 1, "Reset RX\n"
|
DEBUGF 1, "Reset RX\n"
|
||||||
in al, dx ; read command register
|
in al, dx ; read command register
|
||||||
push ax
|
push ax
|
||||||
|
and al, not (1 shl BIT_RE) ; Clear the RE bit
|
||||||
and al, not (1 shl BIT_RE) ; Clear the RE bit
|
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
pop ax
|
pop ax
|
||||||
out dx, al ; write original command back
|
out dx, al ; write original command back
|
||||||
|
|
||||||
add edx, REG_RXCONFIG - REG_COMMAND ; Restore RX configuration
|
add edx, REG_RXCONFIG - REG_COMMAND ; Restore RX configuration
|
||||||
mov ax, RX_CONFIG
|
mov ax, RX_CONFIG
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
@ -985,7 +951,6 @@ int_handler:
|
|||||||
test ax, ISR_LENCHG
|
test ax, ISR_LENCHG
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
DEBUGF 2, "Cable changed!\n"
|
|
||||||
call cable
|
call cable
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
@ -1003,24 +968,35 @@ int_handler:
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
cable:
|
cable:
|
||||||
DEBUGF 1, "Checking Cable status: "
|
DEBUGF 1, "Updating Cable status\n"
|
||||||
|
|
||||||
mov edx, dword [device.io_addr]
|
set_io 0
|
||||||
add edx, REG_MSR
|
set_io REG_MSR
|
||||||
in al , dx
|
in al, dx
|
||||||
|
|
||||||
; test al , 1 SHL 2 ; 0 = link ok 1 = link fail
|
test al, 1 shl 2 ; 0 = link ok 1 = link fail
|
||||||
; jnz .notconnected
|
jnz .notconnected
|
||||||
|
|
||||||
; test al , 1 SHL 3 ; 0 = 100 Mbps 1 = 10 Mbps
|
test al, 1 shl 3 ; 0 = 100 Mbps 1 = 10 Mbps
|
||||||
; jnz .10mbps
|
jnz .10mbps
|
||||||
|
|
||||||
shr al, 2
|
.100mbps:
|
||||||
and al, 3
|
mov [device.state], ETH_LINK_100M
|
||||||
|
call NetLinkChanged
|
||||||
|
|
||||||
mov byte [device.mode+3], al
|
ret
|
||||||
DEBUGF 1, "Done!\n"
|
|
||||||
ret
|
.10mbps:
|
||||||
|
mov [device.state], ETH_LINK_10M
|
||||||
|
call NetLinkChanged
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
.notconnected:
|
||||||
|
mov [device.state], ETH_LINK_DOWN
|
||||||
|
call NetLinkChanged
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1036,7 +1012,6 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
|
|||||||
DEBUGF 2, "Writing MAC: "
|
DEBUGF 2, "Writing MAC: "
|
||||||
|
|
||||||
; disable all in command registers
|
; disable all in command registers
|
||||||
|
|
||||||
set_io 0
|
set_io 0
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -1051,13 +1026,11 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
|
|||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; enable writing
|
; enable writing
|
||||||
|
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
mov eax, REG_9346CR_WE
|
mov eax, REG_9346CR_WE
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; write the mac ...
|
; write the mac ...
|
||||||
|
|
||||||
set_io REG_IDR0
|
set_io REG_IDR0
|
||||||
pop eax
|
pop eax
|
||||||
out dx, eax
|
out dx, eax
|
||||||
@ -1068,7 +1041,6 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
|
|||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; disable writing
|
; disable writing
|
||||||
|
|
||||||
set_io REG_9346CR
|
set_io REG_9346CR
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
out dx, al
|
out dx, al
|
||||||
|
@ -462,8 +462,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -725,6 +723,9 @@ reset:
|
|||||||
|
|
||||||
mov [device.mtu], 1500
|
mov [device.mtu], 1500
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -161,8 +161,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], .fail
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -294,6 +292,11 @@ reset:
|
|||||||
|
|
||||||
call read_mac
|
call read_mac
|
||||||
|
|
||||||
|
; Set the mtu, kernel will be able to send now
|
||||||
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -409,8 +409,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -695,6 +693,9 @@ reset:
|
|||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
DEBUGF 1,"Reset done\n"
|
DEBUGF 1,"Reset done\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
@ -535,8 +535,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], .fail
|
|
||||||
mov [device.unload], .fail
|
mov [device.unload], .fail
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -986,6 +984,9 @@ reset:
|
|||||||
xor eax, eax ; Indicate that we have successfully reset the card
|
xor eax, eax ; Indicate that we have successfully reset the card
|
||||||
mov [device.mtu], 1514 ;;; FIXME
|
mov [device.mtu], 1514 ;;; FIXME
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -374,8 +374,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], .fail
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -585,6 +583,9 @@ start_i8254x:
|
|||||||
|
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -273,8 +273,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], MAC_write
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -561,8 +559,11 @@ reset:
|
|||||||
DEBUGF 1,"Resetting %s complete\n", my_service
|
DEBUGF 1,"Resetting %s complete\n", my_service
|
||||||
|
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
xor eax, eax ; indicate that we have successfully reset the card
|
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
|
xor eax, eax ; indicate that we have successfully reset the card
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -669,6 +670,8 @@ transmit:
|
|||||||
add dword [device.bytes_tx], eax
|
add dword [device.bytes_tx], eax
|
||||||
adc dword [device.bytes_tx + 4], 0
|
adc dword [device.bytes_tx + 4], 0
|
||||||
|
|
||||||
|
DEBUGF 1,"Transmit OK\n"
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret 8
|
ret 8
|
||||||
|
|
||||||
@ -781,13 +784,49 @@ int_handler:
|
|||||||
.no_rx:
|
.no_rx:
|
||||||
|
|
||||||
; Cleanup after TX
|
; Cleanup after TX
|
||||||
|
cmp [txfd.status], 0
|
||||||
|
je .done
|
||||||
cmp [last_tx_buffer], 0
|
cmp [last_tx_buffer], 0
|
||||||
je .done
|
je .done
|
||||||
|
push ax
|
||||||
|
DEBUGF 1, "Removing packet 0x%x from RAM!\n", [last_tx_buffer]
|
||||||
stdcall KernelFree, [last_tx_buffer]
|
stdcall KernelFree, [last_tx_buffer]
|
||||||
mov [last_tx_buffer], 0
|
mov [last_tx_buffer], 0
|
||||||
|
pop ax
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
|
and ax, 00111100b
|
||||||
|
cmp ax, 00001000b
|
||||||
|
jne .fail
|
||||||
|
|
||||||
|
DEBUGF 1, "out of resources!\n"
|
||||||
|
; Restart the RX
|
||||||
|
|
||||||
|
; allocate new descriptor
|
||||||
|
|
||||||
|
stdcall KernelAlloc, 2000
|
||||||
|
mov [device.rx_desc], eax
|
||||||
|
mov esi, eax
|
||||||
|
GetRealAddr
|
||||||
|
mov [esi + rxfd.status], 0x0000
|
||||||
|
mov [esi + rxfd.command], 0xc000 ; End of list + Suspend
|
||||||
|
mov [esi + rxfd.link], eax
|
||||||
|
mov [esi + rxfd.count], 0
|
||||||
|
mov [esi + rxfd.size], 1528
|
||||||
|
|
||||||
|
; restart RX
|
||||||
|
|
||||||
|
set_io 0
|
||||||
|
set_io reg_scb_ptr
|
||||||
|
; lea eax, [device.rx_desc]
|
||||||
|
; GetRealAddr
|
||||||
|
out dx, eax
|
||||||
|
|
||||||
|
set_io reg_scb_cmd
|
||||||
|
mov ax, RX_START
|
||||||
|
out dx, ax
|
||||||
|
call cmd_wait
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
@ -97,5 +97,6 @@ kernel_export \
|
|||||||
NetRegDev,\
|
NetRegDev,\
|
||||||
NetUnRegDev,\
|
NetUnRegDev,\
|
||||||
NetPtrToNum,\
|
NetPtrToNum,\
|
||||||
|
NetLinkChanged,\
|
||||||
Eth_input,\
|
Eth_input,\
|
||||||
IPv4_input
|
IPv4_input
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
format MS COFF
|
format MS COFF
|
||||||
|
|
||||||
API_VERSION = 0x01000100
|
API_VERSION = 0x01000100
|
||||||
DRIVER_VERSION = 5
|
DRIVER_VERSION = 5
|
||||||
|
|
||||||
MAX_DEVICES = 16
|
MAX_DEVICES = 16
|
||||||
|
|
||||||
DEBUG = 1
|
DEBUG = 1
|
||||||
__DEBUG__ = 1
|
__DEBUG__ = 1
|
||||||
__DEBUG_LEVEL__ = 1
|
__DEBUG_LEVEL__ = 1
|
||||||
|
|
||||||
NUM_TX_DESC = 4
|
NUM_TX_DESC = 4
|
||||||
NUM_RX_DESC = 4
|
NUM_RX_DESC = 4
|
||||||
|
|
||||||
include 'proc32.inc'
|
include 'proc32.inc'
|
||||||
include 'imports.inc'
|
include 'imports.inc'
|
||||||
@ -40,210 +40,210 @@ public version
|
|||||||
|
|
||||||
; for different PHY
|
; for different PHY
|
||||||
|
|
||||||
MysonPHY = 1
|
MysonPHY = 1
|
||||||
AhdocPHY = 2
|
AhdocPHY = 2
|
||||||
SeeqPHY = 3
|
SeeqPHY = 3
|
||||||
MarvellPHY = 4
|
MarvellPHY = 4
|
||||||
Myson981 = 5
|
Myson981 = 5
|
||||||
LevelOnePHY = 6
|
LevelOnePHY = 6
|
||||||
OtherPHY = 10
|
OtherPHY = 10
|
||||||
|
|
||||||
; Offsets to the Command and Status Registers.
|
; Offsets to the Command and Status Registers.
|
||||||
|
|
||||||
PAR0 = 0x0 ; physical address 0-3
|
PAR0 = 0x0 ; physical address 0-3
|
||||||
PAR1 = 0x04 ; physical address 4-5
|
PAR1 = 0x04 ; physical address 4-5
|
||||||
MAR0 = 0x08 ; multicast address 0-3
|
MAR0 = 0x08 ; multicast address 0-3
|
||||||
MAR1 = 0x0C ; multicast address 4-7
|
MAR1 = 0x0C ; multicast address 4-7
|
||||||
FAR0 = 0x10 ; flow-control address 0-3
|
FAR0 = 0x10 ; flow-control address 0-3
|
||||||
FAR1 = 0x14 ; flow-control address 4-5
|
FAR1 = 0x14 ; flow-control address 4-5
|
||||||
TCRRCR = 0x18 ; receive & transmit configuration
|
TCRRCR = 0x18 ; receive & transmit configuration
|
||||||
BCR = 0x1C ; bus command
|
BCR = 0x1C ; bus command
|
||||||
TXPDR = 0x20 ; transmit polling demand
|
TXPDR = 0x20 ; transmit polling demand
|
||||||
RXPDR = 0x24 ; receive polling demand
|
RXPDR = 0x24 ; receive polling demand
|
||||||
RXCWP = 0x28 ; receive current word pointer
|
RXCWP = 0x28 ; receive current word pointer
|
||||||
TXLBA = 0x2C ; transmit list base address
|
TXLBA = 0x2C ; transmit list base address
|
||||||
RXLBA = 0x30 ; receive list base address
|
RXLBA = 0x30 ; receive list base address
|
||||||
ISR = 0x34 ; interrupt status
|
ISR = 0x34 ; interrupt status
|
||||||
IMR = 0x38 ; interrupt mask
|
IMR = 0x38 ; interrupt mask
|
||||||
FTH = 0x3C ; flow control high/low threshold
|
FTH = 0x3C ; flow control high/low threshold
|
||||||
MANAGEMENT = 0x40 ; bootrom/eeprom and mii management
|
MANAGEMENT = 0x40 ; bootrom/eeprom and mii management
|
||||||
TALLY = 0x44 ; tally counters for crc and mpa
|
TALLY = 0x44 ; tally counters for crc and mpa
|
||||||
TSR = 0x48 ; tally counter for transmit status
|
TSR = 0x48 ; tally counter for transmit status
|
||||||
BMCRSR = 0x4c ; basic mode control and status
|
BMCRSR = 0x4c ; basic mode control and status
|
||||||
PHYIDENTIFIER = 0x50 ; phy identifier
|
PHYIDENTIFIER = 0x50 ; phy identifier
|
||||||
ANARANLPAR = 0x54 ; auto-negotiation advertisement and link partner ability
|
ANARANLPAR = 0x54 ; auto-negotiation advertisement and link partner ability
|
||||||
ANEROCR = 0x58 ; auto-negotiation expansion and pci conf.
|
ANEROCR = 0x58 ; auto-negotiation expansion and pci conf.
|
||||||
BPREMRPSR = 0x5c ; bypass & receive error mask and phy status
|
BPREMRPSR = 0x5c ; bypass & receive error mask and phy status
|
||||||
|
|
||||||
; Bits in the interrupt status/enable registers.
|
; Bits in the interrupt status/enable registers.
|
||||||
|
|
||||||
RFCON = 0x00020000 ; receive flow control xon packet
|
RFCON = 0x00020000 ; receive flow control xon packet
|
||||||
RFCOFF = 0x00010000 ; receive flow control xoff packet
|
RFCOFF = 0x00010000 ; receive flow control xoff packet
|
||||||
LSCStatus = 0x00008000 ; link status change
|
LSCStatus = 0x00008000 ; link status change
|
||||||
ANCStatus = 0x00004000 ; autonegotiation completed
|
ANCStatus = 0x00004000 ; autonegotiation completed
|
||||||
FBE = 0x00002000 ; fatal bus error
|
FBE = 0x00002000 ; fatal bus error
|
||||||
FBEMask = 0x00001800 ; mask bit12-11
|
FBEMask = 0x00001800 ; mask bit12-11
|
||||||
ParityErr = 0x00000000 ; parity error
|
ParityErr = 0x00000000 ; parity error
|
||||||
TargetErr = 0x00001000 ; target abort
|
TargetErr = 0x00001000 ; target abort
|
||||||
MasterErr = 0x00000800 ; master error
|
MasterErr = 0x00000800 ; master error
|
||||||
TUNF = 0x00000400 ; transmit underflow
|
TUNF = 0x00000400 ; transmit underflow
|
||||||
ROVF = 0x00000200 ; receive overflow
|
ROVF = 0x00000200 ; receive overflow
|
||||||
ETI = 0x00000100 ; transmit early int
|
ETI = 0x00000100 ; transmit early int
|
||||||
ERI = 0x00000080 ; receive early int
|
ERI = 0x00000080 ; receive early int
|
||||||
CNTOVF = 0x00000040 ; counter overflow
|
CNTOVF = 0x00000040 ; counter overflow
|
||||||
RBU = 0x00000020 ; receive buffer unavailable
|
RBU = 0x00000020 ; receive buffer unavailable
|
||||||
TBU = 0x00000010 ; transmit buffer unavilable
|
TBU = 0x00000010 ; transmit buffer unavilable
|
||||||
TI = 0x00000008 ; transmit interrupt
|
TI = 0x00000008 ; transmit interrupt
|
||||||
RI = 0x00000004 ; receive interrupt
|
RI = 0x00000004 ; receive interrupt
|
||||||
RxErr = 0x00000002 ; receive error
|
RxErr = 0x00000002 ; receive error
|
||||||
|
|
||||||
; Bits in the NetworkConfig register.
|
; Bits in the NetworkConfig register.
|
||||||
|
|
||||||
RxModeMask = 0xe0
|
RxModeMask = 0xe0
|
||||||
AcceptAllPhys = 0x80 ; promiscuous mode
|
AcceptAllPhys = 0x80 ; promiscuous mode
|
||||||
AcceptBroadcast = 0x40 ; accept broadcast
|
AcceptBroadcast = 0x40 ; accept broadcast
|
||||||
AcceptMulticast = 0x20 ; accept mutlicast
|
AcceptMulticast = 0x20 ; accept mutlicast
|
||||||
AcceptRunt = 0x08 ; receive runt pkt
|
AcceptRunt = 0x08 ; receive runt pkt
|
||||||
ALP = 0x04 ; receive long pkt
|
ALP = 0x04 ; receive long pkt
|
||||||
AcceptErr = 0x02 ; receive error pkt
|
AcceptErr = 0x02 ; receive error pkt
|
||||||
|
|
||||||
AcceptMyPhys = 0x00000000
|
AcceptMyPhys = 0x00000000
|
||||||
RxEnable = 0x00000001
|
RxEnable = 0x00000001
|
||||||
RxFlowCtrl = 0x00002000
|
RxFlowCtrl = 0x00002000
|
||||||
TxEnable = 0x00040000
|
TxEnable = 0x00040000
|
||||||
TxModeFDX = 0x00100000
|
TxModeFDX = 0x00100000
|
||||||
TxThreshold = 0x00e00000
|
TxThreshold = 0x00e00000
|
||||||
|
|
||||||
PS1000 = 0x00010000
|
PS1000 = 0x00010000
|
||||||
PS10 = 0x00080000
|
PS10 = 0x00080000
|
||||||
FD = 0x00100000
|
FD = 0x00100000
|
||||||
|
|
||||||
|
|
||||||
; Bits in network_desc.status
|
; Bits in network_desc.status
|
||||||
|
|
||||||
RXOWN = 0x80000000 ; own bit
|
RXOWN = 0x80000000 ; own bit
|
||||||
FLNGMASK = 0x0fff0000 ; frame length
|
FLNGMASK = 0x0fff0000 ; frame length
|
||||||
FLNGShift = 16
|
FLNGShift = 16
|
||||||
MARSTATUS = 0x00004000 ; multicast address received
|
MARSTATUS = 0x00004000 ; multicast address received
|
||||||
BARSTATUS = 0x00002000 ; broadcast address received
|
BARSTATUS = 0x00002000 ; broadcast address received
|
||||||
PHYSTATUS = 0x00001000 ; physical address received
|
PHYSTATUS = 0x00001000 ; physical address received
|
||||||
RXFSD = 0x00000800 ; first descriptor
|
RXFSD = 0x00000800 ; first descriptor
|
||||||
RXLSD = 0x00000400 ; last descriptor
|
RXLSD = 0x00000400 ; last descriptor
|
||||||
ErrorSummary = 0x80 ; error summary
|
ErrorSummary = 0x80 ; error summary
|
||||||
RUNT = 0x40 ; runt packet received
|
RUNT = 0x40 ; runt packet received
|
||||||
LONG = 0x20 ; long packet received
|
LONG = 0x20 ; long packet received
|
||||||
FAE = 0x10 ; frame align error
|
FAE = 0x10 ; frame align error
|
||||||
CRC = 0x08 ; crc error
|
CRC = 0x08 ; crc error
|
||||||
RXER = 0x04 ; receive error
|
RXER = 0x04 ; receive error
|
||||||
|
|
||||||
; rx_desc_control_bits
|
; rx_desc_control_bits
|
||||||
|
|
||||||
RXIC = 0x00800000 ; interrupt control
|
RXIC = 0x00800000 ; interrupt control
|
||||||
RBSShift = 0
|
RBSShift = 0
|
||||||
|
|
||||||
; tx_desc_status_bits
|
; tx_desc_status_bits
|
||||||
|
|
||||||
TXOWN = 0x80000000 ; own bit
|
TXOWN = 0x80000000 ; own bit
|
||||||
JABTO = 0x00004000 ; jabber timeout
|
JABTO = 0x00004000 ; jabber timeout
|
||||||
CSL = 0x00002000 ; carrier sense lost
|
CSL = 0x00002000 ; carrier sense lost
|
||||||
LC = 0x00001000 ; late collision
|
LC = 0x00001000 ; late collision
|
||||||
EC = 0x00000800 ; excessive collision
|
EC = 0x00000800 ; excessive collision
|
||||||
UDF = 0x00000400 ; fifo underflow
|
UDF = 0x00000400 ; fifo underflow
|
||||||
DFR = 0x00000200 ; deferred
|
DFR = 0x00000200 ; deferred
|
||||||
HF = 0x00000100 ; heartbeat fail
|
HF = 0x00000100 ; heartbeat fail
|
||||||
NCRMask = 0x000000ff ; collision retry count
|
NCRMask = 0x000000ff ; collision retry count
|
||||||
NCRShift = 0
|
NCRShift = 0
|
||||||
|
|
||||||
; tx_desc_control_bits
|
; tx_desc_control_bits
|
||||||
|
|
||||||
TXIC = 0x80000000 ; interrupt control
|
TXIC = 0x80000000 ; interrupt control
|
||||||
ETIControl = 0x40000000 ; early transmit interrupt
|
ETIControl = 0x40000000 ; early transmit interrupt
|
||||||
TXLD = 0x20000000 ; last descriptor
|
TXLD = 0x20000000 ; last descriptor
|
||||||
TXFD = 0x10000000 ; first descriptor
|
TXFD = 0x10000000 ; first descriptor
|
||||||
CRCEnable = 0x08000000 ; crc control
|
CRCEnable = 0x08000000 ; crc control
|
||||||
PADEnable = 0x04000000 ; padding control
|
PADEnable = 0x04000000 ; padding control
|
||||||
RetryTxLC = 0x02000000 ; retry late collision
|
RetryTxLC = 0x02000000 ; retry late collision
|
||||||
PKTSMask = 0x3ff800 ; packet size bit21-11
|
PKTSMask = 0x3ff800 ; packet size bit21-11
|
||||||
PKTSShift = 11
|
PKTSShift = 11
|
||||||
TBSMask = 0x000007ff ; transmit buffer bit 10-0
|
TBSMask = 0x000007ff ; transmit buffer bit 10-0
|
||||||
TBSShift = 0
|
TBSShift = 0
|
||||||
|
|
||||||
; BootROM/EEPROM/MII Management Register
|
; BootROM/EEPROM/MII Management Register
|
||||||
|
|
||||||
MASK_MIIR_MII_READ = 0x00000000
|
MASK_MIIR_MII_READ = 0x00000000
|
||||||
MASK_MIIR_MII_WRITE = 0x00000008
|
MASK_MIIR_MII_WRITE = 0x00000008
|
||||||
MASK_MIIR_MII_MDO = 0x00000004
|
MASK_MIIR_MII_MDO = 0x00000004
|
||||||
MASK_MIIR_MII_MDI = 0x00000002
|
MASK_MIIR_MII_MDI = 0x00000002
|
||||||
MASK_MIIR_MII_MDC = 0x00000001
|
MASK_MIIR_MII_MDC = 0x00000001
|
||||||
|
|
||||||
; ST+OP+PHYAD+REGAD+TA
|
; ST+OP+PHYAD+REGAD+TA
|
||||||
|
|
||||||
OP_READ = 0x6000 ; ST:01+OP:10+PHYAD+REGAD+TA:Z0
|
OP_READ = 0x6000 ; ST:01+OP:10+PHYAD+REGAD+TA:Z0
|
||||||
OP_WRITE = 0x5002 ; ST:01+OP:01+PHYAD+REGAD+TA:10
|
OP_WRITE = 0x5002 ; ST:01+OP:01+PHYAD+REGAD+TA:10
|
||||||
|
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
; Constants for Myson PHY
|
; Constants for Myson PHY
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
|
|
||||||
MysonPHYID = 0xd0000302
|
MysonPHYID = 0xd0000302
|
||||||
MysonPHYID0 = 0x0302
|
MysonPHYID0 = 0x0302
|
||||||
StatusRegister = 18
|
StatusRegister = 18
|
||||||
SPEED100 = 0x0400 ; bit10
|
SPEED100 = 0x0400 ; bit10
|
||||||
FULLMODE = 0x0800 ; bit11
|
FULLMODE = 0x0800 ; bit11
|
||||||
|
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
; Constants for Seeq 80225 PHY
|
; Constants for Seeq 80225 PHY
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
|
|
||||||
SeeqPHYID0 = 0x0016
|
SeeqPHYID0 = 0x0016
|
||||||
MIIRegister18 = 18
|
MIIRegister18 = 18
|
||||||
SPD_DET_100 = 0x80
|
SPD_DET_100 = 0x80
|
||||||
DPLX_DET_FULL = 0x40
|
DPLX_DET_FULL = 0x40
|
||||||
|
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
; Constants for Ahdoc 101 PHY
|
; Constants for Ahdoc 101 PHY
|
||||||
; -------------------------------------------------------------------------
|
; -------------------------------------------------------------------------
|
||||||
|
|
||||||
AhdocPHYID0 = 0x0022
|
AhdocPHYID0 = 0x0022
|
||||||
DiagnosticReg = 18
|
DiagnosticReg = 18
|
||||||
DPLX_FULL = 0x0800
|
DPLX_FULL = 0x0800
|
||||||
Speed_100 = 0x0400
|
Speed_100 = 0x0400
|
||||||
|
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
; Constants
|
; Constants
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
|
|
||||||
MarvellPHYID0 = 0x0141
|
MarvellPHYID0 = 0x0141
|
||||||
LevelOnePHYID0 = 0x0013
|
LevelOnePHYID0 = 0x0013
|
||||||
|
|
||||||
MII1000BaseTControlReg = 9
|
MII1000BaseTControlReg = 9
|
||||||
MII1000BaseTStatusReg = 10
|
MII1000BaseTStatusReg = 10
|
||||||
SpecificReg = 17
|
SpecificReg = 17
|
||||||
|
|
||||||
; for 1000BaseT Control Register
|
; for 1000BaseT Control Register
|
||||||
|
|
||||||
PHYAbletoPerform1000FullDuplex = 0x0200
|
PHYAbletoPerform1000FullDuplex = 0x0200
|
||||||
PHYAbletoPerform1000HalfDuplex = 0x0100
|
PHYAbletoPerform1000HalfDuplex = 0x0100
|
||||||
PHY1000AbilityMask = 0x300
|
PHY1000AbilityMask = 0x300
|
||||||
|
|
||||||
; for phy specific status register, marvell phy.
|
; for phy specific status register, marvell phy.
|
||||||
|
|
||||||
SpeedMask = 0x0c000
|
SpeedMask = 0x0c000
|
||||||
Speed_1000M = 0x08000
|
Speed_1000M = 0x08000
|
||||||
Speed_100M = 0x4000
|
Speed_100M = 0x4000
|
||||||
Speed_10M = 0
|
Speed_10M = 0
|
||||||
Full_Duplex = 0x2000
|
Full_Duplex = 0x2000
|
||||||
|
|
||||||
; for phy specific status register, levelone phy
|
; for phy specific status register, levelone phy
|
||||||
|
|
||||||
LXT1000_100M = 0x08000
|
LXT1000_100M = 0x08000
|
||||||
LXT1000_1000M = 0x0c000
|
LXT1000_1000M = 0x0c000
|
||||||
LXT1000_Full = 0x200
|
LXT1000_Full = 0x200
|
||||||
|
|
||||||
; for PHY
|
; for PHY
|
||||||
|
|
||||||
LinkIsUp = 0x0004
|
LinkIsUp = 0x0004
|
||||||
LinkIsUp2 = 0x00040000
|
LinkIsUp2 = 0x00040000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -406,8 +406,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -714,8 +712,11 @@ reset:
|
|||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
xor eax, eax
|
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,15 @@ include 'bus/pci.inc'
|
|||||||
NET_TYPE_ETH = 1
|
NET_TYPE_ETH = 1
|
||||||
NET_TYPE_SLIP = 2
|
NET_TYPE_SLIP = 2
|
||||||
|
|
||||||
|
; link state
|
||||||
|
|
||||||
|
ETH_LINK_DOWN = 0 ; Link is down
|
||||||
|
ETH_LINK_UNKOWN = 1b ; There could be an active link
|
||||||
|
ETH_LINK_FD = 10b ; full duplex flag
|
||||||
|
ETH_LINK_10M = 100b ; 10 mbit
|
||||||
|
ETH_LINK_100M = 1000b ; 100 mbit
|
||||||
|
ETH_LINK_1G = 10000b ; gigabit
|
||||||
|
|
||||||
|
|
||||||
LAST_IO = 0
|
LAST_IO = 0
|
||||||
macro set_io addr {
|
macro set_io addr {
|
||||||
@ -117,6 +126,9 @@ macro NET_DEVICE {
|
|||||||
.packets_tx dd ? ;
|
.packets_tx dd ? ;
|
||||||
.packets_rx dd ? ;
|
.packets_rx dd ? ;
|
||||||
|
|
||||||
|
.state dd ? ; link state (0 = no link)
|
||||||
|
.hwacc dd ? ; bitmask stating enabled HW accelerations
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,15 +136,8 @@ macro NET_DEVICE {
|
|||||||
macro ETH_DEVICE {
|
macro ETH_DEVICE {
|
||||||
NET_DEVICE
|
NET_DEVICE
|
||||||
|
|
||||||
.set_mode dd ?
|
|
||||||
.get_mode dd ?
|
|
||||||
|
|
||||||
.set_MAC dd ?
|
|
||||||
.get_MAC dd ?
|
|
||||||
|
|
||||||
.mode dd ?
|
|
||||||
.mac dp ?
|
.mac dp ?
|
||||||
dp ? ; qword alignment
|
dw ? ; qword alignment
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,9 +146,4 @@ macro ETH_DEVICE {
|
|||||||
macro SLIP_DEVICE {
|
macro SLIP_DEVICE {
|
||||||
NET_DEVICE
|
NET_DEVICE
|
||||||
|
|
||||||
.set_mode dd ?
|
|
||||||
.get_mode dd ?
|
|
||||||
|
|
||||||
.mode dd ?
|
|
||||||
|
|
||||||
}
|
}
|
@ -446,8 +446,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -874,6 +872,9 @@ reset:
|
|||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; get link status
|
||||||
|
call cable
|
||||||
|
|
||||||
DEBUGF 1,"reset complete\n"
|
DEBUGF 1,"reset complete\n"
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
@ -634,8 +634,6 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov [device.reset], reset
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.get_MAC], read_mac
|
|
||||||
mov [device.set_MAC], .fail
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -1006,9 +1004,11 @@ reset:
|
|||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
; say reset was successfull
|
; say reset was successfull
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,10 +328,8 @@ service_proc:
|
|||||||
movzx ecx, byte[eax+2]
|
movzx ecx, byte[eax+2]
|
||||||
mov [device.pci_dev], ecx
|
mov [device.pci_dev], ecx
|
||||||
; 4j. Fill in the direct call addresses into the struct.
|
; 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
|
mov [device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [device.transmit], transmit
|
||||||
mov [device.set_MAC], write_mac
|
|
||||||
mov [device.unload], unload
|
mov [device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [device.name], my_service
|
||||||
|
|
||||||
@ -439,10 +437,8 @@ probe:
|
|||||||
jmp .tableloop
|
jmp .tableloop
|
||||||
|
|
||||||
.ok:
|
.ok:
|
||||||
mov eax, [esi + 4] ; Get pointer to "get MAC" function
|
|
||||||
mov [device.get_MAC], eax
|
|
||||||
|
|
||||||
call [device.get_MAC]
|
call dword[esi + 4] ; "get MAC" function
|
||||||
|
|
||||||
; Set table entries
|
; Set table entries
|
||||||
mov [device.table_entries], 16
|
mov [device.table_entries], 16
|
||||||
@ -662,8 +658,11 @@ reset:
|
|||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
mov [device.mtu], 1514
|
mov [device.mtu], 1514
|
||||||
xor eax, eax
|
|
||||||
|
|
||||||
|
; Set link state to unknown
|
||||||
|
mov [device.state], ETH_LINK_UNKOWN
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
|
@ -28,13 +28,6 @@ ends
|
|||||||
|
|
||||||
struct ETH_DEVICE NET_DEVICE
|
struct ETH_DEVICE NET_DEVICE
|
||||||
|
|
||||||
set_mode dd ?
|
|
||||||
get_mode dd ?
|
|
||||||
|
|
||||||
set_MAC dd ?
|
|
||||||
get_MAC dd ?
|
|
||||||
|
|
||||||
mode dd ?
|
|
||||||
mac dp ?
|
mac dp ?
|
||||||
|
|
||||||
ends
|
ends
|
||||||
@ -199,7 +192,7 @@ ETH_api:
|
|||||||
dd .bytes_tx ; 2
|
dd .bytes_tx ; 2
|
||||||
dd .bytes_rx ; 3
|
dd .bytes_rx ; 3
|
||||||
dd .read_mac ; 4
|
dd .read_mac ; 4
|
||||||
dd .write_mac ; 5
|
dd .state ; 5
|
||||||
.number = ($ - .table) / 4 - 1
|
.number = ($ - .table) / 4 - 1
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
@ -234,9 +227,7 @@ ETH_api:
|
|||||||
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.write_mac:
|
.state:
|
||||||
push ecx
|
mov eax, [eax + NET_DEVICE.state]
|
||||||
push dx
|
|
||||||
call [eax + ETH_DEVICE.set_MAC]
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -148,7 +148,8 @@ struct NET_DEVICE
|
|||||||
packets_tx dd ? ;
|
packets_tx dd ? ;
|
||||||
packets_rx dd ? ;
|
packets_rx dd ? ;
|
||||||
|
|
||||||
; hwacc dd ? ; bitmask stating available hardware accelerations (offload engines)
|
state dd ? ; link state (0 = no link)
|
||||||
|
hwacc dd ? ; bitmask stating enabled HW accelerations (offload engines)
|
||||||
|
|
||||||
ends
|
ends
|
||||||
|
|
||||||
@ -290,9 +291,13 @@ stack_handler:
|
|||||||
align 4
|
align 4
|
||||||
NET_link_changed:
|
NET_link_changed:
|
||||||
|
|
||||||
|
DEBUGF 1,"NET_link_changed: %x\n", ebx
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_send_event:
|
NET_send_event:
|
||||||
|
|
||||||
|
DEBUGF 1,"NET_send_event\n"
|
||||||
|
|
||||||
; Send event to all applications
|
; Send event to all applications
|
||||||
push edi ecx
|
push edi ecx
|
||||||
mov edi, SLOT_BASE
|
mov edi, SLOT_BASE
|
||||||
|
Loading…
Reference in New Issue
Block a user