forked from KolibriOS/kolibrios
* boot cleanups (kernel.asm)
* faster & cleaner checkpixel (kernel.asm) * a little bugfix in newproce.inc (".failed" -> ".cleanfailed") * Halyavin's bugfix in mem.inc * sheduler doesn't active proesses waiting for an event (func 10) (event.inc, sched.inc) * faster event check (event.inc) git-svn-id: svn://kolibrios.org@21 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5c9d9d79c0
commit
128676fe2c
@ -238,8 +238,8 @@ dispose_app_cr3_table:
|
|||||||
;eax = current slot of process
|
;eax = current slot of process
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
shl ecx,5
|
shl ecx,5
|
||||||
cmp byte [second_base_address+0x3000+ecx+0xa],0 ;if process running?
|
cmp byte [second_base_address+0x3000+ecx+0xa],9 ;if process running?
|
||||||
jnz .next ;slot empty or process is terminating - go to next slot
|
jz .next ;skip empty slots
|
||||||
shl ecx,3
|
shl ecx,3
|
||||||
cmp [second_base_address+0x80000+ecx+0xB8],ebx ;compare page directory addresses
|
cmp [second_base_address+0x80000+ecx+0xB8],ebx ;compare page directory addresses
|
||||||
jnz .next
|
jnz .next
|
||||||
|
@ -292,7 +292,7 @@ new_start_application_fl:
|
|||||||
|
|
||||||
call get_app_params ;parse header fields
|
call get_app_params ;parse header fields
|
||||||
cmp esi,0
|
cmp esi,0
|
||||||
jz .failed
|
jz .cleanfailed
|
||||||
|
|
||||||
mov eax,[new_process_place]
|
mov eax,[new_process_place]
|
||||||
call create_app_cr3_table ;create page directory for new process
|
call create_app_cr3_table ;create page directory for new process
|
||||||
|
@ -36,12 +36,21 @@ irq0:
|
|||||||
mov [edi+0x14], eax
|
mov [edi+0x14], eax
|
||||||
|
|
||||||
mov ebx,[0x3000]
|
mov ebx,[0x3000]
|
||||||
|
mov [prev_slot], ebx
|
||||||
|
|
||||||
cmp [0xffff], byte 1
|
cmp [0xffff], byte 1
|
||||||
je .do_not_change_task
|
je .do_not_change_task
|
||||||
|
|
||||||
|
|
||||||
.waiting_for_termination:
|
.waiting_for_termination:
|
||||||
.waiting_for_reuse:
|
.waiting_for_reuse:
|
||||||
|
.waiting_for_event:
|
||||||
|
cmp ebx, [0x3004]
|
||||||
|
jb @f
|
||||||
|
mov edi, 0x3000
|
||||||
|
xor ebx, ebx
|
||||||
|
@@:
|
||||||
|
|
||||||
add edi,0x20
|
add edi,0x20
|
||||||
inc ebx
|
inc ebx
|
||||||
|
|
||||||
@ -53,15 +62,21 @@ irq0:
|
|||||||
cmp al, 9
|
cmp al, 9
|
||||||
je .waiting_for_reuse
|
je .waiting_for_reuse
|
||||||
|
|
||||||
cmp ebx,[0x3004]
|
|
||||||
jbe @f
|
|
||||||
mov ebx,1
|
|
||||||
mov edi,0x3020
|
|
||||||
@@:
|
|
||||||
|
|
||||||
mov [0x3000],ebx
|
mov [0x3000],ebx
|
||||||
mov [0x3010],edi
|
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:
|
.do_not_change_task:
|
||||||
|
|
||||||
call _rdtsc
|
call _rdtsc
|
||||||
@ -92,12 +107,15 @@ irq0:
|
|||||||
|
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
|
align 4
|
||||||
far_jump:
|
far_jump:
|
||||||
.offs dd ?
|
.offs dd ?
|
||||||
.sel dw ?
|
.sel dw ?
|
||||||
context_counter dd ? ;noname & halyavin
|
context_counter dd ? ;noname & halyavin
|
||||||
next_usage_update dd ?
|
next_usage_update dd ?
|
||||||
timer_ticks dd ?
|
timer_ticks dd ?
|
||||||
|
prev_slot dd ?
|
||||||
|
event_sched dd ?
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,16 +9,16 @@ align 4
|
|||||||
|
|
||||||
sys_wait_event_timeout:
|
sys_wait_event_timeout:
|
||||||
|
|
||||||
mov ebx,[timer_ticks];[0xfdf0]
|
mov ebx,[timer_ticks]
|
||||||
add ebx,eax
|
add ebx,eax
|
||||||
cmp ebx,[timer_ticks];[0xfdf0]
|
cmp ebx,[timer_ticks]
|
||||||
jna .swfet2
|
jna .swfet2
|
||||||
.swfet1:
|
.swfet1:
|
||||||
call get_event_for_app
|
call get_event_for_app
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jne .eventoccur_time
|
jne .eventoccur_time
|
||||||
call change_task
|
call change_task
|
||||||
cmp ebx,[timer_ticks];[0xfdf0]
|
cmp ebx,[timer_ticks]
|
||||||
jg .swfet1
|
jg .swfet1
|
||||||
.swfet2:
|
.swfet2:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
@ -36,10 +36,11 @@ sys_waitforevent:
|
|||||||
jne eventoccur
|
jne eventoccur
|
||||||
newwait:
|
newwait:
|
||||||
|
|
||||||
|
mov eax, [0x3010]
|
||||||
|
mov [eax+0xA], byte 5
|
||||||
call change_task
|
call change_task
|
||||||
call get_event_for_app
|
|
||||||
test eax,eax
|
mov eax, [event_sched]
|
||||||
je newwait
|
|
||||||
|
|
||||||
eventoccur:
|
eventoccur:
|
||||||
mov [esp+36],eax
|
mov [esp+36],eax
|
||||||
@ -53,7 +54,7 @@ get_event_for_app:
|
|||||||
mov edi,[0x3010] ; WINDOW REDRAW
|
mov edi,[0x3010] ; WINDOW REDRAW
|
||||||
test [edi],dword 1
|
test [edi],dword 1
|
||||||
jz no_eventoccur1
|
jz no_eventoccur1
|
||||||
mov edi,[0x3010]
|
;mov edi,[0x3010]
|
||||||
cmp [edi-twdw+31],byte 0
|
cmp [edi-twdw+31],byte 0
|
||||||
je no_eventoccur1
|
je no_eventoccur1
|
||||||
popad
|
popad
|
||||||
@ -61,7 +62,7 @@ get_event_for_app:
|
|||||||
ret
|
ret
|
||||||
no_eventoccur1:
|
no_eventoccur1:
|
||||||
|
|
||||||
mov edi,[0x3010] ; KEY IN BUFFER
|
;mov edi,[0x3010] ; KEY IN BUFFER
|
||||||
test [edi],dword 2
|
test [edi],dword 2
|
||||||
jz no_eventoccur2
|
jz no_eventoccur2
|
||||||
mov ecx, [0x3000]
|
mov ecx, [0x3000]
|
||||||
@ -76,16 +77,16 @@ get_event_for_app:
|
|||||||
ret
|
ret
|
||||||
no_eventoccur2:
|
no_eventoccur2:
|
||||||
|
|
||||||
mov edi,[0x3010] ; BUTTON IN BUFFER
|
;mov edi,[0x3010] ; BUTTON IN BUFFER
|
||||||
test [edi],dword 4
|
test [edi],dword 4
|
||||||
jz no_eventoccur3
|
jz no_eventoccur3
|
||||||
|
cmp [0xf500],byte 0
|
||||||
|
je no_eventoccur3
|
||||||
mov ecx, [0x3000]
|
mov ecx, [0x3000]
|
||||||
movzx edx, word [0xC000+ecx*2]
|
movzx edx, word [0xC000+ecx*2]
|
||||||
mov eax, [0x3004]
|
mov eax, [0x3004]
|
||||||
cmp eax,edx
|
cmp eax,edx
|
||||||
jnz no_eventoccur3
|
jnz no_eventoccur3
|
||||||
cmp [0xf500],byte 0
|
|
||||||
je no_eventoccur3
|
|
||||||
popad
|
popad
|
||||||
mov eax,[0xf501]
|
mov eax,[0xf501]
|
||||||
cmp eax,65535
|
cmp eax,65535
|
||||||
@ -101,7 +102,22 @@ get_event_for_app:
|
|||||||
|
|
||||||
no_eventoccur3:
|
no_eventoccur3:
|
||||||
|
|
||||||
mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW
|
|
||||||
|
;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
|
||||||
test [edi],dword 16
|
test [edi],dword 16
|
||||||
jz no_eventoccur5
|
jz no_eventoccur5
|
||||||
cmp [0xfff0],byte 2
|
cmp [0xfff0],byte 2
|
||||||
@ -111,46 +127,35 @@ get_event_for_app:
|
|||||||
ret
|
ret
|
||||||
no_eventoccur5:
|
no_eventoccur5:
|
||||||
|
|
||||||
mov edi,[0x3010] ; mouse event
|
;mov edi,[0x3010] ; IPC
|
||||||
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
|
|
||||||
test [edi],dword 01000000b
|
test [edi],dword 01000000b
|
||||||
jz no_ipc
|
jz no_ipc
|
||||||
mov edi,[0x3000]
|
mov eax,[0x3000]
|
||||||
shl edi,8
|
shl eax,8
|
||||||
test [edi+0x80000+0xA8],dword 01000000b
|
test [eax+0x80000+0xA8],dword 01000000b
|
||||||
jz no_ipc
|
jz no_ipc
|
||||||
and [edi+0x80000+0xA8],dword 0xffffffff-01000000b
|
and [eax+0x80000+0xA8],dword 0xffffffff-01000000b
|
||||||
popad
|
popad
|
||||||
mov eax,7
|
mov eax,7
|
||||||
ret
|
ret
|
||||||
no_ipc:
|
no_ipc:
|
||||||
|
|
||||||
|
|
||||||
mov edi,[0x3010] ; STACK
|
;mov edi,[0x3010] ; STACK
|
||||||
test [edi],dword 10000000b
|
test [edi],dword 10000000b
|
||||||
jz no_stack_event
|
jz no_stack_event
|
||||||
mov edi,[0x3000]
|
mov eax,[0x3000]
|
||||||
shl edi,8
|
shl eax,8
|
||||||
test [edi+0x80000+0xA8],dword 10000000b
|
test [eax+0x80000+0xA8],dword 10000000b
|
||||||
jz no_stack_event
|
jz no_stack_event
|
||||||
and [edi+0x80000+0xA8],dword 0xffffffff-10000000b
|
and [eax+0x80000+0xA8],dword 0xffffffff-10000000b
|
||||||
popad
|
popad
|
||||||
mov eax,7
|
mov eax,8
|
||||||
ret
|
ret
|
||||||
no_stack_event:
|
no_stack_event:
|
||||||
|
|
||||||
|
cmp dword [edi], 0xFFFF
|
||||||
|
jbe no_events
|
||||||
|
|
||||||
mov esi,0x2e0000 ; IRQ'S AND DATA
|
mov esi,0x2e0000 ; IRQ'S AND DATA
|
||||||
mov ebx,0x00010000
|
mov ebx,0x00010000
|
||||||
@ -181,6 +186,7 @@ get_event_for_app:
|
|||||||
cmp ecx,16
|
cmp ecx,16
|
||||||
jb irq_event_test
|
jb irq_event_test
|
||||||
|
|
||||||
|
no_events:
|
||||||
popad
|
popad
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
@ -640,10 +640,9 @@ include 'vmodeld.inc'
|
|||||||
mov [0x80000+256+0],dword 'OS/I'
|
mov [0x80000+256+0],dword 'OS/I'
|
||||||
mov [0x80000+256+4],dword 'DLE '
|
mov [0x80000+256+4],dword 'DLE '
|
||||||
; task list
|
; 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+0xE],byte 1 ; on screen number
|
||||||
mov [0x3020+0x4],dword 1 ; process id number
|
mov [0x3020+0x4],dword 1 ; process id number
|
||||||
|
mov [0x3020+0x10], dword 0 ; process base address
|
||||||
|
|
||||||
; set default flags & stacks
|
; set default flags & stacks
|
||||||
mov [l.eflags],dword 0x11202 ; sti and resume
|
mov [l.eflags],dword 0x11202 ; sti and resume
|
||||||
@ -718,51 +717,43 @@ include 'vmodeld.inc'
|
|||||||
|
|
||||||
|
|
||||||
; LOAD FIRST APPLICATION
|
; LOAD FIRST APPLICATION
|
||||||
mov [0x3000],dword 1 ;1
|
mov [0x3000],dword 1
|
||||||
mov [0x3004],dword 1 ;1
|
mov [0x3004],dword 1
|
||||||
cli
|
cli
|
||||||
mov al,[0x2f0000+0x9030]
|
mov al,[0x2f0000+0x9030]
|
||||||
cmp al,1
|
cmp al,1
|
||||||
jne no_load_vrr_m
|
jne no_load_vrr_m
|
||||||
mov eax,vrr_m
|
mov eax,vrr_m
|
||||||
call start_application_fl
|
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
|
je first_app_found
|
||||||
|
|
||||||
no_load_vrr_m:
|
no_load_vrr_m:
|
||||||
mov eax,firstapp
|
mov eax,firstapp
|
||||||
call start_application_fl
|
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
|
je first_app_found
|
||||||
mov eax, 0xDEADBEEF
|
mov eax, 0xDEADBEEF ; otherwise halt
|
||||||
hlt ;jmp $
|
hlt
|
||||||
first_app_found:
|
first_app_found:
|
||||||
cli
|
cli
|
||||||
|
|
||||||
mov [0x3004],dword 2
|
;mov [0x3004],dword 2
|
||||||
mov [0x3000],dword 1
|
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
|
; 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!
|
; mov al, 0xED ; svetodiody - only for testing!
|
||||||
; call kb_write
|
; call kb_write
|
||||||
; call kb_read
|
; call kb_read
|
||||||
@ -780,6 +771,12 @@ wait_loop_1: ; variant 2
|
|||||||
call set_lights
|
call set_lights
|
||||||
;// mike.dld ]
|
;// mike.dld ]
|
||||||
|
|
||||||
|
; START MULTITASKING
|
||||||
|
|
||||||
|
mov esi,boot_tasking
|
||||||
|
call boot_log
|
||||||
|
|
||||||
|
mov [0xe000],byte 1 ; multitasking enabled
|
||||||
|
|
||||||
; UNMASK ALL IRQ'S
|
; UNMASK ALL IRQ'S
|
||||||
|
|
||||||
@ -835,7 +832,6 @@ osloop:
|
|||||||
|
|
||||||
|
|
||||||
checkidle:
|
checkidle:
|
||||||
|
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
cmp [check_idle_semaphore],0
|
cmp [check_idle_semaphore],0
|
||||||
@ -3024,72 +3020,24 @@ modify_pce:
|
|||||||
ret
|
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
|
; check if pixel is allowed to be drawn
|
||||||
|
|
||||||
checkpixel:
|
checkpixel:
|
||||||
|
push eax edx
|
||||||
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
|
|
||||||
|
|
||||||
mov edx,[0xfe00] ; screen x size
|
mov edx,[0xfe00] ; screen x size
|
||||||
inc edx
|
inc edx
|
||||||
imul edx, ebx
|
imul edx, ebx
|
||||||
mov dl, [eax+edx+display_data] ; lea eax, [...]
|
mov dl, [eax+edx+display_data] ; lea eax, [...]
|
||||||
;;; mov dl,[eax]
|
|
||||||
|
|
||||||
mov eax,[0x3000]
|
mov eax, [0x3010]
|
||||||
shl eax,5
|
|
||||||
add eax,0x3000+0xe
|
|
||||||
|
|
||||||
mov ecx, 1
|
|
||||||
cmp byte [eax], dl
|
|
||||||
jnz .ret1
|
|
||||||
|
|
||||||
.ret0:
|
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
.ret1:
|
cmp byte [eax+0xe], dl
|
||||||
pop edx
|
setne cl
|
||||||
pop ebx
|
|
||||||
pop eax
|
pop edx eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
|
Loading…
Reference in New Issue
Block a user