forked from KolibriOS/kolibrios
All exceptions use Interrupt Gate
Better FPU exception handler Code cleanups Correct save_registers for i40 handler (syscall trace) Updated memmap.inc git-svn-id: svn://kolibrios.org@6 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
bc47ee30d7
commit
2e93336e82
@ -1,62 +0,0 @@
|
||||
iglobal
|
||||
prev_user_of_fpu dd 0x1 ; set to OS
|
||||
endg
|
||||
|
||||
label fpu_tss at 0xB080
|
||||
label fpu_stack dword at 0xB060
|
||||
|
||||
|
||||
align 4
|
||||
fpu_handler:
|
||||
|
||||
; clear TS flag in CR0 -> for task switching
|
||||
clts
|
||||
|
||||
; save FPU context of the previous task
|
||||
mov eax,[prev_user_of_fpu]
|
||||
shl eax,8
|
||||
add eax,0x80000+0x10
|
||||
fsave [eax]
|
||||
|
||||
; next task switch save our FPU context
|
||||
; now restore context of current task (if exists)
|
||||
mov eax,[0x3000]
|
||||
mov [prev_user_of_fpu],eax
|
||||
shl eax,8
|
||||
add eax,0x80000
|
||||
cmp [eax+0x7f],byte 0
|
||||
je bs7_first_fpu
|
||||
frstor [eax+0x10]
|
||||
bs7_first_fpu:
|
||||
mov [eax+0x7f],byte 1
|
||||
|
||||
; prepare structure in stack for proper IRET
|
||||
movzx eax,word [fpu_tss+l.ss-tss_sceleton] ; push ss
|
||||
push eax
|
||||
mov eax,[fpu_tss+l.esp-tss_sceleton] ; push esp
|
||||
push eax
|
||||
mov eax,[fpu_tss+l.eflags-tss_sceleton] ; push eflags
|
||||
push eax
|
||||
|
||||
movzx eax,word [fpu_tss+l.cs-tss_sceleton] ; push cs
|
||||
push eax
|
||||
mov eax,[fpu_tss+l.eip-tss_sceleton] ; push eip
|
||||
push eax
|
||||
|
||||
; save eax
|
||||
push dword [fpu_tss+l.eax-tss_sceleton]
|
||||
|
||||
; restore all segment registers
|
||||
mov ax,[fpu_tss+l.es-tss_sceleton]
|
||||
mov es,ax
|
||||
mov ax,[fpu_tss+l.fs-tss_sceleton]
|
||||
mov fs,ax
|
||||
mov ax,[fpu_tss+l.gs-tss_sceleton]
|
||||
mov gs,ax
|
||||
mov ax,[fpu_tss+l.ds-tss_sceleton]
|
||||
mov ds,ax
|
||||
|
||||
; restore eax
|
||||
pop eax
|
||||
|
||||
iret
|
@ -5,23 +5,13 @@ label timer_ticks dword at 0xFDF0
|
||||
;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
|
||||
align 32
|
||||
irq0:
|
||||
|
||||
cmp [error_interrupt],-1
|
||||
je no_error_in_previous_process
|
||||
|
||||
mov edi,[error_interrupt]
|
||||
shl edi, 3
|
||||
mov [edi+tss0i_l +5], word 01010000b *256 +11101001b
|
||||
|
||||
mov edi,[error_interrupt]
|
||||
shl edi,7
|
||||
add edi,0x290000
|
||||
mov esi,[error_interrupt_entry]
|
||||
mov [edi+l.eip-tss_sceleton],esi
|
||||
mov [edi+l.eflags-tss_sceleton],dword 0x11002
|
||||
|
||||
mov [0xffff],byte 0
|
||||
|
||||
mov [error_interrupt],-1
|
||||
@ -85,13 +75,6 @@ irq0:
|
||||
|
||||
do_not_change_task:
|
||||
|
||||
;mov edx,[0x3000]
|
||||
;lea edx,[tss0sys+8*edx]
|
||||
;mov [8*0x40+idts+8+0], word 0
|
||||
;mov [8*0x40+idts+8+2],dx
|
||||
;mov [8*0x40+idts+8+4],word 11100101b*256
|
||||
;mov [8*0x40+idts+8+6], word 0
|
||||
|
||||
call _rdtsc
|
||||
mov [edi+0x18],eax
|
||||
|
||||
@ -113,6 +96,7 @@ irq0:
|
||||
.switch:
|
||||
jmp pword [0xB000]
|
||||
inc [context_counter] ;noname & halyavin
|
||||
|
||||
jmp irq0
|
||||
|
||||
iglobal
|
||||
|
@ -68,7 +68,6 @@ gdte:
|
||||
|
||||
|
||||
|
||||
; <IP 05.02.2005>
|
||||
idtreg:
|
||||
dw 8*0x41-1
|
||||
dd idts+8
|
||||
@ -76,20 +75,8 @@ idtreg:
|
||||
label idts at 0xB100-8
|
||||
;idte = idts + 8 + 0x60
|
||||
|
||||
; </IP> ; old code below:
|
||||
|
||||
|
||||
;align 32
|
||||
|
||||
;idts:
|
||||
; dw idte-$-1
|
||||
; dd idts+8
|
||||
; dw 0
|
||||
|
||||
; times 0x62 dd 0,0
|
||||
|
||||
;idte:
|
||||
|
||||
build_process_gdt_tss_pointer:
|
||||
|
||||
mov ecx,tss_data
|
||||
@ -177,44 +164,32 @@ build_interrupt_table:
|
||||
|
||||
mov edi,0
|
||||
mov edx,tss0i
|
||||
setidtl2:
|
||||
@@:
|
||||
mov [edi+idts+ 8 +0], word 0
|
||||
mov [edi+idts+ 8 +2], dx
|
||||
mov [edi+idts+ 8 +4], word 10000101b*256 ; task gate DPL=0
|
||||
; cmp edi,0x40*8
|
||||
; jne no_sw_int
|
||||
; mov [edi+idts+ 8 +4], word 11100101b*256 ; task gate DPL=3
|
||||
; no_sw_int:
|
||||
mov [edi+idts+ 8 +6], word 0
|
||||
add edx,8
|
||||
add edi,8
|
||||
|
||||
cmp edi,8*0x40 ;0x60
|
||||
jbe setidtl2 ;jb
|
||||
cmp edi,8*0x40
|
||||
jb @b
|
||||
|
||||
; <Ivan Poddubny 06.02.2005>
|
||||
; THIS CODE WON'T WORK ;-(
|
||||
; because each process's 0-level stack points to the same area
|
||||
; and if task switch occurs and another process is being interrupted
|
||||
; a stack overflow happens
|
||||
; The only way to solve that problem is to disable interrupts
|
||||
; while 0x40-handler is working
|
||||
; Then we have to make all entries in the IDT INTERRUPT gates, not TASK
|
||||
; mov edi, idts+8
|
||||
; mov esi, sys_int
|
||||
; mov ecx, 32
|
||||
; @@:
|
||||
; mov eax, [esi]
|
||||
; mov [edi], ax ; lower part of offset
|
||||
; mov [edi+2], word os_code ; segment selector
|
||||
; shr eax, 16
|
||||
; mov [edi+4], word 10001110b shl 8 ; interrupt descriptor
|
||||
; mov [edi+6], ax
|
||||
; add esi, 4
|
||||
; add edi, 8
|
||||
; dec ecx
|
||||
; jnz @b
|
||||
; </Ivan Poddubny>
|
||||
; Exceptions
|
||||
mov edi, idts+8
|
||||
mov esi, sys_int
|
||||
mov ecx, 32
|
||||
@@:
|
||||
mov eax, [esi]
|
||||
mov [edi], ax ; lower part of offset
|
||||
mov [edi+2], word os_code ; segment selector
|
||||
shr eax, 16
|
||||
mov [edi+4], word 10001110b shl 8 ; interrupt descriptor
|
||||
mov [edi+6], ax
|
||||
add esi, 4
|
||||
add edi, 8
|
||||
dec ecx
|
||||
jnz @b
|
||||
|
||||
ret
|
||||
|
||||
@ -230,32 +205,6 @@ build_syscall_interrupt_table:
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
i38:
|
||||
; load data selectors
|
||||
pushfd
|
||||
push ds es
|
||||
push eax
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
pop eax
|
||||
|
||||
pushad
|
||||
push edi
|
||||
mov edi, eax
|
||||
mov eax, ebx
|
||||
mov ebx, ecx
|
||||
mov ecx, edx
|
||||
mov esi, [esp]
|
||||
and edi, 0xFF
|
||||
call dword [servetable+edi*4]
|
||||
add esp, 4
|
||||
popad
|
||||
pop es ds
|
||||
popfd
|
||||
iret
|
||||
|
||||
|
||||
iglobal
|
||||
sys_int:
|
||||
@ -311,7 +260,9 @@ uglobal
|
||||
endg
|
||||
|
||||
s0:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x0
|
||||
mov [error_interrupt_entry],dword s0
|
||||
@ -325,7 +276,9 @@ s0:
|
||||
|
||||
|
||||
s1:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x1
|
||||
mov [error_interrupt_entry],dword s1
|
||||
@ -338,7 +291,9 @@ s1:
|
||||
jmp change_task
|
||||
|
||||
s2:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x2
|
||||
mov [error_interrupt_entry],dword s2
|
||||
@ -351,7 +306,9 @@ s2:
|
||||
jmp change_task
|
||||
|
||||
s3:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x3
|
||||
mov [error_interrupt_entry],dword s3
|
||||
@ -364,7 +321,9 @@ s3:
|
||||
jmp change_task
|
||||
|
||||
s4:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x4
|
||||
mov [error_interrupt_entry],dword s4
|
||||
@ -377,7 +336,9 @@ s4:
|
||||
jmp change_task
|
||||
|
||||
s5:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x5
|
||||
mov [error_interrupt_entry],dword s5
|
||||
@ -390,7 +351,9 @@ s5:
|
||||
jmp change_task
|
||||
|
||||
s6:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x6
|
||||
mov [error_interrupt_entry],dword s6
|
||||
@ -409,54 +372,45 @@ s6:
|
||||
|
||||
align 4
|
||||
s7:
|
||||
; <IP 05.02.2004>
|
||||
cli
|
||||
; </IP>
|
||||
mov edi, 7*8
|
||||
mov [edi+gdts+ tss0i +5], word 01010000b *256 +11101001b
|
||||
clts
|
||||
|
||||
mov edi,[0x3000]
|
||||
shl edi, 3
|
||||
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
|
||||
push eax
|
||||
push ds es
|
||||
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
; save a copy of current task's TSS to fpu_tss
|
||||
mov esi,[0x3000]
|
||||
imul esi,tss_step
|
||||
add esi,tss_data
|
||||
mov edi,fpu_tss
|
||||
mov ecx,120/4
|
||||
cld
|
||||
rep movsd
|
||||
mov eax, [prev_user_of_fpu]
|
||||
shl eax, 8
|
||||
add eax, 0x80000 + 0x10
|
||||
fsave [eax]
|
||||
|
||||
; get base address of our TSS and...
|
||||
mov esi,[0x3000]
|
||||
imul esi,tss_step
|
||||
add esi,tss_data
|
||||
mov eax, [0x3000]
|
||||
mov [prev_user_of_fpu], eax
|
||||
shl eax, 8
|
||||
add eax, 0x80000
|
||||
cmp [eax + 0x7f], byte 0
|
||||
je @f
|
||||
frstor [eax+0x10]
|
||||
@@:
|
||||
mov [eax + 0x7f], byte 1
|
||||
|
||||
; ...init segments, stack, eip, flags
|
||||
mov word [esi+l.cs-tss_sceleton],int_code
|
||||
mov word [esi+l.ss-tss_sceleton],int_data
|
||||
mov word [esi+l.ds-tss_sceleton],int_data
|
||||
mov word [esi+l.es-tss_sceleton],int_data
|
||||
mov word [esi+l.fs-tss_sceleton],int_data
|
||||
mov word [esi+l.gs-tss_sceleton],int_data
|
||||
mov dword [esi+l.esp-tss_sceleton],fpu_stack+4*8
|
||||
mov dword [esi+l.eip-tss_sceleton],fpu_handler
|
||||
mov dword [esi+l.eflags-tss_sceleton],0x11002
|
||||
pop es ds
|
||||
pop eax
|
||||
|
||||
; then execute this task
|
||||
mov ebx, [0x3000]
|
||||
shl ebx,3
|
||||
add ebx, tss0 ;t
|
||||
mov [0xB004], bx
|
||||
iret
|
||||
|
||||
jmp pword [0xB000]
|
||||
iglobal
|
||||
prev_user_of_fpu dd 1
|
||||
endg
|
||||
|
||||
jmp s7
|
||||
|
||||
s8:
|
||||
cli
|
||||
add esp, 4 ; zero on the stack!
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x8
|
||||
mov [error_interrupt_entry],dword s8
|
||||
@ -469,7 +423,9 @@ s8:
|
||||
jmp change_task
|
||||
|
||||
s9:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x9
|
||||
mov [error_interrupt_entry],dword s9
|
||||
@ -481,8 +437,12 @@ s9:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; Invalid TSS
|
||||
sa:
|
||||
cli
|
||||
add esp, 4 ; error code
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xa
|
||||
mov [error_interrupt_entry],dword sa
|
||||
@ -494,8 +454,12 @@ sa:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; Segment not present
|
||||
sb:
|
||||
cli
|
||||
add esp, 4
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xb
|
||||
mov [error_interrupt_entry],dword sb
|
||||
@ -507,8 +471,12 @@ sb:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; Stack fault exception
|
||||
sc:
|
||||
cli
|
||||
add esp, 4
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xc
|
||||
mov [error_interrupt_entry],dword sc
|
||||
@ -520,8 +488,12 @@ sc:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; General Protection Fault
|
||||
sd:
|
||||
cli
|
||||
add esp, 4
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xd
|
||||
mov [error_interrupt_entry],dword sd
|
||||
@ -533,8 +505,12 @@ sd:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; Page-Fault Exception
|
||||
se:
|
||||
cli
|
||||
add esp, 4
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xe
|
||||
mov [error_interrupt_entry],dword se
|
||||
@ -546,8 +522,11 @@ se:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; ??
|
||||
sf:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0xf
|
||||
mov [error_interrupt_entry],dword sf
|
||||
@ -559,8 +538,11 @@ sf:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; x87 FPU Floating-Point Error
|
||||
s10:
|
||||
cli
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x10
|
||||
mov [error_interrupt_entry],dword s10
|
||||
@ -572,8 +554,12 @@ s10:
|
||||
|
||||
jmp change_task
|
||||
|
||||
; Alignment Check Exception
|
||||
s11:
|
||||
cli
|
||||
add esp, 4
|
||||
mov ax, os_data
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
mov [error_interrupt],0x11
|
||||
mov [error_interrupt_entry],dword s11
|
||||
@ -585,6 +571,9 @@ s11:
|
||||
|
||||
jmp change_task
|
||||
|
||||
|
||||
|
||||
|
||||
writehex:
|
||||
|
||||
pusha
|
||||
@ -679,46 +668,9 @@ show_error_parameters:
|
||||
jmp .out_eip
|
||||
|
||||
|
||||
irq5:
|
||||
|
||||
call restore_caller
|
||||
|
||||
mov dx,word [sb16]
|
||||
add dx,0xe
|
||||
in al,dx
|
||||
|
||||
; mov byte [SB16_Status],0
|
||||
|
||||
mov [check_idle_semaphore],5
|
||||
|
||||
mov al,0x20
|
||||
out 0x20,al
|
||||
|
||||
call return_to_caller
|
||||
|
||||
jmp irq5
|
||||
|
||||
irqD:
|
||||
|
||||
call restore_caller
|
||||
|
||||
mov dx,0xf0
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov dx,0xa0
|
||||
mov al,0x20
|
||||
out dx,al
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
mov ds,cx
|
||||
mov es,cx
|
||||
mov fs,cx
|
||||
|
||||
call return_to_caller
|
||||
|
||||
jmp irqD
|
||||
; irq1 -> hid/keyboard.inc
|
||||
|
||||
p_irq2:
|
||||
|
||||
@ -843,16 +795,23 @@ p_irq12:
|
||||
|
||||
jmp p_irq12
|
||||
|
||||
p_irq13:
|
||||
|
||||
irqD:
|
||||
call restore_caller
|
||||
|
||||
mov edi,13
|
||||
call irqhandler
|
||||
mov dx,0xf0
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov dx,0xa0
|
||||
mov al,0x20
|
||||
out dx,al
|
||||
mov dx,0x20
|
||||
out dx,al
|
||||
|
||||
call return_to_caller
|
||||
|
||||
jmp p_irq13
|
||||
jmp irqD
|
||||
|
||||
|
||||
p_irq14:
|
||||
|
||||
@ -977,11 +936,9 @@ irqhandler:
|
||||
ret
|
||||
|
||||
|
||||
; this code should never get control!
|
||||
; applications can use only 0x40 interrupt
|
||||
; simply return control to interrupted process
|
||||
unknown_interrupt:
|
||||
@@: call change_task
|
||||
jmp @b
|
||||
iret
|
||||
|
||||
|
||||
|
||||
@ -1020,21 +977,6 @@ clear_application_table_status:
|
||||
|
||||
ret
|
||||
|
||||
uglobal
|
||||
old_code_0 dd 0x0
|
||||
old_code_1 dd 0x0
|
||||
|
||||
;
|
||||
|
||||
new_code_0 dd 0x0
|
||||
new_code_1 dd 0x0
|
||||
|
||||
new_data_0 dd 0x0
|
||||
new_data_1 dd 0x0
|
||||
|
||||
new_pos dd 0x0
|
||||
new_amount dd 0x0
|
||||
endg
|
||||
|
||||
|
||||
sys_resize_app_memory:
|
||||
@ -1121,10 +1063,7 @@ start_application_hd:
|
||||
jmp new_start_application_hd
|
||||
|
||||
uglobal
|
||||
;threadstring dd 0x0
|
||||
new_process_place dd 0x0
|
||||
;check_processes dd 0x0
|
||||
;dec3004 db 0x0
|
||||
app_start dd 0x0
|
||||
app_i_end dd 0x0
|
||||
app_mem dd 0x0
|
||||
@ -1132,8 +1071,6 @@ uglobal
|
||||
app_i_param dd 0x0
|
||||
app_i_icon dd 0x0
|
||||
app_mem_pos dd 0x0
|
||||
;thread_create dd 0x0
|
||||
;gdt_place dd 0x0
|
||||
appl_path dd 0x0
|
||||
appl_path_size dd 0x0
|
||||
endg
|
||||
@ -1186,8 +1123,6 @@ terminate: ; terminate application
|
||||
mov eax,esi
|
||||
call dispose_app_cr3_table
|
||||
|
||||
mov [first_gdt_search],0x2 ; start gdt search from beginning
|
||||
|
||||
cmp [prev_user_of_fpu],esi ; if user fpu last -> fpu user = 1
|
||||
jne fpu_ok_1
|
||||
mov [prev_user_of_fpu],1
|
||||
@ -1196,18 +1131,6 @@ terminate: ; terminate application
|
||||
mov [0xf400],byte 0 ; empty keyboard buffer
|
||||
mov [0xf500],byte 0 ; empty button buffer
|
||||
|
||||
; mov ecx,esi ; clear memory reserv.
|
||||
; shl ecx,3
|
||||
; mov [ecx+gdts+ app_code-3 +0],dword 0
|
||||
; mov [ecx+gdts+ app_code-3 +4],dword 0
|
||||
; mov [ecx+gdts+ app_data-3 +0],dword 0
|
||||
; mov [ecx+gdts+ app_data-3 +4],dword 0
|
||||
|
||||
mov edi, esi
|
||||
|
||||
|
||||
mov [usedi40+eax],byte 0
|
||||
|
||||
|
||||
mov ecx,esi ; remove buttons
|
||||
bnewba2:
|
||||
@ -1398,8 +1321,7 @@ terminate: ; terminate application
|
||||
|
||||
popa
|
||||
mov edi,esi ; do not run this process slot
|
||||
shl edi, 5 ;imul edi,0x20
|
||||
; add edi,0x3000
|
||||
shl edi, 5
|
||||
mov [edi+0x300A],byte 9
|
||||
; call systest
|
||||
sti ; .. and life goes on
|
||||
@ -1443,12 +1365,6 @@ endg
|
||||
|
||||
|
||||
build_scheduler:
|
||||
; { Ivan 06.03.2005
|
||||
mov edi, usedi40
|
||||
mov ecx, 256/4
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
; } Ivan 06.03.2005
|
||||
|
||||
mov esi,boot_sched_1
|
||||
call boot_log
|
||||
|
@ -4,8 +4,9 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
uglobal
|
||||
task_tss rd 1
|
||||
pushed_regs rd 1
|
||||
endg
|
||||
|
||||
align 32
|
||||
i40:
|
||||
pushad
|
||||
@ -14,45 +15,36 @@ i40:
|
||||
mov ax,word os_data
|
||||
mov ds,ax
|
||||
mov es,ax
|
||||
mov [task_tss],esp
|
||||
add dword [task_tss],4
|
||||
mov [pushed_regs],esp
|
||||
add dword [pushed_regs],4
|
||||
cli
|
||||
|
||||
mov edi,[0x3000]
|
||||
mov eax,edi
|
||||
shl edi, 3
|
||||
;clear busy flag in application's TSS
|
||||
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
|
||||
|
||||
|
||||
shl edi,5
|
||||
mov eax, [0x3000]
|
||||
mov edi, eax
|
||||
shl edi, 8
|
||||
mov [edi+0x80000+0xB0],eax ; used i40 handler
|
||||
|
||||
; for syscall trace function
|
||||
call save_registers
|
||||
|
||||
; mov esi, [0x3000]
|
||||
; imul esi, tss_step
|
||||
; add esi, tss_data
|
||||
mov esi,[task_tss]
|
||||
; sub esi,0x28
|
||||
; esi holds address of TSS of interupted program
|
||||
mov esi,[pushed_regs]
|
||||
|
||||
; load first 3 registers
|
||||
mov eax,[esi+28];+l.eax-tss_sceleton]
|
||||
mov ebx,[esi+16];l.ebx-tss_sceleton]
|
||||
mov ecx,[esi+24];l.ecx-tss_sceleton]
|
||||
mov eax,[esi+28]
|
||||
mov ebx,[esi+16]
|
||||
mov ecx,[esi+24]
|
||||
|
||||
; save current registers
|
||||
; stack may be modified by a system function to return some value to caller!
|
||||
pushad
|
||||
|
||||
; load all registers from TSS of the application, in crossed order (why?)
|
||||
mov edi,[esi+28];l.eax-tss_sceleton]
|
||||
mov eax,[esi+16];l.ebx-tss_sceleton]
|
||||
mov ebx,[esi+24];l.ecx-tss_sceleton]
|
||||
mov ecx,[esi+20];l.edx-tss_sceleton]
|
||||
mov edx,[esi+4];l.esi-tss_sceleton]
|
||||
mov esi,[esi+0];l.edi-tss_sceleton]
|
||||
mov edi,[esi+28]
|
||||
mov eax,[esi+16]
|
||||
mov ebx,[esi+24]
|
||||
mov ecx,[esi+20]
|
||||
mov edx,[esi+4]
|
||||
mov esi,[esi+0]
|
||||
|
||||
; enable interupts - a task switch or an IRQ _CAN_ interrupt i40 handler
|
||||
sti
|
||||
@ -66,16 +58,10 @@ i40:
|
||||
; return saved and probably even changed regs
|
||||
popad
|
||||
|
||||
; <Ivan 05.03.2005> esi already loaded - look above "pusha"
|
||||
;mov esi,[0x3000]
|
||||
;imul esi,tss_step
|
||||
;add esi,tss_data
|
||||
; </Ivan 05.03.2005>
|
||||
|
||||
; modify 3 program's registers (in its TSS)
|
||||
mov [esi+28],eax;[esi+l.eax-tss_sceleton], eax
|
||||
mov [esi+16],ebx;[esi+l.ebx-tss_sceleton], ebx
|
||||
mov [esi+24],ecx;[esi+l.ecx-tss_sceleton], ecx
|
||||
mov [esi+28],eax
|
||||
mov [esi+16],ebx
|
||||
mov [esi+24],ecx
|
||||
|
||||
xor eax, eax
|
||||
mov edi, [0x3000] ; no syscall interrupt in use anymore
|
||||
@ -89,36 +75,11 @@ i40:
|
||||
popad
|
||||
iretd
|
||||
|
||||
jmp i40
|
||||
|
||||
label reg1 dword at 0x6000
|
||||
label reg2 dword at 0x6400
|
||||
label usedi40 byte at 0x6800
|
||||
|
||||
uglobal
|
||||
schd dd 0x0
|
||||
endg
|
||||
|
||||
align 4
|
||||
save_registers:
|
||||
|
||||
mov esi,[0x3000]
|
||||
imul esi,tss_step
|
||||
add esi,tss_data
|
||||
|
||||
mov eax,[esi+l.eax-tss_sceleton]
|
||||
mov ebx,[esi+l.ebx-tss_sceleton]
|
||||
mov ecx,[esi+l.ecx-tss_sceleton]
|
||||
mov edx,[esi+l.edx-tss_sceleton]
|
||||
mov edi,[esi+l.edi-tss_sceleton]
|
||||
mov ebp,[esi+l.ebp-tss_sceleton]
|
||||
|
||||
mov esi,[esi+l.esi-tss_sceleton]
|
||||
|
||||
push eax ecx esi edi
|
||||
mov esi, [0x3010]
|
||||
mov eax,[esi+0x4]
|
||||
mov esi,esp
|
||||
mov eax, [esi+0x4] ; load PID
|
||||
mov esi, [pushed_regs]
|
||||
inc [save_syscall_count]
|
||||
mov edi,[save_syscall_count]
|
||||
and edi,0xF
|
||||
@ -128,7 +89,6 @@ save_registers:
|
||||
mov ecx,32 / 4
|
||||
cld
|
||||
rep movsd
|
||||
pop edi esi ecx eax
|
||||
ret
|
||||
|
||||
uglobal
|
||||
|
@ -34,7 +34,6 @@ ends fix } struct_helper name@struct
|
||||
include "core/sync.inc"
|
||||
include "core/sys32.inc" ; process management
|
||||
include "core/sched.inc" ; process scheduling
|
||||
include "core/fpu.inc" ; FPU handler
|
||||
include "core/syscall.inc" ; system call
|
||||
include "core/mem.inc" ; high-level memory management
|
||||
include "core/newproce.inc" ;new process management
|
||||
|
@ -51,12 +51,10 @@
|
||||
;
|
||||
;!!!
|
||||
; 5000 -> 5FFF save_syscall_data - syscall trace
|
||||
; 6000 -> 63FF reg1 array - for i40 (first parts of saved TSS descriptor)
|
||||
; 6400 -> 67FF reg2 array - same thing, second part
|
||||
; 6800 -> 68FF used i40 (1 if used, 0 if free), first element not used
|
||||
; 6000 -> 68FF free
|
||||
; 6900 -> 6EFF saved picture under mouse pointer
|
||||
;
|
||||
; 6F00 -> 7FFF i38 stack (4,25Kb)
|
||||
; 6F00 -> 7FFF free
|
||||
;
|
||||
; 8000 -> A3FF used FLOPPY driver
|
||||
;
|
||||
@ -65,11 +63,10 @@
|
||||
; B000 -> B005 jump address for irq0 (task switch)
|
||||
; B008 -> B00B count of ticks remaining to updating CPU usage info
|
||||
;
|
||||
; B060 -> B07F fpu error handler's stack
|
||||
; B080 -> B0FF fpu_tss -> temporary TSS for FPU context switching
|
||||
; B060 -> B0FF free
|
||||
|
||||
; B100 -> B2FF IDT
|
||||
; B300 -> BAFF tasknum array - for i40 handler
|
||||
; BB00 -> BEFF free
|
||||
; B300 -> BEFF free
|
||||
;!!!
|
||||
|
||||
; BF00 -> BFFF bytes, 1 if process running/memory in use
|
||||
@ -137,9 +134,9 @@
|
||||
; 30000 -> 36FFF basic text font II
|
||||
; 37000 -> 3BFFF basic text font I
|
||||
; 40000 -> 4FFFF data of retrieved disks and partitions (Mario79)
|
||||
; 50000 -> 500FF TSS of scheduler
|
||||
; 50000 -> 500FF free
|
||||
; 51000 -> 54000 esp0,esp1,esp2
|
||||
; 5F000 -> 5FFFF schedulers stack
|
||||
; 5F000 -> 5FFFF free
|
||||
; 60000 -> 7FFFF paging tables
|
||||
; 80000 -> 8FFFF additional app info, in 256 byte steps - 256 entries
|
||||
;
|
||||
@ -171,7 +168,7 @@
|
||||
; 284000 -> 28FFFF free
|
||||
;
|
||||
; 290000 -> 297FFF TSS's of interrupts
|
||||
; 298000 -> 29FFFF TSS's of SYSTEM interrupts - 256 entries
|
||||
; 298000 -> 29FFFF free
|
||||
; 2A0000 -> 2B00ff wav device data
|
||||
; 2C0000 -> 2C3fff button info
|
||||
;
|
||||
@ -213,7 +210,6 @@
|
||||
;
|
||||
; 800000 -> BFFFFF mapped to LFB
|
||||
;
|
||||
; C00000 -> DFFFFF * Application information
|
||||
;
|
||||
; C00000 -> C01FFF draw_data - 256 entries
|
||||
;
|
||||
@ -227,8 +223,8 @@
|
||||
; - system interrupt stacks
|
||||
; - 256 entries * 4096 step
|
||||
;
|
||||
; D20000 -> DA8000 TSS and IO map for (2048*8)=16384 ports
|
||||
; (128+2048)*256 = 557956 = 0x88000
|
||||
; D20000 -> F28000 TSS and IO map for (8192*8)=65536 ports
|
||||
; (128+8192)*256 = 557956 = 0x88000
|
||||
;
|
||||
; 1000000 -> 3FFFFFF for applications
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user