| 2253 | extern S32 contextTime; // about the # instruction per 10 ms |
| 2254 | #endif |
| 2255 | void ksyscall(CPU* cpu, U32 eipCount) { |
| 2256 | U32 result = -K_ENOSYS; |
| 2257 | U64 startTime = KSystem::getMicroCounter(); |
| 2258 | #ifdef BOXEDWINE_MULTI_THREADED |
| 2259 | U32 syscallNo = EAX; |
| 2260 | #endif |
| 2261 | if (cpu->thread->terminating) { |
| 2262 | terminateCurrentThread(cpu->thread); // there is a race condition, just signal it again |
| 2263 | return; |
| 2264 | } |
| 2265 | if (cpu->thread->pendingSignals) { |
| 2266 | // I know this is a nested if statement, but it makes setting a break point easier |
| 2267 | if (cpu->thread->runSignals()) { |
| 2268 | cpu->nextOp = cpu->getNextOp(); |
| 2269 | return; |
| 2270 | } |
| 2271 | } |
| 2272 | if (EAX>439) { |
| 2273 | result = -K_ENOSYS; |
| 2274 | kdebug("no syscall for %d", EAX); |
| 2275 | } else if (!syscallFunc[EAX]) { |
| 2276 | result = -K_ENOSYS; |
| 2277 | kdebug("no syscall for %d", EAX); |
| 2278 | } else { |
| 2279 | #ifndef BOXEDWINE_MULTI_THREADED |
| 2280 | U64 startTime = KSystem::getMicroCounter(); |
| 2281 | #endif |
| 2282 | result = syscallFunc[EAX](cpu, eipCount); |
| 2283 | #ifndef BOXEDWINE_MULTI_THREADED |
| 2284 | U64 diff = KSystem::getMicroCounter()-startTime; |
| 2285 | sysCallTime+=diff; |
| 2286 | cpu->blockInstructionCount+=(U32)(contextTime*diff/10000); |
| 2287 | #endif |
| 2288 | } |
| 2289 | #ifdef BOXEDWINE_MULTI_THREADED |
| 2290 | if (!cpu->thread->terminating && cpu->thread->startSignal) { |
| 2291 | cpu->thread->startSignal = false; |
| 2292 | result = -K_CONTINUE; |
| 2293 | // I saw this once with multi-thread normal cpu core and firefight, it was from syscall 4 (write) |
| 2294 | klog_fmt("syscall %d was not interrupted correctly by signal", syscallNo); |
| 2295 | } |
| 2296 | #endif |
| 2297 | if (result==(U32)(-K_CONTINUE)) { |
| 2298 | |
| 2299 | } else if (result==(U32)(-K_WAIT)) { |
| 2300 | |
| 2301 | } else { |
| 2302 | EAX = result; |
| 2303 | cpu->eip.u32+=eipCount; |
| 2304 | } |
| 2305 | cpu->thread->kernelTime += KSystem::getMicroCounter() - startTime; |
| 2306 | } |
| 2307 |
no test coverage detected