summaryrefslogtreecommitdiffstats
path: root/src/core/core.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/core.cpp123
1 files changed, 75 insertions, 48 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 47292cd78..b74fd0a58 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -54,10 +54,10 @@
#include "video_core/renderer_base.h"
#include "video_core/video_core.h"
-MICROPROFILE_DEFINE(ARM_Jit_Dynarmic_CPU0, "ARM JIT", "Dynarmic CPU 0", MP_RGB(255, 64, 64));
-MICROPROFILE_DEFINE(ARM_Jit_Dynarmic_CPU1, "ARM JIT", "Dynarmic CPU 1", MP_RGB(255, 64, 64));
-MICROPROFILE_DEFINE(ARM_Jit_Dynarmic_CPU2, "ARM JIT", "Dynarmic CPU 2", MP_RGB(255, 64, 64));
-MICROPROFILE_DEFINE(ARM_Jit_Dynarmic_CPU3, "ARM JIT", "Dynarmic CPU 3", MP_RGB(255, 64, 64));
+MICROPROFILE_DEFINE(ARM_CPU0, "ARM", "CPU 0", MP_RGB(255, 64, 64));
+MICROPROFILE_DEFINE(ARM_CPU1, "ARM", "CPU 1", MP_RGB(255, 64, 64));
+MICROPROFILE_DEFINE(ARM_CPU2, "ARM", "CPU 2", MP_RGB(255, 64, 64));
+MICROPROFILE_DEFINE(ARM_CPU3, "ARM", "CPU 3", MP_RGB(255, 64, 64));
namespace Core {
@@ -117,8 +117,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
return nullptr;
}
- return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(std::move(concat),
- dir->GetName());
+ return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(concat, dir->GetName());
}
if (Common::FS::IsDir(path)) {
@@ -137,7 +136,7 @@ struct System::Impl {
device_memory = std::make_unique<Core::DeviceMemory>();
is_multicore = Settings::values.use_multi_core.GetValue();
- extended_memory_layout = Settings::values.use_extended_memory_layout.GetValue();
+ extended_memory_layout = Settings::values.use_unsafe_extended_memory_layout.GetValue();
core_timing.SetMulticore(is_multicore);
core_timing.Initialize([&system]() { system.RegisterHostThread(); });
@@ -169,7 +168,7 @@ struct System::Impl {
void ReinitializeIfNecessary(System& system) {
const bool must_reinitialize =
is_multicore != Settings::values.use_multi_core.GetValue() ||
- extended_memory_layout != Settings::values.use_extended_memory_layout.GetValue();
+ extended_memory_layout != Settings::values.use_unsafe_extended_memory_layout.GetValue();
if (!must_reinitialize) {
return;
@@ -178,7 +177,7 @@ struct System::Impl {
LOG_DEBUG(Kernel, "Re-initializing");
is_multicore = Settings::values.use_multi_core.GetValue();
- extended_memory_layout = Settings::values.use_extended_memory_layout.GetValue();
+ extended_memory_layout = Settings::values.use_unsafe_extended_memory_layout.GetValue();
Initialize(system);
}
@@ -186,7 +185,7 @@ struct System::Impl {
void Run() {
std::unique_lock<std::mutex> lk(suspend_guard);
- kernel.Suspend(false);
+ kernel.SuspendApplication(false);
core_timing.SyncPause(false);
is_paused.store(false, std::memory_order_relaxed);
}
@@ -195,7 +194,7 @@ struct System::Impl {
std::unique_lock<std::mutex> lk(suspend_guard);
core_timing.SyncPause(true);
- kernel.Suspend(true);
+ kernel.SuspendApplication(true);
is_paused.store(true, std::memory_order_relaxed);
}
@@ -203,25 +202,33 @@ struct System::Impl {
return is_paused.load(std::memory_order_relaxed);
}
- std::unique_lock<std::mutex> StallProcesses() {
+ std::unique_lock<std::mutex> StallApplication() {
std::unique_lock<std::mutex> lk(suspend_guard);
- kernel.Suspend(true);
+ kernel.SuspendApplication(true);
core_timing.SyncPause(true);
return lk;
}
- void UnstallProcesses() {
+ void UnstallApplication() {
if (!IsPaused()) {
core_timing.SyncPause(false);
- kernel.Suspend(false);
+ kernel.SuspendApplication(false);
}
}
+ void SetNVDECActive(bool is_nvdec_active) {
+ nvdec_active = is_nvdec_active;
+ }
+
+ bool GetNVDECActive() {
+ return nvdec_active;
+ }
+
void InitializeDebugger(System& system, u16 port) {
debugger = std::make_unique<Debugger>(system, port);
}
- SystemResultStatus SetupForMainProcess(System& system, Frontend::EmuWindow& emu_window) {
+ SystemResultStatus SetupForApplicationProcess(System& system, Frontend::EmuWindow& emu_window) {
LOG_DEBUG(Core, "initialized OK");
// Setting changes may require a full system reinitialization (e.g., disabling multicore).
@@ -252,10 +259,10 @@ struct System::Impl {
is_powered_on = true;
exit_lock = false;
- microprofile_dynarmic[0] = MICROPROFILE_TOKEN(ARM_Jit_Dynarmic_CPU0);
- microprofile_dynarmic[1] = MICROPROFILE_TOKEN(ARM_Jit_Dynarmic_CPU1);
- microprofile_dynarmic[2] = MICROPROFILE_TOKEN(ARM_Jit_Dynarmic_CPU2);
- microprofile_dynarmic[3] = MICROPROFILE_TOKEN(ARM_Jit_Dynarmic_CPU3);
+ microprofile_cpu[0] = MICROPROFILE_TOKEN(ARM_CPU0);
+ microprofile_cpu[1] = MICROPROFILE_TOKEN(ARM_CPU1);
+ microprofile_cpu[2] = MICROPROFILE_TOKEN(ARM_CPU2);
+ microprofile_cpu[3] = MICROPROFILE_TOKEN(ARM_CPU3);
LOG_DEBUG(Core, "Initialized OK");
@@ -273,7 +280,7 @@ struct System::Impl {
return SystemResultStatus::ErrorGetLoader;
}
- SystemResultStatus init_result{SetupForMainProcess(system, emu_window)};
+ SystemResultStatus init_result{SetupForApplicationProcess(system, emu_window)};
if (init_result != SystemResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to initialize system (Error {})!",
static_cast<int>(init_result));
@@ -293,6 +300,8 @@ struct System::Impl {
ASSERT(Kernel::KProcess::Initialize(main_process, system, "main",
Kernel::KProcess::ProcessType::Userland, resource_limit)
.IsSuccess());
+ Kernel::KProcess::Register(system.Kernel(), main_process);
+ kernel.MakeApplicationProcess(main_process);
const auto [load_result, load_parameters] = app_loader->Load(*main_process, system);
if (load_result != Loader::ResultStatus::Success) {
LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", load_result);
@@ -302,7 +311,6 @@ struct System::Impl {
static_cast<u32>(SystemResultStatus::ErrorLoader) + static_cast<u32>(load_result));
}
AddGlueRegistrationForProcess(*app_loader, *main_process);
- kernel.MakeCurrentProcess(main_process);
kernel.InitializeCores();
// Initialize cheat engine
@@ -358,7 +366,7 @@ struct System::Impl {
void ShutdownMainProcess() {
SetShuttingDown(true);
- // Log last frame performance stats if game was loded
+ // Log last frame performance stats if game was loaded
if (perf_stats) {
const auto perf_results = GetAndResetPerfStats();
constexpr auto performance = Common::Telemetry::FieldType::Performance;
@@ -380,9 +388,7 @@ struct System::Impl {
gpu_core->NotifyShutdown();
}
- kernel.ShutdownCores();
- cpu_manager.Shutdown();
- debugger.reset();
+ kernel.SuspendApplication(true);
if (services) {
services->KillNVNFlinger();
}
@@ -398,6 +404,9 @@ struct System::Impl {
gpu_core.reset();
host1x_core.reset();
perf_stats.reset();
+ kernel.ShutdownCores();
+ cpu_manager.Shutdown();
+ debugger.reset();
kernel.Shutdown();
memory.Reset();
@@ -433,7 +442,7 @@ struct System::Impl {
}
Service::Glue::ApplicationLaunchProperty launch{};
- launch.title_id = process.GetProgramID();
+ launch.title_id = process.GetProgramId();
FileSys::PatchManager pm{launch.title_id, fs_controller, *content_provider};
launch.version = pm.GetGameVersion().value_or(0);
@@ -484,6 +493,8 @@ struct System::Impl {
std::atomic_bool is_powered_on{};
bool exit_lock = false;
+ bool nvdec_active{};
+
Reporter reporter;
std::unique_ptr<Memory::CheatEngine> cheat_engine;
std::unique_ptr<Tools::Freezer> memory_freezer;
@@ -528,7 +539,7 @@ struct System::Impl {
ExitCallback exit_callback;
std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{};
- std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_dynarmic{};
+ std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_cpu{};
};
System::System() : impl{std::make_unique<Impl>(*this)} {}
@@ -563,7 +574,7 @@ void System::InvalidateCpuInstructionCaches() {
impl->kernel.InvalidateAllInstructionCaches();
}
-void System::InvalidateCpuInstructionCacheRange(VAddr addr, std::size_t size) {
+void System::InvalidateCpuInstructionCacheRange(u64 addr, std::size_t size) {
impl->kernel.InvalidateCpuInstructionCacheRange(addr, size);
}
@@ -585,12 +596,20 @@ void System::DetachDebugger() {
}
}
-std::unique_lock<std::mutex> System::StallProcesses() {
- return impl->StallProcesses();
+std::unique_lock<std::mutex> System::StallApplication() {
+ return impl->StallApplication();
+}
+
+void System::UnstallApplication() {
+ impl->UnstallApplication();
+}
+
+void System::SetNVDECActive(bool is_nvdec_active) {
+ impl->SetNVDECActive(is_nvdec_active);
}
-void System::UnstallProcesses() {
- impl->UnstallProcesses();
+bool System::GetNVDECActive() {
+ return impl->GetNVDECActive();
}
void System::InitializeDebugger() {
@@ -610,6 +629,10 @@ void System::PrepareReschedule(const u32 core_index) {
impl->kernel.PrepareReschedule(core_index);
}
+size_t System::GetCurrentHostThreadID() const {
+ return impl->kernel.GetCurrentHostThreadID();
+}
+
PerfStatsResults System::GetAndResetPerfStats() {
return impl->GetAndResetPerfStats();
}
@@ -648,8 +671,8 @@ const Kernel::GlobalSchedulerContext& System::GlobalSchedulerContext() const {
return impl->kernel.GlobalSchedulerContext();
}
-Kernel::KProcess* System::CurrentProcess() {
- return impl->kernel.CurrentProcess();
+Kernel::KProcess* System::ApplicationProcess() {
+ return impl->kernel.ApplicationProcess();
}
Core::DeviceMemory& System::DeviceMemory() {
@@ -660,8 +683,8 @@ const Core::DeviceMemory& System::DeviceMemory() const {
return *impl->device_memory;
}
-const Kernel::KProcess* System::CurrentProcess() const {
- return impl->kernel.CurrentProcess();
+const Kernel::KProcess* System::ApplicationProcess() const {
+ return impl->kernel.ApplicationProcess();
}
ARM_Interface& System::ArmInterface(std::size_t core_index) {
@@ -680,11 +703,11 @@ const ExclusiveMonitor& System::Monitor() const {
return impl->kernel.GetExclusiveMonitor();
}
-Memory::Memory& System::Memory() {
+Memory::Memory& System::ApplicationMemory() {
return impl->memory;
}
-const Core::Memory::Memory& System::Memory() const {
+const Core::Memory::Memory& System::ApplicationMemory() const {
return impl->memory;
}
@@ -760,8 +783,8 @@ const Core::SpeedLimiter& System::SpeedLimiter() const {
return impl->speed_limiter;
}
-u64 System::GetCurrentProcessProgramID() const {
- return impl->kernel.CurrentProcess()->GetProgramID();
+u64 System::GetApplicationProcessProgramID() const {
+ return impl->kernel.ApplicationProcess()->GetProgramId();
}
Loader::ResultStatus System::GetGameName(std::string& out) const {
@@ -793,7 +816,7 @@ FileSys::VirtualFilesystem System::GetFilesystem() const {
}
void System::RegisterCheatList(const std::vector<Memory::CheatEntry>& list,
- const std::array<u8, 32>& build_id, VAddr main_region_begin,
+ const std::array<u8, 32>& build_id, u64 main_region_begin,
u64 main_region_size) {
impl->cheat_engine = std::make_unique<Memory::CheatEngine>(*this, list, build_id);
impl->cheat_engine->SetMainMemoryParameters(main_region_begin, main_region_size);
@@ -880,11 +903,11 @@ bool System::GetExitLock() const {
return impl->exit_lock;
}
-void System::SetCurrentProcessBuildID(const CurrentBuildProcessID& id) {
+void System::SetApplicationProcessBuildID(const CurrentBuildProcessID& id) {
impl->build_id = id;
}
-const System::CurrentBuildProcessID& System::GetCurrentProcessBuildID() const {
+const System::CurrentBuildProcessID& System::GetApplicationProcessBuildID() const {
return impl->build_id;
}
@@ -904,14 +927,14 @@ void System::RegisterHostThread() {
impl->kernel.RegisterHostThread();
}
-void System::EnterDynarmicProfile() {
+void System::EnterCPUProfile() {
std::size_t core = impl->kernel.GetCurrentHostThreadID();
- impl->dynarmic_ticks[core] = MicroProfileEnter(impl->microprofile_dynarmic[core]);
+ impl->dynarmic_ticks[core] = MicroProfileEnter(impl->microprofile_cpu[core]);
}
-void System::ExitDynarmicProfile() {
+void System::ExitCPUProfile() {
std::size_t core = impl->kernel.GetCurrentHostThreadID();
- MicroProfileLeave(impl->microprofile_dynarmic[core], impl->dynarmic_ticks[core]);
+ MicroProfileLeave(impl->microprofile_cpu[core], impl->dynarmic_ticks[core]);
}
bool System::IsMulticore() const {
@@ -938,6 +961,10 @@ const Network::RoomNetwork& System::GetRoomNetwork() const {
return impl->room_network;
}
+void System::RunServer(std::unique_ptr<Service::ServerManager>&& server_manager) {
+ return impl->kernel.RunServer(std::move(server_manager));
+}
+
void System::RegisterExecuteProgramCallback(ExecuteProgramCallback&& callback) {
impl->execute_program_callback = std::move(callback);
}