// Copyright 2018 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include "Common/Logging/Log.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" #include "Core/System.h" #include "DolphinNoGUI/Platform.h" namespace { class PlatformHeadless final : public Platform { public: void SetTitle(const std::string& title) override; void MainLoop() override; WindowSystemInfo GetWindowSystemInfo() const override; }; void PlatformHeadless::SetTitle(const std::string& title) { std::fprintf(stdout, "%s\n", title.c_str()); } void PlatformHeadless::MainLoop() { bool diff_observed = false; while (m_running.IsSet()) { UpdateRunningFlag(); auto& system = Core::System::GetInstance(); Core::HostDispatchJobs(system); if (!diff_observed && Core::IsRunning(system)) { auto& memory = system.GetMemory(); const u32 status = memory.Read_U32(0x00003c00); if (status == 0x52500004 || (status & 0xffffff00) == 0x5250e100) { diff_observed = true; INFO_LOG_FMT(IOS, "IOS_PROBE_DIFF_DONE status={:#010x}", status); constexpr u32 trace_base = 0x00003d00; const u32 count = memory.Read_U32(trace_base); if (count > 8) { ERROR_LOG_FMT(IOS, "IOS_PROBE_DIFF_BAD_COUNT count={}", count); } else { for (u32 index = 0; index < count; ++index) { const u32 record = trace_base + 0x20 + index * 24; INFO_LOG_FMT(IOS, "IOS_PROBE_JSON {{\"schema\":1,\"index\":{},\"operation\":{}," "\"argument\":{},\"return\":{},\"output\":{},\"ticks\":{}," "\"status\":{}}}", index, memory.Read_U32(record), memory.Read_U32(record + 4), static_cast(memory.Read_U32(record + 8)), memory.Read_U32(record + 12), memory.Read_U32(record + 16), memory.Read_U32(record + 20)); } } } } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } WindowSystemInfo PlatformHeadless::GetWindowSystemInfo() const { WindowSystemInfo wsi; wsi.type = WindowSystemType::Headless; wsi.display_connection = nullptr; wsi.render_window = nullptr; wsi.render_surface = nullptr; return wsi; } } // namespace std::unique_ptr Platform::CreateHeadlessPlatform() { return std::make_unique(); }