stratosphere: use SdkMutex/SdkRecursiveMutex over Mutex

This commit is contained in:
Michael Scire
2021-09-29 22:52:50 -07:00
parent a4fe1bb5d8
commit 41ab4c2c68
70 changed files with 188 additions and 645 deletions

View File

@@ -501,18 +501,18 @@ namespace ams::mitm {
crypto::EncryptAes128Ctr(dst, dst_size, entropy.data, crypto::Aes128CtrEncryptor::KeySize, entropy.data + crypto::Aes128CtrEncryptor::KeySize, crypto::Aes128CtrEncryptor::IvSize, dst, dst_size);
}
alignas(os::MemoryPageSize) CalibrationInfo g_calibration_info = {};
alignas(os::MemoryPageSize) CalibrationInfo g_blank_calibration_info = {};
alignas(os::MemoryPageSize) SecureCalibrationInfoBackup g_secure_calibration_info_backup = {};
alignas(os::MemoryPageSize) constinit CalibrationInfo g_calibration_info = {};
alignas(os::MemoryPageSize) constinit CalibrationInfo g_blank_calibration_info = {};
alignas(os::MemoryPageSize) constinit SecureCalibrationInfoBackup g_secure_calibration_info_backup = {};
util::optional<ams::fs::FileStorage> g_prodinfo_backup_file;
util::optional<ams::fs::MemoryStorage> g_blank_prodinfo_storage;
util::optional<ams::fs::MemoryStorage> g_fake_secure_backup_storage;
constinit util::optional<ams::fs::FileStorage> g_prodinfo_backup_file;
constinit util::optional<ams::fs::MemoryStorage> g_blank_prodinfo_storage;
constinit util::optional<ams::fs::MemoryStorage> g_fake_secure_backup_storage;
bool g_allow_writes = false;
bool g_has_secure_backup = false;
constinit bool g_allow_writes = false;
constinit bool g_has_secure_backup = false;
os::Mutex g_prodinfo_management_lock(false);
constinit os::SdkMutex g_prodinfo_management_lock;
}

View File

@@ -22,7 +22,7 @@ namespace ams::mitm::fs {
namespace {
os::Mutex g_cal0_access_mutex(false);
constinit os::SdkMutex g_cal0_access_mutex;
}
Result CalibrationBinaryStorage::Read(s64 offset, void *_buffer, size_t size) {

View File

@@ -22,9 +22,9 @@ namespace ams::mitm::fs {
namespace {
os::Mutex g_mq_lock(false);
bool g_started_req_thread;
uintptr_t g_mq_storage[2];
constinit os::SdkMutex g_mq_lock;
constinit bool g_started_req_thread;
constinit 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);

View File

@@ -258,8 +258,8 @@ namespace ams::mitm::fs {
}
}
os::Mutex g_fs_romfs_path_lock(false);
char g_fs_romfs_path_buffer[fs::EntryNameLengthMax + 1];
constinit os::SdkMutex g_fs_romfs_path_lock;
constinit 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) {
std::scoped_lock lk(g_fs_romfs_path_lock);

View File

@@ -23,15 +23,19 @@ namespace ams::mitm::settings {
namespace {
os::Mutex g_firmware_version_lock(false);
bool g_cached_firmware_version;
settings::FirmwareVersion g_firmware_version;
settings::FirmwareVersion g_ams_firmware_version;
constinit os::SdkMutex g_firmware_version_lock;
constinit bool g_cached_firmware_version;
constinit settings::FirmwareVersion g_firmware_version;
constinit settings::FirmwareVersion g_ams_firmware_version;
void CacheFirmwareVersion() {
if (AMS_LIKELY(g_cached_firmware_version)) {
return;
}
std::scoped_lock lk(g_firmware_version_lock);
if (AMS_LIKELY(g_cached_firmware_version)) {
if (AMS_UNLIKELY(g_cached_firmware_version)) {
return;
}

View File

@@ -20,9 +20,9 @@ namespace ams::mitm::sysupdater {
class SystemUpdateApplyManager {
private:
os::Mutex apply_mutex;
os::SdkMutex apply_mutex;
public:
constexpr SystemUpdateApplyManager() : apply_mutex(false) { /* ... */ }
constexpr SystemUpdateApplyManager() : apply_mutex() { /* ... */ }
Result ApplyPackageTask(ncm::PackageSystemDowngradeTask *task);
};