Rev 398 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
375 | Ghost | 1 | ; |
2 | ; Kolibri Fast Calls test |
||
3 | ; |
||
4 | ; Compile with FASM for Kolibri |
||
5 | ; |
||
6 | ; |
||
7 | use32 |
||
8 | org 0x0 |
||
9 | db 'MENUET01' |
||
10 | dd 0x01 |
||
11 | dd START |
||
12 | dd I_END |
||
13 | dd 0x1000 |
||
14 | dd 0x1000 |
||
15 | dd 0x0, 0x0 |
||
16 | |||
17 | include 'macros.inc' |
||
18 | include 'debug.inc' |
||
19 | |||
398 | Ghost | 20 | START: print 'Please wait' |
21 | ; через быстрый вызов (SYSENTER) |
||
477 | Ghost | 22 | __CPU_type equ p6 |
398 | Ghost | 23 | test1: mov eax, 1 |
24 | cpuid |
||
25 | test edx, 0x800 |
||
26 | jnz .ok |
||
27 | dps 'unsupported ' |
||
28 | jmp .end |
||
29 | .ok: |
||
375 | Ghost | 30 | xor eax, eax |
31 | cpuid |
||
32 | rdtsc |
||
33 | mov [old_tsc], eax |
||
34 | mov [old_tsc + 4], edx |
||
35 | |||
398 | Ghost | 36 | mov ebx, 0x100000 |
375 | Ghost | 37 | align 32 |
477 | Ghost | 38 | .nxt: mcall 19 ; функция пустышка |
39 | ; портятся ecx, edx |
||
40 | dec ebx |
||
375 | Ghost | 41 | jnz .nxt |
42 | |||
43 | xor eax, eax |
||
44 | cpuid |
||
45 | rdtsc |
||
46 | cmp eax, [old_tsc] |
||
47 | jnb @f |
||
48 | dec edx |
||
49 | @@: sub eax, [old_tsc] |
||
50 | sub edx, [old_tsc + 4] |
||
51 | debug_print_hex edx |
||
52 | debug_print_hex eax |
||
398 | Ghost | 53 | .end: print ' <- Fast call (SYSENTER)' |
375 | Ghost | 54 | |
398 | Ghost | 55 | ;---------------------------------------------- |
56 | ; через быстрый вызов (SYSCALL) |
||
477 | Ghost | 57 | __CPU_type equ k6 |
398 | Ghost | 58 | test2: xor eax, eax |
59 | cpuid |
||
60 | cmp ecx, "cAMD" |
||
61 | je .ok |
||
62 | .nf: dps 'unsupported ' |
||
63 | jmp .end |
||
64 | .ok: mov eax, 0x80000001 |
||
65 | cpuid |
||
66 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
||
67 | jz .nf |
||
375 | Ghost | 68 | |
69 | xor eax, eax |
||
70 | cpuid |
||
71 | rdtsc |
||
72 | mov [old_tsc], eax |
||
73 | mov [old_tsc + 4], edx |
||
398 | Ghost | 74 | |
75 | mov ebx, 0x100000 |
||
375 | Ghost | 76 | align 32 |
477 | Ghost | 77 | .nxt: mcall 19 ; функция пустышка |
398 | Ghost | 78 | |
477 | Ghost | 79 | dec ebx |
398 | Ghost | 80 | jnz .nxt |
81 | |||
82 | xor eax, eax |
||
83 | cpuid |
||
84 | rdtsc |
||
85 | cmp eax, [old_tsc] |
||
86 | jnb @f |
||
87 | dec edx |
||
88 | @@: sub eax, [old_tsc] |
||
89 | sub edx, [old_tsc + 4] |
||
90 | debug_print_hex edx |
||
91 | debug_print_hex eax |
||
92 | .end: print ' <- Fast call (SYSCALL)' |
||
93 | ;---------------------------------------------- |
||
94 | ; через шлюз прерывания |
||
477 | Ghost | 95 | __CPU_type equ p5 |
398 | Ghost | 96 | xor eax, eax |
97 | cpuid |
||
98 | rdtsc |
||
99 | mov [old_tsc], eax |
||
100 | mov [old_tsc + 4], edx |
||
101 | |||
102 | test3: mov ebx, 0x100000 |
||
103 | align 32 |
||
477 | Ghost | 104 | .nxt: mcall 19 ; функция пустышка |
375 | Ghost | 105 | dec ebx |
106 | jnz .nxt |
||
107 | |||
108 | xor eax, eax |
||
109 | cpuid |
||
110 | rdtsc |
||
111 | cmp eax, [old_tsc] |
||
112 | jnb @f |
||
113 | dec edx |
||
114 | @@: sub eax, [old_tsc] |
||
115 | sub edx, [old_tsc + 4] |
||
116 | debug_print_hex edx |
||
117 | debug_print_hex eax |
||
118 | print ' <- Interrupt' |
||
119 | |||
477 | Ghost | 120 | mcall -1 |
375 | Ghost | 121 | ;--------------------------------------------- |
122 | old_tsc: dd 0, 0 |
||
123 | I_END:->->-> |