summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp10
-rw-r--r--src/core/file_sys/control_metadata.h4
-rw-r--r--src/core/hle/kernel/k_thread.h4
-rw-r--r--src/core/hle/kernel/kernel.cpp57
-rw-r--r--src/core/hle/kernel/kernel.h4
-rw-r--r--src/core/hle/service/am/service/application_functions.cpp19
-rw-r--r--src/core/hle/service/am/service/application_functions.h1
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.cpp9
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.h1
-rw-r--r--src/core/hle/service/glue/time/manager.cpp4
-rw-r--r--src/core/hle/service/glue/time/manager.h1
-rw-r--r--src/core/memory/cheat_engine.cpp4
12 files changed, 80 insertions, 38 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 435ef6793..bd5f11d53 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -242,7 +242,7 @@ struct System::Impl {
242 void Run() { 242 void Run() {
243 std::unique_lock<std::mutex> lk(suspend_guard); 243 std::unique_lock<std::mutex> lk(suspend_guard);
244 244
245 kernel.SuspendApplication(false); 245 kernel.SuspendEmulation(false);
246 core_timing.SyncPause(false); 246 core_timing.SyncPause(false);
247 is_paused.store(false, std::memory_order_relaxed); 247 is_paused.store(false, std::memory_order_relaxed);
248 } 248 }
@@ -251,7 +251,7 @@ struct System::Impl {
251 std::unique_lock<std::mutex> lk(suspend_guard); 251 std::unique_lock<std::mutex> lk(suspend_guard);
252 252
253 core_timing.SyncPause(true); 253 core_timing.SyncPause(true);
254 kernel.SuspendApplication(true); 254 kernel.SuspendEmulation(true);
255 is_paused.store(true, std::memory_order_relaxed); 255 is_paused.store(true, std::memory_order_relaxed);
256 } 256 }
257 257
@@ -261,7 +261,7 @@ struct System::Impl {
261 261
262 std::unique_lock<std::mutex> StallApplication() { 262 std::unique_lock<std::mutex> StallApplication() {
263 std::unique_lock<std::mutex> lk(suspend_guard); 263 std::unique_lock<std::mutex> lk(suspend_guard);
264 kernel.SuspendApplication(true); 264 kernel.SuspendEmulation(true);
265 core_timing.SyncPause(true); 265 core_timing.SyncPause(true);
266 return lk; 266 return lk;
267 } 267 }
@@ -269,7 +269,7 @@ struct System::Impl {
269 void UnstallApplication() { 269 void UnstallApplication() {
270 if (!IsPaused()) { 270 if (!IsPaused()) {
271 core_timing.SyncPause(false); 271 core_timing.SyncPause(false);
272 kernel.SuspendApplication(false); 272 kernel.SuspendEmulation(false);
273 } 273 }
274 } 274 }
275 275
@@ -459,7 +459,7 @@ struct System::Impl {
459 } 459 }
460 460
461 Network::CancelPendingSocketOperations(); 461 Network::CancelPendingSocketOperations();
462 kernel.SuspendApplication(true); 462 kernel.SuspendEmulation(true);
463 if (services) { 463 if (services) {
464 services->KillNVNFlinger(); 464 services->KillNVNFlinger();
465 } 465 }
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h
index 555b9d8f7..667efbbab 100644
--- a/src/core/file_sys/control_metadata.h
+++ b/src/core/file_sys/control_metadata.h
@@ -64,8 +64,8 @@ struct RawNACP {
64 u64_le cache_storage_size; 64 u64_le cache_storage_size;
65 u64_le cache_storage_journal_size; 65 u64_le cache_storage_journal_size;
66 u64_le cache_storage_data_and_journal_max_size; 66 u64_le cache_storage_data_and_journal_max_size;
67 u64_le cache_storage_max_index; 67 u16_le cache_storage_max_index;
68 INSERT_PADDING_BYTES(0xE70); 68 INSERT_PADDING_BYTES(0xE76);
69}; 69};
70static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size."); 70static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size.");
71 71
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index f13e232b2..e928cfebc 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -66,6 +66,7 @@ enum class SuspendType : u32 {
66 Debug = 2, 66 Debug = 2,
67 Backtrace = 3, 67 Backtrace = 3,
68 Init = 4, 68 Init = 4,
69 System = 5,
69 70
70 Count, 71 Count,
71}; 72};
@@ -84,8 +85,9 @@ enum class ThreadState : u16 {
84 DebugSuspended = (1 << (2 + SuspendShift)), 85 DebugSuspended = (1 << (2 + SuspendShift)),
85 BacktraceSuspended = (1 << (3 + SuspendShift)), 86 BacktraceSuspended = (1 << (3 + SuspendShift)),
86 InitSuspended = (1 << (4 + SuspendShift)), 87 InitSuspended = (1 << (4 + SuspendShift)),
88 SystemSuspended = (1 << (5 + SuspendShift)),
87 89
88 SuspendFlagMask = ((1 << 5) - 1) << SuspendShift, 90 SuspendFlagMask = ((1 << 6) - 1) << SuspendShift,
89}; 91};
90DECLARE_ENUM_FLAG_OPERATORS(ThreadState); 92DECLARE_ENUM_FLAG_OPERATORS(ThreadState);
91 93
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 34b25be66..4f4b02fac 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -1204,39 +1204,48 @@ const Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() const {
1204 return *impl->hidbus_shared_mem; 1204 return *impl->hidbus_shared_mem;
1205} 1205}
1206 1206
1207void KernelCore::SuspendApplication(bool suspended) { 1207void KernelCore::SuspendEmulation(bool suspended) {
1208 const bool should_suspend{exception_exited || suspended}; 1208 const bool should_suspend{exception_exited || suspended};
1209 const auto activity = 1209 auto processes = GetProcessList();
1210 should_suspend ? Svc::ProcessActivity::Paused : Svc::ProcessActivity::Runnable;
1211 1210
1212 // Get the application process. 1211 for (auto& process : processes) {
1213 KScopedAutoObject<KProcess> process = ApplicationProcess(); 1212 KScopedLightLock ll{process->GetListLock()};
1214 if (process.IsNull()) { 1213
1215 return; 1214 for (auto& thread : process->GetThreadList()) {
1215 if (should_suspend) {
1216 thread.RequestSuspend(SuspendType::System);
1217 } else {
1218 thread.Resume(SuspendType::System);
1219 }
1220 }
1216 } 1221 }
1217 1222
1218 // Set the new activity. 1223 if (!should_suspend) {
1219 process->SetActivity(activity); 1224 return;
1225 }
1220 1226
1221 // Wait for process execution to stop. 1227 // Wait for process execution to stop.
1222 bool must_wait{should_suspend}; 1228 // KernelCore::SuspendEmulation must be called from locked context,
1223 1229 // or we could race another call, interfering with waiting.
1224 // KernelCore::SuspendApplication must be called from locked context, 1230 const auto TryWait = [&]() {
1225 // or we could race another call to SetActivity, interfering with waiting.
1226 while (must_wait) {
1227 KScopedSchedulerLock sl{*this}; 1231 KScopedSchedulerLock sl{*this};
1228 1232
1229 // Assume that all threads have finished running. 1233 for (auto& process : processes) {
1230 must_wait = false; 1234 for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) {
1231 1235 if (Scheduler(i).GetSchedulerCurrentThread()->GetOwnerProcess() ==
1232 for (auto i = 0; i < static_cast<s32>(Core::Hardware::NUM_CPU_CORES); ++i) { 1236 process.GetPointerUnsafe()) {
1233 if (Scheduler(i).GetSchedulerCurrentThread()->GetOwnerProcess() == 1237 // A thread has not finished running yet.
1234 process.GetPointerUnsafe()) { 1238 // Continue waiting.
1235 // A thread has not finished running yet. 1239 return false;
1236 // Continue waiting. 1240 }
1237 must_wait = true;
1238 } 1241 }
1239 } 1242 }
1243
1244 return true;
1245 };
1246
1247 while (!TryWait()) {
1248 // ...
1240 } 1249 }
1241} 1250}
1242 1251
@@ -1260,7 +1269,7 @@ bool KernelCore::IsShuttingDown() const {
1260 1269
1261void KernelCore::ExceptionalExitApplication() { 1270void KernelCore::ExceptionalExitApplication() {
1262 exception_exited = true; 1271 exception_exited = true;
1263 SuspendApplication(true); 1272 SuspendEmulation(true);
1264} 1273}
1265 1274
1266void KernelCore::EnterSVCProfile() { 1275void KernelCore::EnterSVCProfile() {
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 8ea5bed1c..57182c0c8 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -258,8 +258,8 @@ public:
258 /// Gets the shared memory object for HIDBus services. 258 /// Gets the shared memory object for HIDBus services.
259 const Kernel::KSharedMemory& GetHidBusSharedMem() const; 259 const Kernel::KSharedMemory& GetHidBusSharedMem() const;
260 260
261 /// Suspend/unsuspend application process. 261 /// Suspend/unsuspend emulated processes.
262 void SuspendApplication(bool suspend); 262 void SuspendEmulation(bool suspend);
263 263
264 /// Exceptional exit application process. 264 /// Exceptional exit application process.
265 void ExceptionalExitApplication(); 265 void ExceptionalExitApplication();
diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp
index b788fddd4..63dd12a47 100644
--- a/src/core/hle/service/am/service/application_functions.cpp
+++ b/src/core/hle/service/am/service/application_functions.cpp
@@ -15,6 +15,7 @@
15#include "core/hle/service/cmif_serialization.h" 15#include "core/hle/service/cmif_serialization.h"
16#include "core/hle/service/filesystem/filesystem.h" 16#include "core/hle/service/filesystem/filesystem.h"
17#include "core/hle/service/filesystem/save_data_controller.h" 17#include "core/hle/service/filesystem/save_data_controller.h"
18#include "core/hle/service/glue/glue_manager.h"
18#include "core/hle/service/ns/ns.h" 19#include "core/hle/service/ns/ns.h"
19#include "core/hle/service/sm/sm.h" 20#include "core/hle/service/sm/sm.h"
20 21
@@ -40,7 +41,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_
40 {26, D<&IApplicationFunctions::GetSaveDataSize>, "GetSaveDataSize"}, 41 {26, D<&IApplicationFunctions::GetSaveDataSize>, "GetSaveDataSize"},
41 {27, D<&IApplicationFunctions::CreateCacheStorage>, "CreateCacheStorage"}, 42 {27, D<&IApplicationFunctions::CreateCacheStorage>, "CreateCacheStorage"},
42 {28, D<&IApplicationFunctions::GetSaveDataSizeMax>, "GetSaveDataSizeMax"}, 43 {28, D<&IApplicationFunctions::GetSaveDataSizeMax>, "GetSaveDataSizeMax"},
43 {29, nullptr, "GetCacheStorageMax"}, 44 {29, D<&IApplicationFunctions::GetCacheStorageMax>, "GetCacheStorageMax"},
44 {30, D<&IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed>, "BeginBlockingHomeButtonShortAndLongPressed"}, 45 {30, D<&IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed>, "BeginBlockingHomeButtonShortAndLongPressed"},
45 {31, D<&IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed>, "EndBlockingHomeButtonShortAndLongPressed"}, 46 {31, D<&IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed>, "EndBlockingHomeButtonShortAndLongPressed"},
46 {32, D<&IApplicationFunctions::BeginBlockingHomeButton>, "BeginBlockingHomeButton"}, 47 {32, D<&IApplicationFunctions::BeginBlockingHomeButton>, "BeginBlockingHomeButton"},
@@ -267,6 +268,22 @@ Result IApplicationFunctions::GetSaveDataSizeMax(Out<u64> out_max_normal_size,
267 R_SUCCEED(); 268 R_SUCCEED();
268} 269}
269 270
271Result IApplicationFunctions::GetCacheStorageMax(Out<u32> out_cache_storage_index_max,
272 Out<u64> out_max_journal_size) {
273 LOG_DEBUG(Service_AM, "called");
274
275 std::vector<u8> nacp;
276 R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id));
277
278 auto raw_nacp = std::make_unique<FileSys::RawNACP>();
279 std::memcpy(raw_nacp.get(), nacp.data(), std::min(sizeof(*raw_nacp), nacp.size()));
280
281 *out_cache_storage_index_max = static_cast<u32>(raw_nacp->cache_storage_max_index);
282 *out_max_journal_size = static_cast<u64>(raw_nacp->cache_storage_data_and_journal_max_size);
283
284 R_SUCCEED();
285}
286
270Result IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(s64 unused) { 287Result IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(s64 unused) {
271 LOG_WARNING(Service_AM, "(STUBBED) called"); 288 LOG_WARNING(Service_AM, "(STUBBED) called");
272 289
diff --git a/src/core/hle/service/am/service/application_functions.h b/src/core/hle/service/am/service/application_functions.h
index 3548202f8..10025a152 100644
--- a/src/core/hle/service/am/service/application_functions.h
+++ b/src/core/hle/service/am/service/application_functions.h
@@ -40,6 +40,7 @@ private:
40 Result CreateCacheStorage(Out<u32> out_target_media, Out<u64> out_required_size, u16 index, 40 Result CreateCacheStorage(Out<u32> out_target_media, Out<u64> out_required_size, u16 index,
41 u64 normal_size, u64 journal_size); 41 u64 normal_size, u64 journal_size);
42 Result GetSaveDataSizeMax(Out<u64> out_max_normal_size, Out<u64> out_max_journal_size); 42 Result GetSaveDataSizeMax(Out<u64> out_max_normal_size, Out<u64> out_max_journal_size);
43 Result GetCacheStorageMax(Out<u32> out_cache_storage_index_max, Out<u64> out_max_journal_size);
43 Result BeginBlockingHomeButtonShortAndLongPressed(s64 unused); 44 Result BeginBlockingHomeButtonShortAndLongPressed(s64 unused);
44 Result EndBlockingHomeButtonShortAndLongPressed(); 45 Result EndBlockingHomeButtonShortAndLongPressed();
45 Result BeginBlockingHomeButton(s64 timeout_ns); 46 Result BeginBlockingHomeButton(s64 timeout_ns);
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
index 63c2d3a58..2d49f30c8 100644
--- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp
@@ -336,7 +336,7 @@ FSP_SRV::FSP_SRV(Core::System& system_)
336 {1012, nullptr, "GetFsStackUsage"}, 336 {1012, nullptr, "GetFsStackUsage"},
337 {1013, nullptr, "UnsetSaveDataRootPath"}, 337 {1013, nullptr, "UnsetSaveDataRootPath"},
338 {1014, nullptr, "OutputMultiProgramTagAccessLog"}, 338 {1014, nullptr, "OutputMultiProgramTagAccessLog"},
339 {1016, nullptr, "FlushAccessLogOnSdCard"}, 339 {1016, &FSP_SRV::FlushAccessLogOnSdCard, "FlushAccessLogOnSdCard"},
340 {1017, nullptr, "OutputApplicationInfoAccessLog"}, 340 {1017, nullptr, "OutputApplicationInfoAccessLog"},
341 {1018, nullptr, "SetDebugOption"}, 341 {1018, nullptr, "SetDebugOption"},
342 {1019, nullptr, "UnsetDebugOption"}, 342 {1019, nullptr, "UnsetDebugOption"},
@@ -706,6 +706,13 @@ void FSP_SRV::GetProgramIndexForAccessLog(HLERequestContext& ctx) {
706 rb.Push(access_log_program_index); 706 rb.Push(access_log_program_index);
707} 707}
708 708
709void FSP_SRV::FlushAccessLogOnSdCard(HLERequestContext& ctx) {
710 LOG_DEBUG(Service_FS, "(STUBBED) called");
711
712 IPC::ResponseBuilder rb{ctx, 2};
713 rb.Push(ResultSuccess);
714}
715
709void FSP_SRV::GetCacheStorageSize(HLERequestContext& ctx) { 716void FSP_SRV::GetCacheStorageSize(HLERequestContext& ctx) {
710 IPC::RequestParser rp{ctx}; 717 IPC::RequestParser rp{ctx};
711 const auto index{rp.Pop<s32>()}; 718 const auto index{rp.Pop<s32>()};
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.h b/src/core/hle/service/filesystem/fsp/fsp_srv.h
index 26980af99..59406e6f9 100644
--- a/src/core/hle/service/filesystem/fsp/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp/fsp_srv.h
@@ -58,6 +58,7 @@ private:
58 void SetGlobalAccessLogMode(HLERequestContext& ctx); 58 void SetGlobalAccessLogMode(HLERequestContext& ctx);
59 void GetGlobalAccessLogMode(HLERequestContext& ctx); 59 void GetGlobalAccessLogMode(HLERequestContext& ctx);
60 void OutputAccessLogToSdCard(HLERequestContext& ctx); 60 void OutputAccessLogToSdCard(HLERequestContext& ctx);
61 void FlushAccessLogOnSdCard(HLERequestContext& ctx);
61 void GetProgramIndexForAccessLog(HLERequestContext& ctx); 62 void GetProgramIndexForAccessLog(HLERequestContext& ctx);
62 void OpenMultiCommitManager(HLERequestContext& ctx); 63 void OpenMultiCommitManager(HLERequestContext& ctx);
63 void GetCacheStorageSize(HLERequestContext& ctx); 64 void GetCacheStorageSize(HLERequestContext& ctx);
diff --git a/src/core/hle/service/glue/time/manager.cpp b/src/core/hle/service/glue/time/manager.cpp
index cad755fa7..059ac3fc9 100644
--- a/src/core/hle/service/glue/time/manager.cpp
+++ b/src/core/hle/service/glue/time/manager.cpp
@@ -186,6 +186,10 @@ TimeManager::TimeManager(Core::System& system)
186 } 186 }
187} 187}
188 188
189TimeManager::~TimeManager() {
190 ResetTimeZoneBinary();
191}
192
189Result TimeManager::SetupStandardSteadyClockCore() { 193Result TimeManager::SetupStandardSteadyClockCore() {
190 Common::UUID external_clock_source_id{}; 194 Common::UUID external_clock_source_id{};
191 auto res = m_set_sys->GetExternalSteadyClockSourceId(&external_clock_source_id); 195 auto res = m_set_sys->GetExternalSteadyClockSourceId(&external_clock_source_id);
diff --git a/src/core/hle/service/glue/time/manager.h b/src/core/hle/service/glue/time/manager.h
index 1de93f8f9..bb4b65049 100644
--- a/src/core/hle/service/glue/time/manager.h
+++ b/src/core/hle/service/glue/time/manager.h
@@ -26,6 +26,7 @@ namespace Service::Glue::Time {
26class TimeManager { 26class TimeManager {
27public: 27public:
28 explicit TimeManager(Core::System& system); 28 explicit TimeManager(Core::System& system);
29 ~TimeManager();
29 30
30 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; 31 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
31 32
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index b84b57d92..d8921e565 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -117,9 +117,9 @@ bool StandardVmCallbacks::IsAddressInRange(VAddr in) const {
117 (in < metadata.heap_extents.base || 117 (in < metadata.heap_extents.base ||
118 in >= metadata.heap_extents.base + metadata.heap_extents.size) && 118 in >= metadata.heap_extents.base + metadata.heap_extents.size) &&
119 (in < metadata.alias_extents.base || 119 (in < metadata.alias_extents.base ||
120 in >= metadata.heap_extents.base + metadata.alias_extents.size) && 120 in >= metadata.alias_extents.base + metadata.alias_extents.size) &&
121 (in < metadata.aslr_extents.base || 121 (in < metadata.aslr_extents.base ||
122 in >= metadata.heap_extents.base + metadata.aslr_extents.size)) { 122 in >= metadata.aslr_extents.base + metadata.aslr_extents.size)) {
123 LOG_DEBUG(CheatEngine, 123 LOG_DEBUG(CheatEngine,
124 "Cheat attempting to access memory at invalid address={:016X}, if this " 124 "Cheat attempting to access memory at invalid address={:016X}, if this "
125 "persists, " 125 "persists, "