sys32 - concentration all (except #NM) exception handlers in ecx_c for optimization purpose

debug  - moved handler to sys32::exc_c
fpu    - moved except_16/19 to sys32::exc_c
memory - changing interface for page_fault_handler
v86    - changing interface for handler v86_exc_c
kernel - small optimization

git-svn-id: svn://kolibrios.org@1056 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Galkov 2009-04-04 19:58:42 +00:00
parent 3be0aa5c21
commit 82da211b9b
7 changed files with 799 additions and 887 deletions

View File

@ -10,71 +10,71 @@ $Revision$
; diamond, 2006
sys_debug_services:
cmp eax, 9
ja @f
jmp dword [sys_debug_services_table+eax*4]
@@: ret
cmp eax, 9
ja @f
jmp dword [sys_debug_services_table+eax*4]
@@: ret
sys_debug_services_table:
dd debug_set_event_data
dd debug_getcontext
dd debug_setcontext
dd debug_detach
dd debug_suspend
dd debug_resume
dd debug_read_process_memory
dd debug_write_process_memory
dd debug_terminate
dd debug_set_drx
dd debug_set_event_data
dd debug_getcontext
dd debug_setcontext
dd debug_detach
dd debug_suspend
dd debug_resume
dd debug_read_process_memory
dd debug_write_process_memory
dd debug_terminate
dd debug_set_drx
debug_set_event_data:
; in: ebx = pointer
; destroys eax
mov eax, [current_slot]
mov [eax+APPDATA.dbg_event_mem], ebx
ret
ret
get_debuggee_slot:
; in: ebx=PID
; out: CF=1 if error
; CF=0 and eax=slot*0x20 if ok
; out: interrupts disabled
cli
mov eax, ebx
call pid_to_slot
test eax, eax
jz .ret_bad
shl eax, 5
push ebx
cli
mov eax, ebx
call pid_to_slot
test eax, eax
jz .ret_bad
shl eax, 5
push ebx
mov ebx, [CURRENT_TASK]
cmp [SLOT_BASE+eax*8+APPDATA.debugger_slot], ebx
pop ebx
jnz .ret_bad
; clc ; automatically
ret
pop ebx
jnz .ret_bad
; clc ; automatically
ret
.ret_bad:
stc
ret
stc
ret
debug_detach:
; in: ebx=pid
; destroys eax,ebx
call get_debuggee_slot
jc .ret
call get_debuggee_slot
jc .ret
and dword [eax*8+SLOT_BASE+APPDATA.debugger_slot], 0
call do_resume
call do_resume
.ret:
sti
ret
sti
ret
debug_terminate:
; in: ebx=pid
call get_debuggee_slot
jc debug_detach.ret
mov ecx, eax
shr ecx, 5
push 2
pop ebx
jmp sys_system
call get_debuggee_slot
jc debug_detach.ret
mov ecx, eax
shr ecx, 5
push 2
pop ebx
jmp sys_system
debug_suspend:
; in: ebx=pid
@ -85,30 +85,30 @@ debug_suspend:
shl eax, 5
jz .ret
mov bl, [CURRENT_TASK+eax+TASKDATA.state] ; process state
test bl, bl
jz .1
cmp bl, 5
jnz .ret
mov bl, 2
test bl, bl
jz .1
cmp bl, 5
jnz .ret
mov bl, 2
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl
.ret:
sti
ret
sti
ret
.1:
inc ebx
jmp .2
inc ebx
jmp .2
do_resume:
mov bl, [CURRENT_TASK+eax+TASKDATA.state]
cmp bl, 1
jz .1
cmp bl, 2
jnz .ret
mov bl, 5
cmp bl, 1
jz .1
cmp bl, 2
jnz .ret
mov bl, 5
.2: mov [CURRENT_TASK+eax+TASKDATA.state], bl
.ret: ret
.1: dec ebx
jmp .2
.ret: ret
.1: dec ebx
jmp .2
debug_resume:
; in: ebx=pid
@ -119,8 +119,8 @@ debug_resume:
shl eax, 5
jz .ret
call do_resume
.ret: sti
ret
.ret: sti
ret
debug_getcontext:
; in:
@ -128,16 +128,16 @@ debug_getcontext:
; ecx=sizeof(CONTEXT)
; edx->CONTEXT
; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h
jnz .ret
push ebx
mov ebx, edx
call check_region
pop ebx
dec eax
jnz .ret
call get_debuggee_slot
jc .ret
cmp ecx, 28h
jnz .ret
push ebx
mov ebx, edx
call check_region
pop ebx
dec eax
jnz .ret
call get_debuggee_slot
jc .ret
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea esi, [eax+RING0_STACK_SIZE]
mov edi, edx
@ -147,30 +147,30 @@ debug_getcontext:
; top of ring0 stack: ring3 stack ptr (ss+esp), iret data (cs+eip+eflags), pushad
sub esi, 8+12+20h
lodsd ;edi
mov [edi+24h], eax
mov [edi+24h], eax
lodsd ;esi
mov [edi+20h], eax
mov [edi+20h], eax
lodsd ; ebp
mov [edi+1Ch], eax
mov [edi+1Ch], eax
lodsd ;esp
lodsd ;ebx
mov [edi+14h], eax
mov [edi+14h], eax
lodsd ;edx
mov [edi+10h], eax
mov [edi+10h], eax
lodsd ;ecx
mov [edi+0Ch], eax
mov [edi+0Ch], eax
lodsd ;eax
mov [edi+8], eax
mov [edi+8], eax
lodsd ;eip
mov [edi], eax
mov [edi], eax
lodsd ;cs
lodsd ;eflags
mov [edi+4], eax
mov [edi+4], eax
lodsd ;esp
mov [edi+18h], eax
mov [edi+18h], eax
.ret:
sti
ret
sti
ret
debug_setcontext:
; in:
@ -178,120 +178,120 @@ debug_setcontext:
; ecx=sizeof(CONTEXT)
; edx->CONTEXT
; destroys eax,ecx,edx,esi,edi
cmp ecx, 28h
jnz .ret
push ebx
mov ebx, edx
call check_region
pop ebx
dec eax
jnz .ret
call get_debuggee_slot
jc .stiret
cmp ecx, 28h
jnz .ret
push ebx
mov ebx, edx
call check_region
pop ebx
dec eax
jnz .ret
call get_debuggee_slot
jc .stiret
mov eax, [eax*8+SLOT_BASE+APPDATA.pl0_stack]
lea edi, [eax+RING0_STACK_SIZE]
mov esi, edx
.ring0:
sub edi, 8+12+20h
mov eax, [esi+24h] ;edi
stosd
stosd
mov eax, [esi+20h] ;esi
stosd
stosd
mov eax, [esi+1Ch] ;ebp
stosd
stosd
scasd
mov eax, [esi+14h] ;ebx
stosd
stosd
mov eax, [esi+10h] ;edx
stosd
stosd
mov eax, [esi+0Ch] ;ecx
stosd
stosd
mov eax, [esi+8] ;eax
stosd
stosd
mov eax, [esi] ;eip
stosd
scasd
stosd
scasd
mov eax, [esi+4] ;eflags
stosd
stosd
mov eax, [esi+18h] ;esp
stosd
stosd
.stiret:
sti
sti
.ret:
ret
ret
debug_set_drx:
call get_debuggee_slot
jc .errret
mov ebp, eax
call get_debuggee_slot
jc .errret
mov ebp, eax
lea eax, [eax*8+SLOT_BASE+APPDATA.dbg_regs]
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
; [eax+10]=dr7
cmp edx, OS_BASE
jae .errret
cmp cl, 3
ja .errret
mov ebx, dr7
shr ebx, cl
shr ebx, cl
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable
jnz .errret2
test ch, ch
jns .new
cmp cl, 3
ja .errret
mov ebx, dr7
shr ebx, cl
shr ebx, cl
test ebx, 2 ; bit 1+2*index = G0..G3, global break enable
jnz .errret2
test ch, ch
jns .new
; clear breakpoint
movzx ecx, cl
add ecx, ecx
and dword [eax+ecx*2], 0 ; clear DR<i>
btr dword [eax+10h], ecx ; clear L<i> bit
test byte [eax+10h], 55h
jnz .okret
movzx ecx, cl
add ecx, ecx
and dword [eax+ecx*2], 0 ; clear DR<i>
btr dword [eax+10h], ecx ; clear L<i> bit
test byte [eax+10h], 55h
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
ret
and dword [esp+36], 0
sti
ret
.errret:
sti
mov dword [esp+36], 1
ret
sti
mov dword [esp+36], 1
ret
.errret2:
sti
mov dword [esp+36], 2
ret
sti
mov dword [esp+36], 2
ret
.new:
; add new breakpoint
; cl=index; ch=flags; edx=address
test ch, 0xF0
jnz .errret
mov bl, ch
and bl, 3
cmp bl, 2
jz .errret
mov bl, ch
shr bl, 2
cmp bl, 2
jz .errret
test dl, bl
jnz .errret
or byte [eax+10h+1], 3 ; set GE and LE flags
movzx ebx, ch
movzx ecx, cl
add ecx, ecx
bts dword [eax+10h], ecx ; set L<i> flag
add ecx, ecx
mov [eax+ecx], edx ; set DR<i>
shl ebx, cl
mov edx, 0xF
shl edx, cl
not edx
and [eax+10h+2], dx
or [eax+10h+2], bx ; set R/W and LEN fields
test ch, 0xF0
jnz .errret
mov bl, ch
and bl, 3
cmp bl, 2
jz .errret
mov bl, ch
shr bl, 2
cmp bl, 2
jz .errret
test dl, bl
jnz .errret
or byte [eax+10h+1], 3 ; set GE and LE flags
movzx ebx, ch
movzx ecx, cl
add ecx, ecx
bts dword [eax+10h], ecx ; set L<i> flag
add ecx, ecx
mov [eax+ecx], edx ; set DR<i>
shl ebx, cl
mov edx, 0xF
shl edx, cl
not edx
and [eax+10h+2], dx
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
jmp .okret
debug_read_process_memory:
; in:
@ -301,23 +301,23 @@ debug_read_process_memory:
; edx=address in debuggee
; out: [esp+36]=sizeof(read)
; destroys all
push ebx
mov ebx, esi
call check_region
pop ebx
dec eax
jnz .err
call get_debuggee_slot
jc .err
shr eax, 5
mov ebx, esi
call read_process_memory
sti
mov dword [esp+36], eax
ret
push ebx
mov ebx, esi
call check_region
pop ebx
dec eax
jnz .err
call get_debuggee_slot
jc .err
shr eax, 5
mov ebx, esi
call read_process_memory
sti
mov dword [esp+36], eax
ret
.err:
or dword [esp+36], -1
ret
or dword [esp+36], -1
ret
debug_write_process_memory:
; in:
@ -327,20 +327,20 @@ debug_write_process_memory:
; edx=address in debuggee
; out: [esp+36]=sizeof(write)
; destroys all
push ebx
mov ebx, esi
call check_region
pop ebx
dec eax
jnz debug_read_process_memory.err
call get_debuggee_slot
jc debug_read_process_memory.err
shr eax, 5
mov ebx, esi
call write_process_memory
sti
mov [esp+36], eax
ret
push ebx
mov ebx, esi
call check_region
pop ebx
dec eax
jnz debug_read_process_memory.err
call get_debuggee_slot
jc debug_read_process_memory.err
shr eax, 5
mov ebx, esi
call write_process_memory
sti
mov [esp+36], eax
ret
debugger_notify:
; in: eax=debugger slot
@ -349,127 +349,96 @@ debugger_notify:
; interrupts must be disabled!
; destroys all general registers
; interrupts remain disabled
xchg ebp, eax
mov edi, [timer_ticks]
add edi, 500 ; 5 sec timeout
xchg ebp, eax
mov edi, [timer_ticks]
add edi, 500 ; 5 sec timeout
.1:
mov eax, ebp
shl eax, 8
mov eax, ebp
shl eax, 8
mov edx, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
test edx, edx
jz .ret
test edx, edx
jz .ret
; read buffer header
push ecx
push eax
push eax
mov eax, ebp
mov ebx, esp
mov ecx, 8
call read_process_memory
cmp eax, ecx
jz @f
add esp, 12
jmp .ret
push ecx
push eax
push eax
mov eax, ebp
mov ebx, esp
mov ecx, 8
call read_process_memory
cmp eax, ecx
jz @f
add esp, 12
jmp .ret
@@:
cmp dword [ebx], 0
jg @f
cmp dword [ebx], 0
jg @f
.2:
pop ecx
pop ecx
pop ecx
pop ecx
pop ecx
pop ecx
cmp dword [CURRENT_TASK], 1
jnz .notos
cmp [timer_ticks], edi
jae .ret
jnz .notos
cmp [timer_ticks], edi
jae .ret
.notos:
sti
call change_task
cli
jmp .1
sti
call change_task
cli
jmp .1
@@:
mov ecx, [ebx+8]
add ecx, [ebx+4]
cmp ecx, [ebx]
ja .2
mov ecx, [ebx+8]
add ecx, [ebx+4]
cmp ecx, [ebx]
ja .2
; advance buffer position
push ecx
mov ecx, 4
sub ebx, ecx
mov eax, ebp
add edx, ecx
call write_process_memory
pop eax
push ecx
mov ecx, 4
sub ebx, ecx
mov eax, ebp
add edx, ecx
call write_process_memory
pop eax
; write message
mov eax, ebp
add edx, ecx
add edx, [ebx+8]
add ebx, 20
pop ecx
pop ecx
pop ecx
call write_process_memory
mov eax, ebp
add edx, ecx
add edx, [ebx+8]
add ebx, 20
pop ecx
pop ecx
pop ecx
call write_process_memory
; new debug event
mov eax, ebp
shl eax, 8
mov eax, ebp
shl eax, 8
or byte [SLOT_BASE+eax+APPDATA.event_mask+1], 1 ; set flag 100h
.ret:
ret
ret
debug_exc:
test byte [esp+8+2], 2
jnz v86_debug_exc
; int 1 = #DB
save_ring3_context
cld
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov eax, dr6
push eax
xor eax, eax
mov dr6, eax
; test if debugging
cli
mov eax, [current_slot]
mov eax, [eax+APPDATA.debugger_slot]
test eax, eax
jnz .debug
sti
; not debuggee => say error and terminate
add esp, 0x20+4
mov [error_interrupt], 1
call show_error_parameters
mov edx, [TASK_BASE]
mov byte [edx+TASKDATA.state], 4
jmp change_task
.debug:
debug_ex:
; we are debugged process, notify debugger and suspend ourself
; eax=debugger PID
pop edx
mov ebx, dr7
mov cl, not 1
.l1:
test bl, 1
jnz @f
and dl, cl
@@:
shr ebx, 2
add cl, cl
inc ecx
cmp cl, not 10h
jnz .l1
push edx ; DR6 image
mov ecx, [TASK_BASE]
push dword [ecx+TASKDATA.pid] ; PID
push 12
pop ecx
push 3 ; 3 = debug exception
call debugger_notify
pop ecx
pop ecx
pop ecx
mov edx, dr6 ; debug_message data=DR6_image
xor ebx, ebx
mov dr6, ebx
mov ebx, dr7
mov cl, not 8
.l1: shl bl,2
jc @f
and dl, cl
@@: sar cl,1
jc .l1
mov ecx,3 ; debug_message code=debug_exception
.notify:
push edx ; debug_message data
mov ebx, [TASK_BASE]
push [ebx+TASKDATA.pid] ; PID
push ecx ; debug_message code
mov ecx,12 ; debug_message size
call debugger_notify ;; only ONE using, inline ???
add esp,12
mov edx, [TASK_BASE]
mov byte [edx+TASKDATA.state], 1 ; suspended
call change_task
restore_ring3_context
iretd
mov byte [edx+TASKDATA.state], 1 ; suspended
call change_task
restore_ring3_context
iretd

View File

@ -142,7 +142,7 @@ fpu_restore:
ret
align 4
e7: ;#NM exception handler
except_7: ;#NM exception handler
save_ring3_context
clts
mov ax, app_data ;
@ -180,7 +180,7 @@ e7: ;#NM exception handler
iglobal
fpu_owner dd 0
endg
endg
reg_eip equ ebp+4
reg_cs equ ebp+8
@ -188,8 +188,8 @@ reg_eflags equ ebp+12
reg_esp equ ebp+16
reg_ss equ ebp+20
align 4
except_16: ;fpu native exceptions handler
align 4 ;not used now
proc except_16 ;fpu native exceptions handler
test byte [esp+8+2], 2
jnz v86_except_16
push ebp
@ -233,9 +233,10 @@ except_16: ;fpu native exceptions handler
mov bl, 16
jmp exc_c
endp
align 4
except_19: ;sse exceptions handler
align 4 ;not used now
proc except_19 ;sse exceptions handler
test byte [esp+8+2], 2
jnz v86_except_19
push ebp
@ -278,6 +279,7 @@ except_19: ;sse exceptions handler
mov bl, 19
jmp exc_c
endp
restore reg_eip
restore reg_cs

View File

@ -544,24 +544,15 @@ get_pg_addr:
align 4
; Now it is called from sys32::exc_c (see stack frame there)
proc page_fault_handler
test byte [esp+12+2], 2
jnz v86_page_fault
.err_addr equ ebp-4
.err_code equ ebp+32
.err_addr equ ebp-4
pushad
mov ebp, esp
mov eax, cr2
push eax
mov ax, app_data
mov ds, ax
mov es, ax
inc [pg_data.pages_faults]
mov ebp, esp
mov ebx, cr2
push ebx ; that is locals: .err_addr = cr2
inc [pg_data.pages_faults]
; push eax
; push edx
@ -571,129 +562,115 @@ proc page_fault_handler
; pop edx
; pop eax
mov ebx, [.err_addr]
mov eax, [.err_code]
mov eax, [pf_err_code]
cmp ebx, OS_BASE
jb .user_space ;страница в памяти приложения ;
cmp ebx, OS_BASE ;ebx == .err_addr
jb .user_space ;ñòðàíèöà â ïàìÿòè ïðèëîæåíèÿ ;
cmp ebx, page_tabs
jb .kernel_space ;страница в памяти ядра
cmp ebx, page_tabs
jb .kernel_space ;ñòðàíèöà â ïàìÿòè ÿäðà
cmp ebx, kernel_tabs
jb .alloc;.app_tabs ;таблицы страниц приложения ;
;просто создадим одну
cmp ebx, kernel_tabs
jb .alloc;.app_tabs ;òàáëèöû ñòðàíèö ïðèëîæåíèÿ ;
;ïðîñòî ñîçäàäèì îäíó
if 0 ;ïîêà ýòî ïðîñòî ëèøíåå
cmp ebx, LFB_BASE
jb .core_tabs ;òàáëèöû ñòðàíèö ÿäðà
;Îøèáêà
.lfb:
;îáëàñòü LFB
;Îøèáêà
jmp .fail
end if
.core_tabs:
.fail: ;simply return to caller
mov esp, ebp
mov bl, 14 ;#PF
ret
cmp ebx, LFB_BASE
jb .core_tabs ;таблицы страниц ядра
;Ошибка
.lfb:
;область LFB
;Ошибка
jmp .fail
align 4
.user_space:
test eax, PG_MAP
jnz .err_access ;Страница присутствует
;Ошибка доступа ?
test eax, PG_MAP
jnz .err_access ;Ñòðàíèöà ïðèñóòñòâóåò
;Îøèáêà äîñòóïà ?
shr ebx, 12
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, PG_MAP
jz .fail ;таблица страниц не создана
;неверный адрес в программе
shr ebx, 12
mov ecx, ebx
shr ecx, 10
mov edx, [master_tab+ecx*4]
test edx, PG_MAP
jz .fail ;òàáëèöà ñòðàíèö íå ñîçäàíà
;íåâåðíûé àäðåñ â ïðîãðàììå
mov eax, [page_tabs+ebx*4]
test eax, 2
jz .fail ;адрес не зарезервирован для ;
;использования. Ошибка
mov eax, [page_tabs+ebx*4]
test eax, 2
jz .fail ;àäðåñ íå çàðåçåðâèðîâàí äëÿ ;
;èñïîëüçîâàíèÿ. Îøèáêà
.alloc:
call alloc_page
test eax, eax
jz .fail
call alloc_page
test eax, eax
jz .fail
stdcall map_page,[ebp-4],eax,dword PG_UW
stdcall map_page,[.err_addr],eax,dword PG_UW
mov edi, [ebp-4]
and edi, 0xFFFFF000
mov ecx, 1024
xor eax, eax
cld
rep stosd
.exit:
mov esp, ebp
popad
add esp, 4
iretd
mov edi, [.err_addr]
and edi, 0xFFFFF000
mov ecx, 1024
xor eax, eax
;cld ;caller is duty for this
rep stosd
.exit: ;iret with repeat fault instruction
add esp,8 ; clear in stack: locals(.err_addr) + ret_to_caller
restore_ring3_context
iretd
.err_access:
.err_access = .fail
;íèêîãäà íå ïðîèñõîäèò
jmp .fail
;jmp .fail
.kernel_space:
test eax, PG_MAP
jz .fail ;страница не присутствует
test eax, PG_MAP
jz .fail ;ñòðàíèöà íå ïðèñóòñòâóåò
test eax, 4 ;U/S
jnz .fail ;приложение обратилось к памяти
;ядра
test eax, 8
jnz .fail ;установлен зарезервированный бит
;в таблицах страниц. добавлено в P4/Xeon
test eax,12 ;U/S (+below)
jnz .fail ;ïðèëîæåíèå îáðàòèëîñü ê ïàìÿòè
;ÿäðà
;test eax, 8
;jnz .fail ;óñòàíîâëåí çàðåçåðâèðîâàííûé áèò
;â òàáëèöàõ ñòðàíèö. äîáàâëåíî â P4/Xeon
;ïîïûòêà çàïèñè â çàùèù¸ííóþ ñòðàíèöó ÿäðà
cmp ebx, tss._io_map_0
jb .fail
cmp ebx, tss._io_map_0
jb .fail
cmp ebx, tss._io_map_0+8192
jae .fail
cmp ebx, tss._io_map_0+8192
jae .fail
; io permission map
; copy-on-write protection
call alloc_page
test eax, eax
jz .fail
call alloc_page
test eax, eax
jz .fail
push eax
stdcall map_page,[ebp-4],eax,dword PG_SW
pop eax
mov edi, [.err_addr]
and edi, -4096
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
push eax
stdcall map_page,[.err_addr],eax,dword PG_SW
pop eax
mov edi, [.err_addr]
and edi, -4096
lea esi, [edi+(not tss._io_map_0)+1]; -tss._io_map_0
mov ebx, esi
shr ebx, 12
mov edx, [current_slot]
or eax, PG_SW
mov [edx+APPDATA.io_map+ebx*4], eax
mov ebx, esi
shr ebx, 12
mov edx, [current_slot]
or eax, PG_SW
mov [edx+APPDATA.io_map+ebx*4], eax
add esi, [default_io_map]
mov ecx, 4096/4
cld
rep movsd
jmp .exit
;не обрабатываем. Ошибка
.core_tabs:
.fail:
mov esp, ebp
popad
add esp, 4
; iretd
save_ring3_context ;debugger support
mov bl, 14
jmp exc_c
iretd
add esi, [default_io_map]
mov ecx, 4096/4
;cld ;caller is duty for this
rep movsd
jmp .exit
endp
align 4
@ -1346,6 +1323,3 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
.fail:
ret
endp

File diff suppressed because it is too large Load Diff

View File

@ -351,47 +351,27 @@ endg
; a protected-mode interrupt handler (typically the general-protection
; exception handler, which in turn calls the virtual 8086-mode monitor).
v86_debug_exc:
pushad
xor eax, eax
mov dr6, eax
mov bl, 1
jmp v86_exc_c
v86_page_fault:
add esp, 4
pushad
mov bl, 14
jmp v86_exc_c
v86_except_16:
pushad
mov bl, 16
jmp v86_exc_c
v86_except_19:
pushad
mov bl, 19
iglobal
v86_exc_str1 db 'V86 : unexpected exception ',0
v86_exc_str2 db ' at ',0
v86_exc_str3 db ':',0
v86_exc_str4 db 13,10,'V86 : faulted code:',0
v86_exc_str5 db ' (unavailable)',0
v86_newline db 13,10,0
v86_io_str1 db 'V86 : access to disabled i/o port ',0
v86_io_byte db ' (byte)',13,10,0
v86_io_word db ' (word)',13,10,0
v86_io_dword db ' (dword)',13,10,0
v86_irqerr db 'V86 : IRQ already hooked',13,10,0
v86_exc_str1 db 'V86 : unexpected exception ',0
v86_exc_str2 db ' at ',0
v86_exc_str3 db ':',0
v86_exc_str4 db 13,10,'V86 : faulted code:',0
v86_exc_str5 db ' (unavailable)',0
v86_newline db 13,10,0
v86_io_str1 db 'V86 : access to disabled i/o port ',0
v86_io_byte db ' (byte)',13,10,0
v86_io_word db ' (word)',13,10,0
v86_io_dword db ' (dword)',13,10,0
v86_irqerr db 'V86 : IRQ already hooked',13,10,0
endg
v86_exc_c:
mov ax, app_data
mov ds, ax
mov es, ax
; Did we all that we have wanted to do?
mov eax, [esp+v86_regs.size+10h+18h]
cmp bl,1
jne @f
xor eax, eax
mov dr6, eax
@@: mov eax, [esp+v86_regs.size+10h+18h]
cmp word [esp+v86_regs.eip], ax
jnz @f
shr eax, 16

View File

@ -454,8 +454,8 @@ high_code:
; LOAD IDT
call build_interrupt_table
lidt [idtreg]
call build_interrupt_table ;lidt is executed
;lidt [idtreg]
call init_kernel_heap
stdcall kernel_alloc, RING0_STACK_SIZE+512
@ -1296,6 +1296,7 @@ display_number_force:
xor edx,edx
call division_64_bits
div ebx
hexletters = __fdo_hexdigits
add edx,hexletters
mov dl,[edx]
mov [edi],dl

View File

@ -70,9 +70,9 @@
;
; A400 -> B0FF free
; B100 -> B2FF IDT
; B100 -> B307 IDT for int_0x00..int_0x40
; B300 -> BFFF free
; B308 -> BFFF free
; C000 -> C3FF window stack C000 no of windows - all in words
; C402 -> C7FF window position in stack