Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5522 → Rev 5363

/drivers/ethernet/rhine.asm
346,7 → 346,7
NIC_LB_INTERNAL = 0x01
NIC_LB_PHY = 0x02 ; MII or Internal-10BaseT loopback
 
PKT_BUF_SZ = 1514
PKT_BUF_SZ = 1536 ; Size of each temporary Rx buffer.
 
PCI_REG_MODE3 = 0x53
MODE3_MIION = 0x04 ; in PCI_REG_MOD3 OF PCI space
929,7 → 929,11
DEBUGF 1,"Attaching int handler to irq %x\n", eax:1
invoke AttachIntHandler, eax, int_handler, ebx
test eax, eax
jz .err
jnz @f
DEBUGF 2,"Could not attach int handler!\n"
or eax, -1
ret
@@:
 
; Soft reset the chip.
set_io [ebx + device.io_addr], 0
941,8 → 945,6
 
; Initialize rings
call init_ring
test eax, eax
jnz .err
 
; Set Multicast
call set_rx_mode
966,6 → 968,7
out dx, al
 
; Set Fulldupex
 
call QueryAuto
test eax, eax ; full duplex?
jz @f
1004,13 → 1007,8
xor eax, eax
ret
 
.err:
DEBUGF 2,"Error!\n"
or eax, -1
ret
 
 
 
align 4
unload:
 
1075,13 → 1073,10
mov [edi + rx_head.status], RX_SBITS_OWN_BIT
mov [edi + rx_head.control], PKT_BUF_SZ
push ecx
invoke NetAlloc, PKT_BUF_SZ+NET_BUFF.data
invoke KernelAlloc, PKT_BUF_SZ
pop ecx
test eax, eax
jz .out_of_mem
mov [edi + rx_head.buff_addr_virt], eax
invoke GetPhysAddr
add eax, NET_BUFF.data
mov [edi + rx_head.buff_addr], eax ; buffer ptr
mov [edi + rx_head.next_desc], esi ; next head
add edi, sizeof.rx_head
1125,15 → 1120,9
mov [ebx + device.cur_tx], ax
mov [ebx + device.last_tx], ax
 
xor eax, eax
ret
 
.out_of_mem:
add esp, 4
or eax, -1
ret
 
 
align 4
QueryAuto:
 
1360,8 → 1349,8
out dx, eax
 
set_io [ebx + device.io_addr], byRCR
mov al, 0x6C ; thresh or rx_mode
out dx, al
mov al, 0x6C ;rx_mode = 0x0C;
out dx, al ;outb(0x60 /* thresh */ | rx_mode, byRCR );
 
ret
 
1404,26 → 1393,26
;; Transmit ;;
;; ;;
;; In: buffer pointer in [esp+4] ;;
;; size of buffer in [esp+8] ;;
;; pointer to device structure in ebx ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
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 eax, [ebx + device.cur_tx]
1435,12 → 1424,11
cmp [edi + tx_head.buff_addr_virt], 0
jne .fail
 
mov eax, esi
mov eax, [bufferptr]
mov [edi + tx_head.buff_addr_virt], eax
add eax, [eax + NET_BUFF.offset]
invoke GetPhysAddr
mov [edi + tx_head.buff_addr], eax
mov ecx, [esi + NET_BUFF.length]
mov ecx, [buffersize]
and ecx, TX_CBITS_TX_BUF_SIZE
or ecx, 0x00E08000
mov [edi + tx_head.control], ecx
1459,7 → 1447,7
 
; Update stats
inc [ebx + device.packets_tx]
mov ecx, [esi + NET_BUFF.length]
mov ecx, [buffersize]
add dword [ebx + device.bytes_tx], ecx
adc dword [ebx + device.bytes_tx + 4], 0
 
1470,7 → 1458,7
 
.fail:
DEBUGF 2,"Transmit failed\n"
invoke NetFree, [bufferptr]
invoke KernelFree, [bufferptr]
popf
or eax, -1
ret
1493,6 → 1481,7
DEBUGF 1,"INT\n"
 
; Find pointer of device which made IRQ occur
 
mov ecx, [devices]
test ecx, ecx
jz .nothing
1517,7 → 1506,9
ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
 
 
 
.got_it:
 
DEBUGF 1, "status=0x%x\n", ax
 
push ax
1530,6 → 1521,7
pop ebx
 
; Get the current descriptor pointer
 
movzx eax, [ebx + device.cur_rx]
mov ecx, sizeof.rx_head
mul ecx
1537,8 → 1529,9
add edi, eax
 
; Check it's status
 
test [edi + rx_head.status], RX_SBITS_OWN_BIT
jnz .not_RX
jnz .not_bit_own
 
DEBUGF 1, "Packet status = 0x%x\n", [edi + rx_head.status]
 
1545,6 → 1538,7
; TODO: check error bits
 
; get length
 
mov ecx, [edi + rx_head.status]
and ecx, RX_SBITS_FRAME_LENGTH
shr ecx, 16
1551,37 → 1545,41
sub ecx, 4 ; We dont want CRC
 
; Update stats
 
add dword [ebx + device.bytes_rx], ecx
adc dword [ebx + device.bytes_rx + 4], 0
inc [ebx + device.packets_rx]
 
; Push packet pointer, kernel will need it..
; Push packet size and pointer, kernel will need it..
 
push ebx
push .more_RX ; return ptr
mov eax, [edi + rx_head.buff_addr_virt]
push eax
mov [eax + NET_BUFF.length], ecx
mov [eax + NET_BUFF.device], ebx
mov [eax + NET_BUFF.offset], NET_BUFF.data
 
push ecx ; full packet size
push [edi + rx_head.buff_addr_virt]
 
; reset the RX descriptor
 
push edi
invoke NetAlloc, PKT_BUF_SZ+NET_BUFF.data
invoke KernelAlloc, PKT_BUF_SZ
pop edi
mov [edi + rx_head.buff_addr_virt], eax
invoke GetPhysAddr
add eax, NET_BUFF.data
mov [edi + rx_head.buff_addr], eax
mov [edi + rx_head.status], RX_SBITS_OWN_BIT
 
; Use next descriptor next time
 
inc [ebx + device.cur_rx]
and [ebx + device.cur_rx], RX_RING_SIZE - 1
 
; At last, send packet to kernel
jmp [EthInput]
 
jmp [Eth_input]
 
.not_bit_own:
.not_RX:
 
pop ax
 
test ax, IntrTxDone
1604,7 → 1602,7
 
push [edi + tx_head.buff_addr_virt]
mov [edi + tx_head.buff_addr_virt], 0
invoke NetFree
invoke KernelFree
 
inc [ebx + device.last_tx]
and [ebx + device.last_tx], TX_RING_SIZE - 1
1615,12 → 1613,12
 
; On Rhine-II, Bit 3 indicates Tx descriptor write-back race.
if 0
cmp [ebx + device.chip_id], 0x3065
cmp [ebx + device.chip_id], 0x3065 ;if (tp->chip_id == 0x3065)
jne @f
push ax
xor eax, eax
set_io [ebx + device.io_addr], IntrStatus2
in al, dx
in al, dx ; intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
shl eax, 16
pop ax
@@: