From e41b234dc4fe07207f5df952ebd9eb31e7724c33 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 26 Aug 2019 16:04:16 +0300 Subject: [PATCH] Use g_fxo for cellSysCache --- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 32 ++++++++++++++------------ rpcs3/Emu/Cell/Modules/cellSysutil.h | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index 79e54ab41a..adae744a18 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -70,6 +70,12 @@ extern void sysutil_send_system_cmd(u64 status, u64 param) } } +struct syscache +{ + atomic_t state = 0; + std::string cache_path; +}; + template <> void fmt_class_string::format(std::string& out, u64 arg) { @@ -307,27 +313,21 @@ s32 cellSysCacheClear() { cellSysutil.warning("cellSysCacheClear()"); - // Get the param as a shared ptr, then decipher the cacheid from it - // (Instead of assuming naively that the param is passed as argument) - std::shared_ptr param = fxm::get(); + const auto cache = g_fxo->get(); - // Unit test for param ptr, since it may be null at the time of get() - if (!param) + if (!cache->state) { return CELL_SYSCACHE_ERROR_NOTMOUNTED; } - const std::string& cache_id = param->cacheId; + std::string local_dir = vfs::get(cache->cache_path); - const std::string& cache_path = "/dev_hdd1/cache/" + cache_id; - const std::string& dir_path = vfs::get(cache_path); - - if (!fs::exists(dir_path) || !fs::is_dir(dir_path)) + if (!fs::exists(local_dir) || !fs::is_dir(local_dir)) { return CELL_SYSCACHE_ERROR_ACCESS_ERROR; } - fs::remove_all(dir_path, false); + fs::remove_all(local_dir, false); return CELL_SYSCACHE_RET_OK_CLEARED; } @@ -336,22 +336,24 @@ s32 cellSysCacheMount(vm::ptr param) { cellSysutil.warning("cellSysCacheMount(param=*0x%x)", param); + const auto cache = g_fxo->get(); + if (!param || !memchr(param->cacheId, '\0', CELL_SYSCACHE_ID_SIZE)) { return CELL_SYSCACHE_ERROR_PARAM; } - const std::string& cache_id = param->cacheId; - const std::string& cache_path = "/dev_hdd1/cache/" + cache_id; + std::string cache_id = param->cacheId; + std::string cache_path = "/dev_hdd1/cache/" + cache_id; strcpy_trunc(param->getCachePath, cache_path); - // TODO: implement (what?) - fxm::make_always(*param); if (!fs::create_dir(vfs::get(cache_path)) && !cache_id.empty()) { return CELL_SYSCACHE_RET_OK_RELAYED; } + cache->cache_path = std::move(cache_path); + cache->state = 1; return CELL_SYSCACHE_RET_OK_CLEARED; } diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.h b/rpcs3/Emu/Cell/Modules/cellSysutil.h index 47e4af7a01..1890d54752 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.h +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.h @@ -194,7 +194,7 @@ struct CellSysCacheParam { char cacheId[CELL_SYSCACHE_ID_SIZE]; char getCachePath[CELL_SYSCACHE_PATH_MAX]; - vm::ptr reserved; + vm::bptr reserved; }; extern void sysutil_register_cb(std::function&&);