From b37db20eb6137d9585c24ee6b198a597fa09c407 Mon Sep 17 00:00:00 2001 From: "Andrey Halyavin (halyavin)" Date: Mon, 10 Oct 2005 16:57:18 +0000 Subject: [PATCH] More correct build_ru.bat and build_en.bat Now kernel uses interrupt gates for i40 handler instead of task gates. So i40 handler TSS can be removed. git-svn-id: svn://kolibrios.org@3 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/build_en.bat | 6 +-- kernel/trunk/build_ru.bat | 6 +-- kernel/trunk/core/newproce.inc | 4 +- kernel/trunk/core/sched.inc | 2 +- kernel/trunk/core/sys32.inc | 8 +-- kernel/trunk/core/syscall.inc | 94 ++++++++++++++++++++-------------- kernel/trunk/kernel.asm | 4 +- 7 files changed, 72 insertions(+), 52 deletions(-) diff --git a/kernel/trunk/build_en.bat b/kernel/trunk/build_en.bat index 3d5a306121..2a911504f5 100644 --- a/kernel/trunk/build_en.bat +++ b/kernel/trunk/build_en.bat @@ -1,4 +1,4 @@ -@if not exist lang.inc ( +@erase lang.inc @echo lang fix en >lang.inc -) -@fasm kernel.asm kernel.mnt \ No newline at end of file +@fasm kernel.asm kernel.mnt +@pause \ No newline at end of file diff --git a/kernel/trunk/build_ru.bat b/kernel/trunk/build_ru.bat index 2e05a68159..fdea9bebf6 100644 --- a/kernel/trunk/build_ru.bat +++ b/kernel/trunk/build_ru.bat @@ -1,4 +1,4 @@ -@if not exist lang.inc ( +@erase lang.inc @echo lang fix ru >lang.inc -) -@fasm kernel.asm kernel.mnt \ No newline at end of file +@fasm kernel.asm kernel.mnt +@pause \ No newline at end of file diff --git a/kernel/trunk/core/newproce.inc b/kernel/trunk/core/newproce.inc index 99644b4dbb..dccae8da4e 100644 --- a/kernel/trunk/core/newproce.inc +++ b/kernel/trunk/core/newproce.inc @@ -455,7 +455,9 @@ new_start_application_fl: mov [l.io],word 128 mov [l.eflags],dword 0x11202 mov [l.ss0],os_data - mov [l.esp0],0x55000 + shl ebx,9 + add ebx,sysint_stack_data + mov [l.esp0],ebx ; mov [l.esp1],0x56000 ; mov [l.esp2],0x57000 diff --git a/kernel/trunk/core/sched.inc b/kernel/trunk/core/sched.inc index 23962a88b3..6e38e2a50c 100644 --- a/kernel/trunk/core/sched.inc +++ b/kernel/trunk/core/sched.inc @@ -93,7 +93,7 @@ irq0: 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+2],dx ;mov [8*0x40+idts+8+4],word 11100101b*256 ;mov [8*0x40+idts+8+6], word 0 diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 095cdc3489..6c11b7b48b 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -288,10 +288,10 @@ build_syscall_interrupt_table: ;mov dx,tss0sys mov edi,8*0x40+idts+8 - mov [edi + 0], word 0 - mov [edi + 2], word tss0sys ;dx - mov [edi + 4], word 11100101b*256 - mov [edi + 6], word 0 + mov [edi + 0], word (i40 and ((1 shl 16)-1)) + mov [edi + 2], word os_code + mov [edi + 4], word 11101110b*256 + mov [edi + 6], word (i40 shr 16) mov edi,8*0x38+idts+8 mov eax, i38 diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index d6c2d187cc..b51656ddb1 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -3,9 +3,19 @@ ;; SYSTEM CALL ENTRY ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - +uglobal + task_tss rd 1 +endg align 32 i40: + pushad + + push ds + mov ax,word os_data + mov ds,ax + mov es,ax + mov [task_tss],esp + add dword [task_tss],4 cli mov edi,[0x3000] @@ -15,15 +25,15 @@ i40: mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b ;save GDT TSS entry - mov edx,[edi+tss0_l] - mov [reg1+eax*4],edx - mov edx,[edi+tss0_l+4] - mov [reg2+eax*4],edx +; mov edx,[edi+tss0_l] +; mov [reg1+eax*4],edx +; mov edx,[edi+tss0_l+4] +; mov [reg2+eax*4],edx ;and then write there i40's descriptor - mov edx,[tss0sys_l+edi] - mov [edi+tss0_l],edx - mov edx,[tss0sys_l+edi+4] - mov [edi+tss0_l+4],edx +; mov edx,[tss0sys_l+edi] +; mov [edi+tss0_l],edx +; mov edx,[tss0sys_l+edi+4] +; mov [edi+tss0_l+4],edx shl edi,5 @@ -32,26 +42,28 @@ i40: ; for syscall trace function call save_registers - mov esi, [0x3000] - imul esi, tss_step - add esi, tss_data +; 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 ; load first 3 registers - mov eax,[esi+l.eax-tss_sceleton] - mov ebx,[esi+l.ebx-tss_sceleton] - mov ecx,[esi+l.ecx-tss_sceleton] + mov eax,[esi+28];+l.eax-tss_sceleton] + mov ebx,[esi+16];l.ebx-tss_sceleton] + mov ecx,[esi+24];l.ecx-tss_sceleton] ; 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+l.eax-tss_sceleton] - mov eax,[esi+l.ebx-tss_sceleton] - mov ebx,[esi+l.ecx-tss_sceleton] - mov ecx,[esi+l.edx-tss_sceleton] - mov edx,[esi+l.esi-tss_sceleton] - mov esi,[esi+l.edi-tss_sceleton] + 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] ; enable interupts - a task switch or an IRQ _CAN_ interrupt i40 handler sti @@ -72,22 +84,22 @@ i40: ; ; modify 3 program's registers (in its TSS) - mov [esi+l.eax-tss_sceleton], eax - mov [esi+l.ebx-tss_sceleton], ebx - mov [esi+l.ecx-tss_sceleton], ecx + 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 ; calculate app's TSS address - mov ebx, [0x3000] - shl ebx, 3 - add ebx, tss0_l +; mov ebx, [0x3000] +; shl ebx, 3 +; add ebx, tss0_l - mov ecx, [0x3000] +; mov ecx, [0x3000] ; restore saved TSS descriptor - mov eax, [reg1+ecx*4] - mov [ebx], eax - mov eax, [reg2+ecx*4] - mov [ebx+4], eax +; mov eax, [reg1+ecx*4] +; mov [ebx], eax +; mov eax, [reg2+ecx*4] +; mov [ebx+4], eax xor eax, eax mov edi, [0x3000] ; no syscall interrupt in use anymore @@ -95,14 +107,20 @@ i40: mov [edi+0x80000+0xB0],eax ; clear busy flag in TSS of this handler - mov edi, [0x3000] - shl edi, 3 - mov [edi+tss0sys_l +5], word 01010000b *256 +11101001b +; mov edi, [0x3000] +; shl edi, 3 +; mov [edi+tss0sys_l +5], word 01010000b *256 +11101001b - add edi,tss0 - mov [0xB004], di +; add edi,tss0 +; mov [0xB004], di - jmp pword [0xB000] +; jmp pword [0xB000] + pop eax + mov ds,ax + mov es,ax + + popad + iretd jmp i40 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 9f15aa2b63..ed19b8a2d8 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -112,8 +112,8 @@ include "KERNEL16.INC" ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -os_data equ os_data_l-gdts ; GDTs -os_code equ os_code_l-gdts +os_data = os_data_l-gdts ; GDTs +os_code = os_code_l-gdts int_code equ int_code_l-gdts int_data equ int_data_l-gdts tss0sys equ tss0sys_l-gdts