Changeset 913 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Feb 14, 2007 8:22:15 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp
r406 r913 61 61 { 62 62 int rcRet = 0; 63 int i; 63 64 int rc; 64 65 int cIterations = argc > 1 ? RTStrToUInt32(argv[1]) : 32; … … 70 71 */ 71 72 RTR3Init(); 72 VM vm; 73 memset(&vm, 0, sizeof(vm)); 74 rc = SUPInit(&vm.pSession); 73 PSUPDRVSESSION pSession; 74 rc = SUPInit(&pSession); 75 75 rcRet += rc != 0; 76 76 RTPrintf("tstInt: SUPInit -> rc=%Vrc\n", rc); … … 82 82 char szFile[RTPATH_MAX]; 83 83 rc = SUPLoadVMM(ExeDirFile(szFile, argv[0], "VMMR0.r0")); 84 rcRet += rc != 0;85 84 if (!rc) 86 85 { 87 86 /* 88 * C all VMM code with invalid function.87 * Create a fake 'VM'. 89 88 */ 90 for (int i = cIterations; i > 0; i--) 89 PVMR0 pVMR0; 90 RTHCPHYS HCPhysVM; 91 PVM pVM = (PVM)SUPContAlloc2(sizeof(*pVM), (void **)&pVMR0, &HCPhysVM); 92 if (pVM) 91 93 { 92 rc = SUPCallVMMR0(&vm, VMMR0_DO_NOP, NULL); 93 if (rc != VINF_SUCCESS) 94 pVM->pVMGC = 0; 95 pVM->pVMHC = pVM; 96 pVM->HCPhysVM = HCPhysVM; 97 pVM->pSession = pSession; 98 99 #ifdef VBOX_WITHOUT_IDT_PATCHING 100 rc = SUPSetVMForFastIOCtl(pVMR0); 101 #endif 102 if (!rc) 94 103 { 95 RTPrintf("tstInt: SUPCallVMMR0 -> rc=%Vrc i=%d Expected VINF_SUCCESS!\n", rc, i); 104 105 /* 106 * Call VMM code with invalid function. 107 */ 108 for (i = cIterations; i > 0; i--) 109 { 110 rc = SUPCallVMMR0((PVM)pVMR0, VMMR0_DO_NOP, NULL); 111 if (rc != VINF_SUCCESS) 112 { 113 RTPrintf("tstInt: SUPCallVMMR0 -> rc=%Vrc i=%d Expected VINF_SUCCESS!\n", rc, i); 114 rcRet++; 115 break; 116 } 117 } 118 RTPrintf("tstInt: Performed SUPCallVMMR0 %d times (rc=%Vrc)\n", cIterations, rc); 119 120 /* 121 * Profile it. 122 */ 123 if (!rc) 124 { 125 RTTimeNanoTS(); 126 uint64_t StartTS = RTTimeNanoTS(); 127 uint64_t StartTick = ASMReadTSC(); 128 uint64_t MinTicks = UINT64_MAX; 129 for (i = 0; i < 1000000; i++) 130 { 131 uint64_t OneStartTick = ASMReadTSC(); 132 rc = SUPCallVMMR0((PVM)pVMR0, VMMR0_DO_NOP, NULL); 133 uint64_t Ticks = ASMReadTSC() - OneStartTick; 134 if (Ticks < MinTicks) 135 MinTicks = Ticks; 136 137 if (RT_UNLIKELY(rc != VINF_SUCCESS)) 138 { 139 RTPrintf("tstInt: SUPCallVMMR0 -> rc=%Vrc i=%d Expected VINF_SUCCESS!\n", rc, i); 140 rcRet++; 141 break; 142 } 143 } 144 uint64_t Ticks = ASMReadTSC() - StartTick; 145 uint64_t NanoSecs = RTTimeNanoTS() - StartTS; 146 147 RTPrintf("tstInt: %d iterations in %llu ns / %llu ticks. %llu ns / %#llu ticks per iteration. Min %llu ticks.\n", 148 i, NanoSecs, Ticks, NanoSecs / i, Ticks / i, MinTicks); 149 } 150 } 151 else 152 { 153 RTPrintf("tstInt: SUPSetVMForFastIOCtl failed: %Vrc\n", rc); 96 154 rcRet++; 97 break;98 155 } 99 156 } 100 RTPrintf("tstInt: Performed SUPCallVMMR0 %d times (rc=%Vrc)\n", cIterations, rc); 101 102 /** @todo profile it! */ 157 else 158 { 159 RTPrintf("tstInt: SUPContAlloc2(%#zx,,) failed\n", sizeof(*pVM)); 160 rcRet++; 161 } 103 162 104 163 /* … … 106 165 */ 107 166 rc = SUPUnloadVMM(); 108 rcRet += rc != 0;109 167 if (rc) 168 { 110 169 RTPrintf("tstInt: SUPUnloadVMM failed with rc=%Vrc\n", rc); 170 rcRet++; 171 } 111 172 } 112 173 else 174 { 113 175 RTPrintf("tstInt: SUPLoadVMM failed with rc=%Vrc\n", rc); 176 rcRet++; 177 } 114 178 115 179 /*
Note:
See TracChangeset
for help on using the changeset viewer.