forked from KolibriOS/kolibrios
refractoring of EVENT, and so on
git-svn-id: svn://kolibrios.org@1055 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -468,9 +468,10 @@ struc EVENT
|
|||||||
.id dd ? ;event uid
|
.id dd ? ;event uid
|
||||||
.state dd ? ;internal flags
|
.state dd ? ;internal flags
|
||||||
.code dd ?
|
.code dd ?
|
||||||
rd 5
|
rd 6
|
||||||
|
.size = $ - .magic
|
||||||
|
.codesize = $ - .code
|
||||||
}
|
}
|
||||||
EVENT_SIZE equ 52
|
|
||||||
|
|
||||||
virtual at 0
|
virtual at 0
|
||||||
EVENT EVENT
|
EVENT EVENT
|
||||||
@@ -687,4 +688,3 @@ end virtual
|
|||||||
virtual at 0
|
virtual at 0
|
||||||
CSYM COFF_SYM
|
CSYM COFF_SYM
|
||||||
end virtual
|
end virtual
|
||||||
|
|
||||||
|
@@ -126,11 +126,11 @@ kernel_export:
|
|||||||
dd szGetPid , get_pid
|
dd szGetPid , get_pid
|
||||||
dd szCreateObject , create_kernel_object
|
dd szCreateObject , create_kernel_object
|
||||||
dd szDestroyObject , destroy_kernel_object
|
dd szDestroyObject , destroy_kernel_object
|
||||||
dd szCreateEvent , create_event
|
dd szCreateEvent , create_event ;see EVENT.inc for specification
|
||||||
dd szRaiseEvent , raise_event
|
dd szRaiseEvent , raise_event ;see EVENT.inc for specification
|
||||||
dd szWaitEvent , wait_event
|
dd szWaitEvent , wait_event ;see EVENT.inc for specification
|
||||||
dd szDestroyEvent , destroy_event
|
dd szDestroyEvent , destroy_event ;see EVENT.inc for specification
|
||||||
dd szClearEvent , clear_event
|
dd szClearEvent , clear_event ;see EVENT.inc for specification
|
||||||
|
|
||||||
dd szLoadCursor , load_cursor ;stdcall
|
dd szLoadCursor , load_cursor ;stdcall
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ kernel_export:
|
|||||||
dd szSysMsgBoardChar , sys_msg_board
|
dd szSysMsgBoardChar , sys_msg_board
|
||||||
dd szGetCurrentTask , get_curr_task
|
dd szGetCurrentTask , get_curr_task
|
||||||
dd szLoadFile , load_file ;retval eax, ebx
|
dd szLoadFile , load_file ;retval eax, ebx
|
||||||
dd szSendEvent , send_event
|
dd szSendEvent , send_event ;see EVENT.inc for specification
|
||||||
dd szSetMouseData , set_mouse_data ;stdcall
|
dd szSetMouseData , set_mouse_data ;stdcall
|
||||||
dd szSleep , delay_ms
|
dd szSleep , delay_ms
|
||||||
dd szGetTimerTicks , get_timer_ticks
|
dd szGetTimerTicks , get_timer_ticks
|
||||||
@@ -160,4 +160,3 @@ exp_lfb:
|
|||||||
dd 0 ;terminator, must be zero
|
dd 0 ;terminator, must be zero
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
@@ -1051,7 +1051,8 @@ f68:
|
|||||||
.14:
|
.14:
|
||||||
cmp ebx, OS_BASE
|
cmp ebx, OS_BASE
|
||||||
jae .fail
|
jae .fail
|
||||||
stdcall get_event_ex, ebx, ecx
|
mov edi,ebx
|
||||||
|
call get_event_ex
|
||||||
mov [esp+36], eax
|
mov [esp+36], eax
|
||||||
ret
|
ret
|
||||||
.15:
|
.15:
|
||||||
|
@@ -16,74 +16,35 @@ $Revision$
|
|||||||
align 32
|
align 32
|
||||||
irq0:
|
irq0:
|
||||||
pushad
|
pushad
|
||||||
mov ax, app_data ;
|
Mov ds, ax, app_data
|
||||||
mov ds, ax
|
|
||||||
mov es, ax
|
mov es, ax
|
||||||
|
inc [timer_ticks]
|
||||||
; cmp dword[CURRENT_TASK], 1
|
|
||||||
; jnz @f
|
|
||||||
; mov eax, [esp + 32]
|
|
||||||
; cmp eax, idle_loop + 1
|
|
||||||
; jz @f
|
|
||||||
; DEBUGF 1, "K : OOOPS! EAX = 0x%x\n", eax
|
|
||||||
; @@:
|
|
||||||
|
|
||||||
inc dword [timer_ticks]
|
|
||||||
|
|
||||||
mov eax, [timer_ticks]
|
mov eax, [timer_ticks]
|
||||||
call playNote ; <<<--- Speaker driver
|
call playNote ; <<<--- Speaker driver
|
||||||
|
sub eax,[next_usage_update]
|
||||||
cmp eax,[next_usage_update]
|
cmp eax,100
|
||||||
jb .nocounter
|
jb .nocounter
|
||||||
add eax,100
|
add [next_usage_update],100
|
||||||
mov [next_usage_update],eax
|
|
||||||
call updatecputimes
|
call updatecputimes
|
||||||
.nocounter:
|
.nocounter:
|
||||||
cmp [DONT_SWITCH], byte 1
|
|
||||||
jne .change_task
|
|
||||||
|
|
||||||
mov al,0x20 ; send End Of Interrupt signal
|
mov al,0x20 ; send End Of Interrupt signal
|
||||||
mov dx,0x20
|
out 0x20,al
|
||||||
out dx,al
|
btr dword[DONT_SWITCH], 0
|
||||||
|
jc .return
|
||||||
mov [DONT_SWITCH], byte 0
|
|
||||||
|
|
||||||
popad
|
|
||||||
iretd
|
|
||||||
|
|
||||||
.change_task:
|
|
||||||
call update_counters
|
|
||||||
|
|
||||||
call find_next_task
|
call find_next_task
|
||||||
mov ecx, eax
|
jz .return ; if there is only one running process
|
||||||
|
|
||||||
mov al,0x20 ; send End Of Interrupt signal
|
|
||||||
mov dx,0x20
|
|
||||||
out dx,al
|
|
||||||
|
|
||||||
test ecx, ecx ; if there is only one running process
|
|
||||||
jnz .return
|
|
||||||
|
|
||||||
call do_change_task
|
call do_change_task
|
||||||
|
|
||||||
.return:
|
.return:
|
||||||
popad
|
popad
|
||||||
; popfd
|
|
||||||
iretd
|
iretd
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
change_task:
|
change_task:
|
||||||
|
|
||||||
pushfd
|
pushfd
|
||||||
cli
|
cli
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
call update_counters
|
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
|
; \begin{Mario79} ; <- must be refractoried, if used...
|
||||||
; \begin{Mario79}
|
|
||||||
cmp [dma_task_switched], 1
|
cmp [dma_task_switched], 1
|
||||||
jne .find_next_task
|
jne .find_next_task
|
||||||
mov [dma_task_switched], 0
|
mov [dma_task_switched], 0
|
||||||
@@ -96,195 +57,152 @@ if 0
|
|||||||
jmp @f
|
jmp @f
|
||||||
.find_next_task:
|
.find_next_task:
|
||||||
; \end{Mario79}
|
; \end{Mario79}
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
call find_next_task
|
call find_next_task
|
||||||
test eax, eax ; the same task -> skip switch
|
jz .return ; the same task -> skip switch
|
||||||
jnz .return
|
@@: mov byte[DONT_SWITCH], 1
|
||||||
@@:
|
|
||||||
mov [DONT_SWITCH],byte 1
|
|
||||||
call do_change_task
|
call do_change_task
|
||||||
|
|
||||||
.return:
|
.return:
|
||||||
popad
|
popad
|
||||||
popfd
|
popfd
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
far_jump:
|
; far_jump:
|
||||||
.offs dd ?
|
; .offs dd ?
|
||||||
.sel dw ?
|
; .sel dw ?
|
||||||
context_counter dd ? ;noname & halyavin
|
context_counter dd 0 ;noname & halyavin
|
||||||
next_usage_update dd ?
|
next_usage_update dd 0
|
||||||
timer_ticks dd ?
|
timer_ticks dd 0
|
||||||
prev_slot dd ?
|
; prev_slot dd ?
|
||||||
event_sched dd ?
|
; event_sched dd ?
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
align 4
|
||||||
update_counters:
|
update_counters:
|
||||||
mov edi, [TASK_BASE]
|
mov edi, [TASK_BASE]
|
||||||
mov ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
|
|
||||||
rdtsc
|
rdtsc
|
||||||
sub eax, ebx
|
sub eax, [edi+TASKDATA.counter_add] ; time stamp counter add
|
||||||
add eax, [edi+TASKDATA.counter_sum] ; counter sum
|
add [edi+TASKDATA.counter_sum], eax ; counter sum
|
||||||
mov [edi+TASKDATA.counter_sum], eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
; Find next task to execute
|
|
||||||
; result: ebx = number of the selected task
|
|
||||||
; eax = 1 if the task is the same
|
|
||||||
; edi = address of the data for the task in ebx
|
|
||||||
; [0x3000] = ebx and [0x3010] = edi
|
|
||||||
; corrupts other regs
|
|
||||||
find_next_task:
|
|
||||||
mov ebx, [CURRENT_TASK]
|
|
||||||
mov edi, [TASK_BASE]
|
|
||||||
mov [prev_slot], ebx
|
|
||||||
|
|
||||||
.waiting_for_termination:
|
|
||||||
.waiting_for_reuse:
|
|
||||||
.waiting_for_event:
|
|
||||||
.suspended:
|
|
||||||
cmp ebx, [TASK_COUNT]
|
|
||||||
jb @f
|
|
||||||
mov edi, CURRENT_TASK
|
|
||||||
xor ebx, ebx
|
|
||||||
@@:
|
|
||||||
|
|
||||||
add edi,0x20
|
|
||||||
inc ebx
|
|
||||||
|
|
||||||
mov al, byte [edi+TASKDATA.state]
|
|
||||||
test al, al
|
|
||||||
jz .found
|
|
||||||
cmp al, 1
|
|
||||||
jz .suspended
|
|
||||||
cmp al, 2
|
|
||||||
jz .suspended
|
|
||||||
cmp al, 3
|
|
||||||
je .waiting_for_termination
|
|
||||||
cmp al, 4
|
|
||||||
je .waiting_for_termination
|
|
||||||
cmp al, 9
|
|
||||||
je .waiting_for_reuse
|
|
||||||
|
|
||||||
mov [CURRENT_TASK],ebx
|
|
||||||
mov [TASK_BASE],edi
|
|
||||||
|
|
||||||
cmp al, 5
|
|
||||||
jne .noevents
|
|
||||||
call get_event_for_app
|
|
||||||
test eax, eax
|
|
||||||
jnz @f
|
|
||||||
mov eax, ebx
|
|
||||||
shl eax, 8
|
|
||||||
mov eax, [SLOT_BASE + APPDATA.wait_timeout + eax]
|
|
||||||
cmp eax, [timer_ticks]
|
|
||||||
jae .waiting_for_event
|
|
||||||
xor eax, eax
|
|
||||||
@@:
|
|
||||||
mov [event_sched], eax
|
|
||||||
mov [edi+TASKDATA.state], byte 0
|
|
||||||
.noevents:
|
|
||||||
.found:
|
|
||||||
mov [CURRENT_TASK],ebx
|
|
||||||
mov [TASK_BASE],edi
|
|
||||||
rdtsc ;call _rdtsc
|
|
||||||
mov [edi+TASKDATA.counter_add],eax
|
|
||||||
|
|
||||||
mov esi, [prev_slot]
|
|
||||||
xor eax, eax
|
|
||||||
cmp ebx, esi
|
|
||||||
sete al
|
|
||||||
ret
|
|
||||||
|
|
||||||
; param
|
|
||||||
; ebx = incoming task
|
|
||||||
; esi = outcomig task
|
|
||||||
|
|
||||||
do_change_task:
|
|
||||||
|
|
||||||
shl ebx, 8
|
|
||||||
add ebx, SLOT_BASE
|
|
||||||
mov [current_slot], ebx
|
|
||||||
|
|
||||||
shl esi, 8
|
|
||||||
add esi, SLOT_BASE
|
|
||||||
|
|
||||||
mov [esi+APPDATA.saved_esp], esp
|
|
||||||
mov esp, [ebx+APPDATA.saved_esp]
|
|
||||||
|
|
||||||
; set thread io map
|
|
||||||
|
|
||||||
mov ecx, [ebx+APPDATA.io_map]
|
|
||||||
mov edx, [ebx+APPDATA.io_map+4]
|
|
||||||
mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)], ecx
|
|
||||||
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
|
|
||||||
|
|
||||||
mov eax, [ebx+APPDATA.dir_table]
|
|
||||||
cmp eax, [esi+APPDATA.dir_table]
|
|
||||||
je @F
|
|
||||||
mov cr3, eax
|
|
||||||
@@:
|
|
||||||
mov eax, [ebx+APPDATA.saved_esp0]
|
|
||||||
mov [tss._esp0], eax
|
|
||||||
mov ax, graph_data
|
|
||||||
mov gs, ax
|
|
||||||
|
|
||||||
mov eax, [CURRENT_TASK]
|
|
||||||
cmp eax, [fpu_owner]
|
|
||||||
clts ;clear a task switch flag
|
|
||||||
je @F
|
|
||||||
;and set it again if the owner
|
|
||||||
mov ecx, cr0 ;of a fpu has changed
|
|
||||||
or ecx, CR0_TS
|
|
||||||
mov cr0, ecx
|
|
||||||
@@:
|
|
||||||
inc [context_counter] ;noname & halyavin
|
|
||||||
test [ebx+APPDATA.dbg_state], 1
|
|
||||||
jnz @F
|
|
||||||
ret
|
|
||||||
@@:
|
|
||||||
mov eax, [ebx+APPDATA.dbg_regs.dr0]
|
|
||||||
mov dr0, eax
|
|
||||||
mov eax, [ebx+APPDATA.dbg_regs.dr1]
|
|
||||||
mov dr1, eax
|
|
||||||
mov eax, [ebx+APPDATA.dbg_regs.dr2]
|
|
||||||
mov dr2, eax
|
|
||||||
mov eax, [ebx+APPDATA.dbg_regs.dr3]
|
|
||||||
mov dr3, eax
|
|
||||||
xor eax, eax
|
|
||||||
mov dr6, eax
|
|
||||||
mov eax, [ebx+APPDATA.dbg_regs.dr7]
|
|
||||||
mov dr7, eax
|
|
||||||
ret
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
updatecputimes:
|
updatecputimes:
|
||||||
|
xor eax,eax
|
||||||
mov eax,[idleuse]
|
xchg eax,[idleuse]
|
||||||
mov [idleusesec],eax
|
mov [idleusesec],eax
|
||||||
mov [idleuse],dword 0
|
|
||||||
mov ecx, [TASK_COUNT]
|
mov ecx, [TASK_COUNT]
|
||||||
mov edi, TASK_DATA
|
mov edi, TASK_DATA
|
||||||
.newupdate:
|
.newupdate:
|
||||||
mov ebx,[edi+TASKDATA.counter_sum]
|
xor eax,eax
|
||||||
mov [edi+TASKDATA.cpu_usage],ebx
|
xchg eax,[edi+TASKDATA.counter_sum]
|
||||||
mov [edi+TASKDATA.counter_sum],dword 0
|
mov [edi+TASKDATA.cpu_usage],eax
|
||||||
add edi,0x20
|
add edi,0x20
|
||||||
dec ecx
|
loop .newupdate
|
||||||
jnz .newupdate
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
|
find_next_task:
|
||||||
|
;info:
|
||||||
|
; Find next task to execute
|
||||||
|
;retval:
|
||||||
|
; ebx = address of the APPDATA for the selected task (slot-base)
|
||||||
|
; esi = previous slot-base ([current_slot] at the begin)
|
||||||
|
; edi = address of the TASKDATA for the selected task
|
||||||
|
; ZF = 1 if the task is the same
|
||||||
|
;warning:
|
||||||
|
; [CURRENT_TASK] = bh , [TASK_BASE] = edi -- as result
|
||||||
|
; [current_slot] is not set to new value (ebx)!!!
|
||||||
|
;scratched: eax,ecx
|
||||||
|
call update_counters ; edi := [TASK_BASE]
|
||||||
|
Mov esi, ebx, [current_slot]
|
||||||
|
.loop:
|
||||||
|
cmp bh,[TASK_COUNT]
|
||||||
|
jb @f
|
||||||
|
xor bh, bh
|
||||||
|
mov edi,CURRENT_TASK
|
||||||
|
@@: inc bh ; ebx += APPDATA.size
|
||||||
|
add edi,0x20 ; edi += TASKDATA.size
|
||||||
|
mov al, [edi+TASKDATA.state]
|
||||||
|
test al, al
|
||||||
|
jz .found ; state == 0
|
||||||
|
cmp al, 5
|
||||||
|
jne .loop ; state == 1,2,3,4,9
|
||||||
|
; state == 5
|
||||||
|
pushad ; more freedom for [APPDATA.wait_test]
|
||||||
|
call [ebx+APPDATA.wait_test]
|
||||||
|
mov [esp+28],eax
|
||||||
|
popad
|
||||||
|
or eax,eax
|
||||||
|
jnz @f
|
||||||
|
; testing for timeout
|
||||||
|
mov ecx, [timer_ticks]
|
||||||
|
sub ecx, [ebx+APPDATA.wait_begin]
|
||||||
|
cmp ecx, [ebx+APPDATA.wait_timeout]
|
||||||
|
jb .loop
|
||||||
|
@@: mov [ebx+APPDATA.wait_param], eax ; retval for wait
|
||||||
|
mov [edi+TASKDATA.state], 0
|
||||||
|
.found:
|
||||||
|
mov [CURRENT_TASK],bh
|
||||||
|
mov [TASK_BASE],edi
|
||||||
|
rdtsc ;call _rdtsc
|
||||||
|
mov [edi+TASKDATA.counter_add],eax ; for next using update_counters
|
||||||
|
cmp ebx, esi ;esi - previous slot-base
|
||||||
|
ret
|
||||||
|
;TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> do_change_task <EFBFBD><EFBFBD> V86...
|
||||||
|
; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TASKDATA.counter_add/sum <EFBFBD> do_change_task
|
||||||
|
|
||||||
|
align 4
|
||||||
|
do_change_task:
|
||||||
|
;param:
|
||||||
|
; ebx = address of the APPDATA for incoming task (new)
|
||||||
|
;warning:
|
||||||
|
; [CURRENT_TASK] and [TASK_BASE] must be changed before (e.g. in find_next_task)
|
||||||
|
; [current_slot] is the outcoming (old), and set here to a new value (ebx)
|
||||||
|
;scratched: eax,ecx,esi
|
||||||
|
mov esi,ebx
|
||||||
|
xchg esi,[current_slot]
|
||||||
|
; set new stack after saving old
|
||||||
|
mov [esi+APPDATA.saved_esp], esp
|
||||||
|
mov esp, [ebx+APPDATA.saved_esp]
|
||||||
|
; set new thread io-map
|
||||||
|
Mov dword [page_tabs+((tss._io_map_0 and -4096) shr 10)],eax,[ebx+APPDATA.io_map]
|
||||||
|
Mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)],eax,[ebx+APPDATA.io_map+4]
|
||||||
|
; set new thread memory-map
|
||||||
|
mov ecx, APPDATA.dir_table
|
||||||
|
mov eax, [ebx+ecx] ;offset>0x7F
|
||||||
|
cmp eax, [esi+ecx] ;offset>0x7F
|
||||||
|
je @f
|
||||||
|
mov cr3, eax
|
||||||
|
@@: ; set tss.esp0
|
||||||
|
Mov [tss._esp0],eax,[ebx+APPDATA.saved_esp0]
|
||||||
|
; set gs selector unconditionally
|
||||||
|
Mov gs,ax,graph_data
|
||||||
|
; set CR0.TS
|
||||||
|
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
||||||
|
clts ;clear a task switch flag
|
||||||
|
je @f
|
||||||
|
mov eax, cr0 ;and set it again if the owner
|
||||||
|
or eax, CR0_TS ;of a fpu has changed
|
||||||
|
mov cr0, eax
|
||||||
|
@@: ; set context_counter (only for user pleasure ???)
|
||||||
|
inc [context_counter] ;noname & halyavin
|
||||||
|
; set debug-registers, if it's necessary
|
||||||
|
test byte[ebx+APPDATA.dbg_state], 1
|
||||||
|
jz @f
|
||||||
|
xor eax, eax
|
||||||
|
mov dr6, eax
|
||||||
|
lea esi,[ebx+ecx+APPDATA.dbg_regs-APPDATA.dir_table] ;offset>0x7F
|
||||||
|
cld
|
||||||
|
macro lodsReg [reg] {
|
||||||
|
lodsd
|
||||||
|
mov reg,eax
|
||||||
|
} lodsReg dr0, dr1, dr2, dr3, dr7
|
||||||
|
purge lodsReg
|
||||||
|
@@: ret
|
||||||
|
;end.
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
|
|
||||||
|
|
||||||
struc TIMER
|
struc TIMER
|
||||||
{
|
{
|
||||||
.next dd ?
|
.next dd ?
|
||||||
@@ -293,14 +211,6 @@ struc TIMER
|
|||||||
.arg dd ?
|
.arg dd ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MAX_PROIRITY 0 ; highest, used for kernel tasks
|
MAX_PROIRITY 0 ; highest, used for kernel tasks
|
||||||
MAX_USER_PRIORITY 0 ; highest priority for user processes
|
MAX_USER_PRIORITY 0 ; highest priority for user processes
|
||||||
USER_PRIORITY 7 ; default (should correspond to nice 0)
|
USER_PRIORITY 7 ; default (should correspond to nice 0)
|
||||||
@@ -310,7 +220,6 @@ NR_SCHED_QUEUES 16 ; MUST equal IDLE_PRIORYTY + 1
|
|||||||
|
|
||||||
rdy_head rd 16
|
rdy_head rd 16
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
pick_task:
|
pick_task:
|
||||||
|
|
||||||
@@ -330,7 +239,6 @@ pick_task:
|
|||||||
inc eax
|
inc eax
|
||||||
jmp .pick
|
jmp .pick
|
||||||
|
|
||||||
|
|
||||||
; param
|
; param
|
||||||
; eax= task
|
; eax= task
|
||||||
;
|
;
|
||||||
@@ -338,7 +246,6 @@ pick_task:
|
|||||||
; eax= task
|
; eax= task
|
||||||
; ebx= queue
|
; ebx= queue
|
||||||
; ecx= front if 1 or back if 0
|
; ecx= front if 1 or back if 0
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
shed:
|
shed:
|
||||||
cmp [eax+.tics_left], 0 ;signed compare
|
cmp [eax+.tics_left], 0 ;signed compare
|
||||||
@@ -356,7 +263,6 @@ shed:
|
|||||||
|
|
||||||
; param
|
; param
|
||||||
; eax= task
|
; eax= task
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
enqueue:
|
enqueue:
|
||||||
call shed ;eax
|
call shed ;eax
|
||||||
@@ -385,4 +291,3 @@ enqueue:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
@@ -16,27 +16,11 @@ cross_order:
|
|||||||
mov ecx, edx
|
mov ecx, edx
|
||||||
mov edx, esi
|
mov edx, esi
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
mov edi, [esp+28 + 4]
|
movzx edi, byte[esp+28 + 4]
|
||||||
and edi,0xff
|
|
||||||
call dword [servetable+edi*4]
|
call dword [servetable+edi*4]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; ;;
|
|
||||||
;; SYSTEM CALL ENTRY ;;
|
|
||||||
;; ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
|
|
||||||
align 16
|
|
||||||
i40:
|
|
||||||
pushad
|
|
||||||
cld
|
|
||||||
movzx eax, al
|
|
||||||
call dword [servetable2 + eax * 4]
|
|
||||||
popad
|
|
||||||
iretd
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; SYSENTER ENTRY ;;
|
;; SYSENTER ENTRY ;;
|
||||||
@@ -68,6 +52,21 @@ sysenter_entry:
|
|||||||
pop edx
|
pop edx
|
||||||
sysexit
|
sysexit
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; ;;
|
||||||
|
;; SYSTEM CALL ENTRY ;;
|
||||||
|
;; ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
align 16
|
||||||
|
i40:
|
||||||
|
pushad
|
||||||
|
cld
|
||||||
|
movzx eax, al
|
||||||
|
call dword [servetable2 + eax * 4]
|
||||||
|
popad
|
||||||
|
iretd
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; SYSCALL ENTRY ;;
|
;; SYSCALL ENTRY ;;
|
||||||
@@ -95,6 +94,7 @@ syscall_entry:
|
|||||||
mov ecx, [ss:esp+4]
|
mov ecx, [ss:esp+4]
|
||||||
pop esp
|
pop esp
|
||||||
sysret
|
sysret
|
||||||
|
|
||||||
iglobal
|
iglobal
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; SYSTEM FUNCTIONS TABLE ;;
|
;; SYSTEM FUNCTIONS TABLE ;;
|
||||||
@@ -175,7 +175,6 @@ iglobal
|
|||||||
dd sys_debug_services ; 69-Debug
|
dd sys_debug_services ; 69-Debug
|
||||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||||
dd syscall_windowsettings ; 71-Window settings
|
dd syscall_windowsettings ; 71-Window settings
|
||||||
dd sys_sendwindowmsg ; 72-Send window message
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
||||||
@@ -255,7 +254,7 @@ iglobal
|
|||||||
dd cross_order ; 69-Debug
|
dd cross_order ; 69-Debug
|
||||||
dd cross_order ; 70-Common file system interface, version 2
|
dd cross_order ; 70-Common file system interface, version 2
|
||||||
dd cross_order ; 71-Window settings
|
dd cross_order ; 71-Window settings
|
||||||
dd cross_order ; 72-Send window message
|
dd sys_sendwindowmsg ; 72-Send window message
|
||||||
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
|
times 255 - ( ($-servetable2) /4 ) dd undefined_syscall
|
||||||
dd sys_end ; -1-end application
|
dd sys_end ; -1-end application
|
||||||
|
|
||||||
|
@@ -945,12 +945,12 @@ v86_irq2:
|
|||||||
mov cx, [eax*4+2]
|
mov cx, [eax*4+2]
|
||||||
mov word [esi-v86_regs.size+v86_regs.cs], cx
|
mov word [esi-v86_regs.size+v86_regs.cs], cx
|
||||||
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
|
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3
|
||||||
push ebx
|
; push ebx
|
||||||
call update_counters
|
call update_counters
|
||||||
pop ebx
|
; pop ebx
|
||||||
sub ebx, SLOT_BASE
|
; sub ebx, SLOT_BASE
|
||||||
shr ebx, 8
|
; shr ebx, 8
|
||||||
mov esi, [CURRENT_TASK]
|
; mov esi, [CURRENT_TASK]
|
||||||
call do_change_task
|
call do_change_task
|
||||||
popad
|
popad
|
||||||
iretd
|
iretd
|
||||||
|
@@ -292,7 +292,6 @@ irq15read rd 16
|
|||||||
irq_tab rd 16
|
irq_tab rd 16
|
||||||
|
|
||||||
mem_block_map rb 512
|
mem_block_map rb 512
|
||||||
event_map rb 64
|
|
||||||
mem_block_list rd 64
|
mem_block_list rd 64
|
||||||
large_block_list rd 31
|
large_block_list rd 31
|
||||||
mem_block_mask rd 2
|
mem_block_mask rd 2
|
||||||
@@ -315,10 +314,6 @@ mst MEM_STATE
|
|||||||
|
|
||||||
page_start rd 1
|
page_start rd 1
|
||||||
page_end rd 1
|
page_end rd 1
|
||||||
events rd 1
|
|
||||||
event_start rd 1
|
|
||||||
event_end rd 1
|
|
||||||
event_uid rd 1
|
|
||||||
sys_page_map rd 1
|
sys_page_map rd 1
|
||||||
os_stack_seg rd 1
|
os_stack_seg rd 1
|
||||||
|
|
||||||
@@ -471,4 +466,3 @@ BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
|||||||
BiosDiskPartitions rd 80h
|
BiosDiskPartitions rd 80h
|
||||||
|
|
||||||
IncludeUGlobals
|
IncludeUGlobals
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -725,11 +725,11 @@ no_lib_load:
|
|||||||
mov esi,boot_tsc
|
mov esi,boot_tsc
|
||||||
call boot_log
|
call boot_log
|
||||||
cli
|
cli
|
||||||
call _rdtsc
|
rdtsc ;call _rdtsc
|
||||||
mov ecx,eax
|
mov ecx,eax
|
||||||
mov esi,250 ; wait 1/4 a second
|
mov esi,250 ; wait 1/4 a second
|
||||||
call delay_ms
|
call delay_ms
|
||||||
call _rdtsc
|
rdtsc ;call _rdtsc
|
||||||
sti
|
sti
|
||||||
sub eax,ecx
|
sub eax,ecx
|
||||||
shl eax,2
|
shl eax,2
|
||||||
@@ -1013,57 +1013,27 @@ osloop:
|
|||||||
|
|
||||||
checkidle:
|
checkidle:
|
||||||
pushad
|
pushad
|
||||||
|
mov ebx,[timer_ticks]
|
||||||
cmp [check_idle_semaphore],0
|
|
||||||
jne no_idle_state
|
|
||||||
|
|
||||||
call change_task
|
call change_task
|
||||||
mov eax,[idlemem]
|
jmp idle_loop_entry
|
||||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
|
||||||
cmp eax,ebx
|
|
||||||
jnz idle_exit
|
|
||||||
call _rdtsc
|
|
||||||
mov ecx,eax
|
|
||||||
idle_loop:
|
idle_loop:
|
||||||
|
cmp ebx,[timer_ticks]
|
||||||
|
jne idle_exit
|
||||||
|
rdtsc ;call _rdtsc
|
||||||
|
mov ecx,eax
|
||||||
hlt
|
hlt
|
||||||
cmp [check_idle_semaphore],0
|
rdtsc ;call _rdtsc
|
||||||
jne idle_loop_exit
|
|
||||||
mov eax,[timer_ticks] ;[0xfdf0]
|
|
||||||
cmp ebx,eax
|
|
||||||
jz idle_loop
|
|
||||||
idle_loop_exit:
|
|
||||||
mov [idlemem],eax
|
|
||||||
call _rdtsc
|
|
||||||
sub eax,ecx
|
sub eax,ecx
|
||||||
mov ebx,[idleuse]
|
add [idleuse],eax
|
||||||
add ebx,eax
|
idle_loop_entry:
|
||||||
mov [idleuse],ebx
|
cmp [check_idle_semaphore],0
|
||||||
|
je idle_loop
|
||||||
popad
|
|
||||||
ret
|
|
||||||
|
|
||||||
idle_exit:
|
|
||||||
|
|
||||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
|
||||||
mov [idlemem],ebx
|
|
||||||
call change_task
|
|
||||||
|
|
||||||
popad
|
|
||||||
ret
|
|
||||||
|
|
||||||
no_idle_state:
|
|
||||||
|
|
||||||
dec [check_idle_semaphore]
|
dec [check_idle_semaphore]
|
||||||
|
idle_exit:
|
||||||
mov ebx,[timer_ticks] ;[0xfdf0]
|
|
||||||
mov [idlemem],ebx
|
|
||||||
call change_task
|
|
||||||
|
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
idlemem dd 0x0
|
|
||||||
idleuse dd 0x0
|
idleuse dd 0x0
|
||||||
idleusesec dd 0x0
|
idleusesec dd 0x0
|
||||||
check_idle_semaphore dd 0x0
|
check_idle_semaphore dd 0x0
|
||||||
@@ -1167,7 +1137,6 @@ set_variables:
|
|||||||
mov [BTN_ADDR],dword BUTTON_INFO ; address of button list
|
mov [BTN_ADDR],dword BUTTON_INFO ; address of button list
|
||||||
|
|
||||||
;!! IP 04.02.2005:
|
;!! IP 04.02.2005:
|
||||||
mov [next_usage_update], 100
|
|
||||||
mov byte [DONT_SWITCH], 0 ; change task if possible
|
mov byte [DONT_SWITCH], 0 ; change task if possible
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@@ -4669,7 +4638,7 @@ setmouse: ; set mousepicture -pointer
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
if used _rdtsc
|
||||||
_rdtsc:
|
_rdtsc:
|
||||||
bt [cpu_caps], CAPS_TSC
|
bt [cpu_caps], CAPS_TSC
|
||||||
jnc ret_rdtsc
|
jnc ret_rdtsc
|
||||||
@@ -4679,6 +4648,7 @@ _rdtsc:
|
|||||||
mov edx,0xffffffff
|
mov edx,0xffffffff
|
||||||
mov eax,0xffffffff
|
mov eax,0xffffffff
|
||||||
ret
|
ret
|
||||||
|
end if
|
||||||
|
|
||||||
rerouteirqs:
|
rerouteirqs:
|
||||||
|
|
||||||
@@ -5621,4 +5591,3 @@ __REV__ = __REV
|
|||||||
|
|
||||||
uglobals_size = $ - endofcode
|
uglobals_size = $ - endofcode
|
||||||
diff16 "end of kernel code",0,$
|
diff16 "end of kernel code",0,$
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ struc APPDATA
|
|||||||
db 5 dup(?)
|
db 5 dup(?)
|
||||||
|
|
||||||
.fpu_state dd ? ;+16
|
.fpu_state dd ? ;+16
|
||||||
.ev_count dd ? ;+20
|
.ev_count_ dd ? ;unused ;+20
|
||||||
.fpu_handler dd ? ;+24
|
.fpu_handler dd ? ;+24
|
||||||
.sse_handler dd ? ;+28
|
.sse_handler dd ? ;+28
|
||||||
.pl0_stack dd ? ;unused ;+32
|
.pl0_stack dd ? ;unused ;+32
|
||||||
@@ -138,8 +138,10 @@ struc APPDATA
|
|||||||
.cur_dir dd ? ;+80
|
.cur_dir dd ? ;+80
|
||||||
.wait_timeout dd ? ;+84
|
.wait_timeout dd ? ;+84
|
||||||
.saved_esp0 dd ? ;+88
|
.saved_esp0 dd ? ;+88
|
||||||
|
.wait_begin dd ? ;+92 +++
|
||||||
db 36 dup(?) ;+92
|
.wait_test dd ? ;+96 +++
|
||||||
|
.wait_param dd ? ;+100 +++
|
||||||
|
db 24 dup(?) ;+104
|
||||||
|
|
||||||
.wnd_shape dd ? ;+128
|
.wnd_shape dd ? ;+128
|
||||||
.wnd_shape_scale dd ? ;+132
|
.wnd_shape_scale dd ? ;+132
|
||||||
|
@@ -98,3 +98,9 @@ if ~ f eq
|
|||||||
end if
|
end if
|
||||||
}
|
}
|
||||||
; \end{diamond}[29.09.2006]
|
; \end{diamond}[29.09.2006]
|
||||||
|
|
||||||
|
macro Mov op1,op2,op3 ; op1 = op2 = op3
|
||||||
|
{
|
||||||
|
mov op2,op3
|
||||||
|
mov op1,op2
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user