Subversion Repositories Kolibri OS

Rev

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

Rev 7678 Rev 7679
Line 19... Line 19...
19
;;          GNU GENERAL PUBLIC LICENSE                             ;;
19
;;          GNU GENERAL PUBLIC LICENSE                             ;;
20
;;             Version 2, June 1991                                ;;
20
;;             Version 2, June 1991                                ;;
21
;;                                                                 ;;
21
;;                                                                 ;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 23... Line 23...
23
 
23
 
Line 24... Line 24...
24
$Revision: 7678 $
24
$Revision: 7679 $
25
 
25
 
26
uglobal
26
uglobal
27
        net_10ms        dd ?
27
        net_10ms        dd ?
Line 249... Line 249...
249
 
249
 
250
 
250
 
Line 251... Line 251...
251
uglobal
251
uglobal
252
align 4
252
align 4
Line 253... Line 253...
253
 
253
 
254
        net_running     dd ?
254
        net_device_count        dd ?
Line 255... Line 255...
255
        net_drv_list    rd NET_DEVICES_MAX
255
        net_device_list         rd NET_DEVICES_MAX
Line 288... Line 288...
288
        mov     eax, net_buffs_free
288
        mov     eax, net_buffs_free
289
        stosd
289
        stosd
Line 290... Line 290...
290
 
290
 
291
; Init the network drivers list
291
; Init the network drivers list
292
        xor     eax, eax
292
        xor     eax, eax
293
        mov     edi, net_running
293
        mov     edi, net_device_count
294
        mov     ecx, (NET_DEVICES_MAX + 1)
294
        mov     ecx, (NET_DEVICES_MAX + 1)
Line 295... Line 295...
295
        rep stosd
295
        rep stosd
Line 344... Line 344...
344
        mov     eax, [timer_ticks]
344
        mov     eax, [timer_ticks]
345
        cmp     eax, [net_10ms]
345
        cmp     eax, [net_10ms]
346
        je      .exit
346
        je      .exit
347
        mov     [net_10ms], eax
347
        mov     [net_10ms], eax
Line 348... Line 348...
348
 
348
 
349
        cmp     [net_running], 0
349
        cmp     [net_device_count], 0
Line 350... Line 350...
350
        je      .exit
350
        je      .exit
351
 
351
 
Line 458... Line 458...
458
align 4
458
align 4
459
net_add_device:
459
net_add_device:
Line 460... Line 460...
460
 
460
 
Line 461... Line 461...
461
        DEBUGF  DEBUG_NETWORK_VERBOSE, "net_add_device: %x\n", ebx   ;;; TODO: use mutex to lock net device list
461
        DEBUGF  DEBUG_NETWORK_VERBOSE, "net_add_device: %x\n", ebx   ;;; TODO: use mutex to lock net device list
462
 
462
 
Line 463... Line 463...
463
        cmp     [net_running], NET_DEVICES_MAX
463
        cmp     [net_device_count], NET_DEVICES_MAX
464
        jae     .error
464
        jae     .error
465
 
465
 
466
;----------------------------------
466
;----------------------------------
467
; Check if device is already listed
467
; Check if device is already listed
Line 468... Line 468...
468
        mov     eax, ebx
468
        mov     eax, ebx
469
        mov     ecx, NET_DEVICES_MAX    ; We need to check whole list because a device may be removed without re-organizing list
469
        mov     ecx, NET_DEVICES_MAX    ; We need to check whole list because a device may be removed without re-organizing list
Line 470... Line 470...
470
        mov     edi, net_drv_list
470
        mov     edi, net_device_list
471
 
471
 
472
        repne scasd                     ; See if device is already in the list
472
        repne scasd                     ; See if device is already in the list
473
        jz      .error
473
        jz      .error
474
 
474
 
Line 475... Line 475...
475
;----------------------------
475
;----------------------------
476
; Find empty slot in the list
476
; Find empty slot in the list
Line 477... Line 477...
477
        xor     eax, eax
477
        xor     eax, eax
Line 486... Line 486...
486
;-----------------------------
486
;-----------------------------
487
; Add device to the found slot
487
; Add device to the found slot
488
        mov     [edi], ebx              ; add device to list
488
        mov     [edi], ebx              ; add device to list
Line 489... Line 489...
489
 
489
 
490
        mov     eax, edi                ; Calculate device number in eax
490
        mov     eax, edi                ; Calculate device number in eax
491
        sub     eax, net_drv_list
491
        sub     eax, net_device_list
Line 492... Line 492...
492
        shr     eax, 2
492
        shr     eax, 2
Line 493... Line 493...
493
 
493
 
Line 494... Line 494...
494
        inc     [net_running]           ; Indicate that one more network device is up and running
494
        inc     [net_device_count]      ; Indicate that one more network device is up and running
495
 
495
 
Line 515... Line 515...
515
;                                                                 ;
515
;                                                                 ;
516
;-----------------------------------------------------------------;
516
;-----------------------------------------------------------------;
517
align 4
517
align 4
518
net_remove_device:
518
net_remove_device:
Line 519... Line 519...
519
 
519
 
520
        cmp     [net_running], 0
520
        cmp     [net_device_count], 0
Line 521... Line 521...
521
        je      .error
521
        je      .error
522
 
522
 
Line 523... Line 523...
523
;----------------------------
523
;----------------------------
524
; Find the driver in the list
524
; Find the driver in the list
525
 
525
 
Line 526... Line 526...
526
        mov     eax, ebx
526
        mov     eax, ebx
527
        mov     ecx, NET_DEVICES_MAX
527
        mov     ecx, NET_DEVICES_MAX
Line 528... Line 528...
528
        mov     edi, net_drv_list
528
        mov     edi, net_device_list
529
 
529
 
Line 530... Line 530...
530
        repne scasd
530
        repne scasd
531
        jnz     .error
531
        jnz     .error
532
 
532
 
Line 533... Line 533...
533
;------------------------
533
;------------------------
Line 534... Line 534...
534
; Remove it from the list
534
; Remove it from the list
535
 
535
 
Line 573... Line 573...
573
        test    ebx, ebx
573
        test    ebx, ebx
574
        jz      .fail
574
        jz      .fail
Line 575... Line 575...
575
 
575
 
576
        push    ecx
576
        push    ecx
577
        mov     ecx, NET_DEVICES_MAX
577
        mov     ecx, NET_DEVICES_MAX
578
        mov     edi, net_drv_list
578
        mov     edi, net_device_list
579
  .loop:
579
  .loop:
580
        cmp     ebx, [edi]
580
        cmp     ebx, [edi]
581
        je      .found
581
        je      .found
582
        add     edi, 4
582
        add     edi, 4
Line 587... Line 587...
587
  .fail:
587
  .fail:
588
        or      edi, -1
588
        or      edi, -1
589
        ret
589
        ret
Line 590... Line 590...
590
 
590
 
591
  .found:
591
  .found:
592
        sub     edi, net_drv_list
592
        sub     edi, net_device_list
593
        pop     ecx
593
        pop     ecx
Line 594... Line 594...
594
        ret
594
        ret
595
 
595
 
Line 715... Line 715...
715
sys_network:
715
sys_network:
Line 716... Line 716...
716
 
716
 
717
        cmp     bl, 255
717
        cmp     bl, 255
Line 718... Line 718...
718
        jne     @f
718
        jne     @f
719
 
719
 
720
        mov     eax, [net_running]
720
        mov     eax, [net_device_count]
Line 721... Line 721...
721
        mov     [esp+32], eax
721
        mov     [esp+32], eax
722
        ret
722
        ret
Line 727... Line 727...
727
 
727
 
728
        mov     esi, ebx
728
        mov     esi, ebx
729
        and     esi, 0x0000ff00
729
        and     esi, 0x0000ff00
Line 730... Line 730...
730
        shr     esi, 6
730
        shr     esi, 6
731
 
731
 
Line 732... Line 732...
732
        cmp     dword[esi + net_drv_list], 0    ; check if driver is running
732
        cmp     dword[esi + net_device_list], 0         ; check if device is running
Line 733... Line 733...
733
        je      .doesnt_exist
733
        je      .doesnt_exist
734
 
734
 
735
        mov     eax, [esi + net_drv_list]
735
        mov     eax, [esi + net_device_list]
736
 
736
 
Line 838... Line 838...
838
        jae     .doesnt_exist
838
        jae     .doesnt_exist
Line 839... Line 839...
839
 
839
 
840
        mov     esi, ebx
840
        mov     esi, ebx
841
        and     esi, 0x0000ff00
841
        and     esi, 0x0000ff00
842
        shr     esi, 6                          ; now we have the device num * 4 in esi
842
        shr     esi, 6                          ; now we have the device num * 4 in esi
843
        cmp     [esi + net_drv_list], 0         ; check if driver is running
843
        cmp     [esi + net_device_list], 0      ; check if device is running
Line 844... Line 844...
844
        je      .doesnt_exist
844
        je      .doesnt_exist
Line 845... Line 845...
845
 
845