forked from KolibriOS/kolibrios
Some more bugfixes and cleanup of RTL8029 driver.
Driver works on real hardware, but is not stable yet. git-svn-id: svn://kolibrios.org@1178 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
740caf3d0d
commit
68b0c1de2a
@ -1,16 +1,20 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; ne2000 driver for KolibriOS ;;
|
;; RTL8029/ne2000 driver for KolibriOS ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Written by hidnplayr@kolibrios.org ;;
|
;; Written by hidnplayr@kolibrios.org ;;
|
||||||
|
;; with help from CleverMouse ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; GNU GENERAL PUBLIC LICENSE ;;
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
||||||
;; Version 2, June 1991 ;;
|
;; Version 2, June 1991 ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; current status (september 2009) - INCOMPLETE ;;
|
;; current status (september 2009) - UNSTABLE ;;
|
||||||
|
;; ;;
|
||||||
|
;; based on RTL8029.asm driver for menuetos ;;
|
||||||
|
;; and realtek8029.asm for SolarOS by Eugen Brasoveanu ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -298,7 +302,7 @@ proc service_proc ;stdcall, ioctl:dword
|
|||||||
|
|
||||||
mov edx, PCI_BASE_ADDRESS_0 ; find the base io address
|
mov edx, PCI_BASE_ADDRESS_0 ; find the base io address
|
||||||
.sb_reg_check:
|
.sb_reg_check:
|
||||||
;
|
|
||||||
movzx eax, byte [ebx+device.pci_bus] ;
|
movzx eax, byte [ebx+device.pci_bus] ;
|
||||||
movzx ecx, byte [ebx+device.pci_dev] ;
|
movzx ecx, byte [ebx+device.pci_dev] ;
|
||||||
;
|
;
|
||||||
@ -415,6 +419,7 @@ create_new_struct:
|
|||||||
mov dword [ebx+device.get_MAC], read_mac
|
mov dword [ebx+device.get_MAC], read_mac
|
||||||
mov dword [ebx+device.set_MAC], write_mac
|
mov dword [ebx+device.set_MAC], write_mac
|
||||||
mov dword [ebx+device.unload], unload
|
mov dword [ebx+device.unload], unload
|
||||||
|
mov dword [ebx+device.name], my_service
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -585,18 +590,16 @@ ep_check_have_vendor:
|
|||||||
mov eax, [ebp + device.bmem]
|
mov eax, [ebp + device.bmem]
|
||||||
mov [ebp + device.rmem], eax
|
mov [ebp + device.rmem], eax
|
||||||
|
|
||||||
;-- hack
|
;-- hack (read mac from eeprom ant write it to hardware's register)
|
||||||
mov ebx, ebp
|
mov ebx, ebp
|
||||||
call read_mac
|
call read_mac
|
||||||
|
|
||||||
|
|
||||||
push .hack
|
push .hack
|
||||||
sub esp, 6
|
sub esp, 6
|
||||||
mov edi, esp
|
mov edi, esp
|
||||||
lea esi, [ebp + device.mac]
|
lea esi, [ebp + device.mac]
|
||||||
movsd
|
movsd
|
||||||
movsw
|
movsw
|
||||||
|
|
||||||
jmp write_mac
|
jmp write_mac
|
||||||
.hack:
|
.hack:
|
||||||
;--- hack
|
;--- hack
|
||||||
@ -613,8 +616,7 @@ ep_check_have_vendor:
|
|||||||
reset:
|
reset:
|
||||||
mov ebp, ebx ;---
|
mov ebp, ebx ;---
|
||||||
|
|
||||||
|
DEBUGF 2,"Resetting device\n"
|
||||||
DEBUGF 2,"Resetting rtl8029\n"
|
|
||||||
|
|
||||||
; attach int handler
|
; attach int handler
|
||||||
movzx eax, [ebp+device.irq_line]
|
movzx eax, [ebp+device.irq_line]
|
||||||
@ -734,6 +736,12 @@ nsr_002:
|
|||||||
mov al, 0 ; no loopback
|
mov al, 0 ; no loopback
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
|
; clear packet/byte counters
|
||||||
|
|
||||||
|
lea edi, [ebp+device.bytes_tx]
|
||||||
|
mov ecx, 6
|
||||||
|
rep stosd
|
||||||
|
|
||||||
|
|
||||||
; Indicate that we have successfully reset the card
|
; Indicate that we have successfully reset the card
|
||||||
DEBUGF 2,"Done!\n"
|
DEBUGF 2,"Done!\n"
|
||||||
@ -792,6 +800,12 @@ transmit:
|
|||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
DEBUGF 2," - Packet Sent!\n"
|
DEBUGF 2," - Packet Sent!\n"
|
||||||
|
|
||||||
|
inc [ebp+device.packets_tx] ;
|
||||||
|
mov eax, [esp+4] ; Get packet size in eax
|
||||||
|
|
||||||
|
add dword [ebp + device.bytes_tx], eax
|
||||||
|
adc dword [ebp + device.bytes_tx + 4], 0
|
||||||
.finish:
|
.finish:
|
||||||
mov ebx, ebp
|
mov ebx, ebp
|
||||||
|
|
||||||
@ -818,13 +832,13 @@ int_handler:
|
|||||||
.nextdevice:
|
.nextdevice:
|
||||||
mov ebp, dword [esi]
|
mov ebp, dword [esi]
|
||||||
|
|
||||||
set_io 0 ; We chould check ISR instead..
|
set_io 0
|
||||||
set_io P0_ISR
|
set_io P0_ISR
|
||||||
in al, dx
|
in al, dx
|
||||||
|
|
||||||
DEBUGF 2,"isr %x ",eax:2
|
DEBUGF 2,"isr %x ",eax:2
|
||||||
|
|
||||||
test al, ISR_PRX
|
test al, ISR_PRX ; packet received ok ?
|
||||||
jnz .rx
|
jnz .rx
|
||||||
|
|
||||||
add esi, 4
|
add esi, 4
|
||||||
@ -832,11 +846,18 @@ int_handler:
|
|||||||
loop .nextdevice
|
loop .nextdevice
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; looks like we've found it!
|
|
||||||
|
|
||||||
|
; looks like we've found a device wich received a packet..
|
||||||
.rx:
|
.rx:
|
||||||
|
stdcall KernelAlloc, ETH_FRAME_LEN ; size doesnt really matter as packet size is smaller then kernel's page size
|
||||||
|
test eax, eax
|
||||||
|
jz .fail_2
|
||||||
|
|
||||||
|
;--------------------------------------
|
||||||
|
; allocate memory for temp variables in stack
|
||||||
|
|
||||||
sub esp, 14+8 ; allocate memory for temp variables in stack
|
sub esp, 14+8
|
||||||
|
|
||||||
eth_type equ esp
|
eth_type equ esp
|
||||||
pkthdr equ esp + 2
|
pkthdr equ esp + 2
|
||||||
@ -844,10 +865,13 @@ int_handler:
|
|||||||
eth_rx_data_ptr equ esp + 8
|
eth_rx_data_ptr equ esp + 8
|
||||||
eth_tmp_len equ esp + 12
|
eth_tmp_len equ esp + 12
|
||||||
|
|
||||||
|
; These will be used by eth_receiver when the packet gets there
|
||||||
|
|
||||||
pointer equ esp + 14
|
pointer equ esp + 14
|
||||||
size equ esp + 18
|
size equ esp + 18
|
||||||
|
|
||||||
stdcall KernelAlloc, ETH_FRAME_LEN
|
;-------------------------------------
|
||||||
|
|
||||||
mov [pointer], eax
|
mov [pointer], eax
|
||||||
mov [eth_rx_data_ptr], eax
|
mov [eth_rx_data_ptr], eax
|
||||||
|
|
||||||
@ -915,6 +939,10 @@ int_handler:
|
|||||||
|
|
||||||
DEBUGF 2,"Received %u bytes\n",eax
|
DEBUGF 2,"Received %u bytes\n",eax
|
||||||
|
|
||||||
|
add dword [ebp + device.bytes_rx], eax ; Update stats
|
||||||
|
adc dword [ebp + device.bytes_rx + 4], 0
|
||||||
|
inc dword [ebp + device.packets_rx] ;
|
||||||
|
|
||||||
mov [eth_tmp_len], ax
|
mov [eth_tmp_len], ax
|
||||||
mov dword[size], eax
|
mov dword[size], eax
|
||||||
|
|
||||||
@ -930,25 +958,29 @@ int_handler:
|
|||||||
|
|
||||||
; Right, we can now get the data
|
; Right, we can now get the data
|
||||||
|
|
||||||
|
xor ebx, ebx
|
||||||
mov bh , [ebp + device.memsize]
|
mov bh , [ebp + device.memsize]
|
||||||
sub bx , [pktoff]
|
sub bx , [pktoff]
|
||||||
|
|
||||||
cmp [eth_tmp_len], bx
|
cmp [eth_tmp_len], bx
|
||||||
jbe .nsp_005
|
jbe .nsp_005
|
||||||
|
|
||||||
|
DEBUGF 2,"tadaa!\n"
|
||||||
|
|
||||||
mov al , [ebp + device.flags]
|
mov al , [ebp + device.flags]
|
||||||
test al , FLAG_PIO
|
test al , FLAG_PIO
|
||||||
jz .nsp_006
|
jz .nsp_006
|
||||||
|
|
||||||
push bx
|
push ebx
|
||||||
mov cx , bx
|
mov cx , bx
|
||||||
mov bx, [pktoff]
|
mov bx , [pktoff+4]
|
||||||
mov edi, [eth_rx_data_ptr]
|
mov edi, [eth_rx_data_ptr+4]
|
||||||
call eth_pio_read
|
call eth_pio_read
|
||||||
pop bx
|
pop ebx
|
||||||
jmp .nsp_007
|
jmp .nsp_007
|
||||||
|
|
||||||
.nsp_006:
|
.nsp_006:
|
||||||
|
DEBUGF 2,"PIO mode not supported by HW!\n"
|
||||||
; Not implemented, as we are using PIO mode on this card
|
; Not implemented, as we are using PIO mode on this card
|
||||||
|
|
||||||
.nsp_007:
|
.nsp_007:
|
||||||
@ -975,6 +1007,7 @@ int_handler:
|
|||||||
jmp .nsp_009
|
jmp .nsp_009
|
||||||
|
|
||||||
.nsp_008:
|
.nsp_008:
|
||||||
|
DEBUGF 2,"PIO mode not supported by HW!\n"
|
||||||
; Not implemented, as we are using PIO mode on this card
|
; Not implemented, as we are using PIO mode on this card
|
||||||
|
|
||||||
.nsp_009:
|
.nsp_009:
|
||||||
@ -990,13 +1023,15 @@ int_handler:
|
|||||||
dec al
|
dec al
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
|
mov ebx, ebp
|
||||||
add esp, 14
|
add esp, 14
|
||||||
|
|
||||||
mov ebx, ebp
|
mov ebx, ebp
|
||||||
jmp EthReceiver ;;;
|
jmp EthReceiver ; send it to the kernel
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
add esp, 14+8
|
add esp, 14+8
|
||||||
|
.fail_2:
|
||||||
DEBUGF 2,"done\n"
|
DEBUGF 2,"done\n"
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1011,7 +1046,7 @@ ret
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
write_mac: ; in: mac on stack
|
write_mac: ; in: mac on stack (6 bytes)
|
||||||
|
|
||||||
mov ebp, ebx ;---
|
mov ebp, ebx ;---
|
||||||
|
|
||||||
@ -1062,9 +1097,6 @@ read_mac:
|
|||||||
; inc dx
|
; inc dx
|
||||||
; loopw .loop
|
; loopw .loop
|
||||||
;
|
;
|
||||||
; lea edi, [ebp + device.mac]
|
|
||||||
; DEBUGF 1,"%x-%x-%x-%x-%x-%x\n",[edi+0]:2,[edi+1]:2,[edi+2]:2,[edi+3]:2,[edi+4]:2,[edi+5]:2
|
|
||||||
;
|
|
||||||
; set_io 0
|
; set_io 0
|
||||||
; mov al, CMD_PS0; + CMD_RD2 + CMD_STA ; set page back to 0
|
; mov al, CMD_PS0; + CMD_RD2 + CMD_STA ; set page back to 0
|
||||||
; out dx, al
|
; out dx, al
|
||||||
@ -1087,6 +1119,7 @@ read_mac:
|
|||||||
.8bit:
|
.8bit:
|
||||||
loop .loop
|
loop .loop
|
||||||
|
|
||||||
|
DEBUGF 1,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2,[edi-5]:2,[edi-4]:2,[edi-3]:2,[edi-2]:2,[edi-1]:2
|
||||||
|
|
||||||
mov ebx, ebp ;---
|
mov ebx, ebp ;---
|
||||||
|
|
||||||
@ -1261,24 +1294,21 @@ align 4
|
|||||||
|
|
||||||
ne2000_DEV dd 0
|
ne2000_DEV dd 0
|
||||||
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
||||||
my_service db 'ne2000',0 ;max 16 chars include zero
|
my_service db 'RTL8029/ne2000',0 ;max 16 chars include zero
|
||||||
devicename db 'Realtek 8029',0
|
|
||||||
db 'Realtek 8019',0
|
device_1 db 'Realtek 8029',0
|
||||||
db 'Realtek 8019AS',0
|
device_2 db 'Realtek 8019',0
|
||||||
db 'ne2000',0
|
device_3 db 'Realtek 8019AS',0
|
||||||
db 'DP8390',0
|
device_4 db 'ne2000',0
|
||||||
|
device_5 db 'DP8390',0
|
||||||
|
|
||||||
test_data db 'NE*000 memory',0
|
test_data db 'NE*000 memory',0
|
||||||
;test_buffer db ' ',0
|
|
||||||
|
|
||||||
include_debug_strings
|
include_debug_strings
|
||||||
|
|
||||||
section '.data' data readable writable align 16
|
section '.data' data readable writable align 16 ;place all uninitialized data place here
|
||||||
|
|
||||||
;place all uninitialized data place here
|
ne2000_LIST rd MAX_ne2000
|
||||||
|
|
||||||
ne2000_LIST:
|
|
||||||
rd MAX_ne2000
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
mov dword [ebx+device.get_MAC], read_mac
|
mov dword [ebx+device.get_MAC], read_mac
|
||||||
mov dword [ebx+device.set_MAC], write_mac
|
mov dword [ebx+device.set_MAC], write_mac
|
||||||
mov dword [ebx+device.unload], unload
|
mov dword [ebx+device.unload], unload
|
||||||
mov dword [ebx+device.name], devicename
|
mov dword [ebx+device.name], my_service
|
||||||
|
|
||||||
; save the pci bus and device numbers
|
; save the pci bus and device numbers
|
||||||
|
|
||||||
@ -555,6 +555,13 @@ probe:
|
|||||||
.chip_ver_found:
|
.chip_ver_found:
|
||||||
mov [ebx+device.hw_ver_id], cl
|
mov [ebx+device.hw_ver_id], cl
|
||||||
|
|
||||||
|
shl ecx, 2
|
||||||
|
add ecx, name_crosslist
|
||||||
|
mov ecx, [ecx]
|
||||||
|
mov dword [ebx+device.name], ecx
|
||||||
|
|
||||||
|
DEBUGF 1,"Chip version: %s\n",ecx
|
||||||
|
|
||||||
; wake up the chip
|
; wake up the chip
|
||||||
|
|
||||||
mov edx, [ebx+device.io_addr]
|
mov edx, [ebx+device.io_addr]
|
||||||
@ -1290,7 +1297,24 @@ align 4 ; Place all initialised data here
|
|||||||
RTL8139_DEV dd 0
|
RTL8139_DEV dd 0
|
||||||
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
|
||||||
my_service db 'RTL8139',0 ; max 16 chars include zero
|
my_service db 'RTL8139',0 ; max 16 chars include zero
|
||||||
devicename db 'Realtek 8139',0
|
|
||||||
|
device_1 db 'Realtek 8139',0
|
||||||
|
device_2 db 'Realtek 8139A',0
|
||||||
|
device_3 db 'Realtek 8139B',0
|
||||||
|
device_4 db 'Realtek 8139C',0
|
||||||
|
device_5 db 'Realtek 8100',0
|
||||||
|
device_6 db 'Realtek 8139D',0
|
||||||
|
device_7 db 'Realtek 8139CP',0
|
||||||
|
device_8 db 'Realtek 8101',0
|
||||||
|
|
||||||
|
name_crosslist dd device_1
|
||||||
|
dd device_2
|
||||||
|
dd device_3
|
||||||
|
dd device_4
|
||||||
|
dd device_5
|
||||||
|
dd device_6
|
||||||
|
dd device_7
|
||||||
|
dd device_8
|
||||||
|
|
||||||
hw_ver_array db VER_RTL8139 ; This array is used by the probe routine to find out wich version of the RTL8139 we are working with
|
hw_ver_array db VER_RTL8139 ; This array is used by the probe routine to find out wich version of the RTL8139 we are working with
|
||||||
db VER_RTL8139A
|
db VER_RTL8139A
|
||||||
|
Loading…
Reference in New Issue
Block a user