diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 76dc8a7b1..430b0afb9 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -48,26 +48,14 @@ i40: ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;uglobal -;times 100 db ? -;sysenter_stack: -;endg - align 32 -SYSENTER_VAR equ 0 sysenter_entry: ; Настраиваем стек - ; cli sysenter clear IF - ; push eax - ; mov eax, [ss:CURRENT_TASK] - ; shl eax, 8 - ; mov eax, [ss:SLOT_BASE + eax + APPDATA.pl0_stack] - ; lea esp, [eax + RING0_STACK_SIZE] ; configure ESP - ; mov eax, [ss:sysenter_stack - 4] ; eax - original eax, from app mov esp, [ss:tss._esp0] - sti - ;------------------ + push ebp ; save app esp + 4 + mov ebp, [ebp] ; ebp - original ebp + ;------------------ pushad cld @@ -85,8 +73,13 @@ sysenter_entry: popad ;------------------ - mov edx, [SYSENTER_VAR] ; eip - mov ecx, [SYSENTER_VAR + 4] ; esp + xchg ecx, [ss:esp] ; в вершин стека - app ecx, ecx - app esp + 4 + sub ecx, 4 + xchg edx, [ecx] ; edx - return point, & save original edx + push edx + mov edx, [ss:esp + 4] + mov [ecx + 4], edx ; save original ecx + pop edx sysexit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 597099f92..22dafe95b 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -3298,12 +3298,24 @@ ret wrmsr_instr: ;now counter in ecx ;(edx:eax) esi:edi => edx:esi -mov eax,esi -wrmsr -mov [esp+36],eax -mov [esp+24],edx ;ret in ebx? + ; Fast Call MSR can't be destroy + ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш + ; включаются/выключаются расширенные возможности + cmp ecx, MSR_SYSENTER_CS + je @f + cmp ecx, MSR_SYSENTER_ESP + je @f + cmp ecx, MSR_SYSENTER_EIP + je @f + cmp ecx, MSR_AMD_STAR + je @f + + mov eax, esi + wrmsr +@@: ret + cache_disable: mov eax,cr0 or eax,01100000000000000000000000000000b diff --git a/programs/develop/fast_call_test/MACROS.INC b/programs/develop/fast_call_test/MACROS.INC index 58209dc4c..d9f50ae7f 100644 --- a/programs/develop/fast_call_test/MACROS.INC +++ b/programs/develop/fast_call_test/MACROS.INC @@ -129,16 +129,42 @@ macro __mov reg,a { ; mike.dld end if } -macro mcall a,b,c,d,e,f { ; mike.dld +__CPU_type equ p5 +SYSENTER_VAR equ 0 + +macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls + local ..ret_point __mov eax,a __mov ebx,b __mov ecx,c __mov edx,d __mov esi,e __mov edi,f - int 0x40 -} + if __CPU_type eq p5 + int 0x40 + else + if __CPU_type eq p6 + push ebp + mov ebp, esp + push ..ret_point ; it may be 2 or 5 byte + sysenter + ..ret_point: + pop edx + pop ecx + + else + if __CPU_type eq k6 + push ecx + syscall + pop ecx + else + display 'ERROR : unknown CPU type' + int 0x40 + end if + end if + end if +} ; language for programs @@ -263,4 +289,4 @@ EVM_EXIT = 1000b EVM_BACKGROUND = 10000b EVM_MOUSE = 100000b EVM_IPC = 1000000b -EVM_STACK = 10000000b \ No newline at end of file +EVM_STACK = 10000000b diff --git a/programs/develop/fast_call_test/test.ASM b/programs/develop/fast_call_test/test.ASM index 90b0dbf71..7a7921999 100644 --- a/programs/develop/fast_call_test/test.ASM +++ b/programs/develop/fast_call_test/test.ASM @@ -4,7 +4,6 @@ ; Compile with FASM for Kolibri ; ; -SYSENTER_VAR equ 0 use32 org 0x0 db 'MENUET01' @@ -20,6 +19,7 @@ include 'debug.inc' START: print 'Please wait' ; через быстрый вызов (SYSENTER) + __CPU_type equ p6 test1: mov eax, 1 cpuid test edx, 0x800 @@ -34,12 +34,10 @@ test1: mov eax, 1 mov [old_tsc + 4], edx mov ebx, 0x100000 - mov dword[SYSENTER_VAR], .ret_p - mov [SYSENTER_VAR + 4], esp align 32 -.nxt: mov eax, 19 ; функция пустышка - sysenter ; портятся ecx, edx -.ret_p: dec ebx +.nxt: mcall 19 ; функция пустышка + ; портятся ecx, edx + dec ebx jnz .nxt xor eax, eax @@ -56,6 +54,7 @@ test1: mov eax, 1 ;---------------------------------------------- ; через быстрый вызов (SYSCALL) + __CPU_type equ k6 test2: xor eax, eax cpuid cmp ecx, "cAMD" @@ -75,12 +74,9 @@ test2: xor eax, eax mov ebx, 0x100000 align 32 -.nxt: mov eax, 19 - push ecx - syscall - pop ecx +.nxt: mcall 19 ; функция пустышка -.ret_p: dec ebx + dec ebx jnz .nxt xor eax, eax @@ -96,6 +92,7 @@ test2: xor eax, eax .end: print ' <- Fast call (SYSCALL)' ;---------------------------------------------- ; через шлюз прерывания + __CPU_type equ p5 xor eax, eax cpuid rdtsc @@ -104,8 +101,7 @@ test2: xor eax, eax test3: mov ebx, 0x100000 align 32 -.nxt: mov eax, 19 ; функция пустышка - int 0x40 +.nxt: mcall 19 ; функция пустышка dec ebx jnz .nxt @@ -121,42 +117,7 @@ test3: mov ebx, 0x100000 debug_print_hex eax print ' <- Interrupt' - call show_alive - mov eax, -1 - int 0x40 + mcall -1 ;--------------------------------------------- -show_alive: - ; через быстрый вызов, настраиваем регистры для возврата - mov eax, 63 - mov ebx, 1 - mov esi, msg_Ok -.nxt: mov cl, [esi] - test cl, cl - jz .end - - mov dword[SYSENTER_VAR], .ret_p - mov [SYSENTER_VAR + 4], esp - sysenter ; портятся ecx, edx - -.ret_p: inc esi - jmp .nxt -.end: ret - ; через шлюз прерывания - ; mov eax, 63 - ; mov ebx, 1 - ; mov esi, msg_Ok -; @@: mov cl, [esi] - ; test cl, cl - ; jz @f - - ; int 0x40 - - ; inc esi - ; jmp @b -; @@: ret - - old_tsc: dd 0, 0 - -msg_Ok db 'Alive!', 10, 13, 0 I_END: \ No newline at end of file diff --git a/programs/system/pcidev/trunk/build.bat b/programs/system/pcidev/trunk/build.bat new file mode 100644 index 000000000..267e63ea1 --- /dev/null +++ b/programs/system/pcidev/trunk/build.bat @@ -0,0 +1,2 @@ +@fasm pcidev.asm pcidev +@pause \ No newline at end of file diff --git a/programs/system/pcidev/trunk/build_en.bat b/programs/system/pcidev/trunk/build_en.bat deleted file mode 100644 index fd0694190..000000000 --- a/programs/system/pcidev/trunk/build_en.bat +++ /dev/null @@ -1,4 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm pcidev.asm pcidev -@pause \ No newline at end of file diff --git a/programs/system/pcidev/trunk/build_ge.bat b/programs/system/pcidev/trunk/build_ge.bat deleted file mode 100644 index 65c8782e8..000000000 --- a/programs/system/pcidev/trunk/build_ge.bat +++ /dev/null @@ -1,4 +0,0 @@ -@erase lang.inc -@echo lang fix ge >lang.inc -@fasm pcidev.asm pcidev -@pause \ No newline at end of file