diff --git a/src/core/kernel/exports/EmuKrnlHal.cpp b/src/core/kernel/exports/EmuKrnlHal.cpp index 2ed3494de..d22d0552a 100644 --- a/src/core/kernel/exports/EmuKrnlHal.cpp +++ b/src/core/kernel/exports/EmuKrnlHal.cpp @@ -599,7 +599,6 @@ XBSYSAPI EXPORTNUM(49) xbox::void_xt DECLSPEC_NORETURN NTAPI xbox::HalReturnToFi } CxbxKrnlShutDown(is_reboot); - TerminateProcess(GetCurrentProcess(), EXIT_SUCCESS); } // ****************************************************************** diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index 3eff4753f..80a30ed0f 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -145,6 +145,7 @@ xbox::void_xt NTAPI CxbxLaunchXbe(xbox::PVOID Entry) { EmuLogInit(LOG_LEVEL::DEBUG, "Calling XBE entry point..."); static_cast(Entry)(); + EmuLogInit(LOG_LEVEL::DEBUG, "XBE entry point returned"); } // Entry point address XOR keys per Xbe type (Retail, Debug or Chihiro) : @@ -703,7 +704,6 @@ static bool CxbxrKrnlXbeSystemSelector(int BootFlags, unsigned& reserved_systems // Launch Segaboot CxbxLaunchNewXbe(chihiroSegaBootNew); CxbxKrnlShutDown(true); - TerminateProcess(GetCurrentProcess(), EXIT_SUCCESS); } #endif // Chihiro wip block @@ -1514,16 +1514,11 @@ static void CxbxrKrnlInitHacks() EmuKeFreePcr(); - // FIXME: Wait for Cxbx to exit or error fatally - Sleep(INFINITE); - - EmuLogInit(LOG_LEVEL::DEBUG, "XBE entry point returned"); - fflush(stdout); - - CxbxUnlockFilePath(); - - // EmuShared::Cleanup(); FIXME: commenting this line is a bad workaround for issue #617 (https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/617) - CxbxKrnlTerminateThread(); + // This will wait forever + std::condition_variable cv; + std::mutex m; + std::unique_lock lock(m); + cv.wait(lock, [] { return false; }); } // REMARK: the following is useless, but PatrickvL has asked to keep it for documentation purposes @@ -1754,11 +1749,6 @@ void CxbxPrintUEMInfo(ULONG ErrorCode) } } -[[noreturn]] void CxbxKrnlTerminateThread() -{ - TerminateThread(GetCurrentThread(), 0); -} - void CxbxKrnlPanic() { CxbxrKrnlAbort("Kernel Panic!"); diff --git a/src/core/kernel/init/CxbxKrnl.h b/src/core/kernel/init/CxbxKrnl.h index 38e27daec..2de3a0e27 100644 --- a/src/core/kernel/init/CxbxKrnl.h +++ b/src/core/kernel/init/CxbxKrnl.h @@ -152,7 +152,7 @@ void CxbxKrnlEmulate(unsigned int system, blocks_reserved_t blocks_reserved); #define CxbxrKrnlAbort(fmt, ...) CxbxrKrnlAbortEx(LOG_PREFIX, fmt, ##__VA_ARGS__) /*! terminate gracefully the emulation */ -void CxbxKrnlShutDown(bool is_reboot = false); +[[noreturn]] void CxbxKrnlShutDown(bool is_reboot = false); /*! display the fatal error message*/ void CxbxKrnlPrintUEM(ULONG ErrorCode); @@ -160,9 +160,6 @@ void CxbxKrnlPrintUEM(ULONG ErrorCode); /*! display the cause of the fatal error message*/ void CxbxPrintUEMInfo(ULONG ErrorCode); -/*! terminate the calling thread */ -[[noreturn]] void CxbxKrnlTerminateThread(); - /*! kernel panic (trap for unimplemented kernel functions) */ void CxbxKrnlPanic();