Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9698 → Rev 9709

/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