From d5c54dd1d0b9c57aa3aede7f15968f9c246c7866 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Fri, 2 Oct 2009 19:49:42 +0000 Subject: [PATCH] Fixes in netstat/zeroconf update of netcfg git-svn-id: svn://kolibrios.org@1192 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../net/applications/netcfg/netcfg.asm | 92 ++++++++----------- .../net/applications/netstat/netstat.asm | 87 +++++++++++------- .../net/applications/zeroconf/zeroconf.asm | 6 +- kernel/branches/net/network/stack.inc | 35 +++++-- 4 files changed, 126 insertions(+), 94 deletions(-) diff --git a/kernel/branches/net/applications/netcfg/netcfg.asm b/kernel/branches/net/applications/netcfg/netcfg.asm index fe8bbc9b6a..2e65397e48 100644 --- a/kernel/branches/net/applications/netcfg/netcfg.asm +++ b/kernel/branches/net/applications/netcfg/netcfg.asm @@ -44,11 +44,15 @@ button: ; button cmp ah, 4 je hook + cmp ah, 5 + je reset + + cmp ah, 6 + je unload + jmp still @@: shr eax, 16 - mov dword[MAC],0 - mov word [MAC+4],0 mov word [selected], ax call load_drv @@ -97,19 +101,25 @@ hook: mov byte[drivernumber], al -printhdwaddr: +reset: + movzx ebx, byte[drivernumber] + mcall 73,,2 - call draw_window + ret - jmp still +unload: + movzx ebx, byte[drivernumber] + mcall 73,,3 + + ret draw_window: mcall 12, 1 ; start of draw mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title - mcall 73, 0 - mov ecx, eax - mcall 47, 1 shl 18, , 50 shl 16 + 10, 0x00000000 +; mcall 73, 1, +; mov ecx, eax +; mcall 47, 1 shl 18, , 50 shl 16 + 10, 0x00000000 call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device @@ -118,49 +128,22 @@ draw_window: mcall 4, 20 shl 16 + 100, 1 shl 31 + 0x00000000 , caption - mcall 8, 122 shl 16 + 100, 50 shl 16 + 18, 0x00000004, 0x00007f00 - mcall ,, 70 shl 16 + 18, 0x00000005, 0x007f0000 + mov ax , [selected] + test ax, ax + jz .done - mcall 4, 137 shl 16 + 57, 1 shl 31 + 0x00ffffff , btn_start - mcall , 140 shl 16 + 77, , btn_stop + mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00 + mcall ,, 55 shl 16 + 18, 5, 0x0000007f + mcall ,, 75 shl 16 + 18, 6, 0x007f0000 - mcall , 240 shl 16 + 77, 1 shl 31 + 0x00000000 , lbl_hdw_addr - mcall , 312 shl 16 + 57, , lbl_type - add ebx, 38 shl 16 - cmp byte [type],type_ethernet - jne @f - mcall , , 1 shl 31 + 0x00000000, lbl_ethernet + mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start + mcall , 33 shl 16 + 62, , btn_reset + mcall , 36 shl 16 + 82, , btn_stop - mcall 8,345 shl 16 + 17, 73 shl 16 + 14, 0x00000006, 0x00aaaa00 - mcall ,365 shl 16 + 17, , 0x00000007 - mcall ,385 shl 16 + 17, , 0x00000008 - mcall ,405 shl 16 + 17, , 0x00000009 - mcall ,425 shl 16 + 17, , 0x0000000a - mcall ,445 shl 16 + 17, , 0x0000000b - movzx ecx,byte[MAC] - mcall 47, 1 shl 17 + 1 shl 8,,349 shl 16 + 77, 0x000022cc - movzx ecx,byte[MAC+1] - add edx, 20 shl 16 - mcall - movzx ecx,byte[MAC+2] - add edx, 20 shl 16 - mcall - movzx ecx,byte[MAC+3] - add edx, 20 shl 16 - mcall - movzx ecx,byte[MAC+4] - add edx, 20 shl 16 - mcall - movzx ecx,byte[MAC+5] - add edx, 20 shl 16 - mcall +; mcall , 140 shl 16 + 62, 1 shl 31 + 0x00000000 , devicename jmp .done - @@: - mcall 4, , 1 shl 31 + 0x00ff0000, lbl_unknown - jmp .done - .nonefound : mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound .done: @@ -411,15 +394,20 @@ Form: dw 800 ; window width (no more, special for 800x600) title db 'Network Driver Control Center', 0 caption db 'Vendor Device Bus Dev Rev IRQ Company Description DRIVER',0 -lbl_1 db 'Hardware control',0 +;lbl_1 db 'Hardware control',0 nonefound db 'No compatible devices were found!',0 -btn_start db 'Start driver',0 -btn_stop db 'Stop driver',0 -lbl_hdw_addr db 'hardware address:',0 -lbl_type db 'type:',0 +btn_start db 'Start device',0 +btn_reset db 'Reset device',0 +btn_stop db 'Stop device',0 +;lbl_hdw_addr db 'hardware address:',0 +;lbl_type db 'type:',0 lbl_none db 'none',0 -lbl_unknown db 'unknown',0 -lbl_ethernet db 'ethernet',0 +;lbl_unknown db 'unknown',0 +;lbl_ethernet db 'ethernet',0 + +devicename db 'test' +rb 64 + db 0 IOCTL: diff --git a/kernel/branches/net/applications/netstat/netstat.asm b/kernel/branches/net/applications/netstat/netstat.asm index 998bc4dbd8..ad683d03ef 100644 --- a/kernel/branches/net/applications/netstat/netstat.asm +++ b/kernel/branches/net/applications/netstat/netstat.asm @@ -1,5 +1,5 @@ ; -; Netstat for KolibriOS v0.1 +; Netstat for KolibriOS v0.1 (still alpha version) ; ; hidnplayr@gmail.com ; @@ -11,10 +11,10 @@ use32 db 'MENUET01' ; 8 byte id dd 0x01 ; header version dd START ; start of code - dd I_END ; size of image - dd IM_END ; memory for app - dd IM_END ; esp - dd I_PARAM , 0x0 ; I_Param , I_Icon + dd IM_END ; size of image + dd (I_END+0x100) ; memory for app + dd (I_END+0x100) ; esp + dd I_PARAM , 0x0 ; I_Param , I_Icon __DEBUG__ equ 1 __DEBUG_LEVEL__ equ 1 @@ -79,8 +79,6 @@ START: ; start of execution mov edx, str_queue_out mcall - push end_of_draw - mov ebx,1337 shl 16 + 4 mov bh, [device] mcall 75 @@ -88,7 +86,8 @@ START: ; start of execution push bx mov edx, 135 shl 16 + 75 + 4*18 - jmp draw_mac + call draw_mac + jmp end_of_draw @@: @@ -201,18 +200,21 @@ START: ; start of execution mov ebx, 1337 shl 16 + 0 mov bh, [device] @@: + push ebx mcall 75 + pop ebx push eax inc bl cmp bl, 3 jle @r - - inc bl - inc bl + inc bl ;5 + inc bl ;6 @@: + push ebx mcall 75 + pop ebx push eax inc bl cmp bl, 7 @@ -251,10 +253,14 @@ START: ; start of execution mov ebx, 0 shl 16 mov bh, [device] + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl @@ -279,13 +285,19 @@ START: ; start of execution mov ebx, 0x0608 shl 16 + 0 mov bh, [device] + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl @@ -312,10 +324,14 @@ not_103: mov ebx, 1 shl 16 + 0 mov bh, [device] + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl @@ -339,10 +355,14 @@ not_104: mov ebx, 17 shl 16 + 0 mov bh, [device] + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl @@ -366,10 +386,14 @@ not_105: mov ebx, 6 shl 16 + 0 mov bh, [device] + push ebx mcall 75 + pop ebx push eax inc bl + push ebx mcall 75 + pop ebx push eax inc bl @@ -414,33 +438,34 @@ draw_mac: mov esi, 0x40000000 mov edi, 0x00bcbcbc - mov cl, [esp] - mcall - - mov cl, [esp+1] - add edx, 15 shl 16 - mcall - - mov cl, [esp+2] - add edx, 15 shl 16 - mcall - - mov cl, [esp+3] - add edx, 15 shl 16 - mcall - mov cl, [esp+4] + mcall + + mov cl, [esp+4+1] add edx, 15 shl 16 mcall - mov cl, [esp+5] + mov cl, [esp+4+2] add edx, 15 shl 16 mcall - add esp, 6 + mov cl, [esp+4+3] + add edx, 15 shl 16 + mcall + + mov cl, [esp+4+4] + add edx, 15 shl 16 + mcall + + mov cl, [esp+4+5] + add edx, 15 shl 16 + mcall + + mov eax, [esp] + add esp, 6+4 sub edx, 5*15 shl 16 - ret + jmp eax draw_ip: @@ -475,7 +500,7 @@ draw_ip: ; DATA AREA -I_END: +IM_END: name db 'Netstat',0 mode db 101 @@ -499,6 +524,6 @@ include_debug_strings ; ALWAYS present in data section I_PARAM rb 1024 -IM_END: +I_END: diff --git a/kernel/branches/net/applications/zeroconf/zeroconf.asm b/kernel/branches/net/applications/zeroconf/zeroconf.asm index 93bfd0a5c2..3efbac2f34 100644 --- a/kernel/branches/net/applications/zeroconf/zeroconf.asm +++ b/kernel/branches/net/applications/zeroconf/zeroconf.asm @@ -12,9 +12,9 @@ use32 dd 0x01 ; header version dd START ; start of code dd IM_END ; size of image - dd I_END ; memory for app - dd I_END ; esp - dd 0x0 , path ; I_Param , I_Icon + dd (I_END+0x100) ; memory for app + dd (I_END+0x100) ; esp + dd 0x0 , path ; I_Param , I_Icon ; CONFIGURATION diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index 725957aa80..22e8b78f38 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -119,7 +119,7 @@ stack_handler: je .exit mov [last_1hsTick], eax -; call tcp_tx_handler + call tcp_tx_handler .sec_tick: @@ -134,7 +134,7 @@ stack_handler: call ARP_decrease_entry_ttls call IPv4_decrease_fragment_ttls -; call tcp_tcb_handler + call tcp_tcb_handler .exit: ret @@ -201,7 +201,8 @@ sys_network: test bl, bl ; 0 = Get device type (ethernet/token ring/...) jnz @f - ;TODO: write code here + xor eax, eax + jmp .return @@: @@ -215,20 +216,38 @@ sys_network: mov ecx, 64 ; max length repnz movsb - ret - - ; TODO: create function wich outputs number of active network devices + xor eax, eax + jmp .return @@: + + dec bl ; 2 = Reset the device + jnz @f + + mov esi, [esi + ETH_DRV_LIST] + call [esi + ETH_DEVICE.reset] + jmp .return + + @@: + + dec bl ; 3 = Stop driver for this device + jnz @f + + mov esi, [esi + ETH_DRV_LIST] + call [esi + ETH_DEVICE.unload] + jmp .return + + @@: + .doesnt_exist: DEBUGF 1,"sys_network: invalid device/function specified!\n" mov eax, -1 + .return: + mov [esp+28+4], eax ret - - ;---------------------------------------------------------------- ; ; System Function To work with Protocols (75)