VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bootsector2-test1-template.mac@ 53195

Last change on this file since 53195 was 53195, checked in by vboxsync, 10 years ago

src/ValidationKit/bootsector: Added RDTSC benchmark and improved precision a little while calculating ins/sec.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.5 KB
Line 
1; $Id: bootsector2-test1-template.mac 53195 2014-11-04 12:44:27Z 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;
35BEGINCODELOW
36BITS 16
37BEGINPROC TMPL_NM(BenchmarkCpuId_rm)
38 call TMPL_NM(Bs2IsModeSupported_rm)
39 jz .done
40 call TMPL_NM(Bs2EnterMode_rm)
41BITS 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)
87BITS 16
88.done:
89 ret
90
91.s_szTestName:
92 db TMPL_MODE_STR, ', CPUID', 0
93ENDPROC TMPL_NM(BenchmarkCpuId_rm)
94
95TMPL_BEGINCODE
96BITS TMPL_BITS
97
98
99;;
100; Run the RDTSC benchmark for this mode.
101;
102; @uses nothing
103;
104BEGINCODELOW
105BITS 16
106BEGINPROC TMPL_NM(BenchmarkRdTsc_rm)
107 call TMPL_NM(Bs2IsModeSupported_rm)
108 jz .done
109 call TMPL_NM(Bs2EnterMode_rm)
110BITS TMPL_BITS
111 push xBP
112 mov xBP, xSP
113 push sAX
114 push sBX
115 push sCX
116 push sDX
117 push sDI
118 sub sSP, 20h
119
120 ; Get the current time.
121 mov xAX, xSP
122 call TMPL_NM_CMN(GetNanoTS)
123
124 ; Do the test.
125 mov edi, TEST_INSTRUCTION_COUNT_RDTSC / 4
126.again:
127 rdtsc
128 rdtsc
129 rdtsc
130 rdtsc
131 dec edi
132 jnz .again
133
134 ; Calc the elapsed time and report the result.
135 mov xAX, xSP
136 call TMPL_NM_CMN(GetElapsedNanoTS)
137
138 mov xCX, .s_szTestName
139 mov edx, TEST_INSTRUCTION_COUNT_RDTSC
140 mov xAX, xSP
141 call TMPL_NM_CMN(ReportResult)
142
143 add sSP, 20h
144 pop sDI
145 pop sDX
146 pop sCX
147 pop sBX
148 pop sAX
149 leave
150
151 call TMPL_NM(Bs2ExitMode)
152BITS 16
153.done:
154 ret
155
156.s_szTestName:
157 db TMPL_MODE_STR, ', RDTSC', 0
158ENDPROC TMPL_NM(BenchmarkRdTsc_rm)
159
160TMPL_BEGINCODE
161BITS TMPL_BITS
162
163
164;;
165; Prologue for the I/O port tests.
166%ifndef HaveIoPortPrologue
167%define HaveIoPortPrologue
168%macro IoPortPrologue 0
169 push xBP
170 mov xBP, xSP
171 push sAX
172 push sDX
173 push sCX
174 sub xSP, 20h
175
176 ; Get the current time.
177 mov xAX, xSP
178 call TMPL_NM_CMN(GetNanoTS)
179
180 ; Do the test.
181 mov dx, VMMDEV_TESTING_IOPORT_NOP
182 mov ecx, TEST_INSTRUCTION_COUNT_IO / 5
183%endmacro
184%endif
185
186
187;;
188; Epilogue for the I/O port tests.
189%ifndef HaveIoPortEpilogue
190%define HaveIoPortEpilogue
191%macro IoPortEpilogue 0
192 ; Calc the elapsed time and report the result.
193 mov xAX, xSP
194 call TMPL_NM_CMN(GetElapsedNanoTS)
195
196 mov xCX, .s_szTestName
197 mov edx, TEST_INSTRUCTION_COUNT_IO
198 mov xAX, xSP
199 call TMPL_NM_CMN(ReportResult)
200
201 add xSP, 20h
202 pop sCX
203 pop sDX
204 pop sAX
205 leave
206 ret
207%endmacro
208%endif
209
210
211;;
212; Benchmarks: IN eax, NOP
213;
214; @uses nothing
215;
216BEGINPROC TMPL_NM(BenchmarkIoPortNop32In)
217 IoPortPrologue
218.again:
219 in eax, dx
220 in eax, dx
221 in eax, dx
222 in eax, dx
223 in eax, dx
224 dec ecx
225 jnz .again
226 IoPortEpilogue
227.s_szTestName:
228 db TMPL_MODE_STR, ', 32-bit IN', 0
229ENDPROC TMPL_NM(BenchmarkIoPortNop32In)
230
231
232;;
233; Benchmarks: OUT NOP, eax
234;
235; @uses nothing
236;
237BEGINPROC TMPL_NM(BenchmarkIoPortNop32Out)
238 IoPortPrologue
239.again:
240 out dx, eax
241 out dx, eax
242 out dx, eax
243 out dx, eax
244 out dx, eax
245 dec ecx
246 jnz .again
247 IoPortEpilogue
248.s_szTestName:
249 db TMPL_MODE_STR, ', 32-bit OUT', 0
250ENDPROC TMPL_NM(BenchmarkIoPortNop32Out)
251
252
253;;
254; Benchmarks: IN ax, NOP
255;
256; @uses nothing
257;
258BEGINPROC TMPL_NM(BenchmarkIoPortNop16In)
259 IoPortPrologue
260.again:
261 in ax, dx
262 in ax, dx
263 in ax, dx
264 in ax, dx
265 in ax, dx
266 dec ecx
267 jnz .again
268 IoPortEpilogue
269.s_szTestName:
270 db TMPL_MODE_STR, ', 16-bit IN', 0
271ENDPROC TMPL_NM(BenchmarkIoPortNop16In)
272
273
274;;
275; Benchmarks: OUT NOP, ax
276;
277; @uses nothing
278;
279BEGINPROC TMPL_NM(BenchmarkIoPortNop16Out)
280 IoPortPrologue
281.again:
282 out dx, ax
283 out dx, ax
284 out dx, ax
285 out dx, ax
286 out dx, ax
287 dec ecx
288 jnz .again
289 IoPortEpilogue
290.s_szTestName:
291 db TMPL_MODE_STR, ', 16-bit OUT', 0
292ENDPROC TMPL_NM(BenchmarkIoPortNop16Out)
293
294
295;;
296; Benchmarks: IN al, NOP
297;
298; @uses nothing
299;
300BEGINPROC TMPL_NM(BenchmarkIoPortNop8In)
301 IoPortPrologue
302.again:
303 in al, dx
304 in al, dx
305 in al, dx
306 in al, dx
307 in al, dx
308 dec ecx
309 jnz .again
310 IoPortEpilogue
311.s_szTestName:
312 db TMPL_MODE_STR, ', 8-bit IN', 0
313ENDPROC TMPL_NM(BenchmarkIoPortNop8In)
314
315
316;;
317; Benchmarks: OUT NOP, al
318;
319; @uses nothing
320;
321BEGINPROC TMPL_NM(BenchmarkIoPortNop8Out)
322 IoPortPrologue
323.again:
324 out dx, al
325 out dx, al
326 out dx, al
327 out dx, al
328 out dx, al
329 dec ecx
330 jnz .again
331 IoPortEpilogue
332.s_szTestName:
333 db TMPL_MODE_STR, ', 8-bit OUT', 0
334ENDPROC TMPL_NM(BenchmarkIoPortNop8Out)
335
336
337%undef IoPortPrologue
338%undef IoPortEpilogue
339
340
341;;
342; Run the I/O benchmarks for this mode.
343;
344; @uses nothing
345;
346BEGINCODELOW
347BITS 16
348BEGINPROC TMPL_NM(BenchmarkIoPortNop_rm)
349 call TMPL_NM(Bs2IsModeSupported_rm)
350 jz .done
351 call TMPL_NM(Bs2EnterMode_rm)
352BITS TMPL_BITS
353
354 call TMPL_NM(BenchmarkIoPortNop32In)
355 call TMPL_NM(BenchmarkIoPortNop32Out)
356%ifndef QUICK_TEST
357 call TMPL_NM(BenchmarkIoPortNop16In)
358 call TMPL_NM(BenchmarkIoPortNop16Out)
359 call TMPL_NM(BenchmarkIoPortNop8In)
360 call TMPL_NM(BenchmarkIoPortNop8Out)
361%endif
362
363 call TMPL_NM(Bs2ExitMode)
364BITS 16
365.done:
366 ret
367ENDPROC TMPL_NM(BenchmarkIoPortNop_rm)
368
369TMPL_BEGINCODE
370BITS TMPL_BITS
371
372
373
374
375;;
376; Prologue for the MMIO tests.
377%ifndef HaveMmioPrologue
378%define HaveMmioPrologue
379%macro MmioPrologue 0
380 push xBP
381 mov xBP, xSP
382 push sAX
383 push sDX
384 push sCX
385 push sBX
386 sub xSP, 20h
387
388 ; Get the current time.
389 mov xAX, xSP
390 call TMPL_NM_CMN(GetNanoTS)
391
392 ; Do the test - X million 32-bit IN instructions.
393%ifdef TMPL_16BIT
394 mov dx, ds ; save ds
395 %ifdef TMPL_RM
396 mov bx, VMMDEV_TESTING_MMIO_RM_SEL
397 mov ds, bx
398 mov ebx, VMMDEV_TESTING_MMIO_RM_OFF(VMMDEV_TESTING_MMIO_NOP)
399 %else
400 mov bx, BS2_SEL_MMIO16
401 mov ds, bx
402 mov ebx, VMMDEV_TESTING_MMIO_NOP - BS2_SEL_MMIO16_BASE
403 %endif
404%else
405 mov xBX, VMMDEV_TESTING_MMIO_NOP
406%endif
407 mov ecx, TEST_INSTRUCTION_COUNT_MMIO / 5
408%endmacro
409%endif
410
411;;
412; Epilogue for the MMIO tests.
413%ifndef HaveMmioEpilogue
414%define HaveMmioEpilogue
415%macro MmioEpilogue 0
416%ifdef TMPL_16BIT
417 mov ds, dx ; restore ds
418%endif
419
420 ; Calc the elapsed time and report the result.
421 mov xAX, xSP
422 call TMPL_NM_CMN(GetElapsedNanoTS)
423
424 mov xCX, .s_szTestName
425 mov edx, TEST_INSTRUCTION_COUNT_MMIO
426 mov xAX, xSP
427 call TMPL_NM_CMN(ReportResult)
428
429 add xSP, 20h
430 pop sBX
431 pop sCX
432 pop sDX
433 pop sAX
434 leave
435 ret
436%endmacro
437%endif
438
439
440;;
441; Benchmarks: MOV eax, [NOP]
442;
443; @uses nothing
444;
445BEGINPROC TMPL_NM(BenchmarkMmioNop32Read)
446 MmioPrologue
447.again:
448 mov eax, [sBX]
449 mov eax, [sBX]
450 mov eax, [sBX]
451 mov eax, [sBX]
452 mov eax, [sBX]
453 dec ecx
454 jnz .again
455 MmioEpilogue
456.s_szTestName:
457 db TMPL_MODE_STR, ', 32-bit read', 0
458ENDPROC TMPL_NM(BenchmarkMmioNop32Read)
459
460
461;;
462; Benchmarks: OUT NOP, eax
463;
464; @uses nothing
465;
466BEGINPROC TMPL_NM(BenchmarkMmioNop32Write)
467 MmioPrologue
468.again:
469 mov [sBX], eax
470 mov [sBX], eax
471 mov [sBX], eax
472 mov [sBX], eax
473 mov [sBX], eax
474 dec ecx
475 jnz .again
476 MmioEpilogue
477.s_szTestName:
478 db TMPL_MODE_STR, ', 32-bit write', 0
479ENDPROC TMPL_NM(BenchmarkMmioNop32Write)
480
481
482;;
483; Benchmarks: MOV ax, [NOP]
484;
485; @uses nothing
486;
487BEGINPROC TMPL_NM(BenchmarkMmioNop16Read)
488 MmioPrologue
489.again:
490 mov ax, [xBX]
491 mov ax, [xBX]
492 mov ax, [xBX]
493 mov ax, [xBX]
494 mov ax, [xBX]
495 dec ecx
496 jnz .again
497 MmioEpilogue
498.s_szTestName:
499 db TMPL_MODE_STR, ', 16-bit read', 0
500ENDPROC TMPL_NM(BenchmarkMmioNop16Read)
501
502
503;;
504; Benchmarks: OUT NOP, ax
505;
506; @uses nothing
507;
508BEGINPROC TMPL_NM(BenchmarkMmioNop16Write)
509 MmioPrologue
510.again:
511 mov [xBX], ax
512 mov [xBX], ax
513 mov [xBX], ax
514 mov [xBX], ax
515 mov [xBX], ax
516 dec ecx
517 jnz .again
518 MmioEpilogue
519.s_szTestName:
520 db TMPL_MODE_STR, ', 16-bit write', 0
521ENDPROC TMPL_NM(BenchmarkMmioNop16Write)
522
523
524;;
525; Benchmarks: MOV al, [NOP]
526;
527; @uses nothing
528;
529BEGINPROC TMPL_NM(BenchmarkMmioNop8Read)
530 MmioPrologue
531.again:
532 mov al, [xBX]
533 mov al, [xBX]
534 mov al, [xBX]
535 mov al, [xBX]
536 mov al, [xBX]
537 dec ecx
538 jnz .again
539 MmioEpilogue
540.s_szTestName:
541 db TMPL_MODE_STR, ', 8-bit read', 0
542ENDPROC TMPL_NM(BenchmarkMmioNop8Read)
543
544
545;;
546; Benchmarks: OUT NOP, al
547;
548; @uses nothing
549;
550BEGINPROC TMPL_NM(BenchmarkMmioNop8Write)
551 MmioPrologue
552.again:
553 mov [xBX], al
554 mov [xBX], al
555 mov [xBX], al
556 mov [xBX], al
557 mov [xBX], al
558 dec ecx
559 jnz .again
560 MmioEpilogue
561.s_szTestName:
562 db TMPL_MODE_STR, ', 8-bit write', 0
563ENDPROC TMPL_NM(BenchmarkMmioNop8Write)
564
565
566%undef MmioPrologue
567%undef MmioEpilogue
568
569
570;;
571; Do the MMIO tests for this mode.
572;
573; @uses nothing
574;
575BEGINCODELOW
576BITS 16
577BEGINPROC TMPL_NM(BenchmarkMmioNop_rm)
578 call TMPL_NM(Bs2IsModeSupported_rm)
579 jz .done
580 call TMPL_NM(Bs2EnterMode_rm)
581BITS TMPL_BITS
582
583 call TMPL_NM(BenchmarkMmioNop32Read)
584 call TMPL_NM(BenchmarkMmioNop32Write)
585%ifndef QUICK_TEST
586 call TMPL_NM(BenchmarkMmioNop16Read)
587 call TMPL_NM(BenchmarkMmioNop16Write)
588 call TMPL_NM(BenchmarkMmioNop8Read)
589 call TMPL_NM(BenchmarkMmioNop8Write)
590%endif
591
592 call TMPL_NM(Bs2ExitMode)
593BITS 16
594.done:
595 ret
596ENDPROC TMPL_NM(BenchmarkMmioNop_rm)
597
598TMPL_BEGINCODE
599BITS TMPL_BITS
600
601
602%include "bootsector2-template-footer.mac"
603
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette