merged trunk

git-svn-id: svn://kolibrios.org@436 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-03-28 18:04:13 +00:00
parent 7ca193f613
commit 025b91fede
5 changed files with 132 additions and 69 deletions

View File

@ -1,3 +1,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
init_fpu: init_fpu:
clts clts
@ -52,36 +58,43 @@ fpu_save:
mov edi, eax mov edi, eax
mov ecx, [fpu_owner] mov ecx, [fpu_owner]
mov eax, [CURRENT_TASK] mov esi, [CURRENT_TASK]
cmp ecx, eax cmp ecx, esi
jne .save jne .save
.copy:
shl eax, 8 call save_context
mov esi, [eax+SLOT_BASE+APPDATA.fpu_state] jmp .exit
.save:
mov [fpu_owner], esi
shl ecx, 8
mov eax, [ecx+SLOT_BASE+APPDATA.fpu_state]
call save_context
shl esi, 8
mov esi, [esi+SLOT_BASE+APPDATA.fpu_state]
mov ecx, 512/4 mov ecx, 512/4
cld cld
rep movsd rep movsd
fninit fninit
.exit:
popfd popfd
pop edi pop edi
pop esi pop esi
pop ecx pop ecx
ret ret
.save:
mov [fpu_owner], eax
shl ecx, 8
mov ecx, [ecx+SLOT_BASE+APPDATA.fpu_state]
align 4
save_context:
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
jnc .no_SSE jnc .no_SSE
fxsave [ecx] fxsave [eax]
jmp .copy ret
.no_SSE: .no_SSE:
fnsave [ecx] fnsave [eax]
jmp .copy ret
align 4 align 4
fpu_restore: fpu_restore:
@ -99,7 +112,6 @@ fpu_restore:
jne .copy jne .copy
clts clts
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
jnc .no_SSE jnc .no_SSE

View File

@ -1,3 +1,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; IRQ0 HANDLER (TIMER INTERRUPT) ;; ;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,11 +1,16 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MenuetOS process management, protected ring3 ;; ;; ;;
;; ;; ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under GPL. See file COPYING for details. ;; ;; Distributed under terms of the GNU General Public License ;;
;; Copyright 2003 Ville Turjanmaa ;; ;; ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MenuetOS process management, protected ring3 ;;
;; ;;
;; Distributed under GPL. See file COPYING for details. ;;
;; Copyright 2003 Ville Turjanmaa ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4 align 4
idtreg: idtreg:
@ -18,23 +23,18 @@ build_interrupt_table:
mov esi, sys_int mov esi, sys_int
mov ecx, 0x40 mov ecx, 0x40
@@: @@:
mov eax, [esi] lodsd
mov [edi], ax ; lower part of offset mov [edi], ax ; lower part of offset
mov [edi+2], word os_code ; segment selector mov [edi+2], word os_code ; segment selector
shr eax, 16 mov ax, word 10001110b shl 8 ; type: interrupt gate
mov [edi+4], word 10001110b shl 8 ; interrupt descriptor mov [edi+4], eax
mov [edi+6], ax
add esi, 4
add edi, 8 add edi, 8
dec ecx loop @b
jnz @b
;mov edi,8*0x40+idts+8 ;mov edi,8*0x40+idts+8
mov [edi + 0], word (i40 and ((1 shl 16)-1)) mov dword [edi], (i40 and 0xFFFF) or (os_code shl 16)
mov [edi + 2], word os_code mov dword [edi+4], (11101111b shl 8) or (i40 and 0xFFFF0000)
mov [edi + 4], word 11101110b*256 ; type: trap gate
mov [edi + 6], word (i40 shr 16)
ret ret
iglobal iglobal

View File

@ -1,3 +1,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; SYSTEM CALL ENTRY ;; ;; SYSTEM CALL ENTRY ;;
@ -6,6 +13,8 @@
align 16 align 16
i40: i40:
; diamond, 27.03.2007: handler does not require disabled interrupts
; so interrupts remain enabled when calling int 0x40
pushad pushad
cld cld
@ -22,7 +31,7 @@ i40:
mov edi, [esp+28] mov edi, [esp+28]
; 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
push eax push eax
and edi,0xff and edi,0xff
call dword [servetable+edi*4] call dword [servetable+edi*4]
@ -38,10 +47,10 @@ i40:
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
uglobal ;uglobal
times 100 db ? ;times 100 db ?
sysenter_stack: ;sysenter_stack:
endg ;endg
align 32 align 32
SYSENTER_VAR equ 0 SYSENTER_VAR equ 0
@ -54,19 +63,13 @@ sysenter_entry:
; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] ; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack]
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [ss:tss._esp0]
mov esp, [current_slot]
mov esp, [esp + APPDATA.pl0_stack]
add esp, RING0_STACK_SIZE ; configure ESP
sti sti
;------------------ ;------------------
pushad pushad
cld cld
; mov ax, word app_data
; mov ds, ax
; mov es, ax
mov eax, ebx mov eax, ebx
mov ebx, ecx mov ebx, ecx
mov ecx, edx mov ecx, edx
@ -93,8 +96,13 @@ sysenter_entry:
align 32 align 32
syscall_entry: syscall_entry:
; cli syscall clear IF ; cli syscall clear IF
xchg ecx, [esp] xchg esp, [ss:tss._esp0]
mov [SYSENTER_VAR + 4], esp push ecx
lea ecx, [esp+4]
xchg ecx, [ss:tss._esp0]
sti
push ecx
mov ecx, [ecx]
; mov [ss:sysenter_stack - 4], eax ; mov [ss:sysenter_stack - 4], eax
; mov eax, [ss:CURRENT_TASK] ; mov eax, [ss:CURRENT_TASK]
@ -103,11 +111,6 @@ syscall_entry:
; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP
; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app
mov esp, [current_slot]
mov esp, [esp + APPDATA.pl0_stack]
add esp, RING0_STACK_SIZE ; configure ESP
sti
;------------------ ;------------------
pushad pushad
cld cld
@ -131,9 +134,8 @@ syscall_entry:
popad popad
;------------------ ;------------------
cli mov ecx, [ss:esp+4]
mov esp, [SYSENTER_VAR + 4] pop esp
xchg ecx, [esp]
sysret sysret
iglobal iglobal
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -1,13 +1,54 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Kolibri OS - based on source code Menuet OS, but not 100% compatible. ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.
;; PROGRAMMING:
;; Ivan Poddubny
;; Marat Zakiyanov (Mario79)
;; VaStaNi
;; Trans
;; Mihail Semenyako (mike.dld)
;; Sergey Kuzmin (Wildwest)
;; Andrey Halyavin (halyavin)
;; Mihail Lisovin (Mihasik)
;; Andrey Ignatiev (andrew_programmer)
;; NoName
;; Evgeny Grechnikov (Diamond)
;; Iliya Mihailov (Ghost)
;; Sergey Semyonov (Serge)
;; Johnny_B
;; ;;
;; See file COPYING or GNU.TXT for details with these additional details: ;; Data in this file was originally part of MenuetOS project which is
;; - All code written in 32 bit x86 assembly language ;; distributed under the terms of GNU GPL. It is modified and redistributed as
;; - No external code (eg. bios) at process execution time ;; part of KolibriOS project under the terms of GNU GPL.
;; ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa
;; PROGRAMMING:
;; ;;
;; Compile with last version FASM ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi
;; - main os coding/design
;; Jan-Michael Brummer, BUZZ2@gmx.de
;; Felix Kaiser, info@felix-kaiser.de
;; Paolo Minazzi, paolo.minazzi@inwind.it
;; quickcode@mail.ru
;; Alexey, kgaz@crosswinds.net
;; Juan M. Caravaca, bitrider@wanadoo.es
;; kristol@nic.fi
;; Mike Hibbett, mikeh@oceanfree.net
;; Lasse Kuusijarvi, kuusijar@lut.fi
;; Jarek Pelczar, jarekp3@wp.pl
;;
;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY
;; WARRANTY. No author or distributor accepts responsibility to anyone for the
;; consequences of using it or for whether it serves any particular purpose or
;; works at all, unless he says so in writing. Refer to the GNU General Public
;; License (the "GPL") for full details.
;
;; Everyone is granted permission to copy, modify and redistribute KolibriOS,
;; but only under the conditions described in the GPL. A copy of this license
;; is supposed to have been given to you along with KolibriOS so you can know
;; your rights and responsibilities. It should be in a file named COPYING.
;; Among other things, the copyright notice and this notice must be preserved
;; on all copies.
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -22,12 +63,12 @@ max_processes equ 255
tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4
os_stack equ os_data_l-gdts ; GDTs os_stack equ (os_data_l-gdts) ; GDTs
os_code equ os_code_l-gdts os_code equ (os_code_l-gdts)
graph_data equ 3+graph_data_l-gdts graph_data equ (3+graph_data_l-gdts)
tss0 equ tss0_l-gdts tss0 equ (tss0_l-gdts)
app_code equ 3+app_code_l-gdts app_code equ (3+app_code_l-gdts)
app_data equ 3+app_data_l-gdts app_data equ (3+app_data_l-gdts)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -338,7 +379,8 @@ high_code:
mov eax, os_code mov eax, os_code
wrmsr wrmsr
mov ecx, MSR_SYSENTER_ESP mov ecx, MSR_SYSENTER_ESP
mov eax, sysenter_stack ; Check it ; mov eax, sysenter_stack ; Check it
xor eax, eax
wrmsr wrmsr
mov ecx, MSR_SYSENTER_EIP mov ecx, MSR_SYSENTER_EIP
mov eax, sysenter_entry mov eax, sysenter_entry