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:
hidnplayr 2013-03-07 09:35:24 +00:00
parent b2da70be62
commit f685c27c07
19 changed files with 379 additions and 353 deletions

View File

@ -76,6 +76,9 @@ redraw:
add ebx, 18
mov edx, str_MAC
mcall
add ebx, 18
mov edx, str_link
mcall
mov ebx, API_ETH + 4
mov bh, [device]
@ -201,14 +204,21 @@ draw_stats:
inc bl
cmp bl, 3
jbe @r
inc bl
mcall 76
push eax
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 75 + 3*18
mov edx, 135 shl 16 + 75 + 5*18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
sub edx, 18*2
pop ecx
mcall
sub edx, 18
pop ecx
mcall
@ -591,6 +601,7 @@ str_conflicts db 'ARP conflicts:', 0
str_unknown db 'unknown', 0
str_missed db 'Packets missed:',0
str_dumped db 'Packets dumped:',0
str_link db 'Link state:',0
namebuf rb 64

View File

@ -480,8 +480,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], null_op
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], null_op
mov [device.name], my_service
@ -829,7 +827,7 @@ start_device:
; print link type
xor eax, eax
bsr ax, word [device.mode]
bsr ax, word [device.state]
jz @f
sub ax, 4
@@:
@ -1108,7 +1106,7 @@ try_link_detect:
.finish:
test al, al
jz @f
or byte [device.mode+1], 100b
or byte [device.state+1], 100b
@@:
ret
@ -1219,7 +1217,7 @@ try_phy:
and eax, 1111100000b
push eax
mov word[device.mode+2], ax
mov word[device.state+2], ax
; switch to register window 3
set_io 0
@ -1508,7 +1506,7 @@ try_loopback:
mov cl, al
inc cl
shl cl, 3
or byte [device.mode+1], cl
or byte [device.state+1], cl
test al, al ; aui or coax?
jz .complete_loopback
@ -1540,7 +1538,7 @@ try_loopback:
test al, al
jnz @f
and byte [device.mode+1], not 11000b
and byte [device.state+1], not 11000b
@@:
ret
@ -1713,7 +1711,7 @@ set_available_media:
DEBUGF 1,"base TX is available\n"
or eax, (100b shl 20)
if defined FORCE_FD
mov word [device.mode], (1 shl 8)
mov word [device.state], (1 shl 8)
else
mov word [device.mode], (1 shl 7)
end if
@ -1725,7 +1723,7 @@ end if
DEBUGF 1,"base FX is available\n"
or eax, (101b shl 20)
mov word [device.mode], (1 shl 10)
mov word [device.state], (1 shl 10)
jmp .set_media
@@:
@ -1734,7 +1732,7 @@ end if
DEBUGF 1,"mii-device is available\n"
or eax, (0110b shl 20)
mov word [device.mode], (1 shl 13)
mov word [device.state], (1 shl 13)
jmp .set_media
@@:
@ -1744,9 +1742,9 @@ end if
DEBUGF 1,"10base-T is available\n"
.set_default:
if FORCE_FD
mov word [device.mode], (1 shl 6)
mov word [device.state], (1 shl 6)
else
mov word [device.mode], (1 shl 5)
mov word [device.state], (1 shl 5)
end if
jmp .set_media
@@:
@ -1762,7 +1760,7 @@ end if
pop eax
or eax, (11b shl 20)
mov word [device.mode], (1 shl 12)
mov word [device.state], (1 shl 12)
jmp .set_media
@@:
@ -1771,7 +1769,7 @@ end if
DEBUGF 1,"AUI is available\n"
or eax, (1 shl 20)
mov word [device.mode], (1 shl 11)
mov word [device.state], (1 shl 11)
.set_media:
set_io 0

View File

@ -305,8 +305,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], .fail
mov [device.unload], unload
mov [device.name], my_service
@ -620,9 +618,11 @@ reset:
; 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
DEBUGF 1,"Reset ok\n"
xor eax, eax
ret

View File

@ -350,8 +350,6 @@ create_new_struct:
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -653,6 +651,9 @@ reset:
; Set the mtu, kernel will be able to send now
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
xor eax, eax
DEBUGF 2,"Done!\n"

View File

@ -32,7 +32,6 @@ format MS COFF
include 'proc32.inc'
include 'imports.inc'
include 'fdo.inc'
include '../struct.inc'
include 'netdrv.inc'
public START
@ -59,7 +58,7 @@ public version
REG_HLTCLK = 0x5b ; undocumented halt clock register
REG_BMCR = 0x62 ; basic mode control 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_LONG = 3 ; total packet length > 4k
@ -166,16 +165,16 @@ public version
IDX_RTL8139D = 6
IDX_RTL8101 = 7
ISR_SERR = 1 SHL 15
ISR_TIMEOUT = 1 SHL 14
ISR_LENCHG = 1 SHL 13
ISR_FIFOOVW = 1 SHL 6
ISR_PUN = 1 SHL 5
ISR_RXOVW = 1 SHL 4
ISR_TER = 1 SHL 3
ISR_TOK = 1 SHL 2
ISR_RER = 1 SHL 1
ISR_ROK = 1 SHL 0
ISR_SERR = 1 shl 15
ISR_TIMEOUT = 1 shl 14
ISR_LENCHG = 1 shl 13
ISR_FIFOOVW = 1 shl 6
ISR_PUN = 1 shl 5
ISR_RXOVW = 1 shl 4
ISR_TER = 1 shl 3
ISR_TOK = 1 shl 2
ISR_RER = 1 shl 1
ISR_ROK = 1 shl 0
INTERRUPT_MASK = ISR_ROK or \
ISR_RXOVW or \
@ -185,14 +184,14 @@ public version
ISR_TOK or \
ISR_TER
TSR_OWN = 1 SHL 13
TSR_TUN = 1 SHL 14
TSR_TOK = 1 SHL 15
TSR_OWN = 1 shl 13
TSR_TUN = 1 shl 14
TSR_TOK = 1 shl 15
TSR_CDH = 1 SHL 28
TSR_OWC = 1 SHL 29
TSR_TABT = 1 SHL 30
TSR_CRS = 1 SHL 31
TSR_CDH = 1 shl 28
TSR_OWC = 1 shl 29
TSR_TABT = 1 shl 30
TSR_CRS = 1 shl 31
virtual at ebx
@ -202,7 +201,6 @@ virtual at ebx
ETH_DEVICE
.rx_buffer dd ?
.tx_buffer dd ?
.rx_data_offset dd ?
.io_addr dd ?
@ -295,7 +293,7 @@ proc service_proc stdcall, ioctl:dword
test ecx, ecx
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:
mov ebx, [esi]
cmp al, byte[device.pci_bus]
@ -318,8 +316,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -339,7 +335,7 @@ proc service_proc stdcall, ioctl:dword
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
; Allocate the receive buffer
@ -428,7 +424,6 @@ probe:
PCI_make_bus_master
; get chip version
set_io 0
set_io REG_TXCONFIG + 2
in ax, dx
@ -436,6 +431,7 @@ probe:
shr ax, 6
and al, 01111111b
; now find it in our array
mov ecx, HW_VER_ARRAY_SIZE-1
.chip_ver_loop:
cmp al, [hw_ver_array + ecx]
@ -456,30 +452,31 @@ probe:
DEBUGF 2, "Chip version: %s\n", ecx
; wake up the chip
set_io 0
set_io REG_HLTCLK
mov al, 'R' ; run the clock
out dx, al
; unlock config and BMCR registers
set_io REG_9346CR
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
out dx, al
; enable power management
set_io REG_CONFIG1
in al, dx
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).
; it is for Wake-On-LAN functionality of some motherboards.
; this signal is used to inform the motherboard to execute a wake-up process.
; only at newer chips.
.new_chip:
or al, (1 shl BIT_PMEn)
and al, not (1 shl BIT_LWACT)
out dx, al
@ -489,17 +486,8 @@ probe:
and al, not (1 shl BIT_LWPTN)
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
.finish_wake_up:
xor al, al
set_io 0
set_io REG_9346CR
@ -514,12 +502,11 @@ probe:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
reset:
DEBUGF 2, "Resetting\n"
DEBUGF 2, "Reset\n"
; attach int handler
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
test eax, eax
jnz @f
@ -529,123 +516,106 @@ reset:
@@:
; reset chip
DEBUGF 1, "Resetting chip\n"
set_io 0
set_io REG_COMMAND
mov al , 1 shl BIT_RST
out dx , al
mov cx , 1000 ; wait no longer for the reset
mov al, 1 shl BIT_RST
out dx, al
mov cx, 1000 ; wait no longer for the reset
.wait_for_reset:
in al , dx
test al , 1 shl BIT_RST
in al, dx
test al, 1 shl BIT_RST
jz .reset_completed ; RST remains 1 during reset
dec cx
jns .wait_for_reset
DEBUGF 1, "Reset timeout!\n"
.reset_completed:
; unlock config and BMCR registers
set_io REG_9346CR
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
out dx, al
; initialize multicast registers (no filtering)
mov eax, 0xffffffff
set_io REG_MAR0
out dx, eax
set_io REG_MAR4
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
; accept broadcast packets, accept physical match packets
mov ax, RX_CONFIG
set_io REG_RXCONFIG
out dx, ax
; 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
set_io REG_TXCONFIG
out dx, eax
; enable auto negotiation
set_io REG_BMCR
in ax, dx
or ax, (1 shl BIT_ANE)
out dx, ax
; set auto negotiation advertisement
set_io REG_ANAR
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)
out dx, ax
; lock config and BMCR registers
xor eax, eax
set_io REG_9346CR
out dx, al
; init RX/TX pointers
mov [device.rx_data_offset], eax
mov [device.curr_tx_desc], al
; set_io REG_CAPR
; out dx, ax
; clear packet/byte counters
lea edi, [device.bytes_tx]
mov ecx, 6
rep stosd
; clear missing packet counter
set_io REG_MPC
out dx, eax
; set RxBuffer address, init RX buffer offset
mov eax, [device.rx_buffer]
mov dword[eax], 0
DEBUGF 2, "RX buffer: %x\n", eax
mov dword[eax], 0 ; clear receive flags for first packet (really needed??)
DEBUGF 2, "RX buffer virtual addr=0x%x\n", eax
GetRealAddr
DEBUGF 2, "RX buffer: %x\n", eax
DEBUGF 2, "RX buffer real addr=0x%x\n", eax
set_io REG_RBSTART
out dx, eax
; Read MAC address
call read_mac
; enable interrupts
; enable Rx/Tx
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
mov eax, INTERRUPT_MASK
out dx , ax
mov ax, INTERRUPT_MASK
out dx, ax
; Set the mtu, kernel will be able to send now
mov [device.mtu], 1514
call cable
; Indicate that we have successfully reset the card
DEBUGF 2, "Done!\n"
xor eax, eax
ret
@ -750,7 +720,6 @@ int_handler:
DEBUGF 1, "\n%s int\n", my_service
; find pointer of device wich made IRQ occur
mov ecx, [devices]
test ecx, ecx
jz .nothing
@ -760,7 +729,7 @@ int_handler:
set_io 0
set_io REG_ISR
in ax, dx
in ax, dx ; Get interrupt status
out dx, ax ; send it back to ACK
test ax, ax
jnz .got_it
@ -785,9 +754,9 @@ int_handler:
.receive:
set_io 0
set_io REG_COMMAND
in al , dx
test al , BUFE ; test if RX buffer is empty
jnz .finish ;
in al, dx
test al, BUFE ; test if RX buffer is empty
jnz .finish
DEBUGF 1, "RX: "
@ -798,13 +767,12 @@ int_handler:
; packet is ok, copy it
movzx ecx, word [eax+2] ; packet length
sub ecx, 4 ; don't copy CRC
sub cx, 4 ; don't copy CRC
; Update stats
add dword [device.bytes_rx], ecx
adc dword [device.bytes_rx + 4], 0
inc dword [device.packets_rx]
inc [device.packets_rx]
DEBUGF 1, "Received %u bytes\n", ecx
@ -874,10 +842,8 @@ int_handler:
DEBUGF 1, "Reset RX\n"
in al, dx ; read command register
push ax
and al, not (1 shl BIT_RE) ; Clear the RE bit
out dx, al
pop ax
out dx, al ; write original command back
@ -985,7 +951,6 @@ int_handler:
test ax, ISR_LENCHG
jz .fail
DEBUGF 2, "Cable changed!\n"
call cable
.fail:
@ -1003,24 +968,35 @@ int_handler:
align 4
cable:
DEBUGF 1, "Checking Cable status: "
DEBUGF 1, "Updating Cable status\n"
mov edx, dword [device.io_addr]
add edx, REG_MSR
in al , dx
set_io 0
set_io REG_MSR
in al, dx
; test al , 1 SHL 2 ; 0 = link ok 1 = link fail
; jnz .notconnected
test al, 1 shl 2 ; 0 = link ok 1 = link fail
jnz .notconnected
; test al , 1 SHL 3 ; 0 = 100 Mbps 1 = 10 Mbps
; jnz .10mbps
test al, 1 shl 3 ; 0 = 100 Mbps 1 = 10 Mbps
jnz .10mbps
shr al, 2
and al, 3
.100mbps:
mov [device.state], ETH_LINK_100M
call NetLinkChanged
mov byte [device.mode+3], al
DEBUGF 1, "Done!\n"
ret
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: "
; disable all in command registers
set_io 0
set_io REG_9346CR
xor eax, eax
@ -1051,13 +1026,11 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
out dx, ax
; enable writing
set_io REG_9346CR
mov eax, REG_9346CR_WE
out dx, al
; write the mac ...
set_io REG_IDR0
pop eax
out dx, eax
@ -1068,7 +1041,6 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
out dx, eax
; disable writing
set_io REG_9346CR
xor eax, eax
out dx, al

View File

@ -462,8 +462,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -725,6 +723,9 @@ reset:
mov [device.mtu], 1500
; Set link state to unknown
mov [device.state], ETH_LINK_UNKOWN
xor eax, eax
ret

View File

@ -161,8 +161,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], .fail
mov [device.unload], unload
mov [device.name], my_service
@ -294,6 +292,11 @@ reset:
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

View File

@ -409,8 +409,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -695,6 +693,9 @@ reset:
; 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
DEBUGF 1,"Reset done\n"
ret

View File

@ -535,8 +535,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], .fail
mov [device.unload], .fail
mov [device.name], my_service
@ -986,6 +984,9 @@ reset:
xor eax, eax ; Indicate that we have successfully reset the card
mov [device.mtu], 1514 ;;; FIXME
; Set link state to unknown
mov [device.state], ETH_LINK_UNKOWN
ret

View File

@ -374,8 +374,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], .fail
mov [device.unload], unload
mov [device.name], my_service
@ -585,6 +583,9 @@ start_i8254x:
mov [device.mtu], 1514
; Set link state to unknown
mov [device.state], ETH_LINK_UNKOWN
xor eax, eax
ret

View File

@ -273,8 +273,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], MAC_write
mov [device.unload], unload
mov [device.name], my_service
@ -561,8 +559,11 @@ reset:
DEBUGF 1,"Resetting %s complete\n", my_service
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
@ -669,6 +670,8 @@ transmit:
add dword [device.bytes_tx], eax
adc dword [device.bytes_tx + 4], 0
DEBUGF 1,"Transmit OK\n"
xor eax, eax
ret 8
@ -781,13 +784,49 @@ int_handler:
.no_rx:
; Cleanup after TX
cmp [txfd.status], 0
je .done
cmp [last_tx_buffer], 0
je .done
push ax
DEBUGF 1, "Removing packet 0x%x from RAM!\n", [last_tx_buffer]
stdcall KernelFree, [last_tx_buffer]
mov [last_tx_buffer], 0
pop ax
.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:
ret

View File

@ -97,5 +97,6 @@ kernel_export \
NetRegDev,\
NetUnRegDev,\
NetPtrToNum,\
NetLinkChanged,\
Eth_input,\
IPv4_input

View File

@ -406,8 +406,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -714,8 +712,11 @@ reset:
rep stosd
mov [device.mtu], 1514
xor eax, eax
; Set link state to unknown
mov [device.state], ETH_LINK_UNKOWN
xor eax, eax
ret

View File

@ -22,6 +22,15 @@ include 'bus/pci.inc'
NET_TYPE_ETH = 1
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
macro set_io addr {
@ -117,6 +126,9 @@ macro NET_DEVICE {
.packets_tx dd ? ;
.packets_rx dd ? ;
.state dd ? ; link state (0 = no link)
.hwacc dd ? ; bitmask stating enabled HW accelerations
.end:
}
@ -124,15 +136,8 @@ macro NET_DEVICE {
macro ETH_DEVICE {
NET_DEVICE
.set_mode dd ?
.get_mode dd ?
.set_MAC dd ?
.get_MAC dd ?
.mode dd ?
.mac dp ?
dp ? ; qword alignment
dw ? ; qword alignment
}
@ -141,9 +146,4 @@ macro ETH_DEVICE {
macro SLIP_DEVICE {
NET_DEVICE
.set_mode dd ?
.get_mode dd ?
.mode dd ?
}

View File

@ -446,8 +446,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -874,6 +872,9 @@ reset:
; Set the mtu, kernel will be able to send now
mov [device.mtu], 1514
; get link status
call cable
DEBUGF 1,"reset complete\n"
xor eax, eax
ret

View File

@ -634,8 +634,6 @@ proc service_proc stdcall, ioctl:dword
mov [device.reset], reset
mov [device.transmit], transmit
mov [device.get_MAC], read_mac
mov [device.set_MAC], .fail
mov [device.unload], unload
mov [device.name], my_service
@ -1006,9 +1004,11 @@ reset:
; 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
; say reset was successfull
xor eax, eax
ret

View File

@ -328,10 +328,8 @@ service_proc:
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
mov [device.transmit], transmit
mov [device.set_MAC], write_mac
mov [device.unload], unload
mov [device.name], my_service
@ -439,10 +437,8 @@ probe:
jmp .tableloop
.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
mov [device.table_entries], 16
@ -662,8 +658,11 @@ reset:
out dx, eax
mov [device.mtu], 1514
xor eax, eax
; Set link state to unknown
mov [device.state], ETH_LINK_UNKOWN
xor eax, eax
ret
.fail:

View File

@ -28,13 +28,6 @@ ends
struct ETH_DEVICE NET_DEVICE
set_mode dd ?
get_mode dd ?
set_MAC dd ?
get_MAC dd ?
mode dd ?
mac dp ?
ends
@ -199,7 +192,7 @@ ETH_api:
dd .bytes_tx ; 2
dd .bytes_rx ; 3
dd .read_mac ; 4
dd .write_mac ; 5
dd .state ; 5
.number = ($ - .table) / 4 - 1
.error:
@ -234,9 +227,7 @@ ETH_api:
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
.write_mac:
push ecx
push dx
call [eax + ETH_DEVICE.set_MAC]
.state:
mov eax, [eax + NET_DEVICE.state]
ret

View File

@ -148,7 +148,8 @@ struct NET_DEVICE
packets_tx 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
@ -290,9 +291,13 @@ stack_handler:
align 4
NET_link_changed:
DEBUGF 1,"NET_link_changed: %x\n", ebx
align 4
NET_send_event:
DEBUGF 1,"NET_send_event\n"
; Send event to all applications
push edi ecx
mov edi, SLOT_BASE