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