diff --git a/kernel/trunk/core/mem.inc b/kernel/trunk/core/mem.inc index 06d9444561..56754e0741 100644 --- a/kernel/trunk/core/mem.inc +++ b/kernel/trunk/core/mem.inc @@ -238,8 +238,8 @@ dispose_app_cr3_table: ;eax = current slot of process mov ecx,eax shl ecx,5 - cmp byte [second_base_address+0x3000+ecx+0xa],0 ;if process running? - jnz .next ;slot empty or process is terminating - go to next slot + cmp byte [second_base_address+0x3000+ecx+0xa],9 ;if process running? + jz .next ;skip empty slots shl ecx,3 cmp [second_base_address+0x80000+ecx+0xB8],ebx ;compare page directory addresses jnz .next diff --git a/kernel/trunk/core/newproce.inc b/kernel/trunk/core/newproce.inc index c59b7061c3..83c10c8582 100644 --- a/kernel/trunk/core/newproce.inc +++ b/kernel/trunk/core/newproce.inc @@ -292,7 +292,7 @@ new_start_application_fl: call get_app_params ;parse header fields cmp esi,0 - jz .failed + jz .cleanfailed mov eax,[new_process_place] call create_app_cr3_table ;create page directory for new process diff --git a/kernel/trunk/core/sched.inc b/kernel/trunk/core/sched.inc index 7468689603..becd6ac429 100644 --- a/kernel/trunk/core/sched.inc +++ b/kernel/trunk/core/sched.inc @@ -36,12 +36,21 @@ irq0: mov [edi+0x14], eax mov ebx,[0x3000] + mov [prev_slot], ebx cmp [0xffff], byte 1 je .do_not_change_task + .waiting_for_termination: .waiting_for_reuse: + .waiting_for_event: + cmp ebx, [0x3004] + jb @f + mov edi, 0x3000 + xor ebx, ebx + @@: + add edi,0x20 inc ebx @@ -53,15 +62,21 @@ irq0: cmp al, 9 je .waiting_for_reuse - cmp ebx,[0x3004] - jbe @f - mov ebx,1 - mov edi,0x3020 - @@: - mov [0x3000],ebx mov [0x3010],edi + cmp al, 5 + jne .noevents + call get_event_for_app + test eax, eax + jz .waiting_for_event + mov [event_sched], eax + mov [edi+0xA], byte 0 + cmp ebx, [prev_slot] + sete [0xffff] + .noevents: + + .do_not_change_task: call _rdtsc @@ -92,12 +107,15 @@ irq0: uglobal + align 4 far_jump: .offs dd ? .sel dw ? context_counter dd ? ;noname & halyavin next_usage_update dd ? timer_ticks dd ? + prev_slot dd ? + event_sched dd ? endg diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index 30c253f4b9..9b5fd277fd 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -9,16 +9,16 @@ align 4 sys_wait_event_timeout: - mov ebx,[timer_ticks];[0xfdf0] + mov ebx,[timer_ticks] add ebx,eax - cmp ebx,[timer_ticks];[0xfdf0] + cmp ebx,[timer_ticks] jna .swfet2 .swfet1: call get_event_for_app test eax,eax jne .eventoccur_time call change_task - cmp ebx,[timer_ticks];[0xfdf0] + cmp ebx,[timer_ticks] jg .swfet1 .swfet2: xor eax,eax @@ -36,10 +36,11 @@ sys_waitforevent: jne eventoccur newwait: + mov eax, [0x3010] + mov [eax+0xA], byte 5 call change_task - call get_event_for_app - test eax,eax - je newwait + + mov eax, [event_sched] eventoccur: mov [esp+36],eax @@ -53,7 +54,7 @@ get_event_for_app: mov edi,[0x3010] ; WINDOW REDRAW test [edi],dword 1 jz no_eventoccur1 - mov edi,[0x3010] + ;mov edi,[0x3010] cmp [edi-twdw+31],byte 0 je no_eventoccur1 popad @@ -61,7 +62,7 @@ get_event_for_app: ret no_eventoccur1: - mov edi,[0x3010] ; KEY IN BUFFER + ;mov edi,[0x3010] ; KEY IN BUFFER test [edi],dword 2 jz no_eventoccur2 mov ecx, [0x3000] @@ -76,16 +77,16 @@ get_event_for_app: ret no_eventoccur2: - mov edi,[0x3010] ; BUTTON IN BUFFER + ;mov edi,[0x3010] ; BUTTON IN BUFFER test [edi],dword 4 jz no_eventoccur3 + cmp [0xf500],byte 0 + je no_eventoccur3 mov ecx, [0x3000] movzx edx, word [0xC000+ecx*2] mov eax, [0x3004] cmp eax,edx jnz no_eventoccur3 - cmp [0xf500],byte 0 - je no_eventoccur3 popad mov eax,[0xf501] cmp eax,65535 @@ -100,8 +101,23 @@ get_event_for_app: ret no_eventoccur3: + + + ;mov edi,[0x3010] ; mouse event + test [edi],dword 00100000b + jz no_mouse_event + mov eax,[0x3000] + shl eax,8 + test [eax+0x80000+0xA8],dword 00100000b + jz no_mouse_event + and [eax+0x80000+0xA8],dword 0xffffffff-00100000b + popad + mov eax,6 + ret + no_mouse_event: + - mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW + ;mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW test [edi],dword 16 jz no_eventoccur5 cmp [0xfff0],byte 2 @@ -111,46 +127,35 @@ get_event_for_app: ret no_eventoccur5: - mov edi,[0x3010] ; mouse event - test [edi],dword 00100000b - jz no_mouse_event - mov edi,[0x3000] - shl edi,8 - test [edi+0x80000+0xA8],dword 00100000b - jz no_mouse_event - and [edi+0x80000+0xA8],dword 0xffffffff-00100000b - popad - mov eax,6 - ret - no_mouse_event: - - mov edi,[0x3010] ; IPC + ;mov edi,[0x3010] ; IPC test [edi],dword 01000000b jz no_ipc - mov edi,[0x3000] - shl edi,8 - test [edi+0x80000+0xA8],dword 01000000b + mov eax,[0x3000] + shl eax,8 + test [eax+0x80000+0xA8],dword 01000000b jz no_ipc - and [edi+0x80000+0xA8],dword 0xffffffff-01000000b + and [eax+0x80000+0xA8],dword 0xffffffff-01000000b popad mov eax,7 ret no_ipc: - mov edi,[0x3010] ; STACK + ;mov edi,[0x3010] ; STACK test [edi],dword 10000000b jz no_stack_event - mov edi,[0x3000] - shl edi,8 - test [edi+0x80000+0xA8],dword 10000000b + mov eax,[0x3000] + shl eax,8 + test [eax+0x80000+0xA8],dword 10000000b jz no_stack_event - and [edi+0x80000+0xA8],dword 0xffffffff-10000000b + and [eax+0x80000+0xA8],dword 0xffffffff-10000000b popad - mov eax,7 + mov eax,8 ret no_stack_event: + cmp dword [edi], 0xFFFF + jbe no_events mov esi,0x2e0000 ; IRQ'S AND DATA mov ebx,0x00010000 @@ -181,6 +186,7 @@ get_event_for_app: cmp ecx,16 jb irq_event_test + no_events: popad xor eax, eax ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index a31ef5549b..897c84b7d9 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -640,10 +640,9 @@ include 'vmodeld.inc' mov [0x80000+256+0],dword 'OS/I' mov [0x80000+256+4],dword 'DLE ' ; task list - mov [0x3004],dword 2 ; number of processes - mov [0x3000],dword 0 ; process count - start with os task mov [0x3020+0xE],byte 1 ; on screen number mov [0x3020+0x4],dword 1 ; process id number + mov [0x3020+0x10], dword 0 ; process base address ; set default flags & stacks mov [l.eflags],dword 0x11202 ; sti and resume @@ -718,51 +717,43 @@ include 'vmodeld.inc' ; LOAD FIRST APPLICATION - mov [0x3000],dword 1 ;1 - mov [0x3004],dword 1 ;1 + mov [0x3000],dword 1 + mov [0x3004],dword 1 cli mov al,[0x2f0000+0x9030] cmp al,1 jne no_load_vrr_m mov eax,vrr_m call start_application_fl - cmp eax,2 ; if no vrr_m app found + cmp eax,2 ; if vrr_m app found (PID=2) je first_app_found - no_load_vrr_m: + no_load_vrr_m: mov eax,firstapp call start_application_fl - cmp eax,2 ; if no first app found - halt + cmp eax,2 ; continue if a process has been loaded je first_app_found - mov eax, 0xDEADBEEF - hlt ;jmp $ + mov eax, 0xDEADBEEF ; otherwise halt + hlt first_app_found: cli - mov [0x3004],dword 2 - mov [0x3000],dword 1 + ;mov [0x3004],dword 2 + mov [0x3000],dword 1 ; set OS task fisrt -; START MULTITASKING - - mov esi,boot_tasking - call boot_log - - mov [0xe000],byte 1 ; multitasking enabled - - mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование - call kb_write - - mov ecx,0 -wait_loop_1: ; variant 2 -; читаем порт состояния процессора 8042 - in al,64h - and al,00000010b ; флаг готовности -; ожидаем готовность процессора 8042 - loopnz wait_loop_1 - ; SET KEYBOARD PARAMETERS + mov al, 0xf6 ; reset keyboard, scan enabled + call kb_write + + ; wait until 8042 is ready + mov ecx,0 + @@: + in al,64h + and al,00000010b + loopnz @b + ; mov al, 0xED ; svetodiody - only for testing! ; call kb_write ; call kb_read @@ -780,6 +771,12 @@ wait_loop_1: ; variant 2 call set_lights ;// mike.dld ] +; START MULTITASKING + + mov esi,boot_tasking + call boot_log + + mov [0xe000],byte 1 ; multitasking enabled ; UNMASK ALL IRQ'S @@ -835,7 +832,6 @@ osloop: checkidle: - pushad cmp [check_idle_semaphore],0 @@ -3024,72 +3020,24 @@ modify_pce: ret ;--------------------------------------------------------------------------------------------- -; check pixel limits - -;cplimit: -; push edi - -; cmp byte [0xe000], 1 ; Multitasking enabled? -; jnz .ret0 -; mov edi,[0x3010] -; add edi, draw_data-0x3000 -; mov ecx, 1 -; cmp [edi+0], eax ; xs -; ja .ret1 -; cmp [edi+4], ebx ; ys -; ja .ret1 -; cmp eax, [edi+8] ; xe -; ja .ret1 -; cmp ebx, [edi+12] ; ye -; ja .ret1 - -;.ret0: -; xor ecx, ecx -;.ret1: -; pop edi -; ret - ; check if pixel is allowed to be drawn checkpixel: - - push eax - push ebx - push edx - -; mov ecx,[0x3000] ; process count -; shl ecx, 6 ; *64 -; add ecx,0xc000 ; +window_stack -; mov dx,word [ecx] ; window_stack_value - -; cmp dx, word [0x3004] ; is this window active right now?! -; jz .ret0 - -; call cplimit -; test ecx, ecx -; jnz .ret1 + push eax edx mov edx,[0xfe00] ; screen x size inc edx - imul edx, ebx + imul edx, ebx mov dl, [eax+edx+display_data] ; lea eax, [...] -;;; mov dl,[eax] - mov eax,[0x3000] - shl eax,5 - add eax,0x3000+0xe + mov eax, [0x3010] - mov ecx, 1 - cmp byte [eax], dl - jnz .ret1 - -.ret0: xor ecx, ecx -.ret1: - pop edx - pop ebx - pop eax + cmp byte [eax+0xe], dl + setne cl + + pop edx eax ret uglobal