Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5522 → Rev 5521

/drivers/ethernet/R6040.asm
137,7 → 137,7
MAC_SM = 0xAC ; MAC status machine
MAC_ID = 0xBE ; Identifier register
 
MAX_BUF_SIZE = 1514
MAX_BUF_SIZE = 0x600 ; 1536
 
MBCR_DEFAULT = 0x012A ; MAC Bus Control Register
MCAST_MAX = 3 ; Max number multicast addresses to filter
396,11 → 396,12
;
; - Stop the device
; - Detach int handler
; - Remove device from local list (device_list)
; - Remove device from local list (RTL8139_LIST)
; - call unregister function in kernel
; - Remove all allocated structures and buffers the card used
 
or eax, -1
 
ret
 
 
451,7 → 452,6
cmp ax, 0xFFFF
jne @f
DEBUGF 2, "Failed to detect an attached PHY!\n"
.err:
mov eax, -1
ret
@@:
462,8 → 462,6
; Initialize and alloc RX/TX buffers
call init_txbufs
call init_rxbufs
test eax, eax
jnz .err
 
; Read the PHY ID
mov [ebx + device.phy_mode], MCR0_FD
664,19 → 662,19
 
.next_desc:
mov [esi + x_head.ndesc], edx
 
push esi ecx edx
invoke NetAlloc, MAX_BUF_SIZE+NET_BUFF.data
invoke KernelAlloc, MAX_BUF_SIZE
pop edx ecx esi
test eax, eax
jz .out_of_mem
 
mov [esi + x_head.skb_ptr], eax
invoke GetPhysAddr
add eax, NET_BUFF.data
mov [esi + x_head.buf], eax
mov [esi + x_head.status], DSC_OWNER_MAC
 
add edx, sizeof.x_head
add esi, sizeof.x_head
 
dec ecx
jnz .next_desc
 
685,15 → 683,10
invoke GetPhysAddr
mov dword[ebx + device.rx_ring + sizeof.x_head*(RX_RING_SIZE-1) + x_head.ndesc], eax
 
xor eax, eax
ret
 
.out_of_mem:
or eax, -1
ret
 
 
 
align 4
phy_mode_chk:
 
741,22 → 734,21
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
proc transmit stdcall bufferptr
proc transmit stdcall bufferptr, buffersize
 
pushf
cli
 
mov esi, [bufferptr]
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
lea eax, [esi + NET_BUFF.data]
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
mov eax, [bufferptr]
DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
[eax+13]:2,[eax+12]:2
 
cmp [esi + NET_BUFF.length], 1514
cmp [buffersize], 1514
ja .fail
cmp [esi + NET_BUFF.length], 60
cmp [buffersize], 60
jb .fail
 
movzx edi, [ebx + device.cur_tx]
772,12 → 764,11
.do_send:
DEBUGF 1,"Sending now\n"
 
mov [edi + x_head.skb_ptr], esi
mov eax, esi
add eax, [eax + NET_BUFF.offset]
mov eax, [bufferptr]
mov [edi + x_head.skb_ptr], eax
invoke GetPhysAddr
mov [edi + x_head.buf], eax
mov ecx, [esi + NET_BUFF.length]
mov ecx, [buffersize]
mov [edi + x_head.len], cx
mov [edi + x_head.status], DSC_OWNER_MAC
 
792,7 → 783,7
 
; Update stats
inc [ebx + device.packets_tx]
mov eax, [esi + NET_BUFF.length]
mov eax, [buffersize]
add dword[ebx + device.bytes_tx], eax
adc dword[ebx + device.bytes_tx + 4], 0
 
802,18 → 793,15
 
.wait_to_send:
DEBUGF 1,"Waiting for TX buffer\n"
 
invoke GetTimerTicks ; returns in eax
lea edx, [eax + 100]
.l2:
mov esi, [bufferptr]
test [edi + x_head.status], DSC_OWNER_MAC
jz .do_send
popf
mov esi, 10
invoke Sleep
invoke GetTimerTicks
pushf
cli
cmp edx, eax
jb .l2
 
820,7 → 808,7
DEBUGF 2,"Send timeout\n"
.fail:
DEBUGF 2,"Send failed\n"
invoke NetFree, [bufferptr]
invoke KernelFree, [bufferptr]
popf
or eax, -1
ret
902,29 → 890,26
and ecx, 0xFFF
sub ecx, 4 ; Do not count the CRC
 
DEBUGF 1,"packet ptr=0x%x size=%u\n", [edx + x_head.skb_ptr], ecx
 
; Update stats
add dword[ebx + device.bytes_rx], ecx
adc dword[ebx + device.bytes_rx + 4], 0
inc dword[ebx + device.packets_rx]
 
; Push packet size and pointer, kernel will need it..
push ebx
; Push packet ptr and return addr for Eth_input
push .more_RX
mov eax, [edx + x_head.skb_ptr]
push eax
mov [eax + NET_BUFF.length], ecx
mov [eax + NET_BUFF.device], ebx
mov [eax + NET_BUFF.offset], NET_BUFF.data
 
; reset the RX descriptor (alloc new buffer)
push ecx
push [edx + x_head.skb_ptr]
 
DEBUGF 1,"packet ptr=0x%x\n", [edx + x_head.skb_ptr]
 
; reset the RX descriptor
push edx
invoke NetAlloc, MAX_BUF_SIZE+NET_BUFF.data
invoke KernelAlloc, MAX_BUF_SIZE
pop edx
mov [edx + x_head.skb_ptr], eax
invoke GetPhysAddr
add eax, NET_BUFF.data
mov [edx + x_head.buf], eax
mov [edx + x_head.status], DSC_OWNER_MAC
 
933,10 → 918,11
and [ebx + device.cur_rx], RX_RING_SIZE - 1
 
; At last, send packet to kernel
jmp [EthInput]
jmp [Eth_input]
 
 
.no_RX:
 
test word[esp], TX_FINISH
jz .no_TX
 
955,7 → 941,7
 
push [edi + x_head.skb_ptr]
mov [edi + x_head.skb_ptr], 0
invoke NetFree
invoke KernelFree
 
inc [ebx + device.last_tx]
and [ebx + device.last_tx], TX_RING_SIZE - 1
1120,13 → 1106,13
lea edi, [ebx + device.mac]
set_io [ebx + device.io_addr], 0
set_io [ebx + device.io_addr], MID_0L
.loop:
.mac:
in ax, dx
stosw
inc dx
inc dx
dec cx
jnz .loop
jnz .mac
 
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