diff --git a/src/common/settings.h b/src/common/settings.h index 9a7064c95e..1a74d42977 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -196,7 +196,14 @@ struct Values { linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; // Core - SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; + SwitchableSetting use_multi_core{linkage, +#ifdef __OPENORBIS__ + // Re-enable once proper TLS support is added + false, +#else + true, +#endif + "use_multi_core", Category::Core}; SwitchableSetting memory_layout_mode{linkage, MemoryLayout::Memory_4Gb, "memory_layout_mode", diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 7a6e7b8352..a4ccd84d38 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -104,6 +104,7 @@ struct Ucontext { } static boost::container::static_vector, 16> swap_regions; +extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num); static void SwapHandler(int sig, void* raw_context) { auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext; if (std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { @@ -116,8 +117,8 @@ static void SwapHandler(int sig, void* raw_context) { void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(res != MAP_FAILED); } else { - LOG_ERROR(HW_Memory, "fault in addr {:#x}", mctx.mc_addr); - sceSystemServiceLoadExec("EXIT", nullptr); + LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address + sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal } } void InitSwap() noexcept { diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 1889ed9938..d25e152333 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -69,7 +69,9 @@ struct KernelCore::Impl { global_object_list_container = std::make_unique(kernel); global_scheduler_context = std::make_unique(kernel); +#ifndef __OPENORBIS__ is_phantom_mode_for_singlecore = false; +#endif // Derive the initial memory layout from the emulated board Init::InitializeSlabResourceCounts(kernel); @@ -356,7 +358,11 @@ struct KernelCore::Impl { application_process->Open(); } +#ifdef __OPENORBIS__ + static inline u8 host_thread_id = UINT8_MAX; +#else static inline thread_local u8 host_thread_id = UINT8_MAX; +#endif /// Sets the host thread ID for the caller. u32 SetHostThreadId(std::size_t core_id) { @@ -380,8 +386,14 @@ struct KernelCore::Impl { ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess()); return thread; }}; +#ifdef __OPENORBIS__ + // No proper TLS yet + static KThread raw_thread{system.Kernel()}; + static KThread* thread = existing_thread ? existing_thread : initialize(&raw_thread); +#else thread_local KThread raw_thread{system.Kernel()}; thread_local KThread* thread = existing_thread ? existing_thread : initialize(&raw_thread); +#endif return thread; } @@ -407,22 +419,33 @@ struct KernelCore::Impl { return this_id; } +#ifdef __OPENORBIS__ + bool IsPhantomModeForSingleCore() const { + return true; + } + void SetIsPhantomModeForSingleCore(bool value) {} +#else + // Forces singlecore static inline thread_local bool is_phantom_mode_for_singlecore{false}; - bool IsPhantomModeForSingleCore() const { return is_phantom_mode_for_singlecore; } - void SetIsPhantomModeForSingleCore(bool value) { ASSERT(!is_multicore); is_phantom_mode_for_singlecore = value; } +#endif bool IsShuttingDown() const { return is_shutting_down.load(std::memory_order_relaxed); } +#ifdef __OPENORBIS__ + // PS4 doesn't have proper TLS handling + static inline KThread* current_thread{nullptr}; +#else static inline thread_local KThread* current_thread{nullptr}; +#endif KThread* GetCurrentEmuThread() { if (!current_thread) { diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b04a70590a..2fc8aa4e8a 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -82,7 +82,10 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB RegisterEngine("gcpad", gcadapter); #endif +#ifndef __OPENORBIS__ + // TODO: Issue in PS4, crash for UDP_client RegisterEngine("cemuhookudp", udp_client); +#endif RegisterEngine("tas", tas_input); RegisterEngine("camera", camera); #ifdef ANDROID @@ -116,7 +119,9 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB UnregisterEngine(gcadapter); #endif +#ifndef __OPENORBIS__ UnregisterEngine(udp_client); +#endif UnregisterEngine(tas_input); UnregisterEngine(camera); #ifdef ANDROID @@ -152,8 +157,10 @@ struct InputSubsystem::Impl { auto gcadapter_devices = gcadapter->GetInputDevices(); devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); #endif +#ifndef __OPENORBIS__ auto udp_devices = udp_client->GetInputDevices(); devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); +#endif #ifdef HAVE_SDL2 auto joycon_devices = joycon->GetInputDevices(); devices.insert(devices.end(), joycon_devices.begin(), joycon_devices.end()); @@ -186,9 +193,11 @@ struct InputSubsystem::Impl { return gcadapter; } #endif +#ifndef __OPENORBIS__ if (engine == udp_client->GetEngineName()) { return udp_client; } +#endif #ifdef HAVE_SDL2 if (engine == sdl->GetEngineName()) { return sdl; @@ -271,9 +280,11 @@ struct InputSubsystem::Impl { return true; } #endif +#ifndef __OPENORBIS__ if (engine == udp_client->GetEngineName()) { return true; } +#endif if (engine == tas_input->GetEngineName()) { return true; } @@ -300,7 +311,9 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB gcadapter->BeginConfiguration(); #endif +#ifndef __OPENORBIS__ udp_client->BeginConfiguration(); +#endif #ifdef HAVE_SDL2 sdl->BeginConfiguration(); joycon->BeginConfiguration(); @@ -316,7 +329,9 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB gcadapter->EndConfiguration(); #endif +#ifndef __OPENORBIS__ udp_client->EndConfiguration(); +#endif #ifdef HAVE_SDL2 sdl->EndConfiguration(); joycon->EndConfiguration(); @@ -341,7 +356,9 @@ struct InputSubsystem::Impl { std::shared_ptr mouse; std::shared_ptr touch_screen; std::shared_ptr tas_input; +#ifndef __OPENORBIS__ std::shared_ptr udp_client; +#endif std::shared_ptr camera; std::shared_ptr virtual_amiibo; std::shared_ptr virtual_gamepad; @@ -470,7 +487,9 @@ bool InputSubsystem::IsStickInverted(const Common::ParamPackage& params) const { } void InputSubsystem::ReloadInputDevices() { +#ifndef __OPENORBIS__ impl->udp_client.get()->ReloadSockets(); +#endif } void InputSubsystem::BeginMapping(Polling::InputType type) {