forked from KolibriOS/kolibrios
1)debugger support
2)fixed bugs in get_event_for_app() git-svn-id: svn://kolibrios.org@459 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1bc5430ccc
commit
73baea5f6c
@ -122,7 +122,6 @@ debug_getcontext:
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
; add edx, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
@ -131,19 +130,12 @@ debug_getcontext:
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .ret
|
||||
; imul eax, tss_step/32
|
||||
; add eax, tss_data
|
||||
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
|
||||
lea esi, [eax+RING0_STACK_SIZE]
|
||||
mov edi, edx
|
||||
; cmp [eax+TSS._cs], app_code
|
||||
; jnz .ring0
|
||||
; lea esi, [eax+TSS._eip]
|
||||
; shr ecx, 2
|
||||
; rep movsd
|
||||
; jmp .ret
|
||||
.ring0:
|
||||
; note that following code assumes that all interrupt/exception handlers
|
||||
; saves ring-3 context by pushad in this order
|
||||
mov esi, [tss._esp0]
|
||||
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
|
||||
sub esi, 8+12+20h
|
||||
lodsd ;edi
|
||||
@ -161,7 +153,6 @@ debug_getcontext:
|
||||
mov [edi+0Ch], eax
|
||||
lodsd ;eax
|
||||
mov [edi+8], eax
|
||||
;;; add esi, 8 ;ds es
|
||||
lodsd ;eip
|
||||
mov [edi], eax
|
||||
lodsd ;cs
|
||||
@ -181,7 +172,6 @@ debug_setcontext:
|
||||
; destroys eax,ecx,edx,esi,edi
|
||||
cmp ecx, 28h
|
||||
jnz .ret
|
||||
; add edx, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
call check_region
|
||||
@ -190,17 +180,10 @@ debug_setcontext:
|
||||
jnz .ret
|
||||
call get_debuggee_slot
|
||||
jc .stiret
|
||||
; imul eax, tss_step/32
|
||||
; add eax, tss_data
|
||||
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
|
||||
lea edi, [eax+RING0_STACK_SIZE]
|
||||
mov esi, edx
|
||||
; cmp [eax+TSS._cs], app_code
|
||||
; jnz .ring0
|
||||
; lea edi, [eax+TSS._eip]
|
||||
; shr ecx, 2
|
||||
; rep movsd
|
||||
; jmp .stiret
|
||||
.ring0:
|
||||
mov edi, [tss._esp0]
|
||||
sub edi, 8+12+20h
|
||||
mov eax, [esi+24h] ;edi
|
||||
stosd
|
||||
@ -217,7 +200,6 @@ debug_setcontext:
|
||||
stosd
|
||||
mov eax, [esi+8] ;eax
|
||||
stosd
|
||||
;;; add edi, 8 ;ds es
|
||||
mov eax, [esi] ;eip
|
||||
stosd
|
||||
scasd
|
||||
@ -237,8 +219,8 @@ debug_set_drx:
|
||||
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
|
||||
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
|
||||
; [eax+10]=dr7
|
||||
; add edx, std_application_base_address
|
||||
jc .errret
|
||||
cmp edx, OS_BASE
|
||||
jae .errret
|
||||
cmp cl, 3
|
||||
ja .errret
|
||||
mov ebx, dr7
|
||||
@ -257,6 +239,7 @@ debug_set_drx:
|
||||
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
|
||||
.okret:
|
||||
and dword [esp+36], 0
|
||||
sti
|
||||
@ -299,6 +282,7 @@ debug_set_drx:
|
||||
or [eax+10h+2], bx ; 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
|
||||
jmp .okret
|
||||
|
||||
debug_read_process_memory:
|
||||
@ -309,7 +293,6 @@ debug_read_process_memory:
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(read)
|
||||
; destroys all
|
||||
; add esi, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
@ -336,7 +319,6 @@ debug_write_process_memory:
|
||||
; edx=address in debuggee
|
||||
; out: [esp+36]=sizeof(write)
|
||||
; destroys all
|
||||
; add esi, std_application_base_address
|
||||
push ebx
|
||||
mov ebx, esi
|
||||
call check_region
|
||||
@ -433,28 +415,6 @@ debug_exc:
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov eax, dr6
|
||||
test ax, ax
|
||||
jns @f
|
||||
; this is exception from task switch
|
||||
; set DRx registers for task and continue
|
||||
mov eax, [CURRENT_TASK]
|
||||
shl eax, 8
|
||||
add eax, SLOT_BASE+APPDATA.dbg_regs
|
||||
mov ecx, [eax+0]
|
||||
mov dr0, ecx
|
||||
mov ecx, [eax+4]
|
||||
mov dr1, ecx
|
||||
mov ecx, [eax+8]
|
||||
mov dr2, ecx
|
||||
mov ecx, [eax+0Ch]
|
||||
mov dr3, ecx
|
||||
xor ecx, ecx
|
||||
mov dr6, ecx
|
||||
mov ecx, [eax+10h]
|
||||
mov dr7, ecx
|
||||
restore_ring3_context
|
||||
iretd
|
||||
@@:
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov dr6, eax
|
||||
|
@ -468,13 +468,13 @@ proc page_fault_handler
|
||||
|
||||
inc [pg_data.pages_faults]
|
||||
|
||||
push eax
|
||||
push edx
|
||||
mov edx, 0x400 ;bochs
|
||||
mov al,0xff ;bochs
|
||||
out dx, al ;bochs
|
||||
pop edx
|
||||
pop eax
|
||||
; push eax
|
||||
; push edx
|
||||
; mov edx, 0x400 ;bochs
|
||||
; mov al,0xff ;bochs
|
||||
; out dx, al ;bochs
|
||||
; pop edx
|
||||
; pop eax
|
||||
|
||||
mov ebx, [.err_addr]
|
||||
mov eax, [.err_code]
|
||||
@ -591,7 +591,8 @@ align 4
|
||||
mov esp, ebp
|
||||
popad
|
||||
add esp, 4
|
||||
iretd
|
||||
|
||||
; iretd
|
||||
|
||||
save_ring3_context ;debugger support
|
||||
|
||||
|
@ -221,6 +221,22 @@ do_change_task:
|
||||
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
|
||||
|
@ -898,6 +898,12 @@ wait_mutex:
|
||||
pop eax
|
||||
ret
|
||||
|
||||
EFL_IF equ 0x0200
|
||||
EFL_IOPL1 equ 0x1000
|
||||
EFL_IOPL2 equ 0x2000
|
||||
EFL_IOPL3 equ 0x3000
|
||||
|
||||
|
||||
align 4
|
||||
proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
cmd_line:dword, app_path:dword, flags:dword
|
||||
@ -1018,12 +1024,10 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
mov [ebx+REG_ECX], eax
|
||||
mov [ebx+REG_EAX], eax
|
||||
|
||||
; mov [ebx+REG_EFL_2], dword 0x1002
|
||||
|
||||
mov eax, [esi+0x08] ;app_eip
|
||||
mov [ebx+REG_EIP], eax ;app_entry
|
||||
mov [ebx+REG_CS], dword app_code
|
||||
mov [ebx+REG_EFLAGS], dword 0x1202
|
||||
mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
|
||||
|
||||
mov eax, [esi+0x0C] ;app_esp
|
||||
mov [ebx+REG_APP_ESP], eax ;app_stack
|
||||
|
@ -1,7 +1,36 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;OS_BASE equ 0x80000000
|
||||
;new_app_base equ 0x60400000
|
||||
;PROC_BASE equ OS_BASE+0x0080000
|
||||
format MS COFF
|
||||
|
||||
include 'proc32.inc'
|
||||
include 'imports.inc'
|
||||
|
||||
PG_SW equ 0x003
|
||||
page_tabs equ 0xFDC00000 ;hack
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
SLOT_BASE equ (OS_BASE+0x0080000)
|
||||
TASK_COUNT equ (OS_BASE+0x0003004)
|
||||
CURRENT_TASK equ (OS_BASE+0x0003000)
|
||||
|
||||
|
||||
struc APPOBJ ;common object header
|
||||
{
|
||||
.magic dd ? ;
|
||||
.destroy dd ? ;internal destructor
|
||||
.fd dd ? ;next object in list
|
||||
.bk dd ? ;prev object in list
|
||||
.pid dd ? ;owner id
|
||||
};
|
||||
|
||||
virtual at 0
|
||||
APPOBJ APPOBJ
|
||||
end virtual
|
||||
|
||||
struc IOCTL
|
||||
{ .handle dd ?
|
||||
@ -12,10 +41,9 @@ struc IOCTL
|
||||
.out_size dd ?
|
||||
}
|
||||
|
||||
|
||||
;public START
|
||||
;public service_proc
|
||||
;public version
|
||||
virtual at 0
|
||||
IOCTL IOCTL
|
||||
end virtual
|
||||
|
||||
DEBUG equ 1
|
||||
|
||||
@ -164,13 +192,19 @@ CONNECTION_SIZE equ 7*4
|
||||
|
||||
UART_VERSION equ 0x12345678 ;debug
|
||||
|
||||
proc init_uart_service stdcall, state:dword
|
||||
public START
|
||||
public service_proc
|
||||
public version
|
||||
|
||||
section '.flat' code readable align 16
|
||||
|
||||
proc START stdcall, state:dword
|
||||
|
||||
cmp [state], 1
|
||||
jne .stop
|
||||
|
||||
mov eax, UART_SIZE
|
||||
call malloc
|
||||
call Kmalloc
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
@ -184,7 +218,7 @@ proc init_uart_service stdcall, state:dword
|
||||
mov eax, [com1]
|
||||
mov [eax+UART.base], COM_1_BASE
|
||||
|
||||
stdcall alloc_kernel_space, 32768
|
||||
stdcall AllocKernelSpace, 32768
|
||||
|
||||
mov edi, [com1]
|
||||
mov edx, eax
|
||||
@ -197,7 +231,7 @@ proc init_uart_service stdcall, state:dword
|
||||
add eax, 8192
|
||||
mov [edi+UART.xmit_top], eax
|
||||
|
||||
call alloc_page
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
@ -206,7 +240,7 @@ proc init_uart_service stdcall, state:dword
|
||||
mov [page_tabs+edx*4], eax
|
||||
mov [page_tabs+edx*4+8], eax
|
||||
|
||||
call alloc_page
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
@ -214,7 +248,7 @@ proc init_uart_service stdcall, state:dword
|
||||
mov [page_tabs+edx*4+4], eax
|
||||
mov [page_tabs+edx*4+12], eax
|
||||
|
||||
call alloc_page
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
@ -222,7 +256,7 @@ proc init_uart_service stdcall, state:dword
|
||||
mov [page_tabs+edx*4+16], eax
|
||||
mov [page_tabs+edx*4+24], eax
|
||||
|
||||
call alloc_page
|
||||
call AllocPage
|
||||
test eax, eax
|
||||
jz .fail
|
||||
|
||||
@ -243,9 +277,8 @@ proc init_uart_service stdcall, state:dword
|
||||
mov eax, edi
|
||||
call uart_reset.internal ;eax= uart
|
||||
|
||||
stdcall attach_int_handler, COM_1_IRQ, com_1_isr
|
||||
stdcall reg_service, sz_uart_srv, uart_proc
|
||||
mov [eax+SRV.entry], init_uart_service
|
||||
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr
|
||||
stdcall RegService, sz_uart_srv, service_proc
|
||||
ret
|
||||
.fail:
|
||||
.stop:
|
||||
@ -273,7 +306,7 @@ PORT_READ equ 8
|
||||
PORT_WRITE equ 9
|
||||
|
||||
align 4
|
||||
proc uart_proc stdcall, ioctl:dword
|
||||
proc service_proc stdcall, ioctl:dword
|
||||
|
||||
mov ebx, [ioctl]
|
||||
mov eax, [ebx+io_code]
|
||||
@ -555,7 +588,7 @@ uart_open:
|
||||
.do_wait:
|
||||
cmp dword [esi+UART.lock],0
|
||||
je .get_lock
|
||||
call change_task
|
||||
; call change_task
|
||||
jmp .do_wait
|
||||
.get_lock:
|
||||
mov eax, 1
|
||||
@ -570,7 +603,7 @@ uart_open:
|
||||
shl ebx, 5
|
||||
mov ebx, [CURRENT_TASK+ebx+4]
|
||||
mov eax, CONNECTION_SIZE
|
||||
call create_kernel_object
|
||||
call CreateObject
|
||||
pop esi ;uart
|
||||
test eax, eax
|
||||
jz .fail
|
||||
@ -599,7 +632,7 @@ uart_close:
|
||||
jne .fail
|
||||
.destroy:
|
||||
push [eax+CONNECTION.uart]
|
||||
call destroy_kernel_object ;eax= object
|
||||
call DestroyObject ;eax= object
|
||||
pop eax ;eax= uart
|
||||
test eax, eax
|
||||
jz .fail
|
||||
@ -901,8 +934,9 @@ isr_modem:
|
||||
|
||||
|
||||
align 4
|
||||
com1 dd 0
|
||||
com2 dd 0
|
||||
divisor dw 2304, 1536, 1047, 857, 768, 384
|
||||
dw 192, 96, 64, 58, 48, 32
|
||||
dw 24, 16, 12, 6, 3, 2, 1
|
||||
|
||||
align 4
|
||||
uart_func dd 0 ;SRV_GETVERSION
|
||||
@ -921,15 +955,12 @@ isr_action dd isr_modem
|
||||
dd isr_recieve
|
||||
dd isr_line
|
||||
|
||||
;version dd 0x00040000
|
||||
|
||||
divisor dw 2304, 1536, 1047, 857, 768, 384
|
||||
dw 192, 96, 64, 58, 48, 32
|
||||
dw 24, 16, 12, 6, 3, 2, 1
|
||||
|
||||
|
||||
version dd 0x00040000
|
||||
|
||||
sz_uart_srv db 'UART',0
|
||||
|
||||
align 4
|
||||
|
||||
com1 rd 1
|
||||
com2 rd 1
|
||||
|
@ -601,23 +601,24 @@ no_eventoccur5:
|
||||
;mov edi,[TASK_BASE] ; IPC
|
||||
test [edi+TASKDATA.event_mask],dword 01000000b
|
||||
jz no_ipc
|
||||
mov eax,[current_slot]
|
||||
test [eax+APPDATA.event_mask],dword 01000000b
|
||||
mov eax, [CURRENT_TASK]
|
||||
shl eax, 8
|
||||
test [eax+SLOT_BASE+APPDATA.event_mask],dword 01000000b
|
||||
jz no_ipc
|
||||
and [eax+APPDATA.event_mask],dword 0xffffffff-01000000b
|
||||
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-01000000b
|
||||
popad
|
||||
mov eax,7
|
||||
ret
|
||||
no_ipc:
|
||||
|
||||
|
||||
;mov edi,[TASK_BASE] ; STACK
|
||||
test [edi+TASKDATA.event_mask],dword 10000000b
|
||||
jz no_stack_event
|
||||
mov eax,[current_slot]
|
||||
test [eax+APPDATA.event_mask],dword 10000000b
|
||||
mov eax, [CURRENT_TASK]
|
||||
shl eax, 8
|
||||
test [eax+SLOT_BASE+APPDATA.event_mask],dword 10000000b
|
||||
jz no_stack_event
|
||||
and [eax+APPDATA.event_mask],dword 0xffffffff-10000000b
|
||||
and [eax+SLOT_BASE+APPDATA.event_mask],dword 0xffffffff-10000000b
|
||||
popad
|
||||
mov eax,8
|
||||
ret
|
||||
@ -625,10 +626,11 @@ no_stack_event:
|
||||
|
||||
test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG
|
||||
jz .test_IRQ
|
||||
mov eax, [current_slot]
|
||||
test byte [eax+APPDATA.event_mask+1], byte 1
|
||||
mov eax, [CURRENT_TASK]
|
||||
shl eax, 8
|
||||
test byte [eax+SLOT_BASE+APPDATA.event_mask+1], byte 1
|
||||
jz .test_IRQ
|
||||
and byte [eax+APPDATA.event_mask+1], not 1
|
||||
and byte [eax+SLOT_BASE+APPDATA.event_mask+1], not 1
|
||||
popad
|
||||
mov eax, 9
|
||||
ret
|
||||
|
@ -1639,7 +1639,6 @@ sys_setup_err:
|
||||
mov [esp+36],dword -1
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
sys_getsetup:
|
||||
@ -3373,8 +3372,7 @@ mouse_not_active:
|
||||
mov [REDRAW_BACKGROUND],byte 0
|
||||
mov [MOUSE_BACKGROUND],byte 0
|
||||
|
||||
nobackgr:
|
||||
|
||||
nobackgr:
|
||||
|
||||
; system shutdown request
|
||||
|
||||
@ -3390,7 +3388,7 @@ mouse_not_active:
|
||||
mov edx,OS_BASE+0x3040
|
||||
movzx ecx,byte [SYS_SHUTDOWN]
|
||||
add ecx,5
|
||||
markz:
|
||||
markz:
|
||||
mov [edx+TASKDATA.state],byte 3
|
||||
add edx,0x20
|
||||
loop markz
|
||||
@ -3404,14 +3402,14 @@ mouse_not_active:
|
||||
cmp [SYS_SHUTDOWN],byte 0
|
||||
je system_shutdown
|
||||
|
||||
noshutdown:
|
||||
noshutdown:
|
||||
|
||||
|
||||
mov eax,[TASK_COUNT] ; termination
|
||||
mov ebx,TASK_DATA+TASKDATA.state
|
||||
mov esi,1
|
||||
|
||||
newct:
|
||||
newct:
|
||||
mov cl,[ebx]
|
||||
cmp cl,byte 3
|
||||
jz terminate
|
||||
@ -3426,8 +3424,6 @@ mouse_not_active:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; redraw screen
|
||||
|
||||
redrawscreen:
|
||||
|
@ -125,8 +125,9 @@ struc APPDATA
|
||||
.bk_obj dd ? ;+60
|
||||
.saved_esp dd ? ;+64
|
||||
.io_map rd 2 ;+68
|
||||
.dbg_state dd ? ;+76
|
||||
|
||||
db 52 dup(?) ;+76
|
||||
db 48 dup(?) ;+80
|
||||
|
||||
.wnd_shape dd ? ;+128
|
||||
.wnd_shape_scale dd ? ;+132
|
||||
|
Loading…
Reference in New Issue
Block a user