os: refactor/rewrite entire namespace.
This commit is contained in:
@@ -30,8 +30,8 @@ namespace ams::mitm::fs {
|
||||
constexpr const char AtmosphereHblWebContentDir[] = "/atmosphere/hbl_html/";
|
||||
constexpr const char ProgramWebContentDir[] = "/manual_html/";
|
||||
|
||||
os::Mutex g_data_storage_lock;
|
||||
os::Mutex g_storage_cache_lock;
|
||||
os::Mutex g_data_storage_lock(false);
|
||||
os::Mutex g_storage_cache_lock(false);
|
||||
std::unordered_map<u64, std::weak_ptr<IStorageInterface>> g_storage_cache;
|
||||
|
||||
std::shared_ptr<IStorageInterface> GetStorageCacheEntry(ncm::ProgramId program_id) {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
namespace {
|
||||
|
||||
os::Mutex g_boot0_access_mutex;
|
||||
os::Mutex g_boot0_access_mutex(false);
|
||||
u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset];
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,11 @@ namespace ams::mitm::fs {
|
||||
|
||||
namespace {
|
||||
|
||||
os::Mutex g_mq_lock;
|
||||
os::Mutex g_mq_lock(false);
|
||||
bool g_started_req_thread;
|
||||
os::MessageQueue g_req_mq(1);
|
||||
os::MessageQueue g_ack_mq(1);
|
||||
uintptr_t g_mq_storage[2];
|
||||
os::MessageQueue g_req_mq(g_mq_storage + 0, 1);
|
||||
os::MessageQueue g_ack_mq(g_mq_storage + 1, 1);
|
||||
|
||||
void RomfsInitializerThreadFunction(void *arg) {
|
||||
while (true) {
|
||||
@@ -38,14 +39,16 @@ namespace ams::mitm::fs {
|
||||
}
|
||||
|
||||
constexpr size_t RomfsInitializerThreadStackSize = 0x8000;
|
||||
constexpr int RomfsInitializerThreadPriority = 44;
|
||||
os::StaticThread<RomfsInitializerThreadStackSize> g_romfs_initializer_thread(&RomfsInitializerThreadFunction, nullptr, RomfsInitializerThreadPriority);
|
||||
constexpr int RomfsInitializerThreadPriority = 16;
|
||||
os::ThreadType g_romfs_initializer_thread;
|
||||
alignas(os::ThreadStackAlignment) u8 g_romfs_initializer_thread_stack[RomfsInitializerThreadStackSize];
|
||||
|
||||
void RequestInitializeStorage(uintptr_t storage_uptr) {
|
||||
std::scoped_lock lk(g_mq_lock);
|
||||
|
||||
if (!g_started_req_thread) {
|
||||
R_ABORT_UNLESS(g_romfs_initializer_thread.Start());
|
||||
if (AMS_UNLIKELY(!g_started_req_thread)) {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_romfs_initializer_thread), RomfsInitializerThreadFunction, nullptr, g_romfs_initializer_thread_stack, sizeof(g_romfs_initializer_thread_stack), RomfsInitializerThreadPriority));
|
||||
os::StartThread(std::addressof(g_romfs_initializer_thread));
|
||||
g_started_req_thread = true;
|
||||
}
|
||||
|
||||
@@ -59,7 +62,7 @@ namespace ams::mitm::fs {
|
||||
|
||||
using namespace ams::fs;
|
||||
|
||||
LayeredRomfsStorage::LayeredRomfsStorage(std::unique_ptr<IStorage> s_r, std::unique_ptr<IStorage> f_r, ncm::ProgramId pr_id) : storage_romfs(std::move(s_r)), file_romfs(std::move(f_r)), initialize_event(false, false), program_id(std::move(pr_id)), is_initialized(false), started_initialize(false) {
|
||||
LayeredRomfsStorage::LayeredRomfsStorage(std::unique_ptr<IStorage> s_r, std::unique_ptr<IStorage> f_r, ncm::ProgramId pr_id) : storage_romfs(std::move(s_r)), file_romfs(std::move(f_r)), initialize_event(os::EventClearMode_ManualClear), program_id(std::move(pr_id)), is_initialized(false), started_initialize(false) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ams::mitm::fs {
|
||||
constexpr size_t ThreadStackSize = mitm::ModuleTraits<fs::MitmModule>::StackSize;
|
||||
alignas(os::MemoryPageSize) u8 g_extra_thread_stacks[NumExtraThreads][ThreadStackSize];
|
||||
|
||||
os::Thread g_extra_threads[NumExtraThreads];
|
||||
os::ThreadType g_extra_threads[NumExtraThreads];
|
||||
|
||||
void LoopServerThread(void *arg) {
|
||||
/* Loop forever, servicing our services. */
|
||||
@@ -49,16 +49,16 @@ namespace ams::mitm::fs {
|
||||
void ProcessForServerOnAllThreads() {
|
||||
/* Initialize threads. */
|
||||
if constexpr (NumExtraThreads > 0) {
|
||||
const s32 priority = os::GetCurrentThreadPriority();
|
||||
const s32 priority = os::GetThreadCurrentPriority(os::GetCurrentThread());
|
||||
for (size_t i = 0; i < NumExtraThreads; i++) {
|
||||
R_ABORT_UNLESS(g_extra_threads[i].Initialize(LoopServerThread, nullptr, g_extra_thread_stacks[i], ThreadStackSize, priority));
|
||||
R_ABORT_UNLESS(os::CreateThread(g_extra_threads + i, LoopServerThread, nullptr, g_extra_thread_stacks[i], ThreadStackSize, priority));
|
||||
}
|
||||
}
|
||||
|
||||
/* Start extra threads. */
|
||||
if constexpr (NumExtraThreads > 0) {
|
||||
for (size_t i = 0; i < NumExtraThreads; i++) {
|
||||
R_ABORT_UNLESS(g_extra_threads[i].Start());
|
||||
os::StartThread(g_extra_threads + i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace ams::mitm::fs {
|
||||
/* Wait for extra threads to finish. */
|
||||
if constexpr (NumExtraThreads > 0) {
|
||||
for (size_t i = 0; i < NumExtraThreads; i++) {
|
||||
R_ABORT_UNLESS(g_extra_threads[i].Join());
|
||||
os::WaitThread(g_extra_threads + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
|
||||
namespace ams::mitm::fs {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 43);
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 15);
|
||||
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace ams::mitm::fs {
|
||||
}
|
||||
}
|
||||
|
||||
os::Mutex g_fs_romfs_path_lock;
|
||||
os::Mutex g_fs_romfs_path_lock(false);
|
||||
char g_fs_romfs_path_buffer[fs::EntryNameLengthMax + 1];
|
||||
|
||||
NOINLINE void OpenFileSystemRomfsDirectory(FsDir *out, ncm::ProgramId program_id, BuildDirectoryContext *parent, fs::OpenDirectoryMode mode, FsFileSystem *fs) {
|
||||
|
||||
Reference in New Issue
Block a user