Rev 398 | Rev 1029 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 398 | Rev 477 | ||
---|---|---|---|
1 | ; |
1 | ; |
2 | ; Kolibri Fast Calls test |
2 | ; Kolibri Fast Calls test |
3 | ; |
3 | ; |
4 | ; Compile with FASM for Kolibri |
4 | ; Compile with FASM for Kolibri |
5 | ; |
5 | ; |
6 | ; |
6 | ; |
7 | SYSENTER_VAR equ 0 |
- | |
8 | use32 |
7 | use32 |
9 | org 0x0 |
8 | org 0x0 |
10 | db 'MENUET01' |
9 | db 'MENUET01' |
11 | dd 0x01 |
10 | dd 0x01 |
12 | dd START |
11 | dd START |
13 | dd I_END |
12 | dd I_END |
14 | dd 0x1000 |
13 | dd 0x1000 |
15 | dd 0x1000 |
14 | dd 0x1000 |
16 | dd 0x0, 0x0 |
15 | dd 0x0, 0x0 |
17 | 16 | ||
18 | include 'macros.inc' |
17 | include 'macros.inc' |
19 | include 'debug.inc' |
18 | include 'debug.inc' |
20 | 19 | ||
21 | START: print 'Please wait' |
20 | START: print 'Please wait' |
22 | ; ÷åðåç áûñòðûé âûçîâ (SYSENTER) |
21 | ; ÷åðåç áûñòðûé âûçîâ (SYSENTER) |
- | 22 | __CPU_type equ p6 |
|
23 | test1: mov eax, 1 |
23 | test1: mov eax, 1 |
24 | cpuid |
24 | cpuid |
25 | test edx, 0x800 |
25 | test edx, 0x800 |
26 | jnz .ok |
26 | jnz .ok |
27 | dps 'unsupported ' |
27 | dps 'unsupported ' |
28 | jmp .end |
28 | jmp .end |
29 | .ok: |
29 | .ok: |
30 | xor eax, eax |
30 | xor eax, eax |
31 | cpuid |
31 | cpuid |
32 | rdtsc |
32 | rdtsc |
33 | mov [old_tsc], eax |
33 | mov [old_tsc], eax |
34 | mov [old_tsc + 4], edx |
34 | mov [old_tsc + 4], edx |
35 | 35 | ||
36 | mov ebx, 0x100000 |
36 | mov ebx, 0x100000 |
37 | mov dword[SYSENTER_VAR], .ret_p |
- | |
38 | mov [SYSENTER_VAR + 4], esp |
- | |
39 | align 32 |
37 | align 32 |
40 | .nxt: mov eax, 19 ; ôóíêöèÿ ïóñòûøêà |
38 | .nxt: mcall 19 ; ôóíêöèÿ ïóñòûøêà |
41 | sysenter ; ïîðòÿòñÿ ecx, edx |
39 | ; ïîðòÿòñÿ ecx, edx |
42 | .ret_p: dec ebx |
40 | dec ebx |
43 | jnz .nxt |
41 | jnz .nxt |
44 | 42 | ||
45 | xor eax, eax |
43 | xor eax, eax |
46 | cpuid |
44 | cpuid |
47 | rdtsc |
45 | rdtsc |
48 | cmp eax, [old_tsc] |
46 | cmp eax, [old_tsc] |
49 | jnb @f |
47 | jnb @f |
50 | dec edx |
48 | dec edx |
51 | @@: sub eax, [old_tsc] |
49 | @@: sub eax, [old_tsc] |
52 | sub edx, [old_tsc + 4] |
50 | sub edx, [old_tsc + 4] |
53 | debug_print_hex edx |
51 | debug_print_hex edx |
54 | debug_print_hex eax |
52 | debug_print_hex eax |
55 | .end: print ' <- Fast call (SYSENTER)' |
53 | .end: print ' <- Fast call (SYSENTER)' |
56 | 54 | ||
57 | ;---------------------------------------------- |
55 | ;---------------------------------------------- |
58 | ; ÷åðåç áûñòðûé âûçîâ (SYSCALL) |
56 | ; ÷åðåç áûñòðûé âûçîâ (SYSCALL) |
- | 57 | __CPU_type equ k6 |
|
59 | test2: xor eax, eax |
58 | test2: xor eax, eax |
60 | cpuid |
59 | cpuid |
61 | cmp ecx, "cAMD" |
60 | cmp ecx, "cAMD" |
62 | je .ok |
61 | je .ok |
63 | .nf: dps 'unsupported ' |
62 | .nf: dps 'unsupported ' |
64 | jmp .end |
63 | jmp .end |
65 | .ok: mov eax, 0x80000001 |
64 | .ok: mov eax, 0x80000001 |
66 | cpuid |
65 | cpuid |
67 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
66 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
68 | jz .nf |
67 | jz .nf |
69 | 68 | ||
70 | xor eax, eax |
69 | xor eax, eax |
71 | cpuid |
70 | cpuid |
72 | rdtsc |
71 | rdtsc |
73 | mov [old_tsc], eax |
72 | mov [old_tsc], eax |
74 | mov [old_tsc + 4], edx |
73 | mov [old_tsc + 4], edx |
75 | 74 | ||
76 | mov ebx, 0x100000 |
75 | mov ebx, 0x100000 |
77 | align 32 |
76 | align 32 |
78 | .nxt: mov eax, 19 |
77 | .nxt: mcall 19 ; ôóíêöèÿ ïóñòûøêà |
79 | push ecx |
- | |
80 | syscall |
- | |
81 | pop ecx |
- | |
82 | 78 | ||
83 | .ret_p: dec ebx |
79 | dec ebx |
84 | jnz .nxt |
80 | jnz .nxt |
85 | 81 | ||
86 | xor eax, eax |
82 | xor eax, eax |
87 | cpuid |
83 | cpuid |
88 | rdtsc |
84 | rdtsc |
89 | cmp eax, [old_tsc] |
85 | cmp eax, [old_tsc] |
90 | jnb @f |
86 | jnb @f |
91 | dec edx |
87 | dec edx |
92 | @@: sub eax, [old_tsc] |
88 | @@: sub eax, [old_tsc] |
93 | sub edx, [old_tsc + 4] |
89 | sub edx, [old_tsc + 4] |
94 | debug_print_hex edx |
90 | debug_print_hex edx |
95 | debug_print_hex eax |
91 | debug_print_hex eax |
96 | .end: print ' <- Fast call (SYSCALL)' |
92 | .end: print ' <- Fast call (SYSCALL)' |
97 | ;---------------------------------------------- |
93 | ;---------------------------------------------- |
98 | ; ÷åðåç øëþç ïðåðûâàíèÿ |
94 | ; ÷åðåç øëþç ïðåðûâàíèÿ |
- | 95 | __CPU_type equ p5 |
|
99 | xor eax, eax |
96 | xor eax, eax |
100 | cpuid |
97 | cpuid |
101 | rdtsc |
98 | rdtsc |
102 | mov [old_tsc], eax |
99 | mov [old_tsc], eax |
103 | mov [old_tsc + 4], edx |
100 | mov [old_tsc + 4], edx |
104 | 101 | ||
105 | test3: mov ebx, 0x100000 |
102 | test3: mov ebx, 0x100000 |
106 | align 32 |
103 | align 32 |
107 | .nxt: mov eax, 19 ; ôóíêöèÿ ïóñòûøêà |
104 | .nxt: mcall 19 ; ôóíêöèÿ ïóñòûøêà |
108 | int 0x40 |
- | |
109 | dec ebx |
105 | dec ebx |
110 | jnz .nxt |
106 | jnz .nxt |
111 | 107 | ||
112 | xor eax, eax |
108 | xor eax, eax |
113 | cpuid |
109 | cpuid |
114 | rdtsc |
110 | rdtsc |
115 | cmp eax, [old_tsc] |
111 | cmp eax, [old_tsc] |
116 | jnb @f |
112 | jnb @f |
117 | dec edx |
113 | dec edx |
118 | @@: sub eax, [old_tsc] |
114 | @@: sub eax, [old_tsc] |
119 | sub edx, [old_tsc + 4] |
115 | sub edx, [old_tsc + 4] |
120 | debug_print_hex edx |
116 | debug_print_hex edx |
121 | debug_print_hex eax |
117 | debug_print_hex eax |
122 | print ' <- Interrupt' |
118 | print ' <- Interrupt' |
123 | - | ||
124 | call show_alive |
119 | |
125 | mov eax, -1 |
- | |
126 | int 0x40 |
120 | mcall -1 |
127 | ;--------------------------------------------- |
- | |
128 | show_alive: |
- | |
129 | ; ÷åðåç áûñòðûé âûçîâ, íàñòðàèâàåì ðåãèñòðû äëÿ âîçâðàòà |
- | |
130 | mov eax, 63 |
- | |
131 | mov ebx, 1 |
- | |
132 | mov esi, msg_Ok |
- | |
133 | .nxt: mov cl, [esi] |
- | |
134 | test cl, cl |
- | |
135 | jz .end |
- | |
136 | - | ||
137 | mov dword[SYSENTER_VAR], .ret_p |
- | |
138 | mov [SYSENTER_VAR + 4], esp |
- | |
139 | sysenter ; ïîðòÿòñÿ ecx, edx |
- | |
140 | - | ||
141 | .ret_p: inc esi |
- | |
142 | jmp .nxt |
- | |
143 | .end: ret |
- | |
144 | ; ÷åðåç øëþç ïðåðûâàíèÿ |
- | |
145 | ; mov eax, 63 |
- | |
146 | ; mov ebx, 1 |
- | |
147 | ; mov esi, msg_Ok |
- | |
148 | ; @@: mov cl, [esi] |
- | |
149 | ; test cl, cl |
- | |
150 | ; jz @f |
- | |
151 | - | ||
152 | ; int 0x40 |
- | |
153 | - | ||
154 | ; inc esi |
- | |
155 | ; jmp @b |
- | |
156 | ; @@: ret |
- | |
157 | - | ||
158 | 121 | ;--------------------------------------------- |
|
159 | old_tsc: dd 0, 0 |
- | |
160 | - | ||
161 | msg_Ok db 'Alive!', 10, 13, 0 |
122 | old_tsc: dd 0, 0 |
162 | I_END:->->-> |
123 | I_END:->->-> |