Fast System Call

Currently it only for kernel developing
See : http://meos.sysbin.com/viewtopic.php?t=662

git-svn-id: svn://kolibrios.org@375 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Iliya Mihailov (Ghost)
2007-02-25 14:20:50 +00:00
parent 72fe949f6f
commit b07dfce332
7 changed files with 695 additions and 26 deletions

View File

@@ -166,10 +166,10 @@ end if
use32
include 'unpacker.inc'
__DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1
include 'debug-fdo.inc'
__DEBUG__ fix 1
__DEBUG_LEVEL__ fix 1
include 'debug-fdo.inc'
iglobal
boot_memdetect db 'Determining amount of memory',0
@@ -370,6 +370,49 @@ B32:
; btr [cpu_caps], CAPS_PGE ;test: don't use global pages
; btr [cpu_caps], CAPS_MTRR ;test: don't use MTRR
bts [cpu_caps], CAPS_TSC ;force use rdtsc
; -------- Fast System Call init ----------
; Intel SYSENTER/SYSEXIT (AMD CPU support it too)
bt [cpu_caps], CAPS_SEP
jnc .SEnP ; SysEnter not Present
xor edx, edx
mov ecx, MSR_SYSENTER_CS
mov eax, os_code
wrmsr
mov ecx, MSR_SYSENTER_ESP
mov eax, sysenter_stack ; Check it
wrmsr
mov ecx, MSR_SYSENTER_EIP
mov eax, sysenter_entry
wrmsr
.SEnP:
; AMD SYSCALL/SYSRET
cmp byte[cpu_vendor], 'A'
jne .noSYSCALL
mov eax, 0x80000001
cpuid
test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support
jz .noSYSCALL
mov ecx, MSR_AMD_EFER
rdmsr
or eax, 1 ; bit_0 - System Call Extension (SCE)
wrmsr
; !!!! It`s dirty hack, fix it !!!
; Bits of EDX :
; Bit 31<33>16 During the SYSRET instruction, this field is copied into the CS register
; and the contents of this field, plus 8, are copied into the SS register.
; Bit 15<31>0 During the SYSCALL instruction, this field is copied into the CS register
; and the contents of this field, plus 8, are copied into the SS register.
; mov edx, (os_code + 16) * 65536 + os_code
mov edx, 0x1B0013
mov eax, syscall_entry
mov ecx, MSR_AMD_STAR
wrmsr
.noSYSCALL:
; -----------------------------------------
; MEMORY MODEL
call mem_test
@@ -4826,7 +4869,9 @@ read_from_hd: ; Read from hd - fn not in use
ret
align 4
paleholder:
ret
; --------------- APM ---------------------
apm_entry dp 0
apm_vf dd 0
@@ -5019,10 +5064,10 @@ iglobal
syslang dd 0x1
endg
if __DEBUG__ eq 1
include_debug_strings
end if
if __DEBUG__ eq 1
include_debug_strings
end if
IncludeIGlobals
endofcode:
IncludeUGlobals