1 | ; $Id: bootsector2-test1-template.mac 52776 2014-09-17 14:51:43Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; bootsector2 test1 - multi mode template.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2014 Oracle Corporation
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
11 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | ; General Public License (GPL) as published by the Free Software
|
---|
13 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | ;
|
---|
17 | ; The contents of this file may alternatively be used under the terms
|
---|
18 | ; of the Common Development and Distribution License Version 1.0
|
---|
19 | ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | ; VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | ; CDDL are applicable instead of those of the GPL.
|
---|
22 | ;
|
---|
23 | ; You may elect to license modified versions of this file under the
|
---|
24 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | ;
|
---|
26 |
|
---|
27 |
|
---|
28 | %include "bootsector2-template-header.mac"
|
---|
29 |
|
---|
30 | ;;
|
---|
31 | ; Run the CPUID benchmark for this mode.
|
---|
32 | ;
|
---|
33 | ; @uses nothing
|
---|
34 | ;
|
---|
35 | BEGINCODELOW
|
---|
36 | BITS 16
|
---|
37 | BEGINPROC TMPL_NM(BenchmarkCpuId_rm)
|
---|
38 | call TMPL_NM(Bs2IsModeSupported_rm)
|
---|
39 | jz .done
|
---|
40 | call TMPL_NM(Bs2EnterMode_rm)
|
---|
41 | BITS TMPL_BITS
|
---|
42 | push xBP
|
---|
43 | mov xBP, xSP
|
---|
44 | push sAX
|
---|
45 | push sBX
|
---|
46 | push sCX
|
---|
47 | push sDX
|
---|
48 | push sDI
|
---|
49 | sub sSP, 20h
|
---|
50 |
|
---|
51 | ; Get the current time.
|
---|
52 | mov xAX, xSP
|
---|
53 | call TMPL_NM_CMN(GetNanoTS)
|
---|
54 |
|
---|
55 | ; Do the test.
|
---|
56 | mov edi, TEST_INSTRUCTION_COUNT_IO / 4
|
---|
57 | .again:
|
---|
58 | mov eax, 1
|
---|
59 | cpuid
|
---|
60 | mov eax, 1
|
---|
61 | cpuid
|
---|
62 | mov eax, 1
|
---|
63 | cpuid
|
---|
64 | mov eax, 1
|
---|
65 | cpuid
|
---|
66 | dec edi
|
---|
67 | jnz .again
|
---|
68 |
|
---|
69 | ; Calc the elapsed time and report the result.
|
---|
70 | mov xAX, xSP
|
---|
71 | call TMPL_NM_CMN(GetElapsedNanoTS)
|
---|
72 |
|
---|
73 | mov xCX, .s_szTestName
|
---|
74 | mov edx, TEST_INSTRUCTION_COUNT_IO
|
---|
75 | mov xAX, xSP
|
---|
76 | call TMPL_NM_CMN(ReportResult)
|
---|
77 |
|
---|
78 | add sSP, 20h
|
---|
79 | pop sDI
|
---|
80 | pop sDX
|
---|
81 | pop sCX
|
---|
82 | pop sBX
|
---|
83 | pop sAX
|
---|
84 | leave
|
---|
85 |
|
---|
86 | call TMPL_NM(Bs2ExitMode)
|
---|
87 | BITS 16
|
---|
88 | .done:
|
---|
89 | ret
|
---|
90 |
|
---|
91 | .s_szTestName:
|
---|
92 | db TMPL_MODE_STR, ', CPUID', 0
|
---|
93 | ENDPROC TMPL_NM(BenchmarkCpuId_rm)
|
---|
94 |
|
---|
95 | TMPL_BEGINCODE
|
---|
96 | BITS TMPL_BITS
|
---|
97 |
|
---|
98 |
|
---|
99 | ;;
|
---|
100 | ; Prologue for the I/O port tests.
|
---|
101 | %ifndef HaveIoPortPrologue
|
---|
102 | %define HaveIoPortPrologue
|
---|
103 | %macro IoPortPrologue 0
|
---|
104 | push xBP
|
---|
105 | mov xBP, xSP
|
---|
106 | push sAX
|
---|
107 | push sDX
|
---|
108 | push sCX
|
---|
109 | sub xSP, 20h
|
---|
110 |
|
---|
111 | ; Get the current time.
|
---|
112 | mov xAX, xSP
|
---|
113 | call TMPL_NM_CMN(GetNanoTS)
|
---|
114 |
|
---|
115 | ; Do the test.
|
---|
116 | mov dx, VMMDEV_TESTING_IOPORT_NOP
|
---|
117 | mov ecx, TEST_INSTRUCTION_COUNT_IO / 5
|
---|
118 | %endmacro
|
---|
119 | %endif
|
---|
120 |
|
---|
121 |
|
---|
122 | ;;
|
---|
123 | ; Epilogue for the I/O port tests.
|
---|
124 | %ifndef HaveIoPortEpilogue
|
---|
125 | %define HaveIoPortEpilogue
|
---|
126 | %macro IoPortEpilogue 0
|
---|
127 | ; Calc the elapsed time and report the result.
|
---|
128 | mov xAX, xSP
|
---|
129 | call TMPL_NM_CMN(GetElapsedNanoTS)
|
---|
130 |
|
---|
131 | mov xCX, .s_szTestName
|
---|
132 | mov edx, TEST_INSTRUCTION_COUNT_IO
|
---|
133 | mov xAX, xSP
|
---|
134 | call TMPL_NM_CMN(ReportResult)
|
---|
135 |
|
---|
136 | add xSP, 20h
|
---|
137 | pop sCX
|
---|
138 | pop sDX
|
---|
139 | pop sAX
|
---|
140 | leave
|
---|
141 | ret
|
---|
142 | %endmacro
|
---|
143 | %endif
|
---|
144 |
|
---|
145 |
|
---|
146 | ;;
|
---|
147 | ; Benchmarks: IN eax, NOP
|
---|
148 | ;
|
---|
149 | ; @uses nothing
|
---|
150 | ;
|
---|
151 | BEGINPROC TMPL_NM(BenchmarkIoPortNop32In)
|
---|
152 | IoPortPrologue
|
---|
153 | .again:
|
---|
154 | in eax, dx
|
---|
155 | in eax, dx
|
---|
156 | in eax, dx
|
---|
157 | in eax, dx
|
---|
158 | in eax, dx
|
---|
159 | dec ecx
|
---|
160 | jnz .again
|
---|
161 | IoPortEpilogue
|
---|
162 | .s_szTestName:
|
---|
163 | db TMPL_MODE_STR, ', 32-bit IN', 0
|
---|
164 | ENDPROC TMPL_NM(BenchmarkIoPortNop32In)
|
---|
165 |
|
---|
166 |
|
---|
167 | ;;
|
---|
168 | ; Benchmarks: OUT NOP, eax
|
---|
169 | ;
|
---|
170 | ; @uses nothing
|
---|
171 | ;
|
---|
172 | BEGINPROC TMPL_NM(BenchmarkIoPortNop32Out)
|
---|
173 | IoPortPrologue
|
---|
174 | .again:
|
---|
175 | out dx, eax
|
---|
176 | out dx, eax
|
---|
177 | out dx, eax
|
---|
178 | out dx, eax
|
---|
179 | out dx, eax
|
---|
180 | dec ecx
|
---|
181 | jnz .again
|
---|
182 | IoPortEpilogue
|
---|
183 | .s_szTestName:
|
---|
184 | db TMPL_MODE_STR, ', 32-bit OUT', 0
|
---|
185 | ENDPROC TMPL_NM(BenchmarkIoPortNop32Out)
|
---|
186 |
|
---|
187 |
|
---|
188 | ;;
|
---|
189 | ; Benchmarks: IN ax, NOP
|
---|
190 | ;
|
---|
191 | ; @uses nothing
|
---|
192 | ;
|
---|
193 | BEGINPROC TMPL_NM(BenchmarkIoPortNop16In)
|
---|
194 | IoPortPrologue
|
---|
195 | .again:
|
---|
196 | in ax, dx
|
---|
197 | in ax, dx
|
---|
198 | in ax, dx
|
---|
199 | in ax, dx
|
---|
200 | in ax, dx
|
---|
201 | dec ecx
|
---|
202 | jnz .again
|
---|
203 | IoPortEpilogue
|
---|
204 | .s_szTestName:
|
---|
205 | db TMPL_MODE_STR, ', 16-bit IN', 0
|
---|
206 | ENDPROC TMPL_NM(BenchmarkIoPortNop16In)
|
---|
207 |
|
---|
208 |
|
---|
209 | ;;
|
---|
210 | ; Benchmarks: OUT NOP, ax
|
---|
211 | ;
|
---|
212 | ; @uses nothing
|
---|
213 | ;
|
---|
214 | BEGINPROC TMPL_NM(BenchmarkIoPortNop16Out)
|
---|
215 | IoPortPrologue
|
---|
216 | .again:
|
---|
217 | out dx, ax
|
---|
218 | out dx, ax
|
---|
219 | out dx, ax
|
---|
220 | out dx, ax
|
---|
221 | out dx, ax
|
---|
222 | dec ecx
|
---|
223 | jnz .again
|
---|
224 | IoPortEpilogue
|
---|
225 | .s_szTestName:
|
---|
226 | db TMPL_MODE_STR, ', 16-bit OUT', 0
|
---|
227 | ENDPROC TMPL_NM(BenchmarkIoPortNop16Out)
|
---|
228 |
|
---|
229 |
|
---|
230 | ;;
|
---|
231 | ; Benchmarks: IN al, NOP
|
---|
232 | ;
|
---|
233 | ; @uses nothing
|
---|
234 | ;
|
---|
235 | BEGINPROC TMPL_NM(BenchmarkIoPortNop8In)
|
---|
236 | IoPortPrologue
|
---|
237 | .again:
|
---|
238 | in al, dx
|
---|
239 | in al, dx
|
---|
240 | in al, dx
|
---|
241 | in al, dx
|
---|
242 | in al, dx
|
---|
243 | dec ecx
|
---|
244 | jnz .again
|
---|
245 | IoPortEpilogue
|
---|
246 | .s_szTestName:
|
---|
247 | db TMPL_MODE_STR, ', 8-bit IN', 0
|
---|
248 | ENDPROC TMPL_NM(BenchmarkIoPortNop8In)
|
---|
249 |
|
---|
250 |
|
---|
251 | ;;
|
---|
252 | ; Benchmarks: OUT NOP, al
|
---|
253 | ;
|
---|
254 | ; @uses nothing
|
---|
255 | ;
|
---|
256 | BEGINPROC TMPL_NM(BenchmarkIoPortNop8Out)
|
---|
257 | IoPortPrologue
|
---|
258 | .again:
|
---|
259 | out dx, al
|
---|
260 | out dx, al
|
---|
261 | out dx, al
|
---|
262 | out dx, al
|
---|
263 | out dx, al
|
---|
264 | dec ecx
|
---|
265 | jnz .again
|
---|
266 | IoPortEpilogue
|
---|
267 | .s_szTestName:
|
---|
268 | db TMPL_MODE_STR, ', 8-bit OUT', 0
|
---|
269 | ENDPROC TMPL_NM(BenchmarkIoPortNop8Out)
|
---|
270 |
|
---|
271 |
|
---|
272 | %undef IoPortPrologue
|
---|
273 | %undef IoPortEpilogue
|
---|
274 |
|
---|
275 |
|
---|
276 | ;;
|
---|
277 | ; Run the I/O benchmarks for this mode.
|
---|
278 | ;
|
---|
279 | ; @uses nothing
|
---|
280 | ;
|
---|
281 | BEGINCODELOW
|
---|
282 | BITS 16
|
---|
283 | BEGINPROC TMPL_NM(BenchmarkIoPortNop_rm)
|
---|
284 | call TMPL_NM(Bs2IsModeSupported_rm)
|
---|
285 | jz .done
|
---|
286 | call TMPL_NM(Bs2EnterMode_rm)
|
---|
287 | BITS TMPL_BITS
|
---|
288 |
|
---|
289 | call TMPL_NM(BenchmarkIoPortNop32In)
|
---|
290 | call TMPL_NM(BenchmarkIoPortNop32Out)
|
---|
291 | %ifndef QUICK_TEST
|
---|
292 | call TMPL_NM(BenchmarkIoPortNop16In)
|
---|
293 | call TMPL_NM(BenchmarkIoPortNop16Out)
|
---|
294 | call TMPL_NM(BenchmarkIoPortNop8In)
|
---|
295 | call TMPL_NM(BenchmarkIoPortNop8Out)
|
---|
296 | %endif
|
---|
297 |
|
---|
298 | call TMPL_NM(Bs2ExitMode)
|
---|
299 | BITS 16
|
---|
300 | .done:
|
---|
301 | ret
|
---|
302 | ENDPROC TMPL_NM(BenchmarkIoPortNop_rm)
|
---|
303 |
|
---|
304 | TMPL_BEGINCODE
|
---|
305 | BITS TMPL_BITS
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|
310 | ;;
|
---|
311 | ; Prologue for the MMIO tests.
|
---|
312 | %ifndef HaveMmioPrologue
|
---|
313 | %define HaveMmioPrologue
|
---|
314 | %macro MmioPrologue 0
|
---|
315 | push xBP
|
---|
316 | mov xBP, xSP
|
---|
317 | push sAX
|
---|
318 | push sDX
|
---|
319 | push sCX
|
---|
320 | push sBX
|
---|
321 | sub xSP, 20h
|
---|
322 |
|
---|
323 | ; Get the current time.
|
---|
324 | mov xAX, xSP
|
---|
325 | call TMPL_NM_CMN(GetNanoTS)
|
---|
326 |
|
---|
327 | ; Do the test - X million 32-bit IN instructions.
|
---|
328 | %ifdef TMPL_16BIT
|
---|
329 | mov dx, ds ; save ds
|
---|
330 | %ifdef TMPL_RM
|
---|
331 | mov bx, VMMDEV_TESTING_MMIO_RM_SEL
|
---|
332 | mov ds, bx
|
---|
333 | mov ebx, VMMDEV_TESTING_MMIO_RM_OFF(VMMDEV_TESTING_MMIO_NOP)
|
---|
334 | %else
|
---|
335 | mov bx, BS2_SEL_MMIO16
|
---|
336 | mov ds, bx
|
---|
337 | mov ebx, VMMDEV_TESTING_MMIO_NOP - BS2_SEL_MMIO16_BASE
|
---|
338 | %endif
|
---|
339 | %else
|
---|
340 | mov xBX, VMMDEV_TESTING_MMIO_NOP
|
---|
341 | %endif
|
---|
342 | mov ecx, TEST_INSTRUCTION_COUNT_MMIO / 5
|
---|
343 | %endmacro
|
---|
344 | %endif
|
---|
345 |
|
---|
346 | ;;
|
---|
347 | ; Epilogue for the MMIO tests.
|
---|
348 | %ifndef HaveMmioEpilogue
|
---|
349 | %define HaveMmioEpilogue
|
---|
350 | %macro MmioEpilogue 0
|
---|
351 | %ifdef TMPL_16BIT
|
---|
352 | mov ds, dx ; restore ds
|
---|
353 | %endif
|
---|
354 |
|
---|
355 | ; Calc the elapsed time and report the result.
|
---|
356 | mov xAX, xSP
|
---|
357 | call TMPL_NM_CMN(GetElapsedNanoTS)
|
---|
358 |
|
---|
359 | mov xCX, .s_szTestName
|
---|
360 | mov edx, TEST_INSTRUCTION_COUNT_MMIO
|
---|
361 | mov xAX, xSP
|
---|
362 | call TMPL_NM_CMN(ReportResult)
|
---|
363 |
|
---|
364 | add xSP, 20h
|
---|
365 | pop sBX
|
---|
366 | pop sCX
|
---|
367 | pop sDX
|
---|
368 | pop sAX
|
---|
369 | leave
|
---|
370 | ret
|
---|
371 | %endmacro
|
---|
372 | %endif
|
---|
373 |
|
---|
374 |
|
---|
375 | ;;
|
---|
376 | ; Benchmarks: MOV eax, [NOP]
|
---|
377 | ;
|
---|
378 | ; @uses nothing
|
---|
379 | ;
|
---|
380 | BEGINPROC TMPL_NM(BenchmarkMmioNop32Read)
|
---|
381 | MmioPrologue
|
---|
382 | .again:
|
---|
383 | mov eax, [sBX]
|
---|
384 | mov eax, [sBX]
|
---|
385 | mov eax, [sBX]
|
---|
386 | mov eax, [sBX]
|
---|
387 | mov eax, [sBX]
|
---|
388 | dec ecx
|
---|
389 | jnz .again
|
---|
390 | MmioEpilogue
|
---|
391 | .s_szTestName:
|
---|
392 | db TMPL_MODE_STR, ', 32-bit read', 0
|
---|
393 | ENDPROC TMPL_NM(BenchmarkMmioNop32Read)
|
---|
394 |
|
---|
395 |
|
---|
396 | ;;
|
---|
397 | ; Benchmarks: OUT NOP, eax
|
---|
398 | ;
|
---|
399 | ; @uses nothing
|
---|
400 | ;
|
---|
401 | BEGINPROC TMPL_NM(BenchmarkMmioNop32Write)
|
---|
402 | MmioPrologue
|
---|
403 | .again:
|
---|
404 | mov [sBX], eax
|
---|
405 | mov [sBX], eax
|
---|
406 | mov [sBX], eax
|
---|
407 | mov [sBX], eax
|
---|
408 | mov [sBX], eax
|
---|
409 | dec ecx
|
---|
410 | jnz .again
|
---|
411 | MmioEpilogue
|
---|
412 | .s_szTestName:
|
---|
413 | db TMPL_MODE_STR, ', 32-bit write', 0
|
---|
414 | ENDPROC TMPL_NM(BenchmarkMmioNop32Write)
|
---|
415 |
|
---|
416 |
|
---|
417 | ;;
|
---|
418 | ; Benchmarks: MOV ax, [NOP]
|
---|
419 | ;
|
---|
420 | ; @uses nothing
|
---|
421 | ;
|
---|
422 | BEGINPROC TMPL_NM(BenchmarkMmioNop16Read)
|
---|
423 | MmioPrologue
|
---|
424 | .again:
|
---|
425 | mov ax, [xBX]
|
---|
426 | mov ax, [xBX]
|
---|
427 | mov ax, [xBX]
|
---|
428 | mov ax, [xBX]
|
---|
429 | mov ax, [xBX]
|
---|
430 | dec ecx
|
---|
431 | jnz .again
|
---|
432 | MmioEpilogue
|
---|
433 | .s_szTestName:
|
---|
434 | db TMPL_MODE_STR, ', 16-bit read', 0
|
---|
435 | ENDPROC TMPL_NM(BenchmarkMmioNop16Read)
|
---|
436 |
|
---|
437 |
|
---|
438 | ;;
|
---|
439 | ; Benchmarks: OUT NOP, ax
|
---|
440 | ;
|
---|
441 | ; @uses nothing
|
---|
442 | ;
|
---|
443 | BEGINPROC TMPL_NM(BenchmarkMmioNop16Write)
|
---|
444 | MmioPrologue
|
---|
445 | .again:
|
---|
446 | mov [xBX], ax
|
---|
447 | mov [xBX], ax
|
---|
448 | mov [xBX], ax
|
---|
449 | mov [xBX], ax
|
---|
450 | mov [xBX], ax
|
---|
451 | dec ecx
|
---|
452 | jnz .again
|
---|
453 | MmioEpilogue
|
---|
454 | .s_szTestName:
|
---|
455 | db TMPL_MODE_STR, ', 16-bit write', 0
|
---|
456 | ENDPROC TMPL_NM(BenchmarkMmioNop16Write)
|
---|
457 |
|
---|
458 |
|
---|
459 | ;;
|
---|
460 | ; Benchmarks: MOV al, [NOP]
|
---|
461 | ;
|
---|
462 | ; @uses nothing
|
---|
463 | ;
|
---|
464 | BEGINPROC TMPL_NM(BenchmarkMmioNop8Read)
|
---|
465 | MmioPrologue
|
---|
466 | .again:
|
---|
467 | mov al, [xBX]
|
---|
468 | mov al, [xBX]
|
---|
469 | mov al, [xBX]
|
---|
470 | mov al, [xBX]
|
---|
471 | mov al, [xBX]
|
---|
472 | dec ecx
|
---|
473 | jnz .again
|
---|
474 | MmioEpilogue
|
---|
475 | .s_szTestName:
|
---|
476 | db TMPL_MODE_STR, ', 8-bit read', 0
|
---|
477 | ENDPROC TMPL_NM(BenchmarkMmioNop8Read)
|
---|
478 |
|
---|
479 |
|
---|
480 | ;;
|
---|
481 | ; Benchmarks: OUT NOP, al
|
---|
482 | ;
|
---|
483 | ; @uses nothing
|
---|
484 | ;
|
---|
485 | BEGINPROC TMPL_NM(BenchmarkMmioNop8Write)
|
---|
486 | MmioPrologue
|
---|
487 | .again:
|
---|
488 | mov [xBX], al
|
---|
489 | mov [xBX], al
|
---|
490 | mov [xBX], al
|
---|
491 | mov [xBX], al
|
---|
492 | mov [xBX], al
|
---|
493 | dec ecx
|
---|
494 | jnz .again
|
---|
495 | MmioEpilogue
|
---|
496 | .s_szTestName:
|
---|
497 | db TMPL_MODE_STR, ', 8-bit write', 0
|
---|
498 | ENDPROC TMPL_NM(BenchmarkMmioNop8Write)
|
---|
499 |
|
---|
500 |
|
---|
501 | %undef MmioPrologue
|
---|
502 | %undef MmioEpilogue
|
---|
503 |
|
---|
504 |
|
---|
505 | ;;
|
---|
506 | ; Do the MMIO tests for this mode.
|
---|
507 | ;
|
---|
508 | ; @uses nothing
|
---|
509 | ;
|
---|
510 | BEGINCODELOW
|
---|
511 | BITS 16
|
---|
512 | BEGINPROC TMPL_NM(BenchmarkMmioNop_rm)
|
---|
513 | call TMPL_NM(Bs2IsModeSupported_rm)
|
---|
514 | jz .done
|
---|
515 | call TMPL_NM(Bs2EnterMode_rm)
|
---|
516 | BITS TMPL_BITS
|
---|
517 |
|
---|
518 | call TMPL_NM(BenchmarkMmioNop32Read)
|
---|
519 | call TMPL_NM(BenchmarkMmioNop32Write)
|
---|
520 | %ifndef QUICK_TEST
|
---|
521 | call TMPL_NM(BenchmarkMmioNop16Read)
|
---|
522 | call TMPL_NM(BenchmarkMmioNop16Write)
|
---|
523 | call TMPL_NM(BenchmarkMmioNop8Read)
|
---|
524 | call TMPL_NM(BenchmarkMmioNop8Write)
|
---|
525 | %endif
|
---|
526 |
|
---|
527 | call TMPL_NM(Bs2ExitMode)
|
---|
528 | BITS 16
|
---|
529 | .done:
|
---|
530 | ret
|
---|
531 | ENDPROC TMPL_NM(BenchmarkMmioNop_rm)
|
---|
532 |
|
---|
533 | TMPL_BEGINCODE
|
---|
534 | BITS TMPL_BITS
|
---|
535 |
|
---|
536 |
|
---|
537 | %include "bootsector2-template-footer.mac"
|
---|
538 |
|
---|