1 | /* $Id: tstMicro.h 3723 2007-07-19 18:46:00Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Micro Testcase, profiling special CPU operations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___tstMicro_h
|
---|
23 | #define ___tstMicro_h
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * The testcase identifier.
|
---|
27 | */
|
---|
28 | typedef enum TSTMICROTEST
|
---|
29 | {
|
---|
30 | TSTMICROTEST_OVERHEAD = 0,
|
---|
31 | TSTMICROTEST_INVLPG_0,
|
---|
32 | TSTMICROTEST_INVLPG_EIP,
|
---|
33 | TSTMICROTEST_INVLPG_ESP,
|
---|
34 | TSTMICROTEST_CR3_RELOAD,
|
---|
35 | TSTMICROTEST_WP_DISABLE,
|
---|
36 | TSTMICROTEST_WP_ENABLE,
|
---|
37 |
|
---|
38 | TSTMICROTEST_TRAP_FIRST,
|
---|
39 | TSTMICROTEST_PF_R0 = TSTMICROTEST_TRAP_FIRST,
|
---|
40 | TSTMICROTEST_PF_R1,
|
---|
41 | TSTMICROTEST_PF_R2,
|
---|
42 | TSTMICROTEST_PF_R3,
|
---|
43 |
|
---|
44 | /** The max testcase. */
|
---|
45 | TSTMICROTEST_MAX
|
---|
46 | } TSTMICROTEST;
|
---|
47 |
|
---|
48 |
|
---|
49 | /**
|
---|
50 | *
|
---|
51 | */
|
---|
52 | typedef struct TSTMICRORESULT
|
---|
53 | {
|
---|
54 | /** The total number of ticks spent executing the testcase.
|
---|
55 | * This may include extra overhead stuff if we're weird stuff during trap handler. */
|
---|
56 | uint64_t cTotalTicks;
|
---|
57 | /** Number of ticks spent getting into Rx from R0.
|
---|
58 | * This will include time spent setting up the testcase in R3. */
|
---|
59 | uint64_t cToRxFirstTicks;
|
---|
60 | /** Number of ticks spent executing the trap.
|
---|
61 | * I.e. from right before trapping instruction to the start of the trap handler.
|
---|
62 | * This does not apply to testcases which doesn't trap. */
|
---|
63 | uint64_t cTrapTicks;
|
---|
64 | /** Number of ticks spent resuming Rx executing after a trap.
|
---|
65 | * This does not apply to testcases which doesn't trap. */
|
---|
66 | uint64_t cToRxTrapTicks;
|
---|
67 | /** Number of ticks to get to back to r0 after resuming the trapped code.
|
---|
68 | * This does not apply to testcases which doesn't trap. */
|
---|
69 | uint64_t cToR0Ticks;
|
---|
70 | } TSTMICRORESULT, *PTSTMICRORESULT;
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Micro profiling testcase
|
---|
74 | */
|
---|
75 | typedef struct TSTMICRO
|
---|
76 | {
|
---|
77 | /** The GC address of this structure. */
|
---|
78 | RTGCPTR GCPtr;
|
---|
79 | /** Just for proper alignment. */
|
---|
80 | RTGCPTR GCPtrStack;
|
---|
81 |
|
---|
82 | /** TSC sampled right before leaving R0. */
|
---|
83 | uint64_t u64TSCR0Start;
|
---|
84 | /** TSC sampled right before the exception. */
|
---|
85 | uint64_t u64TSCRxStart;
|
---|
86 | /** TSC sampled right after entering the trap handler. */
|
---|
87 | uint64_t u64TSCR0Enter;
|
---|
88 | /** TSC sampled right before exitting the trap handler. */
|
---|
89 | uint64_t u64TSCR0Exit;
|
---|
90 | /** TSC sampled right after resuming guest trap. */
|
---|
91 | uint64_t u64TSCRxEnd;
|
---|
92 | /** TSC sampled right after re-entering R0. */
|
---|
93 | uint64_t u64TSCR0End;
|
---|
94 | /** Number of times entered (should be one). */
|
---|
95 | uint32_t cHits;
|
---|
96 | /** Advance EIP. */
|
---|
97 | int32_t offEIPAdd;
|
---|
98 | /** The last CR3 code. */
|
---|
99 | uint32_t u32CR2;
|
---|
100 | /** The last error code. */
|
---|
101 | uint32_t u32ErrCd;
|
---|
102 | /** The last trap eip. */
|
---|
103 | uint32_t u32EIP;
|
---|
104 | /** The original IDT address and limit. */
|
---|
105 | VBOXIDTR OriginalIDTR;
|
---|
106 | /** Our IDT. */
|
---|
107 | VBOXIDTE aIDT[256];
|
---|
108 |
|
---|
109 | /** The overhead for the rdtsc + 2 xchg instr. */
|
---|
110 | uint64_t u64Overhead;
|
---|
111 |
|
---|
112 | /** The testresults. */
|
---|
113 | TSTMICRORESULT aResults[TSTMICROTEST_MAX];
|
---|
114 | /** Ring-3 stack. */
|
---|
115 | uint8_t au8Stack[4096];
|
---|
116 |
|
---|
117 | } TSTMICRO, *PTSTMICRO;
|
---|
118 |
|
---|
119 |
|
---|
120 | __BEGIN_DECLS
|
---|
121 |
|
---|
122 | DECLASM(void) idtOnly42(PTSTMICRO pTst);
|
---|
123 |
|
---|
124 |
|
---|
125 | DECLASM(void) tstOverhead(PTSTMICRO pTst);
|
---|
126 | DECLASM(void) tstInvlpg0(PTSTMICRO pTst);
|
---|
127 | DECLASM(void) tstInvlpgEIP(PTSTMICRO pTst);
|
---|
128 | DECLASM(void) tstInvlpgESP(PTSTMICRO pTst);
|
---|
129 | DECLASM(void) tstCR3Reload(PTSTMICRO pTst);
|
---|
130 | DECLASM(void) tstWPEnable(PTSTMICRO pTst);
|
---|
131 | DECLASM(void) tstWPDisable(PTSTMICRO pTst);
|
---|
132 |
|
---|
133 |
|
---|
134 | DECLASM(int) tstPFR0(PTSTMICRO pTst);
|
---|
135 | DECLASM(int) tstPFR1(PTSTMICRO pTst);
|
---|
136 | DECLASM(int) tstPFR2(PTSTMICRO pTst);
|
---|
137 | DECLASM(int) tstPFR3(PTSTMICRO pTst);
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | DECLASM(void) tstTrapHandlerNoErr(void);
|
---|
142 | DECLASM(void) tstTrapHandler(void);
|
---|
143 | DECLASM(void) tstInterrupt42(void);
|
---|
144 |
|
---|
145 | __END_DECLS
|
---|
146 |
|
---|
147 | #endif
|
---|