Subversion Repositories Kolibri OS

Rev

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

Rev 3600 Rev 3601
Line 215... Line 215...
215
 
215
 
216
align 4
216
align 4
Line 217... Line 217...
217
uglobal
217
uglobal
218
 
-
 
219
        NET_RUNNING     dd  ?
218
 
Line 220... Line 219...
220
        NET_DEFAULT     dd  ?
219
        NET_RUNNING     dd  ?
Line 252... Line 251...
252
        UDP_init
251
        UDP_init
253
        TCP_init
252
        TCP_init
Line 254... Line 253...
254
 
253
 
Line -... Line 254...
-
 
254
        SOCKET_init
-
 
255
 
255
        SOCKET_init
256
        LOOP_init
Line 256... Line 257...
256
 
257
 
Line 310... Line 311...
310
 
311
 
311
 
312
 
Line 312... Line 313...
312
align 4
313
align 4
Line 313... Line 314...
313
NET_link_changed:
314
NET_link_changed:
314
 
315
 
Line 315... Line 316...
315
        DEBUGF  DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.state]
316
        DEBUGF  DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
Line 396... Line 397...
396
 
397
 
397
;-----------------------------------------------------------------
398
;-----------------------------------------------------------------
398
;
399
;
399
; NET_Remove_Device:
400
; NET_Remove_Device:
400
;
401
;
401
;  This function is called by etwork drivers,
402
;  This function is called by network drivers,
402
;  to unregister network devices from the kernel
403
;  to unregister network devices from the kernel
403
;
404
;
404
;  IN:  Pointer to device structure in ebx
405
;  IN:  Pointer to device structure in ebx
405
;  OUT: eax: -1 on error
406
;  OUT: eax: -1 on error
Line 409... Line 410...
409
NET_remove_device:
410
NET_remove_device:
Line 410... Line 411...
410
 
411
 
411
        cmp     [NET_RUNNING], 0
412
        cmp     [NET_RUNNING], 0
Line 412... Line -...
412
        je      .error
-
 
413
 
-
 
414
        cmp     [NET_DRV_LIST], ebx
-
 
415
        jne     @f
-
 
416
        mov     [NET_DRV_LIST], 0
-
 
417
        cmp     [NET_RUNNING], 1
-
 
418
        je      @f
-
 
419
        ; there are still active devices, find one and make it default
-
 
420
        xor     eax, eax
-
 
421
        mov     ecx, NET_DEVICES_MAX
-
 
422
        mov     edi, NET_DRV_LIST
-
 
423
        repe    scasd
-
 
424
        je      @f
-
 
425
        shr     edi, 2
-
 
426
        dec     edi
-
 
427
        mov     [NET_DEFAULT], edi
-
 
428
       @@:
413
        je      .error
429
 
414
 
Line 430... Line 415...
430
;----------------------------
415
;----------------------------
431
; Find the driver in the list
416
; Find the driver in the list
432
 
417
 
Line 433... Line 418...
433
        mov     eax, ebx
418
        mov     eax, ebx
434
        mov     ecx, NET_DEVICES_MAX
419
        mov     ecx, NET_DEVICES_MAX
Line 435... Line 420...
435
        mov     edi, NET_DRV_LIST+4
420
        mov     edi, NET_DRV_LIST
436
 
421
 
Line 437... Line 422...
437
        repne   scasd
422
        repne   scasd
438
        jnz     .error
423
        jnz     .error
-
 
424
 
Line 439... Line 425...
439
 
425
;------------------------
Line 440... Line 426...
440
;------------------------
426
; Remove it from the list
441
; Remove it from the list
427
 
Line 442... Line 428...
442
 
428
        xor     eax, eax
443
        xor     eax, eax
429
        mov     dword [edi-4], eax
444
        mov     dword [edi-4], eax
430
        dec     [NET_RUNNING]
Line 608... Line 594...
608
 
594
 
609
 
595
 
610
 
596
 
611
;----------------------------------------------------------------
597
;----------------------------------------------------------------
612
;
598
;
613
;  System function to work with network devices (75)
599
;  System function to work with network devices (74)
614
;
600
;
Line 615... Line 601...
615
;----------------------------------------------------------------
601
;----------------------------------------------------------------
616
align 4
602
align 4
Line 617... Line 603...
617
sys_network:                    ; FIXME: make default device easily accessible
603
sys_network:
618
 
604
 
-
 
605
        cmp     ebx, -1
Line 619... Line 606...
619
        cmp     ebx, -1
606
        jne     @f
620
        jne     @f
607
 
621
 
608
        mov     eax, [NET_RUNNING]
Line 645... Line 632...
645
        dd      .get_dev_name           ; 1
632
        dd      .get_dev_name           ; 1
646
        dd      .reset                  ; 2
633
        dd      .reset                  ; 2
647
        dd      .stop                   ; 3
634
        dd      .stop                   ; 3
648
        dd      .get_ptr                ; 4
635
        dd      .get_ptr                ; 4
649
        dd      .get_drv_name           ; 5
636
        dd      .get_drv_name           ; 5
650
  .number = ($ - .table) / 4 - 1
-
 
Line -... Line 637...
-
 
637
 
-
 
638
        dd      .packets_tx             ; 6
-
 
639
        dd      .packets_rx             ; 7
-
 
640
        dd      .bytes_tx               ; 8
651
 
641
        dd      .bytes_rx               ; 9
-
 
642
        dd      .state                  ; 10
Line -... Line 643...
-
 
643
  .number = ($ - .table) / 4 - 1
652
  .get_type:                            ; 0 = Get device type (ethernet/token ring/...)
644
 
653
 
645
  .get_type:
654
        mov     eax, [eax + NET_DEVICE.device_type]
-
 
655
        jmp     .return
-
 
656
 
646
        mov     eax, [eax + NET_DEVICE.device_type]
Line -... Line 647...
-
 
647
        mov     [esp+32], eax
657
 
648
        ret
658
  .get_dev_name:                        ; 1 = Get device name
649
 
Line 659... Line 650...
659
 
650
  .get_dev_name:
660
        mov     esi, [eax + NET_DEVICE.name]
651
        mov     esi, [eax + NET_DEVICE.name]
Line 661... Line 652...
661
        mov     edi, ecx
652
        mov     edi, ecx
662
 
653
 
663
        mov     ecx, 64/4 ; max length
-
 
664
        rep     movsd
654
        mov     ecx, 64/4 ; max length
Line -... Line 655...
-
 
655
        rep     movsd
665
 
656
 
666
        xor     eax, eax
657
        xor     eax, eax
667
        jmp     .return
-
 
668
 
658
        mov     [esp+32], eax
Line -... Line 659...
-
 
659
        ret
669
  .reset:                               ; 2 = Reset the device
660
 
670
 
661
  .reset:
-
 
662
        call    [eax + NET_DEVICE.reset]
Line -... Line 663...
-
 
663
        mov     [esp+32], eax
671
        call    [eax + NET_DEVICE.reset]
664
        ret
-
 
665
 
Line 672... Line -...
672
        jmp     .return
-
 
Line -... Line 666...
-
 
666
  .stop:
-
 
667
        call    [eax + NET_DEVICE.unload]
-
 
668
        mov     [esp+32], eax
-
 
669
        ret
Line -... Line 670...
-
 
670
 
673
 
671
 
-
 
672
  .get_ptr:
-
 
673
        mov     [esp+32], eax
Line -... Line 674...
-
 
674
        ret
-
 
675
 
674
  .stop:                                ; 3 = Stop driver for this device
676
 
675
 
677
  .get_drv_name:
Line -... Line 678...
-
 
678
        xor     eax, eax
-
 
679
        mov     [esp+32], eax
-
 
680
        ret
-
 
681
 
-
 
682
  .packets_tx:
-
 
683
        mov     eax, [eax + NET_DEVICE.packets_tx]
Line 676... Line 684...
676
        call    [eax + NET_DEVICE.unload]
684
        mov     [esp+32], eax
-
 
685
        ret
-
 
686
 
-
 
687
  .packets_rx:
677
        jmp     .return
688
        mov     eax, [eax + NET_DEVICE.packets_rx]
-
 
689
        mov     [esp+32], eax
Line 678... Line 690...
678
 
690
        ret
-
 
691
 
679
 
692
  .bytes_tx:
680
  .get_ptr:                             ; 4 = Get driver pointer
693
        mov     ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
Line -... Line 694...
-
 
694
        mov     [esp+20], ebx
-
 
695
        mov     eax, dword [eax + NET_DEVICE.bytes_tx]
-
 
696
        mov     [esp+32], eax
-
 
697
        ret
-
 
698
 
-
 
699
  .bytes_rx:
681
 
700
        mov     ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
682
        jmp     .return
701
        mov     [esp+20], ebx
683
 
702
        mov     eax, dword [eax + NET_DEVICE.bytes_rx]
684
 
703
        mov     [esp+32], eax
685
  .get_drv_name:                        ; 5 = Get driver name
704
        ret