Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9708 → Rev 9709

/kernel/trunk/const.inc
224,11 → 224,11
 
window_data = OS_BASE + 0x0001000
 
TASK_TABLE = OS_BASE + 0x0003000
;TASK_TABLE = OS_BASE + 0x0003000
;CURRENT_TASK = OS_BASE + 0x0003000
;TASK_COUNT = OS_BASE + 0x0003004
TASK_BASE = OS_BASE + 0x0003010
TASK_DATA = OS_BASE + 0x0003020
;TASK_BASE = OS_BASE + 0x0003010
;TASK_DATA = OS_BASE + 0x0003020
;TASK_EVENT = OS_BASE + 0x0003020
 
CDDataBuf = OS_BASE + 0x0005000
281,7 → 281,7
 
new_app_base = 0;
 
twdw = TASK_TABLE - window_data
;twdw = TASK_TABLE - window_data
 
std_application_base_address = new_app_base
RING0_STACK_SIZE = 0x2000
511,16 → 511,16
wait_test dd ? ;+96 +++
wait_param dd ? ;+100 +++
tls_base dd ? ;+104
event_mask dd ? ;+108 ; R stores event types allowed for task
tid dd ? ;+112 ; R thread id
event_mask dd ? ;+108 stores event types allowed for task
tid dd ? ;+112 thread id
draw_bgr_x dd ? ;+116
draw_bgr_y dd ? ;+120
state db ? ;+124 ; R thread state
wnd_number db ? ;+125 ; R
state db ? ;+124 thread state
wnd_number db ? ;+125
dw ? ;+126
wnd_shape dd ? ;+128
wnd_shape_scale dd ? ;+132
mem_start dd ? ;+136 ; R
mem_start dd ? ;+136
counter_sum dd ? ;+140 ; R
saved_box BOX ;+144
ipc_start dd ? ;+160
549,20 → 549,20
APP_EV_OFFSET = 40
 
; Note: in future TASKDATA will be merged into APPDATA
struct TASKDATA
event_mask dd ? ;+0 mask which stores event types allowed for task
pid dd ? ;+4
dw ? ;+8
state db ? ;+10
db ? ;+11
dw ? ;+12
wnd_number db ? ;+14
db ? ;+15
mem_start dd ? ;+16
counter_sum dd ? ;+20
counter_add dd ? ;+24
cpu_usage dd ? ;+28
ends
;struct TASKDATA
; event_mask dd ? ;+0 mask which stores event types allowed for task
; pid dd ? ;+4
; dw ? ;+8
; state db ? ;+10
; db ? ;+11
; dw ? ;+12
; wnd_number db ? ;+14
; db ? ;+15
; mem_start dd ? ;+16
; counter_sum dd ? ;+20
; counter_add dd ? ;+24
; cpu_usage dd ? ;+28
;ends
 
; Thread states:
TSTATE_RUNNING = 0
/kernel/trunk/core/debug.inc
46,10 → 46,10
call pid_to_slot
test eax, eax
jz .ret_bad
shl eax, 5
shl eax, BSF sizeof.APPDATA
push ebx
mov ebx, [current_slot_idx]
cmp [SLOT_BASE+eax*8+APPDATA.debugger_slot], ebx
cmp [SLOT_BASE+eax+APPDATA.debugger_slot], ebx
pop ebx
jnz .ret_bad
; clc ; automatically
63,7 → 63,7
; destroys eax,ebx
call get_debuggee_slot
jc .ret
and dword [eax*8+SLOT_BASE+APPDATA.debugger_slot], 0
and dword [eax+SLOT_BASE+APPDATA.debugger_slot], 0
call do_resume
.ret:
sti
74,7 → 74,7
call get_debuggee_slot
jc debug_detach.ret
mov ecx, eax
shr ecx, 5
shr ecx, BSF sizeof.APPDATA
; push 2
; pop ebx
mov edx, esi
92,7 → 92,7
call get_debuggee_slot
jc .ret
; } End patch
mov cl, [TASK_TABLE+eax+TASKDATA.state] ; process state
mov cl, [SLOT_BASE + eax + APPDATA.state] ; process state
test cl, cl
jz .1
cmp cl, 5
99,7 → 99,7
jnz .ret
mov cl, 2
.2:
mov [TASK_TABLE+eax+TASKDATA.state], cl
mov [SLOT_BASE + eax + APPDATA.state], cl
.ret:
sti
ret
108,7 → 108,7
jmp .2
 
do_resume:
mov cl, [TASK_TABLE+eax+TASKDATA.state]
mov cl, [SLOT_BASE + eax + APPDATA.state]
cmp cl, 1
jz .1
cmp cl, 2
115,7 → 115,7
jnz .ret
mov cl, 5
.2:
mov [TASK_TABLE+eax+TASKDATA.state], cl
mov [SLOT_BASE + eax + APPDATA.state], cl
.ret:
ret
.1:
128,7 → 128,7
cli
mov eax, ecx
call pid_to_slot
shl eax, 5
shl eax, BSF sizeof.APPDATA
jz .ret
call do_resume
.ret:
155,12 → 155,12
call get_debuggee_slot
jc .ret
 
shr eax, 5
shr eax, 8
cmp eax, [fpu_owner]
jne @f
inc bh ; set swap context flag
@@:
shl eax, 8
shl eax, BSF sizeof.APPDATA
mov edi, esi
mov eax, [eax+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE]
231,7 → 231,7
call get_debuggee_slot
jc .stiret
; 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]
 
.ring0:
267,7 → 267,7
call get_debuggee_slot
jc .errret
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+10]=dr7
cmp esi, OS_BASE
294,7 → 294,7
jnz .okret
; imul eax, ebp, tss_step/32
; 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:
and dword [esp+32], 0
sti
341,7 → 341,7
or [eax+10h+2], dx ; set R/W and LEN fields
; imul eax, ebp, tss_step/32
; 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
 
debug_read_process_memory:
354,7 → 354,7
; destroys all
call get_debuggee_slot
jc .err
shr eax, 5
shr eax, 8
mov ecx, edi
call read_process_memory
sti
374,7 → 374,7
; destroys all
call get_debuggee_slot
jc debug_read_process_memory.err
shr eax, 5
shr eax, 8
mov ecx, edi
call write_process_memory
sti
/kernel/trunk/core/sched.inc
280,7 → 280,6
test bl, bl
jz .start
mov ebx, [current_slot]
mov edi, [TASK_BASE]
mov eax, [ebx+APPDATA.priority]
test eax, eax
jz .unlock_found
293,11 → 292,7
jz .priority_next
.task_loop:
mov ebx, [ebx+APPDATA.in_schedule.next]
;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] ;
mov al, [ebx+APPDATA.state]
test al, al
jz .task_found ; state == 0
cmp al, 5
317,7 → 312,6
xor eax, eax
@@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], TSTATE_RUNNING ; on delete
mov [ebx+APPDATA.state], TSTATE_RUNNING
.task_found:
mov [scheduler_current+ecx*4], ebx
338,7 → 332,7
; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is
; aligned on 0x10000
mov byte [current_slot_idx], bh
mov [TASK_BASE], edi
 
rdtsc ;call _rdtsc
mov [ebx-sizeof.APPDATA+APPDATA.counter_add], eax; for next using update_counters
;mov [edi+TASKDATA.counter_add], eax; for next using update_counters
352,7 → 346,6
cmp ecx, [esp]
jb .priority_loop
mov ebx, [current_slot]
mov edi, [TASK_BASE]
jmp .unlock_found
endp
 
/kernel/trunk/core/sync.inc
38,7 → 38,7
 
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
 
.forever:
48,7 → 48,7
dec eax
jz @F
 
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
jmp .forever
@@:
80,7 → 80,7
je @F
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING
mov [eax + APPDATA.state], TSTATE_RUNNING
@@:
popfd
ret
111,10 → 111,10
@@:
sub esp, sizeof.MUTEX_WAITER
 
mov eax, [TASK_BASE]
mov eax, [current_slot]
mov [esp+MUTEX_WAITER.task], eax
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
 
138,10 → 138,10
cli
sub esp, sizeof.MUTEX_WAITER
 
mov edx, [TASK_BASE]
mov edx, [current_slot]
mov [esp+MUTEX_WAITER.task], edx
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
 
152,7 → 152,7
test eax, [ecx+RWSEM.count]
jz @F
 
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
jmp .forever
@@:
178,7 → 178,7
je @F
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING
mov [eax + APPDATA.state], TSTATE_RUNNING
@@:
popfd
ret
202,7 → 202,7
jnz .wake
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], TSTATE_RUNNING
mov [eax + APPDATA.state], TSTATE_RUNNING
.done:
popfd
ret
220,7 → 220,7
mov ebx, [eax+MUTEX_WAITER.list.next]
list_del eax
mov edx, [eax+MUTEX_WAITER.task]
mov [edx+TASKDATA.state], TSTATE_RUNNING
mov [edx + APPDATA.state], TSTATE_RUNNING
inc esi
cmp edi, ebx
je .wake_done
/kernel/trunk/core/sys32.inc
150,9 → 150,9
test eax, eax
jnz .debug
; not debuggee => say error and terminate
call show_error_parameters
call show_error_parameters ; this function output in edx = current_slot
sti
mov [edx + TASKDATA.state], TSTATE_TERMINATING
mov [edx + APPDATA.state], TSTATE_TERMINATING
call wakeup_osloop
call change_task
; If we're here, then the main OS thread has crashed before initializing IDLE thread.
186,8 → 186,8
mov cl, 12 ; debug_message size
call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc
add esp, 12
mov edx, [TASK_BASE]
mov [edx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov edx, [current_slot]
mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task ; SEE: core/shed.inc
restore_ring3_context
iretd
288,6 → 288,27
test eax, eax
jnz .error_ESP
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
ret
.error_ESP:
412,13 → 433,12
 
push esi ;save .slot
 
shl esi, 8
shl esi, BSF sizeof.APPDATA
mov edx, [SLOT_BASE+esi+APPDATA.process]
test edx, edx
jnz @F
mov [SLOT_BASE + esi + APPDATA.state], TSTATE_FREE
pop esi
shl esi, BSF sizeof.TASKDATA
mov [TASK_TABLE+esi+TASKDATA.state], TSTATE_FREE
ret
@@:
push edx ;save .process
428,7 → 448,7
 
; if the process is in V86 mode...
mov eax, [.slot]
shl eax, 8
shl eax, BSF sizeof.APPDATA
mov esi, [eax+SLOT_BASE+APPDATA.pl0_stack]
add esi, RING0_STACK_SIZE
cmp [eax+SLOT_BASE+APPDATA.saved_esp0], esi
445,7 → 465,7
.nov86:
; destroy per-thread kernel objects
mov esi, [.slot]
shl esi, 8
shl esi, BSF sizeof.APPDATA
add esi, SLOT_BASE+APP_OBJ_OFFSET
@@:
mov eax, [esi+APPOBJ.fd]
591,7 → 611,7
popad
 
mov ebx, [.slot]
shl ebx, 8
shl ebx, BSF sizeof.APPDATA
push ebx
mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack]
 
602,7 → 622,7
stdcall kernel_free, ebx
 
mov edi, [.slot]
shl edi, 8
shl edi, BSF sizeof.APPDATA
add edi, SLOT_BASE
 
mov eax, [edi+APPDATA.io_map]
637,9 → 657,10
jbe .nothing_to_activate
lea esi, [WIN_POS+eax*2]
movzx edi, word [esi] ; edi = process
shl edi, BSF sizeof.TASKDATA
cmp [TASK_TABLE + edi + TASKDATA.state], TSTATE_FREE ; skip free slots
shl edi, BSF sizeof.APPDATA
cmp [SLOT_BASE + edi + APPDATA.state], TSTATE_FREE ; skip free slots
je .check_next_window
shr edi, 3
add edi, window_data
; \begin{diamond}[19.09.2006]
; skip minimized windows
711,8 → 732,8
 
popa
mov edi, esi ; do not run this process slot
shl edi, BSF sizeof.TASKDATA
mov [edi+TASK_TABLE + TASKDATA.state], TSTATE_FREE
shl edi, BSF sizeof.APPDATA
mov [edi + SLOT_BASE + APPDATA.state], TSTATE_FREE
; debugger test - terminate all debuggees
mov eax, 2
mov ecx, SLOT_BASE+2*sizeof.APPDATA + APPDATA.debugger_slot
/kernel/trunk/core/taskman.inc
487,26 → 487,22
push ebx
push ecx
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:
; [TASK_TABLE; TASK_TABLE + 32) isnt a task actually
; skip first process in the task table
mov ecx, 2*32 ;sizeof.TASKDATA
;mov ecx, sizeof.APPDATA
;mov ecx, 2*32 ;sizeof.TASKDATA
mov ecx, sizeof.APPDATA
 
.loop:
;ecx = offset of current process info entry
;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
;cmp [ecx+SLOT_BASE+APPDATA.state], TSTATE_FREE
;jz .endloop ;skip empty slots
cmp [ecx*8 + SLOT_BASE + APPDATA.tid], eax;check PID
cmp [ecx + SLOT_BASE + APPDATA.tid], eax;check PID
jz .pid_found
.endloop:
add ecx, sizeof.TASKDATA
;add ecx, sizeof.APPDATA
add ecx, sizeof.APPDATA
cmp ecx, ebx
jle .loop
 
516,8 → 512,7
ret
 
.pid_found:
shr ecx, BSF sizeof.TASKDATA ; divide by size
;shr ecx, BSF sizeof.APPDATA
shr ecx, BSF sizeof.APPDATA ; divide by size
mov eax, ecx ;convert offset to index of slot
pop ecx
pop ebx
903,8 → 898,7
cmp [ebx+APPDATA.debugger_slot], 0
je .exit
mov [ebx+APPDATA.state], TSTATE_RUN_SUSPENDED
mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
.exit:
popad
932,7 → 926,7
mov eax, [slot]
mov ebx, eax
 
shl eax, 8
shl eax, BSF sizeof.APPDATA
mov [eax+SLOT_BASE+APPDATA.fpu_state], edi
mov [eax+SLOT_BASE+APPDATA.exc_handler], 0
mov [eax+SLOT_BASE+APPDATA.except_mask], 0
952,7 → 946,7
 
cmp [thread_count], ebx
adc [thread_count], 0 ; update number of processes
shl ebx, 8
shl ebx, BSF sizeof.APPDATA
lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET]
mov [SLOT_BASE+APPDATA.fd_ev+ebx], edx
mov [SLOT_BASE+APPDATA.bk_ev+ebx], edx
987,7 → 981,7
mov eax, [slot]
mov [ebx+SLOT_BASE+APPDATA.wnd_number], al
mov ebx, eax
shl ebx, 5
shl ebx, BSF sizeof.WDATA
lea ecx, [draw_data+ebx];ecx - pointer to draw data
 
; set window state to 'normal' (non-minimized/maximized/rolled-up) state
1037,8 → 1031,8
 
lea edx, [ebx+REG_RET]
mov ebx, [slot]
shl ebx, 5
mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], edx
shl ebx, BSF sizeof.APPDATA
mov [ebx+SLOT_BASE+APPDATA.saved_esp], edx
 
xor edx, edx; process state - running
; set if debuggee
1045,12 → 1039,10
test byte [flags], 1
jz .no_debug
mov eax, [current_slot_idx]
mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot], eax
mov [SLOT_BASE+ebx+APPDATA.debugger_slot], eax
.no_debug:
mov [TASK_TABLE+ebx+TASKDATA.state], dl
;shl ebx, 3
;mov [ebx+SLOT_BASE+APPDATA.state], dl
lea edx, [SLOT_BASE+ebx*8]
mov [SLOT_BASE + ebx + APPDATA.state], dl
lea edx, [SLOT_BASE+ebx]
call scheduler_add_thread
ret
endp
/kernel/trunk/core/v86.inc
898,9 → 898,6
mov word [esi-sizeof.v86_regs+v86_regs.cs], cx
and byte [esi-sizeof.v86_regs+v86_regs.eflags+1], not 3
call update_counters
lea edi, [ebx + 0x100000000 - SLOT_BASE]
shr edi, 3
add edi, TASK_TABLE
call find_next_task.found
call do_change_task
popad
/kernel/trunk/gui/button.inc
136,9 → 136,10
dec ebp
shr ebx, 16
shr ecx, 16
mov eax, [TASK_BASE]
add ebx, [eax - twdw + WDATA.box.left]
add ecx, [eax - twdw + WDATA.box.top]
mov eax, [current_slot_idx]
shl eax, BSF sizeof.WDATA
add ebx, [eax + window_data + WDATA.box.left]
add ecx, [eax + window_data + WDATA.box.top]
mov eax, ebx
inc eax
mov edx, ebx
/kernel/trunk/gui/event.inc
281,8 → 281,6
mov eax, [timer_ticks]
mov [esi+APPDATA.wait_begin], eax
mov [esi+APPDATA.state], TSTATE_WAITING
mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], TSTATE_WAITING
call change_task
mov eax, [esi+APPDATA.wait_param]
;--------------------------------------
513,7 → 511,7
movzx edi, bh ; bh is assumed as [current_slot_idx]
mov ecx, [ebx+APPDATA.event_mask]
shl edi, 5
add edi, TASK_TABLE ; edi is assumed as [TASK_BASE]
add edi, window_data
and ecx, 0x7FFFFFFF
;--------------------------------------
align 4
541,7 → 539,7
;--------------------------------------
align 4
.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
jmp .loop
;--------------------------------------
/kernel/trunk/gui/mouse.inc
726,10 → 726,11
mov eax, [MOUSE_X]
shl eax, 16
mov ax, [MOUSE_Y]
mov esi, [TASK_BASE]
mov bx, word [esi-twdw+WDATA.box.left]
mov esi, [current_slot_idx]
shl esi, BSF sizeof.WDATA
mov bx, word [esi + window_data + WDATA.box.left]
shl ebx, 16
mov bx, word [esi-twdw+WDATA.box.top]
mov bx, word [esi + window_data + WDATA.box.top]
sub eax, ebx
mov edi, [current_slot_idx]
shl edi, 8
/kernel/trunk/gui/window.inc
78,9 → 78,10
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, [TASK_BASE]
add eax, [edx-twdw+WDATA.box.left]
add ebx, [edx-twdw+WDATA.box.top]
mov edx, [current_slot_idx]
shl edx, BSF sizeof.WDATA
add eax, [edx + window_data + WDATA.box.left]
add ebx, [edx + window_data + WDATA.box.top]
mov edi, [current_slot]
add eax, [edi+APPDATA.wnd_clientbox.left]
add ebx, [edi+APPDATA.wnd_clientbox.top]
103,13 → 104,14
pop esi
jnz .err
 
mov eax, [TASK_BASE]
mov ebp, [eax-twdw+WDATA.box.left]
mov eax, [current_slot_idx]
shl eax, BSF sizeof.WDATA
mov ebp, [eax + window_data + WDATA.box.left]
push esi
mov esi, [current_slot]
add ebp, [esi+APPDATA.wnd_clientbox.left]
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]
pop esi
test ecx, 0x08000000 ; redirect the output to the user area
163,8 → 165,9
align 4
; system function 38
syscall_drawline:
mov edi, [TASK_BASE]
movzx eax, word[edi-twdw+WDATA.box.left]
mov edi, [current_slot_idx]
shl edi, BSF sizeof.WDATA
movzx eax, word[edi + window_data + WDATA.box.left]
mov ebp, eax
mov esi, [current_slot]
add ebp, [esi+APPDATA.wnd_clientbox.left]
171,7 → 174,7
add ax, word[esi+APPDATA.wnd_clientbox.left]
add ebp, ebx
shl eax, 16
movzx ebx, word[edi-twdw+WDATA.box.top]
movzx ebx, word[edi + window_data + WDATA.box.top]
add eax, ebp
mov ebp, ebx
add ebp, [esi+APPDATA.wnd_clientbox.top]
429,7 → 432,7
; system function 67
syscall_move_window:
mov edi, [current_slot_idx]
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
 
test [edi + WDATA.fl_wdrawn], 1
485,7 → 488,7
; system function 71
syscall_window_settings:
mov edi, [current_slot_idx]
shl edi, 5
shl edi, BSF sizeof.WDATA
or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
cmp ebx, 2
jz @f
556,9 → 559,9
align 4
.next_window:
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
 
add edi, window_data
625,7 → 628,7
;---------------------------------------------
mov esi, [thread_count]
movzx edi, word[WIN_POS + esi * 2]
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
 
pop eax ebx ecx edx
1033,7 → 1036,7
pushad
mov edi, [thread_count]
movzx esi, word[WIN_POS + edi * 2]
shl esi, 5
shl esi, BSF sizeof.WDATA
add esi, window_data
 
mov eax, [esi + WDATA.box.left]
1085,9 → 1088,9
align 4
.loop:
movzx edi, word[WIN_POS + eax * 2]
shl edi, 5
shl edi, BSF sizeof.WDATA
; 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
; it is a hidden thread?
lea esi, [edi*8+SLOT_BASE+APPDATA.app_name]
1133,7 → 1136,7
 
; is it already minimized?
movzx edi, word[WIN_POS + eax * 2]
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .exit
1194,7 → 1197,7
; is it already restored?
movzx esi, word[WIN_POS + eax * 2]
mov edi, esi
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jz .exit
1262,7 → 1265,7
;> esi = process slot
sys_window_maximize_handler:
mov edi, esi
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
 
; can window change its height?
1293,7 → 1296,7
align 4
.restore_size:
mov eax, esi
shl eax, 8
shl eax, BSF sizeof.APPDATA
add eax, SLOT_BASE + APPDATA.saved_box
push [eax + BOX.height] \
[eax + BOX.width] \
1327,7 → 1330,7
;> esi = process slot
sys_window_rollup_handler:
mov edx, esi
shl edx, 8
shl edx, BSF sizeof.APPDATA
add edx, SLOT_BASE
 
; toggle normal/rolled up window state
1394,7 → 1397,7
; call window._.end_moving__box
 
mov edi, esi
shl edi, 5
shl edi, BSF sizeof.WDATA
add edi, window_data
 
test [fl_moving], 1
1630,7 → 1633,7
;< edx = pointer to WDATA struct
window._.sys_set_window:
mov eax, [current_slot_idx]
shl eax, 5
shl eax, BSF sizeof.WDATA
add eax, window_data
; save window colors
mov [eax + WDATA.cl_workarea], edx
1866,7 → 1869,7
cmp esi, 1
jz .check_for_shaped_window
mov edi, esi
shl edi, 5
shl edi, BSF sizeof.WDATA
cmp [window_data + edi + WDATA.box.width], 0
jnz .check_for_shaped_window
cmp [window_data + edi + WDATA.box.height], 0
1875,7 → 1878,7
align 4
.check_for_shaped_window:
mov edi, esi
shl edi, 8
shl edi, BSF sizeof.APPDATA
add edi, SLOT_BASE
cmp [edi + APPDATA.wnd_shape], 0
jne .shaped_window
1950,7 → 1953,7
push edx ecx ; for loop - x,y size
 
mov ecx, esi
shl ecx, 5
shl ecx, BSF sizeof.WDATA
mov edx, [window_data + ecx + WDATA.box.top]
push [window_data + ecx + WDATA.box.width] ; for loop - width
mov ecx, [window_data + ecx + WDATA.box.left]
2036,7 → 2039,7
; DEBUGF 1, "K : thread_count (0x%x)\n", ebx
 
movzx ebx, word[WIN_POS + ebx * 2]
shl ebx, 5
shl ebx, BSF sizeof.WDATA
add eax, window_data
mov al, [window_data + ebx + WDATA.fl_wstyle]
and al, 0x0f
2191,8 → 2194,8
ja .exit.no_redraw
 
movzx edx, word[esi]
shl edx, 5 ; size of TASKDATA and WDATA is 32 bytes
cmp byte [TASK_TABLE + edx + TASKDATA.state], TSTATE_FREE
shl edx, BSF sizeof.WDATA ; size of TASKDATA and WDATA is 32 bytes
cmp byte [SLOT_BASE + edx*8 - sizeof.APPDATA + APPDATA.state], TSTATE_FREE
je .next_window
 
mov eax, [edi + WDATA.box.top]
2283,7 → 2286,7
align 4
.2:
mov edi, [current_slot_idx]
shl edi, 5
shl edi, BSF sizeof.WDATA
test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
jz .exit
mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
2387,18 → 2390,19
; void __fastcall get_window_rect(struct RECT* rc);
; ecx = pointer to 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
 
add edx, [eax-twdw + WDATA.box.width]
add edx, [eax + window_data + WDATA.box.width]
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
 
add edx, [eax-twdw + WDATA.box.height]
add edx, [eax + window_data + WDATA.box.height]
mov [ecx+RECT.bottom], edx
ret
;------------------------------------------------------------------------------
2438,7 → 2442,7
cmp ebp, 1
jbe .exit
 
shl esi, 5
shl esi, BSF sizeof.WDATA
cmp [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
je .exit
 
2457,9 → 2461,9
align 4
.next_window:
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
 
add edi, window_data
/kernel/trunk/kernel.asm
630,7 → 630,6
mov dword [current_slot_idx], 2
mov [thread_count], 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
uglobal
1932,8 → 1931,6
 
mov eax, [current_slot]
mov [eax+APPDATA.state], TSTATE_ZOMBIE
mov eax, [TASK_BASE] ;
mov [eax+TASKDATA.state], TSTATE_ZOMBIE ; delete
call wakeup_osloop
 
.waitterm: ; wait here for termination
1953,7 → 1950,7
 
add eax, [_display.win_map]
movzx edx, byte [ebx+eax]
shl edx, 8
shl edx, BSF sizeof.APPDATA
mov esi, [edx+SLOT_BASE+APPDATA.cursor]
 
cmp esi, [current_cursor]
2043,18 → 2040,18
cmp ecx, edx
ja noprocessterminate
mov eax, [thread_count]
shl ecx, BSF sizeof.TASKDATA
mov edx, [ecx*8 + SLOT_BASE + APPDATA.tid]
add ecx, TASK_TABLE+TASKDATA.state
cmp byte [ecx], TSTATE_FREE
shl ecx, BSF sizeof.APPDATA
add ecx, SLOT_BASE
mov edx, [ecx + APPDATA.tid]
cmp byte [ecx + APPDATA.state], TSTATE_FREE
jz noprocessterminate
push eax
lea eax, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
mov eax, ecx
call is_kernel_thread
pop eax
jz noprocessterminate
push ecx edx
lea edx, [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
mov edx, ecx
call request_terminate
pop edx ecx
test eax, eax
2062,7 → 2059,7
;--------------------------------------
; terminate all network sockets it used
pusha
mov eax, edx
mov eax, edx ;TODO: check function
call socket_process_end
popa
;--------------------------------------
2082,7 → 2079,7
.restore_end:
;--------------------------------------
;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 MEM_Heap_UnLock
 
2189,13 → 2186,10
 
mov eax, edx
shl edx, 5
;shl edx, 8
 
;cmp [edx + SLOT_BASE + APPDATA.state], TSTATE_FREE
cmp [edx + TASK_TABLE + TASKDATA.state], TSTATE_FREE
cmp [edx*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE
je .fail
 
;shr edx, 3
cmp ecx, 1
jnz .set_zmod
 
2665,7 → 2659,6
 
; Process state (+50)
movzx eax, byte [ecx*8 + SLOT_BASE + APPDATA.state]
movzx eax, byte [ecx+TASK_TABLE+TASKDATA.state]
stosd
 
; Window client area box
2745,8 → 2738,9
cmp ebx, 2
jnz srl1
 
mov edx, [TASK_BASE] ; return whole screen draw area for this app
add edx, draw_data - TASK_TABLE
mov edx, [current_slot_idx] ; return whole screen draw area for this app
shl edx, 5
add edx, draw_data
mov [edx + RECT.left], 0
mov [edx + RECT.top], 0
mov eax, [_display.width]
2909,7 → 2903,7
mov [mouse_active], 0
 
xor edi, edi
mov ebx, TASK_TABLE
mov ebx, window_data
 
mov ecx, [thread_count]
movzx eax, word [WIN_POS + ecx*2] ; active window
2922,7 → 2916,7
align 4
.set_mouse_event:
add edi, sizeof.APPDATA
add ebx, sizeof.TASKDATA
add ebx, sizeof.WDATA
test [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000
jz .pos_filter
 
2934,17 → 2928,17
test [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000
jz .set
 
mov esi, [ebx-twdw+WDATA.box.left]
mov esi, [ebx + WDATA.box.left]
cmp eax, esi
jb .skip
add esi, [ebx-twdw+WDATA.box.width]
add esi, [ebx + WDATA.box.width]
cmp eax, esi
ja .skip
 
mov esi, [ebx-twdw+WDATA.box.top]
mov esi, [ebx + WDATA.box.top]
cmp edx, esi
jb .skip
add esi, [ebx-twdw+WDATA.box.height]
add esi, [ebx + WDATA.box.height]
cmp edx, esi
ja .skip
;--------------------------------------
3043,15 → 3037,14
jne noshutdown
 
lea ecx, [edx-1]
mov edx, OS_BASE+0x3040
mov edx, SLOT_BASE + sizeof.APPDATA ;OS_BASE+0x3040
jecxz no_mark_system_shutdown
;--------------------------------------
align 4
markz:
push ecx edx
cmp [edx+TASKDATA.state], TSTATE_FREE
cmp [edx + APPDATA.state], TSTATE_FREE
jz .nokill
lea edx, [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
cmp [edx+APPDATA.process], sys_proc
jz .nokill
call request_terminate
3063,10 → 3056,9
pop edx ecx
test eax, eax
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
call wakeup_osloop
;--------------------------------------
3079,7 → 3071,7
align 4
noshutdown:
mov eax, [thread_count] ; termination
mov ebx, TASK_DATA+TASKDATA.state
mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state
mov esi, 1
;--------------------------------------
align 4
3107,7 → 3099,7
je system_shutdown
 
.noterminate:
add ebx, 0x20
add ebx, sizeof.APPDATA
inc esi
dec eax
jnz newct
/kernel/trunk/network/socket.inc
1860,9 → 1860,8
 
; Suspend the thread
push edx
mov edx, [TASK_BASE]
mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED
mov edx, [current_slot]
mov [edx + APPDATA.state], TSTATE_RUN_SUSPENDED
 
; Remember the thread ID so we can wake it up again
mov edx, [edx + APPDATA.tid]
1903,14 → 1902,11
jz .error2
xor ecx, ecx
inc ecx
;mov esi, TASK_DATA
mov esi, SLOT_BASE + sizeof.APPDATA
.next:
;cmp [esi + TASKDATA.pid], ebx
cmp [esi + APPDATA.tid], ebx
je .found
inc ecx
;add esi, sizeof.TASKDATA
add esi, sizeof.APPDATA
cmp ecx, [thread_count]
jbe .next
1943,8 → 1939,8
; Socket and thread exists and socket is of blocking type
; We'll try to unblock it.
and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag
shl ecx, BSF sizeof.TASKDATA
mov [ecx + TASK_TABLE + TASKDATA.state], TSTATE_RUNNING ; Run the thread
shl ecx, BSF sizeof.APPDATA
mov [SLOT_BASE + ecx + APPDATA.state], TSTATE_RUNNING ; Run the thread
 
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
pop esi ecx ebx
/kernel/trunk/posix/futex.inc
126,7 → 126,7
cli
 
sub esp, sizeof.MUTEX_WAITER
mov ebx, [TASK_BASE]
mov ebx, [current_slot]
mov [esp+MUTEX_WAITER.task], ebx
lea esi, [ebp+FUTEX.wait_list]
 
133,7 → 133,7
list_add_tail esp, esi ;esp= new waiter, esi= list head
mov eax, edx
.again:
mov [ebx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
 
lock cmpxchg [ecx], edx
179,10 → 179,9
mov [ebx+APPDATA.wait_param], ebp
mov eax, [timer_ticks]
mov [ebx+APPDATA.wait_begin], eax
mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], TSTATE_WAITING
mov [ebx + APPDATA.state], TSTATE_WAITING
 
mov [esp+MUTEX_WAITER.task], eax
mov [esp+MUTEX_WAITER.task], ebx
lea esi, [ebp+FUTEX.wait_list]
 
list_add_tail esp, esi ;esp= new waiter, esi= list head
232,7 → 231,7
je .done
 
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]
inc ecx
/kernel/trunk/posix/pipe.inc
181,7 → 181,7
je @F
 
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
je @F
191,7 → 191,7
je @F
 
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]
call mutex_unlock
202,7 → 202,7
cli
 
sub esp, sizeof.MUTEX_WAITER
mov ebx, [TASK_BASE]
mov ebx, [current_slot]
mov [esp+MUTEX_WAITER.task], ebx
lea edx, [ebp+PIPE.rlist]
 
211,7 → 211,7
lea ecx, [ebp+PIPE.pipe_lock]
call mutex_unlock
 
mov [ebx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
 
lea ecx, [ebp+PIPE.pipe_lock]
276,7 → 276,7
je @F
 
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
je @F
286,7 → 286,7
je @F
 
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
 
305,7 → 305,7
cli
 
sub esp, sizeof.MUTEX_WAITER
mov ecx, [TASK_BASE]
mov ecx, [current_slot]
mov [esp+MUTEX_WAITER.task], ecx
lea edx, [ebp+PIPE.wlist]
 
314,7 → 314,7
lea ecx, [ebp+PIPE.pipe_lock]
call mutex_unlock
 
mov [ecx+TASKDATA.state], TSTATE_RUN_SUSPENDED
mov [ecx + APPDATA.state], TSTATE_RUN_SUSPENDED
call change_task
 
lea ecx, [ebp+PIPE.pipe_lock]
/kernel/trunk/video/vesa12.inc
398,9 → 398,6
push ebx
push ecx
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]
shl ecx, 5
add eax, [ecx + window_data + WDATA.box.left]
769,9 → 766,6
push edx
movzx eax, word [esp+2]
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]
shl ecx, 5
add eax, [ecx + window_data + WDATA.box.left]
/kernel/trunk/video/vga.inc
495,9 → 495,6
align 4
VGA_draw_bar_1:
mov [temp.cx], eax
;mov eax, [TASK_BASE]
;add ebx, [eax-twdw + 4]
;mov eax, [eax-twdw + 0]
mov eax, [current_slot_idx]
shl eax, 5
add ebx, [eax+window_data+WDATA.box.top]