Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5522 → Rev 5363

/drivers/ethernet/mtd80x.asm
473,6 → 473,7
; - Remove all allocated structures and buffers the card used
 
or eax, -1
 
ret
 
 
626,8 → 627,6
out dx, eax
 
call init_ring
test eax, eax
jnz .err
 
; Initialize other registers.
; Configure the PCI bus bursts and FIFO thresholds.
677,14 → 676,9
xor eax, eax
ret
 
.err:
DEBUGF 2, "Error!\n"
or eax, -1
ret
 
 
 
 
align 4
init_ring:
 
696,7 → 690,7
mov ecx, NUM_RX_DESC
.rx_desc_loop:
mov [esi + descriptor.status], RXOWN
mov [esi + descriptor.control], 1514 shl RBSShift
mov [esi + descriptor.control], 1536 shl RBSShift
 
lea eax, [esi + sizeof.descriptor]
mov [esi + descriptor.next_desc_logical], eax
704,14 → 698,11
invoke GetPhysAddr
mov [esi + descriptor.next_desc], eax
 
invoke NetAlloc, 1514+NET_BUFF.data
pop esi ecx
test eax, eax
jz .out_of_mem
push ecx esi
invoke KernelAlloc, 1536
pop esi
push esi
mov [esi + descriptor.skbuff], eax
invoke GetPgAddr
add eax, NET_BUFF.data
pop esi ecx
mov [esi + descriptor.buffer], eax
 
759,14 → 750,9
set_io [ebx + device.io_addr], TXLBA
out dx, eax
 
xor eax, eax
ret
 
.out_of_mem:
or eax, -1
ret
 
 
align 4
set_rx_mode:
 
938,25 → 924,25
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
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
 
mov esi, [ebx + device.cur_tx]
 
test [esi + descriptor.status], TXOWN
jnz .fail
 
965,12 → 951,10
 
mov eax, [bufferptr]
mov [esi + descriptor.skbuff], eax
add eax, [eax + NET_BUFF.offset]
invoke GetPhysAddr
mov [esi + descriptor.buffer], eax
 
mov eax, [bufferptr]
mov eax, [eax + NET_BUFF.length]
mov eax, [buffersize]
mov ecx, eax
shl eax, PKTSShift ; packet size
shl ecx, TBSShift
981,9 → 965,8
 
; Update stats
inc [ebx + device.packets_tx]
mov eax, [bufferptr]
mov ecx, [eax + NET_BUFF.length]
add dword[ebx + device.bytes_tx], ecx
mov eax, [buffersize]
add dword[ebx + device.bytes_tx], eax
adc dword[ebx + device.bytes_tx + 4], 0
 
; TX Poll
999,7 → 982,7
 
.fail:
DEBUGF 2,"Transmit failed\n"
invoke NetFree, [bufferptr]
invoke KernelFree, [bufferptr]
popf
or eax, -1
ret
1085,12 → 1068,8
mov ecx, [esi + descriptor.status]
shr ecx, FLNGShift
sub ecx, 4 ; we dont need CRC
push ecx
DEBUGF 1,"Received %u bytes\n", ecx
mov eax, [esi + descriptor.skbuff]
push eax
mov [eax + NET_BUFF.length], ecx
mov [eax + NET_BUFF.device], ebx
mov [eax + NET_BUFF.offset], NET_BUFF.data
 
; Update stats
add dword[ebx + device.bytes_rx], ecx
1097,20 → 1076,18
adc dword[ebx + device.bytes_rx + 4], 0
inc [ebx + device.packets_rx]
 
jmp [EthInput]
push [esi + descriptor.skbuff]
jmp [Eth_input]
 
.rx_complete:
pop ebx
mov esi, [ebx + device.cur_rx]
mov [esi + descriptor.control], 1514 shl RBSShift
mov [esi + descriptor.control], 1536 shl RBSShift
push esi
invoke NetAlloc, 1514+NET_BUFF.data
invoke KernelAlloc, 1536
pop esi
; test eax, eax
; jz .rx_loop
mov [esi + descriptor.skbuff], eax
invoke GetPhysAddr
add eax, NET_BUFF.data
invoke GetPgAddr
mov [esi + descriptor.buffer], eax
mov [esi + descriptor.status], RXOWN
 
1145,7 → 1122,7
je .skip_this_one
mov [esi + descriptor.skbuff], 0
DEBUGF 1,"freeing buffer: 0x%x\n", eax
invoke NetFree, eax
invoke KernelFree, eax
.skip_this_one:
mov esi, [esi + descriptor.next_desc_logical]
loop .tx_loop