diff --git a/kernel/branches/net/applications/arpcfg/arpcfg.asm b/kernel/branches/net/applications/arpcfg/arpcfg.asm index 8c22b41c08..a288130010 100644 --- a/kernel/branches/net/applications/arpcfg/arpcfg.asm +++ b/kernel/branches/net/applications/arpcfg/arpcfg.asm @@ -35,27 +35,12 @@ START: ; start of execution mcall 4, 25 shl 16 + 31, 0x80000000, title -;; call draw_stats - mcall 12, 2 - jmp draw_stats - - mainloop: - - mcall 23,50 ; wait for event with timeout (0,5 s) - - cmp eax, 1 - je redraw - cmp eax, 2 - je key - cmp eax, 3 - je button - - draw_stats: mov edx, 50 shl 16 + 50 + mov [last],0 .loop: mcall 75, 0x06080003, [last],,,ARP_ENTRY @@ -130,6 +115,19 @@ START: ; start of execution jmp .loop + mainloop: + + mcall 23,50 ; wait for event with timeout (0,5 s) + + cmp eax, 1 + je redraw + cmp eax, 2 + je key + cmp eax, 3 + je button + + jmp draw_stats + key: mcall 2 diff --git a/kernel/branches/net/applications/nslookup/nslookup.asm b/kernel/branches/net/applications/nslookup/nslookup.asm index 7456c6e7c3..14ca91688f 100644 --- a/kernel/branches/net/applications/nslookup/nslookup.asm +++ b/kernel/branches/net/applications/nslookup/nslookup.asm @@ -20,7 +20,7 @@ include '../network_lib/network.inc' ; entry point start: ; load libraries - stdcall dll.Load, @IMPORT + stdcall dll.Load, @IMPORT test eax, eax jnz exit ; initialize console @@ -116,10 +116,10 @@ str5 db 'Name resolution failed.',10,0 align 4 @IMPORT: -library network, 'network.obj', console, 'console.obj' +library network, 'network.obj', console, 'console.obj' import network, \ getaddrinfo, 'getaddrinfo', \ - freeaddrinfo, 'freeaddrinfo', \ + freeaddrinfo, 'freeaddrinfo', \ inet_ntoa, 'inet_ntoa' import console, \ con_start, 'START', \ diff --git a/kernel/branches/net/blkdev/cd_drv.inc b/kernel/branches/net/blkdev/cd_drv.inc index 4eea37212d..7585e677c2 100644 --- a/kernel/branches/net/blkdev/cd_drv.inc +++ b/kernel/branches/net/blkdev/cd_drv.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 758 $ +$Revision$ ;********************************************************** diff --git a/kernel/branches/net/blkdev/cdrom.inc b/kernel/branches/net/blkdev/cdrom.inc index 675342c20d..d7a9370664 100644 --- a/kernel/branches/net/blkdev/cdrom.inc +++ b/kernel/branches/net/blkdev/cdrom.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ sys_cd_audio: diff --git a/kernel/branches/net/blkdev/fdc.inc b/kernel/branches/net/blkdev/fdc.inc index 85e8db197b..65f4af9402 100644 --- a/kernel/branches/net/blkdev/fdc.inc +++ b/kernel/branches/net/blkdev/fdc.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 766 $ +$Revision$ iglobal diff --git a/kernel/branches/net/blkdev/flp_drv.inc b/kernel/branches/net/blkdev/flp_drv.inc index 2253f30fc7..127bfe48e0 100644 --- a/kernel/branches/net/blkdev/flp_drv.inc +++ b/kernel/branches/net/blkdev/flp_drv.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ;********************************************************** diff --git a/kernel/branches/net/blkdev/hd_drv.inc b/kernel/branches/net/blkdev/hd_drv.inc index b46d22ed50..016f4a2166 100644 --- a/kernel/branches/net/blkdev/hd_drv.inc +++ b/kernel/branches/net/blkdev/hd_drv.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 820 $ +$Revision$ ; Low-level driver for HDD access diff --git a/kernel/branches/net/blkdev/ide_cache.inc b/kernel/branches/net/blkdev/ide_cache.inc index 2d0463027f..453cbf6a26 100644 --- a/kernel/branches/net/blkdev/ide_cache.inc +++ b/kernel/branches/net/blkdev/ide_cache.inc @@ -21,7 +21,7 @@ ; ;************************************************************************** -$Revision: 750 $ +$Revision$ align 4 diff --git a/kernel/branches/net/blkdev/rd.inc b/kernel/branches/net/blkdev/rd.inc index 686bbdf9e0..2b6b49d12d 100644 --- a/kernel/branches/net/blkdev/rd.inc +++ b/kernel/branches/net/blkdev/rd.inc @@ -9,7 +9,7 @@ ;; LFN support by diamond ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1021 $ +$Revision$ ; calculate fat chain diff --git a/kernel/branches/net/blkdev/rdsave.inc b/kernel/branches/net/blkdev/rdsave.inc index 6cc2c8ca8d..2e9396e415 100644 --- a/kernel/branches/net/blkdev/rdsave.inc +++ b/kernel/branches/net/blkdev/rdsave.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 684 $ +$Revision$ iglobal diff --git a/kernel/branches/net/boot/bootcode.inc b/kernel/branches/net/boot/bootcode.inc index c1299165cc..8a9c6e2ea5 100644 --- a/kernel/branches/net/boot/bootcode.inc +++ b/kernel/branches/net/boot/bootcode.inc @@ -11,7 +11,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1018 $ +$Revision$ ;========================================================================== diff --git a/kernel/branches/net/boot/booteng.inc b/kernel/branches/net/boot/booteng.inc index 618709f655..4c14a2d2e3 100644 --- a/kernel/branches/net/boot/booteng.inc +++ b/kernel/branches/net/boot/booteng.inc @@ -11,7 +11,7 @@ ; ;====================================================================== -$Revision: 750 $ +$Revision$ d80x25_bottom: diff --git a/kernel/branches/net/boot/bootet.inc b/kernel/branches/net/boot/bootet.inc index 95f62ea845..414efdf381 100644 --- a/kernel/branches/net/boot/bootet.inc +++ b/kernel/branches/net/boot/bootet.inc @@ -11,7 +11,7 @@ ; ;====================================================================== -$Revision: 750 $ +$Revision$ d80x25_bottom: diff --git a/kernel/branches/net/boot/bootge.inc b/kernel/branches/net/boot/bootge.inc index 7c852f8a7d..2ea4959f19 100644 --- a/kernel/branches/net/boot/bootge.inc +++ b/kernel/branches/net/boot/bootge.inc @@ -11,7 +11,7 @@ ; ;====================================================================== -$Revision: 750 $ +$Revision$ d80x25_bottom: diff --git a/kernel/branches/net/boot/bootru.inc b/kernel/branches/net/boot/bootru.inc index 8f0253aab6..4e85269a6a 100644 --- a/kernel/branches/net/boot/bootru.inc +++ b/kernel/branches/net/boot/bootru.inc @@ -11,7 +11,7 @@ ; ;================================================================= -$Revision: 751 $ +$Revision$ d80x25_bottom: diff --git a/kernel/branches/net/boot/bootstr.inc b/kernel/branches/net/boot/bootstr.inc index 30ba0e3f46..bf71fb7a9e 100644 --- a/kernel/branches/net/boot/bootstr.inc +++ b/kernel/branches/net/boot/bootstr.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; boot data: common strings (for all languages) diff --git a/kernel/branches/net/boot/bootvesa.inc b/kernel/branches/net/boot/bootvesa.inc index e3461338db..aaef71888b 100644 --- a/kernel/branches/net/boot/bootvesa.inc +++ b/kernel/branches/net/boot/bootvesa.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 947 $ +$Revision$ struc VBE_VGAInfo { .VESASignature dd ? ; char diff --git a/kernel/branches/net/boot/et.inc b/kernel/branches/net/boot/et.inc index 9df247c3cf..83fc44f2b6 100644 --- a/kernel/branches/net/boot/et.inc +++ b/kernel/branches/net/boot/et.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; Full ASCII code font diff --git a/kernel/branches/net/boot/preboot.inc b/kernel/branches/net/boot/preboot.inc index de4567c154..73fbbcfaf5 100644 --- a/kernel/branches/net/boot/preboot.inc +++ b/kernel/branches/net/boot/preboot.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 767 $ +$Revision$ display_modechg db 0 ; display mode change for text, yes/no (0 or 2) diff --git a/kernel/branches/net/boot/rdload.inc b/kernel/branches/net/boot/rdload.inc index a62a6343ee..b9c9c96561 100644 --- a/kernel/branches/net/boot/rdload.inc +++ b/kernel/branches/net/boot/rdload.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ; READ RAMDISK IMAGE FROM HD diff --git a/kernel/branches/net/boot/ru.inc b/kernel/branches/net/boot/ru.inc index d21943ea1c..aa59d6f6a9 100644 --- a/kernel/branches/net/boot/ru.inc +++ b/kernel/branches/net/boot/ru.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 774 $ +$Revision$ ; Generated by RUFNT.EXE diff --git a/kernel/branches/net/boot/shutdown.inc b/kernel/branches/net/boot/shutdown.inc index 813ea2bb12..3e3679cafd 100644 --- a/kernel/branches/net/boot/shutdown.inc +++ b/kernel/branches/net/boot/shutdown.inc @@ -11,7 +11,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 748 $ +$Revision$ align 4 diff --git a/kernel/branches/net/bus/pci/pci16.inc b/kernel/branches/net/bus/pci/pci16.inc index bb04d80d58..211fabf2fd 100644 --- a/kernel/branches/net/bus/pci/pci16.inc +++ b/kernel/branches/net/bus/pci/pci16.inc @@ -15,7 +15,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ init_pci_16: diff --git a/kernel/branches/net/bus/pci/pci32.inc b/kernel/branches/net/bus/pci/pci32.inc index d88166a0de..e9752b2d10 100644 --- a/kernel/branches/net/bus/pci/pci32.inc +++ b/kernel/branches/net/bus/pci/pci32.inc @@ -21,7 +21,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ;*************************************************************************** ; Function diff --git a/kernel/branches/net/const.inc b/kernel/branches/net/const.inc index a00b078993..957d5a5820 100644 --- a/kernel/branches/net/const.inc +++ b/kernel/branches/net/const.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ dpl0 equ 10010000b ; data read dpl0 diff --git a/kernel/branches/net/core/conf_lib.inc b/kernel/branches/net/core/conf_lib.inc index 9968d531a8..3f62c3e42e 100644 --- a/kernel/branches/net/core/conf_lib.inc +++ b/kernel/branches/net/core/conf_lib.inc @@ -10,7 +10,7 @@ ; {SPraid.simba} ;------------------------------------------------------------------------- -$Revision: 802 $ +$Revision$ conf_path_sect: db 'path',0 diff --git a/kernel/branches/net/core/debug.inc b/kernel/branches/net/core/debug.inc index c6ca66eb37..15d0b9c178 100644 --- a/kernel/branches/net/core/debug.inc +++ b/kernel/branches/net/core/debug.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; diamond, 2006 diff --git a/kernel/branches/net/core/dll.inc b/kernel/branches/net/core/dll.inc index c98ce788c8..5e5d7b689a 100644 --- a/kernel/branches/net/core/dll.inc +++ b/kernel/branches/net/core/dll.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1018 $ +$Revision$ DRV_COMPAT equ 5 ;minimal required drivers version diff --git a/kernel/branches/net/core/export.inc b/kernel/branches/net/core/export.inc index 619dc5f41b..edb5c373b9 100644 --- a/kernel/branches/net/core/export.inc +++ b/kernel/branches/net/core/export.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; Macroinstruction for making export section diff --git a/kernel/branches/net/core/exports.inc b/kernel/branches/net/core/exports.inc index e634f09a2f..28e6db3431 100644 --- a/kernel/branches/net/core/exports.inc +++ b/kernel/branches/net/core/exports.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 924 $ +$Revision$ iglobal diff --git a/kernel/branches/net/core/ext_lib.inc b/kernel/branches/net/core/ext_lib.inc index 2a61f3ed00..673bd5c6a1 100644 --- a/kernel/branches/net/core/ext_lib.inc +++ b/kernel/branches/net/core/ext_lib.inc @@ -11,7 +11,7 @@ ; ;============================================================================ -$Revision: 750 $ +$Revision$ macro library [name,fname] diff --git a/kernel/branches/net/core/fpu.inc b/kernel/branches/net/core/fpu.inc index 25a86a29e4..5b11e0aa83 100644 --- a/kernel/branches/net/core/fpu.inc +++ b/kernel/branches/net/core/fpu.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ init_fpu: diff --git a/kernel/branches/net/core/heap.inc b/kernel/branches/net/core/heap.inc index c6f732acd4..7b3f0b69b0 100644 --- a/kernel/branches/net/core/heap.inc +++ b/kernel/branches/net/core/heap.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ struc MEM_BLOCK diff --git a/kernel/branches/net/core/malloc.inc b/kernel/branches/net/core/malloc.inc index 15e496d92d..0b9bfd3b8b 100644 --- a/kernel/branches/net/core/malloc.inc +++ b/kernel/branches/net/core/malloc.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 753 $ +$Revision$ ; Small heap based on malloc/free/realloc written by Doug Lea diff --git a/kernel/branches/net/core/memory.inc b/kernel/branches/net/core/memory.inc index 40736abd64..0500134586 100644 --- a/kernel/branches/net/core/memory.inc +++ b/kernel/branches/net/core/memory.inc @@ -5,183 +5,183 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ align 4 proc alloc_page - pushfd - cli - push ebx - mov ebx, [page_start] - mov ecx, [page_end] + pushfd + cli + push ebx + mov ebx, [page_start] + mov ecx, [page_end] .l1: - bsf eax,[ebx]; - jnz .found - add ebx,4 - cmp ebx, ecx - jb .l1 - pop ebx - popfd - xor eax,eax - ret + bsf eax,[ebx]; + jnz .found + add ebx,4 + cmp ebx, ecx + jb .l1 + pop ebx + popfd + xor eax,eax + ret .found: - btr [ebx], eax - mov [page_start],ebx - sub ebx, sys_pgmap - lea eax, [eax+ebx*8] - shl eax, 12 - dec [pg_data.pages_free] - pop ebx - popfd - ret + btr [ebx], eax + mov [page_start],ebx + sub ebx, sys_pgmap + lea eax, [eax+ebx*8] + shl eax, 12 + dec [pg_data.pages_free] + pop ebx + popfd + ret endp align 4 proc alloc_pages stdcall, count:dword - pushfd - push ebx - push edi - cli - mov eax, [count] - add eax, 7 - shr eax, 3 - mov [count], eax - cmp eax, [pg_data.pages_free] - ja .fail + pushfd + push ebx + push edi + cli + mov eax, [count] + add eax, 7 + shr eax, 3 + mov [count], eax + cmp eax, [pg_data.pages_free] + ja .fail - mov ecx, [page_start] - mov ebx, [page_end] + mov ecx, [page_start] + mov ebx, [page_end] .find: - mov edx, [count] - mov edi, ecx + mov edx, [count] + mov edi, ecx .match: - cmp byte [ecx], 0xFF - jne .next - dec edx - jz .ok - inc ecx - cmp ecx,ebx - jb .match + cmp byte [ecx], 0xFF + jne .next + dec edx + jz .ok + inc ecx + cmp ecx,ebx + jb .match .fail: - xor eax, eax - pop edi - pop ebx - popfd - ret + xor eax, eax + pop edi + pop ebx + popfd + ret .next: - inc ecx - cmp ecx, ebx - jb .find - pop edi - pop ebx - popfd - xor eax, eax - ret + inc ecx + cmp ecx, ebx + jb .find + pop edi + pop ebx + popfd + xor eax, eax + ret .ok: - sub ecx, edi - inc ecx - push esi - mov esi, edi - xor eax, eax - rep stosb - sub esi, sys_pgmap - shl esi, 3+12 - mov eax, esi - mov ebx, [count] - shl ebx, 3 - sub [pg_data.pages_free], ebx - pop esi - pop edi - pop ebx - popfd - ret + sub ecx, edi + inc ecx + push esi + mov esi, edi + xor eax, eax + rep stosb + sub esi, sys_pgmap + shl esi, 3+12 + mov eax, esi + mov ebx, [count] + shl ebx, 3 + sub [pg_data.pages_free], ebx + pop esi + pop edi + pop ebx + popfd + ret endp align 4 proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword - push ebx - mov eax, [phis_addr] - and eax, not 0xFFF - or eax, [flags] - mov ebx, [lin_addr] - shr ebx, 12 - mov [page_tabs+ebx*4], eax - mov eax, [lin_addr] - invlpg [eax] - pop ebx - ret + push ebx + mov eax, [phis_addr] + and eax, not 0xFFF + or eax, [flags] + mov ebx, [lin_addr] + shr ebx, 12 + mov [page_tabs+ebx*4], eax + mov eax, [lin_addr] + invlpg [eax] + pop ebx + ret endp align 4 map_space: ;not implemented - ret + ret align 4 proc free_page ;arg: eax page address - pushfd - cli - shr eax, 12 ;page index - bts dword [sys_pgmap], eax ;that's all! - cmc - adc [pg_data.pages_free], 0 - shr eax, 3 - and eax, not 3 ;dword offset from page_map - add eax, sys_pgmap - cmp [page_start], eax - ja @f - popfd - ret + pushfd + cli + shr eax, 12 ;page index + bts dword [sys_pgmap], eax ;that's all! + cmc + adc [pg_data.pages_free], 0 + shr eax, 3 + and eax, not 3 ;dword offset from page_map + add eax, sys_pgmap + cmp [page_start], eax + ja @f + popfd + ret @@: - mov [page_start], eax - popfd - ret + mov [page_start], eax + popfd + ret endp proc map_io_mem stdcall, base:dword, size:dword, flags:dword - push ebx - push edi - mov eax, [size] - add eax, 4095 - and eax, -4096 - mov [size], eax - stdcall alloc_kernel_space, eax - test eax, eax - jz .fail - push eax + push ebx + push edi + mov eax, [size] + add eax, 4095 + and eax, -4096 + mov [size], eax + stdcall alloc_kernel_space, eax + test eax, eax + jz .fail + push eax - mov edi, 0x1000 - mov ebx, eax - mov ecx,[size] - mov edx, [base] - shr eax, 12 - shr ecx, 12 - and edx, -4096 - or edx, [flags] + mov edi, 0x1000 + mov ebx, eax + mov ecx,[size] + mov edx, [base] + shr eax, 12 + shr ecx, 12 + and edx, -4096 + or edx, [flags] @@: - mov [page_tabs+eax*4], edx - ; push eax - ; invlpg [ebx] - ; pop eax - inc eax - add ebx, edi - add edx, edi - loop @B + mov [page_tabs+eax*4], edx + ; push eax + ; invlpg [ebx] + ; pop eax + inc eax + add ebx, edi + add edx, edi + loop @B - pop eax - mov edx, [base] - and edx, 4095 - add eax, edx + pop eax + mov edx, [base] + and edx, 4095 + add eax, edx .fail: - pop edi - pop ebx - ret + pop edi + pop ebx + ret endp ; param @@ -191,31 +191,31 @@ endp align 4 commit_pages: - push edi - test ecx, ecx - jz .fail + push edi + test ecx, ecx + jz .fail - mov edi, ebx - mov ebx, pg_data.pg_mutex - call wait_mutex ;ebx + mov edi, ebx + mov ebx, pg_data.pg_mutex + call wait_mutex ;ebx - mov edx, 0x1000 - mov ebx, edi - shr ebx, 12 + mov edx, 0x1000 + mov ebx, edi + shr ebx, 12 @@: - mov [page_tabs+ebx*4], eax - ; push eax - ; invlpg [edi] - ; pop eax - add edi, edx - add eax, edx - inc ebx - dec ecx - jnz @B - mov [pg_data.pg_mutex],ecx + mov [page_tabs+ebx*4], eax + ; push eax + ; invlpg [edi] + ; pop eax + add edi, edx + add eax, edx + inc ebx + dec ecx + jnz @B + mov [pg_data.pg_mutex],ecx .fail: - pop edi - ret + pop edi + ret ; param @@ -225,49 +225,49 @@ commit_pages: align 4 release_pages: - pushad - mov ebx, pg_data.pg_mutex - call wait_mutex ;ebx + pushad + mov ebx, pg_data.pg_mutex + call wait_mutex ;ebx - mov esi, eax - mov edi, eax + mov esi, eax + mov edi, eax - shr esi, 10 - add esi, page_tabs + shr esi, 10 + add esi, page_tabs - mov ebp, [pg_data.pages_free] - mov ebx, [page_start] - mov edx, sys_pgmap + mov ebp, [pg_data.pages_free] + mov ebx, [page_start] + mov edx, sys_pgmap @@: - xor eax, eax - xchg eax, [esi] - push eax - invlpg [edi] - pop eax + xor eax, eax + xchg eax, [esi] + push eax + invlpg [edi] + pop eax - test eax, 1 - jz .next + test eax, 1 + jz .next - shr eax, 12 - bts [edx], eax - cmc - adc ebp, 0 - shr eax, 3 - and eax, -4 - add eax, edx - cmp eax, ebx - jae .next + shr eax, 12 + bts [edx], eax + cmc + adc ebp, 0 + shr eax, 3 + and eax, -4 + add eax, edx + cmp eax, ebx + jae .next - mov ebx, eax + mov ebx, eax .next: - add edi, 0x1000 - add esi, 4 - dec ecx - jnz @B - mov [pg_data.pages_free], ebp - and [pg_data.pg_mutex],0 - popad - ret + add edi, 0x1000 + add esi, 4 + dec ecx + jnz @B + mov [pg_data.pages_free], ebp + and [pg_data.pg_mutex],0 + popad + ret ; param ; eax= base @@ -276,229 +276,229 @@ release_pages: align 4 unmap_pages: - push edi + push edi - mov edi, eax - mov edx, eax + mov edi, eax + mov edx, eax - shr edi, 10 - add edi, page_tabs + shr edi, 10 + add edi, page_tabs - xor eax, eax + xor eax, eax @@: - stosd - invlpg [edx] - add edx, 0x1000 - loop @b + stosd + invlpg [edx] + add edx, 0x1000 + loop @b - pop edi - ret + pop edi + ret align 4 proc map_page_table stdcall, lin_addr:dword, phis_addr:dword - push ebx - mov ebx, [lin_addr] - shr ebx, 22 - mov eax, [phis_addr] - and eax, not 0xFFF - or eax, PG_UW ;+PG_NOCACHE - mov dword [master_tab+ebx*4], eax - mov eax, [lin_addr] - shr eax, 10 - add eax, page_tabs - invlpg [eax] - pop ebx - ret + push ebx + mov ebx, [lin_addr] + shr ebx, 22 + mov eax, [phis_addr] + and eax, not 0xFFF + or eax, PG_UW ;+PG_NOCACHE + mov dword [master_tab+ebx*4], eax + mov eax, [lin_addr] + shr eax, 10 + add eax, page_tabs + invlpg [eax] + pop ebx + ret endp align 4 proc init_LFB - locals - pg_count dd ? - endl + locals + pg_count dd ? + endl - cmp dword [LFBAddress], -1 - jne @f - mov [BOOT_VAR+0x901c],byte 2 - stdcall kernel_alloc, 0x280000 - mov [LFBAddress], eax - ret + cmp dword [LFBAddress], -1 + jne @f + mov [BOOT_VAR+0x901c],byte 2 + stdcall kernel_alloc, 0x280000 + mov [LFBAddress], eax + ret @@: - test [SCR_MODE],word 0100000000000000b - jnz @f - mov [BOOT_VAR+0x901c],byte 2 - ret + test [SCR_MODE],word 0100000000000000b + jnz @f + mov [BOOT_VAR+0x901c],byte 2 + ret @@: - call init_mtrr + call init_mtrr - mov edx, LFB_BASE - mov esi, [LFBAddress] - mov edi, 0x00800000 - mov dword [exp_lfb+4], edx + mov edx, LFB_BASE + mov esi, [LFBAddress] + mov edi, 0x00800000 + mov dword [exp_lfb+4], edx - shr edi, 12 - mov [pg_count], edi - shr edi, 10 + shr edi, 12 + mov [pg_count], edi + shr edi, 10 - bt [cpu_caps], CAPS_PSE - jnc .map_page_tables - or esi, PG_LARGE+PG_UW - mov edx, sys_pgdir+(LFB_BASE shr 20) + bt [cpu_caps], CAPS_PSE + jnc .map_page_tables + or esi, PG_LARGE+PG_UW + mov edx, sys_pgdir+(LFB_BASE shr 20) @@: - mov [edx], esi - add edx, 4 - add esi, 0x00400000 - dec edi - jnz @B + mov [edx], esi + add edx, 4 + add esi, 0x00400000 + dec edi + jnz @B - bt [cpu_caps], CAPS_PGE - jnc @F - or dword [sys_pgdir+(LFB_BASE shr 20)], PG_GLOBAL + bt [cpu_caps], CAPS_PGE + jnc @F + or dword [sys_pgdir+(LFB_BASE shr 20)], PG_GLOBAL @@: - mov dword [LFBAddress], LFB_BASE - mov eax, cr3 ;flush TLB - mov cr3, eax - ret + mov dword [LFBAddress], LFB_BASE + mov eax, cr3 ;flush TLB + mov cr3, eax + ret .map_page_tables: @@: - call alloc_page - stdcall map_page_table, edx, eax - add edx, 0x00400000 - dec edi - jnz @B + call alloc_page + stdcall map_page_table, edx, eax + add edx, 0x00400000 + dec edi + jnz @B - mov eax, [LFBAddress] - mov edi, page_tabs + (LFB_BASE shr 10) - or eax, PG_UW - mov ecx, [pg_count] - cld + mov eax, [LFBAddress] + mov edi, page_tabs + (LFB_BASE shr 10) + or eax, PG_UW + mov ecx, [pg_count] + cld @@: - stosd - add eax, 0x1000 - dec ecx - jnz @B + stosd + add eax, 0x1000 + dec ecx + jnz @B - mov dword [LFBAddress], LFB_BASE - mov eax, cr3 ;flush TLB - mov cr3, eax + mov dword [LFBAddress], LFB_BASE + mov eax, cr3 ;flush TLB + mov cr3, eax - ret + ret endp align 4 proc new_mem_resize stdcall, new_size:dword - mov ebx, pg_data.pg_mutex - call wait_mutex ;ebx + mov ebx, pg_data.pg_mutex + call wait_mutex ;ebx - mov edi, [new_size] - add edi,4095 - and edi,not 4095 - mov [new_size], edi + mov edi, [new_size] + add edi,4095 + and edi,not 4095 + mov [new_size], edi - mov edx,[current_slot] - cmp [edx+APPDATA.heap_base],0 - jne .exit + mov edx,[current_slot] + cmp [edx+APPDATA.heap_base],0 + jne .exit - mov esi, [edx+APPDATA.mem_size] - add esi, 4095 - and esi, not 4095 + mov esi, [edx+APPDATA.mem_size] + add esi, 4095 + and esi, not 4095 - cmp edi, esi - jae .expand + cmp edi, esi + jae .expand - shr edi, 12 - shr esi, 12 + shr edi, 12 + shr esi, 12 @@: - mov eax, [app_page_tabs+edi*4] - test eax, 1 - jz .next - mov dword [app_page_tabs+edi*4], 2 - mov ebx, edi - shl ebx, 12 - push eax - invlpg [ebx] - pop eax - call free_page + mov eax, [app_page_tabs+edi*4] + test eax, 1 + jz .next + mov dword [app_page_tabs+edi*4], 2 + mov ebx, edi + shl ebx, 12 + push eax + invlpg [ebx] + pop eax + call free_page -.next: add edi, 1 - cmp edi, esi - jb @B +.next: add edi, 1 + cmp edi, esi + jb @B .update_size: - mov ebx, [new_size] - call update_mem_size + mov ebx, [new_size] + call update_mem_size - xor eax, eax - dec [pg_data.pg_mutex] - ret + xor eax, eax + dec [pg_data.pg_mutex] + ret .expand: - push esi - push edi + push esi + push edi - add edi, 0x3FFFFF - and edi, not(0x3FFFFF) - add esi, 0x3FFFFF - and esi, not(0x3FFFFF) + add edi, 0x3FFFFF + and edi, not(0x3FFFFF) + add esi, 0x3FFFFF + and esi, not(0x3FFFFF) - cmp esi, edi - jae .grow + cmp esi, edi + jae .grow - xchg esi, edi + xchg esi, edi @@: - call alloc_page - test eax, eax - jz .exit_pop + call alloc_page + test eax, eax + jz .exit_pop - stdcall map_page_table, edi, eax + stdcall map_page_table, edi, eax - push edi - shr edi, 10 - add edi, page_tabs - mov ecx, 1024 - xor eax, eax - cld - rep stosd - pop edi + push edi + shr edi, 10 + add edi, page_tabs + mov ecx, 1024 + xor eax, eax + cld + rep stosd + pop edi - add edi, 0x00400000 - cmp edi, esi - jb @B + add edi, 0x00400000 + cmp edi, esi + jb @B .grow: - pop edi - pop esi + pop edi + pop esi @@: - call alloc_page - test eax, eax - jz .exit - stdcall map_page,esi,eax,dword PG_UW + call alloc_page + test eax, eax + jz .exit + stdcall map_page,esi,eax,dword PG_UW - push edi - mov edi, esi - xor eax, eax - mov ecx, 1024 - cld - rep stosd - pop edi + push edi + mov edi, esi + xor eax, eax + mov ecx, 1024 + cld + rep stosd + pop edi - add esi, 0x1000 - cmp esi, edi - jb @B + add esi, 0x1000 + cmp esi, edi + jb @B - jmp .update_size + jmp .update_size .exit_pop: - pop edi - pop esi + pop edi + pop esi .exit: - xor eax, eax - inc eax - dec [pg_data.pg_mutex] - ret + xor eax, eax + inc eax + dec [pg_data.pg_mutex] + ret endp update_mem_size: @@ -506,31 +506,31 @@ update_mem_size: ; ebx = new memory size ; destroys eax,ecx,edx - mov [APPDATA.mem_size+edx],ebx + mov [APPDATA.mem_size+edx],ebx ;search threads and update ;application memory size infomation - mov ecx,[APPDATA.dir_table+edx] - mov eax,2 + mov ecx,[APPDATA.dir_table+edx] + mov eax,2 .search_threads: ;eax = current slot ;ebx = new memory size ;ecx = page directory - cmp eax,[TASK_COUNT] - jg .search_threads_end - mov edx,eax - shl edx,5 - cmp word [CURRENT_TASK+edx+TASKDATA.state],9 ;if slot empty? - jz .search_threads_next - shl edx,3 - cmp [SLOT_BASE+edx+APPDATA.dir_table],ecx ;if it is our thread? - jnz .search_threads_next - mov [SLOT_BASE+edx+APPDATA.mem_size],ebx ;update memory size + cmp eax,[TASK_COUNT] + jg .search_threads_end + mov edx,eax + shl edx,5 + cmp word [CURRENT_TASK+edx+TASKDATA.state],9 ;if slot empty? + jz .search_threads_next + shl edx,3 + cmp [SLOT_BASE+edx+APPDATA.dir_table],ecx ;if it is our thread? + jnz .search_threads_next + mov [SLOT_BASE+edx+APPDATA.mem_size],ebx ;update memory size .search_threads_next: - inc eax - jmp .search_threads + inc eax + jmp .search_threads .search_threads_end: - ret + ret ; param ; eax= linear address @@ -540,23 +540,23 @@ update_mem_size: align 4 get_pg_addr: - shr eax, 12 - mov eax, [page_tabs+eax*4] - and eax, 0xFFFFF000 - ret + shr eax, 12 + mov eax, [page_tabs+eax*4] + and eax, 0xFFFFF000 + ret align 4 ; Now it is called from core/sys32::exc_c (see stack frame there) proc page_fault_handler - .err_addr equ ebp-4 + .err_addr equ ebp-4 - push ebx ;save exception number (#PF) - mov ebp, esp - mov ebx, cr2 - push ebx ;that is locals: .err_addr = cr2 - inc [pg_data.pages_faults] + push ebx ;save exception number (#PF) + mov ebp, esp + mov ebx, cr2 + push ebx ;that is locals: .err_addr = cr2 + inc [pg_data.pages_faults] ; push eax ; push edx @@ -566,136 +566,136 @@ proc page_fault_handler ; pop edx ; pop eax - mov eax, [pf_err_code] + mov eax, [pf_err_code] - cmp ebx, OS_BASE ;ebx == .err_addr - jb .user_space ;страница в памяти приложения ; + cmp ebx, OS_BASE ;ebx == .err_addr + jb .user_space ;страница в памяти приложения ; - cmp ebx, page_tabs - jb .kernel_space ;страница в памяти ядра + cmp ebx, page_tabs + jb .kernel_space ;страница в памяти ядра - cmp ebx, kernel_tabs - jb .alloc;.app_tabs ;таблицы страниц приложения ; - ;просто создадим одну + cmp ebx, kernel_tabs + jb .alloc;.app_tabs ;таблицы страниц приложения ; + ;просто создадим одну if 0 ;пока это просто лишнее - cmp ebx, LFB_BASE - jb .core_tabs ;таблицы страниц ядра - ;Ошибка + cmp ebx, LFB_BASE + jb .core_tabs ;таблицы страниц ядра + ;Ошибка .lfb: - ;область LFB - ;Ошибка - jmp .fail + ;область LFB + ;Ошибка + jmp .fail end if .core_tabs: -.fail: ;simply return to caller - mov esp, ebp - pop ebx ;restore exception number (#PF) - ret +.fail: ;simply return to caller + mov esp, ebp + pop ebx ;restore exception number (#PF) + ret .user_space: - test eax, PG_MAP - jnz .err_access ;Страница присутствует - ;Ошибка доступа ? + test eax, PG_MAP + jnz .err_access ;Страница присутствует + ;Ошибка доступа ? - shr ebx, 12 - mov ecx, ebx - shr ecx, 10 - mov edx, [master_tab+ecx*4] - test edx, PG_MAP - jz .fail ;таблица страниц не создана - ;неверный адрес в программе + shr ebx, 12 + mov ecx, ebx + shr ecx, 10 + mov edx, [master_tab+ecx*4] + test edx, PG_MAP + jz .fail ;таблица страниц не создана + ;неверный адрес в программе - mov eax, [page_tabs+ebx*4] - test eax, 2 - jz .fail ;адрес не зарезервирован для ; - ;использования. Ошибка + mov eax, [page_tabs+ebx*4] + test eax, 2 + jz .fail ;адрес не зарезервирован для ; + ;использования. Ошибка .alloc: - call alloc_page - test eax, eax - jz .fail + call alloc_page + test eax, eax + jz .fail - stdcall map_page,[.err_addr],eax,dword PG_UW + stdcall map_page,[.err_addr],eax,dword PG_UW - mov edi, [.err_addr] - and edi, 0xFFFFF000 - mov ecx, 1024 - xor eax, eax + mov edi, [.err_addr] + and edi, 0xFFFFF000 + mov ecx, 1024 + xor eax, eax ;cld ;caller is duty for this - rep stosd -.exit: ;iret with repeat fault instruction - add esp,12 ;clear in stack: locals(.err_addr) + #PF + ret_to_caller - restore_ring3_context - iretd + rep stosd +.exit: ;iret with repeat fault instruction + add esp,12 ;clear in stack: locals(.err_addr) + #PF + ret_to_caller + restore_ring3_context + iretd -.err_access = .fail +.err_access = .fail ;никогда не происходит ;jmp .fail .kernel_space: - test eax, PG_MAP - jz .fail ;страница не присутствует + test eax, PG_MAP + jz .fail ;страница не присутствует - test eax,12 ;U/S (+below) - jnz .fail ;приложение обратилось к памяти - ;ядра + test eax,12 ;U/S (+below) + jnz .fail ;приложение обратилось к памяти + ;ядра ;test eax, 8 ;jnz .fail ;установлен зарезервированный бит - ;в таблицах страниц. добавлено в P4/Xeon + ;в таблицах страниц. добавлено в P4/Xeon ;попытка записи в защищённую страницу ядра - cmp ebx, tss._io_map_0 - jb .fail + cmp ebx, tss._io_map_0 + jb .fail - cmp ebx, tss._io_map_0+8192 - jae .fail + cmp ebx, tss._io_map_0+8192 + jae .fail ; io permission map ; copy-on-write protection - call alloc_page - test eax, eax - jz .fail + call alloc_page + test eax, eax + jz .fail - push eax - stdcall map_page,[.err_addr],eax,dword PG_SW - pop eax - mov edi, [.err_addr] - and edi, -4096 - lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0 + push eax + stdcall map_page,[.err_addr],eax,dword PG_SW + pop eax + mov edi, [.err_addr] + and edi, -4096 + lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0 - mov ebx, esi - shr ebx, 12 - mov edx, [current_slot] - or eax, PG_SW - mov [edx+APPDATA.io_map+ebx*4], eax + mov ebx, esi + shr ebx, 12 + mov edx, [current_slot] + or eax, PG_SW + mov [edx+APPDATA.io_map+ebx*4], eax - add esi, [default_io_map] - mov ecx, 4096/4 + add esi, [default_io_map] + mov ecx, 4096/4 ;cld ;caller is duty for this - rep movsd - jmp .exit + rep movsd + jmp .exit endp align 4 proc map_mem stdcall, lin_addr:dword,pdir:dword,\ - ofs:dword,buf_size:dword - mov eax, [buf_size] - test eax, eax - jz .exit + ofs:dword,buf_size:dword + mov eax, [buf_size] + test eax, eax + jz .exit - mov eax, [pdir] - and eax, 0xFFFFF000 + mov eax, [pdir] + and eax, 0xFFFFF000 - stdcall map_page,[ipc_pdir],eax,PG_UW - mov ebx, [ofs] - shr ebx, 22 - mov esi, [ipc_pdir] - mov edi, [ipc_ptab] - mov eax, [esi+ebx*4] - and eax, 0xFFFFF000 - jz .exit - stdcall map_page,edi,eax,PG_UW + stdcall map_page,[ipc_pdir],eax,PG_UW + mov ebx, [ofs] + shr ebx, 22 + mov esi, [ipc_pdir] + mov edi, [ipc_ptab] + mov eax, [esi+ebx*4] + and eax, 0xFFFFF000 + jz .exit + stdcall map_page,edi,eax,PG_UW ; inc ebx ; add edi, 0x1000 ; mov eax, [esi+ebx*4] @@ -704,85 +704,85 @@ proc map_mem stdcall, lin_addr:dword,pdir:dword,\ ; and eax, 0xFFFFF000 ; stdcall map_page, edi, eax -@@: mov edi, [lin_addr] - and edi, 0xFFFFF000 - mov ecx, [buf_size] - add ecx, 4095 - shr ecx, 12 - inc ecx +@@: mov edi, [lin_addr] + and edi, 0xFFFFF000 + mov ecx, [buf_size] + add ecx, 4095 + shr ecx, 12 + inc ecx - mov edx, [ofs] - shr edx, 12 - and edx, 0x3FF - mov esi, [ipc_ptab] + mov edx, [ofs] + shr edx, 12 + and edx, 0x3FF + mov esi, [ipc_ptab] -.map: mov eax, [esi+edx*4] - and eax, 0xFFFFF000 - jz .exit - stdcall map_page,edi,eax,PG_UW - dec ecx - jz .exit - add edi, 0x1000 - inc edx - cmp edx, 0x400 - jnz .map - inc ebx - mov eax, [ipc_pdir] - mov eax, [eax+ebx*4] - and eax, 0xFFFFF000 - jz .exit - stdcall map_page,esi,eax,PG_UW - xor edx, edx - jmp .map +.map: mov eax, [esi+edx*4] + and eax, 0xFFFFF000 + jz .exit + stdcall map_page,edi,eax,PG_UW + dec ecx + jz .exit + add edi, 0x1000 + inc edx + cmp edx, 0x400 + jnz .map + inc ebx + mov eax, [ipc_pdir] + mov eax, [eax+ebx*4] + and eax, 0xFFFFF000 + jz .exit + stdcall map_page,esi,eax,PG_UW + xor edx, edx + jmp .map .exit: - ret + ret endp align 4 proc map_memEx stdcall, lin_addr:dword,pdir:dword,\ - ofs:dword,buf_size:dword - mov eax, [buf_size] - test eax, eax - jz .exit + ofs:dword,buf_size:dword + mov eax, [buf_size] + test eax, eax + jz .exit - mov eax, [pdir] - and eax, 0xFFFFF000 + mov eax, [pdir] + and eax, 0xFFFFF000 - stdcall map_page,[proc_mem_pdir],eax,dword PG_UW - mov ebx, [ofs] - shr ebx, 22 - mov esi, [proc_mem_pdir] - mov edi, [proc_mem_tab] - mov eax, [esi+ebx*4] - and eax, 0xFFFFF000 - test eax, eax - jz .exit - stdcall map_page,edi,eax,dword PG_UW + stdcall map_page,[proc_mem_pdir],eax,dword PG_UW + mov ebx, [ofs] + shr ebx, 22 + mov esi, [proc_mem_pdir] + mov edi, [proc_mem_tab] + mov eax, [esi+ebx*4] + and eax, 0xFFFFF000 + test eax, eax + jz .exit + stdcall map_page,edi,eax,dword PG_UW -@@: mov edi, [lin_addr] - and edi, 0xFFFFF000 - mov ecx, [buf_size] - add ecx, 4095 - shr ecx, 12 - inc ecx +@@: mov edi, [lin_addr] + and edi, 0xFFFFF000 + mov ecx, [buf_size] + add ecx, 4095 + shr ecx, 12 + inc ecx - mov edx, [ofs] - shr edx, 12 - and edx, 0x3FF - mov esi, [proc_mem_tab] + mov edx, [ofs] + shr edx, 12 + and edx, 0x3FF + mov esi, [proc_mem_tab] -.map: mov eax, [esi+edx*4] +.map: mov eax, [esi+edx*4] ; and eax, 0xFFFFF000 ; test eax, eax ; jz .exit - stdcall map_page,edi,eax,dword PG_UW - add edi, 0x1000 - inc edx - dec ecx - jnz .map + stdcall map_page,edi,eax,dword PG_UW + add edi, 0x1000 + inc edx + dec ecx + jnz .map .exit: - ret + ret endp @@ -798,511 +798,511 @@ sys_IPC: ; ecx=address of message ; edx=size of message - cmp eax,1 - jne @f - call set_ipc_buff - mov [esp+36], eax - ret + cmp eax,1 + jne @f + call set_ipc_buff + mov [esp+36], eax + ret @@: - cmp eax, 2 - jne @f - stdcall sys_ipc_send, ebx, ecx, edx - mov [esp+36], eax - ret + cmp eax, 2 + jne @f + stdcall sys_ipc_send, ebx, ecx, edx + mov [esp+36], eax + ret @@: - xor eax, eax - not eax - mov [esp+36], eax - ret + xor eax, eax + not eax + mov [esp+36], eax + ret align 4 proc set_ipc_buff - mov eax,[current_slot] - pushf - cli - mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area - mov [eax+APPDATA.ipc_size],ecx + mov eax,[current_slot] + pushf + cli + mov [eax+APPDATA.ipc_start],ebx ;set fields in extended information area + mov [eax+APPDATA.ipc_size],ecx - add ecx, ebx - add ecx, 4095 - and ecx, not 4095 + add ecx, ebx + add ecx, 4095 + and ecx, not 4095 .touch: mov eax, [ebx] - add ebx, 0x1000 - cmp ebx, ecx - jb .touch + add ebx, 0x1000 + cmp ebx, ecx + jb .touch - popf - xor eax, eax - ret + popf + xor eax, eax + ret endp proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword - locals - dst_slot dd ? - dst_offset dd ? - buf_size dd ? - used_buf dd ? - endl + locals + dst_slot dd ? + dst_offset dd ? + buf_size dd ? + used_buf dd ? + endl - pushf - cli + pushf + cli - mov eax, [PID] - call pid_to_slot - test eax,eax - jz .no_pid + mov eax, [PID] + call pid_to_slot + test eax,eax + jz .no_pid - mov [dst_slot], eax - shl eax,8 - mov edi,[eax+SLOT_BASE+0xa0] ;is ipc area defined? - test edi,edi - jz .no_ipc_area + mov [dst_slot], eax + shl eax,8 + mov edi,[eax+SLOT_BASE+0xa0] ;is ipc area defined? + test edi,edi + jz .no_ipc_area - mov ebx, edi - and ebx, 0xFFF - mov [dst_offset], ebx + mov ebx, edi + and ebx, 0xFFF + mov [dst_offset], ebx - mov esi, [eax+SLOT_BASE+0xa4] - mov [buf_size], esi + mov esi, [eax+SLOT_BASE+0xa4] + mov [buf_size], esi - mov ecx, [ipc_tmp] - cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page - jbe @f - push eax esi edi - add esi,0x1000 - stdcall alloc_kernel_space,esi - mov ecx, eax - pop edi esi eax + mov ecx, [ipc_tmp] + cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page + jbe @f + push eax esi edi + add esi,0x1000 + stdcall alloc_kernel_space,esi + mov ecx, eax + pop edi esi eax @@: - mov [used_buf], ecx - stdcall map_mem, ecx, [SLOT_BASE+eax+0xB8],\ - edi, esi + mov [used_buf], ecx + stdcall map_mem, ecx, [SLOT_BASE+eax+0xB8],\ + edi, esi - mov edi, [dst_offset] - add edi, [used_buf] - cmp dword [edi], 0 - jnz .ipc_blocked ;if dword [buffer]<>0 - ipc blocked now + mov edi, [dst_offset] + add edi, [used_buf] + cmp dword [edi], 0 + jnz .ipc_blocked ;if dword [buffer]<>0 - ipc blocked now - mov edx, dword [edi+4] - lea ebx, [edx+8] - add ebx, [msg_size] - cmp ebx, [buf_size] - ja .buffer_overflow ;esi<0 - not enough memory in buffer + mov edx, dword [edi+4] + lea ebx, [edx+8] + add ebx, [msg_size] + cmp ebx, [buf_size] + ja .buffer_overflow ;esi<0 - not enough memory in buffer - mov dword [edi+4], ebx - mov eax,[TASK_BASE] - mov eax, [eax+0x04] ;eax - our PID - add edi, edx - mov [edi], eax - mov ecx, [msg_size] + mov dword [edi+4], ebx + mov eax,[TASK_BASE] + mov eax, [eax+0x04] ;eax - our PID + add edi, edx + mov [edi], eax + mov ecx, [msg_size] - mov [edi+4], ecx - add edi, 8 - mov esi, [msg_addr] + mov [edi+4], ecx + add edi, 8 + mov esi, [msg_addr] ; add esi, new_app_base - cld - rep movsb + cld + rep movsb - mov ebx, [ipc_tmp] - mov edx, ebx - shr ebx, 12 - xor eax, eax - mov [page_tabs+ebx*4], eax - invlpg [edx] + mov ebx, [ipc_tmp] + mov edx, ebx + shr ebx, 12 + xor eax, eax + mov [page_tabs+ebx*4], eax + invlpg [edx] - mov ebx, [ipc_pdir] - mov edx, ebx - shr ebx, 12 - xor eax, eax - mov [page_tabs+ebx*4], eax - invlpg [edx] + mov ebx, [ipc_pdir] + mov edx, ebx + shr ebx, 12 + xor eax, eax + mov [page_tabs+ebx*4], eax + invlpg [edx] - mov ebx, [ipc_ptab] - mov edx, ebx - shr ebx, 12 - xor eax, eax - mov [page_tabs+ebx*4], eax - invlpg [edx] + mov ebx, [ipc_ptab] + mov edx, ebx + shr ebx, 12 + xor eax, eax + mov [page_tabs+ebx*4], eax + invlpg [edx] - mov eax, [dst_slot] - shl eax, 8 - or [eax+SLOT_BASE+0xA8],dword 0x40 - cmp dword [check_idle_semaphore],20 - jge .ipc_no_cis + mov eax, [dst_slot] + shl eax, 8 + or [eax+SLOT_BASE+0xA8],dword 0x40 + cmp dword [check_idle_semaphore],20 + jge .ipc_no_cis - mov dword [check_idle_semaphore],5 + mov dword [check_idle_semaphore],5 .ipc_no_cis: - push 0 - jmp .ret + push 0 + jmp .ret .no_pid: - popf - mov eax, 4 - ret + popf + mov eax, 4 + ret .no_ipc_area: - popf - xor eax, eax - inc eax - ret + popf + xor eax, eax + inc eax + ret .ipc_blocked: - push 2 - jmp .ret + push 2 + jmp .ret .buffer_overflow: - push 3 + push 3 .ret: - mov eax, [used_buf] - cmp eax, [ipc_tmp] - jz @f - stdcall free_kernel_space,eax + mov eax, [used_buf] + cmp eax, [ipc_tmp] + jz @f + stdcall free_kernel_space,eax @@: - pop eax - popf - ret + pop eax + popf + ret endp align 4 sysfn_meminfo: - ; add ecx, new_app_base - cmp ecx, OS_BASE - jae .fail + ; add ecx, new_app_base + cmp ecx, OS_BASE + jae .fail - mov eax, [pg_data.pages_count] - mov [ecx], eax - shl eax, 12 - mov [esp+32], eax - mov eax, [pg_data.pages_free] - mov [ecx+4], eax - mov eax, [pg_data.pages_faults] - mov [ecx+8], eax - mov eax, [heap_size] - mov [ecx+12], eax - mov eax, [heap_free] - mov [ecx+16], eax - mov eax, [heap_blocks] - mov [ecx+20], eax - mov eax, [free_blocks] - mov [ecx+24], eax - ret + mov eax, [pg_data.pages_count] + mov [ecx], eax + shl eax, 12 + mov [esp+32], eax + mov eax, [pg_data.pages_free] + mov [ecx+4], eax + mov eax, [pg_data.pages_faults] + mov [ecx+8], eax + mov eax, [heap_size] + mov [ecx+12], eax + mov eax, [heap_free] + mov [ecx+16], eax + mov eax, [heap_blocks] + mov [ecx+20], eax + mov eax, [free_blocks] + mov [ecx+24], eax + ret .fail: - mov dword [esp+32], -1 - ret + mov dword [esp+32], -1 + ret align 4 f68call: - dd f68.11 - dd f68.12 - dd f68.13 - dd f68.14 - dd f68.fail ;moved to f68.24 - dd f68.16 - dd f68.17 - dd f68.fail ;moved to f68.25 - dd f68.19 - dd f68.20 - dd f68.21 - dd f68.22 - dd f68.23 - dd f68.24 - dd f68.25 + dd f68.11 + dd f68.12 + dd f68.13 + dd f68.14 + dd f68.fail ;moved to f68.24 + dd f68.16 + dd f68.17 + dd f68.fail ;moved to f68.25 + dd f68.19 + dd f68.20 + dd f68.21 + dd f68.22 + dd f68.23 + dd f68.24 + dd f68.25 align 4 f68: - cmp eax,4 - jle sys_sheduler + cmp eax,4 + jle sys_sheduler - cmp eax, 11 - jb .fail + cmp eax, 11 + jb .fail - cmp eax, 25 - ja .fail + cmp eax, 25 + ja .fail - jmp dword [f68call+eax*4-11*4] + jmp dword [f68call+eax*4-11*4] .11: - call init_heap - mov [esp+36], eax - ret + call init_heap + mov [esp+36], eax + ret .12: - stdcall user_alloc, ebx - mov [esp+36], eax - ret + stdcall user_alloc, ebx + mov [esp+36], eax + ret .13: - stdcall user_free, ebx - mov [esp+36], eax - ret + stdcall user_free, ebx + mov [esp+36], eax + ret .14: - cmp ebx, OS_BASE - jae .fail - mov edi,ebx - call get_event_ex - mov [esp+36], eax - ret + cmp ebx, OS_BASE + jae .fail + mov edi,ebx + call get_event_ex + mov [esp+36], eax + ret .24: - mov eax, [current_slot] - xchg ebx, [eax+APPDATA.exc_handler] - xchg ecx, [eax+APPDATA.except_mask] - mov [esp+36], ebx ; reg_eax+8 - mov [esp+24], ecx ; reg_ebx+8 - ret + mov eax, [current_slot] + xchg ebx, [eax+APPDATA.exc_handler] + xchg ecx, [eax+APPDATA.except_mask] + mov [esp+36], ebx ; reg_eax+8 + mov [esp+24], ecx ; reg_ebx+8 + ret .16: - test ebx, ebx - jz .fail - cmp ebx, OS_BASE - jae .fail - stdcall get_service, ebx - mov [esp+36], eax - ret + test ebx, ebx + jz .fail + cmp ebx, OS_BASE + jae .fail + stdcall get_service, ebx + mov [esp+36], eax + ret .17: - call srv_handlerEx ;ebx - mov [esp+36], eax - ret + call srv_handlerEx ;ebx + mov [esp+36], eax + ret .25: - cmp ebx,32 - jae .fail - mov eax, [current_slot] - btr [eax+APPDATA.except_mask],ebx - setc byte[esp+36] - jecxz @f - bts [eax+APPDATA.except_mask],ebx + cmp ebx,32 + jae .fail + mov eax, [current_slot] + btr [eax+APPDATA.except_mask],ebx + setc byte[esp+36] + jecxz @f + bts [eax+APPDATA.except_mask],ebx @@: ret .19: - cmp ebx, OS_BASE - jae .fail - stdcall load_library, ebx - mov [esp+36], eax - ret + cmp ebx, OS_BASE + jae .fail + stdcall load_library, ebx + mov [esp+36], eax + ret .20: - mov eax, ecx - call user_realloc - mov [esp+36], eax - ret + mov eax, ecx + call user_realloc + mov [esp+36], eax + ret .21: - cmp ebx, OS_BASE - jae .fail + cmp ebx, OS_BASE + jae .fail - stdcall load_PE, ebx + stdcall load_PE, ebx - test eax, eax - jz @F + test eax, eax + jz @F - mov esi, eax - stdcall eax, DRV_ENTRY + mov esi, eax + stdcall eax, DRV_ENTRY - test eax, eax - jz @F + test eax, eax + jz @F - mov [eax+SRV.entry], esi + mov [eax+SRV.entry], esi @@: - mov [esp+36], eax - ret + mov [esp+36], eax + ret .22: - cmp ebx, OS_BASE - jae .fail + cmp ebx, OS_BASE + jae .fail - stdcall shmem_open, ebx, ecx, edx - mov [esp+28], edx - mov [esp+36], eax - ret + stdcall shmem_open, ebx, ecx, edx + mov [esp+28], edx + mov [esp+36], eax + ret .23: - cmp ebx, OS_BASE - jae .fail + cmp ebx, OS_BASE + jae .fail - stdcall shmem_close, ebx - mov [esp+36], eax - ret + stdcall shmem_close, ebx + mov [esp+36], eax + ret .fail: - xor eax, eax - mov [esp+36], eax - ret + xor eax, eax + mov [esp+36], eax + ret align 4 proc load_pe_driver stdcall, file:dword - stdcall load_PE, [file] - test eax, eax - jz .fail + stdcall load_PE, [file] + test eax, eax + jz .fail - mov esi, eax - stdcall eax, DRV_ENTRY - test eax, eax - jz .fail + mov esi, eax + stdcall eax, DRV_ENTRY + test eax, eax + jz .fail - mov [eax+SRV.entry], esi - ret + mov [eax+SRV.entry], esi + ret .fail: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc init_mtrr - cmp [BOOT_VAR+0x901c],byte 2 - je .exit + cmp [BOOT_VAR+0x901c],byte 2 + je .exit - bt [cpu_caps], CAPS_MTRR - jnc .exit + bt [cpu_caps], CAPS_MTRR + jnc .exit - mov eax, cr0 - or eax, 0x60000000 ;disable caching - mov cr0, eax - wbinvd ;invalidate cache + mov eax, cr0 + or eax, 0x60000000 ;disable caching + mov cr0, eax + wbinvd ;invalidate cache - mov ecx, 0x2FF - rdmsr ; - push eax + mov ecx, 0x2FF + rdmsr ; + push eax - xor edx, edx - xor eax, eax - mov ecx, 0x2FF - wrmsr ;disable all MTRR + xor edx, edx + xor eax, eax + mov ecx, 0x2FF + wrmsr ;disable all MTRR - mov eax, [MEM_AMOUNT] + mov eax, [MEM_AMOUNT] ; round eax up to next power of 2 - dec eax - bsr ecx, eax - mov eax, 2 - shl eax, cl - stdcall set_mtrr, edx,edx,eax,MEM_WB - stdcall set_mtrr, 1,[LFBAddress],[LFBSize],MEM_WC - xor edx, edx - xor eax, eax - mov ecx, 0x204 - mov ebx, 6 + dec eax + bsr ecx, eax + mov eax, 2 + shl eax, cl + stdcall set_mtrr, edx,edx,eax,MEM_WB + stdcall set_mtrr, 1,[LFBAddress],[LFBSize],MEM_WC + xor edx, edx + xor eax, eax + mov ecx, 0x204 + mov ebx, 6 @@: - wrmsr ;disable unused MTRR - inc ecx - wrmsr - inc ecx - dec ebx - jnz @b + wrmsr ;disable unused MTRR + inc ecx + wrmsr + inc ecx + dec ebx + jnz @b - wbinvd ;again invalidate + wbinvd ;again invalidate - pop eax - or eax, 0x800 ;set default memtype to UC - and al, 0xF0 - mov ecx, 0x2FF - wrmsr ;and enable MTRR + pop eax + or eax, 0x800 ;set default memtype to UC + and al, 0xF0 + mov ecx, 0x2FF + wrmsr ;and enable MTRR - mov eax, cr0 - and eax, not 0x60000000 - mov cr0, eax ; enable caching + mov eax, cr0 + and eax, not 0x60000000 + mov cr0, eax ; enable caching .exit: - ret + ret endp align 4 proc set_mtrr stdcall, reg:dword,base:dword,size:dword,mem_type:dword - xor edx, edx - mov eax, [base] - or eax, [mem_type] - mov ecx, [reg] - lea ecx, [0x200+ecx*2] - wrmsr + xor edx, edx + mov eax, [base] + or eax, [mem_type] + mov ecx, [reg] + lea ecx, [0x200+ecx*2] + wrmsr - mov ebx, [size] - dec ebx - mov eax, 0xFFFFFFFF - mov edx, 0x0000000F - sub eax, ebx - sbb edx, 0 - or eax, 0x800 - inc ecx - wrmsr - ret + mov ebx, [size] + dec ebx + mov eax, 0xFFFFFFFF + mov edx, 0x0000000F + sub eax, ebx + sbb edx, 0 + or eax, 0x800 + inc ecx + wrmsr + ret endp align 4 proc stall stdcall, delay:dword - push ecx - push edx - push ebx - push eax + push ecx + push edx + push ebx + push eax - mov eax, [delay] - mul [stall_mcs] - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx,edx + mov eax, [delay] + mul [stall_mcs] + mov ebx, eax ;low + mov ecx, edx ;high + rdtsc + add ebx, eax + adc ecx,edx @@: - rdtsc - sub eax, ebx - sbb edx, ecx - jb @B + rdtsc + sub eax, ebx + sbb edx, ecx + jb @B - pop eax - pop ebx - pop edx - pop ecx - ret + pop eax + pop ebx + pop edx + pop ecx + ret endp align 4 proc create_ring_buffer stdcall, size:dword, flags:dword - locals - buf_ptr dd ? - endl + locals + buf_ptr dd ? + endl - mov eax, [size] - test eax, eax - jz .fail + mov eax, [size] + test eax, eax + jz .fail - add eax, eax - stdcall alloc_kernel_space, eax - test eax, eax - jz .fail + add eax, eax + stdcall alloc_kernel_space, eax + test eax, eax + jz .fail - push ebx + push ebx - mov [buf_ptr], eax + mov [buf_ptr], eax - mov ebx, [size] - shr ebx, 12 - push ebx + mov ebx, [size] + shr ebx, 12 + push ebx - stdcall alloc_pages, ebx - pop ecx + stdcall alloc_pages, ebx + pop ecx - test eax, eax - jz .mm_fail + test eax, eax + jz .mm_fail - push edi + push edi - or eax, [flags] - mov edi, [buf_ptr] - mov ebx, [buf_ptr] - mov edx, ecx - shl edx, 2 - shr edi, 10 + or eax, [flags] + mov edi, [buf_ptr] + mov ebx, [buf_ptr] + mov edx, ecx + shl edx, 2 + shr edi, 10 @@: - mov [page_tabs+edi], eax - mov [page_tabs+edi+edx], eax - invlpg [ebx] - invlpg [ebx+0x10000] - add eax, 0x1000 - add ebx, 0x1000 - add edi, 4 - dec ecx - jnz @B + mov [page_tabs+edi], eax + mov [page_tabs+edi+edx], eax + invlpg [ebx] + invlpg [ebx+0x10000] + add eax, 0x1000 + add ebx, 0x1000 + add edi, 4 + dec ecx + jnz @B - mov eax, [buf_ptr] - pop edi - pop ebx - ret + mov eax, [buf_ptr] + pop edi + pop ebx + ret .mm_fail: - stdcall free_kernel_space, [buf_ptr] - xor eax, eax - pop ebx + stdcall free_kernel_space, [buf_ptr] + xor eax, eax + pop ebx .fail: - ret + ret endp diff --git a/kernel/branches/net/core/peload.inc b/kernel/branches/net/core/peload.inc index 25b5931c13..abc4479f52 100644 --- a/kernel/branches/net/core/peload.inc +++ b/kernel/branches/net/core/peload.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 978 $ +$Revision$ include 'export.inc' diff --git a/kernel/branches/net/core/sched.inc b/kernel/branches/net/core/sched.inc index 6cf987f1af..e29ee756fe 100644 --- a/kernel/branches/net/core/sched.inc +++ b/kernel/branches/net/core/sched.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 907 $ +$Revision$ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/kernel/branches/net/core/string.inc b/kernel/branches/net/core/string.inc index 4c18bf05e3..fc6e35473d 100644 --- a/kernel/branches/net/core/string.inc +++ b/kernel/branches/net/core/string.inc @@ -5,7 +5,7 @@ ;; Author: Kees J. Bot 1 Jan 1994 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; size_t strncat(char *s1, const char *s2, size_t n) diff --git a/kernel/branches/net/core/sync.inc b/kernel/branches/net/core/sync.inc index 8350b87273..03873ade11 100644 --- a/kernel/branches/net/core/sync.inc +++ b/kernel/branches/net/core/sync.inc @@ -7,7 +7,7 @@ ;; Author: Halyavin Andrey, halyavin@land.ru ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ if ~defined sync_inc diff --git a/kernel/branches/net/core/sys32.inc b/kernel/branches/net/core/sys32.inc index 94bbc1bee9..10722d93cb 100644 --- a/kernel/branches/net/core/sys32.inc +++ b/kernel/branches/net/core/sys32.inc @@ -11,7 +11,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 982 $ +$Revision$ align 4 ;3A08 diff --git a/kernel/branches/net/core/syscall.inc b/kernel/branches/net/core/syscall.inc index 4b1aae6316..f978bfd379 100644 --- a/kernel/branches/net/core/syscall.inc +++ b/kernel/branches/net/core/syscall.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 940 $ +$Revision$ ; Old style system call converter align 16 diff --git a/kernel/branches/net/core/taskman.inc b/kernel/branches/net/core/taskman.inc index 3339cacea3..fb6ae4cf64 100644 --- a/kernel/branches/net/core/taskman.inc +++ b/kernel/branches/net/core/taskman.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 819 $ +$Revision$ GREEDY_KERNEL equ 0 diff --git a/kernel/branches/net/core/v86.inc b/kernel/branches/net/core/v86.inc index ca0a14c729..497d01dd04 100644 --- a/kernel/branches/net/core/v86.inc +++ b/kernel/branches/net/core/v86.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 979 $ +$Revision$ ; Virtual-8086 mode manager ; diamond, 2007, 2008 diff --git a/kernel/branches/net/data16.inc b/kernel/branches/net/data16.inc index 3bb7776ae4..e6e2e1348d 100644 --- a/kernel/branches/net/data16.inc +++ b/kernel/branches/net/data16.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ flm db 0 diff --git a/kernel/branches/net/data32.inc b/kernel/branches/net/data32.inc index 2e0a60109a..704936bc81 100644 --- a/kernel/branches/net/data32.inc +++ b/kernel/branches/net/data32.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1018 $ +$Revision$ keymap: diff --git a/kernel/branches/net/detect/dev_fd.inc b/kernel/branches/net/detect/dev_fd.inc index bbc6fec6f1..0bf633582f 100644 --- a/kernel/branches/net/detect/dev_fd.inc +++ b/kernel/branches/net/detect/dev_fd.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ;*************************************************** diff --git a/kernel/branches/net/detect/dev_hdcd.inc b/kernel/branches/net/detect/dev_hdcd.inc index 3c6e35a84b..1a956950d5 100644 --- a/kernel/branches/net/detect/dev_hdcd.inc +++ b/kernel/branches/net/detect/dev_hdcd.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ;****************************************************** diff --git a/kernel/branches/net/detect/disks.inc b/kernel/branches/net/detect/disks.inc index 64158ae32b..aba4571cfb 100644 --- a/kernel/branches/net/detect/disks.inc +++ b/kernel/branches/net/detect/disks.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ include 'dev_fd.inc' diff --git a/kernel/branches/net/detect/getcache.inc b/kernel/branches/net/detect/getcache.inc index 2fc363197a..d554bfaec2 100644 --- a/kernel/branches/net/detect/getcache.inc +++ b/kernel/branches/net/detect/getcache.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ pusha diff --git a/kernel/branches/net/detect/sear_par.inc b/kernel/branches/net/detect/sear_par.inc index 46b6b3407f..970f58b346 100644 --- a/kernel/branches/net/detect/sear_par.inc +++ b/kernel/branches/net/detect/sear_par.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 709 $ +$Revision$ ;**************************************************** diff --git a/kernel/branches/net/drivers/RTL8029.asm b/kernel/branches/net/drivers/RTL8029.asm index 82fb17b9b4..0839a1a53b 100644 --- a/kernel/branches/net/drivers/RTL8029.asm +++ b/kernel/branches/net/drivers/RTL8029.asm @@ -18,6 +18,8 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +$Revision$ + format MS COFF API_VERSION equ 0x01000100 diff --git a/kernel/branches/net/drivers/RTL8139.asm b/kernel/branches/net/drivers/RTL8139.asm index c0ecc1cca1..d254ff74b9 100644 --- a/kernel/branches/net/drivers/RTL8139.asm +++ b/kernel/branches/net/drivers/RTL8139.asm @@ -14,6 +14,8 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +$Revision$ + format MS COFF API_VERSION equ 0x01000100 diff --git a/kernel/branches/net/drivers/i8255x.asm b/kernel/branches/net/drivers/i8255x.asm index a61aba407d..425f9e72c5 100644 --- a/kernel/branches/net/drivers/i8255x.asm +++ b/kernel/branches/net/drivers/i8255x.asm @@ -16,6 +16,8 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +$Revision$ + format MS COFF API_VERSION equ 0x01000100 diff --git a/kernel/branches/net/drivers/pcnet32.asm b/kernel/branches/net/drivers/pcnet32.asm index 5b2eb541bb..e350f471f4 100644 --- a/kernel/branches/net/drivers/pcnet32.asm +++ b/kernel/branches/net/drivers/pcnet32.asm @@ -10,7 +10,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;$Revision$ +$Revision$ format MS COFF @@ -77,7 +77,7 @@ struc ETH_DEVICE { ; The following fields up to .tx_ring_phys inclusive form ; initialization block for hardware; do not modify - align 4 ; initialization block must be dword-aligned + align 4 ; initialization block must be dword-aligned .private: .mode_ dw ? .tlen_rlen dw ? @@ -955,8 +955,8 @@ if 0 ; ------------------------------------------------ end if -; mov esi, 1 -; call Sleep +; mov esi, 1 +; call Sleep reset: @@ -1217,7 +1217,7 @@ transmit: align 4 int_handler: -; DEBUGF 1,"IRQ %x ",eax:2 ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO +; DEBUGF 1,"IRQ %x ",eax:2 ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO ; find pointer of device wich made IRQ occur @@ -1300,7 +1300,7 @@ int_handler: and ecx, 3 rep movsb -; mov word [eax + buf_head.length], PCNET_PKT_BUF_SZ_NEG +; mov word [eax + buf_head.length], PCNET_PKT_BUF_SZ_NEG mov word [eax + buf_head.status], PCNET_RXSTAT_OWN ; Set OWN bit back to 1 (controller may write to tx-buffer again now) inc [ebx + device.cur_rx] ; update descriptor diff --git a/kernel/branches/net/fdo.inc b/kernel/branches/net/fdo.inc index c7d91ee173..ca9055b563 100644 --- a/kernel/branches/net/fdo.inc +++ b/kernel/branches/net/fdo.inc @@ -4,7 +4,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; diff --git a/kernel/branches/net/fs/fat12.inc b/kernel/branches/net/fs/fat12.inc index 325cf0d746..5866494d00 100644 --- a/kernel/branches/net/fs/fat12.inc +++ b/kernel/branches/net/fs/fat12.inc @@ -8,7 +8,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ n_sector dd 0 ; temporary save for sector value diff --git a/kernel/branches/net/fs/fat32.inc b/kernel/branches/net/fs/fat32.inc index 7a9d020f4d..9477eb0077 100644 --- a/kernel/branches/net/fs/fat32.inc +++ b/kernel/branches/net/fs/fat32.inc @@ -44,7 +44,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 709 $ +$Revision$ cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 diff --git a/kernel/branches/net/fs/fs.inc b/kernel/branches/net/fs/fs.inc index 2a5e79f484..71faa505c1 100644 --- a/kernel/branches/net/fs/fs.inc +++ b/kernel/branches/net/fs/fs.inc @@ -17,7 +17,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 709 $ +$Revision$ iglobal diff --git a/kernel/branches/net/fs/fs_lfn.inc b/kernel/branches/net/fs/fs_lfn.inc index 3bbb8e1a8f..a80e50740b 100644 --- a/kernel/branches/net/fs/fs_lfn.inc +++ b/kernel/branches/net/fs/fs_lfn.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 709 $ +$Revision$ image_of_eax EQU esp+36 diff --git a/kernel/branches/net/fs/iso9660.inc b/kernel/branches/net/fs/iso9660.inc index 16ed9bfbeb..8f0555e29c 100644 --- a/kernel/branches/net/fs/iso9660.inc +++ b/kernel/branches/net/fs/iso9660.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ uglobal diff --git a/kernel/branches/net/fs/ntfs.inc b/kernel/branches/net/fs/ntfs.inc index bf6d9ffca9..a28c48c93d 100644 --- a/kernel/branches/net/fs/ntfs.inc +++ b/kernel/branches/net/fs/ntfs.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ntfs_test_bootsec: diff --git a/kernel/branches/net/fs/parse_fn.inc b/kernel/branches/net/fs/parse_fn.inc index d9524743bd..a1061ca937 100644 --- a/kernel/branches/net/fs/parse_fn.inc +++ b/kernel/branches/net/fs/parse_fn.inc @@ -14,7 +14,7 @@ ; ;------------------------------------------------------------------------- -$Revision: 750 $ +$Revision$ iglobal diff --git a/kernel/branches/net/fs/part_set.inc b/kernel/branches/net/fs/part_set.inc index 9c21709859..4d9ed4120f 100644 --- a/kernel/branches/net/fs/part_set.inc +++ b/kernel/branches/net/fs/part_set.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 709 $ +$Revision$ ;************************************************************* diff --git a/kernel/branches/net/gui/button.inc b/kernel/branches/net/gui/button.inc index f351dbdce8..f498180f2a 100644 --- a/kernel/branches/net/gui/button.inc +++ b/kernel/branches/net/gui/button.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ max_buttons=4095 diff --git a/kernel/branches/net/gui/event.inc b/kernel/branches/net/gui/event.inc index fc52dc0687..2046feac41 100644 --- a/kernel/branches/net/gui/event.inc +++ b/kernel/branches/net/gui/event.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 671 $ +$Revision$ uglobal align 4 diff --git a/kernel/branches/net/gui/font.inc b/kernel/branches/net/gui/font.inc index 6e2c3e3eba..e693361153 100644 --- a/kernel/branches/net/gui/font.inc +++ b/kernel/branches/net/gui/font.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ; // Alver 22.06.2008 // { align 4 diff --git a/kernel/branches/net/gui/mouse.inc b/kernel/branches/net/gui/mouse.inc index b16a78df9e..98b38f88c7 100644 --- a/kernel/branches/net/gui/mouse.inc +++ b/kernel/branches/net/gui/mouse.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ iglobal diff --git a/kernel/branches/net/gui/skincode.inc b/kernel/branches/net/gui/skincode.inc index ca9997ed2e..9e6ffbce96 100644 --- a/kernel/branches/net/gui/skincode.inc +++ b/kernel/branches/net/gui/skincode.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ include "skindata.inc" diff --git a/kernel/branches/net/gui/skindata.inc b/kernel/branches/net/gui/skindata.inc index d5135ecf70..b2e3c12447 100644 --- a/kernel/branches/net/gui/skindata.inc +++ b/kernel/branches/net/gui/skindata.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ; diff --git a/kernel/branches/net/gui/window.inc b/kernel/branches/net/gui/window.inc index 521c7f3627..793dda681a 100644 --- a/kernel/branches/net/gui/window.inc +++ b/kernel/branches/net/gui/window.inc @@ -6,7 +6,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 994 $ +$Revision$ get_titlebar_height: ; edi = window draw_data pointer diff --git a/kernel/branches/net/hid/keyboard.inc b/kernel/branches/net/hid/keyboard.inc index 503492cc19..9d6d0b836e 100644 --- a/kernel/branches/net/hid/keyboard.inc +++ b/kernel/branches/net/hid/keyboard.inc @@ -5,7 +5,7 @@ ;; Distributed under terms of the GNU General Public License ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 641 $ +$Revision$ ;// mike.dld [ diff --git a/kernel/branches/net/hid/mousedrv.inc b/kernel/branches/net/hid/mousedrv.inc index f64d910e13..430600664a 100644 --- a/kernel/branches/net/hid/mousedrv.inc +++ b/kernel/branches/net/hid/mousedrv.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ; check mouse diff --git a/kernel/branches/net/hid/set_dtc.inc b/kernel/branches/net/hid/set_dtc.inc index 61c38e1e65..53539700eb 100644 --- a/kernel/branches/net/hid/set_dtc.inc +++ b/kernel/branches/net/hid/set_dtc.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ;setting date,time,clock and alarm-clock diff --git a/kernel/branches/net/imports.inc b/kernel/branches/net/imports.inc index c42f655692..3d94b67a12 100644 --- a/kernel/branches/net/imports.inc +++ b/kernel/branches/net/imports.inc @@ -11,7 +11,7 @@ ; ;============================================================================ -$Revision: 750 $ +$Revision$ align 4 diff --git a/kernel/branches/net/init.inc b/kernel/branches/net/init.inc index 7dc1b3134b..54aa7b5978 100644 --- a/kernel/branches/net/init.inc +++ b/kernel/branches/net/init.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ MEM_WB equ 6 ;write-back memory diff --git a/kernel/branches/net/kernel32.inc b/kernel/branches/net/kernel32.inc index c371fca9b1..b43b404635 100644 --- a/kernel/branches/net/kernel32.inc +++ b/kernel/branches/net/kernel32.inc @@ -13,7 +13,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ;struc db [a] { common . db a diff --git a/kernel/branches/net/kglobals.inc b/kernel/branches/net/kglobals.inc index 792ade595e..3299a5ebe3 100644 --- a/kernel/branches/net/kglobals.inc +++ b/kernel/branches/net/kglobals.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ;------------------------------------------------------------------ diff --git a/kernel/branches/net/macros.inc b/kernel/branches/net/macros.inc index 901c7a7d13..e99a17ec97 100644 --- a/kernel/branches/net/macros.inc +++ b/kernel/branches/net/macros.inc @@ -9,7 +9,7 @@ macro $Revision a { \} } -$Revision: 750 $ +$Revision$ ; structure definition helper diff --git a/kernel/branches/net/network/ARP.inc b/kernel/branches/net/network/ARP.inc index 0564899920..f311890633 100644 --- a/kernel/branches/net/network/ARP.inc +++ b/kernel/branches/net/network/ARP.inc @@ -17,7 +17,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ARP_NO_ENTRY equ 0 @@ -26,7 +26,7 @@ ARP_AWAITING_RESPONSE equ 2 ARP_RESPONSE_TIMEOUT equ 3 ARP_REQUEST_TTL = 20 ; in seconds -ARP_ENTRY_TTL = 30 ; in seconds +ARP_ENTRY_TTL = 600 ; in seconds ETHER_ARP equ 0x0608 @@ -135,8 +135,10 @@ ARP_IP_to_MAC: mov ebx, [IP_LIST+edx] and ebx, [SUBNET_LIST+edx] + mov ecx, eax and ecx, [SUBNET_LIST+edx] + cmp ecx, ebx je .local @@ -146,12 +148,13 @@ ARP_IP_to_MAC: .local: ; try to find it on the list mov ecx, [NumARP] + test ecx, ecx jz .not_in_list mov esi, ARPTable + ARP_ENTRY.IP .scan_loop: - scasd - jz .found_it - add esi, ARP_ENTRY.size - 4 + cmp [esi], eax + je .found_it + add esi, ARP_ENTRY.size loop .scan_loop .not_in_list: @@ -177,7 +180,8 @@ ARP_IP_to_MAC: ret .found_it: - DEBUGF 1,"Found MAC! (%u-%u-%u-%u-%u-%u)\n",[esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2 + add esi, ARP_ENTRY.MAC + DEBUGF 1,"Found MAC! (%x-%x-%x-%x-%x-%x)\n",[esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2 movzx eax, word [esi] mov ebx, [esi+2] @@ -221,34 +225,30 @@ ARP_create_request: cmp edi, -1 je .exit - mov word [edi + ARP_Packet.HardwareType], 0x0100 ;Ethernet - mov word [edi + ARP_Packet.ProtocolType], 0x0008 ;IP - mov byte [edi + ARP_Packet.HardwareSize], 6 ;MAC-addr length - mov byte [edi + ARP_Packet.ProtocolSize], 4 ;IP-addr length - mov word [edi + ARP_Packet.Opcode], ARP_REQ_OPCODE ;Request + mov ecx, eax + + mov [edi + ARP_Packet.HardwareType], 0x0100 ;Ethernet + mov [edi + ARP_Packet.ProtocolType], 0x0008 ;IP + mov [edi + ARP_Packet.HardwareSize], 6 ;MAC-addr length + mov [edi + ARP_Packet.ProtocolSize], 4 ;IP-addr length + mov [edi + ARP_Packet.Opcode], ARP_REQ_OPCODE ;Request add edi, ARP_Packet.SenderMAC ; sendermac - lea esi, [edx + ETH_DEVICE.mac] ; + lea esi, [ebx + ETH_DEVICE.mac] ; movsw ; movsd ; - + pop eax ; + stosd ; + mov eax, -1 ; destmac + stosd ; + stosw ; pop eax stosd ; - xor eax, eax ; destmac - movsw ; - movsw ; + DEBUGF 1,"ARP Packet for device %x created successfully\n", ebx - pop eax - movsd ; - - DEBUGF 1,"ARP Packet for device %x created successfully\n", edx - - call esi - - inc [ARP_PACKETS_TX+4*edi] - - ret + push edx ecx + jmp ETH_Sender .exit: add esp, 8 @@ -278,37 +278,38 @@ ARP_decrease_entry_ttls: .timer_loop: - movsx esi, word [ebx + ARP_ENTRY.TTL] - cmp esi, 0xFFFFFFFF + cmp [ebx + ARP_ENTRY.TTL], 0xFFFF je .timer_loop_end ;if TTL==0xFFFF then it's static entry - test esi, esi + cmp [ebx + ARP_ENTRY.TTL], 0 jnz .timer_loop_end_with_dec ;if TTL!=0 ; Ok, TTL is 0 ;if Status==AWAITING_RESPONSE and TTL==0 ;then we have to change it to ARP_RESPONSE_TIMEOUT - cmp word [ebx + ARP_ENTRY.Status], ARP_AWAITING_RESPONSE + cmp [ebx + ARP_ENTRY.Status], ARP_AWAITING_RESPONSE jne @f - mov word [ebx + ARP_ENTRY.Status], ARP_RESPONSE_TIMEOUT - mov word [ebx + ARP_ENTRY.TTL], word 0x000A ;10 sec + mov [ebx + ARP_ENTRY.Status], ARP_RESPONSE_TIMEOUT + mov [ebx + ARP_ENTRY.TTL], word 0x000A ;10 sec jmp .timer_loop_end @@: ;if TTL==0 and Status==VALID_MAPPING, we have to delete it ;if TTL==0 and Status==RESPONSE_TIMEOUT, delete too - mov esi, dword[NumARP] + mov esi, [NumARP] sub esi, ecx ;esi=index of entry, will be deleted + push ebx ecx call ARP_del_entry + pop ecx ebx jmp .timer_loop_end .timer_loop_end_with_dec: - dec word [ebx + ARP_ENTRY.TTL] ;decrease TTL + dec [ebx + ARP_ENTRY.TTL] ;decrease TTL .timer_loop_end: @@ -338,6 +339,8 @@ ARP_decrease_entry_ttls: align 4 ARP_add_entry: + DEBUGF 1,"ARP add entry: " + mov ecx, [NumARP] test ecx, ecx jz .add @@ -355,7 +358,7 @@ ARP_add_entry: cmp dword[esi + ARP_ENTRY.TTL], 0xFFFF ; static entry jne .notstatic cmp dword[esp + ARP_ENTRY.TTL], 0xFFFF - jne .exit + jne .error .notstatic: mov ebx, [NumARP] @@ -369,14 +372,13 @@ ARP_add_entry: mov ecx, [NumARP] cmp ecx, ARP_TABLE_SIZE - jge .full + jge .error .add: - push ecx imul ecx, ARP_ENTRY.size lea edi, [ecx + ARPTable] - lea esi, [esp + 4] + lea esi, [esp + 8] mov ecx, ARP_ENTRY.size/2 repz movsw @@ -384,17 +386,19 @@ ARP_add_entry: pop eax .exit: + pop ebx ; return addr + add esp, ARP_ENTRY.size + DEBUGF 1,"Exiting\n" + jmp ebx - add esp, 14 - ret +.error: -.full: + DEBUGF 1,"error! \n" mov eax, -1 jmp .exit - ;--------------------------------------------------------------------------- ; ; ARP_del_entry @@ -407,6 +411,13 @@ ARP_add_entry: align 4 ARP_del_entry: + DEBUGF 1,"ARP del entry %u, total entrys: %u\n", esi, [NumARP] + + cmp esi, [NumARP] + jge .error + + DEBUGF 1,"deleting the entry..\n" + imul esi, ARP_ENTRY.size mov ecx, (ARP_TABLE_SIZE - 1) * ARP_ENTRY.size @@ -416,10 +427,10 @@ ARP_del_entry: lea esi, [edi + ARP_ENTRY.size] ;esi=ptr to next entry shr ecx,1 ;ecx/2 => ARP_ENTRY_SIZE MUST BE EVEN NUMBER! - cld rep movsw dec [NumARP] ;decrease arp-entries counter +.error: ret @@ -449,34 +460,40 @@ ARP_handler: cmp word [edx + ARP_Packet.Opcode], ARP_REP_OPCODE ; Is this a reply packet? jne .maybe_request + DEBUGF 1,"ARP_Handler - it's a reply packet from %u.%u.%u.%u\n",\ + [edx + ARP_Packet.SenderIP]:1,[edx + ARP_Packet.SenderIP+1]:1,[edx + ARP_Packet.SenderIP+2]:1,[edx + ARP_Packet.SenderIP+3]:1, + mov ecx, [NumARP] test ecx, ecx jz .exit - mov eax, [esp] - mov eax, [eax + ARP_Packet.SenderIP] + mov eax, [edx + ARP_Packet.SenderIP] mov esi, ARPTable+ARP_ENTRY.IP .loop: - scasd - jz .gotit - add esi, ARP_ENTRY.size-4 + cmp [esi], eax + je .gotit + add esi, ARP_ENTRY.size loop .loop jmp .exit .gotit: - cmp [esi-4+ARP_ENTRY.Status], 0x0300 ;if it is a static entry, dont touch it + + DEBUGF 1,"ARP_Handler - found matching entry\n" + + cmp [esi+ARP_ENTRY.Status], 0x0300 ;if it is a static entry, dont touch it je .exit - mov [esi-4+ARP_ENTRY.Status], ARP_VALID_MAPPING - mov [esi+ARP_ENTRY.TTL-4], ARP_ENTRY_TTL + DEBUGF 1,"ARP_Handler - updating entry\n" - mov ebx, [esp] - mov eax, dword [ebx + ARP_Packet.SenderMAC] - mov dword [esi+ARP_ENTRY.MAC-4], eax - mov ax , word [ebx + ARP_Packet.SenderMAC + 4] - mov word [esi+ARP_ENTRY.MAC-4+4], ax + mov [esi+ARP_ENTRY.Status], ARP_VALID_MAPPING + mov [esi+ARP_ENTRY.TTL], ARP_ENTRY_TTL + + mov eax, dword [edx + ARP_Packet.SenderMAC] + mov dword [esi+ARP_ENTRY.MAC], eax + mov ax , word [edx + ARP_Packet.SenderMAC + 4] + mov word [esi+ARP_ENTRY.MAC+4], ax jmp .exit @@ -489,7 +506,7 @@ ARP_handler: jne .exit call ETH_struc2dev - DEBUGF 1,"ARP Packet came from device: %u\n", edi + DEBUGF 1,"ARP Request packet through device: %u\n", edi inc [ARP_PACKETS_RX+4*edi] cmp edi, -1 jz .exit @@ -536,13 +553,15 @@ ARP_handler: ; mov ax , ETHER_ARP ; stosw + DEBUGF 1,"ARP_Handler - Sending reply \n" + jmp ETH_Sender ; And send it! .exit: call kernel_free add esp, 4 ; pop (balance stack) - DEBUGF 1,"ARP_Handler - fail\n" + DEBUGF 1,"ARP_Handler - exiting\n" ret diff --git a/kernel/branches/net/network/IPv4.inc b/kernel/branches/net/network/IPv4.inc index b8ee99802e..107cefb28a 100644 --- a/kernel/branches/net/network/IPv4.inc +++ b/kernel/branches/net/network/IPv4.inc @@ -16,7 +16,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 922 $ +$Revision$ ; IP underlying protocols numbers @@ -507,29 +507,23 @@ IPv4_decrease_fragment_ttls: align 4 IPv4_create_packet: - DEBUGF 1,"Create IPv4 Packet\n" + DEBUGF 1,"Create IPv4 Packet (size=%u)\n", ecx - cmp ecx, 1514 + cmp ecx, 1480 jg .exit_ + push ecx eax ebx dx di + cmp eax, -1 je .broadcast ; If it is broadcast, just send call ARP_IP_to_MAC cmp eax, -1 - jne .found + je .not_found - DEBUGF 1,"Create IPv4 Packet - ARP entry not found!\n" - - ; TODO: QUEUE! - or edi, -1 - - ret - - .found: - push ax push ebx + push ax jmp .send @@ -537,19 +531,17 @@ IPv4_create_packet: push word -1 push dword -1 - .send: - push ecx eax ebx dx di call IPv4_dest_to_dev inc [IP_PACKETS_TX+4*edi] - mov edi, [ETH_DRV_LIST + 4*edi] - lea eax, [edi + ETH_DEVICE.mac] - lea ebx, [esp+16] - mov ecx, [esp+12] + mov edx, [ETH_DRV_LIST + 4*edi] + lea eax, [edx + ETH_DEVICE.mac] + mov ebx, esp + mov ecx, [esp+18] ;; 18 or 22 ?? add ecx, IPv4_Packet.DataOrOptional - mov edx, edi ;;; mov di , ETHER_IPv4 call ETH_create_Packet ; TODO: figure out a way to make this work with other protocols too + add esp, 6 cmp edi, -1 je .exit @@ -578,12 +570,14 @@ IPv4_create_packet: DEBUGF 1,"IPv4 Packet for device %x created successfully\n", edx - add esp, 6 - ret + + .not_found: + DEBUGF 1,"Create IPv4 Packet - ARP entry not found!\n" + ; TODO: QUEUE! .exit: - add esp, 16+6 + add esp, 16 .exit_: DEBUGF 1,"Create IPv4 Packet - failed\n" or edi, -1 @@ -591,6 +585,7 @@ IPv4_create_packet: + ;--------------------------------------------------------------------------- ; ; IPv4_dest_to_dev diff --git a/kernel/branches/net/network/ethernet.inc b/kernel/branches/net/network/ethernet.inc index a222074b04..93bf8c4296 100644 --- a/kernel/branches/net/network/ethernet.inc +++ b/kernel/branches/net/network/ethernet.inc @@ -14,7 +14,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ MAX_ETH_DEVICES equ MAX_NET_DEVICES ETH_QUEUE_SIZE equ 16 @@ -352,11 +352,11 @@ ETH_struc2dev: ; device number in edx ; protocol in di ; -; OUT: edi is -1 on error, pointer to buffer otherwise ;; TODO: XCHG EDX AND EBX output parameters +; OUT: edi is -1 on error, pointer to buffer otherwise ; eax points to buffer start -; ebx is size of complete buffer +; ebx is pointer to device structure ; ecx is unchanged (packet size of embedded data) -; edx is pointer to device structure +; edx is size of complete buffer ; esi points to procedure wich needs to be called to send packet ; ;--------------------------------------------------------------------------- @@ -364,11 +364,9 @@ ETH_struc2dev: align 4 ETH_create_Packet: - DEBUGF 1,"Creating Ethernet Packet:\n" + DEBUGF 1,"Creating Ethernet Packet (size=%u): \n", ecx - cmp ecx, 60-ETH_FRAME.Data - jl .exit - cmp ecx, 1514-ETH_FRAME.Data + cmp ecx, 1500 jg .exit push ecx di eax ebx edx @@ -394,22 +392,31 @@ ETH_create_Packet: stosw lea eax, [edi - ETH_FRAME.Data] ; Set eax to buffer start - mov ebx, ecx ; Set ebx to complete buffer size + mov edx, ecx ; Set ebx to complete buffer size pop ecx mov esi, ETH_Sender - xor edx, edx ;;;; TODO: Fixme - mov edx, [ETH_DRV_LIST + edx] + xor ebx, ebx ;;;; TODO: Fixme + mov ebx, [ETH_DRV_LIST + ebx] - DEBUGF 1,"done: %x size:%u device:%x\n", eax, ebx, edx + cmp edx, 46 + ETH_FRAME.Data ; If data size is less then 46, add padding bytes + jg .continue + mov edx, 46 + ETH_FRAME.Data + .continue: + + DEBUGF 1,"done: %x size:%u device:%x\n", eax, edx, ebx ret .pop_exit: + DEBUGF 1,"Out of ram space!!\n" add esp, 18 - .exit: - or edi, -1 + or edi,-1 ret + .exit: + DEBUGF 1,"Packet too large!\n" + or edi, -1 + ret diff --git a/kernel/branches/net/network/icmp.inc b/kernel/branches/net/network/icmp.inc index 9cc0ec0a7f..029e25160d 100644 --- a/kernel/branches/net/network/icmp.inc +++ b/kernel/branches/net/network/icmp.inc @@ -17,7 +17,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ ; ICMP types & codes @@ -214,7 +214,7 @@ ICMP_handler: ;TODO: works only on pure ethernet right now ! .check_sockets: - ; TODO: validate the header & checksum. Discard buffer if error + ; TODO: validate the header & checksum. ; Look for an open ICMP socket @@ -387,7 +387,7 @@ ICMP_create_packet: cmp edi, -1 je .exit - DEBUGF 1,"full icmp packet size: %u\n", ebx + DEBUGF 1,"full icmp packet size: %u\n", edx pop eax mov word [edi + ICMP_Packet.Type], ax ; Write both type and code bytes at once @@ -411,8 +411,7 @@ ICMP_create_packet: and cx , 3 rep movsb - sub edi, ebx ;; TODO: find a better way to remember start of packet - xchg ebx, edx + sub edi, edx ;; TODO: find a better way to remember start of packet mov ecx, [ebx + ETH_DEVICE.transmit] push edx edi ecx DEBUGF 1,"Sending ICMP Packet\n" diff --git a/kernel/branches/net/network/queue.inc b/kernel/branches/net/network/queue.inc index 418ce3d8d2..b37029a9c8 100644 --- a/kernel/branches/net/network/queue.inc +++ b/kernel/branches/net/network/queue.inc @@ -12,7 +12,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ struct queue .size dd ? diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index f3cadb53d7..36be87d0f4 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -14,7 +14,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1019 $ +$Revision$ align 4 struct SOCKET @@ -27,8 +27,8 @@ struct SOCKET .Protocol dd ? ; ICMP/IPv4/ARP/ .LocalIP dd ? ; local IP address .RemoteIP dd ? ; remote IP address - .LocalPort dw ? ; local port - .RemotePort dw ? ; remote port + .LocalPort dw ? ; local port (In INET byte order) + .RemotePort dw ? ; remote port (IN INET byte order .OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state) .OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state) .rxDataCount dd ? ; rx data count @@ -130,6 +130,7 @@ s_error: ; OUT: eax is socket num, -1 on error ; ;----------------------------------------------- +align 4 socket_open: DEBUGF 1,"socket_open: domain: %u, type: %u",ecx, edx @@ -162,7 +163,7 @@ socket_open: ; OUT: 0 on success ; ;----------------------------------------------- - +align 4 socket_bind: DEBUGF 1,"Socket_bind: socknum: %u sockaddr: %x, length: %u, ",ecx,edx,esi @@ -175,51 +176,32 @@ socket_bind: jl s_error cmp word [edx], AF_INET4 - je .af_inet4 - - jmp s_error + jne s_error .af_inet4: cmp esi, 6 jl s_error + mov ecx, [eax + SOCKET.Type] mov bx, word [edx + 2] - rol bx,8 ;;; - DEBUGF 1,"local port: %u ",bx + DEBUGF 1,"local port: %x ",bx test bx, bx - jnz .check_only + jz .find_free - mov bx , [last_UDP_port] + call socket_check_port + test bx, bx + je s_error + jmp .got_port - .find_port_loop: - inc bx - inc [last_UDP_port] + .find_free: - .check_only: - mov esi, net_sockets + call socket_find_port + test bx, bx + je s_error - .next_udp_socket: - mov esi, [esi + SOCKET.NextPtr] - or esi, esi - jz .udp_port_ok - - cmp [esi + SOCKET.Type], IP_PROTO_UDP - jne .next_udp_socket - - cmp [esi + SOCKET.LocalPort], bx - jne .next_udp_socket - - cmp word [edx + 2], 0 - jne s_error - - cmp bx, MAX_EPHEMERAL_PORT - jle .find_port_loop - - mov [last_UDP_port], MIN_EPHEMERAL_PORT - jmp s_error - - .udp_port_ok: + .got_port: + DEBUGF 1,"using port: %x ",bx mov word [eax + SOCKET.LocalPort], bx mov ebx, dword [edx + 4] @@ -246,7 +228,6 @@ socket_bind: ; ;----------------------------------------------- align 4 - socket_connect: DEBUGF 1,"Socket_connect: socknum: %u sockaddr: %x, length: %u,",ecx,edx,esi @@ -274,22 +255,19 @@ socket_connect: cmp [eax + SOCKET.Type], IP_PROTO_ICMP je .icmp -; cmp [eax + SOCKET.Type], IP_PROTO_TCP -; je .tcp + cmp [eax + SOCKET.Type], IP_PROTO_TCP + je .tcp jmp s_error .udp: mov bx , word [edx + 2] - rol bx, 8 mov word [eax + SOCKET.RemotePort], bx - - DEBUGF 1,"remote port: %u ",bx + DEBUGF 1,"remote port: %x ",bx mov ebx, dword [edx + 4] mov dword [eax + SOCKET.RemoteIP], ebx - DEBUGF 1,"remote ip: %u.%u.%u.%u\n",[edx+4]:1,[edx+5]:1,[edx+6]:1,[edx+7]:1 mov dword [esp+32],0 @@ -395,7 +373,7 @@ socket_connect: ; OUT: eax is socket num, -1 on error ; ;----------------------------------------------- - +align 4 socket_listen: DEBUGF 1,"Socket_listen: socknum: %u backlog: %u\n",ecx,edx @@ -432,8 +410,7 @@ socket_listen: ; OUT: eax is socket num, -1 on error ; ;----------------------------------------------- - - +align 4 socket_accept: DEBUGF 1,"Socket_accept: socknum: %u sockaddr: %x, length: %u\n",ecx,edx,esi @@ -479,7 +456,7 @@ socket_accept: ; OUT: eax is socket num, -1 on error ; ;----------------------------------------------- - +align 4 socket_close: DEBUGF 1,"Socket_close: socknum: %u\n",ecx @@ -495,8 +472,8 @@ socket_close: cmp [eax + SOCKET.Type], IP_PROTO_ICMP je .icmp -; cmp [eax + SOCKET.Type], IP_PROTO_TCP -; je .tcp + cmp [eax + SOCKET.Type], IP_PROTO_TCP + je .tcp jmp s_error @@ -629,7 +606,7 @@ end if ; OUT: eax is number of bytes copied, -1 on error ; ;----------------------------------------------- - +align 4 socket_recv: DEBUGF 1,"Socket_receive: socknum: %u sockaddr: %x, length: %u, flags: %x\n",ecx,edx,esi,edi @@ -703,13 +680,13 @@ socket_recv: ; ; ; IN: socket number in ecx -; addr in edx -; addrlen in esi +; pointer to data in edx +; datalength in esi ; flags in edi ; OUT: -1 on error ; ;----------------------------------------------- - +align 4 socket_send: DEBUGF 1,"Socket_send: socknum: %u sockaddr: %x, length: %u, flags: %x, ",ecx,edx,esi,edi @@ -718,6 +695,13 @@ socket_send: or eax, eax jz s_error + cmp word [eax + SOCKET.Domain], AF_INET4 + je .af_inet4 + + jmp s_error + + .af_inet4: + DEBUGF 1,"Socket type:%u\n", [eax + SOCKET.Type]:4 cmp [eax + SOCKET.Type], IP_PROTO_UDP @@ -726,21 +710,30 @@ socket_send: cmp [eax + SOCKET.Type], IP_PROTO_ICMP je .icmp -; cmp [eax + SOCKET.Type], IP_PROTO_TCP -; je .tcp + cmp [eax + SOCKET.Type], IP_PROTO_TCP + je .tcp jmp s_error .udp: - DEBUGF 1,"type: UDP\n" + DEBUGF 1,"type: UDP, " + + cmp [eax + SOCKET.LocalPort],0 + jne .port_ok + + mov ecx, [eax + SOCKET.Type] + call socket_find_port + test bx, bx + je s_error + mov [eax + SOCKET.LocalPort], bx + + .port_ok: mov ecx, esi mov esi, edx mov edx, dword [eax + SOCKET.LocalPort] ; load local port and remote port at once - DEBUGF 1,"local port: %u, remote port:%u\n",[eax + SOCKET.LocalPort]:2, [eax + SOCKET.RemotePort]:2 - bswap edx ;;; - rol edx, 16 ;;; + DEBUGF 1,"local port: %x, remote port: %x\n",[eax + SOCKET.LocalPort]:2, [eax + SOCKET.RemotePort]:2 mov ebx, [eax + SOCKET.LocalIP] mov eax, [eax + SOCKET.RemoteIP] @@ -781,6 +774,173 @@ socket_send: +;----------------------------------------------- +; +; SOCKET_find_free_port (local port) +; +; works with INET byte order +; +; IN: type in ecx (TCP/UDP) +; OUT: bx = 0 on error, portnumber otherwise +; +;----------------------------------------------- +align 4 +socket_find_port: + + DEBUGF 1,"Socket_find_free_port, type: %u ",eax + + cmp ecx, IP_PROTO_UDP + je .udp + + cmp ecx, IP_PROTO_TCP + je .tcp + + .udp: + mov bx, [last_UDP_port] + je .continue + + .tcp: + mov bx, [last_TCP_port] + + + .continue: + inc bx + + .check_only: + mov esi, net_sockets + + .next_socket: + mov esi, [esi + SOCKET.NextPtr] + or esi, esi + jz .port_ok + + cmp [esi + SOCKET.Type], ecx + jne .next_socket + + rol bx, 8 + cmp [esi + SOCKET.LocalPort], bx + rol bx, 8 ; this doesnt change the zero flag, does it ? + jne .next_socket + + cmp bx, MAX_EPHEMERAL_PORT + jle .continue + + ; todo: WRAP! +; mov [last_UDP_port], MIN_EPHEMERAL_PORT + .exit: + xor ebx, ebx + + .port_ok: + rol bx, 8 + ret + +;----------------------------------------------- +; +; SOCKET_check_port (local port) +; +; works with INET byte order +; +; IN: type in ecx (TCP/UDP) +; port to check in bx +; OUT: bx = 0 on error, unchanged otherwise +; +;----------------------------------------------- +align 4 +socket_check_port: + mov esi, net_sockets + + .next_socket: + mov esi, [esi + SOCKET.NextPtr] + or esi, esi + jz .port_ok + + cmp [esi + SOCKET.Type], ecx + jne .next_socket + + cmp [esi + SOCKET.LocalPort], bx + jne .next_socket + + xor ebx, ebx + + .port_ok: + ret + + + +;----------------------------------------------- +; +; SOCKET_internal_receiver +; +; Checks if any socket wants the received data +; If so, update the socket +; +; IN: eax = socket number +; ecx = number of bytes +; esi = pointer to beginning of data +; dx = Remote port (in INET byte order) +; edi = IP address of sender +; +; OUT: xxx +; +;----------------------------------------------- +align 4 +socket_internal_receiver: + + DEBUGF 1,"internal socket receiver\n" + + lea ebx, [eax + SOCKET.lock] + call wait_mutex + + mov [eax + SOCKET.RemotePort], dx ; update remote port number + mov [eax + SOCKET.RemoteIP], edi + + mov edx, [eax + SOCKET.rxDataCount] ; get # of bytes already in buffer + DEBUGF 1,"bytes already in socket: %u ", edx + + lea edi, [ecx + edx] ; check for buffer overflow + cmp edi, SOCKETBUFFSIZE - SOCKETHEADERSIZE ; + jg .dump ; + + lea edi, [eax + SOCKET.rxData + edx] + add [eax + SOCKET.rxDataCount], ecx ; increment the count of bytes in buffer + DEBUGF 1,"adding %u bytes\n", ecx + + ; copy the data across + push cx + shr ecx, 2 + rep movsd + pop cx + and cx, 3 + rep movsb + + DEBUGF 1,"socket updated\n" + + mov [eax + SOCKET.lock], 0 + + ; flag an event to the application + mov edx, [eax + SOCKET.PID] ; get socket owner PID + mov ecx, 1 + mov esi, TASK_DATA + TASKDATA.pid + + .next_pid: + cmp [esi], edx + je .found_pid + inc ecx + add esi, 0x20 + cmp ecx, [TASK_COUNT] + jbe .next_pid + ret + + .found_pid: + shl ecx, 8 + or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK ; stack event + mov [check_idle_semaphore], 200 + ret + + .dump: + mov [eax + SOCKET.lock], 0 + ret + diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index e1bca93fab..d2d5dc9fe1 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -17,7 +17,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ uglobal last_1sTick db ? diff --git a/kernel/branches/net/network/tcp.inc b/kernel/branches/net/network/tcp.inc index 0d46595d29..a0b9c57ca9 100644 --- a/kernel/branches/net/network/tcp.inc +++ b/kernel/branches/net/network/tcp.inc @@ -15,7 +15,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1019 $ +$Revision$ ; TCP TCB states diff --git a/kernel/branches/net/network/udp.inc b/kernel/branches/net/network/udp.inc index 1694e9d818..2949b56f31 100644 --- a/kernel/branches/net/network/udp.inc +++ b/kernel/branches/net/network/udp.inc @@ -14,7 +14,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ struct UDP_Packet @@ -44,7 +44,6 @@ endg ; OUT: / ; ;----------------------------------------------------------------- - align 4 UDP_init: @@ -72,117 +71,67 @@ UDP_init: ; OUT: / ; ;----------------------------------------------------------------- - +align 4 UDP_handler: DEBUGF 1,"UDP_Handler\n" - ; TODO: First validate the header & checksum. Discard buffer if error + ; TODO: First validate the header & checksum! ; Look for a socket where ; IP Packet UDP Destination Port = local Port ; IP Packet SA = Remote IP - mov esi, net_sockets + mov eax, net_sockets .try_more: - mov ax , [edx + UDP_Packet.DestinationPort] ; get the local port from the IP Packet's UDP header - rol ax , 8 + mov bx , [edx + UDP_Packet.DestinationPort] ; get the local port from the IP Packet's UDP header .next_socket: - mov esi, [esi + SOCKET.NextPtr] - or esi, esi + mov eax, [eax + SOCKET.NextPtr] + or eax, eax jz .dump - cmp [esi + SOCKET.Type], IP_PROTO_UDP + cmp [eax + SOCKET.Domain], AF_INET4 jne .next_socket - cmp [esi + SOCKET.LocalPort], ax + cmp [eax + SOCKET.Type], IP_PROTO_UDP + jne .next_socket + cmp [eax + SOCKET.LocalPort], bx jne .next_socket ; For dhcp, we must allow any remote server to respond. ; I will accept the first incoming response to be the one ; I bind to, if the socket is opened with a destination IP address of ; 255.255.255.255 - cmp [esi + SOCKET.RemoteIP], 0xffffffff - je @f + cmp [eax + SOCKET.RemoteIP], 0xffffffff + je .ok1 - mov eax, [esp] - mov eax, [eax + ETH_FRAME.Data + IPv4_Packet.SourceAddress] ; get the Source address from the IP Packet - cmp [esi + SOCKET.RemoteIP], eax + mov ebx, [esp] + mov ebx, [ebx + ETH_FRAME.Data + IPv4_Packet.SourceAddress] ; get the Source address from the IP Packet + cmp [eax + SOCKET.RemoteIP], eax jne .try_more ; Quit if the source IP is not valid, check for more sockets with this IP/PORT combination - @@: - DEBUGF 1,"Found valid UDP packet for socket %x\n", esi + .ok1: -; sub ecx, UDP_Packet.Data ; get # of bytes in ecx -; mov eax, ecx + mov bx, [edx + UDP_Packet.SourcePort] ; Remote port must be 0, or equal to sourceport of packet + cmp [eax + SOCKET.RemotePort],0 + je .ok2 + + cmp [eax + SOCKET.RemotePort], bx + jne .dump + + .ok2: + + DEBUGF 1,"Found valid UDP packet for socket %x\n", eax + lea esi, [edx + UDP_Packet.Data] movzx ecx, [edx + UDP_Packet.Length] - xchg cl , ch + rol cx , 8 + sub cx , UDP_Packet.Data + mov dx , bx -; cmp ecx, eax ; If UDP packet size is bigger then IP packet told us, -; jg .error ; Something must went wrong! + call socket_internal_receiver - lea ebx, [esi + SOCKET.lock] - call wait_mutex - - ; OK - we have a valid UDP Packet for this socket. - ; First, update the sockets remote port number with the incoming msg - ; - it will have changed - ; from the original ( 69 normally ) to allow further connects - mov ax, [edx + UDP_Packet.SourcePort] ; get the UDP source port - xchg al, ah - mov [esi + SOCKET.RemotePort], ax - - ; Now, copy data to socket. We have socket address as [eax + sockets]. - ; We have IP Packet in edx - - add edx, UDP_Packet.Data - mov eax, [esi + SOCKET.rxDataCount] ; get # of bytes already in buffer - DEBUGF 1,"bytes in socket: %u ", eax - lea edi, [ecx + eax] ; check for buffer overflow - cmp edi, SOCKETBUFFSIZE - SOCKETHEADERSIZE ; - jg .dump ; - add [esi + SOCKET.rxDataCount], ecx ; increment the count of bytes in buffer - DEBUGF 1,"adding %u bytes\n", ecx - - ; ecx has count, edx points to data - - lea edi, [esi + eax + SOCKETHEADERSIZE] - push esi - push ecx - mov esi, edx - shr ecx, 2 - rep movsd ; copy the data across - pop ecx - and ecx, 3 - rep movsb - pop esi - - DEBUGF 1,"UDP socket updated\n" - - mov [esi + SOCKET.lock], 0 - - ; flag an event to the application - mov eax, [esi + SOCKET.PID] ; get socket owner PID - mov ecx, 1 - mov esi, TASK_DATA + TASKDATA.pid - - .next_pid: - cmp [esi], eax - je .found_pid - inc ecx - add esi, 0x20 - cmp ecx, [TASK_COUNT] - jbe .next_pid - - jmp .dump - - .found_pid: - shl ecx, 8 - or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK ; stack event - - mov [check_idle_semaphore], 200 - - .dump: - DEBUGF 1,"UDP_handler - dumping\n" + inc [UDP_PACKETS_RX] + .dump: + DEBUGF 1,"Dumping UDP packet\n" call kernel_free add esp, 4 ; pop (balance stack) @@ -205,7 +154,7 @@ UDP_handler: UDP_create_packet: - DEBUGF 1,"Create UDP Packet\n" + DEBUGF 1,"Create UDP Packet (size=%u)\n",ecx push edx esi @@ -216,7 +165,7 @@ UDP_create_packet: call IPv4_create_packet ; TODO: figure out a way to choose between IPv4 and IPv6 cmp edi, -1 - je .exit + je .fail mov byte[edi + UDP_Packet.Length], ch mov byte[edi + UDP_Packet.Length+1], cl @@ -234,23 +183,26 @@ UDP_create_packet: pop edi pop ecx -; bswap ecx ; convert little endian - big endian -; rol ecx, 16 ; mov dword [edi + UDP_Packet.SourcePort], ecx ; notice: we write both port's at once - mov [edi + UDP_Packet.Checksum], 0 ; TODO: calculate checksum using Pseudo-header (However, using a 0 as checksum shouldnt generate any errors :) - push ebx eax ; TODO: make this work on other protocols besides ethernet - mov ebx,edx ; + inc [UDP_PACKETS_TX] + + push edx eax ; TODO: make this work on other protocols besides ethernet DEBUGF 1,"Sending UDP Packet to device %x\n", ebx ; jmp ETH_Sender ; .exit: ret + .fail: + ; todo: queue the packet + add esp, 8 + ret + ;--------------------------------------------------------------------------- diff --git a/kernel/branches/net/proc32.inc b/kernel/branches/net/proc32.inc index 10c7948f24..3f474c02fe 100644 --- a/kernel/branches/net/proc32.inc +++ b/kernel/branches/net/proc32.inc @@ -1,5 +1,5 @@ -$Revision: 750 $ +$Revision$ ; Macroinstructions for defining and calling procedures diff --git a/kernel/branches/net/sound/playnote.inc b/kernel/branches/net/sound/playnote.inc index 3a9e20b88e..b4204f1db2 100644 --- a/kernel/branches/net/sound/playnote.inc +++ b/kernel/branches/net/sound/playnote.inc @@ -16,7 +16,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ align 4 sound_interface: diff --git a/kernel/branches/net/unpacker.inc b/kernel/branches/net/unpacker.inc index b3a7e7c1b4..5e70709f9b 100644 --- a/kernel/branches/net/unpacker.inc +++ b/kernel/branches/net/unpacker.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ; void __stdcall unpack(void* packed_data, void* unpacked_data); diff --git a/kernel/branches/net/video/cursors.inc b/kernel/branches/net/video/cursors.inc index af0521af7e..4acdb1e119 100644 --- a/kernel/branches/net/video/cursors.inc +++ b/kernel/branches/net/video/cursors.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ LOAD_FROM_FILE equ 0 diff --git a/kernel/branches/net/video/vesa12.inc b/kernel/branches/net/video/vesa12.inc index 508cfa4132..48d22add80 100644 --- a/kernel/branches/net/video/vesa12.inc +++ b/kernel/branches/net/video/vesa12.inc @@ -15,7 +15,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ TRIDENT equ 0 diff --git a/kernel/branches/net/video/vesa20.inc b/kernel/branches/net/video/vesa20.inc index d89a4b31f9..532168deee 100644 --- a/kernel/branches/net/video/vesa20.inc +++ b/kernel/branches/net/video/vesa20.inc @@ -17,7 +17,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 983 $ +$Revision$ ; If you're planning to write your own video driver I suggest diff --git a/kernel/branches/net/video/vga.inc b/kernel/branches/net/video/vga.inc index 6253e456d3..12cc0f7dcd 100644 --- a/kernel/branches/net/video/vga.inc +++ b/kernel/branches/net/video/vga.inc @@ -11,7 +11,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 593 $ +$Revision$ paletteVGA: diff --git a/kernel/branches/net/vmodeint.inc b/kernel/branches/net/vmodeint.inc index 12c45a3092..3cb0a1c56e 100644 --- a/kernel/branches/net/vmodeint.inc +++ b/kernel/branches/net/vmodeint.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 753 $ +$Revision$ ; diff --git a/kernel/branches/net/vmodeld.inc b/kernel/branches/net/vmodeld.inc index 209646e3f9..3c5e512a23 100644 --- a/kernel/branches/net/vmodeld.inc +++ b/kernel/branches/net/vmodeld.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 750 $ +$Revision$ ;