Subversion Repositories Kolibri OS

Rev

Rev 5140 | Rev 5363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5140 Rev 5156
Line 275... Line 275...
275
        cur_rx          dd ?
275
        cur_rx          dd ?
276
        cur_tx          dd ?
276
        cur_tx          dd ?
277
        last_tx         dd ?
277
        last_tx         dd ?
Line 278... Line 278...
278
 
278
 
279
        rb 0x100 - ($ and 0xff) ; align 256
-
 
280
 
279
        rb 0x100 - ($ and 0xff) ; align 256
Line 281... Line 280...
281
        rx_desc         rb RX_RING_SIZE*sizeof.RDESC*2
280
        rx_desc         rb RX_RING_SIZE*sizeof.RDESC*2
282
 
-
 
283
        rb 0x100 - ($ and 0xff) ; align 256
281
 
Line 284... Line 282...
284
 
282
        rb 0x100 - ($ and 0xff) ; align 256
Line 285... Line 283...
285
        tx_desc         rb TX_RING_SIZE*sizeof.TDESC*2
283
        tx_desc         rb TX_RING_SIZE*sizeof.TDESC*2
Line 414... Line 412...
414
        mov     eax, [devices]                          ; Add the device structure to our device list
412
        mov     eax, [devices]                          ; Add the device structure to our device list
415
        mov     [device_list+4*eax], ebx                ; (IRQ handler uses this list to find device)
413
        mov     [device_list+4*eax], ebx                ; (IRQ handler uses this list to find device)
416
        inc     [devices]                               ;
414
        inc     [devices]                               ;
Line 417... Line 415...
417
 
415
 
-
 
416
        call    start_i8254x
-
 
417
        test    eax, eax
Line 418... Line 418...
418
        call    start_i8254x
418
        jnz     .destroy
419
 
419
 
420
        mov     [ebx + device.type], NET_TYPE_ETH
420
        mov     [ebx + device.type], NET_TYPE_ETH
421
        invoke  NetRegDev
421
        invoke  NetRegDev
Line 441... Line 441...
441
 
441
 
442
  .err:
442
  .err:
Line 443... Line 443...
443
        invoke  KernelFree, ebx
443
        invoke  KernelFree, ebx
-
 
444
 
444
 
445
  .fail:
445
  .fail:
446
        DEBUGF  2,"Loading driver failed\n"
Line 446... Line 447...
446
        or      eax, -1
447
        or      eax, -1
447
        ret
448
        ret
Line 457... Line 458...
457
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
458
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
Line 458... Line 459...
458
 
459
 
459
 
460
 
-
 
461
align 4
-
 
462
unload:
-
 
463
 
460
align 4
464
        DEBUGF  1,"Unload\n"
461
unload:
465
 
462
        ; TODO: (in this particular order)
466
        ; TODO: (in this particular order)
463
        ;
467
        ;
464
        ; - Stop the device
468
        ; - Stop the device
Line 538... Line 542...
538
        stosd
542
        stosd
539
        stosd
543
        stosd
540
        stosd
544
        stosd
Line 541... Line 545...
541
 
545
 
-
 
546
        call    init_rx
-
 
547
        test    eax, eax
542
        call    init_rx
548
        jnz     .fail
Line 543... Line 549...
543
        call    init_tx
549
        call    init_tx
-
 
550
 
544
 
551
        xor     eax, eax
Line 545... Line 552...
545
        xor     eax, eax
552
  .fail:
546
        ret
553
        ret
Line 547... Line 554...
547
 
554
 
548
 
555
 
549
 
556
 
550
align 4
-
 
551
init_rx:
557
align 4
552
 
558
init_rx:
-
 
559
 
-
 
560
        lea     edi, [ebx + device.rx_desc]
553
        lea     edi, [ebx + device.rx_desc]
561
        mov     ecx, RX_RING_SIZE
554
        mov     ecx, RX_RING_SIZE
562
  .loop:
555
  .loop:
563
        push    ecx edi
556
        push    ecx
564
        invoke  KernelAlloc, MAX_PKT_SIZE
557
        push    edi
565
        test    eax, eax
Line 580... Line 588...
580
        mov     dword[esi + REG_RDLEN], RX_RING_SIZE*sizeof.RDESC       ; Receive Descriptor Length
588
        mov     dword[esi + REG_RDLEN], RX_RING_SIZE*sizeof.RDESC       ; Receive Descriptor Length
581
        mov     dword[esi + REG_RDH], 0                                 ; Receive Descriptor Head
589
        mov     dword[esi + REG_RDH], 0                                 ; Receive Descriptor Head
582
        mov     dword[esi + REG_RDT], RX_RING_SIZE-1                    ; Receive Descriptor Tail
590
        mov     dword[esi + REG_RDT], RX_RING_SIZE-1                    ; Receive Descriptor Tail
583
        mov     dword[esi + REG_RCTL], RCTL_SBP or RCTL_BAM or RCTL_SECRC or RCTL_UPE or RCTL_MPE
591
        mov     dword[esi + REG_RCTL], RCTL_SBP or RCTL_BAM or RCTL_SECRC or RCTL_UPE or RCTL_MPE
584
        ; Store Bad Packets, Broadcast Accept Mode, Strip Ethernet CRC from incoming packet, Promiscuous mode
592
        ; Store Bad Packets, Broadcast Accept Mode, Strip Ethernet CRC from incoming packet, Promiscuous mode
-
 
593
        xor     eax, eax        ; success!
-
 
594
        ret
Line -... Line 595...
-
 
595
 
-
 
596
  .out_of_mem:
-
 
597
        DEBUGF  2,"Out of memory!\n"
-
 
598
        pop     edi ecx
585
 
599
        or      eax, -1         ; error!
Line 586... Line 600...
586
        ret
600
        ret
Line 618... Line 632...
618
 
632
 
619
 
633
 
620
align 4
634
align 4
-
 
635
reset:
-
 
636
        call    reset_dontstart
-
 
637
        test    eax, eax
-
 
638
        je      start_i8254x
Line -... Line 639...
-
 
639
 
621
reset:
640
        ret
Line 622... Line 641...
622
        call    reset_dontstart
641
 
623
 
642
align 4
Line 824... Line 843...
824
 
843
 
825
; Allocate new descriptor
844
; Allocate new descriptor
826
        push    esi
845
        push    esi
827
        invoke  KernelAlloc, MAX_PKT_SIZE
846
        invoke  KernelAlloc, MAX_PKT_SIZE
-
 
847
        pop     esi
-
 
848
        test    eax, eax
828
        pop     esi
849
        jz      .out_of_mem
829
        mov     dword[esi + RX_RING_SIZE*sizeof.RDESC], eax
850
        mov     dword[esi + RX_RING_SIZE*sizeof.RDESC], eax
830
        invoke  GetPhysAddr
851
        invoke  GetPhysAddr
831
        mov     [esi + RDESC.addr_l], eax
852
        mov     [esi + RDESC.addr_l], eax
832
        mov     [esi + RDESC.status_l], 0
853
        mov     [esi + RDESC.status_l], 0
Line 839... Line 860...
839
 
860
 
840
; Move to next rx desc
861
; Move to next rx desc
841
        inc     [ebx + device.cur_rx]
862
        inc     [ebx + device.cur_rx]
Line -... Line 863...
-
 
863
        and     [ebx + device.cur_rx], RX_RING_SIZE-1
-
 
864
 
-
 
865
        jmp     [Eth_input]
-
 
866
 
-
 
867
  .out_of_mem:
-
 
868
        DEBUGF  2,"Out of memory!\n"
-
 
869
 
-
 
870
; Move to next rx desc
-
 
871
        inc     [ebx + device.cur_rx]
842
        and     [ebx + device.cur_rx], RX_RING_SIZE-1
872
        and     [ebx + device.cur_rx], RX_RING_SIZE-1
843
 
873
 
Line 844... Line 874...
844
        jmp     [Eth_input]
874
        jmp     [Eth_input]
845
  .no_rx:
875
  .no_rx: