Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1177 → Rev 1178

/kernel/branches/net/drivers/RTL8029.asm
1,17 → 1,21
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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 ;;
;; ;;
;; ne2000 driver for KolibriOS ;;
;; RTL8029/ne2000 driver for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; with help from CleverMouse ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; 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 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
format MS COFF
298,7 → 302,7
 
mov edx, PCI_BASE_ADDRESS_0 ; find the base io address
.sb_reg_check:
;
 
movzx eax, byte [ebx+device.pci_bus] ;
movzx ecx, byte [ebx+device.pci_dev] ;
;
415,6 → 419,7
mov dword [ebx+device.get_MAC], read_mac
mov dword [ebx+device.set_MAC], write_mac
mov dword [ebx+device.unload], unload
mov dword [ebx+device.name], my_service
 
ret
 
585,11 → 590,10
mov eax, [ebp + device.bmem]
mov [ebp + device.rmem], eax
 
;-- hack
;-- hack (read mac from eeprom ant write it to hardware's register)
mov ebx, ebp
call read_mac
 
 
push .hack
sub esp, 6
mov edi, esp
596,7 → 600,6
lea esi, [ebp + device.mac]
movsd
movsw
 
jmp write_mac
.hack:
;--- hack
613,9 → 616,8
reset:
mov ebp, ebx ;---
 
DEBUGF 2,"Resetting device\n"
 
DEBUGF 2,"Resetting rtl8029\n"
 
; attach int handler
movzx eax, [ebp+device.irq_line]
DEBUGF 1,"Attaching int handler to irq %x\n",eax:1
734,7 → 736,13
mov al, 0 ; no loopback
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
DEBUGF 2,"Done!\n"
xor eax, eax
792,6 → 800,12
out dx, al
 
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:
mov ebx, ebp
 
818,13 → 832,13
.nextdevice:
mov ebp, dword [esi]
 
set_io 0 ; We chould check ISR instead..
set_io 0
set_io P0_ISR
in al, dx
 
DEBUGF 2,"isr %x ",eax:2
 
test al, ISR_PRX
test al, ISR_PRX ; packet received ok ?
jnz .rx
 
add esi, 4
832,11 → 846,18
loop .nextdevice
ret
 
; looks like we've found it!
 
 
; looks like we've found a device wich received a packet..
.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
pkthdr equ esp + 2
844,10 → 865,13
eth_rx_data_ptr equ esp + 8
eth_tmp_len equ esp + 12
 
; These will be used by eth_receiver when the packet gets there
 
pointer equ esp + 14
size equ esp + 18
 
stdcall KernelAlloc, ETH_FRAME_LEN
;-------------------------------------
 
mov [pointer], eax
mov [eth_rx_data_ptr], eax
 
915,6 → 939,10
 
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 dword[size], eax
 
930,6 → 958,7
 
; Right, we can now get the data
 
xor ebx, ebx
mov bh, [ebp + device.memsize]
sub bx, [pktoff]
 
936,19 → 965,22
cmp [eth_tmp_len], bx
jbe .nsp_005
 
DEBUGF 2,"tadaa!\n"
 
mov al, [ebp + device.flags]
test al, FLAG_PIO
jz .nsp_006
 
push bx
push ebx
mov cx, bx
mov bx, [pktoff]
mov edi, [eth_rx_data_ptr]
mov bx , [pktoff+4]
mov edi, [eth_rx_data_ptr+4]
call eth_pio_read
pop bx
pop ebx
jmp .nsp_007
 
.nsp_006:
DEBUGF 2,"PIO mode not supported by HW!\n"
; Not implemented, as we are using PIO mode on this card
 
.nsp_007:
975,6 → 1007,7
jmp .nsp_009
 
.nsp_008:
DEBUGF 2,"PIO mode not supported by HW!\n"
; Not implemented, as we are using PIO mode on this card
 
.nsp_009:
990,13 → 1023,15
dec al
out dx, al
 
mov ebx, ebp
add esp, 14
 
mov ebx, ebp
jmp EthReceiver ;;;
jmp EthReceiver ; send it to the kernel
 
.fail:
add esp, 14+8
.fail_2:
DEBUGF 2,"done\n"
ret
 
1011,7 → 1046,7
;;;;;;;;;;;;;;;;;;;;;;;
 
align 4
write_mac: ; in: mac on stack
write_mac: ; in: mac on stack (6 bytes)
 
mov ebp, ebx ;---
 
1062,9 → 1097,6
; inc dx
; 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
; mov al, CMD_PS0; + CMD_RD2 + CMD_STA ; set page back to 0
; out dx, al
1087,6 → 1119,7
.8bit:
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 ;---
 
1261,26 → 1294,23
 
ne2000_DEV dd 0
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'ne2000',0 ;max 16 chars include zero
devicename db 'Realtek 8029',0
db 'Realtek 8019',0
db 'Realtek 8019AS',0
db 'ne2000',0
db 'DP8390',0
my_service db 'RTL8029/ne2000',0 ;max 16 chars include zero
 
device_1 db 'Realtek 8029',0
device_2 db 'Realtek 8019',0
device_3 db 'Realtek 8019AS',0
device_4 db 'ne2000',0
device_5 db 'DP8390',0
 
test_data db 'NE*000 memory',0
;test_buffer db ' ',0
 
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
 
 
 
 
 
/kernel/branches/net/drivers/RTL8139.asm
362,7 → 362,7
mov dword [ebx+device.get_MAC], read_mac
mov dword [ebx+device.set_MAC], write_mac
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
 
555,6 → 555,13
.chip_ver_found:
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
 
mov edx, [ebx+device.io_addr]
1290,8 → 1297,25
RTL8139_DEV dd 0
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
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
db VER_RTL8139A
db VER_RTL8139B