delete TASKDATA

git-svn-id: svn://kolibrios.org@9709 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Doczom 2022-02-09 17:07:51 +00:00
parent 1fdbd55957
commit 707dc7c2e6
17 changed files with 200 additions and 215 deletions

View File

@ -224,11 +224,11 @@ OS_BASE = 0x80000000
window_data = OS_BASE + 0x0001000 window_data = OS_BASE + 0x0001000
TASK_TABLE = OS_BASE + 0x0003000 ;TASK_TABLE = OS_BASE + 0x0003000
;CURRENT_TASK = OS_BASE + 0x0003000 ;CURRENT_TASK = OS_BASE + 0x0003000
;TASK_COUNT = OS_BASE + 0x0003004 ;TASK_COUNT = OS_BASE + 0x0003004
TASK_BASE = OS_BASE + 0x0003010 ;TASK_BASE = OS_BASE + 0x0003010
TASK_DATA = OS_BASE + 0x0003020 ;TASK_DATA = OS_BASE + 0x0003020
;TASK_EVENT = OS_BASE + 0x0003020 ;TASK_EVENT = OS_BASE + 0x0003020
CDDataBuf = OS_BASE + 0x0005000 CDDataBuf = OS_BASE + 0x0005000
@ -281,7 +281,7 @@ LFB_BASE = 0xFE000000
new_app_base = 0; new_app_base = 0;
twdw = TASK_TABLE - window_data ;twdw = TASK_TABLE - window_data
std_application_base_address = new_app_base std_application_base_address = new_app_base
RING0_STACK_SIZE = 0x2000 RING0_STACK_SIZE = 0x2000
@ -511,16 +511,16 @@ struct APPDATA
wait_test dd ? ;+96 +++ wait_test dd ? ;+96 +++
wait_param dd ? ;+100 +++ wait_param dd ? ;+100 +++
tls_base dd ? ;+104 tls_base dd ? ;+104
event_mask dd ? ;+108 ; R stores event types allowed for task event_mask dd ? ;+108 stores event types allowed for task
tid dd ? ;+112 ; R thread id tid dd ? ;+112 thread id
draw_bgr_x dd ? ;+116 draw_bgr_x dd ? ;+116
draw_bgr_y dd ? ;+120 draw_bgr_y dd ? ;+120
state db ? ;+124 ; R thread state state db ? ;+124 thread state
wnd_number db ? ;+125 ; R wnd_number db ? ;+125
dw ? ;+126 dw ? ;+126
wnd_shape dd ? ;+128 wnd_shape dd ? ;+128
wnd_shape_scale dd ? ;+132 wnd_shape_scale dd ? ;+132
mem_start dd ? ;+136 ; R mem_start dd ? ;+136
counter_sum dd ? ;+140 ; R counter_sum dd ? ;+140 ; R
saved_box BOX ;+144 saved_box BOX ;+144
ipc_start dd ? ;+160 ipc_start dd ? ;+160
@ -549,20 +549,20 @@ APP_OBJ_OFFSET = 48
APP_EV_OFFSET = 40 APP_EV_OFFSET = 40
; Note: in future TASKDATA will be merged into APPDATA ; Note: in future TASKDATA will be merged into APPDATA
struct TASKDATA ;struct TASKDATA
event_mask dd ? ;+0 mask which stores event types allowed for task ; event_mask dd ? ;+0 mask which stores event types allowed for task
pid dd ? ;+4 ; pid dd ? ;+4
dw ? ;+8 ; dw ? ;+8
state db ? ;+10 ; state db ? ;+10
db ? ;+11 ; db ? ;+11
dw ? ;+12 ; dw ? ;+12
wnd_number db ? ;+14 ; wnd_number db ? ;+14
db ? ;+15 ; db ? ;+15
mem_start dd ? ;+16 ; mem_start dd ? ;+16
counter_sum dd ? ;+20 ; counter_sum dd ? ;+20
counter_add dd ? ;+24 ; counter_add dd ? ;+24
cpu_usage dd ? ;+28 ; cpu_usage dd ? ;+28
ends ;ends
; Thread states: ; Thread states:
TSTATE_RUNNING = 0 TSTATE_RUNNING = 0

View File

@ -46,10 +46,10 @@ get_debuggee_slot:
call pid_to_slot call pid_to_slot
test eax, eax test eax, eax
jz .ret_bad jz .ret_bad
shl eax, 5 shl eax, BSF sizeof.APPDATA
push ebx push ebx
mov ebx, [current_slot_idx] mov ebx, [current_slot_idx]
cmp [SLOT_BASE+eax*8+APPDATA.debugger_slot], ebx cmp [SLOT_BASE+eax+APPDATA.debugger_slot], ebx
pop ebx pop ebx
jnz .ret_bad jnz .ret_bad
; clc ; automatically ; clc ; automatically
@ -63,7 +63,7 @@ debug_detach:
; destroys eax,ebx ; destroys eax,ebx
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
and dword [eax*8+SLOT_BASE+APPDATA.debugger_slot], 0 and dword [eax+SLOT_BASE+APPDATA.debugger_slot], 0
call do_resume call do_resume
.ret: .ret:
sti sti
@ -74,7 +74,7 @@ debug_terminate:
call get_debuggee_slot call get_debuggee_slot
jc debug_detach.ret jc debug_detach.ret
mov ecx, eax mov ecx, eax
shr ecx, 5 shr ecx, BSF sizeof.APPDATA
; push 2 ; push 2
; pop ebx ; pop ebx
mov edx, esi mov edx, esi
@ -92,14 +92,14 @@ debug_suspend:
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
; } End patch ; } End patch
mov cl, [TASK_TABLE+eax+TASKDATA.state] ; process state mov cl, [SLOT_BASE + eax + APPDATA.state] ; process state
test cl, cl test cl, cl
jz .1 jz .1
cmp cl, 5 cmp cl, 5
jnz .ret jnz .ret
mov cl, 2 mov cl, 2
.2: .2:
mov [TASK_TABLE+eax+TASKDATA.state], cl mov [SLOT_BASE + eax + APPDATA.state], cl
.ret: .ret:
sti sti
ret ret
@ -108,14 +108,14 @@ debug_suspend:
jmp .2 jmp .2
do_resume: do_resume:
mov cl, [TASK_TABLE+eax+TASKDATA.state] mov cl, [SLOT_BASE + eax + APPDATA.state]
cmp cl, 1 cmp cl, 1
jz .1 jz .1
cmp cl, 2 cmp cl, 2
jnz .ret jnz .ret
mov cl, 5 mov cl, 5
.2: .2:
mov [TASK_TABLE+eax+TASKDATA.state], cl mov [SLOT_BASE + eax + APPDATA.state], cl
.ret: .ret:
ret ret
.1: .1:
@ -128,7 +128,7 @@ debug_resume:
cli cli
mov eax, ecx mov eax, ecx
call pid_to_slot call pid_to_slot
shl eax, 5 shl eax, BSF sizeof.APPDATA
jz .ret jz .ret
call do_resume call do_resume
.ret: .ret:
@ -155,12 +155,12 @@ debug_getcontext:
call get_debuggee_slot call get_debuggee_slot
jc .ret jc .ret
shr eax, 5 shr eax, 8
cmp eax, [fpu_owner] cmp eax, [fpu_owner]
jne @f jne @f
inc bh ; set swap context flag inc bh ; set swap context flag
@@: @@:
shl eax, 8 shl eax, BSF sizeof.APPDATA
mov edi, esi mov edi, esi
mov eax, [eax+SLOT_BASE+APPDATA.pl0_stack] mov eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE] lea esi, [eax+RING0_STACK_SIZE]
@ -231,7 +231,7 @@ debug_setcontext:
call get_debuggee_slot call get_debuggee_slot
jc .stiret jc .stiret
; mov esi, edx ; mov esi, edx
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack] mov eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
lea edi, [eax+RING0_STACK_SIZE] lea edi, [eax+RING0_STACK_SIZE]
.ring0: .ring0:
@ -267,7 +267,7 @@ debug_set_drx:
call get_debuggee_slot call get_debuggee_slot
jc .errret jc .errret
mov ebp, eax mov ebp, eax
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs] lea eax, [eax+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3 ; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7 ; [eax+10]=dr7
cmp esi, OS_BASE cmp esi, OS_BASE
@ -294,7 +294,7 @@ debug_set_drx:
jnz .okret jnz .okret
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; and byte [eax + tss_data + TSS._trap], not 1 ; and byte [eax + tss_data + TSS._trap], not 1
and [ebp*8 + SLOT_BASE+APPDATA.dbg_state], not 1 and [ebp + SLOT_BASE+APPDATA.dbg_state], not 1
.okret: .okret:
and dword [esp+32], 0 and dword [esp+32], 0
sti sti
@ -341,7 +341,7 @@ debug_set_drx:
or [eax+10h+2], dx ; set R/W and LEN fields or [eax+10h+2], dx ; set R/W and LEN fields
; imul eax, ebp, tss_step/32 ; imul eax, ebp, tss_step/32
; or byte [eax + tss_data + TSS._trap], 1 ; or byte [eax + tss_data + TSS._trap], 1
or [ebp*8 + SLOT_BASE+APPDATA.dbg_state], 1 or [ebp + SLOT_BASE+APPDATA.dbg_state], 1
jmp .okret jmp .okret
debug_read_process_memory: debug_read_process_memory:
@ -354,7 +354,7 @@ debug_read_process_memory:
; destroys all ; destroys all
call get_debuggee_slot call get_debuggee_slot
jc .err jc .err
shr eax, 5 shr eax, 8
mov ecx, edi mov ecx, edi
call read_process_memory call read_process_memory
sti sti
@ -374,7 +374,7 @@ debug_write_process_memory:
; destroys all ; destroys all
call get_debuggee_slot call get_debuggee_slot
jc debug_read_process_memory.err jc debug_read_process_memory.err
shr eax, 5 shr eax, 8
mov ecx, edi mov ecx, edi
call write_process_memory call write_process_memory
sti sti

View File

@ -280,7 +280,6 @@ proc find_next_task
test bl, bl test bl, bl
jz .start jz .start
mov ebx, [current_slot] mov ebx, [current_slot]
mov edi, [TASK_BASE]
mov eax, [ebx+APPDATA.priority] mov eax, [ebx+APPDATA.priority]
test eax, eax test eax, eax
jz .unlock_found jz .unlock_found
@ -293,11 +292,7 @@ proc find_next_task
jz .priority_next jz .priority_next
.task_loop: .task_loop:
mov ebx, [ebx+APPDATA.in_schedule.next] mov ebx, [ebx+APPDATA.in_schedule.next]
;mov al, [ebx+APPDATA.state] mov al, [ebx+APPDATA.state]
mov edi, ebx ;
shr edi, 3 ;
add edi, TASK_TABLE - (SLOT_BASE shr 3) ; on delete
mov al, [edi+TASKDATA.state] ;
test al, al test al, al
jz .task_found ; state == 0 jz .task_found ; state == 0
cmp al, 5 cmp al, 5
@ -317,7 +312,6 @@ proc find_next_task
xor eax, eax xor eax, eax
@@: @@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], TSTATE_RUNNING ; on delete
mov [ebx+APPDATA.state], TSTATE_RUNNING mov [ebx+APPDATA.state], TSTATE_RUNNING
.task_found: .task_found:
mov [scheduler_current+ecx*4], ebx mov [scheduler_current+ecx*4], ebx
@ -338,7 +332,7 @@ proc find_next_task
; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is
; aligned on 0x10000 ; aligned on 0x10000
mov byte [current_slot_idx], bh mov byte [current_slot_idx], bh
mov [TASK_BASE], edi
rdtsc ;call _rdtsc rdtsc ;call _rdtsc
mov [ebx-sizeof.APPDATA+APPDATA.counter_add], eax; for next using update_counters mov [ebx-sizeof.APPDATA+APPDATA.counter_add], eax; for next using update_counters
;mov [edi+TASKDATA.counter_add], eax; for next using update_counters ;mov [edi+TASKDATA.counter_add], eax; for next using update_counters
@ -352,7 +346,6 @@ proc find_next_task
cmp ecx, [esp] cmp ecx, [esp]
jb .priority_loop jb .priority_loop
mov ebx, [current_slot] mov ebx, [current_slot]
mov edi, [TASK_BASE]
jmp .unlock_found jmp .unlock_found
endp endp

View File

@ -38,7 +38,7 @@ mutex_lock:
list_add_tail esp, ecx ;esp= new waiter, ecx= list head list_add_tail esp, ecx ;esp= new waiter, ecx= list head
mov edx, [TASK_BASE] mov edx, [current_slot]
mov [esp+MUTEX_WAITER.task], edx mov [esp+MUTEX_WAITER.task], edx
.forever: .forever:
@ -48,7 +48,7 @@ mutex_lock:
dec eax dec eax
jz @F jz @F
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
jmp .forever jmp .forever
@@: @@:
@ -80,7 +80,7 @@ mutex_unlock:
je @F je @F
mov eax, [eax+MUTEX_WAITER.task] mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING mov [eax + APPDATA.state], TSTATE_RUNNING
@@: @@:
popfd popfd
ret ret
@ -111,10 +111,10 @@ down_read:
@@: @@:
sub esp, sizeof.MUTEX_WAITER sub esp, sizeof.MUTEX_WAITER
mov eax, [TASK_BASE] mov eax, [current_slot]
mov [esp+MUTEX_WAITER.task], eax mov [esp+MUTEX_WAITER.task], eax
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_READ mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_READ
mov [eax+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [eax + APPDATA.state], TSTATE_RUN_SUSPENDED
list_add_tail esp, ecx ;esp= new waiter, ecx= list head list_add_tail esp, ecx ;esp= new waiter, ecx= list head
@ -138,10 +138,10 @@ down_write:
cli cli
sub esp, sizeof.MUTEX_WAITER sub esp, sizeof.MUTEX_WAITER
mov edx, [TASK_BASE] mov edx, [current_slot]
mov [esp+MUTEX_WAITER.task], edx mov [esp+MUTEX_WAITER.task], edx
mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_WRITE mov [esp+MUTEX_WAITER.type], RWSEM_WAITING_FOR_WRITE
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
list_add_tail esp, ecx ;esp= new waiter, ecx= list head list_add_tail esp, ecx ;esp= new waiter, ecx= list head
@ -152,7 +152,7 @@ down_write:
test eax, [ecx+RWSEM.count] test eax, [ecx+RWSEM.count]
jz @F jz @F
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
jmp .forever jmp .forever
@@: @@:
@ -178,7 +178,7 @@ up_read:
je @F je @F
mov eax, [eax+MUTEX_WAITER.task] mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING mov [eax + APPDATA.state], TSTATE_RUNNING
@@: @@:
popfd popfd
ret ret
@ -202,7 +202,7 @@ up_write:
jnz .wake jnz .wake
mov eax, [eax+MUTEX_WAITER.task] mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING mov [eax + APPDATA.state], TSTATE_RUNNING
.done: .done:
popfd popfd
ret ret
@ -220,7 +220,7 @@ up_write:
mov ebx, [eax+MUTEX_WAITER.list.next] mov ebx, [eax+MUTEX_WAITER.list.next]
list_del eax list_del eax
mov edx, [eax+MUTEX_WAITER.task] mov edx, [eax+MUTEX_WAITER.task]
mov [edx+TASKDATA.state], TSTATE_RUNNING mov [edx + APPDATA.state], TSTATE_RUNNING
inc esi inc esi
cmp edi, ebx cmp edi, ebx
je .wake_done je .wake_done

View File

@ -150,9 +150,9 @@ exc_c: ; exceptions (all but 7th - #NM)
test eax, eax test eax, eax
jnz .debug jnz .debug
; not debuggee => say error and terminate ; not debuggee => say error and terminate
call show_error_parameters call show_error_parameters ; this function output in edx = current_slot
sti sti
mov [edx + TASKDATA.state], TSTATE_TERMINATING mov [edx + APPDATA.state], TSTATE_TERMINATING
call wakeup_osloop call wakeup_osloop
call change_task call change_task
; If we're here, then the main OS thread has crashed before initializing IDLE thread. ; If we're here, then the main OS thread has crashed before initializing IDLE thread.
@ -186,8 +186,8 @@ exc_c: ; exceptions (all but 7th - #NM)
mov cl, 12 ; debug_message size mov cl, 12 ; debug_message size
call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc
add esp, 12 add esp, 12
mov edx, [TASK_BASE] mov edx, [current_slot]
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task ; SEE: core/shed.inc call change_task ; SEE: core/shed.inc
restore_ring3_context restore_ring3_context
iretd iretd
@ -288,6 +288,27 @@ show_error_parameters:
test eax, eax test eax, eax
jnz .error_ESP jnz .error_ESP
DEBUGF 1, " [ESP+32]: %x\n",[ebx] DEBUGF 1, " [ESP+32]: %x\n",[ebx]
;for input instruction
mov ebx, [reg_eip+4]
call .check_ESP
test eax, eax
jnz .error_ESP
DEBUGF 1, "K : [EIP]: %x",[ebx]
add ebx, 4
call .check_ESP
test eax, eax
jnz .error_ESP
DEBUGF 1, " [EIP+4]: %x",[ebx]
add ebx, 4
call .check_ESP
test eax, eax
jnz .error_ESP
DEBUGF 1, " [EIP+8]: %x\n",[ebx]
add ebx, 4
call .check_ESP
test eax, eax
jnz .error_ESP
DEBUGF 1, "K : [EIP+12]: %x\n",[ebx]
pop edx ecx ebx eax pop edx ecx ebx eax
ret ret
.error_ESP: .error_ESP:
@ -412,13 +433,12 @@ destroy_thread:
push esi ;save .slot push esi ;save .slot
shl esi, 8 shl esi, BSF sizeof.APPDATA
mov edx, [SLOT_BASE+esi+APPDATA.process] mov edx, [SLOT_BASE+esi+APPDATA.process]
test edx, edx test edx, edx
jnz @F jnz @F
mov [SLOT_BASE + esi + APPDATA.state], TSTATE_FREE
pop esi pop esi
shl esi, BSF sizeof.TASKDATA
mov [TASK_TABLE+esi+TASKDATA.state], TSTATE_FREE
ret ret
@@: @@:
push edx ;save .process push edx ;save .process
@ -428,7 +448,7 @@ destroy_thread:
; if the process is in V86 mode... ; if the process is in V86 mode...
mov eax, [.slot] mov eax, [.slot]
shl eax, 8 shl eax, BSF sizeof.APPDATA
mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack] mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack]
add esi, RING0_STACK_SIZE add esi, RING0_STACK_SIZE
cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi
@ -445,7 +465,7 @@ destroy_thread:
.nov86: .nov86:
; destroy per-thread kernel objects ; destroy per-thread kernel objects
mov esi, [.slot] mov esi, [.slot]
shl esi, 8 shl esi, BSF sizeof.APPDATA
add esi, SLOT_BASE+APP_OBJ_OFFSET add esi, SLOT_BASE+APP_OBJ_OFFSET
@@: @@:
mov eax, [esi+APPOBJ.fd] mov eax, [esi+APPOBJ.fd]
@ -591,7 +611,7 @@ destroy_thread:
popad popad
mov ebx, [.slot] mov ebx, [.slot]
shl ebx, 8 shl ebx, BSF sizeof.APPDATA
push ebx push ebx
mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack] mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack]
@ -602,7 +622,7 @@ destroy_thread:
stdcall kernel_free, ebx stdcall kernel_free, ebx
mov edi, [.slot] mov edi, [.slot]
shl edi, 8 shl edi, BSF sizeof.APPDATA
add edi, SLOT_BASE add edi, SLOT_BASE
mov eax, [edi+APPDATA.io_map] mov eax, [edi+APPDATA.io_map]
@ -637,9 +657,10 @@ destroy_thread:
jbe .nothing_to_activate jbe .nothing_to_activate
lea esi, [WIN_POS+eax*2] lea esi, [WIN_POS+eax*2]
movzx edi, word [esi] ; edi = process movzx edi, word [esi] ; edi = process
shl edi, BSF sizeof.TASKDATA shl edi, BSF sizeof.APPDATA
cmp [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE ; skip free slots cmp [SLOT_BASE + edi + APPDATA.state], TSTATE_FREE ; skip free slots
je .check_next_window je .check_next_window
shr edi, 3
add edi, window_data add edi, window_data
; \begin{diamond}[19.09.2006] ; \begin{diamond}[19.09.2006]
; skip minimized windows ; skip minimized windows
@ -711,8 +732,8 @@ destroy_thread:
popa popa
mov edi, esi ; do not run this process slot mov edi, esi ; do not run this process slot
shl edi, BSF sizeof.TASKDATA shl edi, BSF sizeof.APPDATA
mov [edi+TASK_TABLE + TASKDATA.state], TSTATE_FREE mov [edi + SLOT_BASE + APPDATA.state], TSTATE_FREE
; debugger test - terminate all debuggees ; debugger test - terminate all debuggees
mov eax, 2 mov eax, 2
mov ecx, SLOT_BASE+2*sizeof.APPDATA + APPDATA.debugger_slot mov ecx, SLOT_BASE+2*sizeof.APPDATA + APPDATA.debugger_slot

View File

@ -487,26 +487,22 @@ pid_to_slot:
push ebx push ebx
push ecx push ecx
mov ebx, [thread_count] mov ebx, [thread_count]
shl ebx, BSF sizeof.TASKDATA ; multiply by size shl ebx, BSF sizeof.APPDATA ; multiply by size
;shl ebx, BSF sizeof.APPDATA ; multiply by size
; add 2*32 cause: ; add 2*32 cause:
; [TASK_TABLE; TASK_TABLE + 32) isnt a task actually ; [TASK_TABLE; TASK_TABLE + 32) isnt a task actually
; skip first process in the task table ; skip first process in the task table
mov ecx, 2*32 ;sizeof.TASKDATA ;mov ecx, 2*32 ;sizeof.TASKDATA
;mov ecx, sizeof.APPDATA mov ecx, sizeof.APPDATA
.loop: .loop:
;ecx = offset of current process info entry ;ecx = offset of current process info entry
;ebx = maximum permitted offset ;ebx = maximum permitted offset
cmp [TASK_TABLE+ecx+TASKDATA.state], TSTATE_FREE cmp [SLOT_BASE + ecx + APPDATA.state], TSTATE_FREE
jz .endloop ;skip empty slots jz .endloop ;skip empty slots
;cmp [ecx+SLOT_BASE+APPDATA.state], TSTATE_FREE cmp [ecx + SLOT_BASE + APPDATA.tid], eax;check PID
;jz .endloop ;skip empty slots
cmp [ecx*8 + SLOT_BASE + APPDATA.tid], eax;check PID
jz .pid_found jz .pid_found
.endloop: .endloop:
add ecx, sizeof.TASKDATA add ecx, sizeof.APPDATA
;add ecx, sizeof.APPDATA
cmp ecx, ebx cmp ecx, ebx
jle .loop jle .loop
@ -516,8 +512,7 @@ pid_to_slot:
ret ret
.pid_found: .pid_found:
shr ecx, BSF sizeof.TASKDATA ; divide by size shr ecx, BSF sizeof.APPDATA ; divide by size
;shr ecx, BSF sizeof.APPDATA
mov eax, ecx ;convert offset to index of slot mov eax, ecx ;convert offset to index of slot
pop ecx pop ecx
pop ebx pop ebx
@ -903,8 +898,7 @@ common_app_entry:
cmp [ebx+APPDATA.debugger_slot], 0 cmp [ebx+APPDATA.debugger_slot], 0
je .exit je .exit
mov [ebx+APPDATA.state], TSTATE_RUN_SUSPENDED mov [ebx+APPDATA.state], TSTATE_RUN_SUSPENDED
mov eax, [TASK_BASE] mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
mov [eax+TASKDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
.exit: .exit:
popad popad
@ -932,7 +926,7 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
mov eax, [slot] mov eax, [slot]
mov ebx, eax mov ebx, eax
shl eax, 8 shl eax, BSF sizeof.APPDATA
mov [eax+SLOT_BASE+APPDATA.fpu_state], edi mov [eax+SLOT_BASE+APPDATA.fpu_state], edi
mov [eax+SLOT_BASE+APPDATA.exc_handler], 0 mov [eax+SLOT_BASE+APPDATA.exc_handler], 0
mov [eax+SLOT_BASE+APPDATA.except_mask], 0 mov [eax+SLOT_BASE+APPDATA.except_mask], 0
@ -952,7 +946,7 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
cmp [thread_count], ebx cmp [thread_count], ebx
adc [thread_count], 0 ; update number of processes adc [thread_count], 0 ; update number of processes
shl ebx, 8 shl ebx, BSF sizeof.APPDATA
lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET]
mov [SLOT_BASE+APPDATA.fd_ev+ebx], edx mov [SLOT_BASE+APPDATA.fd_ev+ebx], edx
mov [SLOT_BASE+APPDATA.bk_ev+ebx], edx mov [SLOT_BASE+APPDATA.bk_ev+ebx], edx
@ -987,7 +981,7 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
mov eax, [slot] mov eax, [slot]
mov [ebx+SLOT_BASE+APPDATA.wnd_number], al mov [ebx+SLOT_BASE+APPDATA.wnd_number], al
mov ebx, eax mov ebx, eax
shl ebx, 5 shl ebx, BSF sizeof.WDATA
lea ecx, [draw_data+ebx];ecx - pointer to draw data lea ecx, [draw_data+ebx];ecx - pointer to draw data
; set window state to 'normal' (non-minimized/maximized/rolled-up) state ; set window state to 'normal' (non-minimized/maximized/rolled-up) state
@ -1037,20 +1031,18 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
lea edx, [ebx+REG_RET] lea edx, [ebx+REG_RET]
mov ebx, [slot] mov ebx, [slot]
shl ebx, 5 shl ebx, BSF sizeof.APPDATA
mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], edx mov [ebx+SLOT_BASE+APPDATA.saved_esp], edx
xor edx, edx; process state - running xor edx, edx; process state - running
; set if debuggee ; set if debuggee
test byte [flags], 1 test byte [flags], 1
jz .no_debug jz .no_debug
mov eax, [current_slot_idx] mov eax, [current_slot_idx]
mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot], eax mov [SLOT_BASE+ebx+APPDATA.debugger_slot], eax
.no_debug: .no_debug:
mov [TASK_TABLE+ebx+TASKDATA.state], dl mov [SLOT_BASE + ebx + APPDATA.state], dl
;shl ebx, 3 lea edx, [SLOT_BASE+ebx]
;mov [ebx+SLOT_BASE+APPDATA.state], dl
lea edx, [SLOT_BASE+ebx*8]
call scheduler_add_thread call scheduler_add_thread
ret ret
endp endp

View File

@ -898,9 +898,6 @@ v86_irq2:
mov word [esi-sizeof.v86_regs+v86_regs.cs], cx mov word [esi-sizeof.v86_regs+v86_regs.cs], cx
and byte [esi-sizeof.v86_regs+v86_regs.eflags+1], not 3 and byte [esi-sizeof.v86_regs+v86_regs.eflags+1], not 3
call update_counters call update_counters
lea edi, [ebx + 0x100000000 - SLOT_BASE]
shr edi, 3
add edi, TASK_TABLE
call find_next_task.found call find_next_task.found
call do_change_task call do_change_task
popad popad

View File

@ -136,9 +136,10 @@ syscall_button: ;////////////// system function 8 //////////////
dec ebp dec ebp
shr ebx, 16 shr ebx, 16
shr ecx, 16 shr ecx, 16
mov eax, [TASK_BASE] mov eax, [current_slot_idx]
add ebx, [eax - twdw + WDATA.box.left] shl eax, BSF sizeof.WDATA
add ecx, [eax - twdw + WDATA.box.top] add ebx, [eax + window_data + WDATA.box.left]
add ecx, [eax + window_data + WDATA.box.top]
mov eax, ebx mov eax, ebx
inc eax inc eax
mov edx, ebx mov edx, ebx

View File

@ -281,8 +281,6 @@ Wait_events_ex:
mov eax, [timer_ticks] mov eax, [timer_ticks]
mov [esi+APPDATA.wait_begin], eax mov [esi+APPDATA.wait_begin], eax
mov [esi + APPDATA.state], TSTATE_WAITING mov [esi + APPDATA.state], TSTATE_WAITING
mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], TSTATE_WAITING
call change_task call change_task
mov eax, [esi+APPDATA.wait_param] mov eax, [esi+APPDATA.wait_param]
;-------------------------------------- ;--------------------------------------
@ -513,7 +511,7 @@ get_event_for_app: ;; used from f10,f11,f23
movzx edi, bh ; bh is assumed as [current_slot_idx] movzx edi, bh ; bh is assumed as [current_slot_idx]
mov ecx, [ebx+APPDATA.event_mask] mov ecx, [ebx+APPDATA.event_mask]
shl edi, 5 shl edi, 5
add edi, TASK_TABLE ; edi is assumed as [TASK_BASE] add edi, window_data
and ecx, 0x7FFFFFFF and ecx, 0x7FFFFFFF
;-------------------------------------- ;--------------------------------------
align 4 align 4
@ -541,7 +539,7 @@ align 4
;-------------------------------------- ;--------------------------------------
align 4 align 4
.WndRedraw: ; eax=0, retval WndRedraw=1 .WndRedraw: ; eax=0, retval WndRedraw=1
cmp [edi-twdw+WDATA.fl_redraw], al;al==0 cmp [edi + WDATA.fl_redraw], al;al==0
jne .result jne .result
jmp .loop jmp .loop
;-------------------------------------- ;--------------------------------------

View File

@ -726,10 +726,11 @@ dd .loadCursorUni
mov eax, [MOUSE_X] mov eax, [MOUSE_X]
shl eax, 16 shl eax, 16
mov ax, [MOUSE_Y] mov ax, [MOUSE_Y]
mov esi, [TASK_BASE] mov esi, [current_slot_idx]
mov bx, word [esi-twdw+WDATA.box.left] shl esi, BSF sizeof.WDATA
mov bx, word [esi + window_data + WDATA.box.left]
shl ebx, 16 shl ebx, 16
mov bx, word [esi-twdw+WDATA.box.top] mov bx, word [esi + window_data + WDATA.box.top]
sub eax, ebx sub eax, ebx
mov edi, [current_slot_idx] mov edi, [current_slot_idx]
shl edi, 8 shl edi, 8

View File

@ -78,9 +78,10 @@ syscall_setpixel:
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
mov ecx, edx mov ecx, edx
mov edx, [TASK_BASE] mov edx, [current_slot_idx]
add eax, [edx-twdw+WDATA.box.left] shl edx, BSF sizeof.WDATA
add ebx, [edx-twdw+WDATA.box.top] add eax, [edx + window_data + WDATA.box.left]
add ebx, [edx + window_data + WDATA.box.top]
mov edi, [current_slot] mov edi, [current_slot]
add eax, [edi+APPDATA.wnd_clientbox.left] add eax, [edi+APPDATA.wnd_clientbox.left]
add ebx, [edi+APPDATA.wnd_clientbox.top] add ebx, [edi+APPDATA.wnd_clientbox.top]
@ -103,13 +104,14 @@ syscall_writetext:
pop esi pop esi
jnz .err jnz .err
mov eax, [TASK_BASE] mov eax, [current_slot_idx]
mov ebp, [eax-twdw+WDATA.box.left] shl eax, BSF sizeof.WDATA
mov ebp, [eax + window_data + WDATA.box.left]
push esi push esi
mov esi, [current_slot] mov esi, [current_slot]
add ebp, [esi+APPDATA.wnd_clientbox.left] add ebp, [esi+APPDATA.wnd_clientbox.left]
shl ebp, 16 shl ebp, 16
add ebp, [eax-twdw+WDATA.box.top] add ebp, [eax + window_data + WDATA.box.top]
add bp, word[esi+APPDATA.wnd_clientbox.top] add bp, word[esi+APPDATA.wnd_clientbox.top]
pop esi pop esi
test ecx, 0x08000000 ; redirect the output to the user area test ecx, 0x08000000 ; redirect the output to the user area
@ -163,15 +165,16 @@ syscall_drawrect:
align 4 align 4
; system function 38 ; system function 38
syscall_drawline: syscall_drawline:
mov edi, [TASK_BASE] mov edi, [current_slot_idx]
movzx eax, word[edi-twdw+WDATA.box.left] shl edi, BSF sizeof.WDATA
movzx eax, word[edi + window_data + WDATA.box.left]
mov ebp, eax mov ebp, eax
mov esi, [current_slot] mov esi, [current_slot]
add ebp, [esi+APPDATA.wnd_clientbox.left] add ebp, [esi+APPDATA.wnd_clientbox.left]
add ax, word[esi+APPDATA.wnd_clientbox.left] add ax, word[esi+APPDATA.wnd_clientbox.left]
add ebp, ebx add ebp, ebx
shl eax, 16 shl eax, 16
movzx ebx, word[edi-twdw+WDATA.box.top] movzx ebx, word[edi + window_data + WDATA.box.top]
add eax, ebp add eax, ebp
mov ebp, ebx mov ebp, ebx
add ebp, [esi+APPDATA.wnd_clientbox.top] add ebp, [esi+APPDATA.wnd_clientbox.top]
@ -429,7 +432,7 @@ align 4
; system function 67 ; system function 67
syscall_move_window: syscall_move_window:
mov edi, [current_slot_idx] mov edi, [current_slot_idx]
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
test [edi + WDATA.fl_wdrawn], 1 test [edi + WDATA.fl_wdrawn], 1
@ -485,7 +488,7 @@ align 4
; system function 71 ; system function 71
syscall_window_settings: syscall_window_settings:
mov edi, [current_slot_idx] mov edi, [current_slot_idx]
shl edi, 5 shl edi, BSF sizeof.WDATA
or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
cmp ebx, 2 cmp ebx, 2
jz @f jz @f
@ -556,9 +559,9 @@ align 4
align 4 align 4
.next_window: .next_window:
movzx edi, word[WIN_POS + esi * 2] movzx edi, word[WIN_POS + esi * 2]
shl edi, 5 ;size of TASKDATA and WDATA = 32 bytes shl edi, BSF sizeof.WDATA ;size of TASKDATA and WDATA = 32 bytes
cmp byte [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE cmp byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
je .skip_window je .skip_window
add edi, window_data add edi, window_data
@ -625,7 +628,7 @@ align 4
;--------------------------------------------- ;---------------------------------------------
mov esi, [thread_count] mov esi, [thread_count]
movzx edi, word[WIN_POS + esi * 2] movzx edi, word[WIN_POS + esi * 2]
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
pop eax ebx ecx edx pop eax ebx ecx edx
@ -1033,7 +1036,7 @@ waredraw:
pushad pushad
mov edi, [thread_count] mov edi, [thread_count]
movzx esi, word[WIN_POS + edi * 2] movzx esi, word[WIN_POS + edi * 2]
shl esi, 5 shl esi, BSF sizeof.WDATA
add esi, window_data add esi, window_data
mov eax, [esi + WDATA.box.left] mov eax, [esi + WDATA.box.left]
@ -1085,9 +1088,9 @@ minimize_all_window:
align 4 align 4
.loop: .loop:
movzx edi, word[WIN_POS + eax * 2] movzx edi, word[WIN_POS + eax * 2]
shl edi, 5 shl edi, BSF sizeof.WDATA
; it is a unused slot? ; it is a unused slot?
cmp byte [edi+TASK_TABLE+TASKDATA.state], TSTATE_FREE cmp byte [edi*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE
je @f je @f
; it is a hidden thread? ; it is a hidden thread?
lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] lea esi, [edi*8+SLOT_BASE+APPDATA.app_name]
@ -1133,7 +1136,7 @@ minimize_window:
; is it already minimized? ; is it already minimized?
movzx edi, word[WIN_POS + eax * 2] movzx edi, word[WIN_POS + eax * 2]
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .exit jnz .exit
@ -1194,7 +1197,7 @@ restore_minimized_window:
; is it already restored? ; is it already restored?
movzx esi, word[WIN_POS + eax * 2] movzx esi, word[WIN_POS + eax * 2]
mov edi, esi mov edi, esi
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jz .exit jz .exit
@ -1262,7 +1265,7 @@ align 4
;> esi = process slot ;> esi = process slot
sys_window_maximize_handler: sys_window_maximize_handler:
mov edi, esi mov edi, esi
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
; can window change its height? ; can window change its height?
@ -1293,7 +1296,7 @@ sys_window_maximize_handler:
align 4 align 4
.restore_size: .restore_size:
mov eax, esi mov eax, esi
shl eax, 8 shl eax, BSF sizeof.APPDATA
add eax, SLOT_BASE + APPDATA.saved_box add eax, SLOT_BASE + APPDATA.saved_box
push [eax + BOX.height] \ push [eax + BOX.height] \
[eax + BOX.width] \ [eax + BOX.width] \
@ -1327,7 +1330,7 @@ align 4
;> esi = process slot ;> esi = process slot
sys_window_rollup_handler: sys_window_rollup_handler:
mov edx, esi mov edx, esi
shl edx, 8 shl edx, BSF sizeof.APPDATA
add edx, SLOT_BASE add edx, SLOT_BASE
; toggle normal/rolled up window state ; toggle normal/rolled up window state
@ -1394,7 +1397,7 @@ sys_window_end_moving_handler:
; call window._.end_moving__box ; call window._.end_moving__box
mov edi, esi mov edi, esi
shl edi, 5 shl edi, BSF sizeof.WDATA
add edi, window_data add edi, window_data
test [fl_moving], 1 test [fl_moving], 1
@ -1630,7 +1633,7 @@ align 4
;< edx = pointer to WDATA struct ;< edx = pointer to WDATA struct
window._.sys_set_window: window._.sys_set_window:
mov eax, [current_slot_idx] mov eax, [current_slot_idx]
shl eax, 5 shl eax, BSF sizeof.WDATA
add eax, window_data add eax, window_data
; save window colors ; save window colors
mov [eax + WDATA.cl_workarea], edx mov [eax + WDATA.cl_workarea], edx
@ -1866,7 +1869,7 @@ end virtual
cmp esi, 1 cmp esi, 1
jz .check_for_shaped_window jz .check_for_shaped_window
mov edi, esi mov edi, esi
shl edi, 5 shl edi, BSF sizeof.WDATA
cmp [window_data + edi + WDATA.box.width], 0 cmp [window_data + edi + WDATA.box.width], 0
jnz .check_for_shaped_window jnz .check_for_shaped_window
cmp [window_data + edi + WDATA.box.height], 0 cmp [window_data + edi + WDATA.box.height], 0
@ -1875,7 +1878,7 @@ end virtual
align 4 align 4
.check_for_shaped_window: .check_for_shaped_window:
mov edi, esi mov edi, esi
shl edi, 8 shl edi, BSF sizeof.APPDATA
add edi, SLOT_BASE add edi, SLOT_BASE
cmp [edi + APPDATA.wnd_shape], 0 cmp [edi + APPDATA.wnd_shape], 0
jne .shaped_window jne .shaped_window
@ -1950,7 +1953,7 @@ align 4
push edx ecx ; for loop - x,y size push edx ecx ; for loop - x,y size
mov ecx, esi mov ecx, esi
shl ecx, 5 shl ecx, BSF sizeof.WDATA
mov edx, [window_data + ecx + WDATA.box.top] mov edx, [window_data + ecx + WDATA.box.top]
push [window_data + ecx + WDATA.box.width] ; for loop - width push [window_data + ecx + WDATA.box.width] ; for loop - width
mov ecx, [window_data + ecx + WDATA.box.left] mov ecx, [window_data + ecx + WDATA.box.left]
@ -2036,7 +2039,7 @@ window._.window_activate:
; DEBUGF 1, "K : thread_count (0x%x)\n", ebx ; DEBUGF 1, "K : thread_count (0x%x)\n", ebx
movzx ebx, word[WIN_POS + ebx * 2] movzx ebx, word[WIN_POS + ebx * 2]
shl ebx, 5 shl ebx, BSF sizeof.WDATA
add eax, window_data add eax, window_data
mov al, [window_data + ebx + WDATA.fl_wstyle] mov al, [window_data + ebx + WDATA.fl_wstyle]
and al, 0x0f and al, 0x0f
@ -2191,8 +2194,8 @@ align 4
ja .exit.no_redraw ja .exit.no_redraw
movzx edx, word[esi] movzx edx, word[esi]
shl edx, 5 ; size of TASKDATA and WDATA is 32 bytes shl edx, BSF sizeof.WDATA ; size of TASKDATA and WDATA is 32 bytes
cmp byte [TASK_TABLE + edx + TASKDATA.state], TSTATE_FREE cmp byte [SLOT_BASE + edx*8 - sizeof.APPDATA + APPDATA.state], TSTATE_FREE
je .next_window je .next_window
mov eax, [edi + WDATA.box.top] mov eax, [edi + WDATA.box.top]
@ -2283,7 +2286,7 @@ align 4
align 4 align 4
.2: .2:
mov edi, [current_slot_idx] mov edi, [current_slot_idx]
shl edi, 5 shl edi, BSF sizeof.WDATA
test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
jz .exit jz .exit
mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption] mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
@ -2387,18 +2390,19 @@ align 4
; void __fastcall get_window_rect(struct RECT* rc); ; void __fastcall get_window_rect(struct RECT* rc);
; ecx = pointer to RECT ; ecx = pointer to RECT
window._.get_rect: window._.get_rect:
mov eax, [TASK_BASE] mov eax, [current_slot_idx]
shl eax, BSF sizeof.WDATA
mov edx, [eax-twdw + WDATA.box.left] mov edx, [eax + window_data + WDATA.box.left]
mov [ecx+RECT.left], edx mov [ecx+RECT.left], edx
add edx, [eax-twdw + WDATA.box.width] add edx, [eax + window_data + WDATA.box.width]
mov [ecx+RECT.right], edx mov [ecx+RECT.right], edx
mov edx, [eax-twdw + WDATA.box.top] mov edx, [eax +window_data + WDATA.box.top]
mov [ecx+RECT.top], edx mov [ecx+RECT.top], edx
add edx, [eax-twdw + WDATA.box.height] add edx, [eax + window_data + WDATA.box.height]
mov [ecx+RECT.bottom], edx mov [ecx+RECT.bottom], edx
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -2438,7 +2442,7 @@ window._.set_top_wnd:
cmp ebp, 1 cmp ebp, 1
jbe .exit jbe .exit
shl esi, 5 shl esi, BSF sizeof.WDATA
cmp [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP cmp [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
je .exit je .exit
@ -2457,9 +2461,9 @@ align 4
align 4 align 4
.next_window: .next_window:
movzx edi, word[WIN_POS + esi * 2] movzx edi, word[WIN_POS + esi * 2]
shl edi, 5 ;size of TASKDATA and WDATA = 32 bytes shl edi, BSF sizeof.WDATA ;size of TASKDATA and WDATA = 32 bytes
cmp byte [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE cmp byte [SLOT_BASE + edi*8 + APPDATA.state], TSTATE_FREE
je .skip_window je .skip_window
add edi, window_data add edi, window_data

View File

@ -630,7 +630,6 @@ high_code:
mov dword [current_slot_idx], 2 mov dword [current_slot_idx], 2
mov [thread_count], 2 mov [thread_count], 2
mov dword [current_slot], SLOT_BASE + sizeof.APPDATA*2 mov dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
mov dword [TASK_BASE], TASK_TABLE + sizeof.TASKDATA*2
; Move other CPUs to deep sleep, if it is useful ; Move other CPUs to deep sleep, if it is useful
uglobal uglobal
@ -1932,8 +1931,6 @@ sys_end:
mov eax, [current_slot] mov eax, [current_slot]
mov [eax+APPDATA.state], TSTATE_ZOMBIE mov [eax+APPDATA.state], TSTATE_ZOMBIE
mov eax, [TASK_BASE] ;
mov [eax+TASKDATA.state], TSTATE_ZOMBIE ; delete
call wakeup_osloop call wakeup_osloop
.waitterm: ; wait here for termination .waitterm: ; wait here for termination
@ -1953,7 +1950,7 @@ restore_default_cursor_before_killing:
add eax, [_display.win_map] add eax, [_display.win_map]
movzx edx, byte [ebx+eax] movzx edx, byte [ebx+eax]
shl edx, 8 shl edx, BSF sizeof.APPDATA
mov esi, [edx+SLOT_BASE+APPDATA.cursor] mov esi, [edx+SLOT_BASE+APPDATA.cursor]
cmp esi, [current_cursor] cmp esi, [current_cursor]
@ -2043,18 +2040,18 @@ sysfn_terminate: ; 18.2 = TERMINATE
cmp ecx, edx cmp ecx, edx
ja noprocessterminate ja noprocessterminate
mov eax, [thread_count] mov eax, [thread_count]
shl ecx, BSF sizeof.TASKDATA shl ecx, BSF sizeof.APPDATA
mov edx, [ecx*8 + SLOT_BASE + APPDATA.tid] add ecx, SLOT_BASE
add ecx, TASK_TABLE+TASKDATA.state mov edx, [ecx + APPDATA.tid]
cmp byte [ecx], TSTATE_FREE cmp byte [ecx + APPDATA.state], TSTATE_FREE
jz noprocessterminate jz noprocessterminate
push eax push eax
lea eax, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] mov eax, ecx
call is_kernel_thread call is_kernel_thread
pop eax pop eax
jz noprocessterminate jz noprocessterminate
push ecx edx push ecx edx
lea edx, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] mov edx, ecx
call request_terminate call request_terminate
pop edx ecx pop edx ecx
test eax, eax test eax, eax
@ -2062,7 +2059,7 @@ sysfn_terminate: ; 18.2 = TERMINATE
;-------------------------------------- ;--------------------------------------
; terminate all network sockets it used ; terminate all network sockets it used
pusha pusha
mov eax, edx mov eax, edx ;TODO: check function
call socket_process_end call socket_process_end
popa popa
;-------------------------------------- ;--------------------------------------
@ -2082,7 +2079,7 @@ sysfn_terminate: ; 18.2 = TERMINATE
.restore_end: .restore_end:
;-------------------------------------- ;--------------------------------------
;call MEM_Heap_Lock ;guarantee that process isn't working with heap ;call MEM_Heap_Lock ;guarantee that process isn't working with heap
mov [ecx], byte 3; clear possible i40's mov [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's
call wakeup_osloop call wakeup_osloop
;call MEM_Heap_UnLock ;call MEM_Heap_UnLock
@ -2189,13 +2186,10 @@ sysfn_zmodif:
mov eax, edx mov eax, edx
shl edx, 5 shl edx, 5
;shl edx, 8
;cmp [edx + SLOT_BASE + APPDATA.state], TSTATE_FREE cmp [edx*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE
cmp [edx + TASK_TABLE + TASKDATA.state], TSTATE_FREE
je .fail je .fail
;shr edx, 3
cmp ecx, 1 cmp ecx, 1
jnz .set_zmod jnz .set_zmod
@ -2665,7 +2659,6 @@ sys_cpuusage:
; Process state (+50) ; Process state (+50)
movzx eax, byte [ecx*8 + SLOT_BASE + APPDATA.state] movzx eax, byte [ecx*8 + SLOT_BASE + APPDATA.state]
movzx eax, byte [ecx+TASK_TABLE+TASKDATA.state]
stosd stosd
; Window client area box ; Window client area box
@ -2745,8 +2738,9 @@ sys_redrawstat:
cmp ebx, 2 cmp ebx, 2
jnz srl1 jnz srl1
mov edx, [TASK_BASE] ; return whole screen draw area for this app mov edx, [current_slot_idx] ; return whole screen draw area for this app
add edx, draw_data - TASK_TABLE shl edx, 5
add edx, draw_data
mov [edx + RECT.left], 0 mov [edx + RECT.left], 0
mov [edx + RECT.top], 0 mov [edx + RECT.top], 0
mov eax, [_display.width] mov eax, [_display.width]
@ -2909,7 +2903,7 @@ nocpustart:
mov [mouse_active], 0 mov [mouse_active], 0
xor edi, edi xor edi, edi
mov ebx, TASK_TABLE mov ebx, window_data
mov ecx, [thread_count] mov ecx, [thread_count]
movzx eax, word [WIN_POS + ecx*2] ; active window movzx eax, word [WIN_POS + ecx*2] ; active window
@ -2922,7 +2916,7 @@ nocpustart:
align 4 align 4
.set_mouse_event: .set_mouse_event:
add edi, sizeof.APPDATA add edi, sizeof.APPDATA
add ebx, sizeof.TASKDATA add ebx, sizeof.WDATA
test [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000 test [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000
jz .pos_filter jz .pos_filter
@ -2934,17 +2928,17 @@ align 4
test [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000 test [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000
jz .set jz .set
mov esi, [ebx-twdw+WDATA.box.left] mov esi, [ebx + WDATA.box.left]
cmp eax, esi cmp eax, esi
jb .skip jb .skip
add esi, [ebx-twdw+WDATA.box.width] add esi, [ebx + WDATA.box.width]
cmp eax, esi cmp eax, esi
ja .skip ja .skip
mov esi, [ebx-twdw+WDATA.box.top] mov esi, [ebx + WDATA.box.top]
cmp edx, esi cmp edx, esi
jb .skip jb .skip
add esi, [ebx-twdw+WDATA.box.height] add esi, [ebx + WDATA.box.height]
cmp edx, esi cmp edx, esi
ja .skip ja .skip
;-------------------------------------- ;--------------------------------------
@ -3043,15 +3037,14 @@ nobackgr:
jne noshutdown jne noshutdown
lea ecx, [edx-1] lea ecx, [edx-1]
mov edx, OS_BASE+0x3040 mov edx, SLOT_BASE + sizeof.APPDATA ;OS_BASE+0x3040
jecxz no_mark_system_shutdown jecxz no_mark_system_shutdown
;-------------------------------------- ;--------------------------------------
align 4 align 4
markz: markz:
push ecx edx push ecx edx
cmp [edx+TASKDATA.state], TSTATE_FREE cmp [edx + APPDATA.state], TSTATE_FREE
jz .nokill jz .nokill
lea edx, [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
cmp [edx+APPDATA.process], sys_proc cmp [edx+APPDATA.process], sys_proc
jz .nokill jz .nokill
call request_terminate call request_terminate
@ -3063,10 +3056,9 @@ markz:
pop edx ecx pop edx ecx
test eax, eax test eax, eax
jz @f jz @f
mov [edx+TASKDATA.state], TSTATE_ZOMBIE mov [edx + APPDATA.state], TSTATE_ZOMBIE
;mov [edx+APPDATA.state], TSTATE_ZOMBIE
@@: @@:
add edx, 0x20 add edx, sizeof.APPDATA
loop markz loop markz
call wakeup_osloop call wakeup_osloop
;-------------------------------------- ;--------------------------------------
@ -3079,7 +3071,7 @@ no_mark_system_shutdown:
align 4 align 4
noshutdown: noshutdown:
mov eax, [thread_count] ; termination mov eax, [thread_count] ; termination
mov ebx, TASK_DATA+TASKDATA.state mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state
mov esi, 1 mov esi, 1
;-------------------------------------- ;--------------------------------------
align 4 align 4
@ -3107,7 +3099,7 @@ newct:
je system_shutdown je system_shutdown
.noterminate: .noterminate:
add ebx, 0x20 add ebx, sizeof.APPDATA
inc esi inc esi
dec eax dec eax
jnz newct jnz newct

View File

@ -1860,9 +1860,8 @@ socket_block:
; Suspend the thread ; Suspend the thread
push edx push edx
mov edx, [TASK_BASE]
mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED
mov edx, [current_slot] mov edx, [current_slot]
mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
; Remember the thread ID so we can wake it up again ; Remember the thread ID so we can wake it up again
mov edx, [edx + APPDATA.tid] mov edx, [edx + APPDATA.tid]
@ -1903,14 +1902,11 @@ socket_notify:
jz .error2 jz .error2
xor ecx, ecx xor ecx, ecx
inc ecx inc ecx
;mov esi, TASK_DATA
mov esi, SLOT_BASE + sizeof.APPDATA mov esi, SLOT_BASE + sizeof.APPDATA
.next: .next:
;cmp [esi + TASKDATA.pid], ebx
cmp [esi + APPDATA.tid], ebx cmp [esi + APPDATA.tid], ebx
je .found je .found
inc ecx inc ecx
;add esi, sizeof.TASKDATA
add esi, sizeof.APPDATA add esi, sizeof.APPDATA
cmp ecx, [thread_count] cmp ecx, [thread_count]
jbe .next jbe .next
@ -1943,8 +1939,8 @@ socket_notify:
; Socket and thread exists and socket is of blocking type ; Socket and thread exists and socket is of blocking type
; We'll try to unblock it. ; We'll try to unblock it.
and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag
shl ecx, BSF sizeof.TASKDATA shl ecx, BSF sizeof.APPDATA
mov [ecx + TASK_TABLE + TASKDATA.state], TSTATE_RUNNING ; Run the thread mov [SLOT_BASE + ecx + APPDATA.state], TSTATE_RUNNING ; Run the thread
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
pop esi ecx ebx pop esi ecx ebx

View File

@ -126,14 +126,14 @@ align 4
cli cli
sub esp, sizeof.MUTEX_WAITER sub esp, sizeof.MUTEX_WAITER
mov ebx, [TASK_BASE] mov ebx, [current_slot]
mov [esp+MUTEX_WAITER.task], ebx mov [esp+MUTEX_WAITER.task], ebx
lea esi, [ebp+FUTEX.wait_list] lea esi, [ebp+FUTEX.wait_list]
list_add_tail esp, esi ;esp= new waiter, esi= list head list_add_tail esp, esi ;esp= new waiter, esi= list head
mov eax, edx mov eax, edx
.again: .again:
mov [ebx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
lock cmpxchg [ecx], edx lock cmpxchg [ecx], edx
@ -179,10 +179,9 @@ align 4
mov [ebx+APPDATA.wait_param], ebp mov [ebx+APPDATA.wait_param], ebp
mov eax, [timer_ticks] mov eax, [timer_ticks]
mov [ebx+APPDATA.wait_begin], eax mov [ebx+APPDATA.wait_begin], eax
mov eax, [TASK_BASE] mov [ebx + APPDATA.state], TSTATE_WAITING
mov [eax+TASKDATA.state], TSTATE_WAITING
mov [esp+MUTEX_WAITER.task], eax mov [esp+MUTEX_WAITER.task], ebx
lea esi, [ebp+FUTEX.wait_list] lea esi, [ebp+FUTEX.wait_list]
list_add_tail esp, esi ;esp= new waiter, esi= list head list_add_tail esp, esi ;esp= new waiter, esi= list head
@ -232,7 +231,7 @@ align 4
je .done je .done
mov eax, [esi+MUTEX_WAITER.task] mov eax, [esi+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING mov [eax + APPDATA.state], TSTATE_RUNNING
mov esi, [esi+MUTEX_WAITER.list.next] mov esi, [esi+MUTEX_WAITER.list.next]
inc ecx inc ecx

View File

@ -181,7 +181,7 @@ pipe_read:
je @F je @F
mov ecx, [ecx+MUTEX_WAITER.task] mov ecx, [ecx+MUTEX_WAITER.task]
mov [ecx+TASKDATA.state], TSTATE_RUNNING ;activate writer task mov [ecx + APPDATA.state], TSTATE_RUNNING ;activate writer task
@@: @@:
cmp [ebp+PIPE.count], 0 cmp [ebp+PIPE.count], 0
je @F je @F
@ -191,7 +191,7 @@ pipe_read:
je @F je @F
mov eax, [eax+MUTEX_WAITER.task] mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING ;activate reader task mov [eax + APPDATA.state], TSTATE_RUNNING ;activate reader task
@@: @@:
lea ecx, [ebp+PIPE.pipe_lock] lea ecx, [ebp+PIPE.pipe_lock]
call mutex_unlock call mutex_unlock
@ -202,7 +202,7 @@ pipe_read:
cli cli
sub esp, sizeof.MUTEX_WAITER sub esp, sizeof.MUTEX_WAITER
mov ebx, [TASK_BASE] mov ebx, [current_slot]
mov [esp+MUTEX_WAITER.task], ebx mov [esp+MUTEX_WAITER.task], ebx
lea edx, [ebp+PIPE.rlist] lea edx, [ebp+PIPE.rlist]
@ -211,7 +211,7 @@ pipe_read:
lea ecx, [ebp+PIPE.pipe_lock] lea ecx, [ebp+PIPE.pipe_lock]
call mutex_unlock call mutex_unlock
mov [ebx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
lea ecx, [ebp+PIPE.pipe_lock] lea ecx, [ebp+PIPE.pipe_lock]
@ -276,7 +276,7 @@ pipe_write:
je @F je @F
mov eax, [eax+MUTEX_WAITER.task] mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING ;activate reader task mov [eax + APPDATA.state], TSTATE_RUNNING ;activate reader task
@@: @@:
cmp [ebp+PIPE.count], 4096 cmp [ebp+PIPE.count], 4096
je @F je @F
@ -286,7 +286,7 @@ pipe_write:
je @F je @F
mov ecx, [eax+MUTEX_WAITER.task] mov ecx, [eax+MUTEX_WAITER.task]
mov [ecx+TASKDATA.state], TSTATE_RUNNING ;activate writer task mov [ecx + APPDATA.state], TSTATE_RUNNING ;activate writer task
@@: @@:
popfd popfd
@ -305,7 +305,7 @@ pipe_write:
cli cli
sub esp, sizeof.MUTEX_WAITER sub esp, sizeof.MUTEX_WAITER
mov ecx, [TASK_BASE] mov ecx, [current_slot]
mov [esp+MUTEX_WAITER.task], ecx mov [esp+MUTEX_WAITER.task], ecx
lea edx, [ebp+PIPE.wlist] lea edx, [ebp+PIPE.wlist]
@ -314,7 +314,7 @@ pipe_write:
lea ecx, [ebp+PIPE.pipe_lock] lea ecx, [ebp+PIPE.pipe_lock]
call mutex_unlock call mutex_unlock
mov [ecx+TASKDATA.state], TSTATE_RUN_SUSPENDED mov [ecx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task call change_task
lea ecx, [ebp+PIPE.pipe_lock] lea ecx, [ebp+PIPE.pipe_lock]

View File

@ -398,9 +398,6 @@ vesa12_drawbar:
push ebx push ebx
push ecx push ecx
push edx push edx
;mov ecx, [TASK_BASE]
;add eax, [ecx-twdw+WDATA.box.left]
;add ebx, [ecx-twdw+WDATA.box.top]
mov ecx, [current_slot_idx] mov ecx, [current_slot_idx]
shl ecx, 5 shl ecx, 5
add eax, [ecx + window_data + WDATA.box.left] add eax, [ecx + window_data + WDATA.box.left]
@ -769,9 +766,6 @@ vesa12_putimage:
push edx push edx
movzx eax, word [esp+2] movzx eax, word [esp+2]
movzx ebx, word [esp+0] movzx ebx, word [esp+0]
;mov ecx, [TASK_BASE]
;add eax, [ecx-twdw+WDATA.box.left]
;add ebx, [ecx-twdw+WDATA.box.top]
mov ecx, [current_slot_idx] mov ecx, [current_slot_idx]
shl ecx, 5 shl ecx, 5
add eax, [ecx + window_data + WDATA.box.left] add eax, [ecx + window_data + WDATA.box.left]

View File

@ -495,9 +495,6 @@ VGA_draw_bar:
align 4 align 4
VGA_draw_bar_1: VGA_draw_bar_1:
mov [temp.cx], eax mov [temp.cx], eax
;mov eax, [TASK_BASE]
;add ebx, [eax-twdw + 4]
;mov eax, [eax-twdw + 0]
mov eax, [current_slot_idx] mov eax, [current_slot_idx]
shl eax, 5 shl eax, 5
add ebx, [eax+window_data+WDATA.box.top] add ebx, [eax+window_data+WDATA.box.top]