VirtualBox

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

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

Test I/O and MMIO performance when we need to go to ring-3 to service the request.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.6 KB
Line 
1; $Id: bootsector2-test1-template.mac 53625 2014-12-31 15:33:55Z vboxsync $
2;; @file
3; bootsector2 test1 - multi mode template.
4;
5
6;
7; Copyright (C) 2007-2015 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 2
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, %2
182 mov ecx, (%1) / 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 1
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, (%1)
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
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 TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_IOPORT_NOP
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 TEST_INSTRUCTION_COUNT_IO
332.s_szTestName:
333 db TMPL_MODE_STR, ', 8-bit OUT', 0
334ENDPROC TMPL_NM(BenchmarkIoPortNop8Out)
335
336
337;;
338; Benchmarks: IN eax, NOP_R3
339;
340; @uses nothing
341;
342BEGINPROC TMPL_NM(BenchmarkIoPortRing3Nop32In)
343 IoPortPrologue TEST_INSTRUCTION_COUNT_IO / 4, VMMDEV_TESTING_IOPORT_NOP_R3
344.again:
345 in eax, dx
346 in eax, dx
347 in eax, dx
348 in eax, dx
349 in eax, dx
350 dec ecx
351 jnz .again
352 IoPortEpilogue TEST_INSTRUCTION_COUNT_IO / 4
353.s_szTestName:
354 db TMPL_MODE_STR, ', 32-bit IN-to-ring-3', 0
355ENDPROC TMPL_NM(BenchmarkIoPortRing3Nop32In)
356
357
358;;
359; Benchmarks: OUT NOP_R3, eax
360;
361; @uses nothing
362;
363BEGINPROC TMPL_NM(BenchmarkIoPortRing3Nop32Out)
364 IoPortPrologue TEST_INSTRUCTION_COUNT_IO / 4, VMMDEV_TESTING_IOPORT_NOP_R3
365.again:
366 out dx, eax
367 out dx, eax
368 out dx, eax
369 out dx, eax
370 out dx, eax
371 dec ecx
372 jnz .again
373 IoPortEpilogue TEST_INSTRUCTION_COUNT_IO / 4
374.s_szTestName:
375 db TMPL_MODE_STR, ', 32-bit OUT-to-ring-3', 0
376ENDPROC TMPL_NM(BenchmarkIoPortRing3Nop32Out)
377
378
379%undef IoPortPrologue
380%undef IoPortEpilogue
381
382
383;;
384; Run the I/O benchmarks for this mode.
385;
386; @uses nothing
387;
388BEGINCODELOW
389BITS 16
390BEGINPROC TMPL_NM(BenchmarkIoPortNop_rm)
391 call TMPL_NM(Bs2IsModeSupported_rm)
392 jz .done
393 call TMPL_NM(Bs2EnterMode_rm)
394BITS TMPL_BITS
395
396 call TMPL_NM(BenchmarkIoPortNop32In)
397 call TMPL_NM(BenchmarkIoPortNop32Out)
398%ifndef QUICK_TEST
399 call TMPL_NM(BenchmarkIoPortNop16In)
400 call TMPL_NM(BenchmarkIoPortNop16Out)
401 call TMPL_NM(BenchmarkIoPortNop8In)
402 call TMPL_NM(BenchmarkIoPortNop8Out)
403%endif
404 call TMPL_NM(BenchmarkIoPortRing3Nop32In)
405 call TMPL_NM(BenchmarkIoPortRing3Nop32Out)
406
407 call TMPL_NM(Bs2ExitMode)
408BITS 16
409.done:
410 ret
411ENDPROC TMPL_NM(BenchmarkIoPortNop_rm)
412
413TMPL_BEGINCODE
414BITS TMPL_BITS
415
416
417
418
419;;
420; Prologue for the MMIO tests.
421%ifndef HaveMmioPrologue
422%define HaveMmioPrologue
423%macro MmioPrologue 2
424 push xBP
425 mov xBP, xSP
426 push sAX
427 push sDX
428 push sCX
429 push sBX
430 sub xSP, 20h
431
432 ; Get the current time.
433 mov xAX, xSP
434 call TMPL_NM_CMN(GetNanoTS)
435
436 ; Do the test - X million 32-bit IN instructions.
437%ifdef TMPL_16BIT
438 mov dx, ds ; save ds
439 %ifdef TMPL_RM
440 mov bx, VMMDEV_TESTING_MMIO_RM_SEL
441 mov ds, bx
442 mov ebx, VMMDEV_TESTING_MMIO_RM_OFF(%2)
443 %else
444 mov bx, BS2_SEL_MMIO16
445 mov ds, bx
446 mov ebx, %2 - BS2_SEL_MMIO16_BASE
447 %endif
448%else
449 mov xBX, %2
450%endif
451 mov ecx, (%1) / 5
452%endmacro
453%endif
454
455;;
456; Epilogue for the MMIO tests.
457%ifndef HaveMmioEpilogue
458%define HaveMmioEpilogue
459%macro MmioEpilogue 1
460%ifdef TMPL_16BIT
461 mov ds, dx ; restore ds
462%endif
463
464 ; Calc the elapsed time and report the result.
465 mov xAX, xSP
466 call TMPL_NM_CMN(GetElapsedNanoTS)
467
468 mov xCX, .s_szTestName
469 mov edx, (%1)
470 mov xAX, xSP
471 call TMPL_NM_CMN(ReportResult)
472
473 add xSP, 20h
474 pop sBX
475 pop sCX
476 pop sDX
477 pop sAX
478 leave
479 ret
480%endmacro
481%endif
482
483
484;;
485; Benchmarks: MOV eax, [NOP]
486;
487; @uses nothing
488;
489BEGINPROC TMPL_NM(BenchmarkMmioNop32Read)
490 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
491.again:
492 mov eax, [sBX]
493 mov eax, [sBX]
494 mov eax, [sBX]
495 mov eax, [sBX]
496 mov eax, [sBX]
497 dec ecx
498 jnz .again
499 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
500.s_szTestName:
501 db TMPL_MODE_STR, ', 32-bit read', 0
502ENDPROC TMPL_NM(BenchmarkMmioNop32Read)
503
504
505;;
506; Benchmarks: MOV [NOP], eax
507;
508; @uses nothing
509;
510BEGINPROC TMPL_NM(BenchmarkMmioNop32Write)
511 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
512.again:
513 mov [sBX], eax
514 mov [sBX], eax
515 mov [sBX], eax
516 mov [sBX], eax
517 mov [sBX], eax
518 dec ecx
519 jnz .again
520 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
521.s_szTestName:
522 db TMPL_MODE_STR, ', 32-bit write', 0
523ENDPROC TMPL_NM(BenchmarkMmioNop32Write)
524
525
526;;
527; Benchmarks: MOV ax, [NOP]
528;
529; @uses nothing
530;
531BEGINPROC TMPL_NM(BenchmarkMmioNop16Read)
532 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
533.again:
534 mov ax, [xBX]
535 mov ax, [xBX]
536 mov ax, [xBX]
537 mov ax, [xBX]
538 mov ax, [xBX]
539 dec ecx
540 jnz .again
541 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
542.s_szTestName:
543 db TMPL_MODE_STR, ', 16-bit read', 0
544ENDPROC TMPL_NM(BenchmarkMmioNop16Read)
545
546
547;;
548; Benchmarks: MOV [NOP], ax
549;
550; @uses nothing
551;
552BEGINPROC TMPL_NM(BenchmarkMmioNop16Write)
553 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
554.again:
555 mov [xBX], ax
556 mov [xBX], ax
557 mov [xBX], ax
558 mov [xBX], ax
559 mov [xBX], ax
560 dec ecx
561 jnz .again
562 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
563.s_szTestName:
564 db TMPL_MODE_STR, ', 16-bit write', 0
565ENDPROC TMPL_NM(BenchmarkMmioNop16Write)
566
567
568;;
569; Benchmarks: MOV al, [NOP]
570;
571; @uses nothing
572;
573BEGINPROC TMPL_NM(BenchmarkMmioNop8Read)
574 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
575.again:
576 mov al, [xBX]
577 mov al, [xBX]
578 mov al, [xBX]
579 mov al, [xBX]
580 mov al, [xBX]
581 dec ecx
582 jnz .again
583 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
584.s_szTestName:
585 db TMPL_MODE_STR, ', 8-bit read', 0
586ENDPROC TMPL_NM(BenchmarkMmioNop8Read)
587
588
589;;
590; Benchmarks: MOV [NOP], al
591;
592; @uses nothing
593;
594BEGINPROC TMPL_NM(BenchmarkMmioNop8Write)
595 MmioPrologue TEST_INSTRUCTION_COUNT_IO, VMMDEV_TESTING_MMIO_NOP
596.again:
597 mov [xBX], al
598 mov [xBX], al
599 mov [xBX], al
600 mov [xBX], al
601 mov [xBX], al
602 dec ecx
603 jnz .again
604 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO
605.s_szTestName:
606 db TMPL_MODE_STR, ', 8-bit write', 0
607ENDPROC TMPL_NM(BenchmarkMmioNop8Write)
608
609
610;;
611; Benchmarks: MOV eax, [NOP_R3]
612;
613; @uses nothing
614;
615BEGINPROC TMPL_NM(BenchmarkMmioRing3Nop32Read)
616 MmioPrologue TEST_INSTRUCTION_COUNT_IO / 4, VMMDEV_TESTING_MMIO_NOP_R3
617.again:
618 mov eax, [sBX]
619 mov eax, [sBX]
620 mov eax, [sBX]
621 mov eax, [sBX]
622 mov eax, [sBX]
623 dec ecx
624 jnz .again
625 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO / 4
626.s_szTestName:
627 db TMPL_MODE_STR, ', 32-bit read-to-ring-3', 0
628ENDPROC TMPL_NM(BenchmarkMmioRing3Nop32Read)
629
630
631;;
632; Benchmarks: MOV [NOP_R3], eax
633;
634; @uses nothing
635;
636BEGINPROC TMPL_NM(BenchmarkMmioRing3Nop32Write)
637 MmioPrologue TEST_INSTRUCTION_COUNT_IO / 4, VMMDEV_TESTING_MMIO_NOP_R3
638.again:
639 mov [sBX], eax
640 mov [sBX], eax
641 mov [sBX], eax
642 mov [sBX], eax
643 mov [sBX], eax
644 dec ecx
645 jnz .again
646 MmioEpilogue TEST_INSTRUCTION_COUNT_MMIO / 4
647.s_szTestName:
648 db TMPL_MODE_STR, ', 32-bit write-to-ring-3', 0
649ENDPROC TMPL_NM(BenchmarkMmioRing3Nop32Write)
650
651
652%undef MmioPrologue
653%undef MmioEpilogue
654
655
656;;
657; Do the MMIO tests for this mode.
658;
659; @uses nothing
660;
661BEGINCODELOW
662BITS 16
663BEGINPROC TMPL_NM(BenchmarkMmioNop_rm)
664 call TMPL_NM(Bs2IsModeSupported_rm)
665 jz .done
666 call TMPL_NM(Bs2EnterMode_rm)
667BITS TMPL_BITS
668
669 call TMPL_NM(BenchmarkMmioNop32Read)
670 call TMPL_NM(BenchmarkMmioNop32Write)
671%ifndef QUICK_TEST
672 call TMPL_NM(BenchmarkMmioNop16Read)
673 call TMPL_NM(BenchmarkMmioNop16Write)
674 call TMPL_NM(BenchmarkMmioNop8Read)
675 call TMPL_NM(BenchmarkMmioNop8Write)
676%endif
677 call TMPL_NM(BenchmarkMmioRing3Nop32Read)
678 call TMPL_NM(BenchmarkMmioRing3Nop32Write)
679
680 call TMPL_NM(Bs2ExitMode)
681BITS 16
682.done:
683 ret
684ENDPROC TMPL_NM(BenchmarkMmioNop_rm)
685
686TMPL_BEGINCODE
687BITS TMPL_BITS
688
689
690%include "bootsector2-template-footer.mac"
691
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